Version 20.31: Feb 15, 2021 Code refactoring in copy, concat and sprintf.

This commit is contained in:
acanas 2021-02-15 16:25:55 +01:00
parent 87083fe7d8
commit 8ce0f8c6b5
109 changed files with 1770 additions and 2871 deletions

View File

@ -225,8 +225,8 @@ static int API_RemoveOldWSKeys (struct soap *soap);
static int API_GetCurrentDegCodFromCurrentCrsCod (void);
static bool API_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod);
static int API_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
static int API_CheckParamsNewAccount (char *NewNickWithArroba, // Input
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
char *NewEmail, // Input-output
char *NewPlainPassword, // Input
char *NewEncryptedPassword); // Output
@ -531,8 +531,7 @@ static int API_GenerateNewWSKey (struct soap *soap,
return ReturnCode;
/***** Create a unique name for the key *****/
Str_Copy (WSKey,Gbl.UniqueNameEncrypted,
API_BYTES_WS_KEY);
Str_Copy (WSKey,Gbl.UniqueNameEncrypted,API_BYTES_WS_KEY);
/***** Check that key does not exist in database *****/
if (DB_QueryCOUNT ("can not get existence of key",
@ -629,16 +628,12 @@ static bool API_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
row = mysql_fetch_row (mysql_res);
/* Get user's name */
Str_Copy (UsrDat->Surname1,row[0],
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Str_Copy (UsrDat->Surname2,row[1],
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Str_Copy (UsrDat->FirstName,row[2],
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Str_Copy (UsrDat->Surname1,row[0],sizeof (UsrDat->Surname1) - 1);
Str_Copy (UsrDat->Surname2,row[1],sizeof (UsrDat->Surname2) - 1);
Str_Copy (UsrDat->FrstName,row[2],sizeof (UsrDat->FrstName) - 1);
/* Get user's photo */
Str_Copy (UsrDat->Photo,row[3],
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Str_Copy (UsrDat->Photo ,row[3],sizeof (UsrDat->Photo ) - 1);
/* Get user's brithday */
Dat_GetDateFromYYYYMMDD (&(UsrDat->Birthday),row[4]);
@ -739,7 +734,7 @@ int swad__createAccount (struct soap *soap,
char *userNickname,char *userEmail,char *userPassword,char *appKey, // input
struct swad__createAccountOutput *createAccountOut) // output
{
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1];
int Result;
int ReturnCode;
@ -761,7 +756,7 @@ int swad__createAccount (struct soap *soap,
/***** Check parameters used to create the new account *****/
Result = API_CheckParamsNewAccount (userNickname, // Input
NewNicknameWithoutArroba,// Output
NewNickWithoutArroba,// Output
userEmail, // Input-output
userPassword, // Input
NewEncryptedPassword); // Output
@ -777,23 +772,23 @@ int swad__createAccount (struct soap *soap,
/***** Set password to the password typed by the user *****/
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword,
Pwd_BYTES_ENCRYPTED_PASSWORD);
sizeof (Gbl.Usrs.Me.UsrDat.Password) - 1);
/***** User does not exist in the platform, so create him/her! *****/
Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,
true); // I am creating my own account
/***** Save nickname *****/
Nck_UpdateNickInDB (Gbl.Usrs.Me.UsrDat.UsrCod,NewNicknameWithoutArroba);
Str_Copy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba,
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
Nck_UpdateNickInDB (Gbl.Usrs.Me.UsrDat.UsrCod,NewNickWithoutArroba);
Str_Copy (Gbl.Usrs.Me.UsrDat.Nickname,NewNickWithoutArroba,
sizeof (Gbl.Usrs.Me.UsrDat.Nickname) - 1);
/***** Save email *****/
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,userEmail))
{
/* Email updated sucessfully */
Str_Copy (Gbl.Usrs.Me.UsrDat.Email,userEmail,
Cns_MAX_BYTES_EMAIL_ADDRESS);
sizeof (Gbl.Usrs.Me.UsrDat.Email) - 1);
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
}
@ -811,26 +806,26 @@ int swad__createAccount (struct soap *soap,
/*****************************************************************************/
// Return false on error
//char *userNickname,char *userEmail,char *userID,char *userPassword
static int API_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
static int API_CheckParamsNewAccount (char *NewNickWithArroba, // Input
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
char *NewEmail, // Input-output
char *NewPlainPassword, // Input
char *NewEncryptedPassword) // Output
{
/***** Step 1/3: Check new nickname *****/
/* Make a copy without possible starting arrobas */
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
Str_Copy (NewNickWithoutArroba,NewNickWithArroba,
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
if (Nck_CheckIfNickWithArrobaIsValid (NewNickWithArroba)) // If new nickname is valid
{
/***** Remove arrobas at the beginning *****/
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
Str_RemoveLeadingArrobas (NewNickWithoutArroba);
/***** Check if the new nickname matches any of the nicknames of other users *****/
if (DB_QueryCOUNT ("can not check if nickname already existed",
"SELECT COUNT(*) FROM usr_nicknames"
" WHERE Nickname='%s'",
NewNicknameWithoutArroba)) // A nickname of another user is the same that this nickname
NewNickWithoutArroba)) // A nickname of another user is the same that this nickname
return API_CHECK_NEW_ACCOUNT_NICKNAME_REGISTERED_BY_ANOTHER_USER;
}
else // New nickname is not valid
@ -905,8 +900,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
return ReturnCode;
/***** Check if user's email, @nickname or ID are valid *****/
Str_Copy (UsrIDNickOrEmail,userID,
Cns_MAX_BYTES_EMAIL_ADDRESS);
Str_Copy (UsrIDNickOrEmail,userID,sizeof (UsrIDNickOrEmail) - 1);
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
{
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
@ -998,7 +992,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
Gbl.Usrs.Me.UsrDat.Surname2,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Str_Copy (loginByUserPasswordKeyOut->userFirstname,
Gbl.Usrs.Me.UsrDat.FirstName,
Gbl.Usrs.Me.UsrDat.FrstName,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
@ -1155,12 +1149,11 @@ int swad__loginBySessionKey (struct soap *soap,
Gbl.Usrs.Me.UsrDat.Surname2,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Str_Copy (loginBySessionKeyOut->userFirstname,
Gbl.Usrs.Me.UsrDat.FirstName,
Gbl.Usrs.Me.UsrDat.FrstName,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
Str_Copy (loginBySessionKeyOut->userPhoto,PhotoURL,
Cns_MAX_BYTES_WWW);
Str_Copy (loginBySessionKeyOut->userPhoto,PhotoURL,Cns_MAX_BYTES_WWW);
Str_Copy (loginBySessionKeyOut->userBirthday,
Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,
@ -1274,8 +1267,7 @@ int swad__getNewPassword (struct soap *soap,
return ReturnCode;
/***** Check if user's email, @nickname or ID are valid *****/
Str_Copy (UsrIDNickOrEmail,userID,
Cns_MAX_BYTES_EMAIL_ADDRESS);
Str_Copy (UsrIDNickOrEmail,userID,sizeof (UsrIDNickOrEmail) - 1);
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
{
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
@ -1414,14 +1406,14 @@ int swad__getCourses (struct soap *soap,
/* Get course short name (row[1]) */
getCoursesOut->coursesArray.__ptr[NumRow].courseShortName =
(char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1);
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName,row[1],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName,
row[1],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
/* Get course full name (row[2]) */
getCoursesOut->coursesArray.__ptr[NumRow].courseFullName =
(char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1);
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName,row[2],
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName,
row[2],Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
/* Get role (row[3]) */
if (sscanf (row[3],"%u",&Role) != 1) // Role in this course
@ -1531,8 +1523,7 @@ int swad__getCourseInfo (struct soap *soap,
&InfoSrc,&MustBeRead);
Length = strlen (NamesInWSForInfoSrc[InfoSrc]);
getCourseInfo->infoSrc = (char *) soap_malloc (soap,Length + 1);
Str_Copy (getCourseInfo->infoSrc,NamesInWSForInfoSrc[InfoSrc],
Length);
Str_Copy (getCourseInfo->infoSrc,NamesInWSForInfoSrc[InfoSrc],Length);
/***** Get info text *****/
getCourseInfo->infoTxt = NULL;
@ -1596,8 +1587,7 @@ static int API_WriteSyllabusIntoHTMLBuffer (struct soap *soap,
if (Syl_LstItemsSyllabus.NumItems)
{
/***** Create a unique name for the file *****/
snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),
"%s/%s_syllabus.html",
snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),"%s/%s_syllabus.html",
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
/***** Create a new temporary file for writing and reading *****/
@ -1617,7 +1607,7 @@ static int API_WriteSyllabusIntoHTMLBuffer (struct soap *soap,
Length = (size_t) ftell (FileHTMLTmp);
/* Allocate memory for buffer */
if ((*HTMLBuffer = (char *) malloc (Length + 1)) == NULL)
if ((*HTMLBuffer = malloc (Length + 1)) == NULL)
{
fclose (FileHTMLTmp);
unlink (FileNameHTMLTmp);
@ -1674,8 +1664,7 @@ static int API_WritePlainTextIntoHTMLBuffer (struct soap *soap,
if (TxtHTML[0])
{
/***** Create a unique name for the file *****/
snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),
"%s/%s_info.html",
snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),"%s/%s_info.html",
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
/***** Create a new temporary file for writing and reading *****/
@ -1707,7 +1696,7 @@ static int API_WritePlainTextIntoHTMLBuffer (struct soap *soap,
Length = (size_t) ftell (FileHTMLTmp);
/***** Allocate memory for buffer *****/
if ((*HTMLBuffer = (char *) malloc (Length + 1)) == NULL)
if ((*HTMLBuffer = malloc (Length + 1)) == NULL)
{
fclose (FileHTMLTmp);
unlink (FileNameHTMLTmp);
@ -1757,16 +1746,14 @@ static int API_WritePageIntoHTMLBuffer (struct soap *soap,
/***** Open file with web page *****/
/* 1. Check if index.html exists */
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.html",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
FileExists = true;
else
{
/* 2. If index.html not exists, try index.htm */
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.htm",
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.htm",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
FileExists = true;
@ -1785,7 +1772,7 @@ static int API_WritePageIntoHTMLBuffer (struct soap *soap,
fseek (FileHTML,0L,SEEK_SET);
/* Allocate memory for buffer */
if ((*HTMLBuffer = (char *) malloc (Length + 1)) == NULL)
if ((*HTMLBuffer = malloc (Length + 1)) == NULL)
{
fclose (FileHTML);
Lay_NotEnoughMemoryExit ();
@ -1957,8 +1944,7 @@ int swad__findUsers (struct soap *soap,
Role = API_SvcRole_to_RolRole[userRole];
/***** Query users beloging to course or group from database *****/
Str_Copy (Gbl.Search.Str,filter,
Sch_MAX_BYTES_STRING_TO_FIND);
Str_Copy (Gbl.Search.Str,filter,sizeof (Gbl.Search.Str) - 1);
if (Gbl.Search.Str[0]) // Search some users
{
@ -2149,8 +2135,8 @@ int swad__getGroupTypes (struct soap *soap,
/* Get group type name (row[1]) */
getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName =
(char *) soap_malloc (soap,Grp_MAX_BYTES_GROUP_TYPE_NAME + 1);
Str_Copy (getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName,row[1],
Grp_MAX_BYTES_GROUP_TYPE_NAME);
Str_Copy (getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName,
row[1],Grp_MAX_BYTES_GROUP_TYPE_NAME);
/* Get whether enrolment is mandatory ('Y') or voluntary ('N') (row[2]) */
getGroupTypesOut->groupTypesArray.__ptr[NumRow].mandatory = (row[2][0] == 'Y') ? 1 :
@ -2384,7 +2370,8 @@ int swad__sendMyGroups (struct soap *soap,
if (LstGrpsIWant.NumGrps) // If I have selected groups...
{
/***** Create a list of groups selected from myGroups *****/
if ((LstGrpsIWant.GrpCods = (long *) calloc (LstGrpsIWant.NumGrps,sizeof (long))) == NULL)
if ((LstGrpsIWant.GrpCods = calloc (LstGrpsIWant.NumGrps,
sizeof (*LstGrpsIWant.GrpCods))) == NULL)
Lay_NotEnoughMemoryExit ();
for (NumGrp = 0, Ptr = myGroups;
*Ptr;
@ -2502,8 +2489,7 @@ static void API_CopyUsrData (struct soap *soap,
/* Copy user's nickname */
Length = strlen (UsrDat->Nickname);
Usr->userNickname = (char *) soap_malloc (soap,Length + 1);
Str_Copy (Usr->userNickname,UsrDat->Nickname,
Length);
Str_Copy (Usr->userNickname,UsrDat->Nickname,Length);
/* Copy user's first ID */
if (UsrIDIsVisible && UsrDat->IDs.List)
@ -2512,33 +2498,28 @@ static void API_CopyUsrData (struct soap *soap,
FirstID = "********";
Length = strlen (FirstID);
Usr->userID = (char *) soap_malloc (soap,Length + 1);
Str_Copy (Usr->userID,FirstID,
Length);
Str_Copy (Usr->userID,FirstID,Length);
/* Copy user's surname1 */
Length = strlen (UsrDat->Surname1);
Usr->userSurname1 = (char *) soap_malloc (soap,Length + 1);
Str_Copy (Usr->userSurname1,UsrDat->Surname1,
Length);
Str_Copy (Usr->userSurname1,UsrDat->Surname1,Length);
/* Copy user's surname2 */
Length = strlen (UsrDat->Surname2);
Usr->userSurname2 = (char *) soap_malloc (soap,Length + 1);
Str_Copy (Usr->userSurname2,UsrDat->Surname2,
Length);
Str_Copy (Usr->userSurname2,UsrDat->Surname2,Length);
/* Copy user's first name */
Length = strlen (UsrDat->FirstName);
Length = strlen (UsrDat->FrstName);
Usr->userFirstname = (char *) soap_malloc (soap,Length + 1);
Str_Copy (Usr->userFirstname,UsrDat->FirstName,
Length);
Str_Copy (Usr->userFirstname,UsrDat->FrstName,Length);
/* User's photo URL */
Pho_BuildLinkToPhoto (UsrDat,PhotoURL);
Length = strlen (PhotoURL);
Usr->userPhoto = (char *) soap_malloc (soap,Length + 1);
Str_Copy (Usr->userPhoto,PhotoURL,
Length);
Str_Copy (Usr->userPhoto,PhotoURL,Length);
}
/*****************************************************************************/
@ -2639,30 +2620,26 @@ int swad__getAttendanceEvents (struct soap *soap,
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1 =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1,
Gbl.Usrs.Other.UsrDat.Surname1,
Length);
Gbl.Usrs.Other.UsrDat.Surname1,Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2 =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2,
Gbl.Usrs.Other.UsrDat.Surname2,
Length);
Gbl.Usrs.Other.UsrDat.Surname2,Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
Length = strlen (Gbl.Usrs.Other.UsrDat.FrstName);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname,
Gbl.Usrs.Other.UsrDat.FirstName,
Length);
Gbl.Usrs.Other.UsrDat.FrstName,Length);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
Length = strlen (PhotoURL);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto,
PhotoURL,
Length);
PhotoURL,Length);
}
else
{
@ -2692,15 +2669,15 @@ int swad__getAttendanceEvents (struct soap *soap,
Length = strlen (row[6]);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title,row[6],
Length);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title,
row[6],Length);
/* Get Txt (row[7]) */
Length = strlen (row[7]);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text,row[7],
Length);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text,
row[7],Length);
/* Get list of groups for this attendance event */
API_GetListGrpsInAttendanceEventFromDB (soap,
@ -2753,12 +2730,10 @@ static void API_GetListGrpsInAttendanceEventFromDB (struct soap *soap,
/* Get group code (row[0]) */
GrpCod = Str_ConvertStrCodToLongCod (row[0]);
snprintf (GrpCodStr,sizeof (GrpCodStr),
NumGrp ? ",%ld" :
"%ld",
snprintf (GrpCodStr,sizeof (GrpCodStr),NumGrp ? ",%ld" :
"%ld",
GrpCod);
Str_Concat (*ListGroups,GrpCodStr,
Length);
Str_Concat (*ListGroups,GrpCodStr,Length);
}
}
@ -2855,8 +2830,7 @@ int swad__sendAttendanceEvent (struct soap *soap,
return soap_receiver_fault (soap,
"Request forbidden",
"Title of attendance event is empty");
Str_Copy (Event.Title,title,
Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE);
Str_Copy (Event.Title,title,sizeof (Event.Title) - 1);
/* Create a list of groups selected */
API_GetLstGrpsSel (groups);
@ -2965,7 +2939,8 @@ static void API_GetLstGrpsSel (const char *Groups)
// Here NestedCalls is always 0
Gbl.Crs.Grps.LstGrpsSel.NestedCalls++;
// Here NestedCalls is always 1
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = (long *) calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL)
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
Lay_NotEnoughMemoryExit ();
for (Ptr = Groups, NumGrp = 0;
@ -3105,8 +3080,7 @@ int swad__getAttendanceUsers (struct soap *soap,
getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname,
Gbl.Usrs.Other.UsrDat.Nickname,
Length);
Gbl.Usrs.Other.UsrDat.Nickname,Length);
if (Gbl.Usrs.Other.UsrDat.IDs.Num)
{
@ -3114,8 +3088,7 @@ int swad__getAttendanceUsers (struct soap *soap,
getAttendanceUsersOut->usersArray.__ptr[NumRow].userID =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userID,
Gbl.Usrs.Other.UsrDat.IDs.List[0].ID,
Length);
Gbl.Usrs.Other.UsrDat.IDs.List[0].ID,Length);
}
else
{
@ -3128,30 +3101,26 @@ int swad__getAttendanceUsers (struct soap *soap,
getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1 =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1,
Gbl.Usrs.Other.UsrDat.Surname1,
Length);
Gbl.Usrs.Other.UsrDat.Surname1,Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2 =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2,
Gbl.Usrs.Other.UsrDat.Surname2,
Length);
Gbl.Usrs.Other.UsrDat.Surname2,Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
Length = strlen (Gbl.Usrs.Other.UsrDat.FrstName);
getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname,
Gbl.Usrs.Other.UsrDat.FirstName,
Length);
Gbl.Usrs.Other.UsrDat.FrstName,Length);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
Length = strlen (PhotoURL);
getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto,
PhotoURL,
Length);
PhotoURL,Length);
}
else
{
@ -3244,7 +3213,7 @@ int swad__sendAttendanceUsers (struct soap *soap,
/* Allocate subquery used to mark not present users as absent */
Length = 256 + NumCodsInList * (1 + Cns_MAX_DECIMAL_DIGITS_LONG + 1) - 1;
if ((SubQueryAllUsrs = (char *) malloc (Length + 1)) == NULL)
if ((SubQueryAllUsrs = malloc (Length + 1)) == NULL)
return soap_receiver_fault (soap,
"Not enough memory",
"Not enough memory to store list of users");
@ -3271,14 +3240,12 @@ int swad__sendAttendanceUsers (struct soap *soap,
{
if (sendAttendanceUsersOut->numUsers)
{
snprintf (SubQueryOneUsr,sizeof (SubQueryOneUsr),
",%ld",UsrDat.UsrCod);
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,
Length);
snprintf (SubQueryOneUsr,sizeof (SubQueryOneUsr),",%ld",
UsrDat.UsrCod);
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,Length);
}
else
snprintf (SubQueryAllUsrs,Length,
" AND UsrCod NOT IN (%ld",
snprintf (SubQueryAllUsrs,Length," AND UsrCod NOT IN (%ld",
UsrDat.UsrCod);
}
@ -3290,8 +3257,7 @@ int swad__sendAttendanceUsers (struct soap *soap,
{
/* Mark not present users as absent in table of users */
if (sendAttendanceUsersOut->numUsers)
Str_Concat (SubQueryAllUsrs,")",
Length);
Str_Concat (SubQueryAllUsrs,")",Length);
DB_QueryUPDATE ("can not set other users as absent",
"UPDATE att_usr SET Present='N'"
@ -3411,8 +3377,7 @@ int swad__getNotifications (struct soap *soap,
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType =
(char *) soap_malloc (soap,Ntf_MAX_BYTES_NOTIFY_EVENT + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType,
Ntf_WSNotifyEvents[NotifyEvent],
Ntf_MAX_BYTES_NOTIFY_EVENT);
Ntf_WSNotifyEvents[NotifyEvent],Ntf_MAX_BYTES_NOTIFY_EVENT);
/* Get time of the event (row[2]) */
EventTime = 0L;
@ -3450,15 +3415,14 @@ int swad__getNotifications (struct soap *soap,
getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname =
(char *) soap_malloc (soap,Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname,
Gbl.Usrs.Other.UsrDat.FirstName,
Gbl.Usrs.Other.UsrDat.FrstName,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto =
(char *) soap_malloc (soap,Cns_MAX_BYTES_WWW + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto,
PhotoURL,
Cns_MAX_BYTES_WWW);
PhotoURL,Cns_MAX_BYTES_WWW);
}
else
{
@ -3529,8 +3493,7 @@ int swad__getNotifications (struct soap *soap,
getNotificationsOut->notificationsArray.__ptr[NumNotif].summary =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].summary,
SummaryStr,
Length);
SummaryStr,Length);
if (ContentStr == NULL)
{
@ -3544,8 +3507,7 @@ int swad__getNotifications (struct soap *soap,
getNotificationsOut->notificationsArray.__ptr[NumNotif].content =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].content,
ContentStr,
Length);
ContentStr,Length);
/* Free memory used by content string */
free (ContentStr);
@ -3773,15 +3735,13 @@ int swad__sendMessage (struct soap *soap,
}
/***** Allocate space for query *****/
if ((Query = (char *) malloc (API_MAX_BYTES_QUERY_RECIPIENTS + 1)) == NULL)
if ((Query = malloc (API_MAX_BYTES_QUERY_RECIPIENTS + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Build query for recipients from database *****/
if (ReplyUsrCod > 0)
snprintf (Query,API_MAX_BYTES_QUERY_RECIPIENTS + 1,
"SELECT UsrCod FROM usr_data"
" WHERE UsrCod=%ld",
ReplyUsrCod);
"SELECT UsrCod FROM usr_data WHERE UsrCod=%ld",ReplyUsrCod);
else
Query[0] = '\0';
@ -3808,8 +3768,7 @@ int swad__sendMessage (struct soap *soap,
if (FirstNickname)
{
if (ReplyUsrCod > 0)
Str_Concat (Query," UNION ",
API_MAX_BYTES_QUERY_RECIPIENTS);
Str_Concat (Query," UNION ",API_MAX_BYTES_QUERY_RECIPIENTS);
Str_Concat (Query,"SELECT UsrCod FROM usr_nicknames"
" WHERE Nickname IN ('",
API_MAX_BYTES_QUERY_RECIPIENTS);
@ -3817,17 +3776,13 @@ int swad__sendMessage (struct soap *soap,
ThereAreNicknames = true;
}
else
Str_Concat (Query,",'",
API_MAX_BYTES_QUERY_RECIPIENTS);
Str_Concat (Query,Nickname,
API_MAX_BYTES_QUERY_RECIPIENTS);
Str_Concat (Query,"'",
API_MAX_BYTES_QUERY_RECIPIENTS);
Str_Concat (Query,",'",API_MAX_BYTES_QUERY_RECIPIENTS);
Str_Concat (Query,Nickname,API_MAX_BYTES_QUERY_RECIPIENTS);
Str_Concat (Query,"'",API_MAX_BYTES_QUERY_RECIPIENTS);
}
}
if (ThereAreNicknames)
Str_Concat (Query,")",
API_MAX_BYTES_QUERY_RECIPIENTS);
Str_Concat (Query,")",API_MAX_BYTES_QUERY_RECIPIENTS);
/***** Initialize output structure *****/
sendMessageOut->numUsers = 0;
@ -4108,24 +4063,19 @@ int swad__getTestConfig (struct soap *soap,
/* Convert from visibility to old feedback */
/* TODO: Remove these lines in 2021 */
if (!TstVis_IsVisibleTotalScore (TstCfg_GetConfigVisibility ()))
Str_Copy (getTestConfigOut->feedback,
"nothing",
Str_Copy (getTestConfigOut->feedback,"nothing",
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
else if (!TstVis_IsVisibleEachQstScore (TstCfg_GetConfigVisibility ()))
Str_Copy (getTestConfigOut->feedback,
"totalResult",
Str_Copy (getTestConfigOut->feedback,"totalResult",
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
else if (!TstVis_IsVisibleCorrectAns (TstCfg_GetConfigVisibility ()))
Str_Copy (getTestConfigOut->feedback,
"eachResult",
Str_Copy (getTestConfigOut->feedback,"eachResult",
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
else if (!TstVis_IsVisibleFeedbackTxt (TstCfg_GetConfigVisibility ()))
Str_Copy (getTestConfigOut->feedback,
"eachGoodBad",
Str_Copy (getTestConfigOut->feedback,"eachGoodBad",
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
else
Str_Copy (getTestConfigOut->feedback,
"fullFeedback",
Str_Copy (getTestConfigOut->feedback,"fullFeedback",
TstPrn_MAX_BYTES_FEEDBACK_TYPE);
/***** Get number of tests *****/
@ -4510,14 +4460,14 @@ static int API_GetTstAnswers (struct soap *soap,
/* Get answer (row[3]) */
getTestsOut->answersArray.__ptr[NumRow].answerText =
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerText,row[3],
Cns_MAX_BYTES_TEXT);
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerText,
row[3],Cns_MAX_BYTES_TEXT);
/* Get feedback (row[4]) */
getTestsOut->answersArray.__ptr[NumRow].answerFeedback =
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerFeedback,row[4],
Cns_MAX_BYTES_TEXT);
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerFeedback,
row[4],Cns_MAX_BYTES_TEXT);
}
}
@ -4667,18 +4617,13 @@ int swad__getTrivialQuestion (struct soap *soap,
/* Add this degree to query */
if (FirstDegree)
{
snprintf (DegreesStr,sizeof (DegreesStr),
"%ld",
DegCod);
snprintf (DegreesStr,sizeof (DegreesStr),"%ld",DegCod);
FirstDegree = false;
}
else
{
snprintf (DegStr,sizeof (DegStr),
",%ld",
DegCod);
Str_Concat (DegreesStr,DegStr,
API_MAX_BYTES_DEGREES_STR);
snprintf (DegStr,sizeof (DegStr),",%ld",DegCod);
Str_Concat (DegreesStr,DegStr,sizeof (DegreesStr) - 1);
}
}
}
@ -4823,14 +4768,14 @@ int swad__getTrivialQuestion (struct soap *soap,
/* Get answer (row[3]) */
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText =
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText,row[3],
Cns_MAX_BYTES_TEXT);
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText,
row[3],Cns_MAX_BYTES_TEXT);
/* Get feedback (row[4]) */
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback =
(char *) soap_malloc (soap,Cns_MAX_BYTES_TEXT + 1);
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback,row[4],
Cns_MAX_BYTES_TEXT);
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback,
row[4],Cns_MAX_BYTES_TEXT);
}
}
@ -4943,30 +4888,26 @@ int swad__getGames (struct soap *soap,
getGamesOut->gamesArray.__ptr[NumGame].userSurname1 =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userSurname1,
Gbl.Usrs.Other.UsrDat.Surname1,
Length);
Gbl.Usrs.Other.UsrDat.Surname1,Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
getGamesOut->gamesArray.__ptr[NumGame].userSurname2 =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userSurname2,
Gbl.Usrs.Other.UsrDat.Surname2,
Length);
Gbl.Usrs.Other.UsrDat.Surname2,Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
Length = strlen (Gbl.Usrs.Other.UsrDat.FrstName);
getGamesOut->gamesArray.__ptr[NumGame].userFirstname =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userFirstname,
Gbl.Usrs.Other.UsrDat.FirstName,
Length);
Gbl.Usrs.Other.UsrDat.FrstName,Length);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
Length = strlen (PhotoURL);
getGamesOut->gamesArray.__ptr[NumGame].userPhoto =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].userPhoto,
PhotoURL,
Length);
PhotoURL,Length);
}
else
{
@ -5000,15 +4941,13 @@ int swad__getGames (struct soap *soap,
Length = strlen (row[6]);
getGamesOut->gamesArray.__ptr[NumGame].title =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].title,row[6],
Length);
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].title,row[6],Length);
/* Get Txt (row[7]) */
Length = strlen (row[7]);
getGamesOut->gamesArray.__ptr[NumGame].text =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].text,row[7],
Length);
Str_Copy (getGamesOut->gamesArray.__ptr[NumGame].text,row[7],Length);
}
}
@ -5134,30 +5073,26 @@ int swad__getMatches (struct soap *soap,
getMatchesOut->matchesArray.__ptr[NumMatch].userSurname1 =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userSurname1,
Gbl.Usrs.Other.UsrDat.Surname1,
Length);
Gbl.Usrs.Other.UsrDat.Surname1,Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
getMatchesOut->matchesArray.__ptr[NumMatch].userSurname2 =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userSurname2,
Gbl.Usrs.Other.UsrDat.Surname2,
Length);
Gbl.Usrs.Other.UsrDat.Surname2,Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
Length = strlen (Gbl.Usrs.Other.UsrDat.FrstName);
getMatchesOut->matchesArray.__ptr[NumMatch].userFirstname =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userFirstname,
Gbl.Usrs.Other.UsrDat.FirstName,
Length);
Gbl.Usrs.Other.UsrDat.FrstName,Length);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
Length = strlen (PhotoURL);
getMatchesOut->matchesArray.__ptr[NumMatch].userPhoto =
(char *) soap_malloc (soap,Length + 1);
Str_Copy (getMatchesOut->matchesArray.__ptr[NumMatch].userPhoto,
PhotoURL,
Length);
PhotoURL,Length);
}
else
{
@ -5450,12 +5385,10 @@ static void API_GetListGrpsInGameFromDB (struct soap *soap,
/* Get group code (row[0]) */
GrpCod = Str_ConvertStrCodToLongCod (row[0]);
snprintf (GrpCodStr,sizeof (GrpCodStr),
NumGrp ? ",%ld" :
"%ld",
snprintf (GrpCodStr,sizeof (GrpCodStr),NumGrp ? ",%ld" :
"%ld",
GrpCod);
Str_Concat (*ListGroups,GrpCodStr,
Length);
Str_Concat (*ListGroups,GrpCodStr,Length);
}
}
@ -5571,22 +5504,20 @@ int swad__getDirectoryTree (struct soap *soap,
Gbl.Crs.Grps.GrpCod = (groupCode > 0) ? (long) groupCode :
-1L;
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),
"%s/%ld",
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),"%s/%ld",
Cfg_PATH_CRS_PRIVATE,Gbl.Hierarchy.Crs.CrsCod);
Brw_InitializeFileBrowser ();
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type],
PATH_MAX);
sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1);
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,".",
NAME_MAX);
sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1);
Brw_SetFullPathInTree ();
/* Check if exists the directory for HTML output. If not exists, create it */
Fil_CreateDirIfNotExists (Cfg_PATH_OUT_PRIVATE);
/* Create a unique name for the file */
snprintf (XMLFileName,sizeof (XMLFileName),
"%s/%s.xml",
snprintf (XMLFileName,sizeof (XMLFileName),"%s/%s.xml",
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
/* Open file for writing and reading */
@ -5644,17 +5575,15 @@ static void API_ListDir (unsigned Level,const char *Path,const char *PathInTree)
if (strcmp (FileList[NumFile]->d_name,".") &&
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
{
snprintf (PathFileRel,sizeof (PathFileRel),
"%s/%s",
snprintf (PathFileRel,sizeof (PathFileRel),"%s/%s",
Path,FileList[NumFile]->d_name);
snprintf (PathFileInExplTree,sizeof (PathFileInExplTree),
"%s/%s",
snprintf (PathFileInExplTree,sizeof (PathFileInExplTree),"%s/%s",
PathInTree,FileList[NumFile]->d_name);
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,PathInTree,
PATH_MAX);
sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1);
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileList[NumFile]->d_name,
NAME_MAX);
sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1);
if (!lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
{
@ -5884,9 +5813,9 @@ int swad__getFile (struct soap *soap,
/***** Set paths *****/
Brw_InitializeFileBrowser ();
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,FileMetadata.FilFolLnk.Path,
PATH_MAX);
sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1);
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileMetadata.FilFolLnk.Name,
NAME_MAX);
sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1);
Brw_SetFullPathInTree ();
/***** Get file size and date *****/
@ -5901,11 +5830,9 @@ int swad__getFile (struct soap *soap,
URL);
/***** Copy data into output structure *****/
Str_Copy (getFileOut->fileName,FileMetadata.FilFolLnk.Name,
NAME_MAX);
Str_Copy (getFileOut->fileName,FileMetadata.FilFolLnk.Name,NAME_MAX);
Str_Copy (getFileOut->URL,URL,
Cns_MAX_BYTES_WWW);
Str_Copy (getFileOut->URL,URL,Cns_MAX_BYTES_WWW);
getFileOut->size = (int) FileMetadata.Size;
@ -5923,8 +5850,7 @@ int swad__getFile (struct soap *soap,
Usr_MAX_BYTES_FULL_NAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
Str_Copy (getFileOut->publisherPhoto,PhotoURL,
Cns_MAX_BYTES_WWW);
Str_Copy (getFileOut->publisherPhoto,PhotoURL,Cns_MAX_BYTES_WWW);
}
return SOAP_OK;
@ -6015,8 +5941,7 @@ int swad__getMarks (struct soap *soap,
{
Length = strlen (ContentStr);
getMarksOut->content = (char *) soap_malloc (soap,Length + 1);
Str_Copy (getMarksOut->content,ContentStr,
Length);
Str_Copy (getMarksOut->content,ContentStr,Length);
free (ContentStr);
ContentStr = NULL;
}

View File

@ -121,7 +121,7 @@ void ID_GetListIDsFromUsrCod (struct UsrData *UsrDat)
/* Get ID from row[0] */
Str_Copy (UsrDat->IDs.List[NumID].ID,row[0],
ID_MAX_BYTES_USR_ID);
sizeof (UsrDat->IDs.List[NumID].ID) - 1);
/* Get if ID is confirmed from row[1] */
UsrDat->IDs.List[NumID].Confirmed = (row[1][0] == 'Y');
@ -146,7 +146,7 @@ void ID_ReallocateListIDs (struct UsrData *UsrDat,unsigned NumIDs)
UsrDat->IDs.Num = NumIDs;
/***** Allocate space for the list *****/
if ((UsrDat->IDs.List = (struct ListIDs *) malloc (NumIDs * sizeof (struct ListIDs))) == NULL)
if ((UsrDat->IDs.List = malloc (NumIDs * sizeof (*UsrDat->IDs.List))) == NULL)
Lay_NotEnoughMemoryExit ();
}
@ -193,7 +193,7 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
/***** Allocate memory for subquery string *****/
MaxLength = 512 + UsrDat->IDs.Num * (1 + ID_MAX_BYTES_USR_ID + 1) - 1;
if ((SubQueryAllUsrs = (char *) malloc (MaxLength + 1)) == NULL)
if ((SubQueryAllUsrs = malloc (MaxLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
SubQueryAllUsrs[0] = '\0';
@ -203,12 +203,10 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
NumID++)
{
if (NumID)
Str_Concat (SubQueryAllUsrs,",",
MaxLength);
Str_Concat (SubQueryAllUsrs,",",MaxLength);
sprintf (SubQueryOneUsr,"'%s'",UsrDat->IDs.List[NumID].ID);
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,
MaxLength);
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,MaxLength);
}
if (CheckPassword)
@ -435,7 +433,7 @@ bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat)
if (!UsrDat->Password[0] && // User has no password (never logged)
!UsrDat->Surname1[0] && // and who has no surname 1 (nobody filled user's surname 1)
!UsrDat->Surname2[0] && // and who has no surname 2 (nobody filled user's surname 2)
!UsrDat->FirstName[0] && // and who has no first name (nobody filled user's first name)
!UsrDat->FrstName[0] && // and who has no first name (nobody filled user's first name)
!UsrDat->Email[0]) // and who has no email (nobody filled user's email)
return true;
@ -491,7 +489,7 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID,
break;
}
}
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Par_PutHiddenParamString (NULL,"UsrID",UsrDat->IDs.List[NumID].ID);
/***** Put link *****/
@ -517,9 +515,7 @@ void ID_ShowFormChangeMyID (bool IShouldFillInID)
HTM_SECTION_Begin (ID_ID_SECTION_ID);
/***** Begin box *****/
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
Box_BoxBegin (StrRecordWidth,Txt_ID,
Acc_PutLinkToRemoveMyAccount,NULL,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
@ -549,9 +545,7 @@ void ID_ShowFormChangeOtherUsrID (void)
HTM_SECTION_Begin (ID_ID_SECTION_ID);
/***** Begin box *****/
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
Box_BoxBegin (StrRecordWidth,Txt_ID,
NULL,NULL,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
@ -704,7 +698,7 @@ static void ID_ShowFormChangeUsrID (bool ItsMe,bool IShouldFillInID)
break;
}
Frm_StartFormAnchor (NextAction,ID_ID_SECTION_ID);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
}
HTM_INPUT_TEXT ("NewID",ID_MAX_BYTES_USR_ID,
UsrDat->IDs.Num ? UsrDat->IDs.List[UsrDat->IDs.Num - 1].ID :
@ -733,7 +727,7 @@ static void ID_PutParamsRemoveOtherID (void *ID)
{
if (ID)
{
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
Par_PutHiddenParamString (NULL,"UsrID",(char *) ID);
}
}

View File

@ -78,7 +78,8 @@ extern struct Globals Gbl;
void MFU_AllocateMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxActionsShown)
{
if ((ListMFUActions->Actions = (Act_Action_t *) malloc (sizeof (Act_Action_t) * MaxActionsShown)) == NULL)
if ((ListMFUActions->Actions = malloc (MaxActionsShown *
sizeof (*ListMFUActions->Actions))) == NULL)
Lay_ShowErrorAndExit ("Can not allocate memory for list of most frequently used actions.");
}
@ -236,12 +237,9 @@ void MFU_WriteBigMFUActions (struct MFU_ListMFUActions *ListMFUActions)
{
/* Action string */
Str_Copy (TabStr,Txt_TABS_TXT[Act_GetTab (Act_GetSuperAction (Action))],
MFU_MAX_BYTES_TAB);
Str_Copy (MenuStr,Title,
MFU_MAX_BYTES_MENU);
snprintf (TabMenuStr,sizeof (TabMenuStr),
"%s > %s",
TabStr,MenuStr);
sizeof (TabStr) - 1);
Str_Copy (MenuStr,Title,sizeof (MenuStr) - 1);
snprintf (TabMenuStr,sizeof (TabMenuStr),"%s > %s",TabStr,MenuStr);
/* Icon and text */
HTM_LI_Begin ("class=\"ICO_HIGHLIGHT\"");
@ -297,12 +295,9 @@ void MFU_WriteSmallMFUActions (struct MFU_ListMFUActions *ListMFUActions)
{
/* Action string */
Str_Copy (TabStr,Txt_TABS_TXT[Act_GetTab (Act_GetSuperAction (Action))],
MFU_MAX_BYTES_TAB);
Str_Copy (MenuStr,Title,
MFU_MAX_BYTES_MENU);
snprintf (TabMenuStr,sizeof (TabMenuStr),
"%s > %s",
TabStr,MenuStr);
sizeof (TabStr) - 1);
Str_Copy (MenuStr,Title,sizeof (MenuStr) - 1);
snprintf (TabMenuStr,sizeof (TabMenuStr),"%s > %s",TabStr,MenuStr);
/* Icon and text */
HTM_LI_Begin ("class=\"ICO_HIGHLIGHT\"");

View File

@ -66,14 +66,12 @@ void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs)
struct tm *tm;
/***** Create RSS directory if not exists *****/
snprintf (PathRelPublRSSDir,sizeof (PathRelPublRSSDir),
"%s/%ld/%s",
snprintf (PathRelPublRSSDir,sizeof (PathRelPublRSSDir),"%s/%ld/%s",
Cfg_PATH_CRS_PUBLIC,Crs->CrsCod,Cfg_RSS_FOLDER);
Fil_CreateDirIfNotExists (PathRelPublRSSDir);
/***** Create RSS file *****/
snprintf (PathRelPublRSSFile,sizeof (PathRelPublRSSFile),
"%s/%s",
snprintf (PathRelPublRSSFile,sizeof (PathRelPublRSSFile),"%s/%s",
PathRelPublRSSDir,Cfg_RSS_FILE);
if ((FileRSS = fopen (PathRelPublRSSFile,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not create RSS file.");
@ -196,8 +194,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
fprintf (FileRSS,"<item>\n");
/* Write title (first characters) of the notice */
Str_Copy (Content,row[3],
Cns_MAX_BYTES_TEXT);
Str_Copy (Content,row[3],sizeof (Content) - 1);
Str_LimitLengthHTMLStr (Content,40); // Remove when notice has a Subject
fprintf (FileRSS,"<title>%s: ",Txt_Notice);
Str_FilePrintStrChangingBRToRetAndNBSPToSpace (FileRSS,Content);
@ -208,16 +205,15 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
Cfg_URL_SWAD_CGI,Crs->CrsCod);
/* Write full content of the notice */
Str_Copy (Content,row[3],
Cns_MAX_BYTES_TEXT);
Str_Copy (Content,row[3],sizeof (Content) - 1);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,40);
fprintf (FileRSS,"<description><![CDATA[<p><em>%s %s %s:</em></p><p>%s</p>]]></description>\n",
UsrDat.FirstName,UsrDat.Surname1,UsrDat.Surname2,Content);
UsrDat.FrstName,UsrDat.Surname1,UsrDat.Surname2,Content);
/* Write author */
if (UsrDat.Email[0])
fprintf (FileRSS,"<author>%s (%s %s %s)</author>\n",
UsrDat.Email,UsrDat.FirstName,UsrDat.Surname1,UsrDat.Surname2);
UsrDat.Email,UsrDat.FrstName,UsrDat.Surname1,UsrDat.Surname2);
/* Write unique string for this item */
fprintf (FileRSS,"<guid isPermaLink=\"false\">%s, course #%ld, notice #%ld</guid>\n",
@ -326,7 +322,6 @@ static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Crs_Course *Crs)
void RSS_BuildRSSLink (char RSSLink[Cns_MAX_BYTES_WWW + 1],long CrsCod)
{
snprintf (RSSLink,Cns_MAX_BYTES_WWW + 1,
"%s/%ld/%s/%s",
snprintf (RSSLink,Cns_MAX_BYTES_WWW + 1,"%s/%ld/%s/%s",
Cfg_URL_CRS_PUBLIC,CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
}

View File

@ -83,9 +83,9 @@ extern struct Globals Gbl;
static void Acc_ShowFormCheckIfIHaveAccount (const char *Title);
static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrData *UsrDat);
static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
static void Acc_ShowFormRequestNewAccountWithParams (const char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
const char *NewEmail);
static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
static bool Acc_GetParamsNewAccount (char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
char *NewEmail,
char *NewEncryptedPassword);
static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat);
@ -313,7 +313,7 @@ static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrD
/***** Button to login with this account *****/
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
Frm_StartForm (ActLogInNew);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Btn_PutCreateButtonInline (Txt_Its_me);
Frm_EndForm ();
HTM_TD_End ();
@ -353,7 +353,7 @@ void Acc_ShowFormCreateMyAccount (void)
/************ Show form to create a new account using parameters *************/
/*****************************************************************************/
static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
static void Acc_ShowFormRequestNewAccountWithParams (const char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
const char *NewEmail)
{
extern const char *Hlp_PROFILE_SignUp;
@ -363,7 +363,7 @@ static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWitho
extern const char *Txt_HELP_nickname;
extern const char *Txt_HELP_email;
extern const char *Txt_Email;
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewNickWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
/***** Begin form to enter some data of the new user *****/
Frm_StartForm (ActCreUsrAcc);
@ -374,12 +374,11 @@ static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWitho
Hlp_PROFILE_SignUp,Box_NOT_CLOSABLE,2);
/***** Nickname *****/
if (NewNicknameWithoutArroba[0])
snprintf (NewNicknameWithArroba,sizeof (NewNicknameWithArroba),
"@%s",
NewNicknameWithoutArroba);
if (NewNickWithoutArroba[0])
snprintf (NewNickWithArroba,sizeof (NewNickWithArroba),"@%s",
NewNickWithoutArroba);
else
NewNicknameWithArroba[0] = '\0';
NewNickWithArroba[0] = '\0';
HTM_TR_Begin (NULL);
/* Label */
@ -388,7 +387,7 @@ static void Acc_ShowFormRequestNewAccountWithParams (const char NewNicknameWitho
/* Data */
HTM_TD_Begin ("class=\"LT\"");
HTM_INPUT_TEXT ("NewNick",1 + Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA,
NewNicknameWithArroba,HTM_DONT_SUBMIT_ON_CHANGE,
NewNickWithArroba,HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"NewNick\" size=\"18\" placeholder=\"%s\" required=\"required\"",
Txt_HELP_nickname);
HTM_TD_End ();
@ -563,7 +562,7 @@ void Acc_PutLinkToRemoveMyAccount (__attribute__((unused)) void *Args)
if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Me.UsrDat.UsrCod))
Lay_PutContextualLinkOnlyIcon (ActReqRemMyAcc,NULL,
Acc_PutParamsToRemoveMyAccount,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
Acc_PutParamsToRemoveMyAccount,Gbl.Usrs.Me.UsrDat.EnUsrCod,
"trash.svg",
Txt_Remove_account);
}
@ -583,11 +582,11 @@ static void Acc_PutParamsToRemoveMyAccount (void *EncryptedUsrCod)
bool Acc_CreateMyNewAccountAndLogIn (void)
{
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewEmail[Cns_MAX_BYTES_EMAIL_ADDRESS + 1];
char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1];
if (Acc_GetParamsNewAccount (NewNicknameWithoutArroba,NewEmail,NewEncryptedPassword))
if (Acc_GetParamsNewAccount (NewNickWithoutArroba,NewEmail,NewEncryptedPassword))
{
/***** User's has no ID *****/
Gbl.Usrs.Me.UsrDat.IDs.Num = 0;
@ -595,23 +594,23 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
/***** Set password to the password typed by the user *****/
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword,
Pwd_BYTES_ENCRYPTED_PASSWORD);
sizeof (Gbl.Usrs.Me.UsrDat.Password) - 1);
/***** User does not exist in the platform, so create him/her! *****/
Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,
true); // I am creating my own account
/***** Save nickname *****/
Nck_UpdateNickInDB (Gbl.Usrs.Me.UsrDat.UsrCod,NewNicknameWithoutArroba);
Str_Copy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba,
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
Nck_UpdateNickInDB (Gbl.Usrs.Me.UsrDat.UsrCod,NewNickWithoutArroba);
Str_Copy (Gbl.Usrs.Me.UsrDat.Nickname,NewNickWithoutArroba,
sizeof (Gbl.Usrs.Me.UsrDat.Nickname) - 1);
/***** Save email *****/
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail))
{
/* Email updated sucessfully */
Str_Copy (Gbl.Usrs.Me.UsrDat.Email,NewEmail,
Cns_MAX_BYTES_EMAIL_ADDRESS);
sizeof (Gbl.Usrs.Me.UsrDat.Email) - 1);
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
}
@ -621,7 +620,7 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
else
{
/***** Show form again ******/
Acc_ShowFormRequestNewAccountWithParams (NewNicknameWithoutArroba,NewEmail);
Acc_ShowFormRequestNewAccountWithParams (NewNickWithoutArroba,NewEmail);
return false;
}
}
@ -631,7 +630,7 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
/*****************************************************************************/
// Return false on error
static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
static bool Acc_GetParamsNewAccount (char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
char *NewEmail,
char *NewEncryptedPassword)
{
@ -639,44 +638,43 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES
extern const char *Txt_The_nickname_entered_X_is_not_valid_;
extern const char *Txt_The_email_address_X_had_been_registered_by_another_user;
extern const char *Txt_The_email_address_entered_X_is_not_valid;
char NewNicknameWithArroba[1 + Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewNickWithArroba[1 + Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewPlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1];
bool Error = false;
/***** Step 1/3: Get new nickname from form *****/
Par_GetParToText ("NewNick",NewNicknameWithArroba,
Par_GetParToText ("NewNick",NewNickWithArroba,
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
/* Remove arrobas at the beginning */
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
Str_Copy (NewNickWithoutArroba,NewNickWithArroba,
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
Str_RemoveLeadingArrobas (NewNickWithoutArroba);
/* Create a new version of the nickname with arroba */
snprintf (NewNicknameWithArroba,sizeof (NewNicknameWithArroba),
"@%s",
NewNicknameWithoutArroba);
snprintf (NewNickWithArroba,sizeof (NewNickWithArroba),"@%s",
NewNickWithoutArroba);
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
if (Nck_CheckIfNickWithArrobaIsValid (NewNickWithArroba)) // If new nickname is valid
{
/* Check if the new nickname
matches any of the nicknames of other users */
if (DB_QueryCOUNT ("can not check if nickname already existed",
"SELECT COUNT(*) FROM usr_nicknames"
" WHERE Nickname='%s' AND UsrCod<>%ld",
NewNicknameWithoutArroba,
NewNickWithoutArroba,
Gbl.Usrs.Me.UsrDat.UsrCod)) // A nickname of another user is the same that this nickname
{
Error = true;
Ale_ShowAlert (Ale_WARNING,Txt_The_nickname_X_had_been_registered_by_another_user,
NewNicknameWithoutArroba);
NewNickWithoutArroba);
}
}
else // New nickname is not valid
{
Error = true;
Ale_ShowAlert (Ale_WARNING,Txt_The_nickname_entered_X_is_not_valid_,
NewNicknameWithArroba,
NewNickWithArroba,
Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA,
Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA);
}
@ -773,9 +771,9 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
"'%s','%s',"
"%s,'%s',"
"%u,%u,-1,0)",
UsrDat->EncryptedUsrCod,
UsrDat->EnUsrCod,
UsrDat->Password,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FrstName,
Usr_StringsSexDB[UsrDat->Sex],
The_ThemeId[UsrDat->Prefs.Theme],
Ico_IconSetId[UsrDat->Prefs.IconSet],
@ -836,8 +834,8 @@ static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat)
NumTry++)
{
Str_CreateRandomAlphanumStr (RandomStr,LENGTH_RANDOM_STR);
Cry_EncryptSHA256Base64 (RandomStr,UsrDat->EncryptedUsrCod);
if (!Usr_ChkIfEncryptedUsrCodExists (UsrDat->EncryptedUsrCod))
Cry_EncryptSHA256Base64 (RandomStr,UsrDat->EnUsrCod);
if (!Usr_ChkIfEncryptedUsrCodExists (UsrDat->EnUsrCod))
break;
}
if (NumTry == MAX_TRY)
@ -985,7 +983,7 @@ static void Acc_AskIfRemoveOtherUsrAccount (void)
/* Show form to request confirmation */
Frm_StartForm (ActRemUsrGbl);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
Pwd_AskForConfirmationOnDangerousAction ();
Btn_PutRemoveButton (Txt_Eliminate_user_account);
Frm_EndForm ();

View File

@ -3965,8 +3965,7 @@ static const char *Act_GetActionTextFromDB (long ActCod) // TODO: Remove when da
{
/***** Get text *****/
row = mysql_fetch_row (mysql_res);
Str_Copy (ActTxt,row[0],
Act_MAX_BYTES_ACTION_TXT);
Str_Copy (ActTxt,row[0],sizeof (ActTxt) - 1);
}
else // ActCod-Language not found on database
ActTxt[0] = '\0';
@ -4084,7 +4083,7 @@ void Act_AdjustCurrentAction (void)
the only action possible
is to show a form to change my shared record card *****/
if ( Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN ||
!Gbl.Usrs.Me.UsrDat.FirstName[0] ||
!Gbl.Usrs.Me.UsrDat.FrstName[0] ||
!Gbl.Usrs.Me.UsrDat.Surname1 [0] ||
Gbl.Usrs.Me.UsrDat.CtyCod <= 0 ||
Gbl.Usrs.Me.UsrDat.InsCod < 0 ||

View File

@ -170,9 +170,7 @@ void Agd_PutParamAgd (void)
{
char Nickname[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
snprintf (Nickname,sizeof (Nickname),
"@%s",
Gbl.Usrs.Other.UsrDat.Nickname);
snprintf (Nickname,sizeof (Nickname),"@%s",Gbl.Usrs.Other.UsrDat.Nickname);
Par_PutHiddenParamString (NULL,"agd",Nickname);
}
@ -411,12 +409,12 @@ void Agd_ShowUsrAgenda (void)
if (ItsMe)
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
Gbl.Usrs.Me.UsrDat.FullName),
Agd_PutIconsMyPublicAgenda,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
Agd_PutIconsMyPublicAgenda,Gbl.Usrs.Me.UsrDat.EnUsrCod,
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
else
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
Gbl.Usrs.Other.UsrDat.FullName),
Agd_PutIconsOtherPublicAgenda,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Agd_PutIconsOtherPublicAgenda,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
Str_FreeString ();
@ -463,12 +461,12 @@ void Agd_ShowOtherAgendaAfterLogIn (void)
if (ItsMe)
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
Gbl.Usrs.Me.UsrDat.FullName),
Agd_PutIconToViewEditMyFullAgenda,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
Agd_PutIconToViewEditMyFullAgenda,Gbl.Usrs.Me.UsrDat.EnUsrCod,
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
else
Box_BoxBegin ("100%",Str_BuildStringStr (Txt_Public_agenda_USER,
Gbl.Usrs.Other.UsrDat.FullName),
Agd_PutIconsOtherPublicAgenda,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Agd_PutIconsOtherPublicAgenda,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Hlp_PROFILE_Agenda_public_agenda,Box_NOT_CLOSABLE);
Str_FreeString ();
@ -650,7 +648,7 @@ static void Agd_WriteHeaderListEvents (const struct Agd_Agenda *Agenda,
case Agd_ANOTHER_AGENDA_TODAY:
case Agd_ANOTHER_AGENDA:
Frm_StartForm (ActSeeUsrAgd);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
Pag_PutHiddenParamPagNum (Pag_ANOTHER_AGENDA,Agenda->CurrentPage);
break;
}
@ -723,10 +721,8 @@ static void Agd_PutIconToShowQR (void)
char URL[Cns_MAX_BYTES_WWW + 1];
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
snprintf (URL,sizeof (URL),
"%s/%s?agd=@%s",
Cfg_URL_SWAD_CGI,
Lan_STR_LANG_ID[Gbl.Prefs.Language],
snprintf (URL,sizeof (URL),"%s/%s?agd=@%s",
Cfg_URL_SWAD_CGI,Lan_STR_LANG_ID[Gbl.Prefs.Language],
Gbl.Usrs.Me.UsrDat.Nickname);
QR_PutLinkToPrintQRCode (ActPrnAgdQR,
QR_PutParamQRString,URL);
@ -1047,9 +1043,9 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
Agd_AgendaType_t AgendaType)
{
char *UsrSubQuery;
char Past__FutureEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
char PrivatPublicEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
char HiddenVisiblEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
char Past__FutureEventsSubQuery[Agd_MAX_BYTES_SUBQUERY + 1];
char PrivatPublicEventsSubQuery[Agd_MAX_BYTES_SUBQUERY + 1];
char HiddenVisiblEventsSubQuery[Agd_MAX_BYTES_SUBQUERY + 1];
static const char *OrderBySubQuery[Dat_NUM_START_END_TIME] =
{
[Dat_START_TIME] = "StartTime,EndTime,Event,Location",
@ -1083,19 +1079,19 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
Str_Copy (Past__FutureEventsSubQuery,
" AND DATE(StartTime)<=CURDATE()"
" AND DATE(EndTime)>=CURDATE()",
Agd_MAX_BYTES_SUBQUERY); // Today events
sizeof (Past__FutureEventsSubQuery) - 1); // Today events
else
switch (Agenda->Past__FutureEvents)
{
case (1 << Agd_PAST___EVENTS):
Str_Copy (Past__FutureEventsSubQuery,
" AND DATE(StartTime)<=CURDATE()",
Agd_MAX_BYTES_SUBQUERY); // Past and today events
sizeof (Past__FutureEventsSubQuery) - 1); // Past and today events
break;
case (1 << Agd_FUTURE_EVENTS):
Str_Copy (Past__FutureEventsSubQuery,
" AND DATE(EndTime)>=CURDATE()",
Agd_MAX_BYTES_SUBQUERY); // Today and future events
sizeof (Past__FutureEventsSubQuery) - 1); // Today and future events
break;
default:
Past__FutureEventsSubQuery[0] = '\0'; // All events
@ -1105,11 +1101,11 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
{
case (1 << Agd_PRIVAT_EVENTS):
Str_Copy (PrivatPublicEventsSubQuery," AND Public='N'",
Agd_MAX_BYTES_SUBQUERY); // Private events
sizeof (PrivatPublicEventsSubQuery) - 1); // Private events
break;
case (1 << Agd_PUBLIC_EVENTS):
Str_Copy (PrivatPublicEventsSubQuery," AND Public='Y'",
Agd_MAX_BYTES_SUBQUERY); // Public events
sizeof (PrivatPublicEventsSubQuery) - 1); // Public events
break;
default:
PrivatPublicEventsSubQuery[0] = '\0'; // All events
@ -1119,11 +1115,11 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
{
case (1 << Agd_HIDDEN_EVENTS):
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='Y'",
Agd_MAX_BYTES_SUBQUERY); // Hidden events
sizeof (HiddenVisiblEventsSubQuery) - 1); // Hidden events
break;
case (1 << Agd_VISIBL_EVENTS):
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='N'",
Agd_MAX_BYTES_SUBQUERY); // Visible events
sizeof (HiddenVisiblEventsSubQuery) - 1); // Visible events
break;
default:
HiddenVisiblEventsSubQuery[0] = '\0'; // All events
@ -1140,15 +1136,15 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
Str_Copy (Past__FutureEventsSubQuery,
" AND DATE(StartTime)<=CURDATE()"
" AND DATE(EndTime)>=CURDATE()",
Agd_MAX_BYTES_SUBQUERY); // Today events
sizeof (Past__FutureEventsSubQuery) - 1); // Today events
else
Str_Copy (Past__FutureEventsSubQuery,
" AND DATE(EndTime)>=CURDATE()",
Agd_MAX_BYTES_SUBQUERY); // Today and future events
sizeof (Past__FutureEventsSubQuery) - 1); // Today and future events
Str_Copy (PrivatPublicEventsSubQuery," AND Public='Y'",
Agd_MAX_BYTES_SUBQUERY); // Public events
sizeof (PrivatPublicEventsSubQuery) - 1); // Public events
Str_Copy (HiddenVisiblEventsSubQuery," AND Hidden='N'",
Agd_MAX_BYTES_SUBQUERY); // Visible events
sizeof (HiddenVisiblEventsSubQuery) - 1); // Visible events
}
if (DoQuery)
@ -1172,7 +1168,8 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
Agenda->Num = (unsigned) NumRows;
/***** Create list of events *****/
if ((Agenda->LstAgdCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
if ((Agenda->LstAgdCods = calloc (NumRows,
sizeof (*Agenda->LstAgdCods))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the events codes *****/
@ -1251,12 +1248,10 @@ static void Agd_GetDataOfEventByCod (struct Agd_Event *AgdEvent)
Dat_PRESENT));
/* Get the event (row[7]) */
Str_Copy (AgdEvent->Event,row[7],
Agd_MAX_BYTES_EVENT);
Str_Copy (AgdEvent->Event ,row[7],sizeof (AgdEvent->Event ) - 1);
/* Get the event (row[8]) */
Str_Copy (AgdEvent->Location,row[8],
Agd_MAX_BYTES_LOCATION);
Str_Copy (AgdEvent->Location,row[8],sizeof (AgdEvent->Location) - 1);
}
else
{
@ -1313,8 +1308,7 @@ static void Agd_GetEventTxtFromDB (struct Agd_Event *AgdEvent,
{
/* Get info text */
row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
}
else
Txt[0] = '\0';

View File

@ -156,12 +156,10 @@ void Ann_ShowAllAnnouncements (void)
Lay_ShowErrorAndExit ("Error when reading roles of announcement.");
/* Get the content (row[3]) */
Str_Copy (Subject,row[3],
Cns_MAX_BYTES_SUBJECT);
Str_Copy (Subject,row[3],sizeof (Subject) - 1);
/* Get the content (row[4]) and insert links */
Str_Copy (Content,row[4],
Cns_MAX_BYTES_TEXT);
Str_Copy (Content,row[4],sizeof (Content) - 1);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
/* Show the announcement */
@ -248,12 +246,10 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
Lay_ShowErrorAndExit ("Wrong code of announcement.");
/* Get the content (row[1]) */
Str_Copy (Subject,row[1],
Cns_MAX_BYTES_SUBJECT);
Str_Copy (Subject,row[1],sizeof (Subject) - 1);
/* Get the content (row[2]) and insert links */
Str_Copy (Content,row[2],
Cns_MAX_BYTES_TEXT);
Str_Copy (Content,row[2],sizeof (Content) - 1);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
/* Show the announcement */

View File

@ -543,8 +543,9 @@ static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView
case Rol_TCH:
case Rol_SYS_ADM:
Gbl.FileBrowser.Type = Brw_ADMI_ASG_CRS; // Course assignments
Str_Copy (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Str_Copy (Gbl.Usrs.Other.UsrDat.EnUsrCod,
Gbl.Usrs.Me.UsrDat.EnUsrCod,
sizeof (Gbl.Usrs.Other.UsrDat.EnUsrCod) - 1);
Usr_CreateListSelectedUsrsCodsAndFillWithOtherUsr (&Gbl.Usrs.Selected);
Frm_StartForm (ActFrmCreAsgCrs);
break;
@ -552,10 +553,11 @@ static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView
Rol_WrongRoleExit ();
break;
}
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS,
PATH_MAX);
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,
Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS,
sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1);
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,Asg->Folder,
NAME_MAX);
sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1);
Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_FOLDER;
Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
Ico_PutIconLink ("folder-open-yellow-plus.png",
@ -720,7 +722,8 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
Assignments->Num = (unsigned) NumRows;
/***** Create list of assignments *****/
if ((Assignments->LstAsgCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
if ((Assignments->LstAsgCods = calloc (NumRows,
sizeof (*Assignments->LstAsgCods))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the assignments codes *****/
@ -863,12 +866,10 @@ static void Asg_GetDataOfAssignment (struct Asg_Assignment *Asg,
Asg->Open = (row[5][0] == '1');
/* Get the title of the assignment (row[6]) */
Str_Copy (Asg->Title,row[6],
Asg_MAX_BYTES_ASSIGNMENT_TITLE);
Str_Copy (Asg->Title ,row[6],sizeof (Asg->Title ) - 1);
/* Get the folder for the assignment files (row[7]) */
Str_Copy (Asg->Folder,row[7],
Brw_MAX_BYTES_FOLDER);
Str_Copy (Asg->Folder,row[7],sizeof (Asg->Folder) - 1);
Asg->SendWork = (Asg->Folder[0] != '\0');
/* Can I do this assignment? */
@ -937,8 +938,7 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT
{
/* Get info text */
row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
}
else
Txt[0] = '\0';
@ -979,17 +979,15 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
row = mysql_fetch_row (mysql_res);
/***** Get summary *****/
Str_Copy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
/***** Get content *****/
if (GetContent)
{
Length = strlen (row[1]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[1],
Length);
if ((*ContentStr = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (*ContentStr,row[1],Length);
}
}

View File

@ -371,7 +371,7 @@ static void Att_PutIconsInListOfAttEvents (void *Events)
/***** Put icon to print my QR code *****/
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod);
}
}
@ -705,7 +705,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
Events->Num = (unsigned) NumRows;
/***** Create list of attendance events *****/
if ((Events->Lst = (struct Att_Event *) calloc (NumRows,sizeof (struct Att_Event))) == NULL)
if ((Events->Lst = calloc (NumRows,sizeof (*Events->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the attendance events codes *****/
@ -804,8 +804,7 @@ bool Att_GetDataOfAttEventByCod (struct Att_Event *Event)
Event->CommentTchVisible = (row[7][0] == 'Y');
/* Get the title of the attendance event (row[8]) */
Str_Copy (Event->Title,row[8],
Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE);
Str_Copy (Event->Title,row[8],sizeof (Event->Title) - 1);
}
/***** Free structure that stores the query result *****/
@ -877,8 +876,7 @@ static void Att_GetAttEventDescriptionFromDB (long AttCod,char Description[Cns_M
row = mysql_fetch_row (mysql_res);
/* Get info text */
Str_Copy (Description,row[0],
Cns_MAX_BYTES_TEXT);
Str_Copy (Description,row[0],Cns_MAX_BYTES_TEXT);
}
else
Description[0] = '\0';
@ -2128,7 +2126,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd);
HTM_INPUT_CHECKBOX ("UsrCodStd",HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Std%u\" value=\"%s\"%s%s",
NumUsr,UsrDat->EncryptedUsrCod,
NumUsr,UsrDat->EnUsrCod,
Present ? " checked=\"checked\"" : "",
ICanChangeStdAttendance ? "" : " disabled=\"disabled\"");
HTM_TD_End ();
@ -2168,7 +2166,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
HTM_Txt (UsrDat->Surname1);
if (UsrDat->Surname2[0])
HTM_TxtF ("&nbsp;%s",UsrDat->Surname2);
HTM_TxtF (", %s",UsrDat->FirstName);
HTM_TxtF (", %s",UsrDat->FrstName);
HTM_TD_End ();
/***** Student's comment: write form or text */
@ -2176,7 +2174,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
if (ICanEditStdComment) // Show with form
{
HTM_TEXTAREA_Begin ("name=\"CommentStd%s\" cols=\"40\" rows=\"3\"",
UsrDat->EncryptedUsrCod);
UsrDat->EnUsrCod);
HTM_Txt (CommentStd);
HTM_TEXTAREA_End ();
}
@ -2193,7 +2191,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
if (ICanEditTchComment) // Show with form
{
HTM_TEXTAREA_Begin ("name=\"CommentTch%s\" cols=\"40\" rows=\"3\"",
UsrDat->EncryptedUsrCod);
UsrDat->EnUsrCod);
HTM_Txt (CommentTch);
HTM_TEXTAREA_End ();
}
@ -2253,7 +2251,7 @@ static void Att_PutParamsCodGrps (long AttCod)
if (NumGrps) // Groups found...
{
MaxLengthGrpCods = NumGrps * (1 + 20) - 1;
if ((GrpCods = (char *) malloc (MaxLengthGrpCods + 1)) == NULL)
if ((GrpCods = malloc (MaxLengthGrpCods + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
GrpCods[0] = '\0';
@ -2310,7 +2308,7 @@ void Att_RegisterMeAsStdInAttEvent (void)
Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Event.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod,
CommentStd,CommentTch);
Par_GetParToHTML (Str_BuildStringStr ("CommentStd%s",
Gbl.Usrs.Me.UsrDat.EncryptedUsrCod),
Gbl.Usrs.Me.UsrDat.EnUsrCod),
CommentStd,Cns_MAX_BYTES_TEXT);
Str_FreeString ();
@ -2396,7 +2394,7 @@ void Att_RegisterStudentsInAttEvent (void)
Ptr = Gbl.Usrs.Selected.List[Rol_STD];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrData.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrData.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrData);
if (UsrData.UsrCod > 0) // Student exists in database
@ -2427,7 +2425,7 @@ void Att_RegisterStudentsInAttEvent (void)
/***** Get comments for this student *****/
Att_CheckIfUsrIsPresentInAttEventAndGetComments (Event.AttCod,Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].UsrCod,CommentStd,CommentTch);
Par_GetParToHTML (Str_BuildStringStr ("CommentTch%s",
Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].EncryptedUsrCod),
Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].EnUsrCod),
CommentTch,Cns_MAX_BYTES_TEXT);
Str_FreeString ();
@ -2603,12 +2601,10 @@ static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long Us
Present = (row[0][0] == 'Y');
/* Get student's comment (row[1]) */
Str_Copy (CommentStd,row[1],
Cns_MAX_BYTES_TEXT);
Str_Copy (CommentStd,row[1],Cns_MAX_BYTES_TEXT);
/* Get teacher's comment (row[2]) */
Str_Copy (CommentTch,row[2],
Cns_MAX_BYTES_TEXT);
Str_Copy (CommentTch,row[2],Cns_MAX_BYTES_TEXT);
}
else // User is not present
{
@ -2977,7 +2973,7 @@ static void Att_GetListSelectedAttCods (struct Att_Events *Events)
/***** Allocate memory for list of attendance events selected *****/
MaxSizeListAttCodsSelected = (size_t) Events->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
if ((Events->StrAttCodsSelected = (char *) malloc (MaxSizeListAttCodsSelected + 1)) == NULL)
if ((Events->StrAttCodsSelected = malloc (MaxSizeListAttCodsSelected + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get parameter multiple with list of attendance events selected *****/
@ -3083,7 +3079,7 @@ static void Att_PutIconsMyAttList (void *Events)
/***** Put icon to print my QR code *****/
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod);
}
}
@ -3113,7 +3109,7 @@ static void Att_PutIconsStdsAttList (void *Events)
/***** Put icon to print my QR code *****/
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod);
}
}
@ -3422,9 +3418,7 @@ static void Att_WriteTableHeadSeveralAttEvents (const struct Att_Events *Events)
/***** Put link to this attendance event *****/
HTM_TH_Begin (1,1,"CM");
snprintf (StrNumAttEvent,sizeof (StrNumAttEvent),
"%u",
NumAttEvent + 1);
snprintf (StrNumAttEvent,sizeof (StrNumAttEvent),"%u",NumAttEvent + 1);
Att_PutLinkAttEvent (&Events->Lst[NumAttEvent],
Events->Lst[NumAttEvent].Title,
StrNumAttEvent,
@ -3487,7 +3481,7 @@ static void Att_WriteRowUsrSeveralAttEvents (const struct Att_Events *Events,
HTM_Txt (UsrDat->Surname1);
if (UsrDat->Surname2[0])
HTM_TxtF ("&nbsp;%s",UsrDat->Surname2);
HTM_TxtF (", %s",UsrDat->FirstName);
HTM_TxtF (", %s",UsrDat->FrstName);
HTM_TD_End ();
/***** Check/cross to show if the user is present/absent *****/
@ -3646,7 +3640,7 @@ static void Att_ListAttEventsForAStd (const struct Att_Events *Events,
HTM_Txt (UsrDat->Surname1);
if (UsrDat->Surname2[0])
HTM_TxtF ("&nbsp;%s",UsrDat->Surname2);
HTM_TxtF (", %s",UsrDat->FirstName);
HTM_TxtF (", %s",UsrDat->FrstName);
HTM_TD_End ();
HTM_TR_End ();

View File

@ -297,8 +297,7 @@ static void Ban_GetListBanners (struct Ban_Banners *Banners,
Banners->Num = (unsigned) NumRows;
/***** Create list with banners *****/
if ((Banners->Lst = (struct Ban_Banner *)
calloc (NumRows,sizeof (struct Ban_Banner))) == NULL)
if ((Banners->Lst = calloc (NumRows,sizeof (*Banners->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the banners *****/
@ -319,20 +318,16 @@ static void Ban_GetListBanners (struct Ban_Banners *Banners,
Ban->Hidden = (row[1][0] == 'Y');
/* Get the short name of the banner (row[2]) */
Str_Copy (Ban->ShrtName,row[2],
Ban_MAX_BYTES_SHRT_NAME);
Str_Copy (Ban->ShrtName,row[2],sizeof (Ban->ShrtName) - 1);
/* Get the full name of the banner (row[3]) */
Str_Copy (Ban->FullName,row[3],
Ban_MAX_BYTES_FULL_NAME);
Str_Copy (Ban->FullName,row[3],sizeof (Ban->FullName) - 1);
/* Get the image of the banner (row[4]) */
Str_Copy (Ban->Img,row[4],
Ban_MAX_BYTES_IMAGE);
Str_Copy (Ban->Img ,row[4],sizeof (Ban->Img ) - 1);
/* Get the URL of the banner (row[5]) */
Str_Copy (Ban->WWW,row[5],
Cns_MAX_BYTES_WWW);
Str_Copy (Ban->WWW ,row[5],sizeof (Ban->WWW ) - 1);
}
}
else
@ -373,20 +368,16 @@ void Ban_GetDataOfBannerByCod (struct Ban_Banner *Ban)
Ban->Hidden = (row[0][0] == 'Y');
/* Get the short name of the banner (row[1]) */
Str_Copy (Ban->ShrtName,row[1],
Ban_MAX_BYTES_SHRT_NAME);
Str_Copy (Ban->ShrtName,row[1],sizeof (Ban->ShrtName) - 1);
/* Get the full name of the banner (row[2]) */
Str_Copy (Ban->FullName,row[2],
Ban_MAX_BYTES_FULL_NAME);
Str_Copy (Ban->FullName,row[2],sizeof (Ban->FullName) - 1);
/* Get the image of the banner (row[3]) */
Str_Copy (Ban->Img,row[3],
Ban_MAX_BYTES_IMAGE);
Str_Copy (Ban->Img ,row[3],sizeof (Ban->Img ) - 1);
/* Get the URL of the banner (row[4]) */
Str_Copy (Ban->WWW,row[4],
Cns_MAX_BYTES_WWW);
Str_Copy (Ban->WWW ,row[4],sizeof (Ban->WWW ) - 1);
}
/***** Free structure that stores the query result *****/
@ -767,8 +758,7 @@ static void Ban_RenameBanner (struct Ban_Banner *Ban,
}
/***** Update name *****/
Str_Copy (CurrentBanName,NewBanName,
MaxBytes);
Str_Copy (CurrentBanName,NewBanName,MaxBytes);
}
/*****************************************************************************/
@ -841,8 +831,7 @@ void Ban_ChangeBannerImg (void)
Txt_You_can_not_leave_the_image_empty);
/***** Update image *****/
Str_Copy (Ban.Img,NewImg,
Ban_MAX_BYTES_IMAGE);
Str_Copy (Ban.Img,NewImg,sizeof (Ban.Img) - 1);
/***** Set editing banner to use ot in a posterior function *****/
Ban_SetEditingBanner (&Ban);
@ -889,8 +878,7 @@ void Ban_ChangeBannerWWW (void)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update web *****/
Str_Copy (Ban.WWW,NewWWW,
Cns_MAX_BYTES_WWW);
Str_Copy (Ban.WWW,NewWWW,sizeof (Ban.WWW) - 1);
/***** Set editing banner to use ot in a posterior function *****/
Ban_SetEditingBanner (&Ban);

View File

@ -132,8 +132,8 @@ static void Box_BoxInternalBegin (const char *Width,const char *Title,
/***** Create unique identifier for this box *****/
if (Closable == Box_CLOSABLE)
{
if ((Gbl.Box.Ids[Gbl.Box.Nested] = (char *) malloc (Frm_MAX_BYTES_ID + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for box id.");
if ((Gbl.Box.Ids[Gbl.Box.Nested] = malloc (Frm_MAX_BYTES_ID + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
}
else
Gbl.Box.Ids[Gbl.Box.Nested] = NULL;

View File

@ -355,9 +355,7 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
Buildings->Num = (unsigned) NumRows;
/***** Create list with courses in centre *****/
if ((Buildings->Lst = (struct Bld_Building *)
calloc (NumRows,
sizeof (struct Bld_Building))) == NULL)
if ((Buildings->Lst = calloc (NumRows,sizeof (*Buildings->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the buildings *****/
@ -375,18 +373,17 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
Lay_ShowErrorAndExit ("Wrong code of building.");
/* Get the short name of the building (row[1]) */
Str_Copy (Building->ShrtName,row[1],
Bld_MAX_BYTES_SHRT_NAME);
Str_Copy (Building->ShrtName,row[1],sizeof (Building->ShrtName) - 1);
if (WhichData == Bld_ALL_DATA)
{
/* Get the full name of the building (row[2]) */
Str_Copy (Building->FullName,row[2],
Bld_MAX_BYTES_FULL_NAME);
sizeof (Building->FullName) - 1);
/* Get the full name of the building (row[3]) */
Str_Copy (Building->Location,row[3],
Bld_MAX_BYTES_LOCATION);
sizeof (Building->Location) - 1);
}
}
}
@ -431,16 +428,13 @@ void Bld_GetDataOfBuildingByCod (struct Bld_Building *Building)
row = mysql_fetch_row (mysql_res);
/* Get the short name of the building (row[0]) */
Str_Copy (Building->ShrtName,row[0],
Bld_MAX_BYTES_SHRT_NAME);
Str_Copy (Building->ShrtName,row[0],sizeof (Building->ShrtName) - 1);
/* Get the full name of the building (row[1]) */
Str_Copy (Building->FullName,row[1],
Bld_MAX_BYTES_FULL_NAME);
Str_Copy (Building->FullName,row[1],sizeof (Building->FullName) - 1);
/* Get the location of the building (row[2]) */
Str_Copy (Building->Location,row[2],
Bld_MAX_BYTES_LOCATION);
Str_Copy (Building->Location,row[2],sizeof (Building->Location) - 1);
}
/***** Free structure that stores the query result *****/
@ -709,8 +703,7 @@ static void Bld_RenameBuilding (Cns_ShrtOrFullName_t ShrtOrFullName)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update building name *****/
Str_Copy (CurrentClaName,NewClaName,
MaxBytes);
Str_Copy (CurrentClaName,NewClaName,MaxBytes);
}
/*****************************************************************************/
@ -772,7 +765,7 @@ void Bld_ChangeBuildingLocation (void)
/* Update the table changing old name by new name */
Bld_UpdateBuildingNameDB (Bld_EditingBuilding->BldCod,"Location",NewLocation);
Str_Copy (Bld_EditingBuilding->Location,NewLocation,
Bld_MAX_BYTES_LOCATION);
sizeof (Bld_EditingBuilding->Location) - 1);
/* Write message to show the change made */
Ale_CreateAlert (Ale_SUCCESS,NULL,
@ -958,8 +951,8 @@ static void Bld_EditingBuildingConstructor (void)
Lay_ShowErrorAndExit ("Error initializing building.");
/***** Allocate memory for building *****/
if ((Bld_EditingBuilding = (struct Bld_Building *) malloc (sizeof (struct Bld_Building))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for building.");
if ((Bld_EditingBuilding = malloc (sizeof (*Bld_EditingBuilding))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset building *****/
Bld_EditingBuilding->BldCod = -1L;

View File

@ -128,9 +128,7 @@ void Cal_ShowFormToSelFirstDayOfWeek (Act_Action_t Action,
Par_PutHiddenParamUnsigned (NULL,"FirstDayOfWeek",FirstDayOfWeek);
if (FuncParams) // Extra parameters depending on the action
FuncParams (Args);
snprintf (Icon,sizeof (Icon),
"first-day-of-week-%u.png",
FirstDayOfWeek);
snprintf (Icon,sizeof (Icon),"first-day-of-week-%u.png",FirstDayOfWeek);
Ico_PutSettingIconLink (Icon,
Str_BuildStringStr (Txt_First_day_of_the_week_X,
Txt_DAYS_SMALL[FirstDayOfWeek]));

View File

@ -571,8 +571,8 @@ void Ctr_GetBasicListOfCentres (long InsCod)
Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows;
/***** Create list with courses in degree *****/
if ((Gbl.Hierarchy.Ctrs.Lst = (struct Ctr_Centre *) calloc (NumRows,
sizeof (struct Ctr_Centre))) == NULL)
if ((Gbl.Hierarchy.Ctrs.Lst = calloc (NumRows,
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the centres *****/
@ -660,8 +660,8 @@ void Ctr_GetFullListOfCentres (long InsCod)
Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows;
/***** Create list with courses in degree *****/
if ((Gbl.Hierarchy.Ctrs.Lst = (struct Ctr_Centre *) calloc (NumRows,
sizeof (struct Ctr_Centre))) == NULL)
if ((Gbl.Hierarchy.Ctrs.Lst = calloc (NumRows,
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the centres *****/
@ -778,16 +778,13 @@ static void Ctr_GetDataOfCentreFromRow (struct Ctr_Centre *Ctr,MYSQL_ROW row)
Ctr->Coord.Altitude = Map_GetAltitudeFromStr (row[7]);
/***** Get the short name of the centre (row[8]) *****/
Str_Copy (Ctr->ShrtName,row[8],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (Ctr->ShrtName,row[8],sizeof (Ctr->ShrtName) - 1);
/***** Get the full name of the centre (row[9]) *****/
Str_Copy (Ctr->FullName,row[9],
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
Str_Copy (Ctr->FullName,row[9],sizeof (Ctr->FullName) - 1);
/***** Get the URL of the centre (row[10]) *****/
Str_Copy (Ctr->WWW,row[10],
Cns_MAX_BYTES_WWW);
Str_Copy (Ctr->WWW,row[10],sizeof (Ctr->WWW) - 1);
}
/*****************************************************************************/
@ -840,8 +837,7 @@ void Ctr_GetShortNameOfCentreByCod (struct Ctr_Centre *Ctr)
/***** Get the short name of this centre *****/
row = mysql_fetch_row (mysql_res);
Str_Copy (Ctr->ShrtName,row[0],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (Ctr->ShrtName,row[0],sizeof (Ctr->ShrtName) - 1);
}
/***** Free structure that stores the query result *****/
@ -1064,8 +1060,7 @@ static void Ctr_ListCentresForEdition (const struct Plc_Places *Places)
}
else
{
Str_Copy (WWW,Ctr->WWW,
Cns_MAX_BYTES_WWW);
Str_Copy (WWW,Ctr->WWW,sizeof (WWW) - 1);
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
HTM_A_Begin ("href=\"%s\" target=\"_blank\""
" class=\"DAT\" title=\"%s\"",Ctr->WWW,Ctr->WWW);
@ -1266,11 +1261,10 @@ void Ctr_RemoveCentre (void)
Roo_RemoveAllRoomsInCtr (Ctr_EditingCtr->CtrCod);
/***** Remove directories of the centre *****/
snprintf (PathCtr,sizeof (PathCtr),
"%s/%02u/%u",
snprintf (PathCtr,sizeof (PathCtr),"%s/%02u/%u",
Cfg_PATH_CTR_PUBLIC,
(unsigned) (Ctr_EditingCtr->CtrCod % 100),
(unsigned) Ctr_EditingCtr->CtrCod);
(unsigned) Ctr_EditingCtr->CtrCod);
Fil_RemoveTree (PathCtr);
/***** Remove centre *****/
@ -1421,8 +1415,7 @@ void Ctr_RenameCentre (struct Ctr_Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFullNam
CurrentCtrName,NewCtrName);
/* Change current centre name in order to display it properly */
Str_Copy (CurrentCtrName,NewCtrName,
MaxBytes);
Str_Copy (CurrentCtrName,NewCtrName,MaxBytes);
}
}
else // The same name
@ -1485,8 +1478,7 @@ void Ctr_ChangeCtrWWW (void)
{
/***** Update database changing old WWW by new WWW *****/
Ctr_UpdateCtrWWWDB (Ctr_EditingCtr->CtrCod,NewWWW);
Str_Copy (Ctr_EditingCtr->WWW,NewWWW,
Cns_MAX_BYTES_WWW);
Str_Copy (Ctr_EditingCtr->WWW,NewWWW,sizeof (Ctr_EditingCtr->WWW) - 1);
/***** Write message to show the change made
and put button to go to centre changed *****/
@ -2279,8 +2271,8 @@ static void Ctr_EditingCentreConstructor (void)
Lay_ShowErrorAndExit ("Error initializing centre.");
/***** Allocate memory for centre *****/
if ((Ctr_EditingCtr = (struct Ctr_Centre *) malloc (sizeof (struct Ctr_Centre))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for centre.");
if ((Ctr_EditingCtr = malloc (sizeof (*Ctr_EditingCtr))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset centre *****/
Ctr_EditingCtr->CtrCod = -1L;

View File

@ -228,12 +228,11 @@ static void CtrCfg_Configuration (bool PrintView)
MapIsAvailable = Ctr_GetIfMapIsAvailable (&Gbl.Hierarchy.Ctr);
/***** Check photo *****/
snprintf (PathPhoto,sizeof (PathPhoto),
"%s/%02u/%u/%u.jpg",
snprintf (PathPhoto,sizeof (PathPhoto),"%s/%02u/%u/%u.jpg",
Cfg_PATH_CTR_PUBLIC,
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
PhotoExists = Fil_CheckIfPathExists (PathPhoto);
if (MapIsAvailable || PhotoExists)
@ -292,8 +291,7 @@ static void CtrCfg_PutIconToChangePhoto (void)
bool PhotoExists;
/***** Link to upload photo of centre *****/
snprintf (PathPhoto,sizeof (PathPhoto),
"%s/%02u/%u/%u.jpg",
snprintf (PathPhoto,sizeof (PathPhoto),"%s/%02u/%u/%u.jpg",
Cfg_PATH_CTR_PUBLIC,
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
@ -531,10 +529,9 @@ static void CtrCfg_GetPhotoAttr (long CtrCod,char **PhotoAttribution)
if (row[0][0])
{
Length = strlen (row[0]);
if (((*PhotoAttribution) = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for photo attribution.");
Str_Copy (*PhotoAttribution,row[0],
Length);
if (((*PhotoAttribution) = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (*PhotoAttribution,row[0],Length);
}
}
@ -936,8 +933,7 @@ void CtrCfg_ReceivePhoto (void)
}
/* End the reception of image in a temporary file */
snprintf (PathFileImgTmp,sizeof (PathFileImgTmp),
"%s/%s.%s",
snprintf (PathFileImgTmp,sizeof (PathFileImgTmp),"%s/%s.%s",
Cfg_PATH_MEDIA_TMP_PRIVATE,Gbl.UniqueNameEncrypted,PtrExtension);
if (!Fil_EndReceptionOfFile (PathFileImgTmp,Param))
{
@ -947,29 +943,25 @@ void CtrCfg_ReceivePhoto (void)
/***** Creates public directories if not exist *****/
Fil_CreateDirIfNotExists (Cfg_PATH_CTR_PUBLIC);
snprintf (Path,sizeof (Path),
"%s/%02u",
Cfg_PATH_CTR_PUBLIC,
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100));
snprintf (Path,sizeof (Path),"%s/%02u",
Cfg_PATH_CTR_PUBLIC,(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100));
Fil_CreateDirIfNotExists (Path);
snprintf (Path,sizeof (Path),
"%s/%02u/%u",
snprintf (Path,sizeof (Path),"%s/%02u/%u",
Cfg_PATH_CTR_PUBLIC,
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
Fil_CreateDirIfNotExists (Path);
/***** Convert temporary file to public JPEG file *****/
snprintf (PathFileImg,sizeof (PathFileImg),
"%s/%02u/%u/%u.jpg",
snprintf (PathFileImg,sizeof (PathFileImg),"%s/%02u/%u/%u.jpg",
Cfg_PATH_CTR_PUBLIC,
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
(unsigned) Gbl.Hierarchy.Ctr.CtrCod,
(unsigned) Gbl.Hierarchy.Ctr.CtrCod);
/* Call to program that makes the conversion */
snprintf (Command,sizeof (Command),
"convert %s -resize '%ux%u>' -quality %u %s",
"convert %s -resize '%ux%u>' -quality %u %s",
PathFileImgTmp,
Ctr_PHOTO_SAVED_MAX_WIDTH,
Ctr_PHOTO_SAVED_MAX_HEIGHT,
@ -1220,7 +1212,7 @@ void CtrCfg_ChangeCtrWWW (void)
/***** Update database changing old WWW by new WWW *****/
Ctr_UpdateCtrWWWDB (Gbl.Hierarchy.Ctr.CtrCod,NewWWW);
Str_Copy (Gbl.Hierarchy.Ctr.WWW,NewWWW,
Cns_MAX_BYTES_WWW);
sizeof (Gbl.Hierarchy.Ctr.WWW) - 1);
/***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,

View File

@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 20.30.1 (2021-02-14)"
#define Log_PLATFORM_VERSION "SWAD 20.31 (2021-02-15)"
#define CSS_FILE "swad20.8.css"
#define JS_FILE "swad20.6.2.js"
/*
@ -601,6 +601,7 @@ TODO: DNI de un estudiante sale err
TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede.
TODO: Salvador Romero Cortés: @acanas opción para editar posts
Version 20.31: Feb 15, 2021 Code refactoring in copy, concat and sprintf. (304811 lines)
Version 20.30.1: Feb 14, 2021 Code refactoring in timeline related to temporary tables. (305883 lines)
Version 20.30: Feb 11, 2021 Code refactoring in hierarchy. (305853 lines)
Version 20.29.3: Feb 11, 2021 Code refactoring in timeline. (305826 lines)

View File

@ -138,8 +138,7 @@ void Cht_ShowListOfAvailableChatRooms (void)
/***** Link to chat available for all the users *****/
IsLastItemInLevel[1] = (!Gbl.Usrs.Me.IBelongToCurrentCrs &&
!Gbl.Usrs.Me.MyDegs.Num);
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
"%s (%s)",
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);
Cht_WriteLinkToChat1 ("GBL_USR",Txt_SEX_PLURAL_Abc[Usr_SEX_ALL],ThisRoomFullName,1,IsLastItemInLevel);
Ico_PutIcon ("comments.svg",ThisRoomFullName,"ICO16x16");
@ -149,19 +148,19 @@ void Cht_ShowListOfAvailableChatRooms (void)
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_STD:
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
"%s (%s)",
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
Txt_General,Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_ALL]);
Cht_WriteLinkToChat1 ("GBL_STD",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD],ThisRoomFullName,1,IsLastItemInLevel);
Cht_WriteLinkToChat1 ("GBL_STD",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD],
ThisRoomFullName,1,IsLastItemInLevel);
Ico_PutIcon ("comments.svg",ThisRoomFullName,"ICO16x16");
Cht_WriteLinkToChat2 ("GBL_STD",ThisRoomFullName);
break;
case Rol_NET:
case Rol_TCH:
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
"%s (%s)",
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
Txt_General,Txt_ROLES_PLURAL_abc[Rol_TCH][Usr_SEX_ALL]);
Cht_WriteLinkToChat1 ("GBL_TCH",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH],ThisRoomFullName,1,IsLastItemInLevel);
Cht_WriteLinkToChat1 ("GBL_TCH",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH],
ThisRoomFullName,1,IsLastItemInLevel);
Ico_PutIcon ("comments.svg",ThisRoomFullName,"ICO16x16");
Cht_WriteLinkToChat2 ("GBL_TCH",ThisRoomFullName);
break;
@ -181,14 +180,10 @@ void Cht_ShowListOfAvailableChatRooms (void)
/* Link to the room of this degree */
IsLastItemInLevel[1] = (NumMyDeg == Gbl.Usrs.Me.MyDegs.Num - 1);
snprintf (ThisRoomCode,sizeof (ThisRoomCode),
"DEG_%ld",
Deg.DegCod);
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),
"%s",
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"DEG_%ld",Deg.DegCod);
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),"%s",
Deg.ShrtName);
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
"%s %s",
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
Txt_Degree,Deg.ShrtName);
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,1,IsLastItemInLevel);
Lgo_DrawLogo (Hie_Lvl_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true);
@ -211,14 +206,11 @@ void Cht_ShowListOfAvailableChatRooms (void)
/* Link to the room of this course */
IsLastItemInLevel[2] = (NumRow == NumRows - 1);
snprintf (ThisRoomCode,sizeof (ThisRoomCode),
"CRS_%ld",
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"CRS_%ld",
Crs.CrsCod);
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),
"%s",
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),"%s",
Crs.ShrtName);
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
"%s %s",
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
Txt_Course,Crs.ShrtName);
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,2,IsLastItemInLevel);
Ico_PutIcon ("chalkboard-teacher.svg",ThisRoomFullName,"ICO16x16");
@ -427,119 +419,86 @@ void Cht_OpenChatWindow (void)
Usr_GetMyCourses ();
/***** Build my user's name *****/
Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,
Usr_MAX_BYTES_FULL_NAME);
Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,sizeof (UsrName) - 1);
if (Gbl.Usrs.Me.UsrDat.Surname2[0])
{
Str_Concat (UsrName," ",
Usr_MAX_BYTES_FULL_NAME);
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2,
Usr_MAX_BYTES_FULL_NAME);
Str_Concat (UsrName," ",sizeof (UsrName) - 1);
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2,sizeof (UsrName) - 1);
}
Str_Concat (UsrName,", ",
Usr_MAX_BYTES_FULL_NAME);
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.FirstName,
Usr_MAX_BYTES_FULL_NAME);
Str_Concat (UsrName,", ",sizeof (UsrName) - 1);
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.FrstName,sizeof (UsrName) - 1);
/***** Build the lists of available rooms *****/
snprintf (ListRoomCodes,sizeof (ListRoomCodes),
"#%s",
RoomCode);
Str_Copy (ListRoomShrtNames,RoomShrtName,
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
Str_Copy (ListRoomFullNames ,RoomFullName,
Cht_MAX_BYTES_ROOM_FULL_NAMES);
snprintf (ListRoomCodes,sizeof (ListRoomCodes),"#%s",RoomCode);
Str_Copy (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
Str_Copy (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
if (strcmp (RoomCode,"GBL_USR"))
{
Str_Concat (ListRoomCodes,"|#GBL_USR",
Cht_MAX_BYTES_ROOM_CODES);
Str_Concat (ListRoomCodes,"|#GBL_USR",sizeof (ListRoomCodes) - 1);
snprintf (RoomShrtName,sizeof (RoomShrtName),
"|%s",
snprintf (RoomShrtName,sizeof (RoomShrtName),"|%s",
Txt_SEX_PLURAL_Abc[Usr_SEX_ALL]);
Str_Concat (ListRoomShrtNames,RoomShrtName,
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
Str_Concat (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
snprintf (RoomFullName,sizeof (RoomFullName),
"|%s (%s)",
snprintf (RoomFullName,sizeof (RoomFullName),"|%s (%s)",
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);
Str_Concat (ListRoomFullNames,RoomFullName,
Cht_MAX_BYTES_ROOM_FULL_NAMES);
Str_Concat (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
}
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
if (strcmp (RoomCode,"GBL_STD"))
{
Str_Concat (ListRoomCodes,"|#GBL_STD",
Cht_MAX_BYTES_ROOM_CODES);
Str_Concat (ListRoomCodes,"|#GBL_STD",sizeof (ListRoomCodes) - 1);
snprintf (RoomShrtName,sizeof (RoomShrtName),
"|%s",
snprintf (RoomShrtName,sizeof (RoomShrtName),"|%s",
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
Str_Concat (ListRoomShrtNames,RoomShrtName,
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
Str_Concat (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
snprintf (RoomFullName,sizeof (RoomFullName),
"|%s (%s)",
snprintf (RoomFullName,sizeof (RoomFullName),"|%s (%s)",
Txt_General,Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_ALL]);
Str_Concat (ListRoomFullNames,RoomFullName,
Cht_MAX_BYTES_ROOM_FULL_NAMES);
Str_Concat (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
}
if (Gbl.Usrs.Me.Role.Logged == Rol_NET ||
Gbl.Usrs.Me.Role.Logged == Rol_TCH)
if (strcmp (RoomCode,"GBL_TCH"))
{
Str_Concat (ListRoomCodes,"|#GBL_TCH",
Cht_MAX_BYTES_ROOM_CODES);
Str_Concat (ListRoomCodes,"|#GBL_TCH",sizeof (ListRoomCodes) - 1);
snprintf (RoomShrtName,sizeof (RoomShrtName),
"|%s",
snprintf (RoomShrtName,sizeof (RoomShrtName),"|%s",
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]);
Str_Concat (ListRoomShrtNames,RoomShrtName,
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
Str_Concat (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
snprintf (RoomFullName,sizeof (RoomFullName),
"|%s (%s)",
snprintf (RoomFullName,sizeof (RoomFullName),"|%s (%s)",
Txt_General,Txt_ROLES_PLURAL_abc[Rol_TCH][Usr_SEX_ALL]);
Str_Concat (ListRoomFullNames,RoomFullName,
Cht_MAX_BYTES_ROOM_FULL_NAMES);
Str_Concat (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
}
for (NumMyDeg = 0;
NumMyDeg < Gbl.Usrs.Me.MyDegs.Num;
NumMyDeg++)
{
snprintf (ThisRoomCode,sizeof (ThisRoomCode),
"DEG_%ld",
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"DEG_%ld",
Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod);
if (strcmp (RoomCode,ThisRoomCode))
{
Str_Concat (ListRoomCodes,"|#",
Cht_MAX_BYTES_ROOM_CODES);
Str_Concat (ListRoomCodes,ThisRoomCode,
Cht_MAX_BYTES_ROOM_CODES);
Str_Concat (ListRoomCodes,"|#",sizeof (ListRoomCodes) - 1);
Str_Concat (ListRoomCodes,ThisRoomCode,sizeof (ListRoomCodes) - 1);
/* Get data of this degree */
Deg.DegCod = Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod;
Deg_GetDataOfDegreeByCod (&Deg);
snprintf (ThisRoomShortName,sizeof (ThisRoomShortName),
"%s",
snprintf (ThisRoomShortName,sizeof (ThisRoomShortName),"%s",
Deg.ShrtName);
Str_Concat (ListRoomShrtNames,"|",
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
Str_Concat (ListRoomShrtNames,ThisRoomShortName,
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
Str_Concat (ListRoomShrtNames,"|",sizeof (ListRoomShrtNames) - 1);
Str_Concat (ListRoomShrtNames,ThisRoomShortName,sizeof (ListRoomShrtNames) - 1);
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
"%s %s",
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
Txt_Degree,Deg.ShrtName);
Str_Concat (ListRoomFullNames,"|",
Cht_MAX_BYTES_ROOM_FULL_NAMES);
Str_Concat (ListRoomFullNames,ThisRoomFullName,
Cht_MAX_BYTES_ROOM_FULL_NAMES);
Str_Concat (ListRoomFullNames,"|",sizeof (ListRoomFullNames) - 1);
Str_Concat (ListRoomFullNames,ThisRoomFullName,sizeof (ListRoomFullNames) - 1);
}
}
@ -547,15 +506,12 @@ void Cht_OpenChatWindow (void)
NumMyCrs < Gbl.Usrs.Me.MyCrss.Num;
NumMyCrs++)
{
snprintf (ThisRoomCode,sizeof (ThisRoomCode),
"CRS_%ld",
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"CRS_%ld",
Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod);
if (strcmp (RoomCode,ThisRoomCode))
{
Str_Concat (ListRoomCodes,"|#",
Cht_MAX_BYTES_ROOM_CODES);
Str_Concat (ListRoomCodes,ThisRoomCode,
Cht_MAX_BYTES_ROOM_CODES);
Str_Concat (ListRoomCodes,"|#",sizeof (ListRoomCodes) - 1);
Str_Concat (ListRoomCodes,ThisRoomCode,sizeof (ListRoomCodes) - 1);
/* Get data of this course */
Crs.CrsCod = Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod;
@ -564,18 +520,13 @@ void Cht_OpenChatWindow (void)
snprintf (ThisRoomShortName,sizeof (ThisRoomShortName),
"%s",
Crs.ShrtName);
Str_Concat (ListRoomShrtNames,"|",
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
Str_Concat (ListRoomShrtNames,ThisRoomShortName,
Cht_MAX_BYTES_ROOM_SHRT_NAMES);
Str_Concat (ListRoomShrtNames,"|",sizeof (ListRoomShrtNames) - 1);
Str_Concat (ListRoomShrtNames,ThisRoomShortName,sizeof (ListRoomShrtNames) - 1);
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),
"%s %s",
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
Txt_Course,Crs.ShrtName);
Str_Concat (ListRoomFullNames,"|",
Cht_MAX_BYTES_ROOM_FULL_NAMES);
Str_Concat (ListRoomFullNames,ThisRoomFullName,
Cht_MAX_BYTES_ROOM_FULL_NAMES);
Str_Concat (ListRoomFullNames,"|",sizeof (ListRoomFullNames) - 1);
Str_Concat (ListRoomFullNames,ThisRoomFullName,sizeof (ListRoomFullNames) - 1);
}
}

View File

@ -86,7 +86,7 @@ void Cfg_GetConfigFromFile (void)
fseek (FileCfg,0L,SEEK_SET);
/* Allocate memory for buffer */
if ((Config = (char *) malloc (Length + 1)) == NULL)
if ((Config = malloc (Length + 1)) == NULL)
{
fclose (FileCfg);
Lay_NotEnoughMemoryExit ();

View File

@ -321,8 +321,7 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void)
// the list of connected users
// is dynamically updated via AJAX
HTM_BUTTON_SUBMIT_Begin (Txt_Connected_users,"BT_LINK CONNECTED_TXT",NULL);
Str_Copy (CourseName,Gbl.Hierarchy.Crs.ShrtName,
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (CourseName,Gbl.Hierarchy.Crs.ShrtName,sizeof (CourseName) - 1);
Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNK,&Usrs);
HTM_TxtF ("%u %s %s",Usrs.NumUsrs,Txt_from,CourseName);
HTM_BUTTON_End ();
@ -851,7 +850,7 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role)
Rol_WrongRoleExit ();
break;
}
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_DIV_Begin ("class=\"CON_NAME_NARROW\""); // Limited width
HTM_BUTTON_SUBMIT_Begin (Txt_View_record_for_this_course,ClassLink,NULL);
@ -1075,7 +1074,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R
default:
Rol_WrongRoleExit ();
}
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
}
HTM_DIV_Begin ("class=\"CON_NAME_WIDE\""); // Limited width

View File

@ -533,7 +533,7 @@ void Cty_DrawCountryMapAndNameWithLink (struct Cty_Countr *Cty,Act_Action_t Acti
/***** Write country name *****/
Str_Copy (CountryName,Cty->Name[Gbl.Prefs.Language],
Cty_MAX_BYTES_NAME);
sizeof (CountryName) - 1);
HTM_TxtF ("&nbsp;%s&nbsp;",CountryName);
HTM_TxtF ("(%s)",Cty->Alpha2);
@ -581,8 +581,7 @@ bool Cty_CheckIfCountryPhotoExists (struct Cty_Countr *Cty)
{
char PathMap[PATH_MAX + 1];
snprintf (PathMap,sizeof (PathMap),
"%s/%s/%s.png",
snprintf (PathMap,sizeof (PathMap),"%s/%s/%s.png",
Cfg_PATH_ICON_COUNTRIES_PUBLIC,
Cty->Alpha2,
Cty->Alpha2);
@ -768,8 +767,8 @@ void Cty_GetBasicListOfCountries (void)
Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows;
/***** Create list with countries *****/
if ((Gbl.Hierarchy.Ctys.Lst = (struct Cty_Countr *)
calloc (NumRows,sizeof (struct Cty_Countr))) == NULL)
if ((Gbl.Hierarchy.Ctys.Lst = calloc (NumRows,
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the countries *****/
@ -787,8 +786,7 @@ void Cty_GetBasicListOfCountries (void)
Lay_ShowErrorAndExit ("Wrong code of country.");
/* Get Alpha-2 country code (row[1]) */
Str_Copy (Cty->Alpha2,row[1],
2);
Str_Copy (Cty->Alpha2,row[1],sizeof (Cty->Alpha2) - 1);
for (Lan = (Lan_Language_t) 1;
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
@ -800,7 +798,7 @@ void Cty_GetBasicListOfCountries (void)
/* Get the name of the country in current language */
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[2],
Cty_MAX_BYTES_NAME);
sizeof (Cty->Name[Gbl.Prefs.Language]) - 1);
/* Reset number of users who claim to belong to country */
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
@ -850,27 +848,15 @@ void Cty_GetFullListOfCountries (void)
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
Lan++)
{
snprintf (StrField,sizeof (StrField),
"countries.Name_%s,",
Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryNam1,StrField,
Cty_MAX_BYTES_SUBQUERY_CTYS);
snprintf (StrField,sizeof (StrField),
"Name_%s,",
Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryNam2,StrField,
Cty_MAX_BYTES_SUBQUERY_CTYS);
snprintf (StrField,sizeof (StrField),"countries.Name_%s,",Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryNam1,StrField,sizeof (SubQueryNam1) - 1);
snprintf (StrField,sizeof (StrField),"Name_%s,",Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryNam2,StrField,sizeof (SubQueryNam2) - 1);
snprintf (StrField,sizeof (StrField),
"countries.WWW_%s,",
Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryWWW1,StrField,
Cty_MAX_BYTES_SUBQUERY_CTYS);
snprintf (StrField,sizeof (StrField),
"WWW_%s,",
Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryWWW2,StrField,
Cty_MAX_BYTES_SUBQUERY_CTYS);
snprintf (StrField,sizeof (StrField),"countries.WWW_%s,",Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryWWW1,StrField,sizeof (SubQueryWWW1) - 1);
snprintf (StrField,sizeof (StrField),"WWW_%s,",Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryWWW2,StrField,sizeof (SubQueryWWW2) - 1);
}
/* Build order subquery */
@ -902,8 +888,8 @@ void Cty_GetFullListOfCountries (void)
Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows;
/***** Create list with countries *****/
if ((Gbl.Hierarchy.Ctys.Lst = (struct Cty_Countr *)
calloc (NumRows,sizeof (struct Cty_Countr))) == NULL)
if ((Gbl.Hierarchy.Ctys.Lst = calloc (NumRows,
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the countries *****/
@ -921,8 +907,7 @@ void Cty_GetFullListOfCountries (void)
Lay_ShowErrorAndExit ("Wrong code of country.");
/* Get Alpha-2 country code (row[1]) */
Str_Copy (Cty->Alpha2,row[1],
2);
Str_Copy (Cty->Alpha2,row[1],sizeof (Cty->Alpha2) - 1);
/* Get the name of the country in several languages */
for (Lan = (Lan_Language_t) 1;
@ -930,9 +915,9 @@ void Cty_GetFullListOfCountries (void)
Lan++)
{
Str_Copy (Cty->Name[Lan],row[1 + Lan],
Cty_MAX_BYTES_NAME);
sizeof (Cty->Name[Lan]) - 1);
Str_Copy (Cty->WWW[Lan],row[1 + Lan_NUM_LANGUAGES + Lan],
Cns_MAX_BYTES_WWW);
sizeof (Cty->WWW[Lan]) - 1);
}
/* Get number of users who claim to belong to this country */
@ -1069,7 +1054,7 @@ bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty)
Lan++)
if (Lan == Gbl.Prefs.Language)
Str_Copy (Cty->Name[Lan],Txt_Another_country,
Cty_MAX_BYTES_NAME);
sizeof (Cty->Name[Lan]) - 1);
else
Cty->Name[Lan][0] = '\0';
return false;
@ -1095,14 +1080,13 @@ bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty)
row = mysql_fetch_row (mysql_res);
/* Get Alpha-2 country code (row[0]) */
Str_Copy (Cty->Alpha2,row[0],
2);
Str_Copy (Cty->Alpha2,row[0],sizeof (Cty->Alpha2) - 1);
/* Get name and WWW of the country in current language */
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[1],
Cty_MAX_BYTES_NAME);
sizeof (Cty->Name[Gbl.Prefs.Language]) - 1);
Str_Copy (Cty->WWW[Gbl.Prefs.Language],row[2],
Cns_MAX_BYTES_WWW);
sizeof (Cty->WWW[Gbl.Prefs.Language]) - 1);
}
else
CtyFound = false;
@ -1142,8 +1126,7 @@ void Cty_GetCountryName (long CtyCod,Lan_Language_t Language,
if (CtyCod == Gbl.Cache.CountryName.CtyCod &&
Language == Gbl.Cache.CountryName.Language)
{
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,
Cty_MAX_BYTES_NAME);
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,Cty_MAX_BYTES_NAME);
return;
}
@ -1160,7 +1143,7 @@ void Cty_GetCountryName (long CtyCod,Lan_Language_t Language,
/* Get the name of the country */
Str_Copy (Gbl.Cache.CountryName.CtyName,row[0],
Cty_MAX_BYTES_NAME);
sizeof (Gbl.Cache.CountryName.CtyName) - 1);
}
else
Gbl.Cache.CountryName.CtyName[0] = '\0';
@ -1168,8 +1151,7 @@ void Cty_GetCountryName (long CtyCod,Lan_Language_t Language,
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,
Cty_MAX_BYTES_NAME);
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,Cty_MAX_BYTES_NAME);
}
/*****************************************************************************/
@ -1441,8 +1423,7 @@ void Cty_RenameCountry (void)
else
{
/* Update the table changing old name by new name */
snprintf (FieldName,sizeof (FieldName),
"Name_%s",
snprintf (FieldName,sizeof (FieldName),"Name_%s",
Lan_STR_LANG_ID[Language]);
Cty_UpdateCtyNameDB (Cty_EditingCty->CtyCod,FieldName,NewCtyName);
@ -1453,7 +1434,7 @@ void Cty_RenameCountry (void)
/* Update country name */
Str_Copy (Cty_EditingCty->Name[Language],NewCtyName,
Cty_MAX_BYTES_NAME);
sizeof (Cty_EditingCty->Name[Language]) - 1);
}
}
else // The same name
@ -1556,7 +1537,7 @@ void Cty_ChangeCtyWWW (void)
" WHERE CtyCod='%03ld'",
Lan_STR_LANG_ID[Language],NewWWW,Cty_EditingCty->CtyCod);
Str_Copy (Cty_EditingCty->WWW[Language],NewWWW,
Cns_MAX_BYTES_WWW);
sizeof (Cty_EditingCty->WWW[Language]) - 1);
/***** Write message to show the change made *****/
Ale_CreateAlert (Ale_SUCCESS,NULL,
@ -1644,9 +1625,7 @@ static void Cty_PutFormToCreateCountry (void)
/***** Numerical country code (ISO 3166-1) *****/
HTM_TD_Begin ("rowspan=\"%u\" class=\"RT\"",1 + Lan_NUM_LANGUAGES);
if (Cty_EditingCty->CtyCod > 0)
snprintf (StrCtyCod,sizeof (StrCtyCod),
"%03ld",
Cty_EditingCty->CtyCod);
snprintf (StrCtyCod,sizeof (StrCtyCod),"%03ld",Cty_EditingCty->CtyCod);
else
StrCtyCod[0] = '\0';
HTM_INPUT_TEXT ("OthCtyCod",3,StrCtyCod,HTM_DONT_SUBMIT_ON_CHANGE,
@ -1687,9 +1666,7 @@ static void Cty_PutFormToCreateCountry (void)
/* Name */
HTM_TD_Begin ("class=\"LM\"");
snprintf (StrName,sizeof (StrName),
"Name_%s",
Lan_STR_LANG_ID[Lan]);
snprintf (StrName,sizeof (StrName),"Name_%s",Lan_STR_LANG_ID[Lan]);
HTM_INPUT_TEXT (StrName,Cty_MAX_CHARS_NAME,Cty_EditingCty->Name[Lan],
HTM_DONT_SUBMIT_ON_CHANGE,
"size=\"15\" required=\"required\"");
@ -1697,9 +1674,7 @@ static void Cty_PutFormToCreateCountry (void)
/* WWW */
HTM_TD_Begin ("class=\"LM\"");
snprintf (StrName,sizeof (StrName),
"WWW_%s",
Lan_STR_LANG_ID[Lan]);
snprintf (StrName,sizeof (StrName),"WWW_%s",Lan_STR_LANG_ID[Lan]);
HTM_INPUT_URL (StrName,Cty_EditingCty->WWW[Lan],HTM_DONT_SUBMIT_ON_CHANGE,
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
HTM_TD_End ();
@ -1810,9 +1785,7 @@ void Cty_ReceiveFormNewCountry (void)
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
Lan++)
{
snprintf (ParamName,sizeof (ParamName),
"Name_%s",
Lan_STR_LANG_ID[Lan]);
snprintf (ParamName,sizeof (ParamName),"Name_%s",Lan_STR_LANG_ID[Lan]);
Par_GetParToText (ParamName,Cty_EditingCty->Name[Lan],Cty_MAX_BYTES_NAME);
if (Cty_EditingCty->Name[Lan][0]) // If there's a country name
@ -1835,9 +1808,7 @@ void Cty_ReceiveFormNewCountry (void)
break;
}
snprintf (ParamName,sizeof (ParamName),
"WWW_%s",
Lan_STR_LANG_ID[Lan]);
snprintf (ParamName,sizeof (ParamName),"WWW_%s",Lan_STR_LANG_ID[Lan]);
Par_GetParToText (ParamName,Cty_EditingCty->WWW[Lan],Cns_MAX_BYTES_WWW);
}
}
@ -1878,31 +1849,19 @@ static void Cty_CreateCountry (void)
Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES;
Lan++)
{
snprintf (StrField,sizeof (StrField),
",Name_%s",
Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryNam1,StrField,
Cty_MAX_BYTES_SUBQUERY_CTYS);
snprintf (StrField,sizeof (StrField),",Name_%s",Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryNam1,StrField,sizeof (SubQueryNam1) - 1);
Str_Concat (SubQueryNam2,",'",
Cty_MAX_BYTES_SUBQUERY_CTYS_NAME);
Str_Concat (SubQueryNam2,Cty_EditingCty->Name[Lan],
Cty_MAX_BYTES_SUBQUERY_CTYS_NAME);
Str_Concat (SubQueryNam2,"'",
Cty_MAX_BYTES_SUBQUERY_CTYS_NAME);
Str_Concat (SubQueryNam2,",'",sizeof (SubQueryNam2) - 1);
Str_Concat (SubQueryNam2,Cty_EditingCty->Name[Lan],sizeof (SubQueryNam2) - 1);
Str_Concat (SubQueryNam2,"'",sizeof (SubQueryNam2) - 1);
snprintf (StrField,sizeof (StrField),
",WWW_%s",
Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryWWW1,StrField,
Cty_MAX_BYTES_SUBQUERY_CTYS);
snprintf (StrField,sizeof (StrField),",WWW_%s",Lan_STR_LANG_ID[Lan]);
Str_Concat (SubQueryWWW1,StrField,sizeof (SubQueryWWW1) - 1);
Str_Concat (SubQueryWWW2,",'",
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
Str_Concat (SubQueryWWW2,Cty_EditingCty->WWW[Lan],
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
Str_Concat (SubQueryWWW2,"'",
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
Str_Concat (SubQueryWWW2,",'",sizeof (SubQueryWWW2) - 1);
Str_Concat (SubQueryWWW2,Cty_EditingCty->WWW[Lan],sizeof (SubQueryWWW2) - 1);
Str_Concat (SubQueryWWW2,"'",sizeof (SubQueryWWW2) - 1);
}
DB_QueryINSERT ("can not create country",
"INSERT INTO countries"
@ -2144,8 +2103,8 @@ static void Cty_EditingCountryConstructor (void)
Lay_ShowErrorAndExit ("Error initializing country.");
/***** Allocate memory for country *****/
if ((Cty_EditingCty = (struct Cty_Countr *) malloc (sizeof (struct Cty_Countr))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for country.");
if ((Cty_EditingCty = malloc (sizeof (*Cty_EditingCty))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset country *****/
Cty_EditingCty->CtyCod = -1L;

View File

@ -592,10 +592,9 @@ static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution)
if (row[0][0])
{
Length = strlen (row[0]);
if ((*MapAttribution = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for map attribution.");
Str_Copy (*MapAttribution,row[0],
Length);
if ((*MapAttribution = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (*MapAttribution,row[0],Length);
}
}

View File

@ -178,8 +178,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
char ClassHighlight[64];
ClassNormal = The_ClassFormLinkInBox[Gbl.Prefs.Theme];
snprintf (ClassHighlight,sizeof (ClassHighlight),
"%s LIGHT_BLUE",
snprintf (ClassHighlight,sizeof (ClassHighlight),"%s LIGHT_BLUE",
The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme]);
/***** Begin box *****/
@ -775,8 +774,8 @@ static void Crs_GetListCrssInCurrentDeg (Crs_WhatCourses_t WhatCourses)
if (NumCrss) // Courses found...
{
/***** Create list with courses in degree *****/
if ((Gbl.Hierarchy.Crss.Lst = (struct Crs_Course *) calloc ((size_t) NumCrss,
sizeof (struct Crs_Course))) == NULL)
if ((Gbl.Hierarchy.Crss.Lst = calloc (NumCrss,
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the courses in degree *****/
@ -1804,7 +1803,7 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row)
/***** Get institutional course code (row[3]) *****/
Str_Copy (Crs->InstitutionalCrsCod,row[3],
Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
sizeof (Crs->InstitutionalCrsCod) - 1);
/***** Get course status (row[4]) *****/
if (sscanf (row[4],"%u",&(Crs->Status)) != 1)
@ -1814,12 +1813,10 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row)
Crs->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[5]);
/***** Get the short name of the course (row[6]) *****/
Str_Copy (Crs->ShrtName,row[6],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (Crs->ShrtName,row[6],sizeof (Crs->ShrtName) - 1);
/***** Get the full name of the course (row[7]) *****/
Str_Copy (Crs->FullName,row[7],
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
Str_Copy (Crs->FullName,row[7],sizeof (Crs->FullName) - 1);
}
/*****************************************************************************/
@ -1848,10 +1845,8 @@ static void Crs_GetShortNamesByCod (long CrsCod,
/***** Get the short name of this course *****/
row = mysql_fetch_row (mysql_res);
Str_Copy (CrsShortName,row[0],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (DegShortName,row[1],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (CrsShortName,row[0],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (DegShortName,row[1],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
}
/***** Free structure that stores the query result *****/
@ -2024,12 +2019,10 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
CrsCod);
/***** Remove directories of the course *****/
snprintf (PathRelCrs,sizeof (PathRelCrs),
"%s/%ld",
snprintf (PathRelCrs,sizeof (PathRelCrs),"%s/%ld",
Cfg_PATH_CRS_PRIVATE,CrsCod);
Fil_RemoveTree (PathRelCrs);
snprintf (PathRelCrs,sizeof (PathRelCrs),
"%s/%ld",
snprintf (PathRelCrs,sizeof (PathRelCrs),"%s/%ld",
Cfg_PATH_CRS_PUBLIC,CrsCod);
Fil_RemoveTree (PathRelCrs);
}
@ -2170,7 +2163,7 @@ void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,const char *NewInstit
/***** Copy institutional course code *****/
Str_Copy (Crs->InstitutionalCrsCod,NewInstitutionalCrsCod,
Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
sizeof (Crs->InstitutionalCrsCod) - 1);
}
/*****************************************************************************/
@ -2261,8 +2254,7 @@ void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullNam
CurrentCrsName,NewCrsName);
/* Change current course name in order to display it properly */
Str_Copy (CurrentCrsName,NewCrsName,
MaxBytes);
Str_Copy (CurrentCrsName,NewCrsName,MaxBytes);
}
}
else // The same name
@ -2987,8 +2979,8 @@ static void Crs_EditingCourseConstructor (void)
Lay_ShowErrorAndExit ("Error initializing course.");
/***** Allocate memory for course *****/
if ((Crs_EditingCrs = (struct Crs_Course *) malloc (sizeof (struct Crs_Course))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for course.");
if ((Crs_EditingCrs = malloc (sizeof (*Crs_EditingCrs))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset course *****/
Crs_EditingCrs->CrsCod = -1L;

View File

@ -148,8 +148,7 @@ void Cry_CreateUniqueNameEncrypted (char UniqueNameEncrypted[Cry_BYTES_ENCRYPTED
char UniqueNamePlain[Cns_MAX_BYTES_IP + Cns_MAX_DECIMAL_DIGITS_LONG + Cns_MAX_DECIMAL_DIGITS_LONG + Cns_MAX_DECIMAL_DIGITS_UINT + 1];
NumCall++;
snprintf (UniqueNamePlain,sizeof (UniqueNamePlain),
"%s-%lx-%x-%x",
snprintf (UniqueNamePlain,sizeof (UniqueNamePlain),"%s-%lx-%x-%x",
Gbl.IP,Gbl.StartExecutionTimeUTC,Gbl.PID,NumCall);
Cry_EncryptSHA256Base64 (UniqueNamePlain,UniqueNameEncrypted); // Make difficult to guess a unique name
}

View File

@ -4058,8 +4058,7 @@ void DB_ExitOnMySQLError (const char *Message)
{
char BigErrorMsg[64 * 1024];
snprintf (BigErrorMsg,sizeof (BigErrorMsg),
"Database error: %s (%s).",
snprintf (BigErrorMsg,sizeof (BigErrorMsg),"Database error: %s (%s).",
Message,mysql_error (&Gbl.mysql));
Lay_ShowErrorAndExit (BigErrorMsg);
}

View File

@ -309,8 +309,7 @@ bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDD)
if (YYYYMMDD[0])
if (sscanf (YYYYMMDD,"%04u%02u%02u",&(Date->Year),&(Date->Month),&(Date->Day)) == 3)
{
Str_Copy (Date->YYYYMMDD,YYYYMMDD,
Dat_LENGTH_YYYYMMDD);
Str_Copy (Date->YYYYMMDD,YYYYMMDD,sizeof (Date->YYYYMMDD) - 1);
return true;
}
@ -415,22 +414,19 @@ void Dat_ConvDateToDateStr (const struct Date *Date,char StrDate[Cns_MAX_BYTES_D
switch (Gbl.Prefs.DateFormat)
{
case Dat_FORMAT_YYYY_MM_DD:
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,
"%04u-%02u-%02u",
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,"%04u-%02u-%02u",
Date->Year,
Date->Month,
Date->Day);
break;
case Dat_FORMAT_DD_MONTH_YYYY:
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,
"%u&nbsp;%s&nbsp;%04u",
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,"%u&nbsp;%s&nbsp;%04u",
Date->Day,
Txt_MONTHS_SMALL_SHORT[Date->Month - 1],
Date->Year);
break;
case Dat_FORMAT_MONTH_DD_YYYY:
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,
"%s&nbsp;%u,&nbsp;%04u",
snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,"%s&nbsp;%u,&nbsp;%04u",
Txt_MONTHS_SMALL_SHORT[Date->Month - 1],
Date->Day,
Date->Year);
@ -831,13 +827,11 @@ void Dat_GetBrowserTimeZone (char BrowserTimeZone[Dat_MAX_BYTES_TIME_ZONE + 1])
/* Convert from minutes to +-hh:mm */
// BrowserTimeZone must have space for strings in +hh:mm format (6 chars + \0)
if (ClientUTCMinusLocal > 0)
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,
"-%02u:%02u",
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,"-%02u:%02u",
(unsigned) ClientUTCMinusLocal / 60,
(unsigned) ClientUTCMinusLocal % 60);
else // ClientUTCMinusLocal <= 0
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,
"+%02u:%02u",
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,"+%02u:%02u",
(unsigned) (-ClientUTCMinusLocal) / 60,
(unsigned) (-ClientUTCMinusLocal) % 60);
}
@ -1577,7 +1571,7 @@ void Dat_AssignDate (struct Date *DateDst,struct Date *DateSrc)
DateDst->Day = DateSrc->Day;
DateDst->Week = DateSrc->Week;
Str_Copy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD,
Dat_LENGTH_YYYYMMDD);
sizeof (DateDst->YYYYMMDD) - 1);
}
/*****************************************************************************/

View File

@ -464,8 +464,7 @@ static void Deg_ListDegreesForEdition (void)
}
else
{
Str_Copy (WWW,Deg->WWW,
Cns_MAX_BYTES_WWW);
Str_Copy (WWW,Deg->WWW,sizeof (WWW) - 1);
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\"",
Deg->WWW,Deg->WWW);
@ -1081,7 +1080,7 @@ void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs)
if (Degs->Num) // Degrees found...
{
/***** Create list with degrees *****/
if ((Degs->Lst = (struct Deg_Degree *) calloc (Degs->Num,sizeof (struct Deg_Degree))) == NULL)
if ((Degs->Lst = calloc (Degs->Num,sizeof (*Degs->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the degrees *****/
@ -1126,8 +1125,8 @@ void Deg_GetListDegsInCurrentCtr (void)
Gbl.Hierarchy.Degs.Num = (unsigned) NumRows;
/***** Create list with degrees of this centre *****/
if ((Gbl.Hierarchy.Degs.Lst = (struct Deg_Degree *) calloc (Gbl.Hierarchy.Degs.Num,
sizeof (struct Deg_Degree))) == NULL)
if ((Gbl.Hierarchy.Degs.Lst = calloc (Gbl.Hierarchy.Degs.Num,
sizeof (*Gbl.Hierarchy.Degs.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the degrees of this centre *****/
@ -1388,16 +1387,13 @@ static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row)
Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
/***** Get degree short name (row[5]) *****/
Str_Copy (Deg->ShrtName,row[5],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (Deg->ShrtName,row[5],sizeof (Deg->ShrtName) - 1);
/***** Get degree full name (row[6]) *****/
Str_Copy (Deg->FullName,row[6],
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
Str_Copy (Deg->FullName,row[6],sizeof (Deg->FullName) - 1);
/***** Get WWW (row[7]) *****/
Str_Copy (Deg->WWW,row[7],
Cns_MAX_BYTES_WWW);
Str_Copy (Deg->WWW,row[7],sizeof (Deg->WWW) - 1);
}
/*****************************************************************************/
@ -1420,8 +1416,7 @@ void Deg_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg)
/***** Get the short name of this degree *****/
row = mysql_fetch_row (mysql_res);
Str_Copy (Deg->ShrtName,row[0],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (Deg->ShrtName,row[0],sizeof (Deg->ShrtName) - 1);
}
/***** Free structure that stores the query result *****/
@ -1537,11 +1532,10 @@ void Deg_RemoveDegreeCompletely (long DegCod)
Brw_RemoveDegFilesFromDB (DegCod);
/***** Remove directories of the degree *****/
snprintf (PathDeg,sizeof (PathDeg),
"%s/%02u/%u",
snprintf (PathDeg,sizeof (PathDeg),"%s/%02u/%u",
Cfg_PATH_DEG_PUBLIC,
(unsigned) (DegCod % 100),
(unsigned) DegCod);
(unsigned) DegCod);
Fil_RemoveTree (PathDeg);
/***** Remove administrators of this degree *****/
@ -1646,8 +1640,7 @@ void Deg_RenameDegree (struct Deg_Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullNam
CurrentDegName,NewDegName);
/* Change current degree name in order to display it properly */
Str_Copy (CurrentDegName,NewDegName,
MaxBytes);
Str_Copy (CurrentDegName,NewDegName,MaxBytes);
}
}
else // The same name
@ -1748,8 +1741,7 @@ void Deg_ChangeDegWWW (void)
{
/***** Update the table changing old WWW by new WWW *****/
Deg_UpdateDegWWWDB (Deg_EditingDeg->DegCod,NewWWW);
Str_Copy (Deg_EditingDeg->WWW,NewWWW,
Cns_MAX_BYTES_WWW);
Str_Copy (Deg_EditingDeg->WWW,NewWWW,sizeof (Deg_EditingDeg->WWW) - 1);
/***** Write alert to show the change made
and put button to go to degree changed *****/
@ -2179,8 +2171,8 @@ static void Deg_EditingDegreeConstructor (void)
Lay_ShowErrorAndExit ("Error initializing degree.");
/***** Allocate memory for degree *****/
if ((Deg_EditingDeg = (struct Deg_Degree *) malloc (sizeof (struct Deg_Degree))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for degree.");
if ((Deg_EditingDeg = malloc (sizeof (*Deg_EditingDeg))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset degree *****/
Deg_EditingDeg->DegCod = -1L;

View File

@ -441,7 +441,7 @@ void DegCfg_ChangeDegWWW (void)
/***** Update the table changing old WWW by new WWW *****/
Deg_UpdateDegWWWDB (Gbl.Hierarchy.Deg.DegCod,NewWWW);
Str_Copy (Gbl.Hierarchy.Deg.WWW,NewWWW,
Cns_MAX_BYTES_WWW);
sizeof (Gbl.Hierarchy.Deg.WWW) - 1);
/***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,

View File

@ -695,9 +695,8 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
if (Gbl.DegTypes.Num)
{
/***** Create a list of degree types *****/
if ((Gbl.DegTypes.Lst = (struct DegreeType *)
calloc (Gbl.DegTypes.Num,
sizeof (struct DegreeType))) == NULL)
if ((Gbl.DegTypes.Lst = calloc (Gbl.DegTypes.Num,
sizeof (*Gbl.DegTypes.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get degree types *****/
@ -714,7 +713,7 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
/* Get degree type name (row[1]) */
Str_Copy (Gbl.DegTypes.Lst[NumRow].DegTypName,row[1],
Deg_MAX_BYTES_DEGREE_TYPE_NAME);
sizeof (Gbl.DegTypes.Lst[NumRow].DegTypName) - 1);
/* Number of degrees of this type (row[2]) */
if (sscanf (row[2],"%u",&Gbl.DegTypes.Lst[NumRow].NumDegs) != 1)
@ -881,8 +880,7 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp)
row = mysql_fetch_row (mysql_res);
/* Get the name of the degree type (row[0]) */
Str_Copy (DegTyp->DegTypName,row[0],
Deg_MAX_BYTES_DEGREE_TYPE_NAME);
Str_Copy (DegTyp->DegTypName,row[0],sizeof (DegTyp->DegTypName) - 1);
/* Count number of degrees of this type */
DegTyp->NumDegs = DT_CountNumDegsOfType (DegTyp->DegTypCod);
@ -1011,7 +1009,7 @@ void DT_RenameDegreeType (void)
/***** Set degree type name *****/
Str_Copy (DT_EditingDegTyp->DegTypName,NewNameDegTyp,
Deg_MAX_BYTES_DEGREE_TYPE_NAME);
sizeof (DT_EditingDegTyp->DegTypName) - 1);
}
/*****************************************************************************/
@ -1055,8 +1053,8 @@ static void DT_EditingDegreeTypeConstructor (void)
Lay_ShowErrorAndExit ("Error initializing degree type.");
/***** Allocate memory for degree type *****/
if ((DT_EditingDegTyp = (struct DegreeType *) malloc (sizeof (struct DegreeType))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for degree type.");
if ((DT_EditingDegTyp = malloc (sizeof (*DT_EditingDegTyp))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset degree type *****/
DT_EditingDegTyp->DegTypCod = -1L;

View File

@ -372,9 +372,8 @@ static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long Ins
if (Departments->Num) // Departments found...
{
/***** Create list with courses in degree *****/
if ((Departments->Lst = (struct Dpt_Department *)
calloc ((size_t) Departments->Num,
sizeof (struct Dpt_Department))) == NULL)
if ((Departments->Lst = calloc (Departments->Num,
sizeof (*Departments->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the departments *****/
@ -396,16 +395,13 @@ static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long Ins
Lay_ShowErrorAndExit ("Wrong code of institution.");
/* Get the short name of the department (row[2]) */
Str_Copy (Dpt->ShrtName,row[2],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (Dpt->ShrtName,row[2],sizeof (Dpt->ShrtName) - 1);
/* Get the full name of the department (row[3]) */
Str_Copy (Dpt->FullName,row[3],
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
Str_Copy (Dpt->FullName,row[3],sizeof (Dpt->FullName) - 1);
/* Get the URL of the department (row[4]) */
Str_Copy (Dpt->WWW,row[4],
Cns_MAX_BYTES_WWW);
Str_Copy (Dpt->WWW,row[4],sizeof (Dpt->WWW) - 1);
/* Get number of non-editing teachers and teachers in this department (row[5]) */
if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1)
@ -437,10 +433,8 @@ void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt)
/***** Check if department code is correct *****/
if (Dpt->DptCod == 0)
{
Str_Copy (Dpt->ShrtName,Txt_Another_department,
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (Dpt->FullName,Txt_Another_department,
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
Str_Copy (Dpt->ShrtName,Txt_Another_department,sizeof (Dpt->ShrtName) - 1);
Str_Copy (Dpt->FullName,Txt_Another_department,sizeof (Dpt->FullName) - 1);
}
else if (Dpt->DptCod > 0)
{
@ -471,16 +465,13 @@ void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt)
Dpt->InsCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get the short name of the department (row[1]) */
Str_Copy (Dpt->ShrtName,row[1],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (Dpt->ShrtName,row[1],sizeof (Dpt->ShrtName) - 1);
/* Get the full name of the department (row[2]) */
Str_Copy (Dpt->FullName,row[2],
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
Str_Copy (Dpt->FullName,row[2],sizeof (Dpt->FullName) - 1);
/* Get the URL of the department (row[3]) */
Str_Copy (Dpt->WWW,row[3],
Cns_MAX_BYTES_WWW);
Str_Copy (Dpt->WWW,row[3],sizeof (Dpt->WWW) - 1);
/* Get number of teachers in this department (row[4]) */
if (sscanf (row[4],"%u",&Dpt->NumTchs) != 1)
@ -817,8 +808,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update name *****/
Str_Copy (CurrentDptName,NewDptName,
MaxBytes);
Str_Copy (CurrentDptName,NewDptName,MaxBytes);
}
/*****************************************************************************/
@ -886,8 +876,7 @@ void Dpt_ChangeDptWWW (void)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update web *****/
Str_Copy (Dpt_EditingDpt->WWW,NewWWW,
Cns_MAX_BYTES_WWW);
Str_Copy (Dpt_EditingDpt->WWW,NewWWW,sizeof (Dpt_EditingDpt->WWW) - 1);
}
/*****************************************************************************/
@ -1197,8 +1186,8 @@ static void Dpt_EditingDepartmentConstructor (void)
Lay_ShowErrorAndExit ("Error initializing department.");
/***** Allocate memory for department *****/
if ((Dpt_EditingDpt = (struct Dpt_Department *) malloc (sizeof (struct Dpt_Department))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for department.");
if ((Dpt_EditingDpt = malloc (sizeof (*Dpt_EditingDpt))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset department *****/
Dpt_EditingDpt->DptCod = -1L;

View File

@ -271,7 +271,7 @@ static void Dup_ListSimilarUsrs (void)
/***** Make query *****/
if (Gbl.Usrs.Other.UsrDat.Surname1[0] &&
Gbl.Usrs.Other.UsrDat.FirstName[0]) // Name and surname 1 not empty
Gbl.Usrs.Other.UsrDat.FrstName[0]) // Name and surname 1 not empty
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
"SELECT DISTINCT UsrCod FROM"
"(SELECT DISTINCT UsrCod FROM usr_IDs"
@ -283,7 +283,7 @@ static void Dup_ListSimilarUsrs (void)
Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.Surname1,
Gbl.Usrs.Other.UsrDat.Surname2,
Gbl.Usrs.Other.UsrDat.FirstName);
Gbl.Usrs.Other.UsrDat.FrstName);
else
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
"SELECT DISTINCT UsrCod FROM usr_IDs"
@ -408,7 +408,7 @@ static void Dup_PutButtonToViewSimilarUsrs (const struct UsrData *UsrDat)
extern const char *Txt_Similar_users;
Frm_StartForm (ActLstSimUsr);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Btn_PutConfirmButtonInline (Txt_Similar_users);
Frm_EndForm ();
}
@ -422,7 +422,7 @@ static void Dup_PutButtonToEliminateUsrAccount (const struct UsrData *UsrDat)
extern const char *Txt_Eliminate_user_account;
Frm_StartForm (ActUpdOth);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Par_PutHiddenParamUnsigned (NULL,"RegRemAction",(unsigned) Enr_ELIMINATE_ONE_USR_FROM_PLATFORM);
Btn_PutRemoveButtonInline (Txt_Eliminate_user_account);
Frm_EndForm ();
@ -437,7 +437,7 @@ static void Dup_PutButtonToRemoveFromListOfDupUsrs (const struct UsrData *UsrDat
extern const char *Txt_Not_duplicated;
Frm_StartForm (ActRemDupUsr);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Btn_PutConfirmButtonInline (Txt_Not_duplicated);
Frm_EndForm ();
}

View File

@ -571,7 +571,7 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
"Comments='%s'"
" WHERE UsrCod=%ld",
UsrDat->Password,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FrstName,
Usr_StringsSexDB[UsrDat->Sex],
UsrDat->CtyCod,
UsrDat->Phone[0],
@ -1183,7 +1183,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
}
/***** Get list of users' IDs *****/
if ((ListUsrsIDs = (char *) malloc (ID_MAX_BYTES_LIST_USRS_IDS + 1)) == NULL)
if ((ListUsrsIDs = malloc (ID_MAX_BYTES_LIST_USRS_IDS + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Par_GetParToText ("UsrsIDs",ListUsrsIDs,ID_MAX_BYTES_LIST_USRS_IDS);
@ -1248,7 +1248,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
/***** Find users for this user's ID *****/
ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID
Str_Copy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,
ID_MAX_BYTES_USR_ID);
sizeof (UsrDat.IDs.List[0].ID) - 1);
Str_ConvertToUpperText (UsrDat.IDs.List[0].ID);
ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false);
}
@ -1375,7 +1375,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
/* Find users for this user's ID */
ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID
Str_Copy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,
ID_MAX_BYTES_USR_ID);
sizeof (UsrDat.IDs.List[0].ID) - 1);
Str_ConvertToUpperText (UsrDat.IDs.List[0].ID);
ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false);
}
@ -2144,7 +2144,7 @@ void Enr_AskIfRejectSignUp (void)
/* End alert */
Ale_ShowAlertAndButton2 (ActRejSignUp,NULL,NULL,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Btn_REMOVE_BUTTON,Txt_Reject);
}
else
@ -2919,7 +2919,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
}
Frm_StartForm (NextAction);
Crs_PutParamCrsCod (Crs.CrsCod);
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
Btn_PutCreateButtonInline (Txt_Register);
Frm_EndForm ();
HTM_TD_End ();
@ -2928,7 +2928,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
HTM_TD_Begin ("class=\"DAT LT\"");
Frm_StartForm (ActReqRejSignUp);
Crs_PutParamCrsCod (Crs.CrsCod);
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
Btn_PutRemoveButtonInline (Txt_Reject);
Frm_EndForm ();
HTM_TD_End ();
@ -3657,7 +3657,7 @@ static void Enr_ReqAddAdm (Hie_Lvl_Level_t Scope,long Cod,const char *InsCtrDegN
/* End alert */
Ale_ShowAlertAndButton2 (Enr_ActNewAdm[Scope],NULL,NULL,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Btn_CREATE_BUTTON,Txt_Register_user_IN_A_COURSE_OR_DEGREE);
}
}
@ -4075,7 +4075,7 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat)
break;
}
Frm_StartForm (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Pwd_AskForConfirmationOnDangerousAction ();
Btn_PutRemoveButton (ItsMe ? Txt_Remove_me_from_this_course :
Txt_Remove_user_from_this_course);
@ -4227,7 +4227,7 @@ static void Enr_AskIfRemAdm (bool ItsMe,Hie_Lvl_Level_t Scope,
/* End alert */
Ale_ShowAlertAndButton2 (Enr_ActRemAdm[Scope],NULL,NULL,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Btn_REMOVE_BUTTON,
ItsMe ? Txt_Remove_me_as_an_administrator :
Txt_Remove_USER_as_an_administrator);

View File

@ -31,7 +31,6 @@
#include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include "swad_database.h"
@ -853,7 +852,7 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
Exams->Num = (unsigned) NumRows;
/***** Create list of exams *****/
if ((Exams->Lst = (struct Exa_ExamSelected *) malloc (NumRows * sizeof (struct Exa_ExamSelected))) == NULL)
if ((Exams->Lst = malloc (NumRows * sizeof (*Exams->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the exams codes *****/
@ -890,7 +889,7 @@ void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams)
/***** Allocate memory for list of exams selected *****/
MaxSizeListExaCodsSelected = Exams->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
if ((Exams->ExaCodsSelected = (char *) malloc (MaxSizeListExaCodsSelected + 1)) == NULL)
if ((Exams->ExaCodsSelected = malloc (MaxSizeListExaCodsSelected + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get parameter multiple with list of exams selected *****/
@ -994,8 +993,7 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
Exam->Visibility = TstVis_GetVisibilityFromStr (row[5]);
/* Get the title of the exam (row[6]) */
Str_Copy (Exam->Title,row[6],
Exa_MAX_BYTES_TITLE);
Str_Copy (Exam->Title,row[6],sizeof (Exam->Title) - 1);
/* Get number of sets */
Exam->NumSets = ExaSet_GetNumSetsExam (Exam->ExaCod);
@ -1083,8 +1081,7 @@ void Exa_GetExamTxtFromDB (long ExaCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
{
/* Get info text */
row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
}
else
Txt[0] = '\0';

View File

@ -192,7 +192,7 @@ static long ExaAnn_GetParamsExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns)
// If the parameter is not present or is empty, initialize the string to the full name of the current course
if (!ExamAnns->ExamAnn.CrsFullName[0])
Str_Copy (ExamAnns->ExamAnn.CrsFullName,Gbl.Hierarchy.Crs.FullName,
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
sizeof (ExamAnns->ExamAnn.CrsFullName) - 1);
/***** Get the year *****/
ExamAnns->ExamAnn.Year = (unsigned)
@ -260,25 +260,25 @@ static long ExaAnn_GetParamsExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns)
static void ExaAnn_AllocMemExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns)
{
if ((ExamAnns->ExamAnn.Place = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((ExamAnns->ExamAnn.Place = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if ((ExamAnns->ExamAnn.Mode = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((ExamAnns->ExamAnn.Mode = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if ((ExamAnns->ExamAnn.Structure = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((ExamAnns->ExamAnn.Structure = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if ((ExamAnns->ExamAnn.DocRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((ExamAnns->ExamAnn.DocRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if ((ExamAnns->ExamAnn.MatRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((ExamAnns->ExamAnn.MatRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if ((ExamAnns->ExamAnn.MatAllowed = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((ExamAnns->ExamAnn.MatAllowed = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if ((ExamAnns->ExamAnn.OtherInfo = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((ExamAnns->ExamAnn.OtherInfo = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
}
@ -896,7 +896,7 @@ void ExaAnn_CreateListExamAnns (struct ExaAnn_ExamAnnouncements *ExamAnns)
if (NumExaAnns)
{
/***** Allocate memory for the list *****/
if ((ExamAnns->Lst = (struct ExaAnn_ExamCodeAndDate *) calloc (NumExaAnns,sizeof (struct ExaAnn_ExamCodeAndDate))) == NULL)
if ((ExamAnns->Lst = calloc (NumExaAnns,sizeof (*ExamAnns->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the dates of the existing exam announcements *****/
@ -984,7 +984,7 @@ static void ExaAnn_GetDataExamAnnFromDB (struct ExaAnn_ExamAnnouncements *ExamAn
/* Name of the course (row[2]) */
Str_Copy (ExamAnns->ExamAnn.CrsFullName,row[2],
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
sizeof (ExamAnns->ExamAnn.CrsFullName) - 1);
/* Year (row[3]) */
if (sscanf (row[3],"%u",&ExamAnns->ExamAnn.Year) != 1)
@ -992,7 +992,7 @@ static void ExaAnn_GetDataExamAnnFromDB (struct ExaAnn_ExamAnnouncements *ExamAn
/* Exam session (row[4]) */
Str_Copy (ExamAnns->ExamAnn.Session,row[4],
ExaAnn_MAX_BYTES_SESSION);
sizeof (ExamAnns->ExamAnn.Session) - 1);
/* Date of exam announcement (row[5]) */
if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u",
@ -1013,8 +1013,8 @@ static void ExaAnn_GetDataExamAnnFromDB (struct ExaAnn_ExamAnnouncements *ExamAn
&ExamAnns->ExamAnn.StartTime.Minute,
&Second) != 6)
Lay_ShowErrorAndExit ("Wrong date of exam.");
snprintf (ExamAnns->ExamAnn.ExamDate.YYYYMMDD,sizeof (ExamAnns->ExamAnn.ExamDate.YYYYMMDD),
"%04u%02u%02u",
snprintf (ExamAnns->ExamAnn.ExamDate.YYYYMMDD,
sizeof (ExamAnns->ExamAnn.ExamDate.YYYYMMDD),"%04u%02u%02u",
ExamAnns->ExamAnn.ExamDate.Year,
ExamAnns->ExamAnn.ExamDate.Month,
ExamAnns->ExamAnn.ExamDate.Day);
@ -1025,31 +1025,31 @@ static void ExaAnn_GetDataExamAnnFromDB (struct ExaAnn_ExamAnnouncements *ExamAn
/* Place (row[8]) */
Str_Copy (ExamAnns->ExamAnn.Place,row[8],
Cns_MAX_BYTES_TEXT);
sizeof (ExamAnns->ExamAnn.Place) - 1);
/* Exam mode (row[9]) */
Str_Copy (ExamAnns->ExamAnn.Mode,row[9],
Cns_MAX_BYTES_TEXT);
sizeof (ExamAnns->ExamAnn.Mode) - 1);
/* Structure (row[10]) */
Str_Copy (ExamAnns->ExamAnn.Structure,row[10],
Cns_MAX_BYTES_TEXT);
sizeof (ExamAnns->ExamAnn.Structure) - 1);
/* Documentation required (row[11]) */
Str_Copy (ExamAnns->ExamAnn.DocRequired,row[11],
Cns_MAX_BYTES_TEXT);
sizeof (ExamAnns->ExamAnn.DocRequired) - 1);
/* Material required (row[12]) */
Str_Copy (ExamAnns->ExamAnn.MatRequired,row[12],
Cns_MAX_BYTES_TEXT);
sizeof (ExamAnns->ExamAnn.MatRequired) - 1);
/* Material allowed (row[13]) */
Str_Copy (ExamAnns->ExamAnn.MatAllowed,row[13],
Cns_MAX_BYTES_TEXT);
sizeof (ExamAnns->ExamAnn.MatAllowed) - 1);
/* Other information for students (row[14]) */
Str_Copy (ExamAnns->ExamAnn.OtherInfo,row[14],
Cns_MAX_BYTES_TEXT);
sizeof (ExamAnns->ExamAnn.OtherInfo) - 1);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
@ -1726,14 +1726,12 @@ void ExaAnn_GetSummaryAndContentExamAnn (char SummaryStr[Ntf_MAX_BYTES_SUMMARY +
/***** Summary *****/
/* Name of the course and date of exam */
Dat_ConvDateToDateStr (&ExamAnns.ExamAnn.ExamDate,StrExamDate);
snprintf (CrsNameAndDate,sizeof (CrsNameAndDate),
"%s, %s, %2u:%02u",
snprintf (CrsNameAndDate,sizeof (CrsNameAndDate),"%s, %s, %2u:%02u",
ExamAnns.ExamAnn.CrsFullName,
StrExamDate,
ExamAnns.ExamAnn.StartTime.Hour,
ExamAnns.ExamAnn.StartTime.Minute);
Str_Copy (SummaryStr,CrsNameAndDate,
Ntf_MAX_BYTES_SUMMARY);
Str_Copy (SummaryStr,CrsNameAndDate,Ntf_MAX_BYTES_SUMMARY);
/***** Free memory of the exam announcement *****/
ExaAnn_FreeMemExamAnn (&ExamAnns);

View File

@ -230,12 +230,11 @@ static void ExaLog_LogUsrAgent (long LogCod,long PrnCod)
MaxBytes = strlen (UserAgent) * Str_MAX_BYTES_PER_CHAR;
else
MaxBytes = 0;
if ((UserAgentDB = (char *) malloc (MaxBytes + 1)) == NULL)
if ((UserAgentDB = malloc (MaxBytes + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if (UserAgent)
{
Str_Copy (UserAgentDB,UserAgent,
MaxBytes);
Str_Copy (UserAgentDB,UserAgent,MaxBytes);
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_TEXT,
UserAgentDB,MaxBytes,true);
}
@ -379,16 +378,12 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
ClickTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
/* Get IP (row[4]) */
Str_Copy (IP,row[4],
Cns_MAX_BYTES_IP);
Str_Copy (IP,row[4],sizeof (IP) - 1);
/* Get session id (row[5]) */
if (row[5]) // This row has a user agent stored in database
Str_Copy (SessionId,row[5],
Cns_BYTES_SESSION_ID);
else
Str_Copy (SessionId,"=",
Cns_BYTES_SESSION_ID);
Str_Copy (SessionId,row[5] ? row[5] : // This row has a user agent stored in database
"=",
sizeof (SessionId) - 1);
/* Get session id (row[6]) */
if (asprintf (&UserAgent,"%s",row[6] ? row[6] :

View File

@ -29,7 +29,6 @@
#include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include "swad_box.h"
@ -405,8 +404,7 @@ static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print,lon
Set.NumQstsToPrint = Str_ConvertStrToUnsigned (row[1]);
/* Get the title of the set (row[2]) */
Str_Copy (Set.Title,row[2],
ExaSet_MAX_BYTES_TITLE);
Str_Copy (Set.Title,row[2],sizeof (Set.Title) - 1);
/***** Questions in this set *****/
NumQstsFromSet = ExaPrn_GetSomeQstsFromSetToPrint (Print,&Set,&NumQstInPrint);
@ -563,7 +561,7 @@ static void ExaPrn_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *Printed
else
snprintf (StrInd,sizeof (StrInd),",%u",Index);
Str_Concat (PrintedQuestion->StrIndexes,StrInd,
Tst_MAX_BYTES_INDEXES_ONE_QST);
sizeof (PrintedQuestion->StrIndexes) - 1);
}
/***** Free structure that stores the query result *****/
@ -648,11 +646,11 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print)
/* Get indexes for this question (row[3]) */
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[3],
Tst_MAX_BYTES_INDEXES_ONE_QST);
strlen (Print->PrintedQuestions[NumQst].StrIndexes) - 1);
/* Get answers selected by user for this question (row[4]) */
Str_Copy (Print->PrintedQuestions[NumQst].StrAnswers,row[4],
Tst_MAX_BYTES_ANSWERS_ONE_QST);
strlen (Print->PrintedQuestions[NumQst].StrAnswers) - 1);
}
/***** Free structure that stores the query result *****/
@ -870,13 +868,10 @@ static void ExaPrn_WriteIntAnsToFill (const struct ExaPrn_Print *Print,
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
/***** Write input field for the answer *****/
snprintf (Id,sizeof (Id),
"Ans%010u",
NumQst);
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
" size=\"11\" maxlength=\"11\" value=\"%s\"",
Id,
Print->PrintedQuestions[NumQst].StrAnswers);
Id,Print->PrintedQuestions[NumQst].StrAnswers);
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
HTM_Txt (" />");
}
@ -892,9 +887,7 @@ static void ExaPrn_WriteFltAnsToFill (const struct ExaPrn_Print *Print,
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
/***** Write input field for the answer *****/
snprintf (Id,sizeof (Id),
"Ans%010u",
NumQst);
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
" size=\"11\" maxlength=\"%u\" value=\"%s\"",
Id,Tst_MAX_BYTES_FLOAT_ANSWER,
@ -918,9 +911,7 @@ static void ExaPrn_WriteTF_AnsToFill (const struct ExaPrn_Print *Print,
/* Initially user has not answered the question ==> initially all the answers will be blank.
If the user does not confirm the submission of their exam ==>
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
snprintf (Id,sizeof (Id),
"Ans%010u",
NumQst);
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
HTM_TxtF ("<select id=\"%s\" name=\"Ans\"",Id);
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
HTM_Txt (" />");
@ -968,9 +959,7 @@ static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print,
If the user does not confirm the submission of their exam ==>
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
HTM_TD_Begin ("class=\"LT\"");
snprintf (Id,sizeof (Id),
"Ans%010u",
NumQst);
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
HTM_TxtF ("<input type=\"%s\" id=\"%s_%u\" name=\"Ans\" value=\"%u\"%s",
Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE ? "radio" :
"checkbox",
@ -1015,9 +1004,7 @@ static void ExaPrn_WriteTxtAnsToFill (const struct ExaPrn_Print *Print,
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
/***** Write input field for the answer *****/
snprintf (Id,sizeof (Id),
"Ans%010u",
NumQst);
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
" size=\"40\" maxlength=\"%u\" value=\"%s\"",
Id,Tst_MAX_CHARS_ANSWERS_ONE_QST,
@ -1427,7 +1414,7 @@ static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question)
/***** Copy answer text (row[0]) ******/
Str_Copy (Question->Answer.Options[NumOpt].Text,row[0],
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
strlen (Question->Answer.Options[NumOpt].Text) - 1);
}
/***** Change format of answers text *****/
@ -1457,8 +1444,7 @@ static void ExaPrn_GetAnswerFromDB (struct ExaPrn_Print *Print,long QstCod,
row = mysql_fetch_row (mysql_res);
/* Get answers selected by user for this question (row[0]) */
Str_Copy (StrAnswers,row[0],
Tst_MAX_BYTES_ANSWERS_ONE_QST);
Str_Copy (StrAnswers,row[0],strlen (StrAnswers) - 1);
}
else
StrAnswers[0] = '\0';

View File

@ -29,7 +29,6 @@
#include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include "swad_action.h"
@ -371,7 +370,7 @@ static void ExaRes_ListAllResultsInSelectedExams (struct Exa_Exams *Exams)
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
@ -782,7 +781,7 @@ static void ExaRes_BuildExamsSelectedCommas (struct Exa_Exams *Exams,
/***** Allocate memory for subquery of exams selected *****/
MaxLength = (size_t) Exams->NumSelected * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
if ((*ExamsSelectedCommas = (char *) malloc (MaxLength + 1)) == NULL)
if ((*ExamsSelectedCommas = malloc (MaxLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Build subquery with list of selected exams *****/
@ -1164,7 +1163,7 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
case Usr_OTHER:
Frm_StartForm (ActSeeOneExaResOth);
ExaSes_PutParamsEdit (Exams);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
}
Ico_PutIconLink ("tasks.svg",Txt_Result);
@ -1650,8 +1649,8 @@ void ExaRes_ShowExamResultUser (struct UsrData *UsrDat)
HTM_TxtF ("&nbsp;%s",UsrDat->Surname1);
if (UsrDat->Surname2[0])
HTM_TxtF ("&nbsp;%s",UsrDat->Surname2);
if (UsrDat->FirstName[0])
HTM_TxtF (", %s",UsrDat->FirstName);
if (UsrDat->FrstName[0])
HTM_TxtF (", %s",UsrDat->FrstName);
HTM_BR ();
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :

View File

@ -29,7 +29,6 @@
#include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include "swad_database.h"
@ -268,8 +267,7 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams,
Session->ExaCod = Exam->ExaCod;
Session->TimeUTC[Dat_START_TIME] = Gbl.StartExecutionTimeUTC; // Now
Session->TimeUTC[Dat_END_TIME ] = Gbl.StartExecutionTimeUTC + (1 * 60 * 60); // Now + 1 hour
Str_Copy (Session->Title,Exam->Title,
ExaSes_MAX_BYTES_TITLE);
Str_Copy (Session->Title,Exam->Title,sizeof (Session->Title) - 1);
/* Put form to create new session */
ExaSes_PutFormSession (Session); // Form to create session
@ -890,8 +888,7 @@ static void ExaSes_GetSessionDataFromRow (MYSQL_RES *mysql_res,
/* Get the title of the session (row[7]) */
if (row[7])
Str_Copy (Session->Title,row[7],
ExaSes_MAX_BYTES_TITLE);
Str_Copy (Session->Title,row[7],sizeof (Session->Title) - 1);
else
Session->Title[0] = '\0';

View File

@ -31,7 +31,6 @@
#include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include "swad_database.h"
@ -242,16 +241,13 @@ void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set)
/* Get set index (row[2]) */
Set->SetInd = Str_ConvertStrToUnsigned (row[2]);
snprintf (StrSetInd,sizeof (Set->SetInd),
"%u",
Set->SetInd);
snprintf (StrSetInd,sizeof (Set->SetInd),"%u",Set->SetInd);
/* Get set index (row[3]) */
Set->NumQstsToPrint = Str_ConvertStrToUnsigned (row[3]);
/* Get the title of the set (row[4]) */
Str_Copy (Set->Title,row[4],
ExaSet_MAX_BYTES_TITLE);
Str_Copy (Set->Title,row[4],sizeof (Set->Title) - 1);
}
else
/* Initialize to empty set */
@ -477,8 +473,7 @@ void ExaSet_ChangeSetTitle (void)
ExaSet_UpdateSetTitleDB (&Set,NewTitle);
/* Update title */
Str_Copy (Set.Title,NewTitle,
ExaSet_MAX_BYTES_TITLE);
Str_Copy (Set.Title,NewTitle,sizeof (Set.Title) - 1);
}
/***** Show current exam and its sets *****/
@ -1085,16 +1080,13 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
/* Get set index (row[1]) */
Set.SetInd = Str_ConvertStrToUnsigned (row[1]);
snprintf (StrSetInd,sizeof (Set.SetInd),
"%u",
Set.SetInd);
snprintf (StrSetInd,sizeof (Set.SetInd),"%u",Set.SetInd);
/* Get number of questions to exam (row[2]) */
Set.NumQstsToPrint = Str_ConvertStrToUnsigned (row[2]);
/* Get the title of the set (row[3]) */
Str_Copy (Set.Title,row[3],
ExaSet_MAX_BYTES_TITLE);
Str_Copy (Set.Title,row[3],sizeof (Set.Title) - 1);
/* Initialize context */
Exams->SetCod = Set.SetCod;
@ -1433,15 +1425,13 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
Question->Stem[0] = '\0';
if (row[3])
if (row[3][0])
Str_Copy (Question->Stem,row[3],
Cns_MAX_BYTES_TEXT);
Str_Copy (Question->Stem,row[3],sizeof (Question->Stem) - 1);
/* Get the feedback (row[4]) */
Question->Feedback[0] = '\0';
if (row[4])
if (row[4][0])
Str_Copy (Question->Feedback,row[4],
Cns_MAX_BYTES_TEXT);
Str_Copy (Question->Feedback,row[4],sizeof (Question->Feedback) - 1);
/* Get media (row[5]) */
Question->Media.MedCod = Str_ConvertStrCodToLongCod (row[5]);
@ -1497,14 +1487,14 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
if (row[1])
if (row[1][0])
Str_Copy (Question->Answer.Options[NumOpt].Text,row[1],
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
sizeof (Question->Answer.Options[NumOpt].Text) - 1);
/* Get feedback (row[2]) */
Question->Answer.Options[NumOpt].Feedback[0] = '\0';
if (row[2])
if (row[2][0])
Str_Copy (Question->Answer.Options[NumOpt].Feedback,row[2],
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
sizeof (Question->Answer.Options[NumOpt].Feedback) - 1);
/* Get media (row[3]) */
Question->Answer.Options[NumOpt].Media.MedCod = Str_ConvertStrCodToLongCod (row[3]);
@ -1679,7 +1669,7 @@ static void ExaSet_AllocateListSelectedQuestions (struct Exa_Exams *Exams)
{
if (!Exams->ListQuestions)
{
if ((Exams->ListQuestions = (char *) malloc (ExaSet_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
if ((Exams->ListQuestions = malloc (ExaSet_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Exams->ListQuestions[0] = '\0';
}

View File

@ -2584,27 +2584,21 @@ static void Fig_WriteRowStatsFileBrowsers1 (const char *NameOfFileZones,
Fil_WriteFileSizeFull ((double) SizeOfFileZones->Size,FileSizeStr);
if (SizeOfFileZones->NumCrss == -1) // Not applicable
Str_Copy (StrNumCrss,"-",
Cns_MAX_DECIMAL_DIGITS_UINT);
Str_Copy (StrNumCrss,"-",sizeof (StrNumCrss) - 1);
else
snprintf (StrNumCrss,sizeof (StrNumCrss),
"%d",
snprintf (StrNumCrss,sizeof (StrNumCrss),"%d",
SizeOfFileZones->NumCrss);
if (SizeOfFileZones->NumGrps == -1) // Not applicable
Str_Copy (StrNumGrps,"-",
Cns_MAX_DECIMAL_DIGITS_UINT);
Str_Copy (StrNumGrps,"-",sizeof (StrNumGrps) - 1);
else
snprintf (StrNumGrps,sizeof (StrNumGrps),
"%d",
snprintf (StrNumGrps,sizeof (StrNumGrps),"%d",
SizeOfFileZones->NumGrps);
if (SizeOfFileZones->NumUsrs == -1) // Not applicable
Str_Copy (StrNumUsrs,"-",
Cns_MAX_DECIMAL_DIGITS_UINT);
Str_Copy (StrNumUsrs,"-",sizeof (StrNumUsrs) - 1);
else
snprintf (StrNumUsrs,sizeof (StrNumUsrs),
"%d",
snprintf (StrNumUsrs,sizeof (StrNumUsrs),"%d",
SizeOfFileZones->NumUsrs);
HTM_TR_Begin (NULL);
@ -2656,22 +2650,17 @@ static void Fig_WriteRowStatsFileBrowsers2 (const char *NameOfFileZones,
if (SizeOfFileZones->NumCrss == -1) // Not applicable
{
Str_Copy (StrNumFoldersPerCrs,"-",
Cns_MAX_DECIMAL_DIGITS_UINT);
Str_Copy (StrNumFilesPerCrs,"-",
Cns_MAX_DECIMAL_DIGITS_UINT);
Str_Copy (FileSizePerCrsStr,"-",
Fil_MAX_BYTES_FILE_SIZE_STRING);
Str_Copy (StrNumFoldersPerCrs,"-",sizeof (StrNumFoldersPerCrs) - 1);
Str_Copy (StrNumFilesPerCrs ,"-",sizeof (StrNumFilesPerCrs ) - 1);
Str_Copy (FileSizePerCrsStr ,"-",sizeof (FileSizePerCrsStr ) - 1);
}
else
{
snprintf (StrNumFoldersPerCrs,sizeof (StrNumFoldersPerCrs),
"%.1f",
snprintf (StrNumFoldersPerCrs,sizeof (StrNumFoldersPerCrs),"%.1f",
SizeOfFileZones->NumCrss ? (double) SizeOfFileZones->NumFolders /
(double) SizeOfFileZones->NumCrss :
0.0);
snprintf (StrNumFilesPerCrs,sizeof (StrNumFilesPerCrs),
"%.1f",
snprintf (StrNumFilesPerCrs,sizeof (StrNumFilesPerCrs),"%.1f",
SizeOfFileZones->NumCrss ? (double) SizeOfFileZones->NumFiles /
(double) SizeOfFileZones->NumCrss :
0.0);
@ -2714,22 +2703,17 @@ static void Fig_WriteRowStatsFileBrowsers3 (const char *NameOfFileZones,
if (SizeOfFileZones->NumUsrs == -1) // Not applicable
{
Str_Copy (StrNumFoldersPerUsr,"-",
Cns_MAX_DECIMAL_DIGITS_UINT);
Str_Copy (StrNumFilesPerUsr,"-",
Cns_MAX_DECIMAL_DIGITS_UINT);
Str_Copy (FileSizePerUsrStr,"-",
Fil_MAX_BYTES_FILE_SIZE_STRING);
Str_Copy (StrNumFoldersPerUsr,"-",sizeof (StrNumFoldersPerUsr) - 1);
Str_Copy (StrNumFilesPerUsr ,"-",sizeof (StrNumFilesPerUsr ) - 1);
Str_Copy (FileSizePerUsrStr ,"-",sizeof (FileSizePerUsrStr ) - 1);
}
else
{
snprintf (StrNumFoldersPerUsr,sizeof (StrNumFoldersPerUsr),
"%.1f",
snprintf (StrNumFoldersPerUsr,sizeof (StrNumFoldersPerUsr),"%.1f",
SizeOfFileZones->NumUsrs ? (double) SizeOfFileZones->NumFolders /
(double) SizeOfFileZones->NumUsrs :
0.0);
snprintf (StrNumFilesPerUsr,sizeof (StrNumFilesPerUsr),
"%.1f",
snprintf (StrNumFilesPerUsr,sizeof (StrNumFilesPerUsr),"%.1f",
SizeOfFileZones->NumUsrs ? (double) SizeOfFileZones->NumFiles /
(double) SizeOfFileZones->NumUsrs :
0.0);

View File

@ -78,8 +78,7 @@ void Fil_CreateFileForHTMLOutput (void)
/***** Create a unique name for the file *****/
snprintf (Gbl.HTMLOutput.FileName,sizeof (Gbl.HTMLOutput.FileName),
"%s/%s.html",
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
"%s/%s.html",Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
/***** Open file for writing and reading *****/
if ((Gbl.F.Out = fopen (Gbl.HTMLOutput.FileName,"w+t")) == NULL)
@ -322,14 +321,10 @@ void Fil_CreateUpdateFile (const char CurrentName[PATH_MAX + 1],
size_t LengthFileRoot = Str_GetLengthRootFileName (CurrentName);
char ErrorMsg[128 + PATH_MAX];
Str_Copy (NewName,CurrentName,
PATH_MAX);
Str_Copy (NewName,CurrentName,PATH_MAX);
NewName[LengthFileRoot] = '\0';
snprintf (OldName,PATH_MAX + 1,
"%s%s",
NewName,ExtensionOldName);
Str_Concat (NewName,".new",
PATH_MAX);
snprintf (OldName,PATH_MAX + 1,"%s%s",NewName,ExtensionOldName);
Str_Concat (NewName,".new",PATH_MAX);
/* The new file shouldn't exist. If it exists is due to any error when running this CGI formerly
and the file was not renamed successfully. In this case, remove it! */
@ -340,8 +335,7 @@ void Fil_CreateUpdateFile (const char CurrentName[PATH_MAX + 1],
if ((*NewFile = fopen (NewName,"wb")) == NULL)
{
snprintf (ErrorMsg,sizeof (ErrorMsg),
"Can not create file <strong>%s</strong>.",
NewName);
"Can not create file <strong>%s</strong>.",NewName);
Lay_ShowErrorAndExit (ErrorMsg);
}
}
@ -402,8 +396,7 @@ void Fil_CreateDirIfNotExists (const char Path[PATH_MAX + 1])
if (mkdir (Path,(mode_t) 0xFFF) != 0)
{
snprintf (ErrorMsg,sizeof (ErrorMsg),
"Can not create folder <strong>%s</strong>.",
Path);
"Can not create folder <strong>%s</strong>.",Path);
Lay_ShowErrorAndExit (ErrorMsg);
}
}
@ -445,8 +438,7 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1])
if (strcmp (FileList[NumFile]->d_name,".") &&
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
{
snprintf (PathFileRel,sizeof (PathFileRel),
"%s/%s",
snprintf (PathFileRel,sizeof (PathFileRel),"%s/%s",
Path,FileList[NumFile]->d_name);
Fil_RemoveTree (PathFileRel);
}
@ -466,8 +458,7 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1])
if (Error)
{
snprintf (ErrorMsg,sizeof (ErrorMsg),
"Can not remove folder %s.",
Path);
"Can not remove folder %s.",Path);
Lay_ShowErrorAndExit (ErrorMsg);
}
}
@ -511,8 +502,7 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,
if (strcmp (FileList[NumFile]->d_name,".") &&
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
{
snprintf (Path2,sizeof (Path2),
"%s/%s",
snprintf (Path2,sizeof (Path2),"%s/%s",
Path,FileList[NumFile]->d_name);
Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call
}
@ -611,24 +601,19 @@ void Fil_WriteFileSizeBrief (double SizeInBytes,
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1])
{
if (SizeInBytes < Ki)
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;B",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f&nbsp;B",
SizeInBytes);
else if (SizeInBytes < Mi)
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;KiB",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f&nbsp;KiB",
SizeInBytes / Ki);
else if (SizeInBytes < Gi)
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;MiB",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f&nbsp;MiB",
SizeInBytes / Mi);
else if (SizeInBytes < Ti)
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;GiB",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f&nbsp;GiB",
SizeInBytes / Gi);
else
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;TiB",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f&nbsp;TiB",
SizeInBytes / Ti);
}
@ -636,23 +621,18 @@ void Fil_WriteFileSizeFull (double SizeInBytes,
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1])
{
if (SizeInBytes < Ki)
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;B",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.0f&nbsp;B",
SizeInBytes);
else if (SizeInBytes < Mi)
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.1f&nbsp;KiB",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.1f&nbsp;KiB",
SizeInBytes / Ki);
else if (SizeInBytes < Gi)
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.1f&nbsp;MiB",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.1f&nbsp;MiB",
SizeInBytes / Mi);
else if (SizeInBytes < Ti)
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.1f&nbsp;GiB",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.1f&nbsp;GiB",
SizeInBytes / Gi);
else
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.1f&nbsp;TiB",
snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,"%.1f&nbsp;TiB",
SizeInBytes / Ti);
}

File diff suppressed because it is too large Load Diff

View File

@ -557,7 +557,7 @@ void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat,
{
Frm_StartForm (IFollowUsr ? ActUnfUsr :
ActFolUsr);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,
IFollowUsr ? "user-check.svg" :
"user-plus.svg",
@ -598,7 +598,7 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat,
{
/* Form to list users */
Frm_StartFormAnchor (Action,Fol_FOLLOW_SECTION_ID);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_BUTTON_SUBMIT_Begin (Title,
(Gbl.Action.Act == Action) ? "BT_LINK FOLLOW_NUM_B" :
"BT_LINK FOLLOW_NUM",
@ -624,7 +624,7 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat,
{
/* Form to list users */
Frm_StartFormAnchor (Action,Fol_FOLLOW_SECTION_ID);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_BUTTON_SUBMIT_Begin (Title,
(Gbl.Action.Act == Action) ? The_ClassFormLinkOutBoxBold[Gbl.Prefs.Theme] :
The_ClassFormLinkOutBox [Gbl.Prefs.Theme],
@ -845,7 +845,7 @@ static void Fol_ShowFollowedOrFollower (struct UsrData *UsrDat)
{
/* Put form to go to public profile */
Frm_StartForm (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_DIV_Begin ("class=\"FOLLOW_USR_NAME\""); // Limited width
HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,"BT_LINK LT DAT",NULL);
Usr_WriteFirstNameBRSurnames (UsrDat);
@ -902,7 +902,7 @@ static void Fol_WriteRowUsrToFollowOnRightColumn (struct UsrData *UsrDat)
{
/* Put form to go to public profile */
Frm_StartForm (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_DIV_Begin ("class=\"CON_NAME_FOLLOW\""); // Limited width
HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,"BT_LINK CON_NAME_FOLLOW CON_CRS",NULL);
Usr_WriteFirstNameBRSurnames (UsrDat);
@ -956,7 +956,7 @@ static void Fol_PutIconToFollow (struct UsrData *UsrDat)
/***** Form to unfollow *****/
Frm_StartForm (ActFolUsr);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-plus.svg",
Txt_Follow,"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16");
Frm_EndForm ();
@ -972,7 +972,7 @@ static void Fol_PutIconToUnfollow (struct UsrData *UsrDat)
/* Form to follow */
Frm_StartForm (ActUnfUsr);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"user-check.svg",
Txt_Unfollow,"FOLLOW_USR_ICO ICO_HIGHLIGHT ICO16x16");
Frm_EndForm ();
@ -1168,7 +1168,7 @@ static void Fol_GetFollowedFromSelectedUsrs (unsigned *NumFollowed,
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod) // Skip me
@ -1217,7 +1217,7 @@ void Fol_FollowUsrs ()
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod) // Skip me
@ -1264,7 +1264,7 @@ void Fol_UnfollowUsrs (void)
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod) // Skip me
@ -1463,7 +1463,7 @@ void Fol_GetNotifFollower (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
{
SummaryStr[0] = '\0'; // Return nothing on error
if ((*ContentStr = (char *) malloc (1)))
if ((*ContentStr = malloc (1)))
*ContentStr[0] = '\0';
}

View File

@ -57,9 +57,7 @@ static void Frm_StartFormInternal (Act_Action_t NextAction,bool PutParameterLoca
void Frm_StartFormGoTo (Act_Action_t NextAction)
{
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),
"form_%d",
Gbl.Form.Num);
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),"form_%d",Gbl.Form.Num);
Frm_StartFormInternal (NextAction,false,Gbl.Form.Id,NULL,NULL); // Do not put now parameter location
}
@ -81,9 +79,7 @@ void Frm_StartFormOnSubmit (Act_Action_t NextAction,const char *OnSubmit)
void Frm_StartFormAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit)
{
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),
"form_%d",
Gbl.Form.Num);
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),"form_%d",Gbl.Form.Num);
Frm_StartFormInternal (NextAction,true,Gbl.Form.Id,Anchor,OnSubmit); // Do put now parameter location (if no open session)
}
@ -95,8 +91,7 @@ void Frm_StartFormUnique (Act_Action_t NextAction)
void Frm_StartFormUniqueAnchor (Act_Action_t NextAction,const char *Anchor)
{
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),
"form_%s_%d",
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),"form_%s_%d",
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
Frm_StartFormInternal (NextAction,true,Gbl.Form.UniqueId,Anchor,NULL); // Do put now parameter location (if no open session)
}
@ -104,8 +99,7 @@ void Frm_StartFormUniqueAnchor (Act_Action_t NextAction,const char *Anchor)
void Frm_StartFormUniqueAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit)
{
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),
"form_%s_%d",
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),"form_%s_%d",
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
Frm_StartFormInternal (NextAction,true,Gbl.Form.UniqueId,Anchor,OnSubmit); // Do put now parameter location (if no open session)
}
@ -236,8 +230,7 @@ void Frm_SetParamsForm (char ParamsStr[Frm_MAX_BYTES_PARAMS_STR + 1],Act_Action_
}
}
snprintf (ParamsStr,Frm_MAX_BYTES_PARAMS_STR + 1,
"%s%s%s",
snprintf (ParamsStr,Frm_MAX_BYTES_PARAMS_STR + 1,"%s%s%s",
ParamAction,ParamSession,ParamLocation);
}
@ -263,8 +256,7 @@ void Frm_SetUniqueId (char UniqueId[Frm_MAX_BYTES_ID + 1])
So, Id uses:
- a name for this execution (Gbl.UniqueNameEncrypted)
- a number for each element in this execution (CountForThisExecution) *****/
snprintf (UniqueId,Frm_MAX_BYTES_ID + 1,
"id_%s_%u",
snprintf (UniqueId,Frm_MAX_BYTES_ID + 1,"id_%s_%u",
Gbl.UniqueNameEncrypted,
++CountForThisExecution);
}

View File

@ -720,8 +720,7 @@ static void For_GetThrSubject (long ThrCod,char Subject[Cns_MAX_BYTES_SUBJECT +
/***** Write the subject of the thread *****/
row = mysql_fetch_row (mysql_res);
Str_Copy (Subject,row[0],
Cns_MAX_BYTES_SUBJECT);
Str_Copy (Subject,row[0],Cns_MAX_BYTES_SUBJECT);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
@ -1031,8 +1030,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
Ale_ShowAlert (AlertType,Message);
/***** Begin box *****/
snprintf (FrameTitle,sizeof (FrameTitle),
"%s: %s",
snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s",
Txt_Thread,Thread.Subject);
Box_BoxBegin (NULL,FrameTitle,
For_PutIconNewPost,Forums,
@ -1231,8 +1229,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
if (Enabled)
/* Return this subject as last subject */
Str_Copy (LastSubject,Subject,
Cns_MAX_BYTES_SUBJECT);
Str_Copy (LastSubject,Subject,Cns_MAX_BYTES_SUBJECT);
HTM_TR_Begin (NULL);
@ -1320,8 +1317,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
HTM_TD_Begin ("class=\"MSG_TXT LT\"");
if (Enabled)
{
Str_Copy (Content,OriginalContent,
Cns_MAX_BYTES_LONG_TEXT);
Str_Copy (Content,OriginalContent,sizeof (Content) - 1);
Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false);
/***** Show image *****/
@ -1376,12 +1372,10 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
*CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
/***** Get subject (row[2]) *****/
Str_Copy (Subject,row[2],
Cns_MAX_BYTES_SUBJECT);
Str_Copy (Subject,row[2],Cns_MAX_BYTES_SUBJECT);
/***** Get location (row[3]) *****/
Str_Copy (Content,row[3],
Cns_MAX_BYTES_LONG_TEXT);
Str_Copy (Content,row[3],Cns_MAX_BYTES_LONG_TEXT);
/***** Get media (row[4]) *****/
Media->MedCod = Str_ConvertStrCodToLongCod (row[4]);
@ -1416,20 +1410,18 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1
row = mysql_fetch_row (mysql_res);
/***** Copy subject *****/
Str_Copy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
/***** Copy content *****/
if (GetContent)
{
Length = strlen (row[1]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
if ((*ContentStr = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if (Length)
Str_Copy (*ContentStr,row[1],
Length);
Str_Copy (*ContentStr,row[1],Length);
else
**ContentStr = '\0';
}
@ -2179,20 +2171,18 @@ void For_SetForumName (const struct For_Forum *Forum,
For_MAX_BYTES_FORUM_NAME);
break;
case For_FORUM_GLOBAL_TCHS:
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
"%s%s",
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
UseHTMLEntities ? Txt_General :
Txt_General_NO_HTML[Language],
UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break;
case For_FORUM__SWAD__USRS:
Str_Copy (ForumName,Cfg_PLATFORM_SHORT_NAME,
For_MAX_BYTES_FORUM_NAME);
Str_Copy (ForumName,Cfg_PLATFORM_SHORT_NAME,For_MAX_BYTES_FORUM_NAME);
break;
case For_FORUM__SWAD__TCHS:
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
"%s%s",Cfg_PLATFORM_SHORT_NAME,
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
Cfg_PLATFORM_SHORT_NAME,
UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break;
@ -2200,15 +2190,14 @@ void For_SetForumName (const struct For_Forum *Forum,
Hie.Ins.InsCod = Forum->Location;
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
Lay_ShowErrorAndExit ("Institution not found.");
Str_Copy (ForumName,Hie.Ins.ShrtName,
For_MAX_BYTES_FORUM_NAME);
Str_Copy (ForumName,Hie.Ins.ShrtName,For_MAX_BYTES_FORUM_NAME);
break;
case For_FORUM_INSTIT_TCHS:
Hie.Ins.InsCod = Forum->Location;
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
Lay_ShowErrorAndExit ("Institution not found.");
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
"%s%s",Hie.Ins.ShrtName,
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
Hie.Ins.ShrtName,
UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break;
@ -2216,15 +2205,14 @@ void For_SetForumName (const struct For_Forum *Forum,
Hie.Ctr.CtrCod = Forum->Location;
if (!Ctr_GetDataOfCentreByCod (&Hie.Ctr))
Lay_ShowErrorAndExit ("Centre not found.");
Str_Copy (ForumName,Hie.Ctr.ShrtName,
For_MAX_BYTES_FORUM_NAME);
Str_Copy (ForumName,Hie.Ctr.ShrtName,For_MAX_BYTES_FORUM_NAME);
break;
case For_FORUM_CENTRE_TCHS:
Hie.Ctr.CtrCod = Forum->Location;
if (!Ctr_GetDataOfCentreByCod (&Hie.Ctr))
Lay_ShowErrorAndExit ("Centre not found.");
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
"%s%s",Hie.Ctr.ShrtName,
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
Hie.Ctr.ShrtName,
UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break;
@ -2232,15 +2220,14 @@ void For_SetForumName (const struct For_Forum *Forum,
Hie.Deg.DegCod = Forum->Location;
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
Lay_ShowErrorAndExit ("Degree not found.");
Str_Copy (ForumName,Hie.Deg.ShrtName,
For_MAX_BYTES_FORUM_NAME);
Str_Copy (ForumName,Hie.Deg.ShrtName,For_MAX_BYTES_FORUM_NAME);
break;
case For_FORUM_DEGREE_TCHS:
Hie.Deg.DegCod = Forum->Location;
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
Lay_ShowErrorAndExit ("Degree not found.");
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
"%s%s",Hie.Deg.ShrtName,
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
Hie.Deg.ShrtName,
UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break;
@ -2248,21 +2235,19 @@ void For_SetForumName (const struct For_Forum *Forum,
Hie.Crs.CrsCod = Forum->Location;
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
Lay_ShowErrorAndExit ("Course not found.");
Str_Copy (ForumName,Hie.Crs.ShrtName,
For_MAX_BYTES_FORUM_NAME);
Str_Copy (ForumName,Hie.Crs.ShrtName,For_MAX_BYTES_FORUM_NAME);
break;
case For_FORUM_COURSE_TCHS:
Hie.Crs.CrsCod = Forum->Location;
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
Lay_ShowErrorAndExit ("Course not found.");
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
"%s%s",Hie.Crs.ShrtName,
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
Hie.Crs.ShrtName,
UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break;
default:
Str_Copy (ForumName,Txt_Unknown_FORUM,
For_MAX_BYTES_FORUM_NAME);
Str_Copy (ForumName,Txt_Unknown_FORUM,For_MAX_BYTES_FORUM_NAME);
}
}
@ -2504,9 +2489,7 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums
Ale_ShowAlert (AlertType,Message);
/***** Begin box for threads of this forum *****/
snprintf (FrameTitle,sizeof (FrameTitle),
"%s: %s",
Txt_Forum,ForumName);
snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s",Txt_Forum,ForumName);
Box_BoxBegin (NULL,FrameTitle,
For_PutIconNewThread,Forums,
Hlp_COMMUNICATION_Forums_threads,Box_NOT_CLOSABLE);
@ -3520,12 +3503,9 @@ static void For_GetThreadData (struct For_Thread *Thr)
Thr->WriteTime[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[5]);
/***** Get the subject of this thread (row[6]) *****/
Str_Copy (Thr->Subject,row[6],
Cns_MAX_BYTES_SUBJECT);
Str_Copy (Thr->Subject,row[6],sizeof (Thr->Subject) - 1);
if (!Thr->Subject[0])
snprintf (Thr->Subject,sizeof (Thr->Subject),
"[%s]",
Txt_no_subject);
snprintf (Thr->Subject,sizeof (Thr->Subject),"[%s]",Txt_no_subject);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
@ -4260,7 +4240,7 @@ void For_CutThread (void)
if (Subject[0])
{
snprintf (Message,sizeof (Message),
Txt_Thread_X_marked_to_be_moved,Subject);
Txt_Thread_X_marked_to_be_moved,Subject);
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Message);
}
else
@ -4301,8 +4281,7 @@ void For_PasteThread (void)
if (Subject[0])
{
snprintf (Message,sizeof (Message),
Txt_The_thread_X_is_already_in_this_forum,
Subject);
Txt_The_thread_X_is_already_in_this_forum,Subject);
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_WARNING,Message);
}
else
@ -4320,8 +4299,7 @@ void For_PasteThread (void)
if (Subject[0])
{
snprintf (Message,sizeof (Message),
Txt_Thread_X_moved_to_this_forum,
Subject);
Txt_Thread_X_moved_to_this_forum,Subject);
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Message);
}
else

View File

@ -30,7 +30,6 @@
#include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include "swad_database.h"
@ -919,7 +918,7 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
Games->Num = (unsigned) NumRows;
/***** Create list of games *****/
if ((Games->Lst = (struct Gam_GameSelected *) malloc (NumRows * sizeof (struct Gam_GameSelected))) == NULL)
if ((Games->Lst = malloc (NumRows * sizeof (*Games->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the games codes *****/
@ -963,7 +962,7 @@ void Gam_GetListSelectedGamCods (struct Gam_Games *Games)
/***** Allocate memory for list of games selected *****/
MaxSizeListGamCodsSelected = Games->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
if ((Games->GamCodsSelected = (char *) malloc (MaxSizeListGamCodsSelected + 1)) == NULL)
if ((Games->GamCodsSelected = malloc (MaxSizeListGamCodsSelected + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get parameter multiple with list of games selected *****/
@ -1062,8 +1061,7 @@ void Gam_GetDataOfGameByCod (struct Gam_Game *Game)
Game->Visibility = TstVis_GetVisibilityFromStr (row[5]);
/* Get the title of the game (row[6]) */
Str_Copy (Game->Title,row[6],
Gam_MAX_BYTES_TITLE);
Str_Copy (Game->Title,row[6],sizeof (Game->Title) - 1);
/* Get number of questions */
Game->NumQsts = Gam_GetNumQstsGame (Game->GamCod);
@ -1148,8 +1146,7 @@ static void Gam_GetGameTxtFromDB (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
{
/* Get info text */
row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
}
else
Txt[0] = '\0';
@ -2106,9 +2103,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
/* Get question index (row[0]) */
QstInd = Str_ConvertStrToUnsigned (row[0]);
snprintf (StrQstInd,sizeof (StrQstInd),
"%u",
QstInd);
snprintf (StrQstInd,sizeof (StrQstInd),"%u",QstInd);
/* Get question code (row[1]) */
Question.QstCod = Str_ConvertStrCodToLongCod (row[1]);
@ -2309,7 +2304,7 @@ static void Gam_AllocateListSelectedQuestions (struct Gam_Games *Games)
{
if (!Games->ListQuestions)
{
if ((Games->ListQuestions = (char *) malloc (Gam_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
if ((Games->ListQuestions = malloc (Gam_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Games->ListQuestions[0] = '\0';
}

View File

@ -144,14 +144,10 @@ void Gbl_InitializeGlobals (void)
Gbl.Prefs.Menu = Mnu_MENU_DEFAULT; // Default menu
Gbl.Prefs.Theme = The_THEME_DEFAULT; // Default theme
Gbl.Prefs.IconSet = Ico_ICON_SET_DEFAULT; // Default icon set
snprintf (Gbl.Prefs.URLTheme,sizeof (Gbl.Prefs.URLTheme),
"%s/%s",
Cfg_URL_ICON_THEMES_PUBLIC,
The_ThemeId[Gbl.Prefs.Theme]);
snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),
"%s/%s",
Cfg_URL_ICON_SETS_PUBLIC,
Ico_IconSetId[Gbl.Prefs.IconSet]);
snprintf (Gbl.Prefs.URLTheme,sizeof (Gbl.Prefs.URLTheme),"%s/%s",
Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]);
snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),"%s/%s",
Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[Gbl.Prefs.IconSet]);
Gbl.Session.NumSessions = 0;
Gbl.Session.IsOpen = false;

View File

@ -502,7 +502,7 @@ void Grp_PutParamsCodGrps (void)
Gbl.Crs.Grps.LstGrpsSel.NumGrps)
{
MaxLengthGrpCods = Gbl.Crs.Grps.LstGrpsSel.NumGrps * (Cns_MAX_DECIMAL_DIGITS_LONG + 1) - 1;
if ((GrpCods = (char *) malloc (MaxLengthGrpCods + 1)) == NULL)
if ((GrpCods = malloc (MaxLengthGrpCods + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
GrpCods[0] = '\0';
@ -513,8 +513,7 @@ void Grp_PutParamsCodGrps (void)
/* Append group code to list */
if (NumGrpSel)
Str_Concat (GrpCods,Par_SEPARATOR_PARAM_MULTIPLE,MaxLengthGrpCods);
snprintf (GrpCod,sizeof (GrpCod),
"%ld",
snprintf (GrpCod,sizeof (GrpCod),"%ld",
Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
Str_Concat (GrpCods,GrpCod,MaxLengthGrpCods);
}
@ -553,7 +552,8 @@ void Grp_GetParCodsSeveralGrpsToShowUsrs (void)
if (LstGrpsIBelong.NumGrps)
{
/* Allocate space for list of selected groups */
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = (long *) calloc (LstGrpsIBelong.NumGrps,sizeof (long))) == NULL)
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (LstGrpsIBelong.NumGrps,
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
Lay_NotEnoughMemoryExit ();
/* Fill list of selected groups with list of groups I belong to */
@ -591,7 +591,7 @@ void Grp_GetParCodsSeveralGrps (void)
if (Gbl.Crs.Grps.NumGrps) // If course has groups
{
/***** Allocate memory for the list of group codes selected *****/
if ((ParamLstCodGrps = (char *) malloc (MaxSizeLstGrpCods + 1)) == NULL)
if ((ParamLstCodGrps = malloc (MaxSizeLstGrpCods + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get parameter with list of groups to list *****/
@ -609,7 +609,8 @@ void Grp_GetParCodsSeveralGrps (void)
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps) // If I have selected groups...
{
/***** Create a list of groups selected from LstCodGrps *****/
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = (long *) calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,sizeof (long))) == NULL)
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
Lay_NotEnoughMemoryExit ();
for (Ptr = ParamLstCodGrps, NumGrp = 0;
*Ptr;
@ -1064,7 +1065,8 @@ static void Grp_ConstructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **Al
unsigned NumGrpTyp;
/***** Allocate memory to a list of booleanos that indica if already se ha selected a group of cada type *****/
if ((*AlreadyExistsGroupOfType = (struct ListGrpsAlreadySelec *) calloc (Gbl.Crs.Grps.GrpTypes.Num,sizeof (struct ListGrpsAlreadySelec))) == NULL)
if ((*AlreadyExistsGroupOfType = calloc (Gbl.Crs.Grps.GrpTypes.Num,
sizeof (**AlreadyExistsGroupOfType))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Initialize the list *****/
@ -1384,9 +1386,7 @@ static void Grp_ListGroupTypesForEdition (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"LM\"");
snprintf (Id,sizeof (Id),
"open_time_%u",
UniqueId);
snprintf (Id,sizeof (Id),"open_time_%u",UniqueId);
Dat_WriteFormClientLocalDateTimeFromTimeUTC (Id,
"Open",
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].OpenTimeUTC,
@ -2064,9 +2064,7 @@ static bool Grp_ListGrpsForChangeMySelection (struct GroupType *GrpTyp,
else
HTM_TD_Begin ("class=\"LM\"");
snprintf (StrGrpCod,sizeof (StrGrpCod),
"GrpCod%ld",
GrpTyp->GrpTypCod);
snprintf (StrGrpCod,sizeof (StrGrpCod),"GrpCod%ld",GrpTyp->GrpTypCod);
if (Gbl.Usrs.Me.Role.Logged == Rol_STD && // If I am a student
!GrpTyp->MultipleEnrolment && // ...and the enrolment is single
GrpTyp->NumGrps > 1) // ...and there are more than one group
@ -2191,9 +2189,7 @@ static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod)
/* Put checkbox to select the group */
// Always checkbox, not radio, because the role in the form may be teacher,
// so if he/she is registered as teacher, he/she can belong to several groups
snprintf (StrGrpCod,sizeof (StrGrpCod),
"GrpCod%ld",
GrpTyp->GrpTypCod);
snprintf (StrGrpCod,sizeof (StrGrpCod),"GrpCod%ld",GrpTyp->GrpTypCod);
HTM_INPUT_CHECKBOX (StrGrpCod,HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Grp%ld\" value=\"%ld\"%s",
Grp->GrpCod,Grp->GrpCod,
@ -2808,7 +2804,8 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
if (Gbl.Crs.Grps.GrpTypes.Num)
{
/***** Create a list of group types *****/
if ((Gbl.Crs.Grps.GrpTypes.LstGrpTypes = (struct GroupType *) calloc (Gbl.Crs.Grps.GrpTypes.Num,sizeof (struct GroupType))) == NULL)
if ((Gbl.Crs.Grps.GrpTypes.LstGrpTypes = calloc (Gbl.Crs.Grps.GrpTypes.Num,
sizeof (*Gbl.Crs.Grps.GrpTypes.LstGrpTypes))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get group types *****/
@ -2825,7 +2822,7 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
/* Get group type name (row[1]) */
Str_Copy (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName,row[1],
Grp_MAX_BYTES_GROUP_TYPE_NAME);
sizeof (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName) - 1);
/* Is it mandatory to register in any groups of this type? (row[2]) */
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MandatoryEnrolment = (row[2][0] == 'Y');
@ -2939,7 +2936,8 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
GrpTyp->NumGrps = (unsigned) NumRows;
/***** Create list with groups of this type *****/
if ((GrpTyp->LstGrps = (struct Group *) calloc (GrpTyp->NumGrps,sizeof (struct Group))) == NULL)
if ((GrpTyp->LstGrps = calloc (GrpTyp->NumGrps,
sizeof (*GrpTyp->LstGrps))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the groups of this type *****/
@ -2957,8 +2955,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
Lay_ShowErrorAndExit ("Wrong code of group.");
/* Get group name (row[1]) */
Str_Copy (Grp->GrpName,row[1],
Grp_MAX_BYTES_GROUP_NAME);
Str_Copy (Grp->GrpName,row[1],sizeof (Grp->GrpName) - 1);
/* Get room code (row[2]) */
Grp->Room.RooCod = Str_ConvertStrCodToLongCod (row[2]);
@ -2966,7 +2963,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
/* Get room short name (row[3]) */
if (row[3]) // May be NULL because of LEFT JOIN
Str_Copy (Grp->Room.ShrtName,row[3],
Roo_MAX_BYTES_SHRT_NAME);
sizeof (Grp->Room.ShrtName) - 1);
else // NULL
Grp->Room.ShrtName[0] = '\0';
@ -3107,8 +3104,7 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
/***** Get some data of group type *****/
row = mysql_fetch_row (mysql_res);
Str_Copy (GrpTyp->GrpTypName,row[0],
Grp_MAX_BYTES_GROUP_TYPE_NAME);
Str_Copy (GrpTyp->GrpTypName,row[0],sizeof (GrpTyp->GrpTypName) - 1);
GrpTyp->MandatoryEnrolment = (row[1][0] == 'Y');
GrpTyp->MultipleEnrolment = (row[2][0] == 'Y');
GrpTyp->MustBeOpened = (row[3][0] == 'Y');
@ -3204,15 +3200,13 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
Lay_ShowErrorAndExit ("Wrong code of course.");
/* Get the name of the group type (row[2]) */
Str_Copy (GrpDat->GrpTypName,row[2],
Grp_MAX_BYTES_GROUP_TYPE_NAME);
Str_Copy (GrpDat->GrpTypName,row[2],sizeof (GrpDat->GrpTypName) - 1);
/* Get whether a student may be in one or multiple groups (row[3]) */
GrpDat->MultipleEnrolment = (row[3][0] == 'Y');
/* Get the name of the group (row[4]) */
Str_Copy (GrpDat->GrpName,row[4],
Grp_MAX_BYTES_GROUP_NAME);
Str_Copy (GrpDat->GrpName,row[4],sizeof (GrpDat->GrpName) - 1);
/* Get the code of the course (row[5]) */
GrpDat->Room.RooCod = Str_ConvertStrCodToLongCod (row[5]);
@ -3220,7 +3214,7 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
/* Get the name of the room (row[6]) */
if (row[6]) // May be NULL because of LEFT JOIN
Str_Copy (GrpDat->Room.ShrtName,row[6],
Roo_MAX_BYTES_SHRT_NAME);
sizeof (GrpDat->Room.ShrtName) - 1);
else // NULL
GrpDat->Room.ShrtName[0] = '\0';
@ -3611,7 +3605,8 @@ static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
if (LstGrps->NumGrps)
{
/***** Create a list of groups the user belongs to *****/
if ((LstGrps->GrpCods = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL)
if ((LstGrps->GrpCods = calloc (LstGrps->NumGrps,
sizeof (*LstGrps->GrpCods))) == NULL)
Lay_NotEnoughMemoryExit ();
for (NumGrp = 0;
NumGrp < LstGrps->NumGrps;
@ -3657,7 +3652,8 @@ void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps)
if (LstGrps->NumGrps)
{
/***** Create a list of groups I belong to *****/
if ((LstGrps->GrpCods = (long *) calloc (LstGrps->NumGrps,sizeof (long))) == NULL)
if ((LstGrps->GrpCods = calloc (LstGrps->NumGrps,
sizeof (*LstGrps->GrpCods))) == NULL)
Lay_NotEnoughMemoryExit ();
for (NumGrp = 0;
NumGrp < LstGrps->NumGrps;
@ -3726,10 +3722,8 @@ void Grp_GetNamesGrpsStdBelongsTo (long GrpTypCod,long UsrCod,char *GroupNames)
/* El group name in row[0] */
if (NumRow)
Str_Concat (GroupNames,", ",
MaxLength);
Str_Concat (GroupNames,row[0],
MaxLength);
Str_Concat (GroupNames,", ",MaxLength);
Str_Concat (GroupNames,row[0],MaxLength);
}
/***** Free structure that stores the query result *****/
@ -3770,7 +3764,7 @@ void Grp_ReceiveFormNewGrpTyp (void)
{
AlertType = Ale_WARNING;
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_The_type_of_group_X_already_exists,
Txt_The_type_of_group_X_already_exists,
Gbl.Crs.Grps.GrpTyp.GrpTypName);
}
else // Add new group type to database
@ -4144,8 +4138,7 @@ static void Grp_RemoveGroupTypeCompletely (void)
Gbl.Crs.Grps.GrpTyp.GrpTypCod);
/***** Create message to show the change made *****/
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_Type_of_group_X_removed,
snprintf (AlertTxt,sizeof (AlertTxt),Txt_Type_of_group_X_removed,
Gbl.Crs.Grps.GrpTyp.GrpTypName);
/***** Show the form again *****/
@ -4198,8 +4191,7 @@ static void Grp_RemoveGroupCompletely (void)
Gbl.Crs.Grps.GrpCod);
/***** Create message to show the change made *****/
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_Group_X_removed,
snprintf (AlertTxt,sizeof (AlertTxt),Txt_Group_X_removed,
GrpDat.GrpName);
/***** Show the form again *****/
@ -4231,8 +4223,7 @@ void Grp_OpenGroup (void)
Gbl.Crs.Grps.GrpCod);
/***** Create message to show the change made *****/
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_The_group_X_is_now_open,
snprintf (AlertTxt,sizeof (AlertTxt),Txt_The_group_X_is_now_open,
GrpDat.GrpName);
/***** Show the form again *****/
@ -4265,8 +4256,7 @@ void Grp_CloseGroup (void)
Gbl.Crs.Grps.GrpCod);
/***** Create message to show the change made *****/
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_The_group_X_is_now_closed,
snprintf (AlertTxt,sizeof (AlertTxt),Txt_The_group_X_is_now_closed,
GrpDat.GrpName);
/***** Show the form again *****/
@ -4300,7 +4290,7 @@ void Grp_EnableFileZonesGrp (void)
/***** Create message to show the change made *****/
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_File_zones_of_the_group_X_are_now_enabled,
Txt_File_zones_of_the_group_X_are_now_enabled,
GrpDat.GrpName);
/***** Show the form again *****/
@ -4373,8 +4363,7 @@ void Grp_ChangeGroupType (void)
{
/* Create warning message */
AlertType = Ale_WARNING;
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_The_group_X_already_exists,
snprintf (AlertTxt,sizeof (AlertTxt),Txt_The_group_X_already_exists,
GrpDat.GrpName);
}
else // Group is not in database
@ -4662,9 +4651,7 @@ void Grp_ChangeMaxStdsGrp (void)
static void Grp_WriteMaxStds (char Str[Cns_MAX_DECIMAL_DIGITS_UINT + 1],unsigned MaxStudents)
{
if (MaxStudents <= Grp_MAX_STUDENTS_IN_A_GROUP)
snprintf (Str,Cns_MAX_DECIMAL_DIGITS_UINT + 1,
"%u",
MaxStudents);
snprintf (Str,Cns_MAX_DECIMAL_DIGITS_UINT + 1,"%u",MaxStudents);
else
Str[0] = '\0';
}
@ -4721,8 +4708,7 @@ void Grp_RenameGroupType (void)
{
AlertType = Ale_WARNING;
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_The_type_of_group_X_already_exists,
NewNameGrpTyp);
Txt_The_type_of_group_X_already_exists,NewNameGrpTyp);
}
else
{
@ -4757,7 +4743,7 @@ void Grp_RenameGroupType (void)
/***** Show the form again *****/
Str_Copy (Gbl.Crs.Grps.GrpTyp.GrpTypName,NewNameGrpTyp,
Grp_MAX_BYTES_GROUP_TYPE_NAME);
sizeof (Gbl.Crs.Grps.GrpTyp.GrpTypName) - 1);
Grp_ReqEditGroupsInternal (AlertType,AlertTxt,
Ale_INFO,NULL);
}
@ -4807,8 +4793,7 @@ void Grp_RenameGroup (void)
{
AlertType = Ale_WARNING;
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_The_group_X_already_exists,
NewNameGrp);
Txt_The_group_X_already_exists,NewNameGrp);
}
else
{
@ -4828,14 +4813,12 @@ void Grp_RenameGroup (void)
{
AlertType = Ale_INFO;
snprintf (AlertTxt,sizeof (AlertTxt),
Txt_The_name_of_the_group_X_has_not_changed,
NewNameGrp);
Txt_The_name_of_the_group_X_has_not_changed,NewNameGrp);
}
}
/***** Show the form again *****/
Str_Copy (Gbl.Crs.Grps.GrpName,NewNameGrp,
Grp_MAX_BYTES_GROUP_NAME);
Str_Copy (Gbl.Crs.Grps.GrpName,NewNameGrp,sizeof (Gbl.Crs.Grps.GrpName) - 1);
Grp_ReqEditGroupsInternal (Ale_INFO,NULL,
AlertType,AlertTxt);
}
@ -4894,7 +4877,8 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
unsigned NumGrpWanted;
/***** Allocate memory for the strings with group codes in each type *****/
if ((LstStrCodGrps = (char **) calloc (Gbl.Crs.Grps.GrpTypes.Num,sizeof (char *))) == NULL)
if ((LstStrCodGrps = calloc (Gbl.Crs.Grps.GrpTypes.Num,
sizeof (*LstStrCodGrps))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get lists with the groups that I want in each type
@ -4904,13 +4888,12 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
NumGrpTyp++)
{
/***** Allocate memory for the list of group codes of this type *****/
if ((LstStrCodGrps[NumGrpTyp] = (char *) malloc ((size_t) ((Cns_MAX_DECIMAL_DIGITS_LONG + 1) *
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps))) == NULL)
if ((LstStrCodGrps[NumGrpTyp] = malloc (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps *
(Cns_MAX_DECIMAL_DIGITS_LONG + 1))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the multiple parameter code of group of this type *****/
snprintf (Param,sizeof (Param),
"GrpCod%ld",
snprintf (Param,sizeof (Param),"GrpCod%ld",
Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod);
Par_GetParMultiToText (Param,LstStrCodGrps[NumGrpTyp],
((Cns_MAX_DECIMAL_DIGITS_LONG + 1) * Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) - 1);
@ -4931,8 +4914,9 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
with all the groups selected (of all the types) *****/
if (LstGrpsWanted->NumGrps)
{
if ((LstGrpsWanted->GrpCods = (long *) calloc (LstGrpsWanted->NumGrps,sizeof (long))) == NULL)
Lay_ShowErrorAndExit ("Not enoguh memory to store codes of groups in which a user wants to be enroled.");
if ((LstGrpsWanted->GrpCods = calloc (LstGrpsWanted->NumGrps,
sizeof (*LstGrpsWanted->GrpCods))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the groups *****/
for (NumGrpTyp = 0, NumGrpWanted = 0;

View File

@ -599,14 +599,11 @@ void Hie_InitHierarchy (void)
if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected
{
/***** Paths of course directories *****/
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),
"%s/%ld",
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),"%s/%ld",
Cfg_PATH_CRS_PRIVATE,Gbl.Hierarchy.Crs.CrsCod);
snprintf (Gbl.Crs.PathRelPubl,sizeof (Gbl.Crs.PathRelPubl),
"%s/%ld",
snprintf (Gbl.Crs.PathRelPubl,sizeof (Gbl.Crs.PathRelPubl),"%s/%ld",
Cfg_PATH_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
snprintf (Gbl.Crs.PathURLPubl,sizeof (Gbl.Crs.PathURLPubl),
"%s/%ld",
snprintf (Gbl.Crs.PathURLPubl,sizeof (Gbl.Crs.PathURLPubl),"%s/%ld",
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
/***** If any of the course directories does not exist, create it *****/

View File

@ -366,9 +366,8 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
if (Holidays->Num) // Holidays found...
{
/***** Create list of holidays *****/
if ((Holidays->Lst = (struct Hld_Holiday *)
calloc ((size_t) Holidays->Num,
sizeof (struct Hld_Holiday))) == NULL)
if ((Holidays->Lst = calloc (Holidays->Num,
sizeof (*Holidays->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the holidays *****/
@ -390,7 +389,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
/* Get the full name of the place (row[2]) */
Str_Copy (Hld->PlaceFullName,row[2],
Plc_MAX_BYTES_PLACE_FULL_NAME);
sizeof (Hld->PlaceFullName) - 1);
/* Get type (row[3]) */
Hld->HldTyp = Hld_GetTypeOfHoliday (row[3]);
@ -414,8 +413,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
}
/* Get the name of the holiday/non school period (row[6]) */
Str_Copy (Hld->Name,row[6],
Hld_MAX_BYTES_HOLIDAY_NAME);
Str_Copy (Hld->Name,row[6],sizeof (Hld->Name) - 1);
}
}
@ -487,8 +485,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld)
Hld->PlcCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get the full name of the place (row[1]) */
Str_Copy (Hld->PlaceFullName,row[1],
Plc_MAX_BYTES_PLACE_FULL_NAME);
Str_Copy (Hld->PlaceFullName,row[1],sizeof (Hld->PlaceFullName) - 1);
/* Get type (row[2]) */
Hld->HldTyp = Hld_GetTypeOfHoliday (row[2]);
@ -512,8 +509,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld)
}
/* Get the name of the holiday/non school period (row[5]) */
Str_Copy (Hld->Name,row[5],
Hld_MAX_BYTES_HOLIDAY_NAME);
Str_Copy (Hld->Name,row[5],sizeof (Hld->Name) - 1);
}
/***** Free structure that stores the query result *****/
@ -769,7 +765,7 @@ void Hld_ChangeHolidayPlace (void)
NewPlace.PlcCod,Hld_EditingHld->HldCod);
Hld_EditingHld->PlcCod = NewPlace.PlcCod;
Str_Copy (Hld_EditingHld->PlaceFullName,NewPlace.FullName,
Plc_MAX_BYTES_PLACE_FULL_NAME);
sizeof (Hld_EditingHld->PlaceFullName) - 1);
/***** Write message to show the change made *****/
Ale_CreateAlert (Ale_SUCCESS,NULL,
@ -938,7 +934,7 @@ void Hld_RenameHoliday (void)
"UPDATE holidays SET Name='%s' WHERE HldCod=%ld",
NewHldName,Hld_EditingHld->HldCod);
Str_Copy (Hld_EditingHld->Name,NewHldName,
Hld_MAX_BYTES_HOLIDAY_NAME);
sizeof (Hld_EditingHld->Name) - 1);
/***** Write message to show the change made *****/
Ale_CreateAlert (Ale_SUCCESS,NULL,
@ -1203,8 +1199,8 @@ static void Hld_EditingHolidayConstructor (void)
Lay_ShowErrorAndExit ("Error initializing holiday.");
/***** Allocate memory for holiday *****/
if ((Hld_EditingHld = (struct Hld_Holiday *) malloc (sizeof (struct Hld_Holiday))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for holiday.");
if ((Hld_EditingHld = malloc (sizeof (*Hld_EditingHld))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset place *****/
Hld_EditingHld->HldCod = -1L;

View File

@ -91,11 +91,9 @@ const char *Ico_GetIcon (const char *IconWithoutExtension)
NumExt < Ico_NUM_ICON_EXTENSIONS;
NumExt++)
{
snprintf (IconWithExtension,sizeof (IconWithExtension),
"%s.%s",
snprintf (IconWithExtension,sizeof (IconWithExtension),"%s.%s",
IconWithoutExtension,Ico_IconExtensions[NumExt]);
snprintf (PathIcon,sizeof (PathIcon),
"%s/%s/%s",
snprintf (PathIcon,sizeof (PathIcon),"%s/%s/%s",
Cfg_PATH_ICON_SETS_PUBLIC,
Ico_IconSetId[Gbl.Prefs.IconSet],
IconWithExtension);
@ -131,8 +129,7 @@ void Ico_PutIconsToSelectIconSet (void)
"PREF_OFF");
Frm_StartForm (ActChgIco);
Par_PutHiddenParamString (NULL,"IconSet",Ico_IconSetId[IconSet]);
snprintf (Icon,sizeof (Icon),
"%s/%s/cog.svg",
snprintf (Icon,sizeof (Icon),"%s/%s/cog.svg",
Cfg_ICON_FOLDER_SETS,
Ico_IconSetId[IconSet]);
Ico_PutSettingIconLink (Icon,Ico_IconSetNames[IconSet]);
@ -162,8 +159,7 @@ void Ico_ChangeIconSet (void)
{
/***** Get param with icon set *****/
Gbl.Prefs.IconSet = Ico_GetParamIconSet ();
snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),
"%s/%s",
snprintf (Gbl.Prefs.URLIconSet,sizeof (Gbl.Prefs.URLIconSet),"%s/%s",
Cfg_URL_ICON_SETS_PUBLIC,
Ico_IconSetId[Gbl.Prefs.IconSet]);

View File

@ -754,15 +754,13 @@ static bool Inf_CheckPage (long CrsCod,Inf_InfoType_t InfoType)
/***** Open file with web page *****/
/* 1. Check if index.html exists */
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.html",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
return true;
/* 2. If index.html does not exist, try index.htm */
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.htm",
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.htm",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
return true;
@ -789,13 +787,11 @@ static bool Inf_CheckAndShowPage (void)
/***** Open file with web page *****/
/* 1. Check if index.html exists */
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.html",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
{
snprintf (URL,sizeof (URL),
"%s/%ld/%s/index.html",
snprintf (URL,sizeof (URL),"%s/%ld/%s/index.html",
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod,
Inf_FileNamesForInfoType[Gbl.Crs.Info.Type]);
Inf_ShowPage (URL);
@ -804,13 +800,11 @@ static bool Inf_CheckAndShowPage (void)
}
/* 2. If index.html does not exist, try index.htm */
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.htm",
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.htm",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
{
snprintf (URL,sizeof (URL),
"%s/%ld/%s/index.htm",
snprintf (URL,sizeof (URL),"%s/%ld/%s/index.htm",
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod,
Inf_FileNamesForInfoType[Gbl.Crs.Info.Type]);
Inf_ShowPage (URL);
@ -827,10 +821,8 @@ static bool Inf_CheckAndShowPage (void)
void Inf_BuildPathPage (long CrsCod,Inf_InfoType_t InfoType,char PathDir[PATH_MAX + 1])
{
snprintf (PathDir,PATH_MAX + 1,
"%s/%ld/%s",
Cfg_PATH_CRS_PUBLIC,CrsCod,
Inf_FileNamesForInfoType[InfoType]);
snprintf (PathDir,PATH_MAX + 1,"%s/%ld/%s",
Cfg_PATH_CRS_PUBLIC,CrsCod,Inf_FileNamesForInfoType[InfoType]);
}
/*****************************************************************************/
@ -899,10 +891,8 @@ static bool Inf_CheckAndShowURL (void)
static void Inf_BuildPathURL (long CrsCod,Inf_InfoType_t InfoType,
char PathFile[PATH_MAX + 1])
{
snprintf (PathFile,PATH_MAX + 1,
"%s/%ld/%s.url",
Cfg_PATH_CRS_PRIVATE,CrsCod,
Inf_FileNamesForInfoType[InfoType]);
snprintf (PathFile,PATH_MAX + 1,"%s/%ld/%s.url",
Cfg_PATH_CRS_PRIVATE,CrsCod,Inf_FileNamesForInfoType[InfoType]);
}
/*****************************************************************************/
@ -1669,13 +1659,11 @@ void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
/* Get text in HTML format (not rigorous) */
if (InfoTxtHTML)
Str_Copy (InfoTxtHTML,row[0],
Cns_MAX_BYTES_LONG_TEXT);
Str_Copy (InfoTxtHTML,row[0],Cns_MAX_BYTES_LONG_TEXT);
/* Get text in Markdown format */
if (InfoTxtMD)
Str_Copy (InfoTxtMD,row[1],
Cns_MAX_BYTES_LONG_TEXT);
Str_Copy (InfoTxtMD,row[1],Cns_MAX_BYTES_LONG_TEXT);
}
else
{
@ -1843,11 +1831,9 @@ static bool Inf_CheckAndShowRichTxt (void)
/***** Store text into a temporary .md file in HTML output directory *****/
// TODO: change to another directory?
/* Create a unique name for the .md file */
snprintf (PathFileMD,sizeof (PathFileMD),
"%s/%s.md",
snprintf (PathFileMD,sizeof (PathFileMD),"%s/%s.md",
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
snprintf (PathFileHTML,sizeof (PathFileHTML),
"%s/%s.md.html", // Do not use only .html because that is the output temporary file
snprintf (PathFileHTML,sizeof (PathFileHTML),"%s/%s.md.html", // Do not use only .html because that is the output temporary file
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
/* Open Markdown file for writing */
@ -1875,8 +1861,7 @@ static bool Inf_CheckAndShowRichTxt (void)
/* MathJax 3.0.1 */
#ifdef Cfg_MATHJAX_LOCAL
// Use the local copy of MathJax
snprintf (MathJaxURL,sizeof (MathJaxURL),
"=%s/mathjax/tex-chtml.js",
snprintf (MathJaxURL,sizeof (MathJaxURL),"=%s/mathjax/tex-chtml.js",
Cfg_URL_SWAD_PUBLIC);
#else
// Use the MathJax Content Delivery Network (CDN)
@ -2052,8 +2037,7 @@ void Inf_RecAndChangePlainTxtInfo (void)
/***** Get text with course information from form *****/
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT,NULL);
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT);
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,sizeof (Txt_MarkdownFormat) - 1);
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,
@ -2092,8 +2076,7 @@ void Inf_RecAndChangeRichTxtInfo (void)
/***** Get text with course information from form *****/
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT,NULL);
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT);
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,sizeof (Txt_MarkdownFormat) - 1);
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,
@ -2231,8 +2214,7 @@ void Inf_ReceivePagInfo (void)
{
Fil_RemoveTree (PathRelDirHTML);
Fil_CreateDirIfNotExists (PathRelDirHTML);
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),"%s/index.html",
PathRelDirHTML);
if (Fil_EndReceptionOfFile (PathRelFileHTML,Param))
{
@ -2246,8 +2228,7 @@ void Inf_ReceivePagInfo (void)
{
Fil_RemoveTree (PathRelDirHTML);
Fil_CreateDirIfNotExists (PathRelDirHTML);
snprintf (PathRelFileZIP,sizeof (PathRelFileZIP),
"%s/%s.zip",
snprintf (PathRelFileZIP,sizeof (PathRelFileZIP),"%s/%s.zip",
Gbl.Crs.PathPriv,
Inf_FileNamesForInfoType[Gbl.Crs.Info.Type]);
@ -2256,15 +2237,13 @@ void Inf_ReceivePagInfo (void)
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_received_successfully);
/* Uncompress ZIP */
snprintf (StrUnzip,sizeof (StrUnzip),
"unzip -qq -o %s -d %s",
snprintf (StrUnzip,sizeof (StrUnzip),"unzip -qq -o %s -d %s",
PathRelFileZIP,PathRelDirHTML);
if (system (StrUnzip) == 0)
{
/* Check if uploaded file is index.html or index.htm */
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
PathRelDirHTML);
"%s/index.html",PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML))
{
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully);
@ -2274,8 +2253,7 @@ void Inf_ReceivePagInfo (void)
else
{
snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.htm",
PathRelDirHTML);
"%s/index.htm",PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML))
{
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully);

View File

@ -646,8 +646,8 @@ void Ins_GetBasicListOfInstitutions (long CtyCod)
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
/***** Create list with institutions *****/
if ((Gbl.Hierarchy.Inss.Lst = (struct Ins_Instit *)
calloc (NumRows,sizeof (struct Ins_Instit))) == NULL)
if ((Gbl.Hierarchy.Inss.Lst = calloc (NumRows,
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the institutions *****/
@ -730,8 +730,8 @@ void Ins_GetFullListOfInstitutions (long CtyCod)
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
/***** Create list with institutions *****/
if ((Gbl.Hierarchy.Inss.Lst = (struct Ins_Instit *)
calloc (NumRows,sizeof (struct Ins_Instit))) == NULL)
if ((Gbl.Hierarchy.Inss.Lst = calloc (NumRows,
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the institutions *****/
@ -849,16 +849,13 @@ static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row)
Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]);
/***** Get the short name of the institution (row[4]) *****/
Str_Copy (Ins->ShrtName,row[4],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Str_Copy (Ins->ShrtName,row[4],sizeof (Ins->ShrtName) - 1);
/***** Get the full name of the institution (row[5]) *****/
Str_Copy (Ins->FullName,row[5],
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
Str_Copy (Ins->FullName,row[5],sizeof (Ins->FullName) - 1);
/***** Get the URL of the institution (row[6]) *****/
Str_Copy (Ins->WWW,row[6],
Cns_MAX_BYTES_WWW);
Str_Copy (Ins->WWW ,row[6],sizeof (Ins->WWW ) - 1);
}
/*****************************************************************************/
@ -887,7 +884,7 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins)
if (Ins->InsCod == Gbl.Cache.InstitutionShrtName.InsCod)
{
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
sizeof (Ins->ShrtName) - 1);
return;
}
@ -904,7 +901,7 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins)
row = mysql_fetch_row (mysql_res);
Str_Copy (Gbl.Cache.InstitutionShrtName.ShrtName,row[0],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
sizeof (Gbl.Cache.InstitutionShrtName.ShrtName) - 1);
}
else
Gbl.Cache.InstitutionShrtName.ShrtName[0] = '\0';
@ -913,7 +910,7 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins)
DB_FreeMySQLResult (&mysql_res);
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
sizeof (Ins->ShrtName) - 1);
}
/*****************************************************************************/
@ -946,7 +943,7 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins,
if (Ins->InsCod == Gbl.Cache.InstitutionShrtNameAndCty.InsCod)
{
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
sizeof (Ins->ShrtName) - 1);
Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName,
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
return;
@ -968,11 +965,11 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins,
/* Get the short name of this institution (row[0]) */
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,row[0],
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
sizeof (Gbl.Cache.InstitutionShrtNameAndCty.ShrtName) - 1);
/* Get the name of the country (row[1]) */
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.CtyName,row[1],
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
sizeof (Gbl.Cache.InstitutionShrtNameAndCty.CtyName) - 1);
}
else
{
@ -984,7 +981,7 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins,
DB_FreeMySQLResult (&mysql_res);
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
sizeof (Ins->ShrtName) - 1);
Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName,
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
}
@ -1176,8 +1173,7 @@ static void Ins_ListInstitutionsForEdition (void)
}
else
{
Str_Copy (WWW,Ins->WWW,
Cns_MAX_BYTES_WWW);
Str_Copy (WWW,Ins->WWW,sizeof (WWW) - 1);
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\"",
Ins->WWW,Ins->WWW);
@ -1393,11 +1389,10 @@ void Ins_RemoveInstitution (void)
Brw_RemoveInsFilesFromDB (Ins_EditingIns->InsCod);
/***** Remove directories of the institution *****/
snprintf (PathIns,sizeof (PathIns),
"%s/%02u/%u",
snprintf (PathIns,sizeof (PathIns),"%s/%02u/%u",
Cfg_PATH_INS_PUBLIC,
(unsigned) (Ins_EditingIns->InsCod % 100),
(unsigned) Ins_EditingIns->InsCod);
(unsigned) Ins_EditingIns->InsCod);
Fil_RemoveTree (PathIns);
/***** Remove institution *****/
@ -1508,8 +1503,7 @@ void Ins_RenameInstitution (struct Ins_Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFu
CurrentInsName,NewInsName);
/* Change current institution name in order to display it properly */
Str_Copy (CurrentInsName,NewInsName,
MaxBytes);
Str_Copy (CurrentInsName,NewInsName,MaxBytes);
}
}
else // The same name
@ -1581,8 +1575,7 @@ void Ins_ChangeInsWWW (void)
{
/***** Update database changing old WWW by new WWW *****/
Ins_UpdateInsWWWDB (Ins_EditingIns->InsCod,NewWWW);
Str_Copy (Ins_EditingIns->WWW,NewWWW,
Cns_MAX_BYTES_WWW);
Str_Copy (Ins_EditingIns->WWW,NewWWW,sizeof (Ins_EditingIns->WWW) - 1);
/***** Write message to show the change made
and put button to go to institution changed *****/
@ -2178,8 +2171,8 @@ static void Ins_EditingInstitutionConstructor (void)
Lay_ShowErrorAndExit ("Error initializing institution.");
/***** Allocate memory for institution *****/
if ((Ins_EditingIns = (struct Ins_Instit *) malloc (sizeof (struct Ins_Instit))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for institution.");
if ((Ins_EditingIns = malloc (sizeof (*Ins_EditingIns))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset institution *****/
Ins_EditingIns->InsCod = -1L;

View File

@ -663,8 +663,7 @@ void InsCfg_ChangeInsWWW (void)
{
/***** Update database changing old WWW by new WWW *****/
Ins_UpdateInsWWWDB (Gbl.Hierarchy.Ins.InsCod,NewWWW);
Str_Copy (Gbl.Hierarchy.Ins.WWW,NewWWW,
Cns_MAX_BYTES_WWW);
Str_Copy (Gbl.Hierarchy.Ins.WWW,NewWWW,sizeof (Gbl.Hierarchy.Ins.WWW) - 1);
/***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,

View File

@ -909,7 +909,7 @@ static void Lay_WriteScriptParamsAJAX (void)
HTM_TxtF ("var RefreshParamNxtActOldPub = \"act=%ld\";\n"
"var RefreshParamUsr = \"OtherUsrCod=%s\";\n",
Act_GetActCod (ActRefOldTL_PubUsr),
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
/* Parameters related with match refreshing (for students) */
case ActJoiMch:

View File

@ -303,7 +303,7 @@ void Lnk_GetListLinks (void)
Gbl.Links.Num = (unsigned) NumRows;
/***** Create list with places *****/
if ((Gbl.Links.Lst = (struct Link *) calloc (NumRows,sizeof (struct Link))) == NULL)
if ((Gbl.Links.Lst = calloc (NumRows,sizeof (*Gbl.Links.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the links *****/
@ -320,17 +320,11 @@ void Lnk_GetListLinks (void)
if ((Lnk->LnkCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of institutional link.");
/* Get the short name of the link (row[1]) */
Str_Copy (Lnk->ShrtName,row[1],
Lnk_MAX_BYTES_LINK_SHRT_NAME);
/* Get the full name of the link (row[2]) */
Str_Copy (Lnk->FullName,row[2],
Lnk_MAX_BYTES_LINK_FULL_NAME);
/* Get the URL of the link (row[3]) */
Str_Copy (Lnk->WWW,row[3],
Cns_MAX_BYTES_WWW);
/* Get the short name (row[0]), the full name (row[1])
and de URL (row[2]) of the link */
Str_Copy (Lnk->ShrtName,row[1],sizeof (Lnk->ShrtName) - 1);
Str_Copy (Lnk->FullName,row[2],sizeof (Lnk->FullName) - 1);
Str_Copy (Lnk->WWW ,row[3],sizeof (Lnk->WWW ) - 1);
}
}
else
@ -369,17 +363,11 @@ void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
/* Get row */
row = mysql_fetch_row (mysql_res);
/* Get the short name of the link (row[0]) */
Str_Copy (Lnk->ShrtName,row[0],
Lnk_MAX_BYTES_LINK_SHRT_NAME);
/* Get the full name of the link (row[1]) */
Str_Copy (Lnk->FullName,row[1],
Lnk_MAX_BYTES_LINK_FULL_NAME);
/* Get the URL of the link (row[2]) */
Str_Copy (Lnk->WWW,row[2],
Cns_MAX_BYTES_WWW);
/* Get the short name (row[0]), the full name (row[1])
and de URL (row[2]) of the link */
Str_Copy (Lnk->ShrtName,row[0],sizeof (Lnk->ShrtName) - 1);
Str_Copy (Lnk->FullName,row[1],sizeof (Lnk->FullName) - 1);
Str_Copy (Lnk->WWW ,row[2],sizeof (Lnk->WWW ) - 1);
}
/***** Free structure that stores the query result *****/
@ -622,8 +610,7 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update name *****/
Str_Copy (CurrentLnkName,NewLnkName,
MaxBytes);
Str_Copy (CurrentLnkName,NewLnkName,MaxBytes);
}
/*****************************************************************************/
@ -692,8 +679,7 @@ void Lnk_ChangeLinkWWW (void)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update web *****/
Str_Copy (Lnk_EditingLnk->WWW,NewWWW,
Cns_MAX_BYTES_WWW);
Str_Copy (Lnk_EditingLnk->WWW,NewWWW,sizeof (Lnk_EditingLnk->WWW) - 1);
}
/*****************************************************************************/
@ -870,8 +856,8 @@ static void Lnk_EditingLinkConstructor (void)
Lay_ShowErrorAndExit ("Error initializing link.");
/***** Allocate memory for link *****/
if ((Lnk_EditingLnk = (struct Link *) malloc (sizeof (struct Link))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for link.");
if ((Lnk_EditingLnk = malloc (sizeof (*Lnk_EditingLnk))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset link *****/
Lnk_EditingLnk->LnkCod = -1L;

View File

@ -132,10 +132,9 @@ void Log_LogAccess (const char *Comments)
if (Comments)
{
MaxLength = strlen (Comments) * Str_MAX_BYTES_PER_CHAR;
if ((CommentsDB = (char *) malloc (MaxLength + 1)) != NULL)
if ((CommentsDB = malloc (MaxLength + 1)) != NULL)
{
Str_Copy (CommentsDB,Comments,
MaxLength);
Str_Copy (CommentsDB,Comments,MaxLength);
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_TEXT,
CommentsDB,MaxLength,true); // Avoid SQL injection
DB_QueryINSERT ("can not log access (comments)",

View File

@ -106,12 +106,11 @@ void Lgo_DrawLogo (Hie_Lvl_Level_t Scope,long Cod,const char *AltText,
{
Folder = Cfg_FOLDER_DEG;
DegCod = Cod;
snprintf (PathLogo,sizeof (PathLogo),
"%s/%02u/%u/logo/%u.png",
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",
Cfg_PATH_DEG_PUBLIC,
(unsigned) (DegCod % 100),
(unsigned) DegCod,
(unsigned) DegCod);
(unsigned) DegCod,
(unsigned) DegCod);
LogoFound = Fil_CheckIfPathExists (PathLogo);
if (LogoFound)
Cod = DegCod;
@ -125,12 +124,11 @@ void Lgo_DrawLogo (Hie_Lvl_Level_t Scope,long Cod,const char *AltText,
CtrCod = Deg_GetCtrCodOfDegreeByCod (Cod);
else
CtrCod = Cod;
snprintf (PathLogo,sizeof (PathLogo),
"%s/%02u/%u/logo/%u.png",
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",
Cfg_PATH_CTR_PUBLIC,
(unsigned) (CtrCod % 100),
(unsigned) CtrCod,
(unsigned) CtrCod);
(unsigned) CtrCod,
(unsigned) CtrCod);
LogoFound = Fil_CheckIfPathExists (PathLogo);
if (LogoFound)
Cod = CtrCod;
@ -146,12 +144,11 @@ void Lgo_DrawLogo (Hie_Lvl_Level_t Scope,long Cod,const char *AltText,
InsCod = Ctr_GetInsCodOfCentreByCod (Cod);
else
InsCod = Cod;
snprintf (PathLogo,sizeof (PathLogo),
"%s/%02u/%u/logo/%u.png",
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",
Cfg_PATH_INS_PUBLIC,
(unsigned) (InsCod % 100),
(unsigned) InsCod,
(unsigned) InsCod);
(unsigned) InsCod,
(unsigned) InsCod);
LogoFound = Fil_CheckIfPathExists (PathLogo);
if (LogoFound)
Cod = InsCod;
@ -233,12 +230,11 @@ void Lgo_PutIconToChangeLogo (Hie_Lvl_Level_t Scope)
}
/***** Check if logo exists *****/
snprintf (PathLogo,sizeof (PathLogo),
"%s/%s/%02u/%u/logo/%u.png",
snprintf (PathLogo,sizeof (PathLogo),"%s/%s/%02u/%u/logo/%u.png",
Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) (Cod % 100),
(unsigned) Cod,
(unsigned) Cod);
(unsigned) Cod,
(unsigned) Cod);
LogoExists = Fil_CheckIfPathExists (PathLogo);
/***** Link for changing / uploading the logo *****/
@ -291,12 +287,11 @@ void Lgo_RequestLogo (Hie_Lvl_Level_t Scope)
}
/***** Check if logo exists *****/
snprintf (PathLogo,sizeof (PathLogo),
"%s/%s/%02u/%u/logo/%u.png",
snprintf (PathLogo,sizeof (PathLogo),"%s/%s/%02u/%u/logo/%u.png",
Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) (Cod % 100),
(unsigned) Cod,
(unsigned) Cod);
(unsigned) Cod,
(unsigned) Cod);
if (!Fil_CheckIfPathExists (PathLogo))
FunctionToDrawContextualIcons = NULL;
@ -393,26 +388,18 @@ void Lgo_ReceiveLogo (Hie_Lvl_Level_t Scope)
}
/***** Creates directories if not exist *****/
snprintf (Path,sizeof (Path),
"%s/%s",
Cfg_PATH_SWAD_PUBLIC,Folder);
snprintf (Path,sizeof (Path),"%s/%s",Cfg_PATH_SWAD_PUBLIC,Folder);
Fil_CreateDirIfNotExists (Path);
snprintf (Path,sizeof (Path),
"%s/%s/%02u",
Cfg_PATH_SWAD_PUBLIC,Folder,
snprintf (Path,sizeof (Path),"%s/%s/%02u",Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) (Cod % 100));
Fil_CreateDirIfNotExists (Path);
snprintf (Path,sizeof (Path),
"%s/%s/%02u/%u",
Cfg_PATH_SWAD_PUBLIC,Folder,
snprintf (Path,sizeof (Path),"%s/%s/%02u/%u",Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) (Cod % 100),
(unsigned) Cod);
(unsigned) Cod);
Fil_CreateDirIfNotExists (Path);
snprintf (Path,sizeof (Path),
"%s/%s/%02u/%u/logo",
Cfg_PATH_SWAD_PUBLIC,Folder,
snprintf (Path,sizeof (Path),"%s/%s/%02u/%u/logo",Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) (Cod % 100),
(unsigned) Cod);
(unsigned) Cod);
Fil_CreateDirIfNotExists (Path);
/***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/
@ -432,12 +419,11 @@ void Lgo_ReceiveLogo (Hie_Lvl_Level_t Scope)
else
{
/* End the reception of logo in a temporary file */
snprintf (FileNameLogo,sizeof (FileNameLogo),
"%s/%s/%02u/%u/logo/%u.png",
snprintf (FileNameLogo,sizeof (FileNameLogo),"%s/%s/%02u/%u/logo/%u.png",
Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) (Cod % 100),
(unsigned) Cod,
(unsigned) Cod);
(unsigned) Cod,
(unsigned) Cod);
if (!Fil_EndReceptionOfFile (FileNameLogo,Param))
Ale_ShowAlert (Ale_ERROR,"Error copying file.");
}
@ -473,11 +459,10 @@ void Lgo_RemoveLogo (Hie_Lvl_Level_t Scope)
}
/***** Remove logo *****/
snprintf (FileNameLogo,sizeof (FileNameLogo),
"%s/%s/%02u/%u/logo/%u.png",
snprintf (FileNameLogo,sizeof (FileNameLogo),"%s/%s/%02u/%u/logo/%u.png",
Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) (Cod % 100),
(unsigned) Cod,
(unsigned) Cod);
(unsigned) Cod,
(unsigned) Cod);
Fil_RemoveTree (FileNameLogo);
}

View File

@ -301,7 +301,7 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
Gbl.Mails.Num = (unsigned) NumRows;
/***** Create list with places *****/
if ((Gbl.Mails.Lst = (struct Mail *) calloc (NumRows,sizeof (struct Mail))) == NULL)
if ((Gbl.Mails.Lst = calloc (NumRows,sizeof (*Gbl.Mails.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the mail domains *****/
@ -318,13 +318,9 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
if ((Mai->MaiCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of mail domain.");
/* Get the mail domain (row[1]) */
Str_Copy (Mai->Domain,row[1],
Cns_MAX_BYTES_EMAIL_ADDRESS);
/* Get the mail domain info (row[2]) */
Str_Copy (Mai->Info,row[2],
Mai_MAX_BYTES_MAIL_INFO);
/* Get the mail domain (row[1]) and the mail domain info (row[2]) */
Str_Copy (Mai->Domain,row[1],sizeof (Mai->Domain) - 1);
Str_Copy (Mai->Info ,row[2],sizeof (Mai->Info ) - 1);
/* Get number of users (row[3]) */
if (sscanf (row[3],"%u",&(Mai->NumUsrs)) != 1)
@ -374,8 +370,7 @@ static void Mai_GetMailDomain (const char *Email,char MailDomain[Cns_MAX_BYTES_E
{
Ptr++; // Skip '@'
if (strchr (Ptr,(int) '@') == NULL) // No more '@' found
Str_Copy (MailDomain,Ptr,
Cns_MAX_BYTES_EMAIL_ADDRESS);
Str_Copy (MailDomain,Ptr,Cns_MAX_BYTES_EMAIL_ADDRESS);
}
}
@ -442,13 +437,9 @@ void Mai_GetDataOfMailDomainByCod (struct Mail *Mai)
/* Get row */
row = mysql_fetch_row (mysql_res);
/* Get the short name of the mail (row[0]) */
Str_Copy (Mai->Domain,row[0],
Cns_MAX_BYTES_EMAIL_ADDRESS);
/* Get the full name of the mail (row[1]) */
Str_Copy (Mai->Info,row[1],
Mai_MAX_BYTES_MAIL_INFO);
/* Get the short & full name of the mail (row[0], row[1]) */
Str_Copy (Mai->Domain,row[0],sizeof (Mai->Domain) - 1);
Str_Copy (Mai->Info ,row[1],sizeof (Mai->Info ) - 1);
}
/***** Free structure that stores the query result *****/
@ -691,8 +682,7 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update name *****/
Str_Copy (CurrentMaiName,NewMaiName,
MaxBytes);
Str_Copy (CurrentMaiName,NewMaiName,MaxBytes);
}
/*****************************************************************************/
@ -944,7 +934,7 @@ static void Mai_ListEmails (__attribute__((unused)) void *Args)
while (*Ptr)
{
/* Get next user */
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
@ -966,14 +956,12 @@ static void Mai_ListEmails (__attribute__((unused)) void *Args)
LengthStrAddr ++;
if (LengthStrAddr > Mai_MAX_BYTES_STR_ADDR)
Lay_ShowErrorAndExit ("The space allocated to store email addresses is full.");
Str_Concat (StrAddresses,",",
Mai_MAX_BYTES_STR_ADDR);
Str_Concat (StrAddresses,",",sizeof (StrAddresses) - 1);
}
LengthStrAddr += strlen (UsrDat.Email);
if (LengthStrAddr > Mai_MAX_BYTES_STR_ADDR)
Lay_ShowErrorAndExit ("The space allocated to store email addresses is full.");
Str_Concat (StrAddresses,UsrDat.Email,
Mai_MAX_BYTES_STR_ADDR);
Str_Concat (StrAddresses,UsrDat.Email,sizeof (StrAddresses) - 1);
HTM_A_Begin ("href=\"mailto:%s?subject=%s\"",
UsrDat.Email,Gbl.Hierarchy.Crs.FullName);
HTM_Txt (UsrDat.Email);
@ -1099,8 +1087,7 @@ bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat)
{
/* Get email */
row = mysql_fetch_row (mysql_res);
Str_Copy (UsrDat->Email,row[0],
Cns_MAX_BYTES_EMAIL_ADDRESS);
Str_Copy (UsrDat->Email,row[0],sizeof (UsrDat->Email) - 1);
UsrDat->EmailConfirmed = (row[1][0] == 'Y');
Found = true;
}
@ -1169,9 +1156,7 @@ void Mai_ShowFormChangeMyEmail (bool IMustFillInEmail,bool IShouldConfirmEmail)
HTM_SECTION_Begin (Mai_EMAIL_SECTION_ID);
/***** Begin box *****/
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
Box_BoxBegin (StrRecordWidth,Txt_Email,
Acc_PutLinkToRemoveMyAccount,NULL,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
@ -1202,9 +1187,7 @@ void Mai_ShowFormChangeOtherUsrEmail (void)
HTM_SECTION_Begin (Mai_EMAIL_SECTION_ID);
/***** Begin box *****/
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
Box_BoxBegin (StrRecordWidth,Txt_Email,
NULL,NULL,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
@ -1359,7 +1342,7 @@ static void Mai_ShowFormChangeUsrEmail (bool ItsMe,
break;
}
Frm_StartFormAnchor (NextAction,Mai_EMAIL_SECTION_ID);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
}
Par_PutHiddenParamString (NULL,"NewEmail",row[0]);
Btn_PutConfirmButtonInline ((ItsMe && NumEmail == 1) ? Txt_Confirm_email :
@ -1405,7 +1388,7 @@ static void Mai_ShowFormChangeUsrEmail (bool ItsMe,
break;
}
Frm_StartFormAnchor (NextAction,Mai_EMAIL_SECTION_ID);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
}
HTM_INPUT_EMAIL ("NewEmail",Cns_MAX_CHARS_EMAIL_ADDRESS,Gbl.Usrs.Me.UsrDat.Email,
"id=\"NewEmail\" size=\"18\"");
@ -1431,7 +1414,7 @@ static void Mai_PutParamsRemoveOtherEmail (void *Email)
{
if (Email)
{
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
Par_PutHiddenParamString (NULL,"Email",Email);
}
}
@ -1792,8 +1775,7 @@ void Mai_ConfirmEmail (void)
UsrCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get user's email */
Str_Copy (Email,row[1],
Cns_MAX_BYTES_EMAIL_ADDRESS);
Str_Copy (Email,row[1],sizeof (Email) - 1);
KeyIsCorrect = true;
}
@ -1861,8 +1843,7 @@ void Mai_ConfirmEmail (void)
void Mai_CreateFileNameMail (char FileNameMail[PATH_MAX + 1],FILE **FileMail)
{
snprintf (FileNameMail,PATH_MAX + 1,
"%s/%s_mail.txt",
snprintf (FileNameMail,PATH_MAX + 1,"%s/%s_mail.txt",
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
if ((*FileMail = fopen (FileNameMail,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not open file to send email.");
@ -1879,7 +1860,7 @@ void Mai_WriteWelcomeNoteEMail (FILE *FileMail,struct UsrData *UsrDat)
fprintf (FileMail,"%s %s:\n",
Txt_Dear_NO_HTML[UsrDat->Sex][UsrDat->Prefs.Language],
UsrDat->FirstName[0] ? UsrDat->FirstName :
UsrDat->FrstName[0] ? UsrDat->FrstName :
Txt_user_NO_HTML[UsrDat->Sex][UsrDat->Prefs.Language]);
}
@ -1958,8 +1939,8 @@ static void Mai_EditingMailDomainConstructor (void)
Lay_ShowErrorAndExit ("Error initializing mail domain.");
/***** Allocate memory for mail domain *****/
if ((Mai_EditingMai = (struct Mail *) malloc (sizeof (struct Mail))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for mail domain.");
if ((Mai_EditingMai = malloc (sizeof (*Mai_EditingMai))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset place *****/
Mai_EditingMai->MaiCod = -1L;

View File

@ -130,9 +130,7 @@ void Mrk_GetAndWriteNumRowsHeaderAndFooter (void)
Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
HTM_LABEL_Begin (NULL);
HTM_TxtF ("&nbsp;%s: ",Txt_TABLE_Header);
snprintf (StrHeadOrFoot,sizeof (StrHeadOrFoot),
"%u",
Marks.Header);
snprintf (StrHeadOrFoot,sizeof (StrHeadOrFoot),"%u",Marks.Header);
HTM_INPUT_TEXT (Mrk_HeadOrFootStr[Brw_HEADER],Cns_MAX_DECIMAL_DIGITS_UINT,StrHeadOrFoot,
HTM_SUBMIT_ON_CHANGE,
"size=\"1\" class=\"LST_EDIT_ROWS COLOR%u\"",
@ -150,9 +148,7 @@ void Mrk_GetAndWriteNumRowsHeaderAndFooter (void)
Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk);
HTM_LABEL_Begin (NULL);
HTM_TxtF ("&nbsp;%s: ",Txt_TABLE_Footer);
snprintf (StrHeadOrFoot,sizeof (StrHeadOrFoot),
"%u",
Marks.Footer);
snprintf (StrHeadOrFoot,sizeof (StrHeadOrFoot),"%u",Marks.Footer);
HTM_INPUT_TEXT (Mrk_HeadOrFootStr[Brw_FOOTER],Cns_MAX_DECIMAL_DIGITS_UINT,StrHeadOrFoot,
HTM_SUBMIT_ON_CHANGE,
"size=\"1\" class=\"LST_EDIT_ROWS COLOR%u\"",
@ -599,8 +595,7 @@ void Mrk_ShowMyMarks (void)
/***** Get the path of the file of marks *****/
Brw_SetFullPathInTree ();
snprintf (PathPrivate,sizeof (PathPrivate),
"%s/%s",
snprintf (PathPrivate,sizeof (PathPrivate),"%s/%s",
Gbl.FileBrowser.Priv.PathAboveRootFolder,
Gbl.FileBrowser.FilFolLnk.Full);
@ -646,8 +641,7 @@ void Mrk_ShowMyMarks (void)
Fil_CreateDirIfNotExists (Cfg_PATH_MARK_PRIVATE);
/* Create a new temporary file *****/
snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),
"%s/%s.html",
snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),"%s/%s.html",
Cfg_PATH_MARK_PRIVATE,Gbl.UniqueNameEncrypted);
if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not open file for my marks.");
@ -752,12 +746,11 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
/* Path (row[2]) */
Str_Copy (FullPathInTreeFromDBMarksTable,row[2],
PATH_MAX);
sizeof (FullPathInTreeFromDBMarksTable) - 1);
Str_SplitFullPathIntoPathAndFileName (FullPathInTreeFromDBMarksTable,
PathUntilFileName,
FileName);
Str_Copy (SummaryStr,FileName,
Cns_MAX_BYTES_TEXT);
Str_Copy (SummaryStr,FileName,Cns_MAX_BYTES_TEXT);
if (GetContent)
{
@ -772,13 +765,11 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
if (UsrDat.IDs.Num)
{
if (GrpCod > 0)
snprintf (PathMarks,sizeof (PathMarks),
"%s/%ld/grp/%ld/%s",
snprintf (PathMarks,sizeof (PathMarks),"%s/%ld/grp/%ld/%s",
Cfg_PATH_CRS_PRIVATE,CrsCod,GrpCod,
FullPathInTreeFromDBMarksTable);
else
snprintf (PathMarks,sizeof (PathMarks),
"%s/%ld/%s",
snprintf (PathMarks,sizeof (PathMarks),"%s/%ld/%s",
Cfg_PATH_CRS_PRIVATE,CrsCod,
FullPathInTreeFromDBMarksTable);
@ -787,8 +778,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
Fil_CreateDirIfNotExists (Cfg_PATH_MARK_PRIVATE);
/* Create a new temporary file *****/
snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),
"%s/%s.html",
snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),"%s/%s.html",
Cfg_PATH_MARK_PRIVATE,Gbl.UniqueNameEncrypted);
if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")))
{
@ -799,11 +789,10 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
fclose (FileUsrMarks);
Length = 9 + SizeOfMyMarks + 3;
if ((*ContentStr = (char *) malloc (Length + 1)))
if ((*ContentStr = malloc (Length + 1)))
{
/* 9 starting chars */
Str_Copy (*ContentStr,"<![CDATA[",
9);
Str_Copy (*ContentStr,"<![CDATA[",9);
/* Content */
Ptr = (*ContentStr) + 9;
@ -817,8 +806,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
}
/* 3 ending chars */
Str_Copy (Ptr,"]]>",
3);
Str_Copy (Ptr,"]]>",3);
}
}
else

View File

@ -29,7 +29,6 @@
#include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include "swad_database.h"
@ -1022,8 +1021,7 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
/* Get the title of the match (row[5]) */
if (row[5])
Str_Copy (Match->Title,row[5],
Mch_MAX_BYTES_TITLE);
Str_Copy (Match->Title,row[5],sizeof (Match->Title) - 1);
else
Match->Title[0] = '\0';
@ -1878,15 +1876,12 @@ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd,
if ((LongNum = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong answer index.");
AnsInd = (unsigned) LongNum;
snprintf (StrOneAnswer,sizeof (StrOneAnswer),
"%u",AnsInd);
snprintf (StrOneAnswer,sizeof (StrOneAnswer),"%u",AnsInd);
/* Concatenate answer index to list of answers */
if (NumAns)
Str_Concat (StrAnswersOneQst,",",
Tst_MAX_BYTES_ANSWERS_ONE_QST);
Str_Concat (StrAnswersOneQst,StrOneAnswer,
Tst_MAX_BYTES_ANSWERS_ONE_QST);
Str_Concat (StrAnswersOneQst,",",sizeof (StrAnswersOneQst) - 1);
Str_Concat (StrAnswersOneQst,StrOneAnswer,sizeof (StrAnswersOneQst) - 1);
}
/***** Free structure that stores the query result *****/
@ -1922,8 +1917,7 @@ void Mch_GetIndexes (long MchCod,unsigned QstInd,
row = mysql_fetch_row (mysql_res);
/* Get indexes (row[0]) */
Str_Copy (StrIndexesOneQst,row[0],
Tst_MAX_BYTES_INDEXES_ONE_QST);
Str_Copy (StrIndexesOneQst,row[0],sizeof (StrIndexesOneQst) - 1);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
@ -4283,14 +4277,15 @@ void Mch_GetMatchQuestionsFromDB (struct MchPrn_Print *Print)
/* Get indexes for this question (row[2]) */
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[2],
Tst_MAX_BYTES_INDEXES_ONE_QST);
sizeof (Print->PrintedQuestions[NumQst].StrIndexes) - 1);
/* Get answers selected by user for this question */
Mch_GetQstAnsFromDB (Print->MchCod,Print->UsrCod,QstInd,&UsrAnswer);
if (UsrAnswer.AnsInd >= 0) // UsrAnswer.AnsInd >= 0 ==> answer selected
{
snprintf (Print->PrintedQuestions[NumQst].StrAnswers,Tst_MAX_BYTES_ANSWERS_ONE_QST + 1,
"%d",UsrAnswer.AnsInd);
snprintf (Print->PrintedQuestions[NumQst].StrAnswers,
sizeof (Print->PrintedQuestions[NumQst].StrAnswers),
"%d",UsrAnswer.AnsInd);
Print->NumQsts.NotBlank++;
}
else // UsrAnswer.AnsInd < 0 ==> no answer selected

View File

@ -29,7 +29,6 @@
#include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include "swad_action.h"
@ -308,7 +307,7 @@ static void MchRes_ListAllMchResultsInSelectedGames (struct Gam_Games *Games)
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
@ -735,7 +734,7 @@ static void MchRes_BuildGamesSelectedCommas (struct Gam_Games *Games,
/***** Allocate memory for subquery of games selected *****/
MaxLength = (size_t) Games->NumSelected * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
if ((*GamesSelectedCommas = (char *) malloc (MaxLength + 1)) == NULL)
if ((*GamesSelectedCommas = malloc (MaxLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Build subquery with list of selected games *****/
@ -1018,7 +1017,7 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games,
case Usr_OTHER:
Frm_StartForm (ActSeeOneMchResOth);
Mch_PutParamsEdit (Games);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
}
Ico_PutIconLink ("tasks.svg",Txt_Result);
@ -1233,8 +1232,8 @@ void MchRes_ShowOneMchResult (void)
HTM_TxtF ("&nbsp;%s",UsrDat->Surname1);
if (UsrDat->Surname2[0])
HTM_TxtF ("&nbsp;%s",UsrDat->Surname2);
if (UsrDat->FirstName[0])
HTM_TxtF (", %s",UsrDat->FirstName);
if (UsrDat->FrstName[0])
HTM_TxtF (", %s",UsrDat->FrstName);
HTM_BR ();
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :

View File

@ -292,8 +292,7 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
Med_STATUS_NONE;
/***** Copy media name (row[1]) to struct *****/
Str_Copy (Media->Name,row[1],
Med_BYTES_NAME);
Str_Copy (Media->Name,row[1],sizeof (Media->Name) - 1);
/***** Copy media URL (row[2]) to struct *****/
// Media->URL can be empty or filled with previous value
@ -306,10 +305,9 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
if (Length > Cns_MAX_BYTES_WWW)
Length = Cns_MAX_BYTES_WWW;
if ((Media->URL = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for media URL.");
Str_Copy (Media->URL,row[2],
Length);
if ((Media->URL = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (Media->URL,row[2],Length);
}
/***** Copy media title (row[3]) to struct *****/
@ -323,10 +321,9 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
if (Length > Med_MAX_BYTES_TITLE)
Length = Med_MAX_BYTES_TITLE;
if ((Media->Title = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for media title.");
Str_Copy (Media->Title,row[3],
Length);
if ((Media->Title = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (Media->Title,row[3],Length);
}
}
else
@ -340,7 +337,7 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
/********* Draw input fields to upload an image/video inside a form **********/
/*****************************************************************************/
void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput)
void Med_PutMediaUploader (int NumMedia,const char *ClassInput)
{
extern const char *Hlp_Multimedia;
extern const char *Txt_Multimedia;
@ -380,7 +377,7 @@ void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput)
};
/***** Set names of parameters depending on number of media in form *****/
Med_SetParamNames (&ParamUploadMedia,NumMediaInForm);
Med_SetParamNames (&ParamUploadMedia,NumMedia);
/***** Create unique id for this media uploader *****/
Frm_SetUniqueId (Id);
@ -507,11 +504,11 @@ static void Med_PutHiddenFormTypeMediaUploader (const char UniqueId[Frm_MAX_BYTE
/******************** Get media (image/video) from form **********************/
/*****************************************************************************/
// Media constructor must be called before calling this function
// If NumMediaInForm < 0, params have no suffix
// If NumMediaInForm >= 0, the number is a suffix of the params
// If NumMedia < 0, params have no suffix
// If NumMedia >= 0, the number is a suffix of the params
void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media,
void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media),
void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMedia,struct Med_Media *Media,
void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMedia,struct Med_Media *Media),
const char *SectionForAlerts)
{
extern const char *Txt_Error_sending_or_processing_image_video;
@ -520,7 +517,7 @@ void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med
Med_FormType_t FormType;
/***** Set names of parameters depending on number of media in form *****/
Med_SetParamNames (&ParamUploadMedia,NumMediaInForm);
Med_SetParamNames (&ParamUploadMedia,NumMedia);
/***** Get action and initialize media (image/video)
(except title, that will be get after the media file) *****/
@ -584,7 +581,7 @@ void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med
/***** Get media name *****/
if (GetMediaFromDB != NULL)
GetMediaFromDB (CrsCod,QstCod,NumMediaInForm,Media);
GetMediaFromDB (CrsCod,QstCod,NumMedia,Media);
break;
default: // Unknown action
Media->Action = Med_ACTION_NO_MEDIA;
@ -595,41 +592,26 @@ void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med
/*****************************************************************************/
/********* Set parameters names depending on number of media in form *********/
/*****************************************************************************/
// If NumMediaInForm < 0, params have no suffix
// If NumMediaInForm >= 0, the number is a suffix of the params
// If NumMedia < 0, params have no suffix
// If NumMedia >= 0, the number is a suffix of the params
void Med_SetParamNames (struct ParamUploadMedia *ParamUploadMedia,int NumMediaInForm)
void Med_SetParamNames (struct ParamUploadMedia *ParamUpl,int NumMedia)
{
if (NumMediaInForm < 0) // One unique media in form ==> no suffix needed
if (NumMedia < 0) // One unique media in form ==> no suffix needed
{
Str_Copy (ParamUploadMedia->Action ,"MedAct",
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
Str_Copy (ParamUploadMedia->FormType,"MedFrm",
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
Str_Copy (ParamUploadMedia->File ,"MedFil",
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
Str_Copy (ParamUploadMedia->Title ,"MedTit",
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
Str_Copy (ParamUploadMedia->URL ,"MedURL",
Med_MAX_BYTES_PARAM_UPLOAD_MEDIA);
Str_Copy (ParamUpl->Action ,"MedAct",sizeof (ParamUpl->Action ) - 1);
Str_Copy (ParamUpl->FormType,"MedFrm",sizeof (ParamUpl->FormType) - 1);
Str_Copy (ParamUpl->File ,"MedFil",sizeof (ParamUpl->File ) - 1);
Str_Copy (ParamUpl->Title ,"MedTit",sizeof (ParamUpl->Title ) - 1);
Str_Copy (ParamUpl->URL ,"MedURL",sizeof (ParamUpl->URL ) - 1);
}
else // Several video/images in form ==> add suffix
{
snprintf (ParamUploadMedia->Action ,sizeof (ParamUploadMedia->Action),
"MedAct%u",
NumMediaInForm);
snprintf (ParamUploadMedia->FormType,sizeof (ParamUploadMedia->Action),
"MedFrm%u",
NumMediaInForm);
snprintf (ParamUploadMedia->File ,sizeof (ParamUploadMedia->File),
"MedFil%u",
NumMediaInForm);
snprintf (ParamUploadMedia->Title ,sizeof (ParamUploadMedia->Title),
"MedTit%u",
NumMediaInForm);
snprintf (ParamUploadMedia->URL ,sizeof (ParamUploadMedia->URL),
"MedURL%u",
NumMediaInForm);
snprintf (ParamUpl->Action ,sizeof (ParamUpl->Action),"MedAct%u",NumMedia);
snprintf (ParamUpl->FormType,sizeof (ParamUpl->Action),"MedFrm%u",NumMedia);
snprintf (ParamUpl->File ,sizeof (ParamUpl->File ),"MedFil%u",NumMedia);
snprintf (ParamUpl->Title ,sizeof (ParamUpl->Title ),"MedTit%u",NumMedia);
snprintf (ParamUpl->URL ,sizeof (ParamUpl->URL ),"MedURL%u",NumMedia);
}
}
@ -677,10 +659,9 @@ static void Usr_GetURLFromForm (const char *ParamName,struct Med_Media *Media)
/* Overwrite current URL (empty or coming from database)
with the URL coming from the form */
Med_FreeMediaURL (Media);
if ((Media->URL = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for media URL.");
Str_Copy (Media->URL,URL,
Length);
if ((Media->URL = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (Media->URL,URL,Length);
}
}
@ -702,10 +683,9 @@ static void Usr_GetTitleFromForm (const char *ParamName,struct Med_Media *Media)
/* Overwrite current title (empty or coming from database)
with the title coming from the form */
Med_FreeMediaTitle (Media);
if ((Media->Title = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for media title.");
Str_Copy (Media->Title,Title,
Length);
if ((Media->Title = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (Media->Title,Title,Length);
}
}
@ -762,8 +742,7 @@ static void Med_GetAndProcessFileFromForm (const char *ParamFile,
/***** End the reception of original not processed media
(it may be very big) into a temporary file *****/
Media->Status = Med_STATUS_NONE;
snprintf (PathFileOrg,sizeof (PathFileOrg),
"%s/%s_original.%s",
snprintf (PathFileOrg,sizeof (PathFileOrg),"%s/%s_original.%s",
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,PtrExtension);
if (Fil_EndReceptionOfFile (PathFileOrg,Param)) // Success
@ -813,13 +792,12 @@ static bool Med_DetectIfAnimated (struct Med_Media *Media,
int NumFrames = 0;
/***** Build path to temporary text file *****/
snprintf (PathFileTxtTmp,sizeof (PathFileTxtTmp),
"%s/%s.txt",
snprintf (PathFileTxtTmp,sizeof (PathFileTxtTmp),"%s/%s.txt",
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name);
/***** Execute system command to get number of frames in GIF *****/
snprintf (Command,sizeof (Command),
"identify -format '%%n\n' %s | head -1 > %s",
"identify -format '%%n\n' %s | head -1 > %s",
PathFileOrg,PathFileTxtTmp);
ReturnCode = system (Command);
if (ReturnCode == -1)
@ -853,8 +831,7 @@ static void Med_ProcessJPG (struct Med_Media *Media,
/***** Convert original media to temporary JPG processed file
by calling to program that makes the conversion *****/
snprintf (PathFileJPGTmp,sizeof (PathFileJPGTmp),
"%s/%s.%s",
snprintf (PathFileJPGTmp,sizeof (PathFileJPGTmp),"%s/%s.%s",
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Med_Extensions[Med_JPG]);
if (Med_ResizeImage (Media,PathFileOrg,PathFileJPGTmp) == 0) // On success ==> 0 is returned
/* Success */
@ -893,16 +870,15 @@ static void Med_ProcessGIF (struct Med_Media *Media,
/* File size correct */
/***** Get first frame of orifinal GIF file
and save it on temporary PNG file */
snprintf (PathFilePNGTmp,sizeof (PathFilePNGTmp),
"%s/%s.png",
snprintf (PathFilePNGTmp,sizeof (PathFilePNGTmp),"%s/%s.png",
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name);
if (Med_GetFirstFrame (PathFileOrg,PathFilePNGTmp) == 0) // On success ==> 0 is returned
{
/* Success */
/***** Move original GIF file to temporary GIF file *****/
snprintf (PathFileGIFTmp,sizeof (PathFileGIFTmp),
"%s/%s.%s",
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Med_Extensions[Med_GIF]);
snprintf (PathFileGIFTmp,sizeof (PathFileGIFTmp),"%s/%s.%s",
Cfg_PATH_MEDIA_TMP_PRIVATE,
Media->Name,Med_Extensions[Med_GIF]);
if (rename (PathFileOrg,PathFileGIFTmp)) // Fail
{
/* Remove temporary PNG file */
@ -960,9 +936,9 @@ static void Med_ProcessVideo (struct Med_Media *Media,
{
/* File size correct */
/***** Move original video file to temporary MP4 file *****/
snprintf (PathFileTmp,sizeof (PathFileTmp),
"%s/%s.%s",
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Med_Extensions[Media->Type]);
snprintf (PathFileTmp,sizeof (PathFileTmp),"%s/%s.%s",
Cfg_PATH_MEDIA_TMP_PRIVATE,
Media->Name,Med_Extensions[Media->Type]);
if (rename (PathFileOrg,PathFileTmp)) // Fail
/* Show error alert */
Ale_ShowAlert (Ale_ERROR,Txt_The_file_could_not_be_processed_successfully);
@ -997,7 +973,7 @@ static int Med_ResizeImage (struct Med_Media *Media,
int ReturnCode;
snprintf (Command,sizeof (Command),
"convert %s -resize '%ux%u>' -quality %u %s",
"convert %s -resize '%ux%u>' -quality %u %s",
PathFileOriginal,
Media->Width,
Media->Height,
@ -1023,8 +999,7 @@ static int Med_GetFirstFrame (const char PathFileOriginal[PATH_MAX + 1],
char Command[128 + PATH_MAX * 2];
int ReturnCode;
snprintf (Command,sizeof (Command),
"convert '%s[0]' %s",
snprintf (Command,sizeof (Command),"convert '%s[0]' %s",
PathFileOriginal,
PathFileProcessed);
ReturnCode = system (Command);
@ -1314,8 +1289,7 @@ void Med_MoveMediaToDefinitiveDir (struct Med_Media *Media)
case Med_WEBM:
case Med_OGG:
/***** Create private subdirectory for media if it does not exist *****/
snprintf (PathMedPriv,sizeof (PathMedPriv),
"%s/%c%c",
snprintf (PathMedPriv,sizeof (PathMedPriv),"%s/%c%c",
Cfg_PATH_MEDIA_PRIVATE,
Media->Name[0],
Media->Name[1]);
@ -1380,13 +1354,11 @@ static bool Med_MoveTmpFileToDefDir (struct Med_Media *Media,
char PathFile[PATH_MAX + 1]; // Full name of definitive processed file
/***** Temporary processed media file *****/
snprintf (PathFileTmp,sizeof (PathFileTmp),
"%s/%s.%s",
snprintf (PathFileTmp,sizeof (PathFileTmp),"%s/%s.%s",
Cfg_PATH_MEDIA_TMP_PRIVATE,Media->Name,Extension);
/***** Definitive processed media file *****/
snprintf (PathFile,sizeof (PathFile),
"%s/%s.%s",
snprintf (PathFile,sizeof (PathFile),"%s/%s.%s",
PathMedPriv,Media->Name,Extension);
/***** Move JPG file *****/
@ -1459,8 +1431,7 @@ void Med_ShowMedia (const struct Med_Media *Media,
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Media->URL);
/* Build path to private directory with the media */
snprintf (PathMedPriv,sizeof (PathMedPriv),
"%s/%c%c",
snprintf (PathMedPriv,sizeof (PathMedPriv),"%s/%c%c",
Cfg_PATH_MEDIA_PRIVATE,
Media->Name[0],
Media->Name[1]);
@ -1519,8 +1490,7 @@ static void Med_ShowJPG (const struct Med_Media *Media,
bool Cached;
/***** Build private path to JPG *****/
snprintf (FileNameJPG,sizeof (FileNameJPG),
"%s.%s",
snprintf (FileNameJPG,sizeof (FileNameJPG),"%s.%s",
Media->Name,Med_Extensions[Med_JPG]);
if (asprintf (&FullPathJPGPriv,"%s/%s",
PathMedPriv,FileNameJPG) < 0)
@ -1539,8 +1509,7 @@ static void Med_ShowJPG (const struct Med_Media *Media,
Brw_CreateDirDownloadTmp ();
Brw_CreateTmpPublicLinkToPrivateFile (FullPathJPGPriv,FileNameJPG);
snprintf (TmpPubDir,sizeof (TmpPubDir),
"%s/%s",
snprintf (TmpPubDir,sizeof (TmpPubDir),"%s/%s",
Gbl.FileBrowser.TmpPubDir.L,Gbl.FileBrowser.TmpPubDir.R);
Ses_AddPublicDirToCache (FullPathJPGPriv,TmpPubDir);
}
@ -1579,17 +1548,14 @@ static void Med_ShowGIF (const struct Med_Media *Media,
bool Cached;
/***** Build private path to animated GIF image *****/
snprintf (FileNameGIF,sizeof (FileNameGIF),
"%s.%s",
snprintf (FileNameGIF,sizeof (FileNameGIF),"%s.%s",
Media->Name,Med_Extensions[Med_GIF]);
if (asprintf (&FullPathGIFPriv,"%s/%s", // The animated GIF image
PathMedPriv,FileNameGIF) < 0)
Lay_NotEnoughMemoryExit ();
/***** Build private path to static PNG image *****/
snprintf (FileNamePNG,sizeof (FileNamePNG),
"%s.png",
Media->Name);
snprintf (FileNamePNG,sizeof (FileNamePNG),"%s.png",Media->Name);
if (asprintf (&FullPathPNGPriv,"%s/%s",
PathMedPriv,FileNamePNG) < 0)
Lay_NotEnoughMemoryExit ();
@ -1608,8 +1574,7 @@ static void Med_ShowGIF (const struct Med_Media *Media,
Brw_CreateTmpPublicLinkToPrivateFile (FullPathGIFPriv,FileNameGIF);
Brw_CreateTmpPublicLinkToPrivateFile (FullPathPNGPriv,FileNamePNG);
snprintf (TmpPubDir,sizeof (TmpPubDir),
"%s/%s",
snprintf (TmpPubDir,sizeof (TmpPubDir),"%s/%s",
Gbl.FileBrowser.TmpPubDir.L,Gbl.FileBrowser.TmpPubDir.R);
Ses_AddPublicDirToCache (FullPathGIFPriv,TmpPubDir);
}
@ -1675,8 +1640,7 @@ static void Med_ShowVideo (const struct Med_Media *Media,
bool Cached;
/***** Build private path to video *****/
snprintf (FileNameVideo,sizeof (FileNameVideo),
"%s.%s",
snprintf (FileNameVideo,sizeof (FileNameVideo),"%s.%s",
Media->Name,Med_Extensions[Media->Type]);
if (asprintf (&FullPathVideoPriv,"%s/%s",
PathMedPriv,FileNameVideo) < 0)
@ -1695,8 +1659,7 @@ static void Med_ShowVideo (const struct Med_Media *Media,
Brw_CreateDirDownloadTmp ();
Brw_CreateTmpPublicLinkToPrivateFile (FullPathVideoPriv,FileNameVideo);
snprintf (TmpPubDir,sizeof (TmpPubDir),
"%s/%s",
snprintf (TmpPubDir,sizeof (TmpPubDir),"%s/%s",
Gbl.FileBrowser.TmpPubDir.L,Gbl.FileBrowser.TmpPubDir.R);
Ses_AddPublicDirToCache (FullPathVideoPriv,TmpPubDir);
}
@ -1876,10 +1839,9 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
Length = strlen (MediaSrc->URL);
if (Length > Cns_MAX_BYTES_WWW)
Length = Cns_MAX_BYTES_WWW;
if ((MediaDst.URL = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for media URL.");
Str_Copy (MediaDst.URL,MediaSrc->URL,
Length);
if ((MediaDst.URL = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (MediaDst.URL,MediaSrc->URL,Length);
}
/***** Copy media title *****/
@ -1890,10 +1852,9 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
Length = strlen (MediaSrc->Title);
if (Length > Cns_MAX_BYTES_WWW)
Length = Cns_MAX_BYTES_WWW;
if ((MediaDst.Title = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for media title.");
Str_Copy (MediaDst.Title,MediaSrc->Title,
Length);
if ((MediaDst.Title = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (MediaDst.Title,MediaSrc->Title,Length);
}
/***** Create duplicate of files *****/
@ -1918,12 +1879,14 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
Fil_CreateDirIfNotExists (MediaPriv[Med_DST].Path);
/* Build paths to private files */
snprintf (MediaPriv[Med_SRC].FullPath,sizeof (MediaPriv[Med_SRC].FullPath),
"%s/%s.%s",
MediaPriv[Med_SRC].Path,MediaSrc->Name,Med_Extensions[MediaSrc->Type]);
snprintf (MediaPriv[Med_DST].FullPath,sizeof (MediaPriv[Med_DST].FullPath),
"%s/%s.%s",
MediaPriv[Med_DST].Path,MediaDst.Name,Med_Extensions[MediaSrc->Type]);
snprintf (MediaPriv[Med_SRC].FullPath,
sizeof (MediaPriv[Med_SRC].FullPath),"%s/%s.%s",
MediaPriv[Med_SRC].Path,
MediaSrc->Name,Med_Extensions[MediaSrc->Type]);
snprintf (MediaPriv[Med_DST].FullPath,
sizeof (MediaPriv[Med_DST].FullPath),"%s/%s.%s",
MediaPriv[Med_DST].Path,
MediaDst.Name,Med_Extensions[MediaSrc->Type]);
/* Copy file */
Fil_FastCopyOfFiles (MediaPriv[Med_SRC].FullPath,
@ -1932,11 +1895,11 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
if (MediaSrc->Type == Med_GIF)
{
/* Build private paths to PNG */
snprintf (MediaPriv[Med_SRC].FullPath,sizeof (MediaPriv[Med_SRC].FullPath),
"%s/%s.png",
snprintf (MediaPriv[Med_SRC].FullPath,
sizeof (MediaPriv[Med_SRC].FullPath),"%s/%s.png",
MediaPriv[Med_SRC].Path,MediaSrc->Name);
snprintf (MediaPriv[Med_DST].FullPath,sizeof (MediaPriv[Med_DST].FullPath),
"%s/%s.png",
snprintf (MediaPriv[Med_DST].FullPath,
sizeof (MediaPriv[Med_DST].FullPath),"%s/%s.png",
MediaPriv[Med_DST].Path,MediaDst.Name);
/* Copy PNG file */
@ -2014,8 +1977,7 @@ void Med_RemoveMedia (long MedCod)
if (Media.Name[0])
{
/***** Build path to private directory with the media *****/
snprintf (PathMedPriv,sizeof (PathMedPriv),
"%s/%c%c",
snprintf (PathMedPriv,sizeof (PathMedPriv),"%s/%c%c",
Cfg_PATH_MEDIA_PRIVATE,
Media.Name[0],
Media.Name[1]);

View File

@ -144,11 +144,11 @@ void Med_ResetMedia (struct Med_Media *Media);
void Med_GetMediaDataByCod (struct Med_Media *Media);
void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput);
void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media,
void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media),
void Med_PutMediaUploader (int NumMedia,const char *ClassInput);
void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMedia,struct Med_Media *Media,
void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMedia,struct Med_Media *Media),
const char *SectionForAlerts);
void Med_SetParamNames (struct ParamUploadMedia *ParamUploadMedia,int NumMediaInForm);
void Med_SetParamNames (struct ParamUploadMedia *ParamUpl,int NumMedia);
void Med_RemoveKeepOrStoreMedia (long CurrentMedCodInDB,struct Med_Media *Media);
void Med_MoveMediaToDefinitiveDir (struct Med_Media *Media);

View File

@ -345,7 +345,7 @@ static void Msg_PutFormMsgUsrs (struct Msg_Messages *Messages,
}
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
if (Messages->ShowOnlyOneRecipient)
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
}
@ -450,7 +450,7 @@ static void Msg_PutParamsShowMorePotentialRecipients (const void *Messages)
Msg_PutHiddenParamMsgCod (((struct Msg_Messages *) Messages)->Reply.OriginalMsgCod);
}
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
/***** Hidden params to send subject and content *****/
Msg_PutHiddenParamsSubjectAndContent ();
@ -474,7 +474,7 @@ static void Msg_PutParamsWriteMsg (void *Messages)
}
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
if (((struct Msg_Messages *) Messages)->ShowOnlyOneRecipient)
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
}
@ -627,13 +627,9 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (struct Msg_Messages *Messag
row = mysql_fetch_row (mysql_res);
/* Get subject */
Str_Copy (Messages->Subject,row[0],
Cns_MAX_BYTES_SUBJECT);
/* Get content */
Str_Copy (Content,row[1],
Cns_MAX_BYTES_LONG_TEXT);
/* Get subject (row[0]) and content (row[1]) */
Str_Copy (Messages->Subject,row[0],sizeof (Messages->Subject) - 1);
Str_Copy (Content ,row[1],Cns_MAX_BYTES_LONG_TEXT);
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
@ -711,12 +707,10 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (struct Msg_Messages *Messag
static void Msg_PutHiddenParamAnotherRecipient (const struct UsrData *UsrDat)
{
char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NickWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
"@%s",
UsrDat->Nickname);
Par_PutHiddenParamString (NULL,"OtherRecipients",NicknameWithArroba);
snprintf (NickWithArroba,sizeof (NickWithArroba),"@%s",UsrDat->Nickname);
Par_PutHiddenParamString (NULL,"OtherRecipients",NickWithArroba);
}
/*****************************************************************************/
@ -839,7 +833,7 @@ void Msg_RecMsgFromUsr (void)
NumRecipients = 0;
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDstData.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDstData.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDstData);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDstData,Usr_DONT_GET_PREFS)) // Get recipient's data from the database
@ -1132,11 +1126,11 @@ static void Msg_GetParamMsgsCrsCod (struct Msg_Messages *Messages)
Crs_GetDataOfCourseByCod (&Crs);
Str_Copy (Messages->FilterCrsShrtName,Crs.ShrtName,
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
sizeof (Messages->FilterCrsShrtName) - 1);
}
else
Str_Copy (Messages->FilterCrsShrtName,Txt_any_course,
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
sizeof (Messages->FilterCrsShrtName) - 1);
}
/*****************************************************************************/
@ -1184,13 +1178,10 @@ static void Msg_MakeFilterFromToSubquery (const struct Msg_Messages *Messages,
if (strlen (FilterFromToSubquery) + strlen (SearchWord) + 512 >
Msg_MAX_BYTES_MESSAGES_QUERY) // Prevent string overflow
break;
Str_Concat (FilterFromToSubquery,"%",
Msg_MAX_BYTES_MESSAGES_QUERY);
Str_Concat (FilterFromToSubquery,SearchWord,
Msg_MAX_BYTES_MESSAGES_QUERY);
Str_Concat (FilterFromToSubquery,"%",Msg_MAX_BYTES_MESSAGES_QUERY);
Str_Concat (FilterFromToSubquery,SearchWord,Msg_MAX_BYTES_MESSAGES_QUERY);
}
Str_Concat (FilterFromToSubquery,"%'",
Msg_MAX_BYTES_MESSAGES_QUERY);
Str_Concat (FilterFromToSubquery,"%'",Msg_MAX_BYTES_MESSAGES_QUERY);
}
else
FilterFromToSubquery[0] = '\0';
@ -2797,7 +2788,7 @@ static void Msg_GetDistinctCoursesInMyMessages (struct Msg_Messages *Messages)
{
Messages->Courses[Messages->NumCourses].CrsCod = Crs.CrsCod;
Str_Copy (Messages->Courses[Messages->NumCourses].ShrtName,Crs.ShrtName,
Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
sizeof (Messages->Courses[Messages->NumCourses].ShrtName) - 1);
Messages->NumCourses++;
}
}
@ -2992,8 +2983,7 @@ static void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT +
{
/***** Get subject *****/
row = mysql_fetch_row (mysql_res);
Str_Copy (Subject,row[0],
Cns_MAX_BYTES_SUBJECT);
Str_Copy (Subject,row[0],Cns_MAX_BYTES_SUBJECT);
}
else
Subject[0] = '\0';
@ -3028,8 +3018,7 @@ static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT
row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/
Str_Copy (Content,row[0],
Cns_MAX_BYTES_LONG_TEXT);
Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
/***** Get media (row[1]) *****/
Media->MedCod = Str_ConvertStrCodToLongCod (row[1]);
@ -3324,17 +3313,15 @@ void Msg_GetNotifMessage (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
}
else
Str_Copy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
/***** Copy subject *****/
if (GetContent)
{
Length = strlen (row[1]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[1],
Length);
if ((*ContentStr = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (*ContentStr,row[1],Length);
}
}
@ -3546,7 +3533,7 @@ static void Msg_WriteFormToReply (long MsgCod,long CrsCod,
Grp_PutParamAllGroups ();
Par_PutHiddenParamChar ("IsReply",'Y');
Msg_PutHiddenParamMsgCod (MsgCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
/****** Link and form end *****/
@ -3887,7 +3874,7 @@ static void Msg_PutFormToBanSender (struct Msg_Messages *Messages,
Frm_StartForm (ActBanUsrMsg);
Pag_PutHiddenParamPagNum (Msg_WhatPaginate[Messages->TypeOfMessages],
Messages->CurrentPage);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Msg_PutHiddenParamsMsgsFilters (Messages);
Ico_PutIconLink ("unlock.svg",Txt_Sender_permitted_click_to_ban_him);
Frm_EndForm ();
@ -3905,7 +3892,7 @@ static void Msg_PutFormToUnbanSender (struct Msg_Messages *Messages,
Frm_StartForm (ActUnbUsrMsg);
Pag_PutHiddenParamPagNum (Msg_WhatPaginate[Messages->TypeOfMessages],
Messages->CurrentPage);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Msg_PutHiddenParamsMsgsFilters (Messages);
Ico_PutIconLink ("lock.svg",Txt_Sender_banned_click_to_unban_him);
Frm_EndForm ();
@ -4078,7 +4065,7 @@ void Msg_ListBannedUsrs (void)
/* Put form to unban user */
HTM_TD_Begin ("class=\"BM\"");
Frm_StartForm (ActUnbUsrLst);
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
Ico_PutIconLink ("lock.svg",Txt_Sender_banned_click_to_unban_him);
Frm_EndForm ();
HTM_TD_End ();

View File

@ -231,8 +231,7 @@ void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
{
/* Get URL */
row = mysql_fetch_row (mysql_res);
Str_Copy (URL,row[0],
Cns_MAX_BYTES_WWW);
Str_Copy (URL,row[0],sizeof (URL) - 1);
/* Show the web / social network */
Net_ShowAWebOrSocialNet (URL,
@ -284,9 +283,7 @@ void Net_ShowFormMyWebsAndSocialNets (void)
HTM_SECTION_Begin (Net_MY_WEBS_ID);
/***** Begin box *****/
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
Box_BoxBegin (StrRecordWidth,Txt_Webs_social_networks,
Net_PutIconsWebsSocialNetworks,NULL,
Hlp_PROFILE_Webs,Box_NOT_CLOSABLE);
@ -313,8 +310,7 @@ void Net_ShowFormMyWebsAndSocialNets (void)
row = mysql_fetch_row (mysql_res);
/* Get URL */
Str_Copy (URL,row[0],
Cns_MAX_BYTES_WWW);
Str_Copy (URL,row[0],sizeof (URL) - 1);
}
else
URL[0] = '\0';
@ -323,9 +319,7 @@ void Net_ShowFormMyWebsAndSocialNets (void)
DB_FreeMySQLResult (&mysql_res);
/***** Row for this web / social network *****/
snprintf (StrName,sizeof (StrName),
"URL%u",
(unsigned) NumURL);
snprintf (StrName,sizeof (StrName),"URL%u",(unsigned) NumURL);
HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"REC_C1_BOT LM\"");
@ -400,9 +394,7 @@ static void Net_GetMyWebsAndSocialNetsFromForm (void)
NumURL++)
{
/***** Get URL from the form *****/
snprintf (ParamName,sizeof (ParamName),
"URL%u",
(unsigned) NumURL);
snprintf (ParamName,sizeof (ParamName),"URL%u",(unsigned) NumURL);
Par_GetParToText (ParamName,URL,Cns_MAX_BYTES_WWW);
if (URL[0])
@ -573,8 +565,7 @@ void Net_ShowWebAndSocialNetworksStats (void)
row = mysql_fetch_row (mysql_res);
/* Get web / social network (row[0]) */
Str_Copy (NetName,row[0],
Net_MAX_BYTES_NETWORK_NAME);
Str_Copy (NetName,row[0],sizeof (NetName) - 1);
for (Web = (Net_WebsAndSocialNetworks_t) 0;
Web <= (Net_WebsAndSocialNetworks_t) (Net_NUM_WEBS_AND_SOCIAL_NETWORKS - 1);
Web++)

View File

@ -74,21 +74,20 @@ static void Nck_UpdateUsrNick (struct UsrData *UsrDat);
/********* Check whether a nickname (with initial arroba) if valid ***********/
/*****************************************************************************/
bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba)
bool Nck_CheckIfNickWithArrobaIsValid (const char *NickWithArroba)
{
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
unsigned Length;
const char *Ptr;
/***** A nickname must start by '@' *****/
if (NicknameWithArroba[0] != '@') // It's not a nickname
if (NickWithArroba[0] != '@') // It's not a nickname
return false;
/***** Make a copy of nickname *****/
Str_Copy (NicknameWithoutArroba,NicknameWithArroba,
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
Str_RemoveLeadingArrobas (NicknameWithoutArroba);
Length = strlen (NicknameWithoutArroba);
Str_Copy (NickWithoutArroba,NickWithArroba,sizeof (NickWithoutArroba) - 1);
Str_RemoveLeadingArrobas (NickWithoutArroba);
Length = strlen (NickWithoutArroba);
/***** A nick (without arroba) must have a number of characters
Nck_MIN_BYTES_NICKNAME_WITHOUT_ARROBA <= Length <= Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA *****/
@ -97,7 +96,7 @@ bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba)
return false;
/***** A nick can have digits, letters and '_' *****/
for (Ptr = NicknameWithoutArroba;
for (Ptr = NickWithoutArroba;
*Ptr;
Ptr++)
if (!((*Ptr >= 'a' && *Ptr <= 'z') ||
@ -128,8 +127,7 @@ bool Nck_GetNicknameFromUsrCod (long UsrCod,
{
/* Get nickname */
row = mysql_fetch_row (mysql_res);
Str_Copy (Nickname,row[0],
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
Str_Copy (Nickname,row[0],Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
Found = true;
}
else
@ -152,7 +150,7 @@ bool Nck_GetNicknameFromUsrCod (long UsrCod,
long Nck_GetUsrCodFromNickname (const char *Nickname)
{
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long UsrCod = -1L;
@ -161,9 +159,8 @@ long Nck_GetUsrCodFromNickname (const char *Nickname)
if (Nickname[0])
{
/***** Make a copy without possible starting arrobas *****/
Str_Copy (NicknameWithoutArroba,Nickname,
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
Str_RemoveLeadingArrobas (NicknameWithoutArroba);
Str_Copy (NickWithoutArroba,Nickname,sizeof (NickWithoutArroba) - 1);
Str_RemoveLeadingArrobas (NickWithoutArroba);
/***** Get user's code from database *****/
/* Check if user code from table usr_nicknames is also in table usr_data */
@ -172,7 +169,7 @@ long Nck_GetUsrCodFromNickname (const char *Nickname)
" FROM usr_nicknames,usr_data"
" WHERE usr_nicknames.Nickname='%s'"
" AND usr_nicknames.UsrCod=usr_data.UsrCod",
NicknameWithoutArroba))
NickWithoutArroba))
{
/* Get row */
row = mysql_fetch_row (mysql_res);
@ -230,7 +227,7 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
unsigned NumNicks;
unsigned NumNick;
Act_Action_t NextAction;
char NicknameWithArroba[1 + Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
char NickWithArroba[1 + Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
const struct UsrData *UsrDat = (ItsMe ? &Gbl.Usrs.Me.UsrDat :
&Gbl.Usrs.Other.UsrDat);
@ -246,9 +243,7 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
UsrDat->UsrCod);
/***** Begin box *****/
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
Box_BoxBegin (StrRecordWidth,Txt_Nickname,
Acc_PutLinkToRemoveMyAccount,NULL,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
@ -325,7 +320,7 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
/* Link to QR code */
if (NumNick == 1 && UsrDat->Nickname[0])
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod);
/* Form to change the nickname */
if (NumNick > 1)
@ -349,13 +344,11 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
break;
}
Frm_StartFormAnchor (NextAction,Nck_NICKNAME_SECTION_ID);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
}
snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
"@%s",
row[0]);
Par_PutHiddenParamString (NULL,"NewNick",NicknameWithArroba); // Nickname
snprintf (NickWithArroba,sizeof (NickWithArroba),"@%s",row[0]);
Par_PutHiddenParamString (NULL,"NewNick",NickWithArroba); // Nickname
Btn_PutConfirmButtonInline (Txt_Use_this_nickname);
Frm_EndForm ();
}
@ -398,13 +391,12 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
break;
}
Frm_StartFormAnchor (NextAction,Nck_NICKNAME_SECTION_ID);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
}
snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
"@%s",
snprintf (NickWithArroba,sizeof (NickWithArroba),"@%s",
Gbl.Usrs.Me.UsrDat.Nickname);
HTM_INPUT_TEXT ("NewNick",1 + Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA,
NicknameWithArroba,HTM_DONT_SUBMIT_ON_CHANGE,
NickWithArroba,HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"NewNick\" size=\"18\"");
HTM_BR ();
Btn_PutCreateButtonInline (NumNicks ? Txt_Change_nickname : // I already have a nickname
@ -431,7 +423,7 @@ static void Nck_PutParamsRemoveOtherNick (void *Nick)
{
if (Nick)
{
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
Par_PutHiddenParamString (NULL,"Nick",Nick);
}
}
@ -444,21 +436,21 @@ void Nck_RemoveMyNick (void)
{
extern const char *Txt_Nickname_X_removed;
extern const char *Txt_You_can_not_delete_your_current_nickname;
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
char NickWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
/***** Get nickname from form *****/
Par_GetParToText ("Nick",NicknameWithoutArroba,
Par_GetParToText ("Nick",NickWithoutArroba,
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
if (strcasecmp (NicknameWithoutArroba,Gbl.Usrs.Me.UsrDat.Nickname)) // Only if not my current nickname
if (strcasecmp (NickWithoutArroba,Gbl.Usrs.Me.UsrDat.Nickname)) // Only if not my current nickname
{
/***** Remove one of my old nicknames *****/
Nck_RemoveNicknameFromDB (Gbl.Usrs.Me.UsrDat.UsrCod,NicknameWithoutArroba);
Nck_RemoveNicknameFromDB (Gbl.Usrs.Me.UsrDat.UsrCod,NickWithoutArroba);
/***** Show message *****/
Ale_CreateAlert (Ale_SUCCESS,Nck_NICKNAME_SECTION_ID,
Txt_Nickname_X_removed,
NicknameWithoutArroba);
NickWithoutArroba);
}
else
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
@ -475,7 +467,7 @@ void Nck_RemoveMyNick (void)
void Nck_RemoveOtherUsrNick (void)
{
extern const char *Txt_Nickname_X_removed;
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
char NickWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
/***** Get user whose nick must be removed *****/
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
@ -483,16 +475,16 @@ void Nck_RemoveOtherUsrNick (void)
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
{
/***** Get nickname from form *****/
Par_GetParToText ("Nick",NicknameWithoutArroba,
Par_GetParToText ("Nick",NickWithoutArroba,
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
/***** Remove one of the old nicknames *****/
Nck_RemoveNicknameFromDB (Gbl.Usrs.Other.UsrDat.UsrCod,NicknameWithoutArroba);
Nck_RemoveNicknameFromDB (Gbl.Usrs.Other.UsrDat.UsrCod,NickWithoutArroba);
/***** Show message *****/
Ale_CreateAlert (Ale_SUCCESS,Nck_NICKNAME_SECTION_ID,
Txt_Nickname_X_removed,
NicknameWithoutArroba);
NickWithoutArroba);
/***** Show user's account again *****/
Acc_ShowFormChgOtherUsrAccount ();
@ -564,57 +556,55 @@ static void Nck_UpdateUsrNick (struct UsrData *UsrDat)
extern const char *Txt_The_nickname_X_had_been_registered_by_another_user;
extern const char *Txt_The_nickname_X_has_been_registered_successfully;
extern const char *Txt_The_nickname_entered_X_is_not_valid_;
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewNickWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewNickWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
/***** Get new nickname from form *****/
Par_GetParToText ("NewNick",NewNicknameWithArroba,
Par_GetParToText ("NewNick",NewNickWithArroba,
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
if (Nck_CheckIfNickWithArrobaIsValid (NewNickWithArroba)) // If new nickname is valid
{
/***** Remove arrobas at the beginning *****/
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
Str_Copy (NewNickWithoutArroba,NewNickWithArroba,sizeof (NewNickWithoutArroba) - 1);
Str_RemoveLeadingArrobas (NewNickWithoutArroba);
/***** Check if new nickname exists in database *****/
if (!strcmp (UsrDat->Nickname,NewNicknameWithoutArroba)) // User's nickname match exactly the new nickname
if (!strcmp (UsrDat->Nickname,NewNickWithoutArroba)) // User's nickname match exactly the new nickname
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
Txt_The_nickname_X_matches_the_one_you_had_previously_registered,
NewNicknameWithoutArroba);
else if (strcasecmp (UsrDat->Nickname,NewNicknameWithoutArroba)) // User's nickname does not match, not even case insensitive, the new nickname
NewNickWithoutArroba);
else if (strcasecmp (UsrDat->Nickname,NewNickWithoutArroba)) // User's nickname does not match, not even case insensitive, the new nickname
{
/***** Check if the new nickname matches any of my old nicknames *****/
if (!DB_QueryCOUNT ("can not check if nickname already existed",
"SELECT COUNT(*) FROM usr_nicknames"
" WHERE UsrCod=%ld AND Nickname='%s'",
UsrDat->UsrCod,NewNicknameWithoutArroba)) // No matches
UsrDat->UsrCod,NewNickWithoutArroba)) // No matches
/***** Check if the new nickname matches any of the nicknames of other users *****/
if (DB_QueryCOUNT ("can not check if nickname already existed",
"SELECT COUNT(*) FROM usr_nicknames"
" WHERE Nickname='%s' AND UsrCod<>%ld",
NewNicknameWithoutArroba,UsrDat->UsrCod)) // A nickname of another user is the same that user's nickname
NewNickWithoutArroba,UsrDat->UsrCod)) // A nickname of another user is the same that user's nickname
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
Txt_The_nickname_X_had_been_registered_by_another_user,
NewNicknameWithoutArroba);
NewNickWithoutArroba);
}
if (Ale_GetNumAlerts () == 0) // No problems
{
// Now we know the new nickname is not already in database
// and is diffent to the current one
Nck_UpdateNickInDB (UsrDat->UsrCod,NewNicknameWithoutArroba);
Str_Copy (UsrDat->Nickname,NewNicknameWithoutArroba,
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
Nck_UpdateNickInDB (UsrDat->UsrCod,NewNickWithoutArroba);
Str_Copy (UsrDat->Nickname,NewNickWithoutArroba,sizeof (UsrDat->Nickname) - 1);
Ale_CreateAlert (Ale_SUCCESS,Nck_NICKNAME_SECTION_ID,
Txt_The_nickname_X_has_been_registered_successfully,
NewNicknameWithoutArroba);
NewNickWithoutArroba);
}
}
else // New nickname is not valid
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
Txt_The_nickname_entered_X_is_not_valid_,
NewNicknameWithArroba,
NewNickWithArroba,
Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA,
Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA);
}

View File

@ -46,7 +46,7 @@
/***************************** Public prototypes *****************************/
/*****************************************************************************/
bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba);
bool Nck_CheckIfNickWithArrobaIsValid (const char *NickWithArroba);
bool Nck_GetNicknameFromUsrCod (long UsrCod,
char Nickname[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1]);

View File

@ -29,7 +29,6 @@
#include <linux/limits.h> // For PATH_MAX
#include <stddef.h> // For NULL
#include <stdio.h> // For sscanf, asprintf, etc.
#include <stdlib.h> // For exit, system, malloc, calloc, free, etc.
#include <string.h>
#include "swad_box.h"
@ -407,8 +406,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
{
/***** Begin box *****/
snprintf (StrWidth,sizeof (StrWidth),
"%upx",
snprintf (StrWidth,sizeof (StrWidth),"%upx",
Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50);
Box_BoxBegin (StrWidth,Txt_Notices,
Not_PutIconsListNotices,NULL,
@ -435,8 +433,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
UsrCod = Str_ConvertStrCodToLongCod (row[2]);
/* Get the content (row[3]) and insert links */
Str_Copy (Content,row[3],
Cns_MAX_BYTES_TEXT);
Str_Copy (Content,row[3],sizeof (Content) - 1);
/* Inserting links is incompatible with limiting the length
==> don't insert links when limiting length */
@ -469,8 +466,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
case Not_LIST_BRIEF_NOTICES:
/***** Link to RSS file *****/
/* Create RSS file if not exists */
snprintf (PathRelRSSFile,sizeof (PathRelRSSFile),
"%s/%ld/%s/%s",
snprintf (PathRelRSSFile,sizeof (PathRelRSSFile),"%s/%ld/%s/%s",
Cfg_PATH_CRS_PUBLIC,
Gbl.Hierarchy.Crs.CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
if (!Fil_CheckIfPathExists (PathRelRSSFile))
@ -586,8 +582,7 @@ static void Not_GetDataAndShowNotice (long NotCod)
UsrCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get the content (row[2]) and insert links*/
Str_Copy (Content,row[2],
Cns_MAX_BYTES_TEXT);
Str_Copy (Content,row[2],sizeof (Content) - 1);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]);
@ -794,17 +789,15 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
}
else
Str_Copy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
/***** Copy content *****/
if (GetContent)
{
Length = strlen (row[0]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[0],
Length);
if ((*ContentStr = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (*ContentStr,row[0],Length);
}
}

View File

@ -726,16 +726,16 @@ static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
// Cod is the code of the social publishing
Frm_StartForm (ActSeeTmlGbl);
TL_Pub_PutHiddenParamPubCod (Cod);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Ntf_PutHiddenParamNotifyEvent (NotifyEvent);
break;
case Ntf_EVENT_FOLLOWER:
if (UsrDat->EncryptedUsrCod[0]) // User's code found ==>
if (UsrDat->EnUsrCod[0]) // User's code found ==>
// go to user's public profile
{
Frm_StartForm (ActSeeOthPubPrf);
/* Put param to go to follower's profile */
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
}
else // No user's code found ==> go to see my followers
Frm_StartForm (ActSeeFlr);

View File

@ -263,7 +263,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutHiddenParamPagNum (WhatPaginate,1);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
default:
break;
@ -390,7 +390,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutHiddenParamPagNum (WhatPaginate,1);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
default:
break;
@ -503,7 +503,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutHiddenParamPagNum (WhatPaginate,Pagination->LeftPage);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
default:
break;
@ -628,7 +628,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutHiddenParamPagNum (WhatPaginate,NumPage);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
default:
break;
@ -740,7 +740,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutHiddenParamPagNum (WhatPaginate,Pagination->RightPage);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
default:
break;
@ -853,7 +853,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Frm_StartFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutHiddenParamEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutHiddenParamPagNum (WhatPaginate,Pagination->NumPags);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
default:
break;

View File

@ -86,8 +86,7 @@ bool Par_GetQueryString (void)
char UnsignedLongStr[Cns_MAX_DECIMAL_DIGITS_ULONG + 1];
unsigned long UnsignedLong;
Str_Copy (Method,getenv ("REQUEST_METHOD"),
Par_MAX_BYTES_METHOD);
Str_Copy (Method,getenv ("REQUEST_METHOD"),sizeof (Method) - 1);
if (!strcmp (Method,"GET"))
{
@ -99,7 +98,7 @@ bool Par_GetQueryString (void)
Gbl.Params.ContentLength = strlen (getenv ("QUERY_STRING"));
/* Allocate memory for query string */
if ((Gbl.Params.QueryString = (char *) malloc (Gbl.Params.ContentLength + 1)) == NULL)
if ((Gbl.Params.QueryString = malloc (Gbl.Params.ContentLength + 1)) == NULL)
return false;
/* Copy query string from environment variable */
@ -113,7 +112,7 @@ bool Par_GetQueryString (void)
if (getenv ("CONTENT_LENGTH"))
{
Str_Copy (UnsignedLongStr,getenv ("CONTENT_LENGTH"),
Cns_MAX_DECIMAL_DIGITS_ULONG);
sizeof (UnsignedLongStr) - 1);
if (sscanf (UnsignedLongStr,"%lu",&UnsignedLong) != 1)
return false;
Gbl.Params.ContentLength = (size_t) UnsignedLong;
@ -127,8 +126,7 @@ bool Par_GetQueryString (void)
if (getenv ("CONTENT_TYPE") == NULL)
return false;
Str_Copy (ContentType,getenv ("CONTENT_TYPE"),
Par_MAX_BYTES_CONTENT_TYPE);
Str_Copy (ContentType,getenv ("CONTENT_TYPE"),sizeof (ContentType) - 1);
if (!strncmp (ContentType,"multipart/form-data",strlen ("multipart/form-data")))
{
@ -145,7 +143,7 @@ bool Par_GetQueryString (void)
Gbl.ContentReceivedByCGI = Act_CONT_NORM;
/* Allocate memory for query string */
if ((Gbl.Params.QueryString = (char *) malloc (Gbl.Params.ContentLength + 1)) == NULL)
if ((Gbl.Params.QueryString = malloc (Gbl.Params.ContentLength + 1)) == NULL)
return false;
/* Copy query string from stdin */
@ -185,11 +183,9 @@ static void Par_GetBoundary (void)
/***** Create boundary strings *****/
snprintf (Gbl.Boundary.StrWithoutCRLF,sizeof (Gbl.Boundary.StrWithoutCRLF),
"--%s",
PtrToBoundary);
"--%s",PtrToBoundary);
snprintf (Gbl.Boundary.StrWithCRLF,sizeof (Gbl.Boundary.StrWithCRLF),
"%c%c%s",
0x0D,0x0A,Gbl.Boundary.StrWithoutCRLF);
"%c%c%s",0x0D,0x0A,Gbl.Boundary.StrWithoutCRLF);
/***** Compute lengths *****/
Gbl.Boundary.LengthWithoutCRLF = strlen (Gbl.Boundary.StrWithoutCRLF);
@ -261,8 +257,8 @@ static void Par_CreateListOfParamsFromQueryString (void)
)
{
/* Allocate space for a new parameter initialized to 0 */
if ((NewParam = (struct Param *) calloc (1,sizeof (struct Param))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for parameter");
if ((NewParam = calloc (1,sizeof (*NewParam))) == NULL)
Lay_NotEnoughMemoryExit ();
/* Link the previous element in list with the current element */
if (CurPos == 0)
@ -337,8 +333,8 @@ static void Par_CreateListOfParamsFromTmpFile (void)
if (!strcasecmp (StrAux,StringBeforeParam)) // Start of a parameter
{
/* Allocate space for a new parameter initialized to 0 */
if ((NewParam = (struct Param *) calloc (1,sizeof (struct Param))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for parameter");
if ((NewParam = calloc (1,sizeof (*NewParam))) == NULL)
Lay_NotEnoughMemoryExit ();
/* Link the previous element in list with the current element */
if (CurPos == 0)
@ -699,7 +695,7 @@ void Par_GetMainParameters (void)
/* Set another user's nickname */
Str_RemoveLeadingArrobas (Nickname);
Str_Copy (Gbl.Usrs.Other.UsrDat.Nickname,Nickname, // without arroba
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
sizeof (Gbl.Usrs.Other.UsrDat.Nickname) - 1);
// This user's code is used to go to public profile
// and to refresh old publishings in user's timeline
@ -715,7 +711,7 @@ void Par_GetMainParameters (void)
/* Set another user's nickname */
Str_RemoveLeadingArrobas (Nickname);
Str_Copy (Gbl.Usrs.Other.UsrDat.Nickname,Nickname, // without arroba
Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA);
sizeof (Gbl.Usrs.Other.UsrDat.Nickname) - 1);
// This user's code is used to go to public agenda
// If user does not exist ==> UsrCod = -1
@ -801,18 +797,14 @@ void Par_GetMainParameters (void)
Gbl.Prefs.Theme = The_THEME_DEFAULT;
/***** Set path of theme *****/
snprintf (URL,sizeof (URL),
"%s/%s",
snprintf (URL,sizeof (URL),"%s/%s",
Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]);
Str_Copy (Gbl.Prefs.URLTheme,URL,
PATH_MAX);
Str_Copy (Gbl.Prefs.URLTheme,URL,sizeof (Gbl.Prefs.URLTheme) - 1);
/***** Set path of icon set *****/
snprintf (URL,sizeof (URL),
"%s/%s",
snprintf (URL,sizeof (URL),"%s/%s",
Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[Gbl.Prefs.IconSet]);
Str_Copy (Gbl.Prefs.URLIconSet,URL,
PATH_MAX);
Str_Copy (Gbl.Prefs.URLIconSet,URL,sizeof (Gbl.Prefs.URLIconSet) - 1);
}
/***** Get country if exists (from menu) *****/

View File

@ -127,7 +127,7 @@ bool Pwd_CheckPendingPassword (void)
/* Get encrypted pending password */
row = mysql_fetch_row (mysql_res);
Str_Copy (Gbl.Usrs.Me.PendingPassword,row[0],
Pwd_BYTES_ENCRYPTED_PASSWORD);
sizeof (Gbl.Usrs.Me.PendingPassword) - 1);
}
else
Gbl.Usrs.Me.PendingPassword[0] = '\0';
@ -155,7 +155,7 @@ void Pwd_AssignMyPendingPasswordToMyCurrentPassword (void)
/***** Update my current password *****/
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,Gbl.Usrs.Me.PendingPassword,
Pwd_BYTES_ENCRYPTED_PASSWORD);
sizeof (Gbl.Usrs.Me.UsrDat.Password) - 1);
/***** Remove my pending password from database
since it is not longer necessary *****/
@ -235,7 +235,7 @@ static void Pwd_CheckAndUpdateNewPwd (struct UsrData *UsrDat)
{
/* Update user's data */
Str_Copy (UsrDat->Password,NewEncryptedPassword,
Pwd_BYTES_ENCRYPTED_PASSWORD);
sizeof (UsrDat->Password) - 1);
Ses_UpdateSessionDataInDB ();
Enr_UpdateUsrData (UsrDat);
@ -364,7 +364,7 @@ void Pwd_ChkIdLoginAndSendNewPwd (void)
// User has typed a user's ID
Str_Copy (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID,Gbl.Usrs.Me.UsrIdLogin,
ID_MAX_BYTES_USR_ID);
sizeof (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID) - 1);
Str_ConvertToUpperText (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID);
/* Get users' codes for this ID */
@ -669,9 +669,7 @@ void Pwd_ShowFormChgMyPwd (void)
Frm_StartFormAnchor (ActChgMyPwd,Pwd_PASSWORD_SECTION_ID);
/***** Begin box *****/
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
Box_BoxBegin (StrRecordWidth,Txt_Password,
NULL,NULL,
Hlp_PROFILE_Password,Box_NOT_CLOSABLE);
@ -833,7 +831,7 @@ void Pwd_ShowFormChgOtherUsrPwd (void)
break;
}
Frm_StartFormAnchor (NextAction,Pwd_PASSWORD_SECTION_ID);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
/* New password */
HTM_TABLE_BeginWidePadding (2);

View File

@ -271,7 +271,7 @@ static void Pho_PutIconToRequestRemoveOtherUsrPhoto (__attribute__((unused)) voi
break;
}
Lay_PutContextualLinkOnlyIcon (NextAction,NULL,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
"trash.svg",
Txt_Remove_photo);
}
@ -343,7 +343,7 @@ static void Pho_ReqPhoto (const struct UsrData *UsrDat)
break;
}
Frm_StartForm (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
}
/***** Show help message *****/
@ -531,7 +531,7 @@ void Pho_ReqRemoveUsrPhoto (void)
break;
}
Ale_ShowAlertAndButton2 (NextAction,NULL,NULL,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Usr_PutParamOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Btn_REMOVE_BUTTON,Txt_Remove_photo);
}
else
@ -614,10 +614,8 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
/***** Creates directories if not exist *****/
Fil_CreateDirIfNotExists (Cfg_PATH_PHOTO_PRIVATE);
snprintf (PathPhotosPriv,sizeof (PathPhotosPriv),
"%s/%02u",
Cfg_PATH_PHOTO_PRIVATE,
(unsigned) (UsrDat->UsrCod % 100));
snprintf (PathPhotosPriv,sizeof (PathPhotosPriv),"%s/%02u",
Cfg_PATH_PHOTO_PRIVATE,(unsigned) (UsrDat->UsrCod % 100));
Fil_CreateDirIfNotExists (PathPhotosPriv);
/***** Create directories if not exists
@ -647,10 +645,8 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
}
/* End the reception of photo in a temporary file */
snprintf (FileNamePhotoTmp,sizeof (FileNamePhotoTmp),
"%s/%s.jpg",
Cfg_PATH_PHOTO_TMP_PUBLIC,
Gbl.UniqueNameEncrypted);
snprintf (FileNamePhotoTmp,sizeof (FileNamePhotoTmp),"%s/%s.jpg",
Cfg_PATH_PHOTO_TMP_PUBLIC,Gbl.UniqueNameEncrypted);
if (!Fil_EndReceptionOfFile (FileNamePhotoTmp,Param))
{
Ale_ShowAlert (Ale_ERROR,"Error copying file.");
@ -659,15 +655,13 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
/* Copy the original photo received to private directory.
The purpose of this copy is only to have a backup used for researching better methods to detect faces in images */
snprintf (PathRelPhoto,sizeof (PathRelPhoto),
"%s/%02u/%ld_original.jpg",
snprintf (PathRelPhoto,sizeof (PathRelPhoto),"%s/%02u/%ld_original.jpg",
Cfg_PATH_PHOTO_PRIVATE,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
Fil_FastCopyOfFiles (FileNamePhotoTmp,PathRelPhoto);
/***** Call to program that makes photo processing / face detection *****/
snprintf (Command,sizeof (Command),
Cfg_COMMAND_FACE_DETECTION,
snprintf (Command,sizeof (Command),Cfg_COMMAND_FACE_DETECTION,
FileNamePhotoTmp);
ReturnCode = system (Command);
if (ReturnCode == -1)
@ -679,10 +673,8 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
{
case 0: // Faces detected
/***** Open text file with text for image map *****/
snprintf (FileNameTxtMap,sizeof (FileNameTxtMap),
"%s/%s_map.txt",
Cfg_PATH_PHOTO_TMP_PUBLIC,
Gbl.UniqueNameEncrypted);
snprintf (FileNameTxtMap,sizeof (FileNameTxtMap),"%s/%s_map.txt",
Cfg_PATH_PHOTO_TMP_PUBLIC,Gbl.UniqueNameEncrypted);
if ((FileTxtMap = fopen (FileNameTxtMap,"rb")) == NULL)
Lay_ShowErrorAndExit ("Can not read text file with coordinates of detected faces.");
@ -714,7 +706,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
break;
}
Frm_StartForm (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
}
Par_PutHiddenParamString (NULL,"FileName",StrFileName);
Frm_EndForm ();
@ -778,9 +770,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
if (BackgroundCode == 1)
{
NumFace++;
snprintf (FormId,sizeof (FormId),
"form_%d",
NumLastForm + NumFace);
snprintf (FormId,sizeof (FormId),"form_%d",NumLastForm + NumFace);
HTM_TxtF ("<area shape=\"circle\""
" href=\"\""
" onclick=\"javascript:document.getElementById('%s').submit();return false;\""
@ -794,10 +784,8 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
HTM_Txt ("</map>\n");
/***** Show map photo *****/
snprintf (FileNamePhotoMap,sizeof (FileNamePhotoMap),
"%s/%s_map.jpg",
Cfg_PATH_PHOTO_TMP_PUBLIC,
Gbl.UniqueNameEncrypted);
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_BuildStringStr ("%s_map.jpg",Gbl.UniqueNameEncrypted),
@ -870,15 +858,12 @@ static void Pho_UpdatePhoto1 (struct UsrData *UsrDat)
Par_GetParToText ("FileName",Gbl.Usrs.FileNamePhoto,NAME_MAX); // Example of FileNamePhoto: "4924a838630e_016"
/***** Convert the temporary photo resulting of the processing to the current photo of the user *****/
snprintf (PathPhotoTmp,sizeof (PathPhotoTmp),
"%s/%s_paso3.jpg",
Cfg_PATH_PHOTO_TMP_PUBLIC,
Gbl.Usrs.FileNamePhoto);
snprintf (PathPhotoTmp,sizeof (PathPhotoTmp),"%s/%s_paso3.jpg",
Cfg_PATH_PHOTO_TMP_PUBLIC,Gbl.Usrs.FileNamePhoto);
if (Fil_CheckIfPathExists (PathPhotoTmp)) // The file with the selected photo exists
{
/* Copy the temporary file of the third (last) step resulting of the processing to the directory of private photos */
snprintf (PathRelPhoto,sizeof (PathRelPhoto),
"%s/%02u/%ld.jpg",
snprintf (PathRelPhoto,sizeof (PathRelPhoto),"%s/%02u/%ld.jpg",
Cfg_PATH_PHOTO_PRIVATE,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
Fil_FastCopyOfFiles (PathPhotoTmp,PathRelPhoto);
@ -1030,13 +1015,11 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX +
if (UsrDat->Photo[0])
{
/***** Make path to public photo *****/
snprintf (PathPublPhoto,sizeof (PathPublPhoto),
"%s/%s.jpg",
snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg",
Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo);
/***** Make path to private photo from public directory *****/
snprintf (PathPrivPhoto,sizeof (PathPrivPhoto),
"%s/%02u/%ld.jpg",
snprintf (PathPrivPhoto,sizeof (PathPrivPhoto),"%s/%02u/%ld.jpg",
Cfg_PATH_PHOTO_PRIVATE,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
@ -1047,8 +1030,7 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX +
" to access to user's private photo");
/***** Create the public URL of the photo *****/
snprintf (PhotoURL,PATH_MAX + 1,
"%s/%s.jpg",
snprintf (PhotoURL,PATH_MAX + 1,"%s/%s.jpg",
Cfg_URL_PHOTO_PUBLIC,UsrDat->Photo);
return true;
@ -1069,10 +1051,8 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX +
bool Pho_CheckIfPrivPhotoExists (long UsrCod,char PathPrivRelPhoto[PATH_MAX + 1])
{
/***** Make path to private photo *****/
snprintf (PathPrivRelPhoto,PATH_MAX + 1,
"%s/%02u/%ld.jpg",
Cfg_PATH_PHOTO_PRIVATE,
(unsigned) (UsrCod % 100),UsrCod);
snprintf (PathPrivRelPhoto,PATH_MAX + 1,"%s/%02u/%ld.jpg",
Cfg_PATH_PHOTO_PRIVATE,(unsigned) (UsrCod % 100),UsrCod);
return Fil_CheckIfPathExists (PathPrivRelPhoto);
}
@ -1095,16 +1075,14 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat)
Pho_ClearPhotoName (UsrDat->UsrCod);
/***** Remove public link *****/
snprintf (PathPublPhoto,sizeof (PathPublPhoto),
"%s/%s.jpg",
snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg",
Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo);
if (Fil_CheckIfPathExists (PathPublPhoto)) // Public link exists
if (unlink (PathPublPhoto)) // Remove public link
NumErrors++;
/***** Remove photo *****/
snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),
"%s/%02u/%ld.jpg",
snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),"%s/%02u/%ld.jpg",
Cfg_PATH_PHOTO_PRIVATE,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Photo exists
@ -1115,7 +1093,7 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat)
/***** Remove original photo *****/
snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),
"%s/%02u/%ld_original.jpg",
"%s/%02u/%ld_original.jpg",
Cfg_PATH_PHOTO_PRIVATE,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Original photo exists
@ -1166,14 +1144,12 @@ void Pho_UpdatePhotoName (struct UsrData *UsrDat)
Gbl.UniqueNameEncrypted,UsrDat->UsrCod);
/***** Remove the old symbolic link to photo *****/
snprintf (PathPublPhoto,sizeof (PathPublPhoto),
"%s/%s.jpg",
snprintf (PathPublPhoto,sizeof (PathPublPhoto),"%s/%s.jpg",
Cfg_PATH_PHOTO_PUBLIC,UsrDat->Photo);
unlink (PathPublPhoto); // Remove public link
/***** Update photo name in user's data *****/
Str_Copy (UsrDat->Photo,Gbl.UniqueNameEncrypted,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Str_Copy (UsrDat->Photo,Gbl.UniqueNameEncrypted,sizeof (UsrDat->Photo) - 1);
}
/*****************************************************************************/
@ -1209,7 +1185,7 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
Frm_StartFormUnique (ActSeeOthPubPrf);
else
Frm_StartForm (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_LINK",NULL);
}
@ -1368,8 +1344,7 @@ void Pho_CalcPhotoDegree (void)
TypeOfAverage++)
{
snprintf (DirAvgPhotosRelPath[TypeOfAverage],
sizeof (DirAvgPhotosRelPath[TypeOfAverage]),
"%s/%s",
sizeof (DirAvgPhotosRelPath[TypeOfAverage]),"%s/%s",
Cfg_PATH_PHOTO_PUBLIC,Pho_StrAvgPhotoDirs[TypeOfAverage]);
Fil_CreateDirIfNotExists (DirAvgPhotosRelPath[TypeOfAverage]);
}
@ -1656,8 +1631,7 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role,
/***** Call to program to calculate average photo *****/
if (*NumStdsWithPhoto)
{
snprintf (StrCallToProgram,sizeof (StrCallToProgram),
"%s %s %s",
snprintf (StrCallToProgram,sizeof (StrCallToProgram),"%s %s %s",
Pho_StrAvgPhotoPrograms[TypeOfAverage],
FileNamePhotoNames,PathRelAvgPhoto);
ReturnCode = system (StrCallToProgram);
@ -2058,7 +2032,7 @@ static void Pho_PutLinkToCalculateDegreeStats (const struct Pho_DegPhotos *DegPh
EstimatedTimeToComputeAvgPhotoInMicroseconds = Pho_GetTimeToComputeAvgPhoto (Degs.Lst[NumDeg].DegCod);
if (EstimatedTimeToComputeAvgPhotoInMicroseconds == -1L)
Str_Copy (StrEstimatedTimeToComputeAvgPhoto,Txt_unknown_TIME,
Dat_MAX_BYTES_TIME);
sizeof (StrEstimatedTimeToComputeAvgPhoto) - 1);
else
Sta_WriteTime (StrEstimatedTimeToComputeAvgPhoto,
EstimatedTimeToComputeAvgPhotoInMicroseconds);
@ -2502,15 +2476,13 @@ static void Pho_ShowDegreeAvgPhotoAndStat (const struct Deg_Degree *Deg,
if (ShowDegPhoto)
{
snprintf (PathRelAvgPhoto,sizeof (PathRelAvgPhoto),
"%s/%s/%ld_%s.jpg",
snprintf (PathRelAvgPhoto,sizeof (PathRelAvgPhoto),"%s/%s/%ld_%s.jpg",
Cfg_PATH_PHOTO_PUBLIC,
Pho_StrAvgPhotoDirs[DegPhotos->TypeOfAverage],
Deg->DegCod,Usr_StringsSexDB[Sex]);
if (Fil_CheckIfPathExists (PathRelAvgPhoto))
{
snprintf (PhotoURL,sizeof (PhotoURL),
"%s/%s/%ld_%s.jpg",
snprintf (PhotoURL,sizeof (PhotoURL),"%s/%s/%ld_%s.jpg",
Cfg_URL_PHOTO_PUBLIC,
Pho_StrAvgPhotoDirs[DegPhotos->TypeOfAverage],
Deg->DegCod,Usr_StringsSexDB[Sex]);

View File

@ -397,8 +397,8 @@ void Plc_GetListPlaces (struct Plc_Places *Places)
Places->Num = (unsigned) NumRows;
/***** Create list with courses in centre *****/
if ((Places->Lst = (struct Plc_Place *) calloc (NumRows,sizeof (struct Plc_Place))) == NULL)
Lay_NotEnoughMemoryExit ();
if ((Places->Lst = calloc (NumRows,sizeof (*Places->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the places *****/
for (NumPlc = 0;
@ -414,13 +414,9 @@ void Plc_GetListPlaces (struct Plc_Places *Places)
if ((Plc->PlcCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of place.");
/* Get the short name of the place (row[1]) */
Str_Copy (Plc->ShrtName,row[1],
Plc_MAX_BYTES_PLACE_SHRT_NAME);
/* Get the full name of the place (row[2]) */
Str_Copy (Plc->FullName,row[2],
Plc_MAX_BYTES_PLACE_FULL_NAME);
/* Get the short (row[1]) and full (row[2]) names of the place */
Str_Copy (Plc->ShrtName,row[1],sizeof (Plc->ShrtName) - 1);
Str_Copy (Plc->FullName,row[2],sizeof (Plc->FullName) - 1);
/* Get number of centres in this place (row[3]) */
if (sscanf (row[3],"%u",&Plc->NumCtrs) != 1)
@ -454,17 +450,13 @@ void Plc_GetDataOfPlaceByCod (struct Plc_Place *Plc)
/***** Check if place code is correct *****/
if (Plc->PlcCod < 0)
{
Str_Copy (Plc->ShrtName,Txt_Place_unspecified,
Plc_MAX_BYTES_PLACE_SHRT_NAME);
Str_Copy (Plc->FullName,Txt_Place_unspecified,
Plc_MAX_BYTES_PLACE_FULL_NAME);
Str_Copy (Plc->ShrtName,Txt_Place_unspecified,sizeof (Plc->ShrtName) - 1);
Str_Copy (Plc->FullName,Txt_Place_unspecified,sizeof (Plc->FullName) - 1);
}
else if (Plc->PlcCod == 0)
{
Str_Copy (Plc->ShrtName,Txt_Another_place,
Plc_MAX_BYTES_PLACE_SHRT_NAME);
Str_Copy (Plc->FullName,Txt_Another_place,
Plc_MAX_BYTES_PLACE_FULL_NAME);
Str_Copy (Plc->ShrtName,Txt_Another_place,sizeof (Plc->ShrtName) - 1);
Str_Copy (Plc->FullName,Txt_Another_place,sizeof (Plc->FullName) - 1);
}
else if (Plc->PlcCod > 0)
{
@ -496,13 +488,9 @@ void Plc_GetDataOfPlaceByCod (struct Plc_Place *Plc)
/* Get row */
row = mysql_fetch_row (mysql_res);
/* Get the short name of the place (row[0]) */
Str_Copy (Plc->ShrtName,row[0],
Plc_MAX_BYTES_PLACE_SHRT_NAME);
/* Get the full name of the place (row[1]) */
Str_Copy (Plc->FullName,row[1],
Plc_MAX_BYTES_PLACE_FULL_NAME);
/* Get the short (row[0]) and full (row[1]) names of the place */
Str_Copy (Plc->ShrtName,row[0],sizeof (Plc->ShrtName) - 1);
Str_Copy (Plc->FullName,row[1],sizeof (Plc->FullName) - 1);
/* Get number of centres in this place (row[2]) */
if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1)
@ -754,8 +742,7 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update place name *****/
Str_Copy (CurrentPlcName,NewPlcName,
MaxBytes);
Str_Copy (CurrentPlcName,NewPlcName,MaxBytes);
}
/*****************************************************************************/
@ -952,8 +939,8 @@ static void Plc_EditingPlaceConstructor (void)
Lay_ShowErrorAndExit ("Error initializing place.");
/***** Allocate memory for place *****/
if ((Plc_EditingPlc = (struct Plc_Place *) malloc (sizeof (struct Plc_Place))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for place.");
if ((Plc_EditingPlc = malloc (sizeof (*Plc_EditingPlc))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset place *****/
Plc_EditingPlc->PlcCod = -1L;

View File

@ -131,9 +131,7 @@ void Plg_ListPlugins (void)
{
Plg = &(Gbl.Plugins.Lst[NumPlg]);
snprintf (URL,sizeof (URL),
"%s%s",
Plg->URL,Gbl.Session.Id);
snprintf (URL,sizeof (URL),"%s%s",Plg->URL,Gbl.Session.Id);
/* Plugin logo */
// TODO: Change plugin icons to 32x32
@ -242,7 +240,8 @@ static void Plg_GetListPlugins (void)
Gbl.Plugins.Num = (unsigned) NumRows;
/***** Create list with plugins *****/
if ((Gbl.Plugins.Lst = (struct Plugin *) calloc ((size_t) Gbl.Plugins.Num,sizeof (struct Plugin))) == NULL)
if ((Gbl.Plugins.Lst = calloc (Gbl.Plugins.Num,
sizeof (*Gbl.Plugins.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the plugins *****/
@ -259,29 +258,14 @@ static void Plg_GetListPlugins (void)
if ((Plg->PlgCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of plugin.");
/* Get the name of the plugin (row[1]) */
Str_Copy (Plg->Name,row[1],
Plg_MAX_BYTES_PLUGIN_NAME);
/* Get the description of the plugin (row[2]) */
Str_Copy (Plg->Description,row[2],
Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
/* Get the logo of the plugin (row[3]) */
Str_Copy (Plg->Logo,row[3],
Plg_MAX_BYTES_PLUGIN_LOGO);
/* Get the application key of the plugin (row[4]) */
Str_Copy (Plg->AppKey,row[4],
Plg_MAX_BYTES_PLUGIN_APP_KEY);
/* Get the URL of the plugin (row[5]) */
Str_Copy (Plg->URL,row[5],
Cns_MAX_BYTES_WWW);
/* Get the IP of the plugin (row[6]) */
Str_Copy (Plg->IP,row[6],
Cns_MAX_BYTES_IP);
/* Get name (row[1]), description (row[2), logo (row[3]),
* application key (row[4]), URL (row[5]) and IP (row[6]) of the plugin */
Str_Copy (Plg->Name ,row[1],sizeof (Plg->Name ) - 1);
Str_Copy (Plg->Description,row[2],sizeof (Plg->Description) - 1);
Str_Copy (Plg->Logo ,row[3],sizeof (Plg->Logo ) - 1);
Str_Copy (Plg->AppKey ,row[4],sizeof (Plg->AppKey ) - 1);
Str_Copy (Plg->URL ,row[5],sizeof (Plg->URL ) - 1);
Str_Copy (Plg->IP ,row[6],sizeof (Plg->IP ) - 1);
}
}
else
@ -329,29 +313,14 @@ bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
/* Get row */
row = mysql_fetch_row (mysql_res);
/* Get the name of the plugin (row[0]) */
Str_Copy (Plg->Name,row[0],
Plg_MAX_BYTES_PLUGIN_NAME);
/* Get the description of the plugin (row[1]) */
Str_Copy (Plg->Description,row[1],
Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
/* Get the logo of the plugin (row[2]) */
Str_Copy (Plg->Logo,row[2],
Plg_MAX_BYTES_PLUGIN_LOGO);
/* Get the application key of the plugin (row[3]) */
Str_Copy (Plg->AppKey,row[3],
Plg_MAX_BYTES_PLUGIN_APP_KEY);
/* Get the URL of the plugin (row[4]) */
Str_Copy (Plg->URL,row[4],
Cns_MAX_BYTES_WWW);
/* Get the IP of the plugin (row[5]) */
Str_Copy (Plg->IP,row[5],
Cns_MAX_BYTES_IP);
/* Get name (row[0]), description (row[1]), logo (row[2]),
application key (row[3]), URL (row[4]) and IP (row[5]) of the plugin */
Str_Copy (Plg->Name ,row[0],sizeof (Plg->Name ) - 1);
Str_Copy (Plg->Description,row[1],sizeof (Plg->Description) - 1);
Str_Copy (Plg->Logo ,row[2],sizeof (Plg->Logo ) - 1);
Str_Copy (Plg->AppKey ,row[3],sizeof (Plg->AppKey ) - 1);
Str_Copy (Plg->URL ,row[4],sizeof (Plg->URL ) - 1);
Str_Copy (Plg->IP ,row[5],sizeof (Plg->IP ) - 1);
}
else
PluginFound = false;
@ -595,8 +564,7 @@ void Plg_RenamePlugin (void)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update name *****/
Str_Copy (Plg_EditingPlg->Name,NewPlgName,
Plg_MAX_BYTES_PLUGIN_NAME);
Str_Copy (Plg_EditingPlg->Name,NewPlgName,sizeof (Plg_EditingPlg->Name) - 1);
}
/*****************************************************************************/
@ -654,7 +622,7 @@ void Plg_ChangePlgDescription (void)
/***** Update description *****/
Str_Copy (Plg_EditingPlg->Description,NewDescription,
Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
sizeof (Plg_EditingPlg->Description) - 1);
}
/*****************************************************************************/
@ -697,8 +665,7 @@ void Plg_ChangePlgLogo (void)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update logo *****/
Str_Copy (Plg_EditingPlg->Logo,NewLogo,
Plg_MAX_BYTES_PLUGIN_LOGO);
Str_Copy (Plg_EditingPlg->Logo,NewLogo,sizeof (Plg_EditingPlg->Logo) - 1);
}
/*****************************************************************************/
@ -742,7 +709,7 @@ void Plg_ChangePlgAppKey (void)
/***** Update app key *****/
Str_Copy (Plg_EditingPlg->AppKey,NewAppKey,
Plg_MAX_BYTES_PLUGIN_APP_KEY);
sizeof (Plg_EditingPlg->AppKey) - 1);
}
/*****************************************************************************/
@ -785,8 +752,7 @@ void Plg_ChangePlgURL (void)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update URL *****/
Str_Copy (Plg_EditingPlg->URL,NewURL,
Cns_MAX_BYTES_WWW);
Str_Copy (Plg_EditingPlg->URL,NewURL,sizeof (Plg_EditingPlg->URL) - 1);
}
/*****************************************************************************/
@ -829,8 +795,7 @@ void Plg_ChangePlgIP (void)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update IP *****/
Str_Copy (Plg_EditingPlg->IP,NewIP,
Cns_MAX_BYTES_IP);
Str_Copy (Plg_EditingPlg->IP,NewIP,sizeof (Plg_EditingPlg->IP) - 1);
}
/*****************************************************************************/
@ -1059,8 +1024,8 @@ static void Plg_EditingPluginConstructor (void)
Lay_ShowErrorAndExit ("Error initializing plugin.");
/***** Allocate memory for plugin *****/
if ((Plg_EditingPlg = (struct Plugin *) malloc (sizeof (struct Plugin))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for plugin.");
if ((Plg_EditingPlg = malloc (sizeof (*Plg_EditingPlg))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset plugin *****/
Plg_EditingPlg->PlgCod = -1L;

View File

@ -139,16 +139,14 @@ void Prf_SeeSocialProfiles (void)
/*****************************************************************************/
char *Prf_GetURLPublicProfile (char URL[Cns_MAX_BYTES_WWW + 1],
const char *NicknameWithoutArroba)
const char *NickWithoutArroba)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
/***** Build URL using nickname *****/
snprintf (URL,Cns_MAX_BYTES_WWW + 1,
"%s/%s?usr=@%s",
Cfg_URL_SWAD_CGI,
Lan_STR_LANG_ID[Gbl.Prefs.Language],
NicknameWithoutArroba);
snprintf (URL,Cns_MAX_BYTES_WWW + 1,"%s/%s?usr=@%s",
Cfg_URL_SWAD_CGI,Lan_STR_LANG_ID[Gbl.Prefs.Language],
NickWithoutArroba);
return URL;
}
@ -162,7 +160,7 @@ void Prf_PutLinkMyPublicProfile (void)
extern const char *Txt_My_public_profile;
Lay_PutContextualLinkIconText (ActSeeOthPubPrf,NULL,
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod,
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod,
"user-circle.svg",
Txt_My_public_profile);
}
@ -192,7 +190,7 @@ void Prf_RequestUserProfile (void)
extern const char *The_ClassFormInBox[The_NUM_THEMES];
extern const char *Txt_Nickname;
extern const char *Txt_Continue;
char NicknameWithArroba[1 + Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
char NickWithArroba[1 + Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
if (Gbl.Usrs.Me.Logged)
{
@ -217,10 +215,9 @@ void Prf_RequestUserProfile (void)
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
HTM_TxtColonNBSP (Txt_Nickname);
snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
"@%s",
snprintf (NickWithArroba,sizeof (NickWithArroba),"@%s",
Gbl.Usrs.Me.UsrDat.Nickname);
HTM_INPUT_TEXT ("usr",Nck_MAX_BYTES_NICKNAME_FROM_FORM,NicknameWithArroba,
HTM_INPUT_TEXT ("usr",Nck_MAX_BYTES_NICKNAME_FROM_FORM,NickWithArroba,
HTM_DONT_SUBMIT_ON_CHANGE,
"size=\"18\"");
HTM_LABEL_End ();
@ -522,7 +519,7 @@ static void Prf_ShowTimeSinceFirstClick (const struct UsrData *UsrDat,
}
else // First click time is unknown or user never logged
/***** Button to fetch and store user's figures *****/
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
Prf_EndListItem ();
}
@ -625,7 +622,7 @@ static void Prf_ShowNumClicks (const struct UsrData *UsrDat,
}
else // Number of clicks is unknown
/***** Button to fetch and store user's figures *****/
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
Prf_EndListItem ();
}
@ -662,7 +659,7 @@ static void Prf_ShowNumFileViews (const struct UsrData *UsrDat,
}
else // Number of file views is unknown
/***** Button to fetch and store user's figures *****/
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
Prf_EndListItem ();
}
@ -699,7 +696,7 @@ static void Prf_ShowNumSocialPublications (const struct UsrData *UsrDat,
}
else // Number of social publications is unknown
/***** Button to fetch and store user's figures *****/
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
Prf_EndListItem ();
}
@ -736,7 +733,7 @@ static void Prf_ShowNumForumPosts (const struct UsrData *UsrDat,
}
else // Number of forum posts is unknown
/***** Button to fetch and store user's figures *****/
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
Prf_EndListItem ();
}
@ -773,7 +770,7 @@ static void Prf_ShowNumMessagesSent (const struct UsrData *UsrDat,
}
else // Number of messages sent is unknown
/***** Button to fetch and store user's figures *****/
Prf_PutLinkCalculateFigures (UsrDat->EncryptedUsrCod);
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
Prf_EndListItem ();
}
@ -1272,8 +1269,7 @@ static void Prf_CreateUsrFigures (long UsrCod,const struct UsrFigures *UsrFigure
if (CreatingMyOwnAccount)
// This is the first click
Str_Copy (SubQueryFirstClickTime,"NOW()",
Prf_MAX_BYTES_SUBQUERY_FIRST_CLICK_TIME);
Str_Copy (SubQueryFirstClickTime,"NOW()",sizeof (SubQueryFirstClickTime) - 1);
else
sprintf (SubQueryFirstClickTime,"FROM_UNIXTIME(%ld)",
(long) UsrFigures->FirstClickTimeUTC); // 0 ==> unknown first click time or user never logged
@ -1788,7 +1784,7 @@ static void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank,bool ItsM
if (Visible)
{
Frm_StartForm (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_BUTTON_SUBMIT_Begin (Txt_Another_user_s_profile,
ItsMe ? "BT_LINK RANK_USR DAT_SMALL_N" :
"BT_LINK RANK_USR DAT_SMALL",

View File

@ -53,7 +53,7 @@ struct UsrFigures
void Prf_SeeSocialProfiles (void);
char *Prf_GetURLPublicProfile (char URL[Cns_MAX_BYTES_WWW + 1],
const char *NicknameWithoutArroba);
const char *NickWithoutArroba);
void Prf_PutLinkMyPublicProfile (void);
void Prf_PutLinkRequestAnotherUserProfile (void);
void Prf_RequestUserProfile (void);

View File

@ -666,8 +666,8 @@ static void Prg_CreateLevels (void)
4 1
5 0 <--- Used to create a new item
*/
if ((Prg_Gbl.Levels = (struct Level *) calloc ((size_t) (1 + MaxLevel + 1),
sizeof (struct Level))) == NULL)
if ((Prg_Gbl.Levels = calloc (1 + MaxLevel + 1,
sizeof (*Prg_Gbl.Levels))) == NULL)
Lay_NotEnoughMemoryExit ();
}
else
@ -778,9 +778,7 @@ static void Prg_PutFormsToRemEditOneItem (unsigned NumItem,
char StrItemIndex[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
/***** Initialize item index string *****/
snprintf (StrItemIndex,sizeof (StrItemIndex),
"%u",
Item->Hierarchy.Index);
snprintf (StrItemIndex,sizeof (StrItemIndex),"%u",Item->Hierarchy.Index);
switch (Gbl.Usrs.Me.Role.Logged)
{
@ -992,9 +990,8 @@ static void Prg_GetListItems (void)
if (Prg_Gbl.List.NumItems) // Items found...
{
/***** Create list of program items *****/
if ((Prg_Gbl.List.Items =
(struct ProgramItemHierarchy *) calloc ((size_t) Prg_Gbl.List.NumItems,
sizeof (struct ProgramItemHierarchy))) == NULL)
if ((Prg_Gbl.List.Items = calloc (Prg_Gbl.List.NumItems,
sizeof (*Prg_Gbl.List.Items))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the program items codes *****/
@ -1116,8 +1113,7 @@ static void Prg_GetDataOfItem (struct ProgramItem *Item,
Item->Open = (row[7][0] == '1');
/* Get the title of the program item (row[8]) */
Str_Copy (Item->Title,row[8],
Prg_MAX_BYTES_PROGRAM_ITEM_TITLE);
Str_Copy (Item->Title,row[8],sizeof (Item->Title) - 1);
}
/***** Free structure that stores the query result *****/
@ -1179,8 +1175,7 @@ static void Prg_GetItemTxtFromDB (long ItmCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
{
/* Get info text */
row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
}
else
Txt[0] = '\0';

View File

@ -814,7 +814,7 @@ void Prj_PutParams (struct Prj_Filter *Filter,
/***** Put another user's code *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
/***** Put selected users' codes *****/
if (Filter->Who == Usr_WHO_SELECTED)
@ -2236,7 +2236,7 @@ static void Prj_ShowTableAllProjectsMembersWithARole (const struct Prj_Project *
HTM_Txt (Gbl.Usrs.Other.UsrDat.Surname1);
if (Gbl.Usrs.Other.UsrDat.Surname2[0])
HTM_TxtF ("&nbsp;%s",Gbl.Usrs.Other.UsrDat.Surname2);
HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FirstName);
HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FrstName);
HTM_LI_End ();
}
}
@ -2506,7 +2506,7 @@ static void Prj_AddUsrsToProject (Prj_RoleInProject_t RoleInProject)
while (*Ptr)
{
/* Get next user */
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
@ -3072,7 +3072,8 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
NumPrjsFromDB = (unsigned) NumRows;
/***** Create list of projects *****/
if ((Projects->LstPrjCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
if ((Projects->LstPrjCods = calloc (NumRows,
sizeof (*Projects->LstPrjCods))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the projects codes *****/
@ -3226,25 +3227,13 @@ void Prj_GetDataOfProjectByCod (struct Prj_Project *Prj)
/* Get modification date/time (row[9] holds the modification UTC time) */
Prj->ModifTime = Dat_GetUNIXTimeFromStr (row[9]);
/* Get the title of the project (row[10]) */
Str_Copy (Prj->Title,row[10],
Prj_MAX_BYTES_PROJECT_TITLE);
/* Get the description of the project (row[11]) */
Str_Copy (Prj->Description,row[11],
Cns_MAX_BYTES_TEXT);
/* Get the required knowledge for the project (row[12]) */
Str_Copy (Prj->Knowledge,row[12],
Cns_MAX_BYTES_TEXT);
/* Get the required materials for the project (row[13]) */
Str_Copy (Prj->Materials,row[13],
Cns_MAX_BYTES_TEXT);
/* Get the URL of the project (row[14]) */
Str_Copy (Prj->URL,row[14],
Cns_MAX_BYTES_WWW);
/* Get title (row[10]), description (row[11]), required knowledge (row[12]),
required materials (row[13]) and URL (row[14]) of the project */
Str_Copy (Prj->Title ,row[10],sizeof (Prj->Title ) - 1);
Str_Copy (Prj->Description,row[11],Cns_MAX_BYTES_TEXT);
Str_Copy (Prj->Knowledge ,row[12],Cns_MAX_BYTES_TEXT);
Str_Copy (Prj->Materials ,row[13],Cns_MAX_BYTES_TEXT);
Str_Copy (Prj->URL ,row[14],sizeof (Prj->URL ) - 1);
}
/***** Free structure that stores the query result *****/
@ -3409,8 +3398,7 @@ void Prj_RemoveProject (void)
Brw_RemovePrjFilesFromDB (Prj.PrjCod);
/***** Remove directory of the project *****/
snprintf (PathRelPrj,sizeof (PathRelPrj),
"%s/%ld/%s/%02u/%ld",
snprintf (PathRelPrj,sizeof (PathRelPrj),"%s/%ld/%s/%02u/%ld",
Cfg_PATH_CRS_PRIVATE,Prj.CrsCod,Cfg_FOLDER_PRJ,
(unsigned) (Prj.PrjCod % 100),Prj.PrjCod);
Fil_RemoveTree (PathRelPrj);
@ -3815,13 +3803,13 @@ static void Prj_EditOneProjectTxtArea (const char *Id,
void Prj_AllocMemProject (struct Prj_Project *Prj)
{
if ((Prj->Description = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((Prj->Description = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if ((Prj->Knowledge = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((Prj->Knowledge = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
if ((Prj->Materials = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((Prj->Materials = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
}

View File

@ -212,7 +212,8 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
if (Gbl.Crs.Records.LstFields.Num)
{
/***** Create a list of fields *****/
if ((Gbl.Crs.Records.LstFields.Lst = (struct RecordField *) calloc (Gbl.Crs.Records.LstFields.Num,sizeof (struct RecordField))) == NULL)
if ((Gbl.Crs.Records.LstFields.Lst = calloc (Gbl.Crs.Records.LstFields.Num,
sizeof (*Gbl.Crs.Records.LstFields.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the fields *****/
@ -229,7 +230,7 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
/* Name of the field (row[1]) */
Str_Copy (Gbl.Crs.Records.LstFields.Lst[NumRow].Name,row[1],
Rec_MAX_BYTES_NAME_FIELD);
sizeof (Gbl.Crs.Records.LstFields.Lst[NumRow].Name) - 1);
/* Number of lines (row[2]) */
Gbl.Crs.Records.LstFields.Lst[NumRow].NumLines = Rec_ConvertToNumLinesField (row[2]);
@ -291,8 +292,7 @@ void Rec_ListFieldsRecordsForEdition (void)
HTM_TD_Begin ("class=\"CM\"");
Frm_StartForm (ActChgRowFie);
Rec_PutParamFieldCod (&Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
snprintf (StrNumLines,sizeof (StrNumLines),
"%u",
snprintf (StrNumLines,sizeof (StrNumLines),"%u",
Gbl.Crs.Records.LstFields.Lst[NumField].NumLines);
HTM_INPUT_TEXT ("NumLines",Cns_MAX_DECIMAL_DIGITS_UINT,StrNumLines,
HTM_SUBMIT_ON_CHANGE,
@ -362,8 +362,7 @@ void Rec_ShowFormCreateRecordField (void)
/***** Number of lines in form ******/
HTM_TD_Begin ("class=\"CM\"");
snprintf (StrNumLines,sizeof (StrNumLines),
"%u",
snprintf (StrNumLines,sizeof (StrNumLines),"%u",
Gbl.Crs.Records.Field.NumLines);
HTM_INPUT_TEXT ("NumLines",Cns_MAX_DECIMAL_DIGITS_UINT,StrNumLines,
HTM_DONT_SUBMIT_ON_CHANGE,
@ -692,8 +691,7 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD
row = mysql_fetch_row (mysql_res);
/* Name of the field */
Str_Copy (Name,row[0],
Rec_MAX_BYTES_NAME_FIELD);
Str_Copy (Name,row[0],Rec_MAX_BYTES_NAME_FIELD);
/* Number of lines of the field (row[1]) */
*NumLines = Rec_ConvertToNumLinesField (row[1]);
@ -782,7 +780,7 @@ void Rec_RenameField (void)
/***** Show the form again *****/
Str_Copy (Gbl.Crs.Records.Field.Name,NewFieldName,
Rec_MAX_BYTES_NAME_FIELD);
sizeof (Gbl.Crs.Records.Field.Name) - 1);
Rec_ReqEditRecordFields ();
}
@ -971,15 +969,13 @@ static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView)
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
{
/* Start container for this user */
snprintf (RecordSectionId,sizeof (RecordSectionId),
"record_%u",
NumUsr);
snprintf (RecordSectionId,sizeof (RecordSectionId),"record_%u",NumUsr);
HTM_SECTION_Begin (RecordSectionId);
if (Gbl.Action.Act == ActPrnRecSevGst &&
@ -1171,7 +1167,7 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
@ -1182,9 +1178,7 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
/* Start container for this user */
snprintf (RecordSectionId,sizeof (RecordSectionId),
"record_%u",
NumUsr);
snprintf (RecordSectionId,sizeof (RecordSectionId),"record_%u",NumUsr);
HTM_SECTION_Begin (RecordSectionId);
if (Gbl.Action.Act == ActPrnRecSevStd &&
@ -1265,9 +1259,7 @@ static void Rec_ShowRecordOneTchCrs (void)
bool ShowOfficeHours;
/***** Width for office hours *****/
snprintf (Width,sizeof (Width),
"%upx",
Rec_RECORD_WIDTH);
snprintf (Width,sizeof (Width),"%upx",Rec_RECORD_WIDTH);
/***** Get if teacher has accepted enrolment in current course *****/
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
@ -1354,9 +1346,7 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
Usr_GetListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
/***** Width for office hours *****/
snprintf (Width,sizeof (Width),
"%upx",
Rec_RECORD_WIDTH);
snprintf (Width,sizeof (Width),"%upx",Rec_RECORD_WIDTH);
/***** Assign users listing type depending on current action *****/
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
@ -1396,7 +1386,7 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
@ -1407,9 +1397,7 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
/* Start container for this user */
snprintf (RecordSectionId,sizeof (RecordSectionId),
"record_%u",
NumUsr);
snprintf (RecordSectionId,sizeof (RecordSectionId),"record_%u",NumUsr);
HTM_SECTION_Begin (RecordSectionId);
if (Gbl.Action.Act == ActPrnRecSevTch &&
@ -1530,7 +1518,7 @@ static void Rec_WriteFormShowOfficeHoursSeveralTchs (bool ShowOfficeHours)
static void Rec_PutParamsShowOfficeHoursOneTch (void)
{
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
}
@ -1707,7 +1695,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
Frm_StartFormAnchor (ActRcvRecOthUsr,Anchor);
Par_PutHiddenParamLong (NULL,"OriginalActCod",
Act_GetActCod (ActSeeRecSevStd)); // Original action, used to know where we came from
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
if (TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS)
Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected);
}
@ -1717,9 +1705,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
}
/***** Begin box and table *****/
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
snprintf (StrRecordWidth,sizeof (StrRecordWidth),"%upx",Rec_RECORD_WIDTH);
Box_BoxTableBegin (StrRecordWidth,NULL,
NULL,NULL,
Rec_RecordHelp[TypeOfView],Box_NOT_CLOSABLE,2);
@ -1821,8 +1807,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
{
if (ThisFieldHasText)
{
Str_Copy (Text,row[0],
Cns_MAX_BYTES_TEXT);
Str_Copy (Text,row[0],sizeof (Text));
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Text,Cns_MAX_BYTES_TEXT,false);
HTM_Txt (Text);
@ -1881,8 +1866,7 @@ void Rec_GetFieldsCrsRecordFromForm (void)
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
{
/* Get text from the form */
snprintf (FieldParamName,sizeof (FieldParamName),
"Field%ld",
snprintf (FieldParamName,sizeof (FieldParamName),"Field%ld",
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
Par_GetParToHTML (FieldParamName,Gbl.Crs.Records.LstFields.Lst[NumField].Text,Cns_MAX_BYTES_TEXT);
}
@ -1994,7 +1978,7 @@ void Rec_AllocMemFieldsRecordsCrs (void)
NumField++)
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
/* Allocate memory for the texts of the fields */
if ((Gbl.Crs.Records.LstFields.Lst[NumField].Text = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((Gbl.Crs.Records.LstFields.Lst[NumField].Text = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
}
@ -2300,7 +2284,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
break;
}
Frm_StartForm (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); // Existing user
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); // Existing user
break;
case Rec_SHA_OTHER_NEW_USR_FORM:
switch (Gbl.Action.Act)
@ -2635,7 +2619,7 @@ static void Rec_PutIconsCommands (__attribute__((unused)) void *Args)
void Rec_PutParamUsrCodEncrypted (__attribute__((unused)) void *Args)
{
Usr_PutParamUsrCodEncrypted (Gbl.Record.UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (Gbl.Record.UsrDat->EnUsrCod);
}
static void Rec_PutParamsMyTsts (__attribute__((unused)) void *Args)
@ -2661,7 +2645,7 @@ static void Rec_PutParamsWorks (__attribute__((unused)) void *Args)
static void Rec_PutParamsStudent (__attribute__((unused)) void *Args)
{
Par_PutHiddenParamString (NULL,"UsrCodStd",Gbl.Record.UsrDat->EncryptedUsrCod);
Par_PutHiddenParamString (NULL,"UsrCodStd",Gbl.Record.UsrDat->EnUsrCod);
Grp_PutParamAllGroups ();
}
@ -2747,7 +2731,7 @@ static void Rec_ShowFullName (struct UsrData *UsrDat)
HTM_DIV_Begin ("class=\"REC_NAME\"");
/***** First name *****/
HTM_Txt (UsrDat->FirstName);
HTM_Txt (UsrDat->FrstName);
HTM_BR ();
/***** Surname 1 *****/
@ -2780,7 +2764,7 @@ static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks)
/* Put form to go to public profile */
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
Frm_StartForm (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
Txt_Another_user_s_profile,
"BT_LINK REC_NICK",
@ -3236,14 +3220,14 @@ static void Rec_ShowFirstName (struct UsrData *UsrDat,bool PutForm)
HTM_TD_Begin ("colspan=\"2\" class=\"REC_C2_BOT DAT_N LM\"");
if (PutForm)
HTM_INPUT_TEXT ("FirstName",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
UsrDat->FirstName,
UsrDat->FrstName,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"FirstName\" class=\"REC_C2_BOT_INPUT\""
" required=\"required\"");
else if (UsrDat->FirstName[0])
else if (UsrDat->FrstName[0])
{
HTM_STRONG_Begin ();
HTM_Txt (UsrDat->FirstName);
HTM_Txt (UsrDat->FrstName);
HTM_STRONG_End ();
}
HTM_TD_End ();
@ -3700,8 +3684,7 @@ void Rec_GetUsrNameFromRecordForm (struct UsrData *UsrDat)
Str_ConvertToTitleType (Surname1);
// Surname 1 is mandatory, so avoid overwriting surname 1 with empty string
if (Surname1[0]) // New surname 1 not empty
Str_Copy (UsrDat->Surname1,Surname1,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Str_Copy (UsrDat->Surname1,Surname1,sizeof (UsrDat->Surname1) - 1);
/***** Get surname 2 *****/
Par_GetParToText ("Surname2",UsrDat->Surname2,
@ -3714,8 +3697,7 @@ void Rec_GetUsrNameFromRecordForm (struct UsrData *UsrDat)
Str_ConvertToTitleType (FirstName);
// First name is mandatory, so avoid overwriting first name with empty string
if (FirstName[0]) // New first name not empty
Str_Copy (UsrDat->FirstName,FirstName,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
Str_Copy (UsrDat->FrstName,FirstName,sizeof (UsrDat->FrstName) - 1);
/***** Build full name *****/
Usr_BuildFullName (UsrDat);
@ -3782,7 +3764,7 @@ void Rec_ShowMySharedRecordAndMore (void)
(1 << Rol_TCH))); // ...or a teacher in any course
/***** If user has no name and surname, sex... *****/
if (!Gbl.Usrs.Me.UsrDat.FirstName[0] ||
if (!Gbl.Usrs.Me.UsrDat.FrstName[0] ||
!Gbl.Usrs.Me.UsrDat.Surname1[0]) // 1. No name
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_name);
else if (Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN) // 2. No sex

View File

@ -343,14 +343,12 @@ static void Rep_GetCurrentDateTimeUTC (struct Rep_Report *Report)
{
/* Date and time as strings */
snprintf (Report->CurrentTimeUTC.StrDate,
sizeof (Report->CurrentTimeUTC.StrDate),
"%04d-%02d-%02d",
sizeof (Report->CurrentTimeUTC.StrDate),"%04d-%02d-%02d",
1900 + Report->tm_CurrentTime.tm_year, // year
1 + Report->tm_CurrentTime.tm_mon, // month
Report->tm_CurrentTime.tm_mday); // day of the month
snprintf (Report->CurrentTimeUTC.StrTime,
sizeof (Report->CurrentTimeUTC.StrTime),
"%02d:%02d:%02d",
sizeof (Report->CurrentTimeUTC.StrTime),"%02d:%02d:%02d",
Report->tm_CurrentTime.tm_hour, // hours
Report->tm_CurrentTime.tm_min, // minutes
Report->tm_CurrentTime.tm_sec); // seconds
@ -383,16 +381,14 @@ static void Rep_CreateNewReportFile (struct Rep_Report *Report)
/***** Unique directory for the file with the report *****/
/* 1. Create a directory using the leftmost 2 chars of a unique name */
snprintf (PathUniqueDirL,sizeof (PathUniqueDirL),
"%s/%c%c",
snprintf (PathUniqueDirL,sizeof (PathUniqueDirL),"%s/%c%c",
Cfg_PATH_REP_PUBLIC,
Gbl.UniqueNameEncrypted[0],
Gbl.UniqueNameEncrypted[1]);
Fil_CreateDirIfNotExists (PathUniqueDirL);
/* 2. Create a directory using the rightmost 41 chars of a unique name */
snprintf (PathUniqueDirR,sizeof (PathUniqueDirR),
"%s/%s",
snprintf (PathUniqueDirR,sizeof (PathUniqueDirR),"%s/%s",
PathUniqueDirL,
&Gbl.UniqueNameEncrypted[2]);
if (mkdir (PathUniqueDirR,(mode_t) 0xFFF))
@ -402,22 +398,19 @@ static void Rep_CreateNewReportFile (struct Rep_Report *Report)
snprintf (Report->FilenameReport,sizeof (Report->FilenameReport),
"%s_%06u_%06u.html",
Rep_FILENAME_ROOT,Report->CurrentTimeUTC.Date,Report->CurrentTimeUTC.Time);
snprintf (PathFileReport,sizeof (PathFileReport),
"%s/%s",
snprintf (PathFileReport,sizeof (PathFileReport),"%s/%s",
PathUniqueDirR,Report->FilenameReport);
if ((Gbl.F.Rep = fopen (PathFileReport,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not create report file.");
/***** Permalink *****/
snprintf (Permalink,sizeof (Permalink),
"%s/%c%c/%s/%s",
snprintf (Permalink,sizeof (Permalink),"%s/%c%c/%s/%s",
Cfg_URL_REP_PUBLIC,
Gbl.UniqueNameEncrypted[0],
Gbl.UniqueNameEncrypted[1],
&Gbl.UniqueNameEncrypted[2],
Report->FilenameReport);
Str_Copy (Report->Permalink,Permalink,
Cns_MAX_BYTES_WWW);
Str_Copy (Report->Permalink,Permalink,sizeof (Report->Permalink) - 1);
}
/*****************************************************************************/
@ -1439,8 +1432,7 @@ static void Rep_RemoveUsrReportsFiles (long UsrCod)
row = mysql_fetch_row (mysql_res);
/* Remove report directory and file */
snprintf (PathUniqueDirReport,sizeof (PathUniqueDirReport),
"%s/%s/%s",
snprintf (PathUniqueDirReport,sizeof (PathUniqueDirReport),"%s/%s/%s",
Cfg_PATH_REP_PUBLIC,row[0],row[1]);
Fil_RemoveTree (PathUniqueDirReport);
}

View File

@ -585,9 +585,7 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
Rooms->Num = (unsigned) NumRows;
/***** Create list with courses in centre *****/
if ((Rooms->Lst = (struct Roo_Room *)
calloc (NumRows,
sizeof (struct Roo_Room))) == NULL)
if ((Rooms->Lst = calloc (NumRows,sizeof (*Rooms->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the rooms *****/
@ -619,13 +617,9 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
/* Get type (row[4]) */
Room->Type = Roo_GetTypeFromString (row[4]);
/* Get the short name of the room (row[5]) */
Str_Copy (Room->ShrtName,row[5],
Roo_MAX_BYTES_SHRT_NAME);
/* Get the full name of the room (row[6]) */
Str_Copy (Room->FullName,row[6],
Roo_MAX_BYTES_FULL_NAME);
/* Get the short (row[5]) and full (row[6]) names of the room */
Str_Copy (Room->ShrtName,row[5],sizeof (Room->ShrtName) - 1);
Str_Copy (Room->FullName,row[6],sizeof (Room->FullName) - 1);
/* Get seating capacity in this room (row[7]) */
if (sscanf (row[7],"%u",&Room->Capacity) != 1)
@ -634,8 +628,7 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
case Roo_ONLY_SHRT_NAME:
default:
/* Get the short name of the room (row[1]) */
Str_Copy (Room->ShrtName,row[1],
Roo_MAX_BYTES_SHRT_NAME);
Str_Copy (Room->ShrtName,row[1],sizeof (Room->ShrtName) - 1);
break;
}
}
@ -693,13 +686,9 @@ static void Roo_GetDataOfRoomByCod (struct Roo_Room *Room)
/* Get type (row[3]) */
Room->Type = Roo_GetTypeFromString (row[3]);
/* Get the short name of the room (row[4]) */
Str_Copy (Room->ShrtName,row[4],
Roo_MAX_BYTES_SHRT_NAME);
/* Get the full name of the room (row[5]) */
Str_Copy (Room->FullName,row[5],
Roo_MAX_BYTES_FULL_NAME);
/* Get the short (row[4]) and full (row[5]) names of the room */
Str_Copy (Room->ShrtName,row[4],sizeof (Room->ShrtName) - 1);
Str_Copy (Room->FullName,row[5],sizeof (Room->FullName) - 1);
/* Get seating capacity in this room (row[6]) */
if (sscanf (row[6],"%u",&Room->Capacity) != 1)
@ -721,16 +710,16 @@ static void Roo_GetBldShrtName (struct Roo_Room *Room,const char *BldShrtNameFro
if (Room->BldCod < 0)
Str_Copy (Room->BldShrtName,Txt_No_assigned_building,
Bld_MAX_BYTES_SHRT_NAME);
sizeof (Room->BldShrtName) - 1);
else if (Room->BldCod == 0)
Str_Copy (Room->BldShrtName,Txt_Another_building,
Bld_MAX_BYTES_SHRT_NAME);
sizeof (Room->BldShrtName) - 1);
else // Room->BldCod > 0
{
Room->BldShrtName[0] = '\0';
if (BldShrtNameFromDB)
Str_Copy (Room->BldShrtName,BldShrtNameFromDB,
Bld_MAX_BYTES_SHRT_NAME);
sizeof (Room->BldShrtName) - 1);
}
}
@ -1288,8 +1277,7 @@ static void Roo_RenameRoom (Cns_ShrtOrFullName_t ShrtOrFullName)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
/***** Update room name *****/
Str_Copy (CurrentClaName,NewClaName,
MaxBytes);
Str_Copy (CurrentClaName,NewClaName,MaxBytes);
}
/*****************************************************************************/
@ -1383,9 +1371,7 @@ void Roo_ChangeCapacity (void)
static void Roo_WriteCapacity (char Str[Cns_MAX_DECIMAL_DIGITS_UINT + 1],unsigned Capacity)
{
if (Capacity <= Roo_MAX_CAPACITY)
snprintf (Str,Cns_MAX_DECIMAL_DIGITS_UINT + 1,
"%u",
Capacity);
snprintf (Str,Cns_MAX_DECIMAL_DIGITS_UINT + 1,"%u",Capacity);
else
Str[0] = '\0';
}
@ -1638,8 +1624,8 @@ static void Roo_EditingRoomConstructor (void)
Lay_ShowErrorAndExit ("Error initializing room.");
/***** Allocate memory for room *****/
if ((Roo_EditingRoom = (struct Roo_Room *) malloc (sizeof (struct Roo_Room))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for room.");
if ((Roo_EditingRoom = malloc (sizeof (*Roo_EditingRoom))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Reset room *****/
Roo_EditingRoom->RooCod = -1L;

View File

@ -459,8 +459,7 @@ static unsigned Sch_SearchCountriesInDB (const char *RangeQuery)
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_COUNTRIES))
{
/***** Split countries string into words *****/
snprintf (FieldName,sizeof (FieldName),
"Name_%s",
snprintf (FieldName,sizeof (FieldName),"Name_%s",
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
if (Sch_BuildSearchQuery (SearchQuery,FieldName,NULL,NULL))
{
@ -1111,26 +1110,18 @@ bool Sch_BuildSearchQuery (char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1],
Sch_MAX_BYTES_SEARCH_QUERY) // Prevent string overflow
break;
if (NumWords)
Str_Concat (SearchQuery," AND ",
Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,FieldName,
Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery," LIKE ",
Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery," AND ",Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,FieldName,Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery," LIKE ",Sch_MAX_BYTES_SEARCH_QUERY);
if (CharSet)
if (CharSet[0])
Str_Concat (SearchQuery,CharSet,
Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,"'%",
Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,SearchWords[NumWords],
Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,"%'",
Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,CharSet,Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,"'%",Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,SearchWords[NumWords],Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,"%'",Sch_MAX_BYTES_SEARCH_QUERY);
if (Collate)
if (Collate[0])
Str_Concat (SearchQuery,Collate,
Sch_MAX_BYTES_SEARCH_QUERY);
Str_Concat (SearchQuery,Collate,Sch_MAX_BYTES_SEARCH_QUERY);
}
}

View File

@ -28,7 +28,6 @@
#include <mysql/mysql.h> // To access MySQL databases
#include <stddef.h> // For NULL
#include <stdio.h> // For sprintf
#include <stdlib.h> // For malloc and free
#include <string.h> // For string functions
#include "swad_connected.h"
@ -80,8 +79,7 @@ void Ses_GetNumSessions (void)
void Ses_CreateSession (void)
{
/***** Create a unique name for the session *****/
Str_Copy (Gbl.Session.Id,Gbl.UniqueNameEncrypted,
Cns_BYTES_SESSION_ID);
Str_Copy (Gbl.Session.Id,Gbl.UniqueNameEncrypted,sizeof (Gbl.Session.Id) - 1);
/***** Check that session is not open *****/
if (Ses_CheckIfSessionExists (Gbl.Session.Id))
@ -288,7 +286,7 @@ bool Ses_GetSessionData (void)
/***** Get password (row[1]) *****/
Str_Copy (Gbl.Usrs.Me.LoginEncryptedPassword,row[1],
Pwd_BYTES_ENCRYPTED_PASSWORD);
sizeof (Gbl.Usrs.Me.LoginEncryptedPassword) - 1);
/***** Get logged user type (row[2]) *****/
if (sscanf (row[2],"%u",&Gbl.Usrs.Me.Role.FromSession) != 1)
@ -321,8 +319,7 @@ bool Ses_GetSessionData (void)
Gbl.Search.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
/* Get search string (row[9]) */
Str_Copy (Gbl.Search.Str,row[9],
Sch_MAX_BYTES_STRING_TO_FIND);
Str_Copy (Gbl.Search.Str,row[9],sizeof (Gbl.Search.Str) - 1);
}
Result = true;
@ -440,8 +437,7 @@ void Ses_GetHiddenParFromDB (const char *ParamName,char *ParamValue,
ParameterIsTooBig = (strlen (row[0]) > MaxBytes);
if (!ParameterIsTooBig)
Str_Copy (ParamValue,row[0],
MaxBytes);
Str_Copy (ParamValue,row[0],MaxBytes);
}
/***** Free structure that stores the query result *****/

View File

@ -262,8 +262,7 @@ static void Set_PutIconsToSelectSideCols (void)
"PREF_OFF");
Frm_StartForm (ActChgCol);
Par_PutHiddenParamUnsigned (NULL,"SideCols",SideCols);
snprintf (Icon,sizeof (Icon),
"layout%u%u_32x20.gif",
snprintf (Icon,sizeof (Icon),"layout%u%u_32x20.gif",
SideCols >> 1,SideCols & 1);
Ico_PutSettingIconLink (Icon,Txt_LAYOUT_SIDE_COLUMNS[SideCols]);
Frm_EndForm ();

View File

@ -201,8 +201,7 @@ The IP address of the remote host making the request.
void Sta_GetRemoteAddr (void)
{
if (getenv ("REMOTE_ADDR"))
Str_Copy (Gbl.IP,getenv ("REMOTE_ADDR"),
Cns_MAX_BYTES_IP);
Str_Copy (Gbl.IP,getenv ("REMOTE_ADDR"),sizeof (Gbl.IP) - 1);
else
Gbl.IP[0] = '\0';
}
@ -920,8 +919,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
switch (Stats.CountType)
{
case Sta_TOTAL_CLICKS:
Str_Copy (StrQueryCountType,"COUNT(*)",
Sta_MAX_BYTES_COUNT_TYPE);
Str_Copy (StrQueryCountType,"COUNT(*)",sizeof (StrQueryCountType) - 1);
break;
case Sta_DISTINCT_USRS:
sprintf (StrQueryCountType,"COUNT(DISTINCT(%s.UsrCod))",LogTable);
@ -939,7 +937,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
/***** Select clicks from the table of log *****/
/* Allocate memory for the query */
if ((Query = (char *) malloc (Sta_MAX_BYTES_QUERY_ACCESS + 1)) == NULL)
if ((Query = malloc (Sta_MAX_BYTES_QUERY_ACCESS + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/* Start the query */
@ -1079,8 +1077,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
LogTable,
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME],
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME ]);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
switch (GlobalOrCourse)
{
@ -1096,8 +1093,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
{
sprintf (QueryAux," AND %s.CtyCod=%ld",
LogTable,Gbl.Hierarchy.Cty.CtyCod);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
}
break;
case Hie_Lvl_INS:
@ -1105,8 +1101,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
{
sprintf (QueryAux," AND %s.InsCod=%ld",
LogTable,Gbl.Hierarchy.Ins.InsCod);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
}
break;
case Hie_Lvl_CTR:
@ -1114,8 +1109,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
{
sprintf (QueryAux," AND %s.CtrCod=%ld",
LogTable,Gbl.Hierarchy.Ctr.CtrCod);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
}
break;
case Hie_Lvl_DEG:
@ -1123,8 +1117,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
{
sprintf (QueryAux," AND %s.DegCod=%ld",
LogTable,Gbl.Hierarchy.Deg.DegCod);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
}
break;
case Hie_Lvl_CRS:
@ -1132,8 +1125,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
{
sprintf (QueryAux," AND %s.CrsCod=%ld",
LogTable,Gbl.Hierarchy.Crs.CrsCod);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
}
break;
}
@ -1201,8 +1193,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
LogTable,Gbl.Usrs.Me.UsrDat.UsrCod);
break;
}
Str_Concat (Query,StrRole,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,StrRole,Sta_MAX_BYTES_QUERY_ACCESS);
switch (Stats.ClicksGroupedBy)
{
@ -1210,14 +1201,12 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
case Sta_CLICKS_GBL_PER_API_FUNCTION:
sprintf (QueryAux," AND %s.LogCod=log_ws.LogCod",
LogTable);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_GBL_PER_BANNER:
sprintf (QueryAux," AND %s.LogCod=log_banners.LogCod",
LogTable);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
break;
default:
break;
@ -1226,8 +1215,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
case Sta_SHOW_COURSE_ACCESSES:
sprintf (QueryAux," AND %s.CrsCod=%ld",
LogTable,Gbl.Hierarchy.Crs.CrsCod);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
/***** Initialize data structure of the user *****/
Usr_UsrDataConstructor (&UsrDat);
@ -1237,7 +1225,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (UsrDat.UsrCod > 0)
@ -1249,13 +1237,11 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
NumUsr ? " OR %s.UsrCod=%ld" :
" AND (%s.UsrCod=%ld",
LogTable,UsrDat.UsrCod);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
NumUsr++;
}
}
Str_Concat (Query,")",
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,")",Sta_MAX_BYTES_QUERY_ACCESS);
/***** Free memory used by the data of the user *****/
Usr_UsrDataDestructor (&UsrDat);
@ -1267,62 +1253,51 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
{
sprintf (QueryAux," AND %s.ActCod=%ld",
LogTable,Act_GetActCod (Stats.NumAction));
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
}
/* End the query */
switch (Stats.ClicksGroupedBy)
{
case Sta_CLICKS_CRS_DETAILED_LIST:
Str_Concat (Query," ORDER BY F",
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query," ORDER BY F",Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_CRS_PER_USR:
sprintf (QueryAux," GROUP BY %s.UsrCod ORDER BY Num DESC",LogTable);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_CRS_PER_DAY:
case Sta_CLICKS_GBL_PER_DAY:
Str_Concat (Query," GROUP BY Day DESC",
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query," GROUP BY Day DESC",Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_CRS_PER_DAY_AND_HOUR:
case Sta_CLICKS_GBL_PER_DAY_AND_HOUR:
Str_Concat (Query," GROUP BY Day DESC,Hour",
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query," GROUP BY Day DESC,Hour",Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_CRS_PER_WEEK:
case Sta_CLICKS_GBL_PER_WEEK:
Str_Concat (Query," GROUP BY Week DESC",
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query," GROUP BY Week DESC",Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_CRS_PER_MONTH:
case Sta_CLICKS_GBL_PER_MONTH:
Str_Concat (Query," GROUP BY Month DESC",
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query," GROUP BY Month DESC",Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_CRS_PER_YEAR:
case Sta_CLICKS_GBL_PER_YEAR:
Str_Concat (Query," GROUP BY Year DESC",
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query," GROUP BY Year DESC",Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_CRS_PER_HOUR:
case Sta_CLICKS_GBL_PER_HOUR:
Str_Concat (Query," GROUP BY Hour",
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query," GROUP BY Hour",Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_CRS_PER_MINUTE:
case Sta_CLICKS_GBL_PER_MINUTE:
Str_Concat (Query," GROUP BY Minute",
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query," GROUP BY Minute",Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_CRS_PER_ACTION:
case Sta_CLICKS_GBL_PER_ACTION:
sprintf (QueryAux," GROUP BY %s.ActCod ORDER BY Num DESC",LogTable);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_GBL_PER_PLUGIN:
Str_Concat (Query," GROUP BY log_ws.PlgCod ORDER BY Num DESC",
@ -1338,28 +1313,23 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
break;
case Sta_CLICKS_GBL_PER_COUNTRY:
sprintf (QueryAux," GROUP BY %s.CtyCod ORDER BY Num DESC",LogTable);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_GBL_PER_INSTITUTION:
sprintf (QueryAux," GROUP BY %s.InsCod ORDER BY Num DESC",LogTable);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_GBL_PER_CENTRE:
sprintf (QueryAux," GROUP BY %s.CtrCod ORDER BY Num DESC",LogTable);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_GBL_PER_DEGREE:
sprintf (QueryAux," GROUP BY %s.DegCod ORDER BY Num DESC",LogTable);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
break;
case Sta_CLICKS_GBL_PER_COURSE:
sprintf (QueryAux," GROUP BY %s.CrsCod ORDER BY Num DESC",LogTable);
Str_Concat (Query,QueryAux,
Sta_MAX_BYTES_QUERY_ACCESS);
Str_Concat (Query,QueryAux,Sta_MAX_BYTES_QUERY_ACCESS);
break;
}
/***** Write query for debug *****/
@ -3913,20 +3883,14 @@ void Sta_WriteTimeToGenerateAndSendPage (void)
void Sta_WriteTime (char Str[Dat_MAX_BYTES_TIME],long TimeInMicroseconds)
{
if (TimeInMicroseconds < 1000L)
snprintf (Str,Dat_MAX_BYTES_TIME + 1,
"%ld &micro;s",
TimeInMicroseconds);
snprintf (Str,Dat_MAX_BYTES_TIME + 1,"%ld &micro;s",TimeInMicroseconds);
else if (TimeInMicroseconds < 1000000L)
snprintf (Str,Dat_MAX_BYTES_TIME + 1,
"%ld ms",
TimeInMicroseconds / 1000);
snprintf (Str,Dat_MAX_BYTES_TIME + 1,"%ld ms",TimeInMicroseconds / 1000);
else if (TimeInMicroseconds < (60 * 1000000L))
snprintf (Str,Dat_MAX_BYTES_TIME + 1,
"%.1f s",
(double) TimeInMicroseconds / 1E6);
snprintf (Str,Dat_MAX_BYTES_TIME + 1,"%.1f s",
(double) TimeInMicroseconds / 1E6);
else
snprintf (Str,Dat_MAX_BYTES_TIME + 1,
"%ld min, %ld s",
snprintf (Str,Dat_MAX_BYTES_TIME + 1,"%ld min, %ld s",
TimeInMicroseconds / (60 * 1000000L),
(TimeInMicroseconds / 1000000L) % 60);
}

View File

@ -305,12 +305,10 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
Gbl.Form.Num++;
if (Gbl.Usrs.Me.Logged)
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),
"form_%s_%d",
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
"form_%s_%d",Gbl.UniqueNameEncrypted,Gbl.Form.Num);
else
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),
"form_%d",
Gbl.Form.Num);
"form_%d",Gbl.Form.Num);
/* Store first part of anchor */
Frm_SetParamsForm (ParamsStr,ActSeeOthPubPrf,true);
@ -324,7 +322,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
Gbl.Form.Id,
ParamsStr);
Anchor1NickLength = strlen (Anchor1Nick);
if ((Links[NumLinks].Anchor1Nick = (char *) malloc (Anchor1NickLength + 1)) == NULL)
if ((Links[NumLinks].Anchor1Nick = malloc (Anchor1NickLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
strcpy (Links[NumLinks].Anchor1Nick,Anchor1Nick);
Links[NumLinks].Anchor1NickLength = Anchor1NickLength;
@ -337,7 +335,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId :
Gbl.Form.Id);
Anchor2NickLength = strlen (Anchor2Nick);
if ((Links[NumLinks].Anchor2Nick = (char *) malloc (Anchor2NickLength + 1)) == NULL)
if ((Links[NumLinks].Anchor2Nick = malloc (Anchor2NickLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
strcpy (Links[NumLinks].Anchor2Nick,Anchor2Nick);
Links[NumLinks].Anchor2NickLength = Anchor2NickLength;
@ -1148,7 +1146,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
if (ChangeTo != Str_DONT_CHANGE)
{
/***** Allocate memory for a destination string where to do the changes *****/
if ((StrDst = (char *) malloc (MaxLengthStr + 1)) == NULL)
if ((StrDst = malloc (MaxLengthStr + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Make the change *****/
@ -1287,12 +1285,12 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
Str_Concat (StrSpecialChar,
ThereIsSpaceChar ? "&nbsp;" :
" ", // The first space
Str_MAX_BYTES_SPECIAL_CHAR);
sizeof (StrSpecialChar) - 1);
for (i = 1;
i < NumSpacesTab;
i++) // Rest of spaces, except the first
Str_Concat (StrSpecialChar,"&nbsp;", // Add a space
Str_MAX_BYTES_SPECIAL_CHAR);
sizeof (StrSpecialChar) - 1);
NumPrintableCharsFromReturn += NumSpacesTab;
}
else
@ -1305,7 +1303,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
case 0x0A: /* \n */
if (ChangeTo == Str_TO_RIGOROUS_HTML)
Str_Copy (StrSpecialChar,"<br />",
Str_MAX_BYTES_SPECIAL_CHAR);
sizeof (StrSpecialChar) - 1);
else
{
StrSpecialChar[0] = Str_LF[0];
@ -1328,7 +1326,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
case 0x20: /* Space */
if (ChangeTo == Str_TO_RIGOROUS_HTML && ThereIsSpaceChar)
Str_Copy (StrSpecialChar,"&nbsp;",
Str_MAX_BYTES_SPECIAL_CHAR);
sizeof (StrSpecialChar) - 1);
else
{
StrSpecialChar[0] = ' ';
@ -1346,7 +1344,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
}
else
Str_Copy (StrSpecialChar,"&#34;", // Double comilla is stored as HTML code to avoid problems when displaying it
Str_MAX_BYTES_SPECIAL_CHAR);
sizeof (StrSpecialChar) - 1);
NumPrintableCharsFromReturn++;
ThereIsSpaceChar = false;
break;
@ -1371,7 +1369,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
}
else
Str_Copy (StrSpecialChar,"&#39;", // Single comilla is stored as HTML entity to avoid problem when querying database (SQL code injection)
Str_MAX_BYTES_SPECIAL_CHAR);
sizeof (StrSpecialChar) - 1);
NumPrintableCharsFromReturn++;
ThereIsSpaceChar = false;
break;
@ -1407,7 +1405,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
}
else
Str_Copy (StrSpecialChar,"&#60;", // "<" is stored as HTML code to avoid problems when displaying it
Str_MAX_BYTES_SPECIAL_CHAR);
sizeof (StrSpecialChar) - 1);
NumPrintableCharsFromReturn++;
ThereIsSpaceChar = false;
break;
@ -1419,7 +1417,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
}
else
Str_Copy (StrSpecialChar,"&#62;", // ">" is stored as HTML code to avoid problems when displaying it
Str_MAX_BYTES_SPECIAL_CHAR);
sizeof (StrSpecialChar) - 1);
NumPrintableCharsFromReturn++;
ThereIsSpaceChar = false;
break;
@ -1444,7 +1442,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
}
else
Str_Copy (StrSpecialChar,"&#92;", // "\" is stored as HTML code to avoid problems when displaying it
Str_MAX_BYTES_SPECIAL_CHAR);
sizeof (StrSpecialChar) - 1);
NumPrintableCharsFromReturn++;
ThereIsSpaceChar = false;
break;
@ -2579,16 +2577,14 @@ void Str_SplitFullPathIntoPathAndFileName (const char FullPath[PATH_MAX + 1],
LengthUntilFileName = (size_t) (PtrFileName - FullPath); // Last slash included
if (LengthUntilFileName > 1)
{
Str_Copy (PathWithoutFileName,FullPath,
PATH_MAX);
Str_Copy (PathWithoutFileName,FullPath,PATH_MAX);
PathWithoutFileName[LengthUntilFileName - 1] = '\0'; // Do not copy ending slash
}
else
PathWithoutFileName[0] = '\0';
/***** Get FileName *****/
Str_Copy (FileName,PtrFileName,
NAME_MAX);
Str_Copy (FileName,PtrFileName,NAME_MAX);
}
/*****************************************************************************/
@ -3043,8 +3039,7 @@ void Str_Concat (char *Dst,const char *Src,size_t DstSize)
DstLength = strlen (Dst);
if (DstLength > DstSize)
{
snprintf (ErrorTxt,sizeof (ErrorTxt),
"%lu-chars buffer has %lu chars!",
snprintf (ErrorTxt,sizeof (ErrorTxt),"%lu-chars buffer has %lu chars!",
DstSize,DstLength);
Lay_ShowErrorAndExit (ErrorTxt);
}

View File

@ -1055,7 +1055,8 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
Surveys->Num = (unsigned) NumRows;
/***** Create list of surveys *****/
if ((Surveys->LstSvyCods = (long *) calloc (NumRows,sizeof (long))) == NULL)
if ((Surveys->LstSvyCods = calloc (NumRows,
sizeof (*Surveys->LstSvyCods))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get the surveys codes *****/
@ -1301,8 +1302,7 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy)
Svy->Status.Open = (row[8][0] == '1');
/* Get the title of the survey (row[9]) */
Str_Copy (Svy->Title,row[9],
Svy_MAX_BYTES_SURVEY_TITLE);
Str_Copy (Svy->Title,row[9],strlen (Svy->Title) - 1);
/* Get number of questions and number of users who have already answer this survey */
Svy->NumQsts = Svy_GetNumQstsSvy (Svy->SvyCod);
@ -1493,8 +1493,7 @@ static void Svy_GetSurveyTxtFromDB (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1]
{
/* Get info text */
row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
}
else
Txt[0] = '\0';
@ -1532,17 +1531,15 @@ void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
row = mysql_fetch_row (mysql_res);
/***** Get summary *****/
Str_Copy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
/***** Get content *****/
if (GetContent)
{
Length = strlen (row[1]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[1],
Length);
if ((*ContentStr = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (*ContentStr,row[1],Length);
}
}
@ -2708,8 +2705,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
/* Get the stem of the question from the database (row[2]) */
Str_Copy (Txt,row[2],
Cns_MAX_BYTES_TEXT);
Str_Copy (Txt,row[2],Cns_MAX_BYTES_TEXT);
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
@ -2728,8 +2724,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
/* Abort on error */
Ale_ShowAlertsAndExit ();
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],
Svy_MAX_BYTES_ANSWER);
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER);
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
@ -2968,7 +2963,7 @@ static bool Svy_AllocateTextChoiceAnswer (struct Svy_Question *SvyQst,
unsigned NumAns)
{
Svy_FreeTextChoiceAnswer (SvyQst,NumAns);
if ((SvyQst->AnsChoice[NumAns].Text = (char *) malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL)
if ((SvyQst->AnsChoice[NumAns].Text = malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL)
{
Ale_CreateAlert (Ale_ERROR,NULL,
"Not enough memory to store answer.");
@ -3057,9 +3052,7 @@ void Svy_ReceiveQst (void)
if (!Svy_AllocateTextChoiceAnswer (&SvyQst,NumAns))
/* Abort on error */
Ale_ShowAlertsAndExit ();
snprintf (AnsStr,sizeof (AnsStr),
"AnsStr%u",
NumAns);
snprintf (AnsStr,sizeof (AnsStr),"AnsStr%u",NumAns);
Par_GetParToHTML (AnsStr,SvyQst.AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER);
}
@ -3438,10 +3431,9 @@ static void Svy_WriteQstStem (const char *Stem)
/* Convert the stem, that is in HTML, to rigorous HTML */
Length = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
if ((HeadingRigorousHTML = (char *) malloc (Length + 1)) == NULL)
if ((HeadingRigorousHTML = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (HeadingRigorousHTML,Stem,
Length);
Str_Copy (HeadingRigorousHTML,Stem,Length);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
HeadingRigorousHTML,Length,false);
@ -3495,8 +3487,7 @@ static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy,
/* Abort on error */
Ale_ShowAlertsAndExit ();
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],
Svy_MAX_BYTES_ANSWER);
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
SvyQst->AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER,false);
@ -3507,9 +3498,8 @@ static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy,
{
/* Write selector to choice this answer */
HTM_TD_Begin ("class=\"LT\"");
snprintf (StrAns,sizeof (StrAns),
"Ans%010u",
(unsigned) SvyQst->QstCod);
snprintf (StrAns,sizeof (StrAns),"Ans%010u",
(unsigned) SvyQst->QstCod);
if (SvyQst->AnswerType == Svy_ANS_UNIQUE_CHOICE)
HTM_INPUT_RADIO (StrAns,false,
"id=\"Ans%010u_%010u\" value=\"%u\""
@ -3799,9 +3789,7 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod)
Lay_ShowErrorAndExit ("Error: wrong question code.");
/* Get possible parameter with the user's answer */
snprintf (ParamName,sizeof (ParamName),
"Ans%010u",
(unsigned) QstCod);
snprintf (ParamName,sizeof (ParamName),"Ans%010u",(unsigned) QstCod);
// Lay_ShowAlert (Lay_INFO,ParamName);
Par_GetParMultiToText (ParamName,StrAnswersIndexes,
Svy_MAX_ANSWERS_PER_QUESTION * (Cns_MAX_DECIMAL_DIGITS_UINT + 1));

View File

@ -118,7 +118,7 @@ static void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos);
static void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel);
static void Syl_OpenSyllabusFile (const struct Syl_Syllabus *Syllabus,
char *PathFile);
char PathFile[PATH_MAX + 1]);
/*****************************************************************************/
/************************** Reset syllabus context ***************************/
@ -371,8 +371,7 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
unsigned NumItemsWithChildren = 0;
/* Path of the private directory for the XML file with the syllabus */
snprintf (Syllabus->PathDir,sizeof (Syllabus->PathDir),
"%s/%ld/%s",
snprintf (Syllabus->PathDir,sizeof (Syllabus->PathDir),"%s/%ld/%s",
Cfg_PATH_CRS_PRIVATE,CrsCod,
Syllabus->WhichSyllabus == Syl_LECTURES ? Cfg_SYLLABUS_FOLDER_LECTURES :
Cfg_SYLLABUS_FOLDER_PRACTICALS);
@ -393,8 +392,8 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
Syl_LstItemsSyllabus.NumItems++);
/***** Allocate memory for the list of items *****/
if ((Syl_LstItemsSyllabus.Lst = (struct ItemSyllabus *) calloc (Syl_LstItemsSyllabus.NumItems + 1,
sizeof (struct ItemSyllabus))) == NULL)
if ((Syl_LstItemsSyllabus.Lst = calloc (Syl_LstItemsSyllabus.NumItems + 1,
sizeof (*Syl_LstItemsSyllabus.Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Return to the start of the list *****/
@ -907,17 +906,13 @@ static void Syl_WriteNumItem (char *StrDst,FILE *FileTgt,int Level,int *CodItem)
if (N > 1)
{
if (StrDst)
Str_Concat (StrDst,".",
Syl_MAX_BYTES_ITEM_COD);
Str_Concat (StrDst,".",Syl_MAX_BYTES_ITEM_COD);
if (FileTgt)
fprintf (FileTgt,".");
}
snprintf (InStr,sizeof (InStr),
"%d",
CodItem[N]);
snprintf (InStr,sizeof (InStr),"%d",CodItem[N]);
if (StrDst)
Str_Concat (StrDst,InStr,
Syl_MAX_BYTES_ITEM_COD);
Str_Concat (StrDst,InStr,Syl_MAX_BYTES_ITEM_COD);
if (FileTgt)
fprintf (FileTgt,"%s",InStr);
}
@ -1379,15 +1374,12 @@ void Syl_ModifyItemSyllabus (void)
/*****************************************************************************/
void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
char *PathFile)
char PathFile[PATH_MAX + 1])
{
char Path[PATH_MAX + 1 + NAME_MAX + 1];
snprintf (Path,sizeof (Path),
"%s/%s",
Syllabus->PathDir,Cfg_SYLLABUS_FILENAME);
Str_Copy (PathFile,Path,
PATH_MAX);
snprintf (Path,sizeof (Path),"%s/%s",Syllabus->PathDir,Cfg_SYLLABUS_FILENAME);
Str_Copy (PathFile,Path,PATH_MAX);
}
/*****************************************************************************/
@ -1395,7 +1387,7 @@ void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
/*****************************************************************************/
static void Syl_OpenSyllabusFile (const struct Syl_Syllabus *Syllabus,
char *PathFile)
char PathFile[PATH_MAX + 1])
{
if (Gbl.F.XML == NULL) // If it's not open in this moment...
{

View File

@ -111,7 +111,7 @@ void Syl_LeftItemSyllabus (void);
void Syl_InsertItemSyllabus (void);
void Syl_ModifyItemSyllabus (void);
void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
char *PathFile);
char PathFile[PATH_MAX + 1]);
void Syl_WriteStartFileSyllabus (FILE *FileSyllabus);
void Syl_WriteAllItemsFileSyllabus (FILE *FileSyllabus);
void Syl_WriteItemFileSyllabus (FILE *FileSyllabus,int Level,const char *Text);

View File

@ -124,7 +124,7 @@ static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print);
static bool Tst_CheckIfNextTstAllowed (void);
static unsigned Tst_GetNumExamsGeneratedByMe (void);
static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMediaInForm,
static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedia,
bool OptionsDisabled);
static void Tst_IncreaseMyNumAccessTst (void);
static void Tst_UpdateLastAccTst (unsigned NumQsts);
@ -572,9 +572,7 @@ static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print)
NumQst++)
{
/* Get answers selected by user for this question */
snprintf (StrAns,sizeof (StrAns),
"Ans%010u",
NumQst);
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
Par_GetParMultiToText (StrAns,Print->PrintedQuestions[NumQst].StrAnswers,
Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */
Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[NumQst].StrAnswers);
@ -816,10 +814,9 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible)
{
/* Convert the stem, that is in HTML, to rigorous HTML */
StemLength = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
if ((StemRigorousHTML = (char *) malloc (StemLength + 1)) == NULL)
if ((StemRigorousHTML = malloc (StemLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (StemRigorousHTML,Stem,
StemLength);
Str_Copy (StemRigorousHTML,Stem,StemLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
StemRigorousHTML,StemLength,false);
@ -842,7 +839,7 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible)
/************* Put form to upload a new image for a test question ************/
/*****************************************************************************/
static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMediaInForm,
static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedia,
bool OptionsDisabled)
{
extern const char *The_ClassFormInBox[The_NUM_THEMES];
@ -855,7 +852,7 @@ static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedi
if (Media->Name[0])
{
/***** Set names of parameters depending on number of image in form *****/
Med_SetParamNames (&ParamUploadMedia,NumMediaInForm);
Med_SetParamNames (&ParamUploadMedia,NumMedia);
/***** Start container *****/
HTM_DIV_Begin ("class=\"TEST_MED_EDIT_FORM\"");
@ -892,14 +889,14 @@ static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedi
OptionsDisabled ? " disabled=\"disabled\"" : "");
HTM_TxtColonNBSP (Txt_Change_image_video);
HTM_LABEL_End ();
Med_PutMediaUploader (NumMediaInForm,"TEST_MED_INPUT");
Med_PutMediaUploader (NumMedia,"TEST_MED_INPUT");
/***** End container *****/
HTM_DIV_End ();
}
else // No current image
/***** Attached media *****/
Med_PutMediaUploader (NumMediaInForm,"TEST_MED_INPUT");
Med_PutMediaUploader (NumMedia,"TEST_MED_INPUT");
}
/*****************************************************************************/
@ -916,10 +913,9 @@ void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback)
{
/***** Convert the feedback, that is in HTML, to rigorous HTML *****/
FeedbackLength = strlen (Feedback) * Str_MAX_BYTES_PER_CHAR;
if ((FeedbackRigorousHTML = (char *) malloc (FeedbackLength + 1)) == NULL)
if ((FeedbackRigorousHTML = malloc (FeedbackLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (FeedbackRigorousHTML,Feedback,
FeedbackLength);
Str_Copy (FeedbackRigorousHTML,Feedback,FeedbackLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
FeedbackRigorousHTML,FeedbackLength,false);
@ -1481,9 +1477,8 @@ static void Tst_ShowFormConfigTst (void)
/* Data */
HTM_TD_Begin ("class=\"LB\"");
snprintf (StrMinTimeNxtTstPerQst,sizeof (StrMinTimeNxtTstPerQst),
"%lu",
TstCfg_GetConfigMinTimeNxtTstPerQst ());
snprintf (StrMinTimeNxtTstPerQst,sizeof (StrMinTimeNxtTstPerQst),"%lu",
TstCfg_GetConfigMinTimeNxtTstPerQst ());
HTM_INPUT_TEXT ("MinTimeNxtTstPerQst",Cns_MAX_DECIMAL_DIGITS_ULONG,StrMinTimeNxtTstPerQst,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"MinTimeNxtTstPerQst\" size=\"7\" required=\"required\"");
@ -1537,9 +1532,7 @@ static void Tst_PutInputFieldNumQst (const char *Field,const char *Label,
HTM_TD_End ();
HTM_TD_Begin ("class=\"LM\"");
snprintf (StrValue,sizeof (StrValue),
"%u",
Value);
snprintf (StrValue,sizeof (StrValue),"%u",Value);
HTM_INPUT_TEXT (Field,Cns_MAX_DECIMAL_DIGITS_UINT,StrValue,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"%s\" size=\"3\" required=\"required\"",Field);
@ -1750,41 +1743,30 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
char CrsCodStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
/***** Allocate space for query *****/
if ((Query = (char *) malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
if ((Query = malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Select questions *****/
/* Start query */
snprintf (Query,Tst_MAX_BYTES_QUERY_TEST + 1,
"SELECT tst_questions.QstCod" // row[0]
" FROM tst_questions");
Str_Copy (Query,"SELECT tst_questions.QstCod" // row[0]
" FROM tst_questions",Tst_MAX_BYTES_QUERY_TEST);
if (!Test->Tags.All)
Str_Concat (Query,",tst_question_tags,tst_tags",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,",tst_question_tags,tst_tags",Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query," WHERE tst_questions.CrsCod='",
Tst_MAX_BYTES_QUERY_TEST);
snprintf (CrsCodStr,sizeof (CrsCodStr),
"%ld",
Gbl.Hierarchy.Crs.CrsCod);
Str_Concat (Query,CrsCodStr,
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query," WHERE tst_questions.CrsCod='",Tst_MAX_BYTES_QUERY_TEST);
snprintf (CrsCodStr,sizeof (CrsCodStr),"%ld",Gbl.Hierarchy.Crs.CrsCod);
Str_Concat (Query,CrsCodStr,Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"' AND tst_questions.EditTime>=FROM_UNIXTIME('",
Tst_MAX_BYTES_QUERY_TEST);
snprintf (LongStr,sizeof (LongStr),
"%ld",
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME]);
Str_Concat (Query,LongStr,
Tst_MAX_BYTES_QUERY_TEST);
snprintf (LongStr,sizeof (LongStr),"%ld",
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME]);
Str_Concat (Query,LongStr,Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"') AND tst_questions.EditTime<=FROM_UNIXTIME('",
Tst_MAX_BYTES_QUERY_TEST);
snprintf (LongStr,sizeof (LongStr),
"%ld",
snprintf (LongStr,sizeof (LongStr),"%ld",
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME]);
Str_Concat (Query,LongStr,
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"')",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,LongStr,Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"')",Tst_MAX_BYTES_QUERY_TEST);
/* Add the tags selected */
if (!Test->Tags.All)
@ -1793,10 +1775,8 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
" AND tst_question_tags.TagCod=tst_tags.TagCod"
" AND tst_tags.CrsCod='",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,CrsCodStr,
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,CrsCodStr,Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
LengthQuery = strlen (Query);
NumItemInList = 0;
Ptr = Test->Tags.List;
@ -1810,14 +1790,11 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
NumItemInList ? " OR tst_tags.TagTxt='" :
" AND (tst_tags.TagTxt='",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,TagText,
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,TagText,Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
NumItemInList++;
}
Str_Concat (Query,")",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_TEST);
}
/* Add the types of answer selected */
@ -1837,19 +1814,15 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
NumItemInList ? " OR tst_questions.AnsType='" :
" AND (tst_questions.AnsType='",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,Tst_StrAnswerTypesDB[AnsType],
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,Tst_StrAnswerTypesDB[AnsType],Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
NumItemInList++;
}
Str_Concat (Query,")",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_TEST);
}
/* End the query */
Str_Concat (Query," GROUP BY tst_questions.QstCod",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query," GROUP BY tst_questions.QstCod",Tst_MAX_BYTES_QUERY_TEST);
switch (Test->SelectedOrder)
{
@ -1915,7 +1888,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
Lay_ShowErrorAndExit ("Wrong number of questions.");
/***** Allocate space for query *****/
if ((Query = (char *) malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
if ((Query = malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Select questions without hidden tags *****/
@ -1957,14 +1930,11 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
NumItemInList ? " OR tst_tags.TagTxt='" :
" AND (tst_tags.TagTxt='",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,TagText,
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,TagText,Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
NumItemInList++;
}
Str_Concat (Query,")",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_TEST);
}
/* Add answer types selected */
@ -1984,24 +1954,17 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
NumItemInList ? " OR tst_questions.AnsType='" :
" AND (tst_questions.AnsType='",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,Tst_StrAnswerTypesDB[AnswerType],
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,Tst_StrAnswerTypesDB[AnswerType],Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_TEST);
NumItemInList++;
}
Str_Concat (Query,")",
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_TEST);
}
/* End query */
Str_Concat (Query," ORDER BY RAND() LIMIT ",
Tst_MAX_BYTES_QUERY_TEST);
snprintf (StrNumQsts,sizeof (StrNumQsts),
"%u",
Test->NumQsts);
Str_Concat (Query,StrNumQsts,
Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query," ORDER BY RAND() LIMIT ",Tst_MAX_BYTES_QUERY_TEST);
snprintf (StrNumQsts,sizeof (StrNumQsts),"%u",Test->NumQsts);
Str_Concat (Query,StrNumQsts,Tst_MAX_BYTES_QUERY_TEST);
/*
if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
Lay_ShowAlert (Lay_INFO,Query);
@ -2115,12 +2078,10 @@ void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion,
if (ErrorInIndex)
Lay_ShowErrorAndExit ("Wrong index of answer.");
if (NumOpt == 0)
snprintf (StrInd,sizeof (StrInd),"%u",Index);
else
snprintf (StrInd,sizeof (StrInd),",%u",Index);
snprintf (StrInd,sizeof (StrInd),NumOpt ? ",%u" :
"%u",Index);
Str_Concat (PrintedQuestion->StrIndexes,StrInd,
Tst_MAX_BYTES_INDEXES_ONE_QST);
sizeof (PrintedQuestion->StrIndexes) - 1);
}
/***** Free structure that stores the query result *****/
@ -2920,9 +2881,7 @@ void Tst_WriteParamQstCod (unsigned NumQst,long QstCod)
{
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
snprintf (StrAns,sizeof (StrAns),
"Qst%010u",
NumQst);
snprintf (StrAns,sizeof (StrAns),"Qst%010u",NumQst);
Par_PutHiddenParamLong (NULL,StrAns,QstCod);
}
@ -3011,7 +2970,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test,
Test->Tags.All = Par_GetParToBool ("AllTags");
/* Get the tags */
if ((Test->Tags.List = (char *) malloc (Tag_MAX_BYTES_TAGS_LIST + 1)) == NULL)
if ((Test->Tags.List = malloc (Tag_MAX_BYTES_TAGS_LIST + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Par_GetParMultiToText ("ChkTag",Test->Tags.List,Tag_MAX_BYTES_TAGS_LIST);
@ -3044,8 +3003,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test,
case Tst_SELECT_QUESTIONS_FOR_GAME:
/* The unique allowed type of answer in a game is unique choice */
Test->AnswerTypes.All = false;
snprintf (Test->AnswerTypes.List,sizeof (Test->AnswerTypes.List),
"%u",
snprintf (Test->AnswerTypes.List,sizeof (Test->AnswerTypes.List),"%u",
(unsigned) Tst_ANS_UNIQUE_CHOICE);
break;
default:
@ -3349,9 +3307,7 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question)
/***** Input of a new tag *****/
HTM_TD_Begin ("class=\"RM\"");
snprintf (StrTagTxt,sizeof (StrTagTxt),
"TagTxt%u",
IndTag);
snprintf (StrTagTxt,sizeof (StrTagTxt),"TagTxt%u",IndTag);
HTM_INPUT_TEXT (StrTagTxt,Tag_MAX_CHARS_TAG,Question->Tags.Txt[IndTag],
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"%s\" class=\"TAG_TXT\" onchange=\"changeSelTag('%u')\"",
@ -3435,9 +3391,7 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question)
HTM_TD_Begin ("class=\"LT\"");
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
HTM_TxtColonNBSP (Txt_Integer_number);
snprintf (StrInteger,sizeof (StrInteger),
"%ld",
Question->Answer.Integer);
snprintf (StrInteger,sizeof (StrInteger),"%ld",Question->Answer.Integer);
HTM_INPUT_TEXT ("AnsInt",Cns_MAX_DECIMAL_DIGITS_LONG,StrInteger,
HTM_DONT_SUBMIT_ON_CHANGE,
"size=\"11\" required=\"required\"%s",
@ -3643,8 +3597,7 @@ static void Tst_PutFloatInputField (const char *Label,const char *Field,
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
HTM_TxtF ("%s&nbsp;",Label);
snprintf (StrDouble,sizeof (StrDouble),
"%.15lg",
snprintf (StrDouble,sizeof (StrDouble),"%.15lg",
Question->Answer.FloatingPoint[Index]);
HTM_INPUT_TEXT (Field,Tst_MAX_BYTES_FLOAT_ANSWER,StrDouble,
HTM_DONT_SUBMIT_ON_CHANGE,
@ -3690,11 +3643,11 @@ void Tst_QstConstructor (struct Tst_Question *Question)
Question->EditTime = (time_t) 0;
/***** Allocate memory for stem and feedback *****/
if ((Question->Stem = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((Question->Stem = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Question->Stem[0] = '\0';
if ((Question->Feedback = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
if ((Question->Feedback = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Question->Feedback[0] = '\0';
@ -3760,14 +3713,14 @@ void Tst_QstDestructor (struct Tst_Question *Question)
bool Tst_AllocateTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt)
{
if ((Question->Answer.Options[NumOpt].Text =
(char *) malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL)
malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL)
{
Ale_CreateAlert (Ale_ERROR,NULL,
"Not enough memory to store answer.");
return false;
}
if ((Question->Answer.Options[NumOpt].Feedback =
(char *) malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL)
malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL)
{
Ale_CreateAlert (Ale_ERROR,NULL,
"Not enough memory to store feedback.");
@ -3919,15 +3872,13 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question)
Question->Stem[0] = '\0';
if (row[3])
if (row[3][0])
Str_Copy (Question->Stem,row[3],
Cns_MAX_BYTES_TEXT);
Str_Copy (Question->Stem,row[3],Cns_MAX_BYTES_TEXT);
/* Get the feedback (row[4]) */
Question->Feedback[0] = '\0';
if (row[4])
if (row[4][0])
Str_Copy (Question->Feedback,row[4],
Cns_MAX_BYTES_TEXT);
Str_Copy (Question->Feedback,row[4],Cns_MAX_BYTES_TEXT);
/* Get media (row[5]) */
Question->Media.MedCod = Str_ConvertStrCodToLongCod (row[5]);
@ -3962,7 +3913,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question)
{
row = mysql_fetch_row (mysql_res);
Str_Copy (Question->Tags.Txt[NumRow],row[0],
Tag_MAX_BYTES_TAG);
sizeof (Question->Tags.Txt[NumRow]) - 1);
}
/* Free structure that stores the query result */
@ -4164,8 +4115,7 @@ void Tst_ReceiveQst (void)
Tst_InsertOrUpdateQstTagsAnsIntoDB (&Test.Question);
/***** Show the question just inserted in the database *****/
snprintf (Test.AnswerTypes.List,sizeof (Test.AnswerTypes.List),
"%u",
snprintf (Test.AnswerTypes.List,sizeof (Test.AnswerTypes.List),"%u",
(unsigned) Test.Question.Answer.Type);
Tst_ListOneQstToEdit (&Test);
}
@ -4217,9 +4167,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question)
NumTag < Tag_MAX_TAGS_PER_QUESTION;
NumTag++)
{
snprintf (TagStr,sizeof (TagStr),
"TagTxt%u",
NumTag);
snprintf (TagStr,sizeof (TagStr),"TagTxt%u",NumTag);
Par_GetParToText (TagStr,Question->Tags.Txt[NumTag],Tag_MAX_BYTES_TAG);
if (Question->Tags.Txt[NumTag][0])
@ -4303,9 +4251,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question)
Ale_ShowAlertsAndExit ();
/* Get answer */
snprintf (AnsStr,sizeof (AnsStr),
"AnsStr%u",
NumOpt);
snprintf (AnsStr,sizeof (AnsStr),"AnsStr%u",NumOpt);
Par_GetParToHTML (AnsStr,Question->Answer.Options[NumOpt].Text,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
if (Question->Answer.Type == Tst_ANS_TEXT)
@ -4314,9 +4260,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question)
Str_ReplaceSeveralSpacesForOne (Question->Answer.Options[NumOpt].Text);
/* Get feedback */
snprintf (FbStr,sizeof (FbStr),
"FbStr%u",
NumOpt);
snprintf (FbStr,sizeof (FbStr),"FbStr%u",NumOpt);
Par_GetParToHTML (FbStr,Question->Answer.Options[NumOpt].Feedback,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);

View File

@ -197,8 +197,7 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res)
Brw_CreateDirDownloadTmp ();
/***** Create public XML file with the questions *****/
snprintf (PathPubFile,sizeof (PathPubFile),
"%s/%s/%s/test.xml",
snprintf (PathPubFile,sizeof (PathPubFile),"%s/%s/%s/test.xml",
Cfg_PATH_FILE_BROWSER_TMP_PUBLIC,
Gbl.FileBrowser.TmpPubDir.L,
Gbl.FileBrowser.TmpPubDir.R);
@ -424,8 +423,7 @@ void TsI_ImportQstsFromXML (void)
else
{
/* End the reception of XML in a temporary file */
snprintf (FileNameXMLTmp,sizeof (FileNameXMLTmp),
"%s/%s.xml",
snprintf (FileNameXMLTmp,sizeof (FileNameXMLTmp),"%s/%s.xml",
Cfg_PATH_TEST_PRIVATE,Gbl.UniqueNameEncrypted);
if (Fil_EndReceptionOfFile (FileNameXMLTmp,Param))
/***** Get questions from XML file and store them in database *****/
@ -455,7 +453,7 @@ static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML)
fseek (FileXML,0L,SEEK_SET);
/***** Allocate memory for XML buffer *****/
if ((XMLBuffer = (char *) malloc (FileSize + 1)) == NULL)
if ((XMLBuffer = malloc (FileSize + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
else
{
@ -569,7 +567,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
{
Str_Copy (Question.Tags.Txt[Question.Tags.Num],
TagElem->Content,
Tag_MAX_BYTES_TAG);
sizeof (Question.Tags.Txt[Question.Tags.Num]) - 1);
Question.Tags.Num++;
}
}
@ -585,8 +583,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
if (StemElem->Content)
{
/* Convert stem from text to HTML (in database stem is stored in HTML) */
Str_Copy (Question.Stem,StemElem->Content,
Cns_MAX_BYTES_TEXT);
Str_Copy (Question.Stem,StemElem->Content,Cns_MAX_BYTES_TEXT);
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
Question.Stem,Cns_MAX_BYTES_TEXT,true);
}
@ -602,8 +599,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
if (FeedbackElem->Content)
{
/* Convert feedback from text to HTML (in database feedback is stored in HTML) */
Str_Copy (Question.Feedback,FeedbackElem->Content,
Cns_MAX_BYTES_TEXT);
Str_Copy (Question.Feedback,FeedbackElem->Content,Cns_MAX_BYTES_TEXT);
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
Question.Feedback,Cns_MAX_BYTES_TEXT,true);
}
@ -1004,7 +1000,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
/* Convert the answer, that is in HTML, to rigorous HTML */
AnswerTextLength = strlen (Question->Answer.Options[NumOpt].Text) *
Str_MAX_BYTES_PER_CHAR;
if ((AnswerText = (char *) malloc (AnswerTextLength + 1)) == NULL)
if ((AnswerText = malloc (AnswerTextLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (AnswerText,Question->Answer.Options[NumOpt].Text,
AnswerTextLength);
@ -1019,7 +1015,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
{
AnswerFeedbackLength = strlen (Question->Answer.Options[NumOpt].Feedback) *
Str_MAX_BYTES_PER_CHAR;
if ((AnswerFeedback = (char *) malloc (AnswerFeedbackLength + 1)) == NULL)
if ((AnswerFeedback = malloc (AnswerFeedbackLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Str_Copy (AnswerFeedback,
Question->Answer.Options[NumOpt].Feedback,

View File

@ -413,9 +413,7 @@ static void TstPrn_WriteIntAnsToFill (const struct TstPrn_PrintedQuestion *Print
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
/***** Write input field for the answer *****/
snprintf (StrAns,sizeof (StrAns),
"Ans%010u",
NumQst);
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
HTM_INPUT_TEXT (StrAns,11,PrintedQuestion->StrAnswers,
HTM_DONT_SUBMIT_ON_CHANGE,
"size=\"11\"");
@ -432,9 +430,7 @@ static void TstPrn_WriteFltAnsToFill (const struct TstPrn_PrintedQuestion *Print
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
/***** Write input field for the answer *****/
snprintf (StrAns,sizeof (StrAns),
"Ans%010u",
NumQst);
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
HTM_INPUT_TEXT (StrAns,Tst_MAX_BYTES_FLOAT_ANSWER,PrintedQuestion->StrAnswers,
HTM_DONT_SUBMIT_ON_CHANGE,
"size=\"11\"");
@ -501,9 +497,7 @@ static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *Print
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
HTM_TD_Begin ("class=\"LT\"");
snprintf (StrAns,sizeof (StrAns),
"Ans%010u",
NumQst);
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE)
HTM_INPUT_RADIO (StrAns,false,
"id=\"Ans%010u_%u\" value=\"%u\"%s"
@ -557,9 +551,7 @@ static void TstPrn_WriteTxtAnsToFill (const struct TstPrn_PrintedQuestion *Print
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
/***** Write input field for the answer *****/
snprintf (StrAns,sizeof (StrAns),
"Ans%010u",
NumQst);
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
HTM_INPUT_TEXT (StrAns,Tst_MAX_CHARS_ANSWERS_ONE_QST,PrintedQuestion->StrAnswers,
HTM_DONT_SUBMIT_ON_CHANGE,
"size=\"40\"");
@ -1214,8 +1206,7 @@ void TstPrn_ComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
if (PrintedQuestion->StrAnswers[0]) // If user has answered the answer
{
/* Filter the user answer */
Str_Copy (TextAnsUsr,PrintedQuestion->StrAnswers,
Tst_MAX_BYTES_ANSWERS_ONE_QST);
Str_Copy (TextAnsUsr,PrintedQuestion->StrAnswers,sizeof (TextAnsUsr) - 1);
/* In order to compare student answer to stored answer,
the text answers are stored avoiding two or more consecurive spaces */
@ -1228,8 +1219,7 @@ void TstPrn_ComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
NumOpt++)
{
/* Filter this correct answer */
Str_Copy (TextAnsOK,Question->Answer.Options[NumOpt].Text,
Tst_MAX_BYTES_ANSWERS_ONE_QST);
Str_Copy (TextAnsOK,Question->Answer.Options[NumOpt].Text,sizeof (TextAnsOK) - 1);
Str_ConvertToComparable (TextAnsOK);
/* Check is user answer is correct */
@ -1728,8 +1718,7 @@ static void TstPrn_WriteTxtAnsPrint (struct UsrData *UsrDat,
if (PrintedQuestion->StrAnswers[0]) // If user has answered the question
{
/* Filter the user answer */
Str_Copy (TextAnsUsr,PrintedQuestion->StrAnswers,
Tst_MAX_BYTES_ANSWERS_ONE_QST);
Str_Copy (TextAnsUsr,PrintedQuestion->StrAnswers,sizeof (TextAnsUsr) - 1);
/* In order to compare student answer to stored answer,
the text answers are stored avoiding two or more consecurive spaces */
@ -1742,8 +1731,7 @@ static void TstPrn_WriteTxtAnsPrint (struct UsrData *UsrDat,
NumOpt++)
{
/* Filter this correct answer */
Str_Copy (TextAnsOK,Question->Answer.Options[NumOpt].Text,
Tst_MAX_BYTES_ANSWERS_ONE_QST);
Str_Copy (TextAnsOK,Question->Answer.Options[NumOpt].Text,sizeof (TextAnsOK) - 1);
Str_ConvertToComparable (TextAnsOK);
/* Check is user answer is correct */
@ -1976,7 +1964,7 @@ static void TstPrn_ShowUsrsPrints (__attribute__((unused)) void *Args)
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
while (*Ptr)
{
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
@ -2451,8 +2439,8 @@ void TstPrn_ShowOnePrint (void)
HTM_TxtF ("&nbsp;%s",Gbl.Usrs.Other.UsrDat.Surname1);
if (Gbl.Usrs.Other.UsrDat.Surname2[0])
HTM_TxtF ("&nbsp;%s",Gbl.Usrs.Other.UsrDat.Surname2);
if (Gbl.Usrs.Other.UsrDat.FirstName[0])
HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FirstName);
if (Gbl.Usrs.Other.UsrDat.FrstName[0])
HTM_TxtF (", %s",Gbl.Usrs.Other.UsrDat.FrstName);
HTM_BR ();
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Other.UsrDat,PhotoURL);
Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,ShowPhoto ? PhotoURL :
@ -2799,11 +2787,11 @@ void TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print)
/* Get indexes for this question (row[2]) */
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[2],
Tst_MAX_BYTES_INDEXES_ONE_QST);
sizeof (Print->PrintedQuestions[NumQst].StrIndexes) - 1);
/* Get answers selected by user for this question (row[3]) */
Str_Copy (Print->PrintedQuestions[NumQst].StrAnswers,row[3],
Tst_MAX_BYTES_ANSWERS_ONE_QST);
sizeof (Print->PrintedQuestions[NumQst].StrAnswers) - 1);
}
/***** Free structure that stores the query result *****/

View File

@ -155,7 +155,7 @@ unsigned TstVis_GetVisibilityFromForm (void)
/***** Allocate memory for list of attendance events selected *****/
MaxSizeListVisibilitySelected = TstVis_NUM_ITEMS_VISIBILITY * (Cns_MAX_DECIMAL_DIGITS_UINT + 1);
if ((StrVisibilitySelected = (char *) malloc (MaxSizeListVisibilitySelected + 1)) == NULL)
if ((StrVisibilitySelected = malloc (MaxSizeListVisibilitySelected + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
/***** Get parameter multiple with list of visibility items selected *****/

View File

@ -331,10 +331,8 @@ void The_PutIconsToSelectTheme (void)
"PREF_OFF");
Frm_StartForm (ActChgThe);
Par_PutHiddenParamString (NULL,"Theme",The_ThemeId[Theme]);
snprintf (Icon,sizeof (Icon),
"%s/%s/theme_32x20.gif",
Cfg_ICON_FOLDER_THEMES,
The_ThemeId[Theme]);
snprintf (Icon,sizeof (Icon),"%s/%s/theme_32x20.gif",
Cfg_ICON_FOLDER_THEMES,The_ThemeId[Theme]);
Ico_PutSettingIconLink (Icon,The_ThemeNames[Theme]);
Frm_EndForm ();
HTM_DIV_End ();
@ -366,12 +364,9 @@ void The_ChangeTheme (void)
/***** Get param theme *****/
Gbl.Prefs.Theme = The_GetParamTheme ();
snprintf (Path,sizeof (Path),
"%s/%s",
Cfg_URL_ICON_THEMES_PUBLIC,
The_ThemeId[Gbl.Prefs.Theme]);
Str_Copy (Gbl.Prefs.URLTheme,Path,
PATH_MAX);
snprintf (Path,sizeof (Path),"%s/%s",
Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]);
Str_Copy (Gbl.Prefs.URLTheme,Path,sizeof (Gbl.Prefs.URLTheme) - 1);
/***** Store theme in database *****/
if (Gbl.Usrs.Me.Logged)

View File

@ -296,7 +296,7 @@ void TL_ShowTimelineUsrHighlightingNot (struct TL_Timeline *Timeline,
/***** Show timeline *****/
TL_ShowTimeline (Timeline,
Str_BuildStringStr (Txt_Timeline_OF_A_USER,
Gbl.Usrs.Other.UsrDat.FirstName),
Gbl.Usrs.Other.UsrDat.FrstName),
NotCod);
Str_FreeString ();
@ -515,7 +515,7 @@ void TL_FormStart (const struct TL_Timeline *Timeline,
{
/***** Start form in user timeline *****/
Frm_StartFormAnchor (ActionUsr,"timeline");
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
}
else
{

View File

@ -28,7 +28,6 @@
#define _GNU_SOURCE // For asprintf
#include <linux/limits.h> // For PATH_MAX
#include <stdio.h> // For asprintf
#include <stdlib.h> // For malloc and free
#include "swad_database.h"
#include "swad_forum.h"
@ -347,7 +346,7 @@ static void TL_Com_FormToShowHiddenComments (Act_Action_t ActionGbl,Act_Action_t
NotCod,
IdComments,
NumInitialComments,
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0)
Gbl.Usrs.Other.UsrDat.EnUsrCod) < 0)
Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
}
@ -678,7 +677,7 @@ static void TL_Com_WriteAuthorComment (struct UsrData *UsrDat)
/***** Show user's name inside form to go to user's public profile *****/
Frm_StartFormUnique (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
Txt_Another_user_s_profile,
"BT_LINK TL_COM_AUTHOR TL_COMM_AUTHOR_WIDTH DAT_BOLD",NULL);
@ -915,7 +914,7 @@ static void TL_Com_PutParamsRemoveComment (void *Timeline)
if (Timeline)
{
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
else
Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who);
TL_Pub_PutHiddenParamPubCod (((struct TL_Timeline *) Timeline)->PubCod);
@ -1127,8 +1126,7 @@ static void TL_Com_GetDataOfCommentFromRow (MYSQL_ROW row,struct TL_Com_Comment
Com->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
/***** Get text content (row[4]) *****/
Str_Copy (Com->Content.Txt,row[4],
Cns_MAX_BYTES_LONG_TEXT);
Str_Copy (Com->Content.Txt,row[4],sizeof (Com->Content.Txt) - 1);
/***** Get number of times this comment has been favourited *****/
TL_Fav_GetNumTimesACommHasBeenFav (Com);

View File

@ -389,7 +389,7 @@ static void TL_Not_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod
/***** Show user's name inside form to go to user's public profile *****/
Frm_StartFormUnique (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (PublisherDat.EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (PublisherDat.EnUsrCod);
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
Txt_Another_user_s_profile,
"BT_LINK TL_TOP_PUBLISHER",NULL);
@ -419,7 +419,7 @@ void TL_Not_WriteAuthorNote (const struct UsrData *UsrDat)
/***** Show user's name inside form to go to user's public profile *****/
Frm_StartFormUnique (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
Txt_Another_user_s_profile,
"BT_LINK TL_RIGHT_AUTHOR TL_RIGHT_AUTHOR_WIDTH DAT_N_BOLD",
@ -1064,7 +1064,7 @@ static void TL_Not_PutParamsRemoveNote (void *Timeline)
if (Timeline)
{
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
else
Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who);
TL_Not_PutHiddenParamNotCod (((struct TL_Timeline *) Timeline)->NotCod);
@ -1350,7 +1350,7 @@ long TL_Not_GetPubCodOfOriginalNote (long NotCod)
/****** Add just retrieved notes to current timeline for this session ********/
/*****************************************************************************/
void TL_Not_AddNotesJustRetrievedToTimelineThisSession (void)
void TL_Not_AddNotesJustRetrievedToVisibleTimelineThisSession (void)
{
/* tl_timelines contains the distinct notes in timeline of each open session:
mysql> SELECT SessionId,COUNT(*) FROM tl_timelines GROUP BY SessionId;

View File

@ -117,7 +117,7 @@ void TL_Not_RemoveNoteGbl (void);
long TL_Not_GetPubCodOfOriginalNote (long NotCod);
void TL_Not_AddNotesJustRetrievedToTimelineThisSession (void);
void TL_Not_AddNotesJustRetrievedToVisibleTimelineThisSession (void);
void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not);

Some files were not shown because too many files have changed in this diff Show More