Version 21.77.3: Dec 29, 2021 Changing Str_BuildString for asprintf.

This commit is contained in:
acanas 2021-12-29 23:41:26 +01:00
parent f8391edd6c
commit 4be9e2a7f1
21 changed files with 240 additions and 146 deletions

View File

@ -1205,7 +1205,8 @@ void HTM_INPUT_BUTTON (const char *Name,const char *Value,const char *Attr)
Attr);
}
void HTM_INPUT_IMAGE (const char *URL,const char *Icon,const char *Title,const char *Class)
void HTM_INPUT_IMAGE (const char *URL,const char *Icon,
const char *Title,const char *Class)
{
HTM_TxtF ("<input type=\"image\" src=\"%s",URL);
if (Icon)

View File

@ -134,7 +134,8 @@ void HTM_INPUT_FILE (const char *Name,const char *Accept,
HTM_SubmitOnChange_t SubmitOnChange,
const char *fmt,...);
void HTM_INPUT_BUTTON (const char *Name,const char *Value,const char *Attr);
void HTM_INPUT_IMAGE (const char *URL,const char *Icon,const char *Title,const char *Class);
void HTM_INPUT_IMAGE (const char *URL,const char *Icon,
const char *Title,const char *Class);
void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,
const char *AutoComplete,bool Required,
const char *fmt,...);

View File

@ -25,8 +25,10 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <ctype.h> // For isalnum, isdigit, etc.
#include <stdbool.h> // For boolean type
#include <stdio.h> // For asprintf
#include <stdlib.h> // For exit, system, malloc, free, rand, etc.
#include <string.h> // For string functions
@ -510,6 +512,7 @@ static void ID_ShowFormChangeUsrID (bool ItsMe,bool IShouldFillInID)
extern const char *Txt_Add_this_ID;
extern const char *Txt_The_ID_is_used_in_order_to_facilitate_;
unsigned NumID;
char *Title;
static const struct
{
Act_Action_t Remove;
@ -576,13 +579,15 @@ static void ID_ShowFormChangeUsrID (bool ItsMe,bool IShouldFillInID)
}
/* User's ID */
if (asprintf (&Title,UsrDat->IDs.List[NumID].Confirmed ? Txt_ID_X_confirmed :
Txt_ID_X_not_confirmed,
UsrDat->IDs.List[NumID].ID) < 0)
Err_NotEnoughMemoryExit ();
HTM_SPAN_Begin ("class=\"%s\" title=\"%s\"",
UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" :
"USR_ID_NC",
Str_BuildString (UsrDat->IDs.List[NumID].Confirmed ? Txt_ID_X_confirmed :
Txt_ID_X_not_confirmed,
UsrDat->IDs.List[NumID].ID));
Str_FreeStrings ();
Title);
free (Title);
HTM_Txt (UsrDat->IDs.List[NumID].ID);
HTM_Txt (UsrDat->IDs.List[NumID].Confirmed ? "&check;" :
"");

View File

@ -602,10 +602,11 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/
#define Log_PLATFORM_VERSION "SWAD 21.77.2 (2021-12-29)"
#define Log_PLATFORM_VERSION "SWAD 21.77.3 (2021-12-29)"
#define CSS_FILE "swad21.77.1.css"
#define JS_FILE "swad21.67.4.js"
/*
Version 21.77.3: Dec 29, 2021 Changing Str_BuildString for asprintf. (322287 lines)
Version 21.77.2: Dec 29, 2021 Changing Str_BuildString for asprintf. (322199 lines)
Version 21.77.1: Dec 29, 2021 Working on design of dark theme. (322161 lines)
Version 21.77: Dec 29, 2021 Animated recycle icon is changed by static icon. (322250 lines)

View File

@ -25,8 +25,10 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdbool.h> // For boolean type
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For free
#include <string.h> // For string functions

View File

@ -25,11 +25,14 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdbool.h> // For boolean type
#include <stdio.h> // For asprintf
#include "swad_database.h"
#include "swad_degree_config.h"
#include "swad_degree_database.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_help.h"

View File

@ -25,8 +25,10 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdbool.h> // For boolean type
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
@ -104,6 +106,7 @@ void Dpt_SeeDepts (void)
extern const char *Txt_Other_departments;
extern const char *Txt_Department_unspecified;
struct Dpt_Departments Departments;
char *Title;
Dpt_Order_t Order;
unsigned NumDpt;
unsigned NumTchsInsInOtherDpts;
@ -123,17 +126,14 @@ void Dpt_SeeDepts (void)
Dpt_GetListDepartments (&Departments,Gbl.Hierarchy.Ins.InsCod);
/***** Begin box and table *****/
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
Box_BoxTableBegin (NULL,Str_BuildString (Txt_Departments_of_INSTITUTION_X,
Gbl.Hierarchy.Ins.FullName),
Dpt_PutIconToEditDpts,NULL,
Hlp_INSTITUTION_Departments,Box_NOT_CLOSABLE,2);
else
Box_BoxTableBegin (NULL,Str_BuildString (Txt_Departments_of_INSTITUTION_X,
Gbl.Hierarchy.Ins.FullName),
NULL,NULL,
Hlp_INSTITUTION_Departments,Box_NOT_CLOSABLE,2);
Str_FreeStrings ();
if (asprintf (&Title,Txt_Departments_of_INSTITUTION_X,Gbl.Hierarchy.Ins.FullName) < 0)
Err_NotEnoughMemoryExit ();
Box_BoxTableBegin (NULL,Title,
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ? Dpt_PutIconToEditDpts :
NULL,
NULL,
Hlp_INSTITUTION_Departments,Box_NOT_CLOSABLE,2);
free (Title);
/***** Write heading *****/
HTM_TR_Begin (NULL);
@ -271,6 +271,7 @@ static void Dpt_EditDepartmentsInternal (void)
extern const char *Hlp_INSTITUTION_Departments_edit;
extern const char *Txt_Departments_of_INSTITUTION_X;
struct Dpt_Departments Departments;
char *Title;
/***** Trivial check *****/
if (Gbl.Hierarchy.Ins.InsCod <= 0) // An institution must be selected
@ -286,11 +287,11 @@ static void Dpt_EditDepartmentsInternal (void)
Dpt_GetListDepartments (&Departments,Gbl.Hierarchy.Ins.InsCod);
/***** Begin box *****/
Box_BoxBegin (NULL,Str_BuildString (Txt_Departments_of_INSTITUTION_X,
Gbl.Hierarchy.Ins.FullName),
NULL,NULL,
if (asprintf (&Title,Txt_Departments_of_INSTITUTION_X,Gbl.Hierarchy.Ins.FullName) < 0)
Err_NotEnoughMemoryExit ();
Box_BoxBegin (NULL,Title,NULL,NULL,
Hlp_INSTITUTION_Departments_edit,Box_NOT_CLOSABLE);
Str_FreeStrings ();
free (Title);
/***** Put a form to create a new department *****/
Dpt_PutFormToCreateDepartment ();

View File

@ -184,6 +184,7 @@ void ExaRes_ShowMyResultsInExa (void)
struct Exa_Exams Exams;
struct Exa_Exam Exam;
struct ExaSes_Session Session;
char *Title;
/***** Reset exams context *****/
Exa_ResetExams (&Exams);
@ -205,10 +206,10 @@ void ExaRes_ShowMyResultsInExa (void)
false); // Do not put form to start new session
/***** List my sessions results in exam *****/
ExaRes_ShowResultsBegin (&Exams,
Str_BuildString (Txt_Results_of_exam_X,Exam.Title),
false); // Do not list exams to select
Str_FreeStrings ();
if (asprintf (&Title,Txt_Results_of_exam_X,Exam.Title) < 0)
Err_NotEnoughMemoryExit ();
ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select
free (Title);
ExaRes_ListMyResultsInExa (&Exams,Exam.ExaCod);
ExaRes_ShowResultsEnd ();
@ -236,6 +237,7 @@ void ExaRes_ShowMyResultsInSes (void)
struct Exa_Exams Exams;
struct Exa_Exam Exam;
struct ExaSes_Session Session;
char *Title;
/***** Reset exams context *****/
Exa_ResetExams (&Exams);
@ -258,10 +260,10 @@ void ExaRes_ShowMyResultsInSes (void)
false); // Do not put form to start new session
/***** List my sessions results in session *****/
ExaRes_ShowResultsBegin (&Exams,Str_BuildString (Txt_Results_of_session_X,
Session.Title),
false); // Do not list exams to select
Str_FreeStrings ();
if (asprintf (&Title,Txt_Results_of_session_X,Session.Title) < 0)
Err_NotEnoughMemoryExit ();
ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select
free (Title);
ExaRes_ListMyResultsInSes (&Exams,Session.SesCod);
ExaRes_ShowResultsEnd ();
@ -387,6 +389,7 @@ void ExaRes_ShowAllResultsInExa (void)
struct Exa_Exams Exams;
struct Exa_Exam Exam;
struct ExaSes_Session Session;
char *Title;
/***** Reset exams context *****/
Exa_ResetExams (&Exams);
@ -406,10 +409,10 @@ void ExaRes_ShowAllResultsInExa (void)
false); // Do not put form to start new session
/***** List sessions results in exam *****/
ExaRes_ShowResultsBegin (&Exams,
Str_BuildString (Txt_Results_of_exam_X,Exam.Title),
false); // Do not list exams to select
Str_FreeStrings ();
if (asprintf (&Title,Txt_Results_of_exam_X,Exam.Title) < 0)
Err_NotEnoughMemoryExit ();
ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select
free (Title);
ExaRes_ListAllResultsInExa (&Exams,Exam.ExaCod);
ExaRes_ShowResultsEnd ();
@ -459,6 +462,7 @@ void ExaRes_ShowAllResultsInSes (void)
struct Exa_Exams Exams;
struct Exa_Exam Exam;
struct ExaSes_Session Session;
char *Title;
/***** Reset exams context *****/
Exa_ResetExams (&Exams);
@ -483,10 +487,10 @@ void ExaRes_ShowAllResultsInSes (void)
false); // Do not put form to start new session
/***** List sessions results in session *****/
ExaRes_ShowResultsBegin (&Exams,
Str_BuildString (Txt_Results_of_session_X,Session.Title),
false); // Do not list exams to select
Str_FreeStrings ();
if (asprintf (&Title,Txt_Results_of_session_X,Session.Title) < 0)
Err_NotEnoughMemoryExit ();
ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select
free (Title);
ExaRes_ListAllResultsInSes (&Exams,Session.SesCod);
ExaRes_ShowResultsEnd ();

View File

@ -722,6 +722,7 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
MYSQL_ROW row;
char *Anchor;
char StrSetInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char *Title;
/***** Trivial check *****/
if (!NumSets)
@ -787,12 +788,13 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
/* Put icon to move up the question */
if (ICanEditSets && Set.SetInd > 1)
{
if (asprintf (&Title,Txt_Move_up_X,StrSetInd) < 0)
Err_NotEnoughMemoryExit ();
Lay_PutContextualLinkOnlyIcon (ActUp_ExaSet,Anchor,
ExaSet_PutParamsOneSet,Exams,
"arrow-up.svg",Ico_BLACK,
Str_BuildString (Txt_Move_up_X,
StrSetInd));
Str_FreeStrings ();
Title);
free (Title);
}
else
Ico_PutIconOff ("arrow-up.svg",Ico_BLACK,
@ -801,12 +803,13 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
/* Put icon to move down the set */
if (ICanEditSets && Set.SetInd < MaxSetInd)
{
if (asprintf (&Title,Txt_Move_down_X,StrSetInd) < 0)
Err_NotEnoughMemoryExit ();
Lay_PutContextualLinkOnlyIcon (ActDwnExaSet,Anchor,
ExaSet_PutParamsOneSet,Exams,
"arrow-down.svg",Ico_BLACK,
Str_BuildString (Txt_Move_down_X,
StrSetInd));
Str_FreeStrings ();
Title);
free (Title);
}
else
Ico_PutIconOff ("arrow-down.svg",Ico_BLACK,

View File

@ -448,14 +448,24 @@ static void Fig_GetAndShowNumUsrsInCrss (Rol_Role_t Role)
extern const char *Txt_Total;
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
long Cod = Sco_GetCurrentCod ();
char *Class = (Role == Rol_UNK) ? Str_BuildString ("RB %s LINE_TOP",
The_ClassDatStrong[Gbl.Prefs.Theme]) :
Str_BuildString ("RB %s",
The_ClassDat[Gbl.Prefs.Theme]);
unsigned Roles = (Role == Rol_UNK) ? ((1 << Rol_STD) |
(1 << Rol_NET) |
(1 << Rol_TCH)) :
(1 << Role);
char *Class;
unsigned Roles;
/***** Initializations depending on role *****/
if (Role == Rol_UNK)
{
if (asprintf (&Class,"RB %s LINE_TOP",The_ClassDatStrong[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
Roles = (1 << Rol_STD) |
(1 << Rol_NET) |
(1 << Rol_TCH);
}
else
{
if (asprintf (&Class,"RB %s",The_ClassDat[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
Roles = (1 << Role);
}
/***** Write the total number of users *****/
HTM_TR_Begin (NULL);
@ -480,7 +490,7 @@ static void Fig_GetAndShowNumUsrsInCrss (Rol_Role_t Role)
HTM_TR_End ();
Str_FreeStrings ();
free (Class);
}
/*****************************************************************************/
@ -491,7 +501,10 @@ static void Fig_GetAndShowNumUsrsNotBelongingToAnyCrs (void)
{
extern const char *The_ClassDat[The_NUM_THEMES];
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
char *Class = Str_BuildString ("%s RB",The_ClassDat[Gbl.Prefs.Theme]);
char *Class;
if (asprintf (&Class,"%s RB",The_ClassDat[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
/***** Write the total number of users not belonging to any course *****/
HTM_TR_Begin (NULL);
@ -514,7 +527,7 @@ static void Fig_GetAndShowNumUsrsNotBelongingToAnyCrs (void)
HTM_TR_End ();
Str_FreeStrings ();
free (Class);
}
/*****************************************************************************/
@ -889,6 +902,7 @@ static void Fig_GetAndShowHierarchyTotal (void)
{
extern const char *The_ClassDatStrong[The_NUM_THEMES];
extern const char *Txt_Total;
char *ClassTxt;
unsigned NumCtysTotal = 1;
unsigned NumInssTotal = 1;
unsigned NumCtrsTotal = 1;
@ -931,15 +945,15 @@ static void Fig_GetAndShowHierarchyTotal (void)
}
/***** Write total number of elements *****/
Fig_ShowHierarchyRow ("",Txt_Total,
Str_BuildString ("%s LINE_TOP",
The_ClassDatStrong[Gbl.Prefs.Theme]),
if (asprintf (&ClassTxt,"%s LINE_TOP",The_ClassDatStrong[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
Fig_ShowHierarchyRow ("",Txt_Total,ClassTxt,
(int) NumCtysTotal,
(int) NumInssTotal,
(int) NumCtrsTotal,
(int) NumDegsTotal,
(int) NumCrssTotal);
Str_FreeStrings ();
free (ClassTxt);
}
/*****************************************************************************/
@ -1565,9 +1579,17 @@ static void Fig_WriteRowStatsFileBrowsers1 (const char *NameOfFileZones,
char StrNumGrps[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char StrNumUsrs[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1];
const char *Class = (FileZone == Brw_UNKNOWN) ? Str_BuildString ("%s LINE_TOP",
The_ClassDatStrong[Gbl.Prefs.Theme]) :
The_ClassDat[Gbl.Prefs.Theme];
char *Cl;
const char *Class;
if (FileZone == Brw_UNKNOWN)
{
if (asprintf (&Cl,"%s LINE_TOP",The_ClassDatStrong[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
Class = Cl;
}
else
Class = The_ClassDat[Gbl.Prefs.Theme];
Fil_WriteFileSizeFull ((double) SizeOfFileZones->Size,FileSizeStr);
@ -1625,7 +1647,8 @@ static void Fig_WriteRowStatsFileBrowsers1 (const char *NameOfFileZones,
HTM_TR_End ();
Str_FreeStrings ();
if (FileZone == Brw_UNKNOWN)
free (Cl);
}
static void Fig_WriteRowStatsFileBrowsers2 (const char *NameOfFileZones,
@ -1637,9 +1660,17 @@ static void Fig_WriteRowStatsFileBrowsers2 (const char *NameOfFileZones,
char StrNumFoldersPerCrs[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char StrNumFilesPerCrs[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char FileSizePerCrsStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1];
const char *Class = (FileZone == Brw_UNKNOWN) ? Str_BuildString ("%s LINE_TOP",
The_ClassDatStrong[Gbl.Prefs.Theme]) :
The_ClassDat[Gbl.Prefs.Theme];
char *Cl;
const char *Class;
if (FileZone == Brw_UNKNOWN)
{
if (asprintf (&Cl,"%s LINE_TOP",The_ClassDatStrong[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
Class = Cl;
}
else
Class = The_ClassDat[Gbl.Prefs.Theme];
if (SizeOfFileZones->NumCrss == -1) // Not applicable
{
@ -1683,7 +1714,8 @@ static void Fig_WriteRowStatsFileBrowsers2 (const char *NameOfFileZones,
HTM_TR_End ();
Str_FreeStrings ();
if (FileZone == Brw_UNKNOWN)
free (Cl);
}
static void Fig_WriteRowStatsFileBrowsers3 (const char *NameOfFileZones,
@ -1695,9 +1727,17 @@ static void Fig_WriteRowStatsFileBrowsers3 (const char *NameOfFileZones,
char StrNumFoldersPerUsr[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char StrNumFilesPerUsr[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char FileSizePerUsrStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1];
const char *Class = (FileZone == Brw_UNKNOWN) ? Str_BuildString ("%s LINE_TOP",
The_ClassDatStrong[Gbl.Prefs.Theme]) :
The_ClassDat[Gbl.Prefs.Theme];
char *Cl;
const char *Class;
if (FileZone == Brw_UNKNOWN)
{
if (asprintf (&Cl,"%s LINE_TOP",The_ClassDatStrong[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
Class = Cl;
}
else
Class = The_ClassDat[Gbl.Prefs.Theme];
if (SizeOfFileZones->NumUsrs == -1) // Not applicable
{
@ -1741,7 +1781,8 @@ static void Fig_WriteRowStatsFileBrowsers3 (const char *NameOfFileZones,
HTM_TR_End ();
Str_FreeStrings ();
if (FileZone == Brw_UNKNOWN)
free (Cl);
}
/*****************************************************************************/
@ -3580,6 +3621,7 @@ static void Fig_GetAndShowNumUsrsPerFirstDayOfWeek (void)
unsigned FirstDayOfWeek;
char *SubQuery;
char *Icon;
char *Title;
unsigned NumUsrs[7]; // 7: seven days in a week
unsigned NumUsrsTotal = 0;
@ -3624,11 +3666,11 @@ static void Fig_GetAndShowNumUsrsPerFirstDayOfWeek (void)
if (asprintf (&Icon,"first-day-of-week-%u.png",
FirstDayOfWeek) < 0)
Err_NotEnoughMemoryExit ();
Ico_PutIcon (Icon,Ico_BLACK,
Str_BuildString (Txt_First_day_of_the_week_X,
Txt_DAYS_SMALL[FirstDayOfWeek]),
"ICO40x40");
Str_FreeStrings ();
if (asprintf (&Title,Txt_First_day_of_the_week_X,
Txt_DAYS_SMALL[FirstDayOfWeek]) < 0)
Err_NotEnoughMemoryExit ();
Ico_PutIcon (Icon,Ico_BLACK,Title,"ICO40x40");
free (Title);
free (Icon);
HTM_TD_End ();

View File

@ -862,6 +862,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
struct Med_Media Media;
bool Enabled;
char *Title;
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
@ -927,28 +928,31 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
For_ActionsEnbPstFor[Forums->Forum.Type],
For_FORUM_POSTS_SECTION_ID);
For_PutParamsForum (Forums);
if (Enabled)
Ico_PutIconLink ("eye.svg",Ico_GREEN,
Str_BuildString (Txt_FORUM_Post_X_allowed_Click_to_ban_it,
PstNum));
else
Ico_PutIconLink ("eye-slash.svg",Ico_RED,
Str_BuildString (Txt_FORUM_Post_X_banned_Click_to_unban_it,
PstNum));
Str_FreeStrings ();
if (asprintf (&Title,Enabled ? Txt_FORUM_Post_X_allowed_Click_to_ban_it :
Txt_FORUM_Post_X_banned_Click_to_unban_it,
PstNum) < 0)
Err_NotEnoughMemoryExit ();
Ico_PutIconLink (Enabled ? "eye.svg" :
"eye-slash.svg",
Enabled ? Ico_GREEN :
Ico_RED,
Title);
free (Title);
Frm_EndForm ();
}
else
{
if (Enabled)
Ico_PutIcon ("eye.svg" ,Ico_GREEN,
Str_BuildString (Txt_FORUM_Post_X_allowed,PstNum),
"ICO_HIDDEN ICO16x16");
else
Ico_PutIcon ("eye-slash.svg",Ico_RED ,
Str_BuildString (Txt_FORUM_Post_X_banned ,PstNum),
"ICO_HIDDEN ICO16x16");
Str_FreeStrings ();
if (asprintf (&Title,Enabled ? Txt_FORUM_Post_X_allowed :
Txt_FORUM_Post_X_banned,
PstNum) < 0)
Err_NotEnoughMemoryExit ();
Ico_PutIcon (Enabled ? "eye.svg" :
"eye-slash.svg",
Enabled ? Ico_GREEN :
Ico_RED,
Title,
"ICO_HIDDEN ICO16x16");
free (Title);
}
/***** Form to remove post *****/
@ -2673,6 +2677,7 @@ static void For_WriteFormForumPst (struct For_Forums *Forums,
extern const char *Txt_MSG_Subject;
extern const char *Txt_MSG_Content;
extern const char *Txt_Send;
char *ClassInput;
/***** Begin box *****/
if (IsReply)
@ -2743,9 +2748,10 @@ static void For_WriteFormForumPst (struct For_Forums *Forums,
Lay_HelpPlainEditor ();
/***** Attached image (optional) *****/
Med_PutMediaUploader (-1,Str_BuildString ("FOR_MED_INPUT %s",
The_ClassInput[Gbl.Prefs.Theme]));
Str_FreeStrings ();
if (asprintf (&ClassInput,"FOR_MED_INPUT %s",The_ClassInput[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
Med_PutMediaUploader (-1,ClassInput);
free (ClassInput);
/***** Send button *****/
Btn_PutCreateButton (Txt_Send);

View File

@ -1704,6 +1704,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
char StrQstInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
bool QuestionExists;
char *Anchor = NULL;
char *Title;
/***** Trivial check *****/
if (!NumQsts)
@ -1771,12 +1772,13 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
/* Put icon to move up the question */
if (ICanEditQuestions && QstInd > 1)
{
if (asprintf (&Title,Txt_Move_up_X,StrQstInd) < 0)
Err_NotEnoughMemoryExit ();
Lay_PutContextualLinkOnlyIcon (ActUp_GamQst,Anchor,
Gam_PutParamsOneQst,Games,
"arrow-up.svg",Ico_BLACK,
Str_BuildString (Txt_Move_up_X,
StrQstInd));
Str_FreeStrings ();
Title);
free (Title);
}
else
Ico_PutIconOff ("arrow-up.svg",Ico_BLACK,
@ -1785,12 +1787,13 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
/* Put icon to move down the question */
if (ICanEditQuestions && QstInd < MaxQstInd)
{
if (asprintf (&Title,Txt_Move_down_X,StrQstInd) < 0)
Err_NotEnoughMemoryExit ();
Lay_PutContextualLinkOnlyIcon (ActDwnGamQst,Anchor,
Gam_PutParamsOneQst,Games,
"arrow-down.svg",Ico_BLACK,
Str_BuildString (Txt_Move_down_X,
StrQstInd));
Str_FreeStrings ();
Title);
free (Title);
}
else
Ico_PutIconOff ("arrow-down.svg",Ico_BLACK,

View File

@ -25,6 +25,10 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include "swad_error.h"
#include "swad_figure_cache.h"
#include "swad_form.h"
#include "swad_global.h"
@ -251,6 +255,7 @@ void HieCfg_NumCtrs (unsigned NumCtrs,bool PutForm)
extern const char *The_ClassDat[The_NUM_THEMES];
extern const char *Txt_Centers;
extern const char *Txt_Centers_of_INSTITUTION_X;
char *Title;
/***** Number of centers *****/
HTM_TR_Begin (NULL);
@ -264,10 +269,11 @@ void HieCfg_NumCtrs (unsigned NumCtrs,bool PutForm)
{
Frm_BeginFormGoTo (ActSeeCtr);
Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod);
HTM_BUTTON_OnSubmit_Begin (Str_BuildString (Txt_Centers_of_INSTITUTION_X,
Gbl.Hierarchy.Ins.ShrtName),
"BT_LINK",NULL);
Str_FreeStrings ();
if (asprintf (&Title,Txt_Centers_of_INSTITUTION_X,
Gbl.Hierarchy.Ins.ShrtName) < 0)
Err_NotEnoughMemoryExit ();
HTM_BUTTON_OnSubmit_Begin (Title,"BT_LINK",NULL);
free (Title);
}
HTM_Unsigned (NumCtrs);
if (PutForm)

View File

@ -25,7 +25,9 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include <sys/wait.h> // For the macro WEXITSTATUS
@ -1069,6 +1071,7 @@ static void Mai_ShowFormChangeUsrEmail (bool ItsMe,
unsigned NumEmails;
unsigned NumEmail;
bool Confirmed;
char *Icon;
static const struct
{
Act_Action_t Remove;
@ -1150,10 +1153,10 @@ static void Mai_ShowFormChangeUsrEmail (bool ItsMe,
/* Email confirmed? */
if (Confirmed)
{
Ico_PutIcon ("check-circle.svg",Ico_GREEN,
Str_BuildString (Txt_Email_X_confirmed,row[0]),
"ICO16x16");
Str_FreeStrings ();
if (asprintf (&Icon,Txt_Email_X_confirmed,row[0]) < 0)
Err_NotEnoughMemoryExit ();
Ico_PutIcon ("check-circle.svg",Ico_GREEN,Icon,"ICO16x16");
free (Icon);
}
/* Form to change user's email */

View File

@ -227,6 +227,7 @@ static void Msg_PutFormMsgUsrs (struct Msg_Messages *Messages,
unsigned NumUsrsInCrs = 0; // Initialized to avoid warning
bool ShowUsrsInCrs = false;
bool GetUsrsInCrs;
char *ClassInput;
Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs =
Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs =
@ -371,9 +372,11 @@ static void Msg_PutFormMsgUsrs (struct Msg_Messages *Messages,
Lay_HelpPlainEditor ();
/***** Attached image (optional) *****/
Med_PutMediaUploader (-1,Str_BuildString ("MSG_MED_INPUT %s",
The_ClassInput[Gbl.Prefs.Theme]));
Str_FreeStrings ();
if (asprintf (&ClassInput,"MSG_MED_INPUT %s",
The_ClassInput[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
Med_PutMediaUploader (-1,ClassInput);
free (ClassInput);
/***** Send button *****/
Btn_PutCreateButton (Txt_Send_message);

View File

@ -626,6 +626,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
[Rol_SYS_ADM] = ActUpdOthPho,
};
char ErrorTxt[256];
char *Icon;
/***** Creates directories if not exist *****/
Fil_CreateDirIfNotExists (Cfg_PATH_PHOTO_PRIVATE);
@ -789,11 +790,10 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
snprintf (FileNamePhotoMap,sizeof (FileNamePhotoMap),"%s/%s_map.jpg",
Cfg_PATH_PHOTO_TMP_PUBLIC,Gbl.UniqueNameEncrypted);
HTM_DIV_Begin ("class=\"TIT CM\"");
HTM_IMG (Cfg_URL_PHOTO_TMP_PUBLIC,
Str_BuildString ("%s_map.jpg",Gbl.UniqueNameEncrypted),
Txt_Faces_detected,
"usemap=\"#faces_map\"");
Str_FreeStrings ();
if (asprintf (&Icon,"%s_map.jpg",Gbl.UniqueNameEncrypted) < 0)
Err_NotEnoughMemoryExit ();
HTM_IMG (Cfg_URL_PHOTO_TMP_PUBLIC,Icon,Txt_Faces_detected,"usemap=\"#faces_map\"");
free (Icon);
HTM_DIV_End ();
/***** End alert *****/

View File

@ -70,6 +70,7 @@ void Pho_PutIconsToSelectPhotoShape (void)
[Pho_SHAPE_RECTANGLE] = "ICO_HIGHLIGHT PHOTOR15x20B",
};
Pho_Shape_t Shape;
char *Class;
Box_BoxBegin (NULL,Txt_User_photos,
Pho_PutIconsPhotoShape,NULL,
@ -87,12 +88,13 @@ void Pho_PutIconsToSelectPhotoShape (void)
HTM_DIV_Begin ("class=\"PREF_OFF\"");
Frm_BeginForm (ActChgUsrPho);
Par_PutHiddenParamUnsigned (NULL,"PhotoShape",Shape);
if (asprintf (&Class,"%s %s",
ClassPhoto[Shape],
Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user.svg",
Txt_PHOTO_SHAPES[Shape],
Str_BuildString ("%s %s",
ClassPhoto[Shape],
Ico_ClassColor[Ico_BLACK][Gbl.Prefs.Theme]));
Str_FreeStrings ();
Txt_PHOTO_SHAPES[Shape],Class);
free (Class);
Frm_EndForm ();
HTM_DIV_End ();
}

View File

@ -127,6 +127,7 @@ mysql> SHOW TABLES LIKE 'tml_%';
#include <linux/limits.h> // For PATH_MAX
#include <stdio.h> // For asprintf
#include "swad_error.h"
#include "swad_figure.h"
#include "swad_global.h"
#include "swad_message.h"
@ -270,6 +271,7 @@ void Tml_ShowTimelineUsr (struct Tml_Timeline *Timeline)
void Tml_ShowTimelineUsrHighlighting (struct Tml_Timeline *Timeline,long NotCod)
{
extern const char *Txt_Timeline_OF_A_USER;
char *Title;
/***** Get list of pubications to show in timeline *****/
Timeline->UsrOrGbl = Tml_Usr_TIMELINE_USR;
@ -277,10 +279,10 @@ void Tml_ShowTimelineUsrHighlighting (struct Tml_Timeline *Timeline,long NotCod)
Tml_Pub_GetListPubsToShowInTimeline (Timeline);
/***** Show timeline *****/
Tml_ShowTimeline (Timeline,NotCod,
Str_BuildString (Txt_Timeline_OF_A_USER,
Gbl.Usrs.Other.UsrDat.FrstName));
Str_FreeStrings ();
if (asprintf (&Title,Txt_Timeline_OF_A_USER,Gbl.Usrs.Other.UsrDat.FrstName) < 0)
Err_NotEnoughMemoryExit ();
Tml_ShowTimeline (Timeline,NotCod,Title);
free (Title);
/***** Free chained list of publications *****/
Tml_Pub_FreeListPubs (Timeline);

View File

@ -299,6 +299,7 @@ void Tml_Frm_FormToShowHiddenComms (long NotCod,
extern const char *Txt_See_the_previous_X_COMMENTS;
char *OnSubmit;
const char *Anchor;
char *Text;
/***** Begin container which content will be updated via AJAX *****/
HTM_DIV_Begin ("id=\"%s\" class=\"Tml_RIGHT_WIDTH\"",IdComms);
@ -347,10 +348,10 @@ void Tml_Frm_FormToShowHiddenComms (long NotCod,
HTM_BUTTON_OnSubmit_Begin (NULL,
The_ClassFormLinkInBox[Gbl.Prefs.Theme],
NULL);
Ico_PutIconTextLink ("angle-up.svg",Ico_BLACK,
Str_BuildString (Txt_See_the_previous_X_COMMENTS,
NumInitialComms));
Str_FreeStrings ();
if (asprintf (&Text,Txt_See_the_previous_X_COMMENTS,NumInitialComms) < 0)
Err_NotEnoughMemoryExit ();
Ico_PutIconTextLink ("angle-up.svg",Ico_BLACK,Text);
free (Text);
HTM_BUTTON_End ();
/* End form */

View File

@ -346,13 +346,15 @@ static void Tml_Usr_PutDisabledIconFavSha (Tml_Usr_FavSha_t FavSha,
},
},
};
char *Title;
/***** Disabled icon to fav/share *****/
if (NumUsrs)
{
Ico_PutDivIcon ("Tml_ICO_DISABLED",Ico[FavSha].Icon,Ico_BLACK,
Str_BuildString (*Ico[FavSha].Title.WithUsrs,NumUsrs));
Str_FreeStrings ();
if (asprintf (&Title,*Ico[FavSha].Title.WithUsrs,NumUsrs) < 0)
Err_NotEnoughMemoryExit ();
Ico_PutDivIcon ("Tml_ICO_DISABLED",Ico[FavSha].Icon,Ico_BLACK,Title);
free (Title);
}
else
Ico_PutDivIcon ("Tml_ICO_DISABLED",Ico[FavSha].Icon,Ico_BLACK,

View File

@ -1355,6 +1355,7 @@ void Usr_WriteLoggedUsrHead (void)
[Pho_SHAPE_RECTANGLE] = "PHOTOR18x24",
};
unsigned NumAvailableRoles = Rol_GetNumAvailableRoles ();
char *ClassSelect;
HTM_DIV_Begin ("class=\"HEAD_USR USR_%s\"",The_Colors[Gbl.Prefs.Theme]);
@ -1371,9 +1372,10 @@ void Usr_WriteLoggedUsrHead (void)
}
else
{
Rol_PutFormToChangeMyRole (Str_BuildString ("SEL_ROLE %s",
The_ClassInput[Gbl.Prefs.Theme]));
Str_FreeStrings ();
if (asprintf (&ClassSelect,"SEL_ROLE %s",The_ClassInput[Gbl.Prefs.Theme]) < 0)
Err_NotEnoughMemoryExit ();
Rol_PutFormToChangeMyRole (ClassSelect);
free (ClassSelect);
}
HTM_NBSP ();
@ -4728,6 +4730,7 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role,
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
unsigned NumUsrs;
unsigned NumUsr;
char *Title;
struct UsrData UsrDat;
Usr_Sex_t Sex;
struct UsrInList *UsrInList;
@ -4746,14 +4749,14 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role,
/***** Begin box and table *****/
/* Number of users found */
Sex = Usr_GetSexOfUsrsLst (Role);
Box_BoxTableBegin (NULL,Str_BuildString ("%u %s",NumUsrs,
(Role == Rol_UNK) ? ((NumUsrs == 1) ? Txt_user[Sex] :
Txt_users[Sex]) :
((NumUsrs == 1) ? Txt_ROLES_SINGUL_abc[Role][Sex] :
Txt_ROLES_PLURAL_abc[Role][Sex])),
NULL,NULL,
NULL,Box_NOT_CLOSABLE,2);
Str_FreeStrings ();
if (asprintf (&Title,"%u %s",NumUsrs,
(Role == Rol_UNK) ? (NumUsrs == 1 ? Txt_user[Sex] :
Txt_users[Sex]) :
(NumUsrs == 1 ? Txt_ROLES_SINGUL_abc[Role][Sex] :
Txt_ROLES_PLURAL_abc[Role][Sex])) < 0)
Err_NotEnoughMemoryExit ();
Box_BoxTableBegin (NULL,Title,NULL,NULL,NULL,Box_NOT_CLOSABLE,2);
free (Title);
/***** Heading row with column names *****/
Gbl.Usrs.Listing.WithPhotos = true;