Version 16.115

This commit is contained in:
Antonio Cañas Vargas 2017-01-15 18:02:52 +01:00
parent 0c61dd94e7
commit a96a5079b8
70 changed files with 962 additions and 1367 deletions

View File

@ -118,8 +118,7 @@ void ID_GetListIDsFromUsrCod (struct UsrData *UsrDat)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get ID from row[0] */ /* Get ID from row[0] */
strncpy (UsrDat->IDs.List[NumID].ID,row[0],ID_MAX_LENGTH_USR_ID); Str_Copy (UsrDat->IDs.List[NumID].ID,row[0],ID_MAX_LENGTH_USR_ID);
UsrDat->IDs.List[NumID].ID[ID_MAX_LENGTH_USR_ID] = '\0';
/* Get if ID is confirmed from row[1] */ /* Get if ID is confirmed from row[1] */
UsrDat->IDs.List[NumID].Confirmed = (row[1][0] == 'Y'); UsrDat->IDs.List[NumID].Confirmed = (row[1][0] == 'Y');
@ -195,12 +194,10 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
Lay_ShowErrorAndExit ("Not enough memory to store list of user's IDs."); Lay_ShowErrorAndExit ("Not enough memory to store list of user's IDs.");
/***** Get user's code(s) from database *****/ /***** Get user's code(s) from database *****/
strncpy (Query,CheckPassword ? "SELECT DISTINCT(usr_IDs.UsrCod) FROM usr_IDs,usr_data" Str_Copy (Query,CheckPassword ? "SELECT DISTINCT(usr_IDs.UsrCod) FROM usr_IDs,usr_data"
" WHERE usr_IDs.UsrID IN (" : " WHERE usr_IDs.UsrID IN (" :
"SELECT DISTINCT(UsrCod) FROM usr_IDs" "SELECT DISTINCT(UsrCod) FROM usr_IDs"
" WHERE UsrID IN (",Length); " WHERE UsrID IN (",Length);
Query[Length] = '\0';
for (NumID = 0; for (NumID = 0;
NumID < UsrDat->IDs.Num; NumID < UsrDat->IDs.Num;
NumID++) NumID++)

View File

@ -43,7 +43,7 @@
struct ListIDs struct ListIDs
{ {
bool Confirmed; bool Confirmed;
char ID[ID_MAX_LENGTH_USR_ID+1]; char ID[ID_MAX_LENGTH_USR_ID + 1];
}; };
/*****************************************************************************/ /*****************************************************************************/

View File

@ -45,6 +45,9 @@
/***************************** Private constants *****************************/ /***************************** Private constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define MFU_MAX_LENGTH_TAB (128 - 1)
#define MFU_MAX_LENGTH_MENU (128 - 1)
/*****************************************************************************/ /*****************************************************************************/
/****************************** Internal types *******************************/ /****************************** Internal types *******************************/
/*****************************************************************************/ /*****************************************************************************/
@ -212,9 +215,9 @@ void MFU_WriteBigMFUActions (struct MFU_ListMFUActions *ListMFUActions)
Act_Action_t Action; Act_Action_t Action;
Act_Action_t SuperAction; Act_Action_t SuperAction;
const char *Title; const char *Title;
char TabStr[128+1]; char TabStr[MFU_MAX_LENGTH_TAB + 1];
char MenuStr[128+1]; char MenuStr[MFU_MAX_LENGTH_MENU + 1];
char TabMenuStr[128+6+128+1]; char TabMenuStr[MFU_MAX_LENGTH_TAB + 6 + MFU_MAX_LENGTH_MENU + 1];
/***** Start frame *****/ /***** Start frame *****/
Lay_StartRoundFrame (NULL,Txt_My_frequent_actions,NULL,Hlp_STATS_Frequent); Lay_StartRoundFrame (NULL,Txt_My_frequent_actions,NULL,Hlp_STATS_Frequent);
@ -232,10 +235,9 @@ void MFU_WriteBigMFUActions (struct MFU_ListMFUActions *ListMFUActions)
{ {
/* Action string */ /* Action string */
SuperAction = Act_Actions[Action].SuperAction; SuperAction = Act_Actions[Action].SuperAction;
strncpy (TabStr,Txt_TABS_TXT[Act_Actions[SuperAction].Tab],128); Str_Copy (TabStr,Txt_TABS_TXT[Act_Actions[SuperAction].Tab],
TabStr[128] = '\0'; MFU_MAX_LENGTH_TAB);
strncpy (MenuStr,Title,128); Str_Copy (MenuStr,Title,MFU_MAX_LENGTH_MENU);
MenuStr[128] = '\0';
sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr); sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr);
/* Icon and text */ /* Icon and text */
@ -271,9 +273,9 @@ void MFU_WriteSmallMFUActions (struct MFU_ListMFUActions *ListMFUActions)
Act_Action_t Action; Act_Action_t Action;
Act_Action_t SuperAction; Act_Action_t SuperAction;
const char *Title; const char *Title;
char TabStr[128+1]; char TabStr[MFU_MAX_LENGTH_TAB + 1];
char MenuStr[128+1]; char MenuStr[MFU_MAX_LENGTH_MENU + 1];
char TabMenuStr[128+6+128+1]; char TabMenuStr[MFU_MAX_LENGTH_TAB + 6 + MFU_MAX_LENGTH_MENU + 1];
/***** Start div and link *****/ /***** Start div and link *****/
fprintf (Gbl.F.Out,"<div id=\"MFU_actions\">"); fprintf (Gbl.F.Out,"<div id=\"MFU_actions\">");
@ -296,10 +298,9 @@ void MFU_WriteSmallMFUActions (struct MFU_ListMFUActions *ListMFUActions)
{ {
/* Action string */ /* Action string */
SuperAction = Act_Actions[Action].SuperAction; SuperAction = Act_Actions[Action].SuperAction;
strncpy (TabStr,Txt_TABS_TXT[Act_Actions[SuperAction].Tab],128); Str_Copy (TabStr,Txt_TABS_TXT[Act_Actions[SuperAction].Tab],
TabStr[128] = '\0'; MFU_MAX_LENGTH_TAB);
strncpy (MenuStr,Title,128); Str_Copy (MenuStr,Title,MFU_MAX_LENGTH_MENU);
MenuStr[128] = '\0';
sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr); sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr);
/* Icon and text */ /* Icon and text */

View File

@ -25,8 +25,6 @@
/*********************************** Headers *********************************/ /*********************************** Headers *********************************/
/*****************************************************************************/ /*****************************************************************************/
#include <string.h> // For strncpy...
#include "swad_action.h" #include "swad_action.h"
#include "swad_global.h" #include "swad_global.h"
#include "swad_ID.h" #include "swad_ID.h"

View File

@ -191,8 +191,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
fprintf (FileRSS,"<item>\n"); fprintf (FileRSS,"<item>\n");
/* Write title (first characters) of the notice */ /* Write title (first characters) of the notice */
strncpy (Content,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[3],Cns_MAX_BYTES_TEXT);
Content[Cns_MAX_BYTES_TEXT] = '\0';
Str_LimitLengthHTMLStr (Content,40); Str_LimitLengthHTMLStr (Content,40);
fprintf (FileRSS,"<title>%s: ",Txt_Notice); fprintf (FileRSS,"<title>%s: ",Txt_Notice);
Str_FilePrintStrChangingBRToRetAndNBSPToSpace (FileRSS,Content); Str_FilePrintStrChangingBRToRetAndNBSPToSpace (FileRSS,Content);
@ -203,8 +202,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
Cfg_URL_SWAD_CGI,Crs->CrsCod); Cfg_URL_SWAD_CGI,Crs->CrsCod);
/* Write full content of the notice */ /* Write full content of the notice */
strncpy (Content,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[3],Cns_MAX_BYTES_TEXT);
Content[Cns_MAX_BYTES_TEXT] = '\0';
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,40); Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,40);
fprintf (FileRSS,"<description><![CDATA[<p><em>%s %s %s:</em></p><p>%s</p>]]></description>\n", fprintf (FileRSS,"<description><![CDATA[<p><em>%s %s %s:</em></p><p>%s</p>]]></description>\n",
UsrDat.FirstName,UsrDat.Surname1,UsrDat.Surname2,Content); UsrDat.FirstName,UsrDat.Surname1,UsrDat.Surname2,Content);
@ -295,9 +293,6 @@ static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Course *Crs)
Cfg_URL_SWAD_CGI,Crs->CrsCod); Cfg_URL_SWAD_CGI,Crs->CrsCod);
/* Write full content of the exam announcement */ /* Write full content of the exam announcement */
//strncpy (Content,row[4],Cns_MAX_BYTES_TEXT);
//Content[Cns_MAX_BYTES_TEXT] = '\0';
//Str_InsertLinkInURLs (Content,Cns_MAX_BYTES_TEXT,40);
fprintf (FileRSS,"<description><![CDATA[<p><em>Fecha examen: %s</em></p>]]></description>\n", fprintf (FileRSS,"<description><![CDATA[<p><em>Fecha examen: %s</em></p>]]></description>\n",
row[2]); row[2]);

View File

@ -559,9 +559,8 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
Gbl.Usrs.Me.UsrDat.IDs.List = NULL; Gbl.Usrs.Me.UsrDat.IDs.List = NULL;
/***** Set password to the password typed by the user *****/ /***** Set password to the password typed by the user *****/
strncpy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword, Str_Copy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword,
Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64); Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64);
Gbl.Usrs.Me.UsrDat.Password[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64] = '\0';
/***** User does not exist in the platform, so create him/her! *****/ /***** User does not exist in the platform, so create him/her! *****/
Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat, Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,
@ -569,16 +568,14 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
/***** Save nickname *****/ /***** Save nickname *****/
Nck_UpdateMyNick (NewNicknameWithoutArroba); Nck_UpdateMyNick (NewNicknameWithoutArroba);
strncpy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba, Str_Copy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba,
Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA); Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
Gbl.Usrs.Me.UsrDat.Nickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0';
/***** Save email *****/ /***** Save email *****/
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail)) if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail))
{ {
/* Email updated sucessfully */ /* Email updated sucessfully */
strncpy (Gbl.Usrs.Me.UsrDat.Email,NewEmail,Usr_MAX_BYTES_USR_EMAIL); Str_Copy (Gbl.Usrs.Me.UsrDat.Email,NewEmail,Usr_MAX_BYTES_USR_EMAIL);
Gbl.Usrs.Me.UsrDat.Email[Usr_MAX_BYTES_USR_EMAIL] = '\0';
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false; Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
} }
@ -615,8 +612,8 @@ static bool Acc_GetParamsNewAccount (char *NewNicknameWithoutArroba,
Par_GetParToText ("NewNick",NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Par_GetParToText ("NewNick",NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
/* Remove arrobas at the beginning */ /* Remove arrobas at the beginning */
strncpy (NewNicknameWithoutArroba,NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA] = '\0'; Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba); Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
/* Create a new version of the nickname with arroba */ /* Create a new version of the nickname with arroba */

View File

@ -4608,8 +4608,7 @@ char *Act_GetActionTextFromDB (long ActCod,char *Txt)
{ {
/***** Get text *****/ /***** Get text *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Txt,row[0],Act_MAX_LENGTH_ACTION_TXT); Str_Copy (Txt,row[0],Act_MAX_LENGTH_ACTION_TXT);
Txt[Act_MAX_LENGTH_ACTION_TXT] = '\0';
} }
else // ActCod-Language not found on database else // ActCod-Language not found on database
Txt[0] = '\0'; Txt[0] = '\0';

View File

@ -947,12 +947,10 @@ static void Agd_GetDataOfEventByCod (struct AgendaEvent *AgdEvent)
Dat_PRESENT)); Dat_PRESENT));
/* Get the event (row[7]) */ /* Get the event (row[7]) */
strncpy (AgdEvent->Event,row[7],Agd_MAX_LENGTH_EVENT); Str_Copy (AgdEvent->Event,row[7],Agd_MAX_LENGTH_EVENT);
AgdEvent->Event[Agd_MAX_LENGTH_EVENT] = '\0';
/* Get the event (row[8]) */ /* Get the event (row[8]) */
strncpy (AgdEvent->Location,row[8],Agd_MAX_LENGTH_LOCATION); Str_Copy (AgdEvent->Location,row[8],Agd_MAX_LENGTH_LOCATION);
AgdEvent->Location[Agd_MAX_LENGTH_LOCATION] = '\0';
} }
else else
{ {
@ -1009,8 +1007,7 @@ static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,char *Txt)
{ {
/* Get info text */ /* Get info text */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Txt,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
Txt[Cns_MAX_BYTES_TEXT] = '\0';
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';

View File

@ -25,8 +25,6 @@
/*********************************** Headers *********************************/ /*********************************** Headers *********************************/
/*****************************************************************************/ /*****************************************************************************/
#include <string.h> // For strncpy...
#include "swad_announcement.h" #include "swad_announcement.h"
#include "swad_database.h" #include "swad_database.h"
#include "swad_global.h" #include "swad_global.h"
@ -151,12 +149,10 @@ void Ann_ShowAllAnnouncements (void)
Lay_ShowErrorAndExit ("Error when reading roles of announcement."); Lay_ShowErrorAndExit ("Error when reading roles of announcement.");
/* Get the content (row[3]) */ /* Get the content (row[3]) */
strncpy (Subject,row[3],Cns_MAX_BYTES_SUBJECT); Str_Copy (Subject,row[3],Cns_MAX_BYTES_SUBJECT);
Content[Cns_MAX_BYTES_SUBJECT] = '\0';
/* Get the content (row[4]) and insert links */ /* Get the content (row[4]) and insert links */
strncpy (Content,row[4],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[4],Cns_MAX_BYTES_TEXT);
Content[Cns_MAX_BYTES_TEXT] = '\0';
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50); Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
/* Show the announcement */ /* Show the announcement */
@ -245,12 +241,10 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
Lay_ShowErrorAndExit ("Wrong code of announcement."); Lay_ShowErrorAndExit ("Wrong code of announcement.");
/* Get the content (row[1]) */ /* Get the content (row[1]) */
strncpy (Subject,row[1],Cns_MAX_BYTES_SUBJECT); Str_Copy (Subject,row[1],Cns_MAX_BYTES_SUBJECT);
Content[Cns_MAX_BYTES_SUBJECT] = '\0';
/* Get the content (row[2]) and insert links */ /* Get the content (row[2]) and insert links */
strncpy (Content,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[2],Cns_MAX_BYTES_TEXT);
Content[Cns_MAX_BYTES_TEXT] = '\0';
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50); Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
/* Show the announcement */ /* Show the announcement */

View File

@ -452,12 +452,8 @@ static void Asg_WriteAsgAuthor (struct Assignment *Asg)
"PHOTO15x20",Pho_ZOOM,false); "PHOTO15x20",Pho_ZOOM,false);
/***** Write name *****/ /***** Write name *****/
strncpy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Copy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME);
UsrDat.FirstName[Usr_MAX_BYTES_NAME] = '\0'; Str_Copy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES);
strncpy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES);
Surnames[Usr_MAX_BYTES_SURNAMES] = '\0';
if (UsrDat.Surname2[0]) if (UsrDat.Surname2[0])
{ {
strcat (Surnames," "); strcat (Surnames," ");
@ -780,13 +776,10 @@ static void Asg_GetDataOfAssignment (struct Assignment *Asg,const char *Query)
Asg->Open = (row[5][0] == '1'); Asg->Open = (row[5][0] == '1');
/* Get the title of the assignment (row[6]) */ /* Get the title of the assignment (row[6]) */
strncpy (Asg->Title,row[6],Asg_MAX_LENGTH_ASSIGNMENT_TITLE); Str_Copy (Asg->Title,row[6],Asg_MAX_LENGTH_ASSIGNMENT_TITLE);
Asg->Title[Asg_MAX_LENGTH_ASSIGNMENT_TITLE] = '\0';
/* Get the folder for the assignment files (row[7]) */ /* Get the folder for the assignment files (row[7]) */
strncpy (Asg->Folder,row[7],Asg_MAX_LENGTH_FOLDER); Str_Copy (Asg->Folder,row[7],Asg_MAX_LENGTH_FOLDER);
Asg->Folder[Asg_MAX_LENGTH_FOLDER] = '\0';
Asg->SendWork = (Asg->Folder[0] != '\0'); Asg->SendWork = (Asg->Folder[0] != '\0');
/* Can I do this assignment? */ /* Can I do this assignment? */
@ -855,8 +848,7 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT
{ {
/* Get info text */ /* Get info text */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Txt,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
Txt[Cns_MAX_BYTES_TEXT] = '\0';
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';
@ -895,8 +887,7 @@ void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **Cont
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/***** Get summary *****/ /***** Get summary *****/
strncpy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT);
SummaryStr[Cns_MAX_BYTES_TEXT] = '\0';
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -907,8 +898,7 @@ void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **Cont
if ((*ContentStr = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) if ((*ContentStr = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content."); Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
strncpy (*ContentStr,row[1],Cns_MAX_BYTES_TEXT); Str_Copy (*ContentStr,row[1],Cns_MAX_BYTES_TEXT);
(*ContentStr)[Cns_MAX_BYTES_TEXT] = '\0';
} }
} }
mysql_free_result (mysql_res); mysql_free_result (mysql_res);

View File

@ -492,12 +492,8 @@ static void Att_WriteAttEventAuthor (struct AttendanceEvent *Att)
"PHOTO15x20",Pho_ZOOM,false); "PHOTO15x20",Pho_ZOOM,false);
/***** Write name *****/ /***** Write name *****/
strncpy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Copy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME);
FirstName[Usr_MAX_BYTES_NAME] = '\0'; Str_Copy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES);
strncpy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES);
Surnames[Usr_MAX_BYTES_SURNAMES] = '\0';
if (UsrDat.Surname2[0]) if (UsrDat.Surname2[0])
{ {
strcat (Surnames," "); strcat (Surnames," ");
@ -789,8 +785,7 @@ bool Att_GetDataOfAttEventByCod (struct AttendanceEvent *Att)
Att->CommentTchVisible = (row[7][0] == 'Y'); Att->CommentTchVisible = (row[7][0] == 'Y');
/* Get the title of the attendance event (row[8]) */ /* Get the title of the attendance event (row[8]) */
strncpy (Att->Title,row[8],Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE); Str_Copy (Att->Title,row[8],Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE);
Att->Title[Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -861,8 +856,7 @@ static void Att_GetAttEventTxtFromDB (long AttCod,char Txt[Cns_MAX_BYTES_TEXT +
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get info text */ /* Get info text */
strncpy (Txt,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT);
Txt[Cns_MAX_BYTES_TEXT] = '\0';
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';
@ -2518,12 +2512,10 @@ static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long Us
Present = (row[0][0] == 'Y'); Present = (row[0][0] == 'Y');
/* Get student's comment (row[1]) */ /* Get student's comment (row[1]) */
strncpy (CommentStd,row[1],Cns_MAX_BYTES_TEXT); Str_Copy (CommentStd,row[1],Cns_MAX_BYTES_TEXT);
CommentStd[Cns_MAX_BYTES_TEXT] = '\0';
/* Get teacher's comment (row[2]) */ /* Get teacher's comment (row[2]) */
strncpy (CommentTch,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (CommentTch,row[2],Cns_MAX_BYTES_TEXT);
CommentTch[Cns_MAX_BYTES_TEXT] = '\0';
} }
else // User is not present else // User is not present
{ {

View File

@ -204,20 +204,16 @@ static void Ban_GetListBanners (const char *Query)
Ban->Hidden = (row[1][0] == 'Y'); Ban->Hidden = (row[1][0] == 'Y');
/* Get the short name of the banner (row[2]) */ /* Get the short name of the banner (row[2]) */
strncpy (Ban->ShrtName,row[2],Ban_MAX_LENGTH_SHRT_NAME); Str_Copy (Ban->ShrtName,row[2],Ban_MAX_LENGTH_SHRT_NAME);
Ban->ShrtName[Ban_MAX_LENGTH_SHRT_NAME] = '\0';
/* Get the full name of the banner (row[3]) */ /* Get the full name of the banner (row[3]) */
strncpy (Ban->FullName,row[3],Ban_MAX_LENGTH_FULL_NAME); Str_Copy (Ban->FullName,row[3],Ban_MAX_LENGTH_FULL_NAME);
Ban->FullName[Ban_MAX_LENGTH_FULL_NAME] = '\0';
/* Get the image of the banner (row[4]) */ /* Get the image of the banner (row[4]) */
strncpy (Ban->Img,row[4],Ban_MAX_LENGTH_IMAGE); Str_Copy (Ban->Img,row[4],Ban_MAX_LENGTH_IMAGE);
Ban->Img[Ban_MAX_LENGTH_IMAGE] = '\0';
/* Get the URL of the banner (row[5]) */ /* Get the URL of the banner (row[5]) */
strncpy (Ban->WWW,row[5],Cns_MAX_LENGTH_WWW); Str_Copy (Ban->WWW,row[5],Cns_MAX_LENGTH_WWW);
Ban->WWW[Cns_MAX_LENGTH_WWW] = '\0';
} }
} }
else else
@ -261,20 +257,16 @@ void Ban_GetDataOfBannerByCod (struct Banner *Ban)
Ban->Hidden = (row[0][0] == 'Y'); Ban->Hidden = (row[0][0] == 'Y');
/* Get the short name of the banner (row[1]) */ /* Get the short name of the banner (row[1]) */
strncpy (Ban->ShrtName,row[1],Ban_MAX_LENGTH_SHRT_NAME); Str_Copy (Ban->ShrtName,row[1],Ban_MAX_LENGTH_SHRT_NAME);
Ban->ShrtName[Ban_MAX_LENGTH_SHRT_NAME] = '\0';
/* Get the full name of the banner (row[2]) */ /* Get the full name of the banner (row[2]) */
strncpy (Ban->FullName,row[2],Ban_MAX_LENGTH_FULL_NAME); Str_Copy (Ban->FullName,row[2],Ban_MAX_LENGTH_FULL_NAME);
Ban->FullName[Ban_MAX_LENGTH_FULL_NAME] = '\0';
/* Get the image of the banner (row[3]) */ /* Get the image of the banner (row[3]) */
strncpy (Ban->Img,row[3],Ban_MAX_LENGTH_IMAGE); Str_Copy (Ban->Img,row[3],Ban_MAX_LENGTH_IMAGE);
Ban->Img[Ban_MAX_LENGTH_IMAGE] = '\0';
/* Get the URL of the banner (row[4]) */ /* Get the URL of the banner (row[4]) */
strncpy (Ban->WWW,row[4],Cns_MAX_LENGTH_WWW); Str_Copy (Ban->WWW,row[4],Cns_MAX_LENGTH_WWW);
Ban->WWW[Cns_MAX_LENGTH_WWW] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -624,8 +616,7 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (CurrentBanName,NewBanName,MaxLength); Str_Copy (CurrentBanName,NewBanName,MaxLength);
CurrentBanName[MaxLength] = '\0';
Ban_EditBanners (); Ban_EditBanners ();
} }
@ -683,8 +674,7 @@ void Ban_ChangeBannerImg (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_image_empty); Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_image_empty);
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (Ban->Img,NewImg,Ban_MAX_LENGTH_IMAGE); Str_Copy (Ban->Img,NewImg,Ban_MAX_LENGTH_IMAGE);
Ban->Img[Ban_MAX_LENGTH_IMAGE] = '\0';
Ban_EditBanners (); Ban_EditBanners ();
} }
@ -728,8 +718,7 @@ void Ban_ChangeBannerWWW (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty); Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty);
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (Ban->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Ban->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Ban->WWW[Cns_MAX_LENGTH_WWW] = '\0';
Ban_EditBanners (); Ban_EditBanners ();
} }

View File

@ -1038,16 +1038,13 @@ void Ctr_GetListCentres (long InsCod)
Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]); Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
/* Get the short name of the centre (row[5]) */ /* Get the short name of the centre (row[5]) */
strncpy (Ctr->ShrtName,row[5],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME); Str_Copy (Ctr->ShrtName,row[5],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME);
Ctr->ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME] = '\0';
/* Get the full name of the centre (row[6]) */ /* Get the full name of the centre (row[6]) */
strncpy (Ctr->FullName,row[6],Ctr_MAX_LENGTH_CENTRE_FULL_NAME); Str_Copy (Ctr->FullName,row[6],Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
Ctr->FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME] = '\0';
/* Get the URL of the centre (row[7]) */ /* Get the URL of the centre (row[7]) */
strncpy (Ctr->WWW,row[7],Cns_MAX_LENGTH_WWW); Str_Copy (Ctr->WWW,row[7],Cns_MAX_LENGTH_WWW);
Ctr->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* Get number of users who claim to belong to this centre (row[8]) */ /* Get number of users who claim to belong to this centre (row[8]) */
if (sscanf (row[8],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1) if (sscanf (row[8],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1)
@ -1136,16 +1133,13 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr)
Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]); Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]);
/* Get the short name of the centre (row[4]) */ /* Get the short name of the centre (row[4]) */
strncpy (Ctr->ShrtName,row[4],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME); Str_Copy (Ctr->ShrtName,row[4],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME);
Ctr->ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME] = '\0';
/* Get the full name of the centre (row[5]) */ /* Get the full name of the centre (row[5]) */
strncpy (Ctr->FullName,row[5],Ctr_MAX_LENGTH_CENTRE_FULL_NAME); Str_Copy (Ctr->FullName,row[5],Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
Ctr->FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME] = '\0';
/* Get the URL of the centre (row[6]) */ /* Get the URL of the centre (row[6]) */
strncpy (Ctr->WWW,row[6],Cns_MAX_LENGTH_WWW); Str_Copy (Ctr->WWW,row[6],Cns_MAX_LENGTH_WWW);
Ctr->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* Get number of users who claim to belong to this centre (row[7]) */ /* Get number of users who claim to belong to this centre (row[7]) */
if (sscanf (row[7],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1) if (sscanf (row[7],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1)
@ -1223,8 +1217,7 @@ void Ctr_GetShortNameOfCentreByCod (struct Centre *Ctr)
/***** Get the short name of this centre *****/ /***** Get the short name of this centre *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Ctr->ShrtName,row[0],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME); Str_Copy (Ctr->ShrtName,row[0],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME);
Ctr->ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -1263,8 +1256,7 @@ static void Ctr_GetPhotoAttribution (long CtrCod,char **PhotoAttribution)
if (((*PhotoAttribution) = (char *) malloc (Length + 1)) == NULL) if (((*PhotoAttribution) = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for photo attribution."); Lay_ShowErrorAndExit ("Error allocating memory for photo attribution.");
strncpy (*PhotoAttribution,row[0],Length); Str_Copy (*PhotoAttribution,row[0],Length);
(*PhotoAttribution)[Length] = '\0';
} }
} }
@ -1518,8 +1510,7 @@ static void Ctr_ListCentresForEdition (void)
} }
else else
{ {
strncpy (WWW,Ctr->WWW,Ctr_MAX_LENGTH_WWW_ON_SCREEN); Str_Copy (WWW,Ctr->WWW,Ctr_MAX_LENGTH_WWW_ON_SCREEN);
WWW[Ctr_MAX_LENGTH_WWW_ON_SCREEN] = '\0';
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\">%s", fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\">%s",
Ctr->WWW,Ctr->WWW,WWW); Ctr->WWW,Ctr->WWW,WWW);
if (strlen (Ctr->WWW) > Ctr_MAX_LENGTH_WWW_ON_SCREEN) if (strlen (Ctr->WWW) > Ctr_MAX_LENGTH_WWW_ON_SCREEN)
@ -1959,8 +1950,7 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull
CurrentCtrName,NewCtrName); CurrentCtrName,NewCtrName);
/* Change current centre name in order to display it properly */ /* Change current centre name in order to display it properly */
strncpy (CurrentCtrName,NewCtrName,MaxLength); Str_Copy (CurrentCtrName,NewCtrName,MaxLength);
CurrentCtrName[MaxLength] = '\0';
} }
} }
else // The same name else // The same name
@ -2013,8 +2003,7 @@ void Ctr_ChangeCtrWWW (void)
/***** Update database changing old WWW by new WWW *****/ /***** Update database changing old WWW by new WWW *****/
Ctr_UpdateCtrWWWDB (Ctr->CtrCod,NewWWW); Ctr_UpdateCtrWWWDB (Ctr->CtrCod,NewWWW);
strncpy (Ctr->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Ctr->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Ctr->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);
@ -2045,9 +2034,7 @@ void Ctr_ChangeCtrWWWInConfig (void)
{ {
/***** Update database changing old WWW by new WWW *****/ /***** Update database changing old WWW by new WWW *****/
Ctr_UpdateCtrWWWDB (Gbl.CurrentCtr.Ctr.CtrCod,NewWWW); Ctr_UpdateCtrWWWDB (Gbl.CurrentCtr.Ctr.CtrCod,NewWWW);
Str_Copy (Gbl.CurrentCtr.Ctr.WWW,NewWWW,Cns_MAX_LENGTH_WWW);
strncpy (Gbl.CurrentCtr.Ctr.WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Gbl.CurrentCtr.Ctr.WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);
@ -2252,7 +2239,7 @@ void Ctr_ReceivePhoto (void)
char FileNameImgSrc[PATH_MAX+1]; char FileNameImgSrc[PATH_MAX+1];
char *PtrExtension; char *PtrExtension;
size_t LengthExtension; size_t LengthExtension;
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
char PathImgPriv[PATH_MAX+1]; char PathImgPriv[PATH_MAX+1];
char FileNameImgTmp[PATH_MAX+1]; // Full name (including path and .jpg) of the destination temporary file char FileNameImgTmp[PATH_MAX+1]; // Full name (including path and .jpg) of the destination temporary file
char FileNameImg[PATH_MAX+1]; // Full name (including path and .jpg) of the destination file char FileNameImg[PATH_MAX+1]; // Full name (including path and .jpg) of the destination file

View File

@ -183,19 +183,20 @@
// TODO: Draw future dates in attendance, surveys, assignments in blue? // TODO: Draw future dates in attendance, surveys, assignments in blue?
// TODO: Fix bug in generate a test: after entering a number of questions with empty tags and type of answers, number of questions is not remembered // TODO: Fix bug in generate a test: after entering a number of questions with empty tags and type of answers, number of questions is not remembered
// TODO: Fix big when editing a test question with images: when "Change image" is selected but no image is uploades, other images (for example in answers) are lost // TODO: Fix bug when editing a test question with images: when "Change image" is selected but no image is uploades, other images (for example in answers) are lost
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.114.3 (2017-01-15)" #define Log_PLATFORM_VERSION "SWAD 16.115 (2017-01-15)"
#define CSS_FILE "swad16.111.5.css" #define CSS_FILE "swad16.111.5.css"
#define JS_FILE "swad16.114.js" #define JS_FILE "swad16.114.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/* /*
Version 16.115: Jan 15, 2017 Code refactoring related to string copy. (211046 lines)
Version 16.114.3: Jan 15, 2017 Fixed bug in chat. (211412 lines) Version 16.114.3: Jan 15, 2017 Fixed bug in chat. (211412 lines)
Version 16.114.2: Jan 15, 2017 Fixed bug in file browser. (211412 lines) Version 16.114.2: Jan 15, 2017 Fixed bug in file browser. (211412 lines)
Version 16.114.1: Jan 15, 2017 Fixed bug in string concatenation. (211411 lines) Version 16.114.1: Jan 15, 2017 Fixed bug in string concatenation. (211411 lines)

View File

@ -29,7 +29,6 @@
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include <stdio.h> // For sprintf #include <stdio.h> // For sprintf
#include <string.h> #include <string.h>
#include <sys/param.h> // For MAX()
#include "swad_chat.h" #include "swad_chat.h"
#include "swad_config.h" #include "swad_config.h"
@ -416,8 +415,7 @@ void Cht_OpenChatWindow (void)
Usr_GetMyCourses (); Usr_GetMyCourses ();
/***** Build my user's name *****/ /***** Build my user's name *****/
strncpy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME); Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME);
UsrName[Usr_MAX_BYTES_NAME] = '\0';
if (Gbl.Usrs.Me.UsrDat.Surname2[0]) if (Gbl.Usrs.Me.UsrDat.Surname2[0])
{ {
Str_Concat (UsrName," ",Usr_MAX_BYTES_NAME); Str_Concat (UsrName," ",Usr_MAX_BYTES_NAME);
@ -428,12 +426,8 @@ void Cht_OpenChatWindow (void)
/***** Build the lists of available rooms *****/ /***** Build the lists of available rooms *****/
sprintf (ListRoomCodes,"#%s",RoomCode); sprintf (ListRoomCodes,"#%s",RoomCode);
Str_Copy (ListRoomShortNames,RoomShortName,sizeof (ListRoomShortNames) - 1);
strncpy (ListRoomShortNames,RoomShortName,sizeof (ListRoomShortNames) - 1); Str_Copy (ListRoomFullNames ,RoomFullName,sizeof (ListRoomFullNames) - 1);
ListRoomShortNames[sizeof (ListRoomShortNames) - 1] = '\0';
strncpy (ListRoomFullNames ,RoomFullName,sizeof (ListRoomFullNames) - 1);
ListRoomFullNames[sizeof (ListRoomFullNames) - 1] = '\0';
if (strcmp (RoomCode,"GBL_USR")) if (strcmp (RoomCode,"GBL_USR"))
{ {

View File

@ -464,49 +464,43 @@ static void Con_ShowConnectedUsrsBelongingToLocation (void)
switch (Gbl.Scope.Current) switch (Gbl.Scope.Current)
{ {
case Sco_SCOPE_SYS: // Show connected users in the whole platform case Sco_SCOPE_SYS: // Show connected users in the whole platform
strncpy (LocationName,Cfg_PLATFORM_SHORT_NAME, Str_Copy (LocationName,Cfg_PLATFORM_SHORT_NAME,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
break; break;
case Sco_SCOPE_CTY: // Show connected users in the current country case Sco_SCOPE_CTY: // Show connected users in the current country
if (Gbl.CurrentCty.Cty.CtyCod <= 0) // There is no country selected if (Gbl.CurrentCty.Cty.CtyCod <= 0) // There is no country selected
return; return;
strncpy (LocationName,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language], Str_Copy (LocationName,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language],
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
break; break;
case Sco_SCOPE_INS: // Show connected users in the current institution case Sco_SCOPE_INS: // Show connected users in the current institution
if (Gbl.CurrentIns.Ins.InsCod <= 0) // There is no institution selected if (Gbl.CurrentIns.Ins.InsCod <= 0) // There is no institution selected
return; return;
strncpy (LocationName,Gbl.CurrentIns.Ins.ShrtName, Str_Copy (LocationName,Gbl.CurrentIns.Ins.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
break; break;
case Sco_SCOPE_CTR: // Show connected users in the current centre case Sco_SCOPE_CTR: // Show connected users in the current centre
if (Gbl.CurrentCtr.Ctr.CtrCod <= 0) // There is no centre selected if (Gbl.CurrentCtr.Ctr.CtrCod <= 0) // There is no centre selected
return; return;
strncpy (LocationName,Gbl.CurrentCtr.Ctr.ShrtName, Str_Copy (LocationName,Gbl.CurrentCtr.Ctr.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
break; break;
case Sco_SCOPE_DEG: // Show connected users in the current degree case Sco_SCOPE_DEG: // Show connected users in the current degree
if (Gbl.CurrentDeg.Deg.DegCod <= 0) // There is no degree selected if (Gbl.CurrentDeg.Deg.DegCod <= 0) // There is no degree selected
return; return;
strncpy (LocationName,Gbl.CurrentDeg.Deg.ShrtName, Str_Copy (LocationName,Gbl.CurrentDeg.Deg.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
break; break;
case Sco_SCOPE_CRS: // Show connected users in the current course case Sco_SCOPE_CRS: // Show connected users in the current course
if (Gbl.CurrentCrs.Crs.CrsCod <= 0) // There is no course selected if (Gbl.CurrentCrs.Crs.CrsCod <= 0) // There is no course selected
return; return;
strncpy (LocationName,Gbl.CurrentCrs.Crs.ShrtName, Str_Copy (LocationName,Gbl.CurrentCrs.Crs.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
break; break;
default: default:
return; return;
@ -575,9 +569,8 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void)
Act_LinkFormSubmitUnique (Txt_Connected_users,The_ClassConnected[Gbl.Prefs.Theme]); Act_LinkFormSubmitUnique (Txt_Connected_users,The_ClassConnected[Gbl.Prefs.Theme]);
/* Write total number of connected users belonging to the current course */ /* Write total number of connected users belonging to the current course */
strncpy (CourseName,Gbl.CurrentCrs.Crs.ShrtName, Str_Copy (CourseName,Gbl.CurrentCrs.Crs.ShrtName,
Crs_MAX_LENGTH_COURSE_SHRT_NAME); Crs_MAX_LENGTH_COURSE_SHRT_NAME);
CourseName[Crs_MAX_LENGTH_COURSE_SHRT_NAME] = '\0';
Str_LimitLengthHTMLStr (CourseName,12); Str_LimitLengthHTMLStr (CourseName,12);
Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNKNOWN,&Usrs); Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNKNOWN,&Usrs);
fprintf (Gbl.F.Out,"%u %s %s", fprintf (Gbl.F.Out,"%u %s %s",

View File

@ -46,9 +46,9 @@ int main (void)
unsigned NumUsrs = 0; unsigned NumUsrs = 0;
unsigned i; unsigned i;
long UsrCod; long UsrCod;
char UsrID[16+1]; char UsrID[16 + 1];
char OldPathUsr[PATH_MAX+1]; char OldPathUsr[PATH_MAX + 1];
char Command[1024+PATH_MAX*2]; char Command[1024 + PATH_MAX * 2];
sprintf (Command,"mv %s/%s %s/%s_backup", sprintf (Command,"mv %s/%s %s/%s_backup",
PATH_SWAD_PRIVATE,FOLDER_USR, PATH_SWAD_PRIVATE,FOLDER_USR,
@ -94,8 +94,7 @@ int main (void)
if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod
if (row[1]) if (row[1])
{ {
strncpy (UsrID,row[1],16); // UsrID Str_Copy (UsrID,row[1],16); // UsrID
UsrID[16] = '\0';
sprintf (OldPathUsr,"%s/%s_backup/%c/%s", sprintf (OldPathUsr,"%s/%s_backup/%c/%s",
PATH_SWAD_PRIVATE,FOLDER_USR,UsrID[strlen (UsrID)-1],UsrID); PATH_SWAD_PRIVATE,FOLDER_USR,UsrID[strlen (UsrID)-1],UsrID);

View File

@ -3,6 +3,8 @@
// Author: Antonio Cañas Vargas // Author: Antonio Cañas Vargas
// Compile with: gcc -Wall -O1 swad_convert_photos.c -o swad_convert_photos -lmysqlclient -L/usr/lib64/mysql // Compile with: gcc -Wall -O1 swad_convert_photos.c -o swad_convert_photos -lmysqlclient -L/usr/lib64/mysql
#include "swad_ID.h"
#include <mysql/mysql.h> #include <mysql/mysql.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
@ -47,9 +49,9 @@ int main (void)
unsigned NumPhotos = 0; unsigned NumPhotos = 0;
unsigned i; unsigned i;
long UsrCod; long UsrCod;
char UsrID[16+1]; char UsrID[ID_MAX_LENGTH_USR_ID + 1];
char OldPathPhoto[PATH_MAX+1]; char OldPathPhoto[PATH_MAX + 1];
char Command[1024+PATH_MAX*2]; char Command[1024 + PATH_MAX * 2];
sprintf (Command,"mv %s/%s %s/%s_backup", sprintf (Command,"mv %s/%s %s/%s_backup",
PATH_SWAD_PRIVATE,FOLDER_PHOTO, PATH_SWAD_PRIVATE,FOLDER_PHOTO,
@ -95,8 +97,7 @@ int main (void)
if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod
if (row[1]) if (row[1])
{ {
strncpy (UsrID,row[1],16); // UsrID Str_Copy (UsrID,row[1],ID_MAX_LENGTH_USR_ID); // UsrID
UsrID[16] = '\0';
sprintf (OldPathPhoto,"%s/%s_backup/%s_original.jpg", sprintf (OldPathPhoto,"%s/%s_backup/%s_original.jpg",
PATH_SWAD_PRIVATE,FOLDER_PHOTO,UsrID); PATH_SWAD_PRIVATE,FOLDER_PHOTO,UsrID);
if (CheckIfPathExists (OldPathPhoto)) if (CheckIfPathExists (OldPathPhoto))

View File

@ -3,6 +3,8 @@
// Author: Antonio Cañas Vargas // Author: Antonio Cañas Vargas
// Compile with: gcc -Wall -O1 swad_convert_works.c -o swad_convert_works -lmysqlclient -L/usr/lib64/mysql // Compile with: gcc -Wall -O1 swad_convert_works.c -o swad_convert_works -lmysqlclient -L/usr/lib64/mysql
#include "swad_ID.h"
#include <mysql/mysql.h> #include <mysql/mysql.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
@ -50,11 +52,11 @@ int main (void)
unsigned NumUsr; unsigned NumUsr;
long CrsCod; long CrsCod;
long UsrCod; long UsrCod;
char UsrID[16+1]; char UsrID[ID_MAX_LENGTH_USR_ID + 1];
char OldPathUsrs[PATH_MAX+1]; char OldPathUsrs[PATH_MAX + 1];
char OldPathUsr[PATH_MAX+1]; char OldPathUsr[PATH_MAX + 1];
char Path02u[PATH_MAX+1]; char Path02u[PATH_MAX + 1];
char Command[1024+PATH_MAX*2]; char Command[1024 + PATH_MAX * 2];
if (mysql_init (&mysql) == NULL) if (mysql_init (&mysql) == NULL)
{ {
@ -124,8 +126,7 @@ int main (void)
if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod
if (row[1]) if (row[1])
{ {
strncpy (UsrID,row[1],16); // UsrID Str_Copy (UsrID,row[1],ID_MAX_LENGTH_USR_ID); // UsrID
UsrID[16] = '\0';
sprintf (OldPathUsr,"%s_backup/%s",OldPathUsrs,UsrID); sprintf (OldPathUsr,"%s_backup/%s",OldPathUsrs,UsrID);
if (CheckIfPathExists (OldPathUsr)) if (CheckIfPathExists (OldPathUsr))

View File

@ -773,8 +773,8 @@ void Cty_DrawCountryMapAndNameWithLink (struct Country *Cty,Act_Action_t Action,
Cty_DrawCountryMap (Cty,ClassMap); Cty_DrawCountryMap (Cty,ClassMap);
/***** Write country name and end link *****/ /***** Write country name and end link *****/
strncpy (CountryName,Cty->Name[Gbl.Prefs.Language],Cty_MAX_BYTES_COUNTRY_NAME); Str_Copy (CountryName,Cty->Name[Gbl.Prefs.Language],
CountryName[Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; Cty_MAX_BYTES_COUNTRY_NAME);
Str_LimitLengthHTMLStr (CountryName,30); Str_LimitLengthHTMLStr (CountryName,30);
fprintf (Gbl.F.Out,"&nbsp;%s (%s)</a>", fprintf (Gbl.F.Out,"&nbsp;%s (%s)</a>",
CountryName, CountryName,
@ -1031,8 +1031,7 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
Lay_ShowErrorAndExit ("Wrong code of country."); Lay_ShowErrorAndExit ("Wrong code of country.");
/* Get Alpha-2 country code (row[1]) */ /* Get Alpha-2 country code (row[1]) */
strncpy (Cty->Alpha2,row[1],2); Str_Copy (Cty->Alpha2,row[1],2);
Cty->Alpha2[2] = '\0';
switch (GetExtraData) switch (GetExtraData)
{ {
@ -1049,9 +1048,8 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
Cty->NumUsrs = 0; Cty->NumUsrs = 0;
/* Get the name of the country in current language */ /* Get the name of the country in current language */
strncpy (Cty->Name[Gbl.Prefs.Language],row[2], Str_Copy (Cty->Name[Gbl.Prefs.Language],row[2],
Cty_MAX_BYTES_COUNTRY_NAME); Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Gbl.Prefs.Language][Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
break; break;
case Cty_GET_EXTRA_DATA: case Cty_GET_EXTRA_DATA:
/* Get the name of the country in several languages */ /* Get the name of the country in several languages */
@ -1059,13 +1057,10 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
Lan <= Txt_NUM_LANGUAGES; Lan <= Txt_NUM_LANGUAGES;
Lan++) Lan++)
{ {
strncpy (Cty->Name[Lan],row[1 + Lan], Str_Copy (Cty->Name[Lan],row[1 + Lan],
Cty_MAX_BYTES_COUNTRY_NAME); Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Lan][Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; Str_Copy (Cty->WWW[Lan],row[1 + Txt_NUM_LANGUAGES + Lan],
Cns_MAX_LENGTH_WWW);
strncpy (Cty->WWW[Lan],row[1 + Txt_NUM_LANGUAGES + Lan],
Cns_MAX_LENGTH_WWW);
Cty->WWW[Lan][Cns_MAX_LENGTH_WWW] = '\0';
} }
/* Get number of users who claim to belong to this country */ /* Get number of users who claim to belong to this country */
@ -1230,11 +1225,8 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
Lan <= Txt_NUM_LANGUAGES; Lan <= Txt_NUM_LANGUAGES;
Lan++) Lan++)
if (Lan == Gbl.Prefs.Language) if (Lan == Gbl.Prefs.Language)
{ Str_Copy (Cty->Name[Lan],Txt_Another_country,
strncpy (Cty->Name[Lan],Txt_Another_country, Cty_MAX_BYTES_COUNTRY_NAME);
Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Lan][Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
}
else else
Cty->Name[Lan][0] = '\0'; Cty->Name[Lan][0] = '\0';
return false; return false;
@ -1298,19 +1290,15 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get Alpha-2 country code (row[0]) */ /* Get Alpha-2 country code (row[0]) */
strncpy (Cty->Alpha2,row[0],2); Str_Copy (Cty->Alpha2,row[0],2);
Cty->Alpha2[2] = '\0';
switch (GetExtraData) switch (GetExtraData)
{ {
case Cty_GET_BASIC_DATA: case Cty_GET_BASIC_DATA:
/* Get name and WWW of the country in current language */ /* Get name and WWW of the country in current language */
strncpy (Cty->Name[Gbl.Prefs.Language],row[1], Str_Copy (Cty->Name[Gbl.Prefs.Language],row[1],
Cty_MAX_BYTES_COUNTRY_NAME); Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Gbl.Prefs.Language][Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; Str_Copy (Cty->WWW[Gbl.Prefs.Language],row[2],Cns_MAX_LENGTH_WWW);
strncpy (Cty->WWW[Gbl.Prefs.Language],row[2],Cns_MAX_LENGTH_WWW);
Cty->WWW[Gbl.Prefs.Language][Cns_MAX_LENGTH_WWW] = '\0';
break; break;
case Cty_GET_EXTRA_DATA: case Cty_GET_EXTRA_DATA:
/* Get name and WWW of the country in several languages */ /* Get name and WWW of the country in several languages */
@ -1318,13 +1306,10 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
Lan <= Txt_NUM_LANGUAGES; Lan <= Txt_NUM_LANGUAGES;
Lan++) Lan++)
{ {
strncpy (Cty->Name[Lan],row[Lan], Str_Copy (Cty->Name[Lan],row[Lan],
Cty_MAX_BYTES_COUNTRY_NAME); Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Lan][Cty_MAX_BYTES_COUNTRY_NAME] = '\0'; Str_Copy (Cty->WWW[Lan],row[Txt_NUM_LANGUAGES + Lan],
Cns_MAX_LENGTH_WWW);
strncpy (Cty->WWW[Lan],row[Txt_NUM_LANGUAGES + Lan],
Cns_MAX_LENGTH_WWW);
Cty->WWW[Lan][Cns_MAX_LENGTH_WWW] = '\0';
} }
/* Get number of users who claim to belong to this country */ /* Get number of users who claim to belong to this country */
@ -1375,8 +1360,7 @@ void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME+1])
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the name of the country */ /* Get the name of the country */
strncpy (CtyName,row[0],Cty_MAX_BYTES_COUNTRY_NAME); Str_Copy (CtyName,row[0],Cty_MAX_BYTES_COUNTRY_NAME);
CtyName[Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -1414,8 +1398,7 @@ static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution)
if (((*MapAttribution) = (char *) malloc (Length + 1)) == NULL) if (((*MapAttribution) = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for map attribution."); Lay_ShowErrorAndExit ("Error allocating memory for map attribution.");
strncpy (*MapAttribution,row[0],Length); Str_Copy (*MapAttribution,row[0],Length);
(*MapAttribution)[Length] = '\0';
} }
} }
@ -1724,8 +1707,7 @@ void Cty_RenameCountry (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (Cty->Name[Language],NewCtyName,Cty_MAX_BYTES_COUNTRY_NAME); Str_Copy (Cty->Name[Language],NewCtyName,Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Language][Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
Cty_EditCountries (); Cty_EditCountries ();
} }
@ -1812,8 +1794,7 @@ void Cty_ChangeCtyWWW (void)
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (Cty->WWW[Language],NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Cty->WWW[Language],NewWWW,Cns_MAX_LENGTH_WWW);
Cty->WWW[Language][Cns_MAX_LENGTH_WWW] = '\0';
Cty_EditCountries (); Cty_EditCountries ();
} }

View File

@ -643,8 +643,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Highlight ? ClassHighlight : Highlight ? ClassHighlight :
ClassNormal,NULL); ClassNormal,NULL);
Log_DrawLogo (Sco_SCOPE_INS,Ins.InsCod,Ins.ShrtName,20,NULL,true); Log_DrawLogo (Sco_SCOPE_INS,Ins.InsCod,Ins.ShrtName,20,NULL,true);
strncpy (InsFullName,Ins.FullName,Ins_MAX_LENGTH_INSTIT_FULL_NAME); Str_Copy (InsFullName,Ins.FullName,Ins_MAX_LENGTH_INSTIT_FULL_NAME);
InsFullName[Ins_MAX_LENGTH_INSTIT_FULL_NAME] = '\0';
Str_LimitLengthHTMLStr (InsFullName,Crs_MAX_BYTES_TXT_LINK); Str_LimitLengthHTMLStr (InsFullName,Crs_MAX_BYTES_TXT_LINK);
fprintf (Gbl.F.Out,"&nbsp;%s</a>",InsFullName); fprintf (Gbl.F.Out,"&nbsp;%s</a>",InsFullName);
Act_FormEnd (); Act_FormEnd ();
@ -679,8 +678,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Highlight ? ClassHighlight : Highlight ? ClassHighlight :
ClassNormal,NULL); ClassNormal,NULL);
Log_DrawLogo (Sco_SCOPE_CTR,Ctr.CtrCod,Ctr.ShrtName,20,NULL,true); Log_DrawLogo (Sco_SCOPE_CTR,Ctr.CtrCod,Ctr.ShrtName,20,NULL,true);
strncpy (CtrFullName,Ctr.FullName,Ctr_MAX_LENGTH_CENTRE_FULL_NAME); Str_Copy (CtrFullName,Ctr.FullName,Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
CtrFullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME] = '\0';
Str_LimitLengthHTMLStr (CtrFullName,Crs_MAX_BYTES_TXT_LINK); Str_LimitLengthHTMLStr (CtrFullName,Crs_MAX_BYTES_TXT_LINK);
fprintf (Gbl.F.Out,"&nbsp;%s</a>",CtrFullName); fprintf (Gbl.F.Out,"&nbsp;%s</a>",CtrFullName);
Act_FormEnd (); Act_FormEnd ();
@ -715,8 +713,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Highlight ? ClassHighlight : Highlight ? ClassHighlight :
ClassNormal,NULL); ClassNormal,NULL);
Log_DrawLogo (Sco_SCOPE_DEG,Deg.DegCod,Deg.ShrtName,20,NULL,true); Log_DrawLogo (Sco_SCOPE_DEG,Deg.DegCod,Deg.ShrtName,20,NULL,true);
strncpy (DegFullName,Deg.FullName,Deg_MAX_LENGTH_DEGREE_FULL_NAME); Str_Copy (DegFullName,Deg.FullName,Deg_MAX_LENGTH_DEGREE_FULL_NAME);
DegFullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME] = '\0';
Str_LimitLengthHTMLStr (DegFullName,Crs_MAX_BYTES_TXT_LINK); Str_LimitLengthHTMLStr (DegFullName,Crs_MAX_BYTES_TXT_LINK);
fprintf (Gbl.F.Out,"&nbsp;%s</a>",DegFullName); fprintf (Gbl.F.Out,"&nbsp;%s</a>",DegFullName);
Act_FormEnd (); Act_FormEnd ();
@ -756,8 +753,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Gbl.Prefs.IconsURL, Gbl.Prefs.IconsURL,
Crs.ShrtName, Crs.ShrtName,
Crs.FullName); Crs.FullName);
strncpy (CrsFullName,Crs.FullName,Crs_MAX_LENGTH_COURSE_FULL_NAME); Str_Copy (CrsFullName,Crs.FullName,
CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0'; Crs_MAX_LENGTH_COURSE_FULL_NAME);
Str_LimitLengthHTMLStr (CrsFullName,Crs_MAX_BYTES_TXT_LINK); Str_LimitLengthHTMLStr (CrsFullName,Crs_MAX_BYTES_TXT_LINK);
fprintf (Gbl.F.Out,"&nbsp;%s</a>",CrsFullName); fprintf (Gbl.F.Out,"&nbsp;%s</a>",CrsFullName);
Act_FormEnd (); Act_FormEnd ();
@ -2106,8 +2103,7 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row)
Crs->Year = Deg_ConvStrToYear (row[2]); Crs->Year = Deg_ConvStrToYear (row[2]);
/***** Get institutional course code (row[3]) *****/ /***** Get institutional course code (row[3]) *****/
strncpy (Crs->InstitutionalCrsCod,row[3],Crs_LENGTH_INSTITUTIONAL_CRS_COD); Str_Copy (Crs->InstitutionalCrsCod,row[3],Crs_LENGTH_INSTITUTIONAL_CRS_COD);
Crs->InstitutionalCrsCod[Crs_LENGTH_INSTITUTIONAL_CRS_COD] = '\0';
/***** Get course status (row[4]) *****/ /***** Get course status (row[4]) *****/
if (sscanf (row[4],"%u",&(Crs->Status)) != 1) if (sscanf (row[4],"%u",&(Crs->Status)) != 1)
@ -2117,12 +2113,10 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row)
Crs->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[5]); Crs->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[5]);
/***** Get the short name of the course (row[6]) *****/ /***** Get the short name of the course (row[6]) *****/
strncpy (Crs->ShrtName,row[6],Crs_MAX_LENGTH_COURSE_SHRT_NAME); Str_Copy (Crs->ShrtName,row[6],Crs_MAX_LENGTH_COURSE_SHRT_NAME);
Crs->ShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME] = '\0';
/***** Get the full name of the course (row[7]) *****/ /***** Get the full name of the course (row[7]) *****/
strncpy (Crs->FullName,row[7],Crs_MAX_LENGTH_COURSE_FULL_NAME); Str_Copy (Crs->FullName,row[7],Crs_MAX_LENGTH_COURSE_FULL_NAME);
Crs->FullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0';
/***** Get number of teachers *****/ /***** Get number of teachers *****/
Crs->NumTchs = Usr_GetNumUsrsInCrs (Rol_TEACHER,Crs->CrsCod); Crs->NumTchs = Usr_GetNumUsrsInCrs (Rol_TEACHER,Crs->CrsCod);
@ -2161,11 +2155,8 @@ static void Crs_GetShortNamesByCod (long CrsCod,
/***** Get the short name of this course *****/ /***** Get the short name of this course *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (CrsShortName,row[0],Crs_MAX_LENGTH_COURSE_SHRT_NAME); Str_Copy (CrsShortName,row[0],Crs_MAX_LENGTH_COURSE_SHRT_NAME);
CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME] = '\0'; Str_Copy (DegShortName,row[1],Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
strncpy (DegShortName,row[1],Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -2390,9 +2381,8 @@ void Crs_ChangeInsCrsCod (void)
else else
{ {
Gbl.Error = true; Gbl.Error = true;
strncpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course, Str_Copy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course,
Lay_MAX_BYTES_ALERT); Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
} }
} }
@ -2598,9 +2588,8 @@ void Crs_ChangeCrsYear (void)
else else
{ {
Gbl.Error = true; Gbl.Error = true;
strncpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course, Str_Copy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course,
Lay_MAX_BYTES_ALERT); Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
} }
} }
@ -2635,8 +2624,8 @@ void Crs_UpdateInstitutionalCrsCod (struct Course *Crs,const char *NewInstitutio
DB_QueryUPDATE (Query,"can not update the institutional code of the current course"); DB_QueryUPDATE (Query,"can not update the institutional code of the current course");
/***** Copy institutional course code *****/ /***** Copy institutional course code *****/
strncpy (Crs->InstitutionalCrsCod,NewInstitutionalCrsCod,Crs_LENGTH_INSTITUTIONAL_CRS_COD); Str_Copy (Crs->InstitutionalCrsCod,NewInstitutionalCrsCod,
Crs->InstitutionalCrsCod[Crs_LENGTH_INSTITUTIONAL_CRS_COD] = '\0'; Crs_LENGTH_INSTITUTIONAL_CRS_COD);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2744,8 +2733,7 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull
CurrentCrsName,NewCrsName); CurrentCrsName,NewCrsName);
/* Change current course name in order to display it properly */ /* Change current course name in order to display it properly */
strncpy (CurrentCrsName,NewCrsName,MaxLength); Str_Copy (CurrentCrsName,NewCrsName,MaxLength);
CurrentCrsName[MaxLength] = '\0';
} }
} }
else // The same name else // The same name
@ -2756,9 +2744,8 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull
else else
{ {
Gbl.Error = true; Gbl.Error = true;
strncpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course, Str_Copy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course,
Lay_MAX_BYTES_ALERT); Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
} }
} }

View File

@ -76,13 +76,13 @@ typedef enum
struct Course struct Course
{ {
long CrsCod; long CrsCod;
char InstitutionalCrsCod[Crs_LENGTH_INSTITUTIONAL_CRS_COD+1]; // Institutional code of the course char InstitutionalCrsCod[Crs_LENGTH_INSTITUTIONAL_CRS_COD + 1]; // Institutional code of the course
long DegCod; long DegCod;
unsigned Year; // Year: 0 (optatives), 1, 2, 3... unsigned Year; // Year: 0 (optatives), 1, 2, 3...
Crs_Status_t Status; // Course status Crs_Status_t Status; // Course status
long RequesterUsrCod; // User code of the person who requested the creation of this course long RequesterUsrCod; // User code of the person who requested the creation of this course
char ShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME+1]; // Short name of course char ShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1]; // Short name of course
char FullName[Crs_MAX_LENGTH_COURSE_FULL_NAME+1]; // Full name of course char FullName[Crs_MAX_LENGTH_COURSE_FULL_NAME + 1]; // Full name of course
unsigned NumUsrs; // Number of users (students + teachers) unsigned NumUsrs; // Number of users (students + teachers)
unsigned NumTchs; // Number of teachers unsigned NumTchs; // Number of teachers
unsigned NumStds; // Number of students unsigned NumStds; // Number of students

View File

@ -142,8 +142,7 @@ bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDD)
{ {
if (sscanf (YYYYMMDD,"%04u%02u%02u",&(Date->Year),&(Date->Month),&(Date->Day)) == 3) if (sscanf (YYYYMMDD,"%04u%02u%02u",&(Date->Year),&(Date->Month),&(Date->Day)) == 3)
{ {
strncpy (Date->YYYYMMDD,YYYYMMDD,Dat_LENGTH_YYYYMMDD); Str_Copy (Date->YYYYMMDD,YYYYMMDD,Dat_LENGTH_YYYYMMDD);
Date->YYYYMMDD[Dat_LENGTH_YYYYMMDD] = '\0';
return true; return true;
} }
else else
@ -1264,8 +1263,7 @@ void Dat_AssignDate (struct Date *DateDst,struct Date *DateSrc)
DateDst->Month = DateSrc->Month; DateDst->Month = DateSrc->Month;
DateDst->Day = DateSrc->Day; DateDst->Day = DateSrc->Day;
DateDst->Week = DateSrc->Week; DateDst->Week = DateSrc->Week;
strncpy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD,Dat_LENGTH_YYYYMMDD); Str_Copy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD,Dat_LENGTH_YYYYMMDD);
DateDst->YYYYMMDD[Dat_LENGTH_YYYYMMDD] = '\0';
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -822,8 +822,7 @@ static void Deg_ListDegreesForEdition (void)
} }
else else
{ {
strncpy (WWW,Deg->WWW,Deg_MAX_LENGTH_WWW_ON_SCREEN); Str_Copy (WWW,Deg->WWW,Deg_MAX_LENGTH_WWW_ON_SCREEN);
WWW[Deg_MAX_LENGTH_WWW_ON_SCREEN] = '\0';
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\"" fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"DAT\" title=\"%s\">%s", " class=\"DAT\" title=\"%s\">%s",
Deg->WWW,Deg->WWW,WWW); Deg->WWW,Deg->WWW,WWW);
@ -1738,16 +1737,13 @@ static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row)
Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]); Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
/***** Get degree short name (row[5]) *****/ /***** Get degree short name (row[5]) *****/
strncpy (Deg->ShrtName,row[5],Deg_MAX_LENGTH_DEGREE_SHRT_NAME); Str_Copy (Deg->ShrtName,row[5],Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
Deg->ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0';
/***** Get degree full name (row[6]) *****/ /***** Get degree full name (row[6]) *****/
strncpy (Deg->FullName,row[6],Deg_MAX_LENGTH_DEGREE_FULL_NAME); Str_Copy (Deg->FullName,row[6],Deg_MAX_LENGTH_DEGREE_FULL_NAME);
Deg->FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME] = '\0';
/***** Get WWW (row[7]) *****/ /***** Get WWW (row[7]) *****/
strncpy (Deg->WWW,row[7],Cns_MAX_LENGTH_WWW); Str_Copy (Deg->WWW,row[7],Cns_MAX_LENGTH_WWW);
Deg->WWW[Cns_MAX_LENGTH_WWW] = '\0';
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1772,8 +1768,7 @@ void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg)
/***** Get the short name of this degree *****/ /***** Get the short name of this degree *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Deg->ShrtName,row[0],Deg_MAX_LENGTH_DEGREE_SHRT_NAME); Str_Copy (Deg->ShrtName,row[0],Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
Deg->ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -2011,8 +2006,7 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull
CurrentDegName,NewDegName); CurrentDegName,NewDegName);
/* Change current degree name in order to display it properly */ /* Change current degree name in order to display it properly */
strncpy (CurrentDegName,NewDegName,MaxLength); Str_Copy (CurrentDegName,NewDegName,MaxLength);
CurrentDegName[MaxLength] = '\0';
} }
} }
else // The same name else // The same name
@ -2143,8 +2137,7 @@ void Deg_ChangeDegWWW (void)
{ {
/***** Update the table changing old WWW by new WWW *****/ /***** Update the table changing old WWW by new WWW *****/
Deg_UpdateDegWWWDB (Deg->DegCod,NewWWW); Deg_UpdateDegWWWDB (Deg->DegCod,NewWWW);
strncpy (Deg->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Deg->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Deg->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);
@ -2175,8 +2168,7 @@ void Deg_ChangeDegWWWInConfig (void)
{ {
/***** Update the table changing old WWW by new WWW *****/ /***** Update the table changing old WWW by new WWW *****/
Deg_UpdateDegWWWDB (Gbl.CurrentDeg.Deg.DegCod,NewWWW); Deg_UpdateDegWWWDB (Gbl.CurrentDeg.Deg.DegCod,NewWWW);
strncpy (Gbl.CurrentDeg.Deg.WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Gbl.CurrentDeg.Deg.WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Gbl.CurrentDeg.Deg.WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);

View File

@ -481,8 +481,8 @@ void DT_GetListDegreeTypes (void)
Lay_ShowErrorAndExit ("Wrong code of type of degree."); Lay_ShowErrorAndExit ("Wrong code of type of degree.");
/* Get degree type name (row[1]) */ /* Get degree type name (row[1]) */
strncpy (Gbl.Degs.DegTypes.Lst[NumRow].DegTypName,row[1],Deg_MAX_LENGTH_DEGREE_TYPE_NAME); Str_Copy (Gbl.Degs.DegTypes.Lst[NumRow].DegTypName,row[1],
Gbl.Degs.DegTypes.Lst[NumRow].DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME] = '\0'; Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
/* Number of degrees of this type (row[2]) */ /* Number of degrees of this type (row[2]) */
if (sscanf (row[2],"%u",&Gbl.Degs.DegTypes.Lst[NumRow].NumDegs) != 1) if (sscanf (row[2],"%u",&Gbl.Degs.DegTypes.Lst[NumRow].NumDegs) != 1)
@ -650,8 +650,7 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the name of the degree type (row[0]) */ /* Get the name of the degree type (row[0]) */
strncpy (DegTyp->DegTypName,row[0],Deg_MAX_LENGTH_DEGREE_TYPE_NAME); Str_Copy (DegTyp->DegTypName,row[0],Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
DegTyp->DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME] = '\0';
/* Count number of degrees of this type */ /* Count number of degrees of this type */
DegTyp->NumDegs = DT_CountNumDegsOfType (DegTyp->DegTypCod); DegTyp->NumDegs = DT_CountNumDegsOfType (DegTyp->DegTypCod);
@ -786,8 +785,7 @@ void DT_RenameDegreeType (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (DegTyp->DegTypName,NewNameDegTyp,Deg_MAX_LENGTH_DEGREE_TYPE_NAME); Str_Copy (DegTyp->DegTypName,NewNameDegTyp,Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
DegTyp->DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME] = '\0';
DT_ReqEditDegreeTypes (); DT_ReqEditDegreeTypes ();
} }

View File

@ -351,16 +351,13 @@ void Dpt_GetListDepartments (long InsCod)
Lay_ShowErrorAndExit ("Wrong code of institution."); Lay_ShowErrorAndExit ("Wrong code of institution.");
/* Get the short name of the department (row[2]) */ /* Get the short name of the department (row[2]) */
strncpy (Dpt->ShrtName,row[2],MAX_LENGTH_DEPARTMENT_SHRT_NAME); Str_Copy (Dpt->ShrtName,row[2],MAX_LENGTH_DEPARTMENT_SHRT_NAME);
Dpt->ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME] = '\0';
/* Get the full name of the department (row[3]) */ /* Get the full name of the department (row[3]) */
strncpy (Dpt->FullName,row[3],MAX_LENGTH_DEPARTMENT_FULL_NAME); Str_Copy (Dpt->FullName,row[3],MAX_LENGTH_DEPARTMENT_FULL_NAME);
Dpt->FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME] = '\0';
/* Get the URL of the department (row[4]) */ /* Get the URL of the department (row[4]) */
strncpy (Dpt->WWW,row[4],Cns_MAX_LENGTH_WWW); Str_Copy (Dpt->WWW,row[4],Cns_MAX_LENGTH_WWW);
Dpt->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* Get number of teachers in this department (row[5]) */ /* Get number of teachers in this department (row[5]) */
if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1) if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1)
@ -394,11 +391,10 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt)
/***** Check if department code is correct *****/ /***** Check if department code is correct *****/
if (Dpt->DptCod == 0) if (Dpt->DptCod == 0)
{ {
strncpy (Dpt->ShrtName,Txt_Another_department,MAX_LENGTH_DEPARTMENT_SHRT_NAME); Str_Copy (Dpt->ShrtName,Txt_Another_department,
Dpt->ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME] = '\0'; MAX_LENGTH_DEPARTMENT_SHRT_NAME);
Str_Copy (Dpt->FullName,Txt_Another_department,
strncpy (Dpt->FullName,Txt_Another_department,MAX_LENGTH_DEPARTMENT_FULL_NAME); MAX_LENGTH_DEPARTMENT_FULL_NAME);
Dpt->FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME] = '\0';
} }
else if (Dpt->DptCod > 0) else if (Dpt->DptCod > 0)
{ {
@ -430,16 +426,13 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt)
Dpt->InsCod = Str_ConvertStrCodToLongCod (row[0]); Dpt->InsCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get the short name of the department (row[1]) */ /* Get the short name of the department (row[1]) */
strncpy (Dpt->ShrtName,row[1],MAX_LENGTH_DEPARTMENT_SHRT_NAME); Str_Copy (Dpt->ShrtName,row[1],MAX_LENGTH_DEPARTMENT_SHRT_NAME);
Dpt->ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME] = '\0';
/* Get the full name of the department (row[2]) */ /* Get the full name of the department (row[2]) */
strncpy (Dpt->FullName,row[2],MAX_LENGTH_DEPARTMENT_FULL_NAME); Str_Copy (Dpt->FullName,row[2],MAX_LENGTH_DEPARTMENT_FULL_NAME);
Dpt->FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME] = '\0';
/* Get the URL of the department (row[3]) */ /* Get the URL of the department (row[3]) */
strncpy (Dpt->WWW,row[3],Cns_MAX_LENGTH_WWW); Str_Copy (Dpt->WWW,row[3],Cns_MAX_LENGTH_WWW);
Dpt->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* Get number of teachers in this department (row[4]) */ /* Get number of teachers in this department (row[4]) */
if (sscanf (row[4],"%u",&Dpt->NumTchs) != 1) if (sscanf (row[4],"%u",&Dpt->NumTchs) != 1)
@ -798,8 +791,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (CurrentDptName,NewDptName,MaxLength); Str_Copy (CurrentDptName,NewDptName,MaxLength);
CurrentDptName[MaxLength] = '\0';
Dpt_EditDepartments (); Dpt_EditDepartments ();
} }
@ -860,8 +852,7 @@ void Dpt_ChangeDptWWW (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (Dpt->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Dpt->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Dpt->WWW[Cns_MAX_LENGTH_WWW] = '\0';
Dpt_EditDepartments (); Dpt_EditDepartments ();
} }

View File

@ -396,8 +396,8 @@ void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
/* Role (row[0]) */ /* Role (row[0]) */
Role = Rol_ConvertUnsignedStrToRole (row[0]); Role = Rol_ConvertUnsignedStrToRole (row[0]);
strncpy (SummaryStr,Txt_ROLES_SINGUL_Abc[Role][UsrDat.Sex],Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,Txt_ROLES_SINGUL_Abc[Role][UsrDat.Sex],
SummaryStr[Cns_MAX_BYTES_TEXT] = '\0'; Cns_MAX_BYTES_TEXT);
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -1442,10 +1442,8 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
{ {
/***** Find users for this user's ID *****/ /***** Find users for this user's ID *****/
ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID
Str_Copy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,
strncpy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,ID_MAX_LENGTH_USR_ID); ID_MAX_LENGTH_USR_ID);
UsrDat.IDs.List[0].ID[ID_MAX_LENGTH_USR_ID] = '\0';
Str_ConvertToUpperText (UsrDat.IDs.List[0].ID); Str_ConvertToUpperText (UsrDat.IDs.List[0].ID);
ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false); ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false);
} }
@ -1568,10 +1566,8 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
/* Find users for this user's ID */ /* Find users for this user's ID */
ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID ID_ReallocateListIDs (&UsrDat,1); // Only one user's ID
Str_Copy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,
strncpy (UsrDat.IDs.List[0].ID,UsrDat.UsrIDNickOrEmail,ID_MAX_LENGTH_USR_ID); ID_MAX_LENGTH_USR_ID);
UsrDat.IDs.List[0].ID[ID_MAX_LENGTH_USR_ID] = '\0';
Str_ConvertToUpperText (UsrDat.IDs.List[0].ID); Str_ConvertToUpperText (UsrDat.IDs.List[0].ID);
ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false); ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false);
} }
@ -1973,8 +1969,8 @@ void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char
/* Role (row[1]) */ /* Role (row[1]) */
DesiredRole = Rol_ConvertUnsignedStrToRole (row[1]); DesiredRole = Rol_ConvertUnsignedStrToRole (row[1]);
strncpy (SummaryStr,Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex],Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex],
SummaryStr[Cns_MAX_BYTES_TEXT] = '\0'; Cns_MAX_BYTES_TEXT);
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);

View File

@ -97,9 +97,9 @@ void Exa_PutFrmEditAExamAnnouncement (void)
Exa_AllocMemExamAnnouncement (); Exa_AllocMemExamAnnouncement ();
/***** Get the code of the exam announcement *****/ /***** Get the code of the exam announcement *****/
Gbl.ExamAnnouncements.ExaDat.ExaCod = Exa_GetParamsExamAnnouncement (); Gbl.ExamAnns.ExaDat.ExaCod = Exa_GetParamsExamAnnouncement ();
if (Gbl.ExamAnnouncements.ExaDat.ExaCod > 0) // -1 indicates that this is a new exam announcement if (Gbl.ExamAnns.ExaDat.ExaCod > 0) // -1 indicates that this is a new exam announcement
/***** Read exam announcement from the database *****/ /***** Read exam announcement from the database *****/
Exa_GetDataExamAnnouncementFromDB (); Exa_GetDataExamAnnouncementFromDB ();
@ -123,83 +123,80 @@ static long Exa_GetParamsExamAnnouncement (void)
ExaCod = Exa_GetParamExaCod (); ExaCod = Exa_GetParamExaCod ();
/***** Get the name of the course (it is allowed to be different from the official name of the course) *****/ /***** Get the name of the course (it is allowed to be different from the official name of the course) *****/
Par_GetParToText ("CrsName",Gbl.ExamAnnouncements.ExaDat.CrsFullName,Cns_MAX_BYTES_STRING); Par_GetParToText ("CrsName",Gbl.ExamAnns.ExaDat.CrsFullName,Cns_MAX_BYTES_STRING);
// If the parameter is not present or is empty, initialize the string to the full name of the current course // If the parameter is not present or is empty, initialize the string to the full name of the current course
if (!Gbl.ExamAnnouncements.ExaDat.CrsFullName[0]) if (!Gbl.ExamAnns.ExaDat.CrsFullName[0])
{ Str_Copy (Gbl.ExamAnns.ExaDat.CrsFullName,Gbl.CurrentCrs.Crs.FullName,
strncpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,Gbl.CurrentCrs.Crs.FullName, Crs_MAX_LENGTH_COURSE_FULL_NAME);
Crs_MAX_LENGTH_COURSE_FULL_NAME);
Gbl.ExamAnnouncements.ExaDat.CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0';
}
/***** Get the year *****/ /***** Get the year *****/
Par_GetParToText ("Year",UnsignedStr,10); Par_GetParToText ("Year",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.Year) != 1) if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnns.ExaDat.Year) != 1)
Gbl.ExamAnnouncements.ExaDat.Year = Gbl.CurrentCrs.Crs.Year; Gbl.ExamAnns.ExaDat.Year = Gbl.CurrentCrs.Crs.Year;
if (Gbl.ExamAnnouncements.ExaDat.Year > Deg_MAX_YEARS_PER_DEGREE) if (Gbl.ExamAnns.ExaDat.Year > Deg_MAX_YEARS_PER_DEGREE)
Gbl.ExamAnnouncements.ExaDat.Year = Gbl.CurrentCrs.Crs.Year; Gbl.ExamAnns.ExaDat.Year = Gbl.CurrentCrs.Crs.Year;
/***** Get the type of exam announcement *****/ /***** Get the type of exam announcement *****/
Par_GetParToText ("ExamSession",Gbl.ExamAnnouncements.ExaDat.Session,Cns_MAX_BYTES_STRING); Par_GetParToText ("ExamSession",Gbl.ExamAnns.ExaDat.Session,Cns_MAX_BYTES_STRING);
/***** Get the data of the exam *****/ /***** Get the data of the exam *****/
Dat_GetDateFromForm ("ExamDay","ExamMonth","ExamYear", Dat_GetDateFromForm ("ExamDay","ExamMonth","ExamYear",
&Gbl.ExamAnnouncements.ExaDat.ExamDate.Day, &Gbl.ExamAnns.ExaDat.ExamDate.Day,
&Gbl.ExamAnnouncements.ExaDat.ExamDate.Month, &Gbl.ExamAnns.ExaDat.ExamDate.Month,
&Gbl.ExamAnnouncements.ExaDat.ExamDate.Year); &Gbl.ExamAnns.ExaDat.ExamDate.Year);
if (Gbl.ExamAnnouncements.ExaDat.ExamDate.Day == 0 || if (Gbl.ExamAnns.ExaDat.ExamDate.Day == 0 ||
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month == 0 || Gbl.ExamAnns.ExaDat.ExamDate.Month == 0 ||
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year == 0) Gbl.ExamAnns.ExaDat.ExamDate.Year == 0)
{ {
Gbl.ExamAnnouncements.ExaDat.ExamDate.Day = Gbl.Now.Date.Day; Gbl.ExamAnns.ExaDat.ExamDate.Day = Gbl.Now.Date.Day;
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month = Gbl.Now.Date.Month; Gbl.ExamAnns.ExaDat.ExamDate.Month = Gbl.Now.Date.Month;
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year = Gbl.Now.Date.Year; Gbl.ExamAnns.ExaDat.ExamDate.Year = Gbl.Now.Date.Year;
} }
/***** Get the hour of the exam *****/ /***** Get the hour of the exam *****/
Par_GetParToText ("ExamHour",UnsignedStr,10); Par_GetParToText ("ExamHour",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.StartTime.Hour) != 1) if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnns.ExaDat.StartTime.Hour) != 1)
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour = 0; Gbl.ExamAnns.ExaDat.StartTime.Hour = 0;
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Hour > 23) if (Gbl.ExamAnns.ExaDat.StartTime.Hour > 23)
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour = 0; Gbl.ExamAnns.ExaDat.StartTime.Hour = 0;
Par_GetParToText ("ExamMinute",UnsignedStr,10); Par_GetParToText ("ExamMinute",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.StartTime.Minute) != 1) if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnns.ExaDat.StartTime.Minute) != 1)
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute = 0; Gbl.ExamAnns.ExaDat.StartTime.Minute = 0;
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Minute > 59) if (Gbl.ExamAnns.ExaDat.StartTime.Minute > 59)
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute = 0; Gbl.ExamAnns.ExaDat.StartTime.Minute = 0;
/***** Get the duration of the exam *****/ /***** Get the duration of the exam *****/
Par_GetParToText ("DurationHour",UnsignedStr,10); Par_GetParToText ("DurationHour",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.Duration.Hour) != 1) if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnns.ExaDat.Duration.Hour) != 1)
Gbl.ExamAnnouncements.ExaDat.Duration.Hour = 0; Gbl.ExamAnns.ExaDat.Duration.Hour = 0;
if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour > 23) if (Gbl.ExamAnns.ExaDat.Duration.Hour > 23)
Gbl.ExamAnnouncements.ExaDat.Duration.Hour = 0; Gbl.ExamAnns.ExaDat.Duration.Hour = 0;
Par_GetParToText ("DurationMinute",UnsignedStr,10); Par_GetParToText ("DurationMinute",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.Duration.Minute) != 1) if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnns.ExaDat.Duration.Minute) != 1)
Gbl.ExamAnnouncements.ExaDat.Duration.Minute = 0; Gbl.ExamAnns.ExaDat.Duration.Minute = 0;
if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute > 59) if (Gbl.ExamAnns.ExaDat.Duration.Minute > 59)
Gbl.ExamAnnouncements.ExaDat.Duration.Minute = 0; Gbl.ExamAnns.ExaDat.Duration.Minute = 0;
/***** Get the place where the exam will happen *****/ /***** Get the place where the exam will happen *****/
Par_GetParToHTML ("Place",Gbl.ExamAnnouncements.ExaDat.Place,Cns_MAX_BYTES_TEXT); Par_GetParToHTML ("Place",Gbl.ExamAnns.ExaDat.Place,Cns_MAX_BYTES_TEXT);
/***** Get the modality of exam *****/ /***** Get the modality of exam *****/
Par_GetParToHTML ("ExamMode",Gbl.ExamAnnouncements.ExaDat.Mode,Cns_MAX_BYTES_TEXT); Par_GetParToHTML ("ExamMode",Gbl.ExamAnns.ExaDat.Mode,Cns_MAX_BYTES_TEXT);
/***** Get the structure of exam *****/ /***** Get the structure of exam *****/
Par_GetParToHTML ("Structure",Gbl.ExamAnnouncements.ExaDat.Structure,Cns_MAX_BYTES_TEXT); Par_GetParToHTML ("Structure",Gbl.ExamAnns.ExaDat.Structure,Cns_MAX_BYTES_TEXT);
/***** Get the mandatory documentation *****/ /***** Get the mandatory documentation *****/
Par_GetParToHTML ("DocRequired",Gbl.ExamAnnouncements.ExaDat.DocRequired,Cns_MAX_BYTES_TEXT); Par_GetParToHTML ("DocRequired",Gbl.ExamAnns.ExaDat.DocRequired,Cns_MAX_BYTES_TEXT);
/***** Get the mandatory material *****/ /***** Get the mandatory material *****/
Par_GetParToHTML ("MatRequired",Gbl.ExamAnnouncements.ExaDat.MatRequired,Cns_MAX_BYTES_TEXT); Par_GetParToHTML ("MatRequired",Gbl.ExamAnns.ExaDat.MatRequired,Cns_MAX_BYTES_TEXT);
/***** Get the allowed material *****/ /***** Get the allowed material *****/
Par_GetParToHTML ("MatAllowed",Gbl.ExamAnnouncements.ExaDat.MatAllowed,Cns_MAX_BYTES_TEXT); Par_GetParToHTML ("MatAllowed",Gbl.ExamAnns.ExaDat.MatAllowed,Cns_MAX_BYTES_TEXT);
/***** Get other information *****/ /***** Get other information *****/
Par_GetParToHTML ("OtherInfo",Gbl.ExamAnnouncements.ExaDat.OtherInfo,Cns_MAX_BYTES_TEXT); Par_GetParToHTML ("OtherInfo",Gbl.ExamAnns.ExaDat.OtherInfo,Cns_MAX_BYTES_TEXT);
return ExaCod; return ExaCod;
} }
@ -210,25 +207,25 @@ static long Exa_GetParamsExamAnnouncement (void)
static void Exa_AllocMemExamAnnouncement (void) static void Exa_AllocMemExamAnnouncement (void)
{ {
if ((Gbl.ExamAnnouncements.ExaDat.Place = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.Place = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnnouncements.ExaDat.Mode = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.Mode = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnnouncements.ExaDat.Structure = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.Structure = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnnouncements.ExaDat.DocRequired = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.DocRequired = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnnouncements.ExaDat.MatRequired = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.MatRequired = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnnouncements.ExaDat.MatAllowed = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.MatAllowed = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnnouncements.ExaDat.OtherInfo = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.OtherInfo = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
} }
@ -238,40 +235,40 @@ static void Exa_AllocMemExamAnnouncement (void)
void Exa_FreeMemExamAnnouncement (void) void Exa_FreeMemExamAnnouncement (void)
{ {
if (Gbl.ExamAnnouncements.ExaDat.Place) if (Gbl.ExamAnns.ExaDat.Place)
{ {
free ((void *) Gbl.ExamAnnouncements.ExaDat.Place); free ((void *) Gbl.ExamAnns.ExaDat.Place);
Gbl.ExamAnnouncements.ExaDat.Place = NULL; Gbl.ExamAnns.ExaDat.Place = NULL;
} }
if (Gbl.ExamAnnouncements.ExaDat.Mode) if (Gbl.ExamAnns.ExaDat.Mode)
{ {
free ((void *) Gbl.ExamAnnouncements.ExaDat.Mode); free ((void *) Gbl.ExamAnns.ExaDat.Mode);
Gbl.ExamAnnouncements.ExaDat.Mode = NULL; Gbl.ExamAnns.ExaDat.Mode = NULL;
} }
if (Gbl.ExamAnnouncements.ExaDat.Structure) if (Gbl.ExamAnns.ExaDat.Structure)
{ {
free ((void *) Gbl.ExamAnnouncements.ExaDat.Structure); free ((void *) Gbl.ExamAnns.ExaDat.Structure);
Gbl.ExamAnnouncements.ExaDat.Structure = NULL; Gbl.ExamAnns.ExaDat.Structure = NULL;
} }
if (Gbl.ExamAnnouncements.ExaDat.DocRequired) if (Gbl.ExamAnns.ExaDat.DocRequired)
{ {
free ((void *) Gbl.ExamAnnouncements.ExaDat.DocRequired); free ((void *) Gbl.ExamAnns.ExaDat.DocRequired);
Gbl.ExamAnnouncements.ExaDat.DocRequired = NULL; Gbl.ExamAnns.ExaDat.DocRequired = NULL;
} }
if (Gbl.ExamAnnouncements.ExaDat.MatRequired) if (Gbl.ExamAnns.ExaDat.MatRequired)
{ {
free ((void *) Gbl.ExamAnnouncements.ExaDat.MatRequired); free ((void *) Gbl.ExamAnns.ExaDat.MatRequired);
Gbl.ExamAnnouncements.ExaDat.MatRequired = NULL; Gbl.ExamAnns.ExaDat.MatRequired = NULL;
} }
if (Gbl.ExamAnnouncements.ExaDat.MatAllowed) if (Gbl.ExamAnns.ExaDat.MatAllowed)
{ {
free ((void *) Gbl.ExamAnnouncements.ExaDat.MatAllowed); free ((void *) Gbl.ExamAnns.ExaDat.MatAllowed);
Gbl.ExamAnnouncements.ExaDat.MatAllowed = NULL; Gbl.ExamAnns.ExaDat.MatAllowed = NULL;
} }
if (Gbl.ExamAnnouncements.ExaDat.OtherInfo) if (Gbl.ExamAnns.ExaDat.OtherInfo)
{ {
free ((void *) Gbl.ExamAnnouncements.ExaDat.OtherInfo); free ((void *) Gbl.ExamAnns.ExaDat.OtherInfo);
Gbl.ExamAnnouncements.ExaDat.OtherInfo = NULL; Gbl.ExamAnns.ExaDat.OtherInfo = NULL;
} }
} }
@ -287,12 +284,12 @@ void Exa_ReceiveExamAnnouncement1 (void)
Exa_AllocMemExamAnnouncement (); Exa_AllocMemExamAnnouncement ();
/***** Get parameters of the exam announcement *****/ /***** Get parameters of the exam announcement *****/
Gbl.ExamAnnouncements.ExaDat.ExaCod = Exa_GetParamsExamAnnouncement (); Gbl.ExamAnns.ExaDat.ExaCod = Exa_GetParamsExamAnnouncement ();
Gbl.ExamAnnouncements.NewExamAnnouncement = (Gbl.ExamAnnouncements.ExaDat.ExaCod < 0); Gbl.ExamAnns.NewExamAnnouncement = (Gbl.ExamAnns.ExaDat.ExaCod < 0);
/***** Add the exam announcement to the database and read it again from the database *****/ /***** Add the exam announcement to the database and read it again from the database *****/
if (Gbl.ExamAnnouncements.NewExamAnnouncement) if (Gbl.ExamAnns.NewExamAnnouncement)
Gbl.ExamAnnouncements.ExaDat.ExaCod = Exa_AddExamAnnouncementToDB (); Gbl.ExamAnns.ExaDat.ExaCod = Exa_AddExamAnnouncementToDB ();
else else
Exa_ModifyExamAnnouncementInDB (); Exa_ModifyExamAnnouncementInDB ();
@ -309,16 +306,16 @@ void Exa_ReceiveExamAnnouncement2 (void)
/***** Show message *****/ /***** Show message *****/
Lay_ShowAlert (Lay_SUCCESS, Lay_ShowAlert (Lay_SUCCESS,
Gbl.ExamAnnouncements.NewExamAnnouncement ? Txt_Created_new_announcement_of_exam : Gbl.ExamAnns.NewExamAnnouncement ? Txt_Created_new_announcement_of_exam :
Txt_The_announcement_of_exam_has_been_successfully_updated); Txt_The_announcement_of_exam_has_been_successfully_updated);
/***** Notify by email about the new exam announcement *****/ /***** Notify by email about the new exam announcement *****/
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_EXAM_ANNOUNCEMENT,Gbl.ExamAnnouncements.ExaDat.ExaCod))) if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_EXAM_ANNOUNCEMENT,Gbl.ExamAnns.ExaDat.ExaCod)))
Exa_UpdateNumUsrsNotifiedByEMailAboutExamAnnouncement (Gbl.ExamAnnouncements.ExaDat.ExaCod,NumUsrsToBeNotifiedByEMail); Exa_UpdateNumUsrsNotifiedByEMailAboutExamAnnouncement (Gbl.ExamAnns.ExaDat.ExaCod,NumUsrsToBeNotifiedByEMail);
Ntf_ShowAlertNumUsrsToBeNotifiedByEMail (NumUsrsToBeNotifiedByEMail); Ntf_ShowAlertNumUsrsToBeNotifiedByEMail (NumUsrsToBeNotifiedByEMail);
/***** Create a new social note about the new exam announcement *****/ /***** Create a new social note about the new exam announcement *****/
Soc_StoreAndPublishSocialNote (Soc_NOTE_EXAM_ANNOUNCEMENT,Gbl.ExamAnnouncements.ExaDat.ExaCod,&SocPub); Soc_StoreAndPublishSocialNote (Soc_NOTE_EXAM_ANNOUNCEMENT,Gbl.ExamAnns.ExaDat.ExaCod,&SocPub);
/***** Update RSS of current course *****/ /***** Update RSS of current course *****/
RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs); RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs);
@ -352,7 +349,7 @@ void Exa_PrintExamAnnouncement (void)
Exa_AllocMemExamAnnouncement (); Exa_AllocMemExamAnnouncement ();
/***** Get the code of the exam announcement *****/ /***** Get the code of the exam announcement *****/
if ((Gbl.ExamAnnouncements.ExaDat.ExaCod = Exa_GetParamExaCod ()) <= 0) if ((Gbl.ExamAnns.ExaDat.ExaCod = Exa_GetParamExaCod ()) <= 0)
Lay_ShowErrorAndExit ("Code of exam announcement is missing."); Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
/***** Read exam announcement from the database *****/ /***** Read exam announcement from the database *****/
@ -375,7 +372,7 @@ void Exa_ReqRemoveExamAnnouncement (void)
extern const char *Txt_Remove; extern const char *Txt_Remove;
/***** Get the code of the exam announcement *****/ /***** Get the code of the exam announcement *****/
if ((Gbl.ExamAnnouncements.ExaDat.ExaCod = Exa_GetParamExaCod ()) <= 0) if ((Gbl.ExamAnns.ExaDat.ExaCod = Exa_GetParamExaCod ()) <= 0)
Lay_ShowErrorAndExit ("Code of exam announcement is missing."); Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
/***** Message *****/ /***** Message *****/
@ -537,7 +534,7 @@ void Exa_GetExaCodToHighlight (void)
{ {
/***** Get the exam announcement code /***** Get the exam announcement code
of the exam announcement to highlight *****/ of the exam announcement to highlight *****/
Gbl.ExamAnnouncements.HighlightExaCod = Exa_GetParamExaCod (); Gbl.ExamAnns.HighlightExaCod = Exa_GetParamExaCod ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -548,7 +545,7 @@ void Exa_GetDateToHighlight (void)
{ {
/***** Get the date (in YYYY-MM-DD format) /***** Get the date (in YYYY-MM-DD format)
of the exam announcements to highlight *****/ of the exam announcements to highlight *****/
Par_GetParToText ("Date",Gbl.ExamAnnouncements.HighlightDate,4+1+2+1+2); Par_GetParToText ("Date",Gbl.ExamAnns.HighlightDate,4+1+2+1+2);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -579,14 +576,14 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT); (unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT);
/***** Show one highlighted exam announcement *****/ /***** Show one highlighted exam announcement *****/
if (Gbl.ExamAnnouncements.HighlightExaCod > 0) if (Gbl.ExamAnns.HighlightExaCod > 0)
{ {
/***** Get one exam announcement from database *****/ /***** Get one exam announcement from database *****/
sprintf (Query,"SELECT ExaCod" sprintf (Query,"SELECT ExaCod"
" FROM exam_announcements" " FROM exam_announcements"
" WHERE ExaCod='%ld'" " WHERE ExaCod='%ld'"
" AND CrsCod='%ld' AND %s", " AND CrsCod='%ld' AND %s",
Gbl.ExamAnnouncements.HighlightExaCod, Gbl.ExamAnns.HighlightExaCod,
Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus); Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus);
NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course for listing"); NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course for listing");
@ -598,7 +595,7 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
/***** Get the code of the exam announcement (row[0]) *****/ /***** Get the code of the exam announcement (row[0]) *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%ld",&Gbl.ExamAnnouncements.ExaDat.ExaCod) != 1) if (sscanf (row[0],"%ld",&Gbl.ExamAnns.ExaDat.ExaCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of exam announcement."); Lay_ShowErrorAndExit ("Wrong code of exam announcement.");
/***** Allocate memory for the exam announcement *****/ /***** Allocate memory for the exam announcement *****/
@ -616,7 +613,7 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
} }
/***** Show highlighted exam announcements of a date *****/ /***** Show highlighted exam announcements of a date *****/
if (Gbl.ExamAnnouncements.HighlightDate[0]) if (Gbl.ExamAnns.HighlightDate[0])
{ {
/***** Get exam announcements (the most recent first) /***** Get exam announcements (the most recent first)
in current course for a date from database *****/ in current course for a date from database *****/
@ -626,7 +623,7 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
" AND DATE(ExamDate)='%s'" " AND DATE(ExamDate)='%s'"
" ORDER BY ExamDate DESC", " ORDER BY ExamDate DESC",
Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus, Gbl.CurrentCrs.Crs.CrsCod,SubQueryStatus,
Gbl.ExamAnnouncements.HighlightDate); Gbl.ExamAnns.HighlightDate);
NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course for listing"); NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course for listing");
/***** List the existing exam announcements *****/ /***** List the existing exam announcements *****/
@ -637,7 +634,7 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
/***** Get the code of the exam announcement (row[0]) *****/ /***** Get the code of the exam announcement (row[0]) *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%ld",&Gbl.ExamAnnouncements.ExaDat.ExaCod) != 1) if (sscanf (row[0],"%ld",&Gbl.ExamAnns.ExaDat.ExaCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of exam announcement."); Lay_ShowErrorAndExit ("Wrong code of exam announcement.");
/***** Allocate memory for the exam announcement *****/ /***** Allocate memory for the exam announcement *****/
@ -665,8 +662,8 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
/***** Start frame *****/ /***** Start frame *****/
Lay_StartRoundFrame (NULL, Lay_StartRoundFrame (NULL,
(Gbl.ExamAnnouncements.HighlightExaCod > 0 || (Gbl.ExamAnns.HighlightExaCod > 0 ||
Gbl.ExamAnnouncements.HighlightDate[0]) ? Txt_All_announcements_of_exams : Gbl.ExamAnns.HighlightDate[0]) ? Txt_All_announcements_of_exams :
Txt_Announcements_of_exams, Txt_Announcements_of_exams,
ICanEdit ? Exa_PutIconToCreateNewExamAnnouncement : ICanEdit ? Exa_PutIconToCreateNewExamAnnouncement :
NULL, NULL,
@ -688,7 +685,7 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx
/***** Get the code of the exam announcement (row[0]) *****/ /***** Get the code of the exam announcement (row[0]) *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%ld",&Gbl.ExamAnnouncements.ExaDat.ExaCod) != 1) if (sscanf (row[0],"%ld",&Gbl.ExamAnns.ExaDat.ExaCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of exam announcement."); Lay_ShowErrorAndExit ("Wrong code of exam announcement.");
/***** Allocate memory for the exam announcement *****/ /***** Allocate memory for the exam announcement *****/
@ -765,23 +762,23 @@ static long Exa_AddExamAnnouncementToDB (void)
"'%s','%s','%s','%s','%s','%s')", "'%s','%s','%s','%s','%s','%s')",
Gbl.CurrentCrs.Crs.CrsCod, Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT, (unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT,
Gbl.ExamAnnouncements.ExaDat.CrsFullName, Gbl.ExamAnns.ExaDat.CrsFullName,
Gbl.ExamAnnouncements.ExaDat.Year, Gbl.ExamAnns.ExaDat.Year,
Gbl.ExamAnnouncements.ExaDat.Session, Gbl.ExamAnns.ExaDat.Session,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year, Gbl.ExamAnns.ExaDat.ExamDate.Year,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month, Gbl.ExamAnns.ExaDat.ExamDate.Month,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Day, Gbl.ExamAnns.ExaDat.ExamDate.Day,
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour, Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute, Gbl.ExamAnns.ExaDat.StartTime.Minute,
Gbl.ExamAnnouncements.ExaDat.Duration.Hour, Gbl.ExamAnns.ExaDat.Duration.Hour,
Gbl.ExamAnnouncements.ExaDat.Duration.Minute, Gbl.ExamAnns.ExaDat.Duration.Minute,
Gbl.ExamAnnouncements.ExaDat.Place, Gbl.ExamAnns.ExaDat.Place,
Gbl.ExamAnnouncements.ExaDat.Mode, Gbl.ExamAnns.ExaDat.Mode,
Gbl.ExamAnnouncements.ExaDat.Structure, Gbl.ExamAnns.ExaDat.Structure,
Gbl.ExamAnnouncements.ExaDat.DocRequired, Gbl.ExamAnns.ExaDat.DocRequired,
Gbl.ExamAnnouncements.ExaDat.MatRequired, Gbl.ExamAnns.ExaDat.MatRequired,
Gbl.ExamAnnouncements.ExaDat.MatAllowed, Gbl.ExamAnns.ExaDat.MatAllowed,
Gbl.ExamAnnouncements.ExaDat.OtherInfo); Gbl.ExamAnns.ExaDat.OtherInfo);
ExaCod = DB_QueryINSERTandReturnCode (Query,"can not create a new exam announcement"); ExaCod = DB_QueryINSERTandReturnCode (Query,"can not create a new exam announcement");
free ((void *) Query); free ((void *) Query);
@ -806,24 +803,24 @@ static void Exa_ModifyExamAnnouncementInDB (void)
"Place='%s',ExamMode='%s',Structure='%s'," "Place='%s',ExamMode='%s',Structure='%s',"
"DocRequired='%s',MatRequired='%s',MatAllowed='%s',OtherInfo='%s'" "DocRequired='%s',MatRequired='%s',MatAllowed='%s',OtherInfo='%s'"
" WHERE ExaCod='%ld'", " WHERE ExaCod='%ld'",
Gbl.ExamAnnouncements.ExaDat.CrsFullName, Gbl.ExamAnns.ExaDat.CrsFullName,
Gbl.ExamAnnouncements.ExaDat.Year, Gbl.ExamAnns.ExaDat.Year,
Gbl.ExamAnnouncements.ExaDat.Session, Gbl.ExamAnns.ExaDat.Session,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year, Gbl.ExamAnns.ExaDat.ExamDate.Year,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month, Gbl.ExamAnns.ExaDat.ExamDate.Month,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Day, Gbl.ExamAnns.ExaDat.ExamDate.Day,
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour, Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute, Gbl.ExamAnns.ExaDat.StartTime.Minute,
Gbl.ExamAnnouncements.ExaDat.Duration.Hour, Gbl.ExamAnns.ExaDat.Duration.Hour,
Gbl.ExamAnnouncements.ExaDat.Duration.Minute, Gbl.ExamAnns.ExaDat.Duration.Minute,
Gbl.ExamAnnouncements.ExaDat.Place, Gbl.ExamAnns.ExaDat.Place,
Gbl.ExamAnnouncements.ExaDat.Mode, Gbl.ExamAnns.ExaDat.Mode,
Gbl.ExamAnnouncements.ExaDat.Structure, Gbl.ExamAnns.ExaDat.Structure,
Gbl.ExamAnnouncements.ExaDat.DocRequired, Gbl.ExamAnns.ExaDat.DocRequired,
Gbl.ExamAnnouncements.ExaDat.MatRequired, Gbl.ExamAnns.ExaDat.MatRequired,
Gbl.ExamAnnouncements.ExaDat.MatAllowed, Gbl.ExamAnns.ExaDat.MatAllowed,
Gbl.ExamAnnouncements.ExaDat.OtherInfo, Gbl.ExamAnns.ExaDat.OtherInfo,
Gbl.ExamAnnouncements.ExaDat.ExaCod); Gbl.ExamAnns.ExaDat.ExaCod);
DB_QueryUPDATE (Query,"can not update an exam announcement"); DB_QueryUPDATE (Query,"can not update an exam announcement");
free ((void *) Query); free ((void *) Query);
} }
@ -853,12 +850,12 @@ void Exa_CreateListDatesOfExamAnnouncements (void)
NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course"); NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course");
/***** The result of the query may be empty *****/ /***** The result of the query may be empty *****/
Gbl.ExamAnnouncements.Lst = NULL; Gbl.ExamAnns.Lst = NULL;
Gbl.ExamAnnouncements.NumExaAnns = 0; Gbl.ExamAnns.NumExaAnns = 0;
if (NumExaAnns) if (NumExaAnns)
{ {
/***** Allocate memory for the list *****/ /***** Allocate memory for the list *****/
if ((Gbl.ExamAnnouncements.Lst = (struct Date *) calloc (NumExaAnns,sizeof (struct Date))) == NULL) if ((Gbl.ExamAnns.Lst = (struct Date *) calloc (NumExaAnns,sizeof (struct Date))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store dates of exam announcements."); Lay_ShowErrorAndExit ("Not enough memory to store dates of exam announcements.");
/***** Get the dates of the existing exam announcements *****/ /***** Get the dates of the existing exam announcements *****/
@ -871,13 +868,13 @@ void Exa_CreateListDatesOfExamAnnouncements (void)
/* Read the date of the exam (row[0]) */ /* Read the date of the exam (row[0]) */
if (sscanf (row[0],"%04u-%02u-%02u", if (sscanf (row[0],"%04u-%02u-%02u",
&Gbl.ExamAnnouncements.Lst[Gbl.ExamAnnouncements.NumExaAnns].Year, &Gbl.ExamAnns.Lst[Gbl.ExamAnns.NumExaAnns].Year,
&Gbl.ExamAnnouncements.Lst[Gbl.ExamAnnouncements.NumExaAnns].Month, &Gbl.ExamAnns.Lst[Gbl.ExamAnns.NumExaAnns].Month,
&Gbl.ExamAnnouncements.Lst[Gbl.ExamAnnouncements.NumExaAnns].Day) != 3) &Gbl.ExamAnns.Lst[Gbl.ExamAnns.NumExaAnns].Day) != 3)
Lay_ShowErrorAndExit ("Wrong date of exam."); Lay_ShowErrorAndExit ("Wrong date of exam.");
/***** Increment number of elements in list *****/ /***** Increment number of elements in list *****/
Gbl.ExamAnnouncements.NumExaAnns++; Gbl.ExamAnns.NumExaAnns++;
} }
} }
@ -892,11 +889,11 @@ void Exa_CreateListDatesOfExamAnnouncements (void)
void Exa_FreeListExamAnnouncements (void) void Exa_FreeListExamAnnouncements (void)
{ {
if (Gbl.ExamAnnouncements.Lst) if (Gbl.ExamAnns.Lst)
{ {
free ((void *) Gbl.ExamAnnouncements.Lst); free ((void *) Gbl.ExamAnns.Lst);
Gbl.ExamAnnouncements.Lst = NULL; Gbl.ExamAnns.Lst = NULL;
Gbl.ExamAnnouncements.NumExaAnns = 0; Gbl.ExamAnns.NumExaAnns = 0;
} }
} }
@ -920,7 +917,7 @@ static void Exa_GetDataExamAnnouncementFromDB (void)
"CallDate,ExamDate,Duration,Place,ExamMode," "CallDate,ExamDate,Duration,Place,ExamMode,"
"Structure,DocRequired,MatRequired,MatAllowed,OtherInfo" "Structure,DocRequired,MatRequired,MatAllowed,OtherInfo"
" FROM exam_announcements WHERE ExaCod='%ld'", " FROM exam_announcements WHERE ExaCod='%ld'",
Gbl.ExamAnnouncements.ExaDat.ExaCod); Gbl.ExamAnns.ExaDat.ExaCod);
NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get data of an exam announcement"); NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get data of an exam announcement");
/***** The result of the query must have one row *****/ /***** The result of the query must have one row *****/
@ -931,73 +928,64 @@ static void Exa_GetDataExamAnnouncementFromDB (void)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Code of the course in which the exam announcement is inserted (row[0]) */ /* Code of the course in which the exam announcement is inserted (row[0]) */
Gbl.ExamAnnouncements.ExaDat.CrsCod = Str_ConvertStrCodToLongCod (row[0]); Gbl.ExamAnns.ExaDat.CrsCod = Str_ConvertStrCodToLongCod (row[0]);
/* Status of the exam announcement (row[1]) */ /* Status of the exam announcement (row[1]) */
if (sscanf (row[1],"%u",&UnsignedNum) != 1) if (sscanf (row[1],"%u",&UnsignedNum) != 1)
Lay_ShowErrorAndExit ("Wrong status."); Lay_ShowErrorAndExit ("Wrong status.");
if (UnsignedNum >= Exa_NUM_STATUS) if (UnsignedNum >= Exa_NUM_STATUS)
Lay_ShowErrorAndExit ("Wrong status."); Lay_ShowErrorAndExit ("Wrong status.");
Gbl.ExamAnnouncements.ExaDat.Status = (Exa_ExamAnnouncementStatus_t) UnsignedNum; Gbl.ExamAnns.ExaDat.Status = (Exa_ExamAnnouncementStatus_t) UnsignedNum;
/* Name of the course (row[2]) */ /* Name of the course (row[2]) */
strncpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,row[2], Str_Copy (Gbl.ExamAnns.ExaDat.CrsFullName,row[2],
Crs_MAX_LENGTH_COURSE_FULL_NAME); Crs_MAX_LENGTH_COURSE_FULL_NAME);
Gbl.ExamAnnouncements.ExaDat.CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0';
/* Year (row[3]) */ /* Year (row[3]) */
if (sscanf (row[3],"%u",&Gbl.ExamAnnouncements.ExaDat.Year) != 1) if (sscanf (row[3],"%u",&Gbl.ExamAnns.ExaDat.Year) != 1)
Lay_ShowErrorAndExit ("Wrong year."); Lay_ShowErrorAndExit ("Wrong year.");
/* Exam session (row[4]) */ /* Exam session (row[4]) */
strncpy (Gbl.ExamAnnouncements.ExaDat.Session,row[4],Cns_MAX_BYTES_STRING); Str_Copy (Gbl.ExamAnns.ExaDat.Session,row[4],Cns_MAX_BYTES_STRING);
Gbl.ExamAnnouncements.ExaDat.Session[Cns_MAX_BYTES_STRING] = '\0';
/* Date of exam announcement (row[5]) */ /* Date of exam announcement (row[5]) */
if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u", if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u",
&Gbl.ExamAnnouncements.ExaDat.CallDate.Year, &Gbl.ExamAnns.ExaDat.CallDate.Year,
&Gbl.ExamAnnouncements.ExaDat.CallDate.Month, &Gbl.ExamAnns.ExaDat.CallDate.Month,
&Gbl.ExamAnnouncements.ExaDat.CallDate.Day, &Gbl.ExamAnns.ExaDat.CallDate.Day,
&Hour,&Minute,&Second) != 6) &Hour,&Minute,&Second) != 6)
Lay_ShowErrorAndExit ("Wrong date of exam announcement."); Lay_ShowErrorAndExit ("Wrong date of exam announcement.");
/* Date of exam (row[6]) */ /* Date of exam (row[6]) */
if (sscanf (row[6],"%04u-%02u-%02u %02u:%02u:%02u", if (sscanf (row[6],"%04u-%02u-%02u %02u:%02u:%02u",
&Gbl.ExamAnnouncements.ExaDat.ExamDate.Year,&Gbl.ExamAnnouncements.ExaDat.ExamDate.Month,&Gbl.ExamAnnouncements.ExaDat.ExamDate.Day, &Gbl.ExamAnns.ExaDat.ExamDate.Year,&Gbl.ExamAnns.ExaDat.ExamDate.Month,&Gbl.ExamAnns.ExaDat.ExamDate.Day,
&Gbl.ExamAnnouncements.ExaDat.StartTime.Hour,&Gbl.ExamAnnouncements.ExaDat.StartTime.Minute,&Second) != 6) &Gbl.ExamAnns.ExaDat.StartTime.Hour,&Gbl.ExamAnns.ExaDat.StartTime.Minute,&Second) != 6)
Lay_ShowErrorAndExit ("Wrong date of exam."); Lay_ShowErrorAndExit ("Wrong date of exam.");
/* Approximate duration (row[7]) */ /* Approximate duration (row[7]) */
if (sscanf (row[7],"%02u:%02u:%02u",&Gbl.ExamAnnouncements.ExaDat.Duration.Hour,&Gbl.ExamAnnouncements.ExaDat.Duration.Minute,&Second) != 3) if (sscanf (row[7],"%02u:%02u:%02u",&Gbl.ExamAnns.ExaDat.Duration.Hour,&Gbl.ExamAnns.ExaDat.Duration.Minute,&Second) != 3)
Lay_ShowErrorAndExit ("Wrong duration of exam."); Lay_ShowErrorAndExit ("Wrong duration of exam.");
/* Place (row[8]) */ /* Place (row[8]) */
strncpy (Gbl.ExamAnnouncements.ExaDat.Place,row[8],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.Place,row[8],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.Place[Cns_MAX_BYTES_TEXT] = '\0';
/* Exam mode (row[9]) */ /* Exam mode (row[9]) */
strncpy (Gbl.ExamAnnouncements.ExaDat.Mode,row[9],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.Mode,row[9],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.Mode[Cns_MAX_BYTES_TEXT] = '\0';
/* Structure (row[10]) */ /* Structure (row[10]) */
strncpy (Gbl.ExamAnnouncements.ExaDat.Structure,row[10],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.Structure,row[10],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.Structure[Cns_MAX_BYTES_TEXT] = '\0';
/* Documentation required (row[11]) */ /* Documentation required (row[11]) */
strncpy (Gbl.ExamAnnouncements.ExaDat.DocRequired,row[11],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.DocRequired,row[11],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.DocRequired[Cns_MAX_BYTES_TEXT] = '\0';
/* Material required (row[12]) */ /* Material required (row[12]) */
strncpy (Gbl.ExamAnnouncements.ExaDat.MatRequired,row[12],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.MatRequired,row[12],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.MatRequired[Cns_MAX_BYTES_TEXT] = '\0';
/* Material allowed (row[13]) */ /* Material allowed (row[13]) */
strncpy (Gbl.ExamAnnouncements.ExaDat.MatAllowed,row[13],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.MatAllowed,row[13],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.MatAllowed[Cns_MAX_BYTES_TEXT] = '\0';
/* Other information for students (row[14]) */ /* Other information for students (row[14]) */
strncpy (Gbl.ExamAnnouncements.ExaDat.OtherInfo,row[14],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.OtherInfo,row[14],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.OtherInfo[Cns_MAX_BYTES_TEXT] = '\0';
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -1080,7 +1068,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
Lay_StartRoundFrame ("625px",NULL, Lay_StartRoundFrame ("625px",NULL,
TypeViewExamAnnouncement == Exa_NORMAL_VIEW ? Exa_PutIconsExamAnnouncement : TypeViewExamAnnouncement == Exa_NORMAL_VIEW ? Exa_PutIconsExamAnnouncement :
NULL, NULL,
TypeViewExamAnnouncement == Exa_FORM_VIEW ? ((Gbl.ExamAnnouncements.ExaDat.ExaCod > 0) ? Hlp_ASSESSMENT_Announcements_edit_announcement : TypeViewExamAnnouncement == Exa_FORM_VIEW ? ((Gbl.ExamAnns.ExaDat.ExaCod > 0) ? Hlp_ASSESSMENT_Announcements_edit_announcement :
Hlp_ASSESSMENT_Announcements_new_announcement) : Hlp_ASSESSMENT_Announcements_new_announcement) :
NULL); NULL);
@ -1088,13 +1076,13 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
{ {
/***** Start form *****/ /***** Start form *****/
Act_FormStart (ActRcvExaAnn); Act_FormStart (ActRcvExaAnn);
if (Gbl.ExamAnnouncements.ExaDat.ExaCod > 0) // Existing announcement of exam if (Gbl.ExamAnns.ExaDat.ExaCod > 0) // Existing announcement of exam
Exa_PutParamExaCodToEdit (); Exa_PutParamExaCodToEdit ();
} }
/***** Start table *****/ /***** Start table *****/
fprintf (Gbl.F.Out,"<table class=\"%s CELLS_PAD_2\">", fprintf (Gbl.F.Out,"<table class=\"%s CELLS_PAD_2\">",
ClassExaAnnouncement[TypeViewExamAnnouncement][Gbl.ExamAnnouncements.ExaDat.Status]); ClassExaAnnouncement[TypeViewExamAnnouncement][Gbl.ExamAnns.ExaDat.Status]);
/***** Institution logo *****/ /***** Institution logo *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
@ -1153,11 +1141,11 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
{ {
fprintf (Gbl.F.Out,"<input type=\"text\" id=\"CrsName\" name=\"CrsName\"" fprintf (Gbl.F.Out,"<input type=\"text\" id=\"CrsName\" name=\"CrsName\""
" size=\"30\" maxlength=\"%u\" value=\"%s\" />", " size=\"30\" maxlength=\"%u\" value=\"%s\" />",
Cns_MAX_LENGTH_STRING,Gbl.ExamAnnouncements.ExaDat.CrsFullName); Cns_MAX_LENGTH_STRING,Gbl.ExamAnns.ExaDat.CrsFullName);
} }
else else
fprintf (Gbl.F.Out,"<strong>%s</strong>", fprintf (Gbl.F.Out,"<strong>%s</strong>",
Gbl.ExamAnnouncements.ExaDat.CrsFullName); Gbl.ExamAnns.ExaDat.CrsFullName);
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1178,7 +1166,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
Year++) Year++)
{ {
fprintf (Gbl.F.Out,"<option"); fprintf (Gbl.F.Out,"<option");
if (Gbl.ExamAnnouncements.ExaDat.Year == Year) if (Gbl.ExamAnns.ExaDat.Year == Year)
fprintf (Gbl.F.Out," selected=\"selected\""); fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," value=\"%u\">" fprintf (Gbl.F.Out," value=\"%u\">"
"%s" "%s"
@ -1189,7 +1177,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
} }
else else
fprintf (Gbl.F.Out,"%s", fprintf (Gbl.F.Out,"%s",
Txt_YEAR_OF_DEGREE[Gbl.ExamAnnouncements.ExaDat.Year]); Txt_YEAR_OF_DEGREE[Gbl.ExamAnns.ExaDat.Year]);
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1206,9 +1194,9 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
fprintf (Gbl.F.Out,"<input type=\"text\"" fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"ExamSession\" name=\"ExamSession\"" " id=\"ExamSession\" name=\"ExamSession\""
" size=\"30\" maxlength=\"%u\" value=\"%s\" />", " size=\"30\" maxlength=\"%u\" value=\"%s\" />",
Cns_MAX_LENGTH_STRING,Gbl.ExamAnnouncements.ExaDat.Session); Cns_MAX_LENGTH_STRING,Gbl.ExamAnns.ExaDat.Session);
else else
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.Session); fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.Session);
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1222,16 +1210,16 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
if (TypeViewExamAnnouncement == Exa_FORM_VIEW) if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
{ {
fprintf (Gbl.F.Out,"<td class=\"LEFT_BOTTOM\">"); fprintf (Gbl.F.Out,"<td class=\"LEFT_BOTTOM\">");
Dat_WriteFormDate (Gbl.ExamAnnouncements.ExaDat.ExamDate.Year < Gbl.Now.Date.Year ? Gbl.ExamAnnouncements.ExaDat.ExamDate.Year : Dat_WriteFormDate (Gbl.ExamAnns.ExaDat.ExamDate.Year < Gbl.Now.Date.Year ? Gbl.ExamAnns.ExaDat.ExamDate.Year :
Gbl.Now.Date.Year, Gbl.Now.Date.Year,
Gbl.Now.Date.Year + 1,"Exam", Gbl.Now.Date.Year + 1,"Exam",
&(Gbl.ExamAnnouncements.ExaDat.ExamDate), &(Gbl.ExamAnns.ExaDat.ExamDate),
false,false); false,false);
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
} }
else else
{ {
Dat_ConvDateToDateStr (&Gbl.ExamAnnouncements.ExaDat.ExamDate, Dat_ConvDateToDateStr (&Gbl.ExamAnns.ExaDat.ExamDate,
StrExamDate); StrExamDate);
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_BOTTOM\">" fprintf (Gbl.F.Out,"<td class=\"%s LEFT_BOTTOM\">"
"%s" "%s"
@ -1253,7 +1241,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
{ {
fprintf (Gbl.F.Out,"<select name=\"ExamHour\">" fprintf (Gbl.F.Out,"<select name=\"ExamHour\">"
"<option value=\"0\""); "<option value=\"0\"");
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Hour == 0) if (Gbl.ExamAnns.ExaDat.StartTime.Hour == 0)
fprintf (Gbl.F.Out," selected=\"selected\""); fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">-</option>"); fprintf (Gbl.F.Out,">-</option>");
for (Hour = 7; for (Hour = 7;
@ -1261,7 +1249,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
Hour++) Hour++)
{ {
fprintf (Gbl.F.Out,"<option value=\"%u\"",Hour); fprintf (Gbl.F.Out,"<option value=\"%u\"",Hour);
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Hour == Hour) if (Gbl.ExamAnns.ExaDat.StartTime.Hour == Hour)
fprintf (Gbl.F.Out," selected=\"selected\""); fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%02u %s</option>", fprintf (Gbl.F.Out,">%02u %s</option>",
Hour,Txt_hours_ABBREVIATION); Hour,Txt_hours_ABBREVIATION);
@ -1273,16 +1261,16 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
Minute++) Minute++)
{ {
fprintf (Gbl.F.Out,"<option value=\"%u\"",Minute); fprintf (Gbl.F.Out,"<option value=\"%u\"",Minute);
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Minute == Minute) if (Gbl.ExamAnns.ExaDat.StartTime.Minute == Minute)
fprintf (Gbl.F.Out," selected=\"selected\""); fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%02u &#39;</option>",Minute); fprintf (Gbl.F.Out,">%02u &#39;</option>",Minute);
} }
fprintf (Gbl.F.Out,"</select>"); fprintf (Gbl.F.Out,"</select>");
} }
else if (Gbl.ExamAnnouncements.ExaDat.StartTime.Hour) else if (Gbl.ExamAnns.ExaDat.StartTime.Hour)
fprintf (Gbl.F.Out,"%2u:%02u", fprintf (Gbl.F.Out,"%2u:%02u",
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour, Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute); Gbl.ExamAnns.ExaDat.StartTime.Minute);
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1303,7 +1291,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
Hour++) Hour++)
{ {
fprintf (Gbl.F.Out,"<option value=\"%u\"",Hour); fprintf (Gbl.F.Out,"<option value=\"%u\"",Hour);
if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour == Hour) if (Gbl.ExamAnns.ExaDat.Duration.Hour == Hour)
fprintf (Gbl.F.Out," selected=\"selected\""); fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%02u %s</option>", fprintf (Gbl.F.Out,">%02u %s</option>",
Hour,Txt_hours_ABBREVIATION); Hour,Txt_hours_ABBREVIATION);
@ -1315,38 +1303,38 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
Minute++) Minute++)
{ {
fprintf (Gbl.F.Out,"<option value=\"%u\"",Minute); fprintf (Gbl.F.Out,"<option value=\"%u\"",Minute);
if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute == Minute) if (Gbl.ExamAnns.ExaDat.Duration.Minute == Minute)
fprintf (Gbl.F.Out," selected=\"selected\""); fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%02u &#39;</option>",Minute); fprintf (Gbl.F.Out,">%02u &#39;</option>",Minute);
} }
fprintf (Gbl.F.Out,"</select>"); fprintf (Gbl.F.Out,"</select>");
} }
else if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour || else if (Gbl.ExamAnns.ExaDat.Duration.Hour ||
Gbl.ExamAnnouncements.ExaDat.Duration.Minute) Gbl.ExamAnns.ExaDat.Duration.Minute)
{ {
if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour) if (Gbl.ExamAnns.ExaDat.Duration.Hour)
{ {
if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute) if (Gbl.ExamAnns.ExaDat.Duration.Minute)
fprintf (Gbl.F.Out,"%u %s %u &#39;", fprintf (Gbl.F.Out,"%u %s %u &#39;",
Gbl.ExamAnnouncements.ExaDat.Duration.Hour, Gbl.ExamAnns.ExaDat.Duration.Hour,
Txt_hours_ABBREVIATION, Txt_hours_ABBREVIATION,
Gbl.ExamAnnouncements.ExaDat.Duration.Minute); Gbl.ExamAnns.ExaDat.Duration.Minute);
else else
{ {
if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour == 1) if (Gbl.ExamAnns.ExaDat.Duration.Hour == 1)
fprintf (Gbl.F.Out,"1 %s",Txt_hour); fprintf (Gbl.F.Out,"1 %s",Txt_hour);
else else
fprintf (Gbl.F.Out,"%u %s", fprintf (Gbl.F.Out,"%u %s",
Gbl.ExamAnnouncements.ExaDat.Duration.Hour,Txt_hours); Gbl.ExamAnns.ExaDat.Duration.Hour,Txt_hours);
} }
} }
else if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute) else if (Gbl.ExamAnns.ExaDat.Duration.Minute)
{ {
if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute == 1) if (Gbl.ExamAnns.ExaDat.Duration.Minute == 1)
fprintf (Gbl.F.Out,"1 %s",Txt_minute); fprintf (Gbl.F.Out,"1 %s",Txt_minute);
else else
fprintf (Gbl.F.Out,"%u %s", fprintf (Gbl.F.Out,"%u %s",
Gbl.ExamAnnouncements.ExaDat.Duration.Minute,Txt_minutes); Gbl.ExamAnns.ExaDat.Duration.Minute,Txt_minutes);
} }
} }
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
@ -1366,13 +1354,13 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
" cols=\"40\" rows=\"4\">" " cols=\"40\" rows=\"4\">"
"%s" "%s"
"</textarea>", "</textarea>",
Gbl.ExamAnnouncements.ExaDat.Place); Gbl.ExamAnns.ExaDat.Place);
else else
{ {
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.ExamAnnouncements.ExaDat.Place, Gbl.ExamAnns.ExaDat.Place,
Cns_MAX_BYTES_TEXT,false); Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.Place); fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.Place);
} }
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1391,13 +1379,13 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
" cols=\"40\" rows=\"2\">" " cols=\"40\" rows=\"2\">"
"%s" "%s"
"</textarea>", "</textarea>",
Gbl.ExamAnnouncements.ExaDat.Mode); Gbl.ExamAnns.ExaDat.Mode);
else else
{ {
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.ExamAnnouncements.ExaDat.Mode, Gbl.ExamAnns.ExaDat.Mode,
Cns_MAX_BYTES_TEXT,false); Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.Mode); fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.Mode);
} }
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1416,13 +1404,13 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
" cols=\"40\" rows=\"8\">" " cols=\"40\" rows=\"8\">"
"%s" "%s"
"</textarea>", "</textarea>",
Gbl.ExamAnnouncements.ExaDat.Structure); Gbl.ExamAnns.ExaDat.Structure);
else else
{ {
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.ExamAnnouncements.ExaDat.Structure, Gbl.ExamAnns.ExaDat.Structure,
Cns_MAX_BYTES_TEXT,false); Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.Structure); fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.Structure);
} }
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1441,13 +1429,13 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
" cols=\"40\" rows=\"2\">" " cols=\"40\" rows=\"2\">"
"%s" "%s"
"</textarea>", "</textarea>",
Gbl.ExamAnnouncements.ExaDat.DocRequired); Gbl.ExamAnns.ExaDat.DocRequired);
else else
{ {
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.ExamAnnouncements.ExaDat.DocRequired, Gbl.ExamAnns.ExaDat.DocRequired,
Cns_MAX_BYTES_TEXT,false); Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.DocRequired); fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.DocRequired);
} }
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1466,13 +1454,13 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
" cols=\"40\" rows=\"4\">" " cols=\"40\" rows=\"4\">"
"%s" "%s"
"</textarea>", "</textarea>",
Gbl.ExamAnnouncements.ExaDat.MatRequired); Gbl.ExamAnns.ExaDat.MatRequired);
else else
{ {
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.ExamAnnouncements.ExaDat.MatRequired, Gbl.ExamAnns.ExaDat.MatRequired,
Cns_MAX_BYTES_TEXT,false); Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.MatRequired); fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.MatRequired);
} }
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1491,13 +1479,13 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
" cols=\"40\" rows=\"4\">" " cols=\"40\" rows=\"4\">"
"%s" "%s"
"</textarea>", "</textarea>",
Gbl.ExamAnnouncements.ExaDat.MatAllowed); Gbl.ExamAnns.ExaDat.MatAllowed);
else else
{ {
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.ExamAnnouncements.ExaDat.MatAllowed, Gbl.ExamAnns.ExaDat.MatAllowed,
Cns_MAX_BYTES_TEXT,false); Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.MatAllowed); fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.MatAllowed);
} }
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1515,13 +1503,13 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
" cols=\"40\" rows=\"5\">" " cols=\"40\" rows=\"5\">"
"%s" "%s"
"</textarea>", "</textarea>",
Gbl.ExamAnnouncements.ExaDat.OtherInfo); Gbl.ExamAnns.ExaDat.OtherInfo);
else else
{ {
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.ExamAnnouncements.ExaDat.OtherInfo, Gbl.ExamAnns.ExaDat.OtherInfo,
Cns_MAX_BYTES_TEXT,false); Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.OtherInfo); fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.OtherInfo);
} }
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -1531,7 +1519,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa
/***** End frame *****/ /***** End frame *****/
if (TypeViewExamAnnouncement == Exa_FORM_VIEW) if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
Lay_EndRoundFrameWithButton ((Gbl.ExamAnnouncements.ExaDat.ExaCod > 0) ? Lay_CONFIRM_BUTTON : Lay_EndRoundFrameWithButton ((Gbl.ExamAnns.ExaDat.ExaCod > 0) ? Lay_CONFIRM_BUTTON :
Lay_CREATE_BUTTON, Lay_CREATE_BUTTON,
Txt_Publish_announcement_OF_EXAM); Txt_Publish_announcement_OF_EXAM);
else else
@ -1563,7 +1551,7 @@ static void Exa_PutIconsExamAnnouncement (void)
NULL); NULL);
/***** Put form to hide/show exam announement *****/ /***** Put form to hide/show exam announement *****/
switch (Gbl.ExamAnnouncements.ExaDat.Status) switch (Gbl.ExamAnns.ExaDat.Status)
{ {
case Exa_VISIBLE_EXAM_ANNOUNCEMENT: case Exa_VISIBLE_EXAM_ANNOUNCEMENT:
Lay_PutContextualLink (ActHidExaAnn,Exa_PutParamExaCodToEdit, Lay_PutContextualLink (ActHidExaAnn,Exa_PutParamExaCodToEdit,
@ -1601,7 +1589,7 @@ static void Exa_PutIconsExamAnnouncement (void)
static void Exa_PutParamExaCodToEdit (void) static void Exa_PutParamExaCodToEdit (void)
{ {
Exa_PutHiddenParamExaCod (Gbl.ExamAnnouncements.ExaDat.ExaCod); Exa_PutHiddenParamExaCod (Gbl.ExamAnns.ExaDat.ExaCod);
} }
void Exa_PutHiddenParamExaCod (long ExaCod) void Exa_PutHiddenParamExaCod (long ExaCod)
@ -1638,7 +1626,7 @@ void Exa_GetSummaryAndContentExamAnnouncement (char *SummaryStr,char **ContentSt
extern const char *Txt_hours_ABBREVIATION; extern const char *Txt_hours_ABBREVIATION;
/***** Initializations *****/ /***** Initializations *****/
Gbl.ExamAnnouncements.ExaDat.ExaCod = ExaCod; Gbl.ExamAnns.ExaDat.ExaCod = ExaCod;
SummaryStr[0] = '\0'; // Return nothing on error SummaryStr[0] = '\0'; // Return nothing on error
/***** Allocate memory for the exam announcement *****/ /***** Allocate memory for the exam announcement *****/
@ -1654,17 +1642,17 @@ void Exa_GetSummaryAndContentExamAnnouncement (char *SummaryStr,char **ContentSt
/***** Summary *****/ /***** Summary *****/
/* Name of the course */ /* Name of the course */
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (Gbl.ExamAnnouncements.ExaDat.CrsFullName, Str_LimitLengthHTMLStr (Gbl.ExamAnns.ExaDat.CrsFullName,
MaxChars-(2+Cns_MAX_LENGTH_DATE+6)); MaxChars-(2+Cns_MAX_LENGTH_DATE+6));
/* Date of exam */ /* Date of exam */
sprintf (SummaryStr,"%s, %04u-%02u-%02u %2u:%02u", sprintf (SummaryStr,"%s, %04u-%02u-%02u %2u:%02u",
Gbl.ExamAnnouncements.ExaDat.CrsFullName, Gbl.ExamAnns.ExaDat.CrsFullName,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year, Gbl.ExamAnns.ExaDat.ExamDate.Year,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month, Gbl.ExamAnns.ExaDat.ExamDate.Month,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Day, Gbl.ExamAnns.ExaDat.ExamDate.Day,
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour, Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute); Gbl.ExamAnns.ExaDat.StartTime.Minute);
/***** Free memory of the exam announcement *****/ /***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement (); Exa_FreeMemExamAnnouncement ();
@ -1703,7 +1691,7 @@ static void Exa_GetNotifContentExamAnnouncement (char **ContentStr)
(*ContentStr)[0] = '\0'; // Return nothing on error (*ContentStr)[0] = '\0'; // Return nothing on error
/***** Get data of course *****/ /***** Get data of course *****/
Crs.CrsCod = Gbl.ExamAnnouncements.ExaDat.CrsCod; Crs.CrsCod = Gbl.ExamAnns.ExaDat.CrsCod;
Crs_GetDataOfCourseByCod (&Crs); Crs_GetDataOfCourseByCod (&Crs);
/***** Get data of degree *****/ /***** Get data of degree *****/
@ -1714,7 +1702,7 @@ static void Exa_GetNotifContentExamAnnouncement (char **ContentStr)
Ins.InsCod = Deg_GetInsCodOfDegreeByCod (Deg.DegCod); Ins.InsCod = Deg_GetInsCodOfDegreeByCod (Deg.DegCod);
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Dat_ConvDateToDateStr (&Gbl.ExamAnnouncements.ExaDat.ExamDate,StrExamDate); Dat_ConvDateToDateStr (&Gbl.ExamAnns.ExaDat.ExamDate,StrExamDate);
/***** Institution *****/ /***** Institution *****/
sprintf (*ContentStr,"%s: %s<br />" sprintf (*ContentStr,"%s: %s<br />"
@ -1734,21 +1722,21 @@ static void Exa_GetNotifContentExamAnnouncement (char **ContentStr)
"%s: %s", "%s: %s",
Txt_Institution,Ins.FullName, Txt_Institution,Ins.FullName,
Txt_Degree,Deg.FullName, Txt_Degree,Deg.FullName,
Txt_EXAM_ANNOUNCEMENT_Course,Gbl.ExamAnnouncements.ExaDat.CrsFullName, Txt_EXAM_ANNOUNCEMENT_Course,Gbl.ExamAnns.ExaDat.CrsFullName,
Txt_EXAM_ANNOUNCEMENT_Year_or_semester,Txt_YEAR_OF_DEGREE[Gbl.ExamAnnouncements.ExaDat.Year], Txt_EXAM_ANNOUNCEMENT_Year_or_semester,Txt_YEAR_OF_DEGREE[Gbl.ExamAnns.ExaDat.Year],
Txt_EXAM_ANNOUNCEMENT_Session,Gbl.ExamAnnouncements.ExaDat.Session, Txt_EXAM_ANNOUNCEMENT_Session,Gbl.ExamAnns.ExaDat.Session,
Txt_EXAM_ANNOUNCEMENT_Exam_date,StrExamDate, Txt_EXAM_ANNOUNCEMENT_Exam_date,StrExamDate,
Txt_EXAM_ANNOUNCEMENT_Start_time,Gbl.ExamAnnouncements.ExaDat.StartTime.Hour, Txt_EXAM_ANNOUNCEMENT_Start_time,Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute, Gbl.ExamAnns.ExaDat.StartTime.Minute,
Txt_hours_ABBREVIATION, Txt_hours_ABBREVIATION,
Txt_EXAM_ANNOUNCEMENT_Approximate_duration,Gbl.ExamAnnouncements.ExaDat.Duration.Hour, Txt_EXAM_ANNOUNCEMENT_Approximate_duration,Gbl.ExamAnns.ExaDat.Duration.Hour,
Gbl.ExamAnnouncements.ExaDat.Duration.Minute, Gbl.ExamAnns.ExaDat.Duration.Minute,
Txt_hours_ABBREVIATION, Txt_hours_ABBREVIATION,
Txt_EXAM_ANNOUNCEMENT_Place_of_exam,Gbl.ExamAnnouncements.ExaDat.Place, Txt_EXAM_ANNOUNCEMENT_Place_of_exam,Gbl.ExamAnns.ExaDat.Place,
Txt_EXAM_ANNOUNCEMENT_Mode,Gbl.ExamAnnouncements.ExaDat.Mode, Txt_EXAM_ANNOUNCEMENT_Mode,Gbl.ExamAnns.ExaDat.Mode,
Txt_EXAM_ANNOUNCEMENT_Structure_of_the_exam,Gbl.ExamAnnouncements.ExaDat.Structure, Txt_EXAM_ANNOUNCEMENT_Structure_of_the_exam,Gbl.ExamAnns.ExaDat.Structure,
Txt_EXAM_ANNOUNCEMENT_Documentation_required,Gbl.ExamAnnouncements.ExaDat.DocRequired, Txt_EXAM_ANNOUNCEMENT_Documentation_required,Gbl.ExamAnns.ExaDat.DocRequired,
Txt_EXAM_ANNOUNCEMENT_Material_required,Gbl.ExamAnnouncements.ExaDat.MatRequired, Txt_EXAM_ANNOUNCEMENT_Material_required,Gbl.ExamAnns.ExaDat.MatRequired,
Txt_EXAM_ANNOUNCEMENT_Material_allowed,Gbl.ExamAnnouncements.ExaDat.MatAllowed, Txt_EXAM_ANNOUNCEMENT_Material_allowed,Gbl.ExamAnns.ExaDat.MatAllowed,
Txt_EXAM_ANNOUNCEMENT_Other_information,Gbl.ExamAnnouncements.ExaDat.OtherInfo); Txt_EXAM_ANNOUNCEMENT_Other_information,Gbl.ExamAnns.ExaDat.OtherInfo);
} }

View File

@ -322,8 +322,7 @@ void Fil_CreateUpdateFile (const char *CurrentName,const char *ExtensionOldName,
{ {
size_t LengthFileRoot = Str_GetLengthRootFileName (CurrentName); size_t LengthFileRoot = Str_GetLengthRootFileName (CurrentName);
strncpy (NewName,CurrentName,LengthFileRoot); Str_Copy (NewName,CurrentName,LengthFileRoot);
NewName[LengthFileRoot] = '\0';
sprintf (OldName,"%s%s",NewName,ExtensionOldName); sprintf (OldName,"%s%s",NewName,ExtensionOldName);
strcat (NewName,".new"); strcat (NewName,".new");

View File

@ -2384,15 +2384,10 @@ static void Brw_GetDataCurrentGrp (void)
if (Gbl.CurrentCrs.Grps.GrpCod > 0) if (Gbl.CurrentCrs.Grps.GrpCod > 0)
{ {
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = GrpDat.GrpTypCod; Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = GrpDat.GrpTypCod;
Str_Copy (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,GrpDat.GrpTypName,
strncpy (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,GrpDat.GrpTypName, Grp_MAX_LENGTH_GROUP_TYPE_NAME);
Grp_MAX_LENGTH_GROUP_TYPE_NAME); Str_Copy (Gbl.CurrentCrs.Grps.GrpName,GrpDat.GrpName,
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME] = '\0'; Grp_MAX_LENGTH_GROUP_NAME);
strncpy (Gbl.CurrentCrs.Grps.GrpName,GrpDat.GrpName,
Grp_MAX_LENGTH_GROUP_NAME);
Gbl.CurrentCrs.Grps.GrpName[Grp_MAX_LENGTH_GROUP_NAME] = '\0';
Gbl.CurrentCrs.Grps.MaxStudents = GrpDat.MaxStudents; Gbl.CurrentCrs.Grps.MaxStudents = GrpDat.MaxStudents;
Gbl.CurrentCrs.Grps.Open = GrpDat.Open; Gbl.CurrentCrs.Grps.Open = GrpDat.Open;
Gbl.CurrentCrs.Grps.FileZones = GrpDat.FileZones; Gbl.CurrentCrs.Grps.FileZones = GrpDat.FileZones;
@ -2508,11 +2503,9 @@ static void Brw_GetParamsPathInTreeAndFileName (void)
Gbl.FileBrowser.Type == Brw_ADMI_ASSIG_CRS)) Gbl.FileBrowser.Type == Brw_ADMI_ASSIG_CRS))
{ {
if (Gbl.FileBrowser.Level == 1) if (Gbl.FileBrowser.Level == 1)
{
// We are in this case: assignments/assignment-folder // We are in this case: assignments/assignment-folder
strncpy (Gbl.FileBrowser.Asg.Folder,Gbl.FileBrowser.FilFolLnkName,Asg_MAX_LENGTH_FOLDER); Str_Copy (Gbl.FileBrowser.Asg.Folder,Gbl.FileBrowser.FilFolLnkName,
Gbl.FileBrowser.Asg.Folder[Asg_MAX_LENGTH_FOLDER] = '\0'; Asg_MAX_LENGTH_FOLDER);
}
else else
{ {
// We are in this case: assignments/assignment-folder/rest-of-path // We are in this case: assignments/assignment-folder/rest-of-path
@ -2612,9 +2605,8 @@ static void Brw_SetPathFileBrowser (void)
case Brw_ADMI_SHARE_CRS: case Brw_ADMI_SHARE_CRS:
case Brw_SHOW_MARKS_CRS: case Brw_SHOW_MARKS_CRS:
case Brw_ADMI_MARKS_CRS: case Brw_ADMI_MARKS_CRS:
strncpy (Gbl.FileBrowser.Priv.PathAboveRootFolder, Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
Gbl.CurrentCrs.PathPriv,PATH_MAX); Gbl.CurrentCrs.PathPriv,PATH_MAX);
Gbl.FileBrowser.Priv.PathAboveRootFolder[PATH_MAX] = '\0';
break; break;
case Brw_SHOW_DOCUM_GRP: case Brw_SHOW_DOCUM_GRP:
case Brw_ADMI_DOCUM_GRP: case Brw_ADMI_DOCUM_GRP:
@ -2664,9 +2656,8 @@ static void Brw_SetPathFileBrowser (void)
} }
break; break;
case Brw_ADMI_BRIEF_USR: case Brw_ADMI_BRIEF_USR:
strncpy (Gbl.FileBrowser.Priv.PathAboveRootFolder, Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
Gbl.Usrs.Me.PathDir,PATH_MAX); Gbl.Usrs.Me.PathDir,PATH_MAX);
Gbl.FileBrowser.Priv.PathAboveRootFolder[PATH_MAX] = '\0';
break; break;
default: default:
return; return;
@ -4807,10 +4798,7 @@ void Brw_CreateDirDownloadTmp (void)
if (NumDir) if (NumDir)
sprintf (Gbl.FileBrowser.TmpPubDir,"%s_%u",Gbl.UniqueNameEncrypted,NumDir); sprintf (Gbl.FileBrowser.TmpPubDir,"%s_%u",Gbl.UniqueNameEncrypted,NumDir);
else else
{ Str_Copy (Gbl.FileBrowser.TmpPubDir,Gbl.UniqueNameEncrypted,NAME_MAX);
strncpy (Gbl.FileBrowser.TmpPubDir,Gbl.UniqueNameEncrypted,NAME_MAX);
Gbl.FileBrowser.TmpPubDir[NAME_MAX] = '\0';
}
sprintf (PathPubDirTmp,"%s/%s",PathFileBrowserTmpPubl,Gbl.FileBrowser.TmpPubDir); sprintf (PathPubDirTmp,"%s/%s",PathFileBrowserTmpPubl,Gbl.FileBrowser.TmpPubDir);
if (mkdir (PathPubDirTmp,(mode_t) 0xFFF)) if (mkdir (PathPubDirTmp,(mode_t) 0xFFF))
Lay_ShowErrorAndExit ("Can not create a temporary folder for download."); Lay_ShowErrorAndExit ("Can not create a temporary folder for download.");
@ -5219,8 +5207,7 @@ static bool Brw_WriteRowFileBrowser (unsigned Level,Brw_ExpandTree_t ExpandTree,
{ {
if (Level == 1) // Main folder of the assignment if (Level == 1) // Main folder of the assignment
{ {
strncpy (Gbl.FileBrowser.Asg.Folder,FileName,Asg_MAX_LENGTH_FOLDER); Str_Copy (Gbl.FileBrowser.Asg.Folder,FileName,Asg_MAX_LENGTH_FOLDER);
Gbl.FileBrowser.Asg.Folder[Asg_MAX_LENGTH_FOLDER] = '\0';
Asg_GetDataOfAssignmentByFolder (&Gbl.FileBrowser.Asg); Asg_GetDataOfAssignmentByFolder (&Gbl.FileBrowser.Asg);
// The data of this assignment remains in Gbl.FileBrowser.Asg // The data of this assignment remains in Gbl.FileBrowser.Asg
// for all subsequent rows with Level > 1 (files or folders inside this folder), // for all subsequent rows with Level > 1 (files or folders inside this folder),
@ -5356,11 +5343,8 @@ void Brw_SetFullPathInTree (const char *PathInTreeUntilFileOrFolder,const char *
sprintf (Gbl.FileBrowser.Priv.FullPathInTree,"%s/%s", sprintf (Gbl.FileBrowser.Priv.FullPathInTree,"%s/%s",
PathInTreeUntilFileOrFolder,FilFolLnkName); PathInTreeUntilFileOrFolder,FilFolLnkName);
else // It's the root folder else // It's the root folder
{ Str_Copy (Gbl.FileBrowser.Priv.FullPathInTree,
strncpy (Gbl.FileBrowser.Priv.FullPathInTree, PathInTreeUntilFileOrFolder,PATH_MAX);
PathInTreeUntilFileOrFolder,PATH_MAX);
Gbl.FileBrowser.Priv.FullPathInTree[PATH_MAX] = '\0';
}
} }
/*****************************************************************************/ /*****************************************************************************/
@ -6013,8 +5997,7 @@ static void Brw_LimitLengthFileNameToShow (Brw_FileType_t FileType,const char *F
NumCharsToCopy -= 4; // Remove .url NumCharsToCopy -= 4; // Remove .url
if (NumCharsToCopy > NAME_MAX) if (NumCharsToCopy > NAME_MAX)
NumCharsToCopy = NAME_MAX; NumCharsToCopy = NAME_MAX;
strncpy (FileNameToShow,FileName,NumCharsToCopy); Str_Copy (FileNameToShow,FileName,NumCharsToCopy);
FileNameToShow[NumCharsToCopy] = '\0';
Str_LimitLengthHTMLStr (FileNameToShow,60); Str_LimitLengthHTMLStr (FileNameToShow,60);
} }
@ -6724,8 +6707,7 @@ static bool Brw_GetMyClipboard (void)
Gbl.FileBrowser.Clipboard.FileType = (Brw_FileType_t) UnsignedNum; Gbl.FileBrowser.Clipboard.FileType = (Brw_FileType_t) UnsignedNum;
/* Get file path (row[4]) */ /* Get file path (row[4]) */
strncpy (Gbl.FileBrowser.Clipboard.Path,row[4],PATH_MAX); Str_Copy (Gbl.FileBrowser.Clipboard.Path,row[4],PATH_MAX);
Gbl.FileBrowser.Clipboard.Path[PATH_MAX] = '\0';
Str_SplitFullPathIntoPathAndFileName (Gbl.FileBrowser.Clipboard.Path, Str_SplitFullPathIntoPathAndFileName (Gbl.FileBrowser.Clipboard.Path,
PathUntilFileName, PathUntilFileName,
Gbl.FileBrowser.Clipboard.FileName); Gbl.FileBrowser.Clipboard.FileName);
@ -6920,8 +6902,7 @@ static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char
// if (strcmp (Path,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type])) // Don't insert root folder // if (strcmp (Path,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type])) // Don't insert root folder
/***** Make a copy to keep Path unchanged *****/ /***** Make a copy to keep Path unchanged *****/
strncpy (CopyOfPath,Path,PATH_MAX); Str_Copy (CopyOfPath,Path,PATH_MAX);
CopyOfPath[PATH_MAX] = '\0';
/***** Insert paths in table of expanded folders if they are not yet there *****/ /***** Insert paths in table of expanded folders if they are not yet there *****/
do do
@ -7689,10 +7670,7 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
if (LevelOrg == 0) // Origin of copy is the root folder, if (LevelOrg == 0) // Origin of copy is the root folder,
// for example "sha" // for example "sha"
// ==> do not copy the root folder itself into destination // ==> do not copy the root folder itself into destination
{ Str_Copy (PathDstInTreeWithFile,PathDstInTree,PATH_MAX);
strncpy (PathDstInTreeWithFile,PathDstInTree,PATH_MAX);
PathDstInTreeWithFile[PATH_MAX] = '\0';
}
else // Origin of copy is a file or folder inside the root folder else // Origin of copy is a file or folder inside the root folder
// for example "sha/folder1/file1" // for example "sha/folder1/file1"
sprintf (PathDstInTreeWithFile,"%s/%s",PathDstInTree,FileNameOrg); sprintf (PathDstInTreeWithFile,"%s/%s",PathDstInTree,FileNameOrg);
@ -8417,15 +8395,15 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
char PathUntilFileName[PATH_MAX+1]; char PathUntilFileName[PATH_MAX+1];
char Path[PATH_MAX+1]; char Path[PATH_MAX+1];
char PathTmp[PATH_MAX+1]; char PathTmp[PATH_MAX+1];
char PathCompleteInTreeIncludingFile[PATH_MAX+1]; char PathCompleteInTreeIncludingFile[PATH_MAX + 1];
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
bool AdminMarks; bool AdminMarks;
bool FileIsValid = true; bool FileIsValid = true;
long FilCod = -1L; // Code of new file in database long FilCod = -1L; // Code of new file in database
struct FileMetadata FileMetadata; struct FileMetadata FileMetadata;
struct MarksProperties Marks; struct MarksProperties Marks;
unsigned NumUsrsToBeNotifiedByEMail; unsigned NumUsrsToBeNotifiedByEMail;
char FileNameToShow[NAME_MAX+1]; char FileNameToShow[NAME_MAX + 1];
bool UploadSucessful = false; bool UploadSucessful = false;
/***** Get parameters related to file browser *****/ /***** Get parameters related to file browser *****/
@ -8573,18 +8551,12 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
} }
} }
else // Empty filename else // Empty filename
{ Str_Copy (Gbl.Message,Txt_UPLOAD_FILE_You_must_specify_the_file_NO_HTML,
strncpy (Gbl.Message,Txt_UPLOAD_FILE_You_must_specify_the_file_NO_HTML, Lay_MAX_BYTES_ALERT);
Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
}
} }
else // I do not have permission to create files here else // I do not have permission to create files here
{ Str_Copy (Gbl.Message,Txt_UPLOAD_FILE_Forbidden_NO_HTML,
strncpy (Gbl.Message,Txt_UPLOAD_FILE_Forbidden_NO_HTML, Lay_MAX_BYTES_ALERT);
Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
}
return UploadSucessful; return UploadSucessful;
} }
@ -8630,7 +8602,7 @@ void Brw_RecLinkFileBrowser (void)
Name given by me: intel-architectures.pdf Name given by me: intel-architectures.pdf
File in swad: intel-architectures.pdf.url File in swad: intel-architectures.pdf.url
*/ */
strncpy (URLWithoutEndingSlash,Gbl.FileBrowser.NewFilFolLnkName,PATH_MAX); Str_Copy (URLWithoutEndingSlash,Gbl.FileBrowser.NewFilFolLnkName,PATH_MAX);
else else
/* /*
Gbl.FileBrowser.NewFilFolLnkName is empty Gbl.FileBrowser.NewFilFolLnkName is empty
@ -8639,8 +8611,7 @@ void Brw_RecLinkFileBrowser (void)
URL: http://www.intel.es/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-manual-325462.pdf URL: http://www.intel.es/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-manual-325462.pdf
File in swad: 64-ia-32-architectures-software-developer-manual-325462.pdf.url File in swad: 64-ia-32-architectures-software-developer-manual-325462.pdf.url
*/ */
strncpy (URLWithoutEndingSlash,URL,PATH_MAX); Str_Copy (URLWithoutEndingSlash,URL,PATH_MAX);
URLWithoutEndingSlash[PATH_MAX] = '\0';
/* Remove possible final '/' from URL */ /* Remove possible final '/' from URL */
if (URLWithoutEndingSlash[LengthURL - 1] == '/') if (URLWithoutEndingSlash[LengthURL - 1] == '/')
@ -9997,8 +9968,7 @@ void Brw_GetFileMetadataByPath (struct FileMetadata *FileMetadata)
FileMetadata->FileType = (Brw_FileType_t) UnsignedNum; FileMetadata->FileType = (Brw_FileType_t) UnsignedNum;
/* Get path (row[6]) */ /* Get path (row[6]) */
strncpy (FileMetadata->FullPathInTree,row[6],PATH_MAX); Str_Copy (FileMetadata->FullPathInTree,row[6],PATH_MAX);
FileMetadata->FullPathInTree[PATH_MAX] = '\0';
Str_SplitFullPathIntoPathAndFileName (FileMetadata->FullPathInTree, Str_SplitFullPathIntoPathAndFileName (FileMetadata->FullPathInTree,
FileMetadata->PathInTreeUntilFilFolLnk, FileMetadata->PathInTreeUntilFilFolLnk,
FileMetadata->FilFolLnkName); FileMetadata->FilFolLnkName);
@ -10127,8 +10097,7 @@ void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata)
FileMetadata->FileType = (Brw_FileType_t) UnsignedNum; FileMetadata->FileType = (Brw_FileType_t) UnsignedNum;
/* Get path (row[6]) */ /* Get path (row[6]) */
strncpy (FileMetadata->FullPathInTree,row[6],PATH_MAX); Str_Copy (FileMetadata->FullPathInTree,row[6],PATH_MAX);
FileMetadata->FullPathInTree[PATH_MAX] = '\0';
Str_SplitFullPathIntoPathAndFileName (FileMetadata->FullPathInTree, Str_SplitFullPathIntoPathAndFileName (FileMetadata->FullPathInTree,
FileMetadata->PathInTreeUntilFilFolLnk, FileMetadata->PathInTreeUntilFilFolLnk,
FileMetadata->FilFolLnkName); FileMetadata->FilFolLnkName);
@ -11189,8 +11158,7 @@ void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],cha
Brw_GetFileMetadataByCod (&FileMetadata); Brw_GetFileMetadataByCod (&FileMetadata);
/***** Copy file name into summary string *****/ /***** Copy file name into summary string *****/
strncpy (SummaryStr,FileMetadata.FilFolLnkName,Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,FileMetadata.FilFolLnkName,Cns_MAX_BYTES_TEXT);
SummaryStr[Cns_MAX_BYTES_TEXT] = '\0';
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);

View File

@ -136,7 +136,9 @@ struct FileMetadata
#define Brw_MAX_DIR_LEVELS 10 // Maximum number of subdirectory levels in file browsers #define Brw_MAX_DIR_LEVELS 10 // Maximum number of subdirectory levels in file browsers
#define Brw_MAX_BYTES_MIME_TYPE 256 // Maximum length of "image/jpeg", "text/html", etc. #define Brw_MAX_BYTES_MIME_TYPE (256 - 1) // Maximum length of "image/jpeg", "text/html", etc.
#define Brw_MAX_LENGTH_LICENSE (256 - 1)
#define Brw_INTERNAL_NAME_ROOT_FOLDER_DOCUMENTS "doc" #define Brw_INTERNAL_NAME_ROOT_FOLDER_DOCUMENTS "doc"
#define Brw_INTERNAL_NAME_ROOT_FOLDER_SHARED_FILES "sha" #define Brw_INTERNAL_NAME_ROOT_FOLDER_SHARED_FILES "sha"

View File

@ -676,8 +676,7 @@ static void For_GetThrSubject (long ThrCod,char *Subject,size_t MaxSize)
/***** Write the subject of the thread *****/ /***** Write the subject of the thread *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Subject,row[0],MaxSize); Str_Copy (Subject,row[0],MaxSize);
Subject[MaxSize] = '\0';
Str_LimitLengthHTMLStr (Subject,20); Str_LimitLengthHTMLStr (Subject,20);
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -1193,11 +1192,8 @@ static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long Pst
Subject,OriginalContent,&Image); Subject,OriginalContent,&Image);
if (Enabled) if (Enabled)
{
/* Return this subject as last subject */ /* Return this subject as last subject */
strncpy (LastSubject,Subject,Cns_MAX_BYTES_SUBJECT); Str_Copy (LastSubject,Subject,Cns_MAX_BYTES_SUBJECT);
LastSubject[Cns_MAX_BYTES_SUBJECT] = '\0';
}
/***** Put an icon with post status *****/ /***** Put an icon with post status *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
@ -1323,8 +1319,7 @@ static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long Pst
"<td class=\"MSG_TXT LEFT_TOP\">"); "<td class=\"MSG_TXT LEFT_TOP\">");
if (Enabled) if (Enabled)
{ {
strncpy (Content,OriginalContent,Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,OriginalContent,Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false); Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false);
/***** Show image *****/ /***** Show image *****/
@ -1375,12 +1370,10 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
*CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]); *CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
/****** Get subject (row[2]) *****/ /****** Get subject (row[2]) *****/
strncpy (Subject,row[2],Cns_MAX_BYTES_SUBJECT); Str_Copy (Subject,row[2],Cns_MAX_BYTES_SUBJECT);
Subject[Cns_MAX_BYTES_SUBJECT] = '\0';
/****** Get location (row[3]) *****/ /****** Get location (row[3]) *****/
strncpy (Content,row[3],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[3],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
/****** Get image name (row[4]), title (row[5]) and URL (row[6]) *****/ /****** Get image name (row[4]), title (row[5]) and URL (row[6]) *****/
Img_GetImageNameTitleAndURLFromRow (row[4],row[5],row[6],Image); Img_GetImageNameTitleAndURLFromRow (row[4],row[5],row[6],Image);
@ -1419,9 +1412,7 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/***** Copy subject *****/ /***** Copy subject *****/
strncpy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT);
SummaryStr[Cns_MAX_BYTES_TEXT] = '\0';
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -1433,8 +1424,7 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL) if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content."); Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
strncpy (*ContentStr,row[1],Length); Str_Copy (*ContentStr,row[1],Length);
(*ContentStr)[Length] = '\0';
} }
} }
mysql_free_result (mysql_res); mysql_free_result (mysql_res);
@ -2201,8 +2191,7 @@ void For_SetForumName (For_ForumType_t ForumType,
switch (ForumType) switch (ForumType)
{ {
case For_FORUM_COURSE_USRS: case For_FORUM_COURSE_USRS:
strncpy (ForumName,Crs->ShrtName,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Crs->ShrtName,For_MAX_BYTES_FORUM_NAME);
ForumName[For_MAX_BYTES_FORUM_NAME] = '\0';
break; break;
case For_FORUM_COURSE_TCHS: case For_FORUM_COURSE_TCHS:
sprintf (ForumName,"%s%s",Crs->ShrtName, sprintf (ForumName,"%s%s",Crs->ShrtName,
@ -2210,8 +2199,7 @@ void For_SetForumName (For_ForumType_t ForumType,
Txt_only_teachers_NO_HTML[Language]); Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_DEGREE_USRS: case For_FORUM_DEGREE_USRS:
strncpy (ForumName,Deg->ShrtName,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Deg->ShrtName,For_MAX_BYTES_FORUM_NAME);
ForumName[For_MAX_BYTES_FORUM_NAME] = '\0';
break; break;
case For_FORUM_DEGREE_TCHS: case For_FORUM_DEGREE_TCHS:
sprintf (ForumName,"%s%s",Deg->ShrtName, sprintf (ForumName,"%s%s",Deg->ShrtName,
@ -2219,8 +2207,7 @@ void For_SetForumName (For_ForumType_t ForumType,
Txt_only_teachers_NO_HTML[Language]); Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_CENTRE_USRS: case For_FORUM_CENTRE_USRS:
strncpy (ForumName,Ctr->ShrtName,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Ctr->ShrtName,For_MAX_BYTES_FORUM_NAME);
ForumName[For_MAX_BYTES_FORUM_NAME] = '\0';
break; break;
case For_FORUM_CENTRE_TCHS: case For_FORUM_CENTRE_TCHS:
sprintf (ForumName,"%s%s",Ctr->ShrtName, sprintf (ForumName,"%s%s",Ctr->ShrtName,
@ -2228,8 +2215,7 @@ void For_SetForumName (For_ForumType_t ForumType,
Txt_only_teachers_NO_HTML[Language]); Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_INSTIT_USRS: case For_FORUM_INSTIT_USRS:
strncpy (ForumName,Ins->ShrtName,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Ins->ShrtName,For_MAX_BYTES_FORUM_NAME);
ForumName[For_MAX_BYTES_FORUM_NAME] = '\0';
break; break;
case For_FORUM_INSTIT_TCHS: case For_FORUM_INSTIT_TCHS:
sprintf (ForumName,"%s%s",Ins->ShrtName, sprintf (ForumName,"%s%s",Ins->ShrtName,
@ -2237,10 +2223,9 @@ void For_SetForumName (For_ForumType_t ForumType,
Txt_only_teachers_NO_HTML[Language]); Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_GLOBAL_USRS: case For_FORUM_GLOBAL_USRS:
strncpy (ForumName,UseHTMLEntities ? Txt_General : Str_Copy (ForumName,UseHTMLEntities ? Txt_General :
Txt_General_NO_HTML[Language], Txt_General_NO_HTML[Language],
For_MAX_BYTES_FORUM_NAME); For_MAX_BYTES_FORUM_NAME);
ForumName[For_MAX_BYTES_FORUM_NAME] = '\0';
break; break;
case For_FORUM_GLOBAL_TCHS: case For_FORUM_GLOBAL_TCHS:
sprintf (ForumName,"%s%s", sprintf (ForumName,"%s%s",
@ -2250,8 +2235,7 @@ void For_SetForumName (For_ForumType_t ForumType,
Txt_only_teachers_NO_HTML[Language]); Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_SWAD_USRS: case For_FORUM_SWAD_USRS:
strncpy (ForumName,Cfg_PLATFORM_SHORT_NAME,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Cfg_PLATFORM_SHORT_NAME,For_MAX_BYTES_FORUM_NAME);
ForumName[For_MAX_BYTES_FORUM_NAME] = '\0';
break; break;
case For_FORUM_SWAD_TCHS: case For_FORUM_SWAD_TCHS:
sprintf (ForumName,"%s%s",Cfg_PLATFORM_SHORT_NAME, sprintf (ForumName,"%s%s",Cfg_PLATFORM_SHORT_NAME,
@ -3613,8 +3597,7 @@ void For_GetThrData (struct ForumThread *Thr)
Thr->WriteTime[For_LAST_MSG ] = Dat_GetUNIXTimeFromStr (row[5]); Thr->WriteTime[For_LAST_MSG ] = Dat_GetUNIXTimeFromStr (row[5]);
/***** Get the subject of this thread (row[6]) *****/ /***** Get the subject of this thread (row[6]) *****/
strncpy (Thr->Subject,row[6],Cns_MAX_BYTES_SUBJECT); Str_Copy (Thr->Subject,row[6],Cns_MAX_BYTES_SUBJECT);
Thr->Subject[Cns_MAX_BYTES_SUBJECT] = '\0';
if (!Thr->Subject[0]) if (!Thr->Subject[0])
sprintf (Thr->Subject,"[%s]",Txt_no_subject); sprintf (Thr->Subject,"[%s]",Txt_no_subject);

View File

@ -191,10 +191,10 @@ void Gbl_InitializeGlobals (void)
Gbl.Usrs.LstUsrs[Role].NumUsrs = 0; Gbl.Usrs.LstUsrs[Role].NumUsrs = 0;
} }
Gbl.ExamAnnouncements.NumExaAnns = 0; Gbl.ExamAnns.NumExaAnns = 0;
Gbl.ExamAnnouncements.Lst = NULL; Gbl.ExamAnns.Lst = NULL;
Gbl.ExamAnnouncements.HighlightExaCod = -1L; Gbl.ExamAnns.HighlightExaCod = -1L;
Gbl.ExamAnnouncements.HighlightDate[0] = '\0'; // No exam announcements highlighted Gbl.ExamAnns.HighlightDate[0] = '\0'; // No exam announcements highlighted
Gbl.Usrs.Select.All = Gbl.Usrs.Select.All =
Gbl.Usrs.Select.Std = Gbl.Usrs.Select.Std =

View File

@ -493,7 +493,7 @@ struct Globals
char HighlightDate[4+1+2+1+2+1]; // Date with exam announcements to be highlighted (in YYYY-MM-DD format) char HighlightDate[4+1+2+1+2+1]; // Date with exam announcements to be highlighted (in YYYY-MM-DD format)
struct ExamData ExaDat; struct ExamData ExaDat;
bool NewExamAnnouncement; bool NewExamAnnouncement;
} ExamAnnouncements; } ExamAnns;
struct struct
{ {
unsigned Id; // Each file browser in the page has a unique identifier unsigned Id; // Each file browser in the page has a unique identifier

View File

@ -2367,7 +2367,8 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
Lay_ShowErrorAndExit ("Wrong type of group."); Lay_ShowErrorAndExit ("Wrong type of group.");
/* Get group type name (row[1]) */ /* Get group type name (row[1]) */
strncpy (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].GrpTypName,row[1],Grp_MAX_LENGTH_GROUP_TYPE_NAME); Str_Copy (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].GrpTypName,row[1],
Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Is it mandatory to register in any groups of this type? (row[2]) */ /* Is it mandatory to register in any groups of this type? (row[2]) */
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].MandatoryEnrollment = (row[2][0] == 'Y'); Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].MandatoryEnrollment = (row[2][0] == 'Y');
@ -2497,8 +2498,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
Lay_ShowErrorAndExit ("Wrong code of group."); Lay_ShowErrorAndExit ("Wrong code of group.");
/* Get group name (row[1]) */ /* Get group name (row[1]) */
strncpy (Grp->GrpName,row[1],Grp_MAX_LENGTH_GROUP_NAME); Str_Copy (Grp->GrpName,row[1],Grp_MAX_LENGTH_GROUP_NAME);
Grp->GrpName[Grp_MAX_LENGTH_GROUP_NAME] = '\0';
/* Get max number of students of group (row[2]) and number of current students */ /* Get max number of students of group (row[2]) and number of current students */
Grp->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[2]); Grp->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[2]);
@ -2626,8 +2626,7 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
/***** Get some data of group type *****/ /***** Get some data of group type *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (GrpTyp->GrpTypName,row[0],Grp_MAX_LENGTH_GROUP_TYPE_NAME); Str_Copy (GrpTyp->GrpTypName,row[0],Grp_MAX_LENGTH_GROUP_TYPE_NAME);
GrpTyp->GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME] = '\0';
GrpTyp->MandatoryEnrollment = (row[1][0] == 'Y'); GrpTyp->MandatoryEnrollment = (row[1][0] == 'Y');
GrpTyp->MultipleEnrollment = (row[2][0] == 'Y'); GrpTyp->MultipleEnrollment = (row[2][0] == 'Y');
GrpTyp->MustBeOpened = (row[3][0] == 'Y'); GrpTyp->MustBeOpened = (row[3][0] == 'Y');
@ -2713,15 +2712,13 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
Lay_ShowErrorAndExit ("Wrong code of course."); Lay_ShowErrorAndExit ("Wrong code of course.");
/* Get the name of the group type (row[2]) */ /* Get the name of the group type (row[2]) */
strncpy (GrpDat->GrpTypName,row[2],Grp_MAX_LENGTH_GROUP_TYPE_NAME); Str_Copy (GrpDat->GrpTypName,row[2],Grp_MAX_LENGTH_GROUP_TYPE_NAME);
GrpDat->GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME] = '\0';
/* Get whether a student may be in one or multiple groups (row[3]) */ /* Get whether a student may be in one or multiple groups (row[3]) */
GrpDat->MultipleEnrollment = (row[3][0] == 'Y'); GrpDat->MultipleEnrollment = (row[3][0] == 'Y');
/* Get the name of the group (row[4]) */ /* Get the name of the group (row[4]) */
strncpy (GrpDat->GrpName,row[4],Grp_MAX_LENGTH_GROUP_NAME); Str_Copy (GrpDat->GrpName,row[4],Grp_MAX_LENGTH_GROUP_NAME);
GrpDat->GrpName[Grp_MAX_LENGTH_GROUP_NAME] = '\0';
/* Get maximum number of students (row[5]) */ /* Get maximum number of students (row[5]) */
GrpDat->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[5]); GrpDat->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[5]);
@ -4018,9 +4015,8 @@ void Grp_RenameGroupType (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,NewNameGrpTyp, Str_Copy (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,NewNameGrpTyp,
Grp_MAX_LENGTH_GROUP_TYPE_NAME); Grp_MAX_LENGTH_GROUP_TYPE_NAME);
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME] = '\0';
Grp_ReqEditGroups (); Grp_ReqEditGroups ();
} }
@ -4091,8 +4087,7 @@ void Grp_RenameGroup (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (Gbl.CurrentCrs.Grps.GrpName,NewNameGrp,Grp_MAX_LENGTH_GROUP_NAME); Str_Copy (Gbl.CurrentCrs.Grps.GrpName,NewNameGrp,Grp_MAX_LENGTH_GROUP_NAME);
Gbl.CurrentCrs.Grps.GrpName[Grp_MAX_LENGTH_GROUP_NAME] = '\0';
Grp_ReqEditGroups (); Grp_ReqEditGroups ();
} }

View File

@ -312,8 +312,7 @@ void Hld_GetListHolidays (void)
Hld->PlcCod = Str_ConvertStrCodToLongCod (row[1]); Hld->PlcCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get the full name of the place (row[2]) */ /* Get the full name of the place (row[2]) */
strncpy (Hld->PlaceFullName,row[2],Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Hld->PlaceFullName,row[2],Plc_MAX_LENGTH_PLACE_FULL_NAME);
Hld->PlaceFullName[Plc_MAX_LENGTH_PLACE_FULL_NAME] = '\0';
/* Get type (row[3]) */ /* Get type (row[3]) */
Hld->HldTyp = Hld_GetTypeOfHoliday (row[3]); Hld->HldTyp = Hld_GetTypeOfHoliday (row[3]);
@ -337,8 +336,7 @@ void Hld_GetListHolidays (void)
} }
/* Get the name of the holiday/non school period (row[6]) */ /* Get the name of the holiday/non school period (row[6]) */
strncpy (Hld->Name,row[6],Hld_MAX_LENGTH_HOLIDAY_NAME); Str_Copy (Hld->Name,row[6],Hld_MAX_LENGTH_HOLIDAY_NAME);
Hld->Name[Hld_MAX_LENGTH_HOLIDAY_NAME] = '\0';
} }
} }
@ -404,8 +402,7 @@ static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld)
Hld->PlcCod = Str_ConvertStrCodToLongCod (row[0]); Hld->PlcCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get the full name of the place (row[1]) */ /* Get the full name of the place (row[1]) */
strncpy (Hld->PlaceFullName,row[1],Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Hld->PlaceFullName,row[1],Plc_MAX_LENGTH_PLACE_FULL_NAME);
Hld->PlaceFullName[Plc_MAX_LENGTH_PLACE_FULL_NAME] = '\0';
/* Get type (row[2]) */ /* Get type (row[2]) */
Hld->HldTyp = Hld_GetTypeOfHoliday (row[2]); Hld->HldTyp = Hld_GetTypeOfHoliday (row[2]);
@ -429,8 +426,7 @@ static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld)
} }
/* Get the name of the holiday/non school period (row[5]) */ /* Get the name of the holiday/non school period (row[5]) */
strncpy (Hld->Name,row[5],Hld_MAX_LENGTH_HOLIDAY_NAME); Str_Copy (Hld->Name,row[5],Hld_MAX_LENGTH_HOLIDAY_NAME);
Hld->Name[Hld_MAX_LENGTH_HOLIDAY_NAME] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -698,9 +694,7 @@ void Hld_ChangeHolidayPlace (void)
/***** Show the form again *****/ /***** Show the form again *****/
Hld->PlcCod = NewPlace.PlcCod; Hld->PlcCod = NewPlace.PlcCod;
strncpy (Hld->PlaceFullName,NewPlace.FullName,Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Hld->PlaceFullName,NewPlace.FullName,Plc_MAX_LENGTH_PLACE_FULL_NAME);
Hld->PlaceFullName[Plc_MAX_LENGTH_PLACE_FULL_NAME] = '\0';
Hld_EditHolidays (); Hld_EditHolidays ();
} }
@ -895,9 +889,7 @@ void Hld_RenameHoliday (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (Hld->Name,NewHldName,Hld_MAX_LENGTH_HOLIDAY_NAME); Str_Copy (Hld->Name,NewHldName,Hld_MAX_LENGTH_HOLIDAY_NAME);
Hld->Name[Hld_MAX_LENGTH_HOLIDAY_NAME] = '\0';
Hld_EditHolidays (); Hld_EditHolidays ();
} }

View File

@ -143,8 +143,7 @@ void Img_GetImageNameTitleAndURLFromRow (const char *Name,
size_t Length; size_t Length;
/***** Copy image name to struct *****/ /***** Copy image name to struct *****/
strncpy (Image->Name,Name,Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Str_Copy (Image->Name,Name,Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
Image->Name[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64] = '\0';
/***** Set status of image file *****/ /***** Set status of image file *****/
Image->Status = Image->Name[0] ? Img_NAME_STORED_IN_DB : Image->Status = Image->Name[0] ? Img_NAME_STORED_IN_DB :
@ -164,8 +163,7 @@ void Img_GetImageNameTitleAndURLFromRow (const char *Name,
if ((Image->Title = (char *) malloc (Length+1)) == NULL) if ((Image->Title = (char *) malloc (Length+1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for image title."); Lay_ShowErrorAndExit ("Error allocating memory for image title.");
strncpy (Image->Title,Title,Length); Str_Copy (Image->Title,Title,Length);
Image->Title[Length] = '\0';
} }
/***** Copy image URL to struct *****/ /***** Copy image URL to struct *****/
@ -181,8 +179,7 @@ void Img_GetImageNameTitleAndURLFromRow (const char *Name,
if ((Image->URL = (char *) malloc (Length+1)) == NULL) if ((Image->URL = (char *) malloc (Length+1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for image URL."); Lay_ShowErrorAndExit ("Error allocating memory for image URL.");
strncpy (Image->URL,URL,Length); Str_Copy (Image->URL,URL,Length);
Image->URL[Length] = '\0';
} }
} }
@ -320,8 +317,7 @@ void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
Img_FreeImageTitle (Image); Img_FreeImageTitle (Image);
if ((Image->Title = (char *) malloc (Length + 1)) == NULL) if ((Image->Title = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for image title."); Lay_ShowErrorAndExit ("Error allocating memory for image title.");
strncpy (Image->Title,Title,Length); Str_Copy (Image->Title,Title,Length);
Image->Title[Length] = '\0';
} }
/***** By last, get image URL from form *****/ /***** By last, get image URL from form *****/
@ -335,8 +331,7 @@ void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
Img_FreeImageURL (Image); Img_FreeImageURL (Image);
if ((Image->URL = (char *) malloc (Length + 1)) == NULL) if ((Image->URL = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for image URL."); Lay_ShowErrorAndExit ("Error allocating memory for image URL.");
strncpy (Image->URL,URL,Length); Str_Copy (Image->URL,URL,Length);
Image->URL[Length] = '\0';
} }
} }
@ -350,17 +345,10 @@ void Img_SetParamNames (struct ParamUploadImg *ParamUploadImg,int NumImgInForm)
{ {
if (NumImgInForm < 0) // One unique image in form ==> no suffix needed if (NumImgInForm < 0) // One unique image in form ==> no suffix needed
{ {
strncpy (ParamUploadImg->Action,"ImgAct",Img_MAX_LENGTH_PARAM_UPLOAD_IMG); Str_Copy (ParamUploadImg->Action,"ImgAct",Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
ParamUploadImg->Action[Img_MAX_LENGTH_PARAM_UPLOAD_IMG] = '\0'; Str_Copy (ParamUploadImg->File ,"ImgFil",Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
Str_Copy (ParamUploadImg->Title ,"ImgTit",Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
strncpy (ParamUploadImg->File ,"ImgFil",Img_MAX_LENGTH_PARAM_UPLOAD_IMG); Str_Copy (ParamUploadImg->URL ,"ImgURL",Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
ParamUploadImg->File [Img_MAX_LENGTH_PARAM_UPLOAD_IMG] = '\0';
strncpy (ParamUploadImg->Title ,"ImgTit",Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
ParamUploadImg->Title [Img_MAX_LENGTH_PARAM_UPLOAD_IMG] = '\0';
strncpy (ParamUploadImg->URL ,"ImgURL",Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
ParamUploadImg->URL [Img_MAX_LENGTH_PARAM_UPLOAD_IMG] = '\0';
} }
else // Several images in form ==> add suffix else // Several images in form ==> add suffix
{ {
@ -401,7 +389,7 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
char FileNameImgSrc[PATH_MAX+1]; char FileNameImgSrc[PATH_MAX+1];
char *PtrExtension; char *PtrExtension;
size_t LengthExtension; size_t LengthExtension;
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
char PathImgPriv[PATH_MAX+1]; char PathImgPriv[PATH_MAX+1];
char FileNameImgOrig[PATH_MAX+1]; // Full name of original uploaded file char FileNameImgOrig[PATH_MAX+1]; // Full name of original uploaded file
char FileNameImgTmp[PATH_MAX+1]; // Full name of temporary processed file char FileNameImgTmp[PATH_MAX+1]; // Full name of temporary processed file

View File

@ -1715,17 +1715,11 @@ static void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
/* Get text in HTML format (not rigorous) */ /* Get text in HTML format (not rigorous) */
if (InfoTxtHTML) if (InfoTxtHTML)
{ Str_Copy (InfoTxtHTML,row[0],MaxLength);
strncpy (InfoTxtHTML,row[0],MaxLength);
InfoTxtHTML[MaxLength] = '\0';
}
/* Get text in Markdown format */ /* Get text in Markdown format */
if (InfoTxtMD) if (InfoTxtMD)
{ Str_Copy (InfoTxtMD,row[1],MaxLength);
strncpy (InfoTxtMD,row[1],MaxLength);
InfoTxtMD[MaxLength] = '\0';
}
} }
else else
{ {
@ -2150,10 +2144,7 @@ void Inf_RecAndChangePlainTxtInfo (void)
/***** Get text with course information from form *****/ /***** Get text with course information from form *****/
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat, Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT,NULL); Cns_MAX_BYTES_LONG_TEXT,NULL);
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT);
strncpy (Txt_MarkdownFormat,Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT);
Txt_MarkdownFormat[Cns_MAX_BYTES_LONG_TEXT] = '\0';
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML, Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous) Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN, Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,
@ -2188,10 +2179,7 @@ void Inf_RecAndChangeRichTxtInfo (void)
/***** Get text with course information from form *****/ /***** Get text with course information from form *****/
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat, Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT,NULL); Cns_MAX_BYTES_LONG_TEXT,NULL);
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT);
strncpy (Txt_MarkdownFormat,Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT);
Txt_MarkdownFormat[Cns_MAX_BYTES_LONG_TEXT] = '\0';
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML, Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous) Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN, Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,
@ -2286,7 +2274,7 @@ void Inf_ReceivePagInfo (void)
char PathRelDirHTML[PATH_MAX+1]; char PathRelDirHTML[PATH_MAX+1];
char PathRelFileHTML[PATH_MAX+1]; char PathRelFileHTML[PATH_MAX+1];
char PathRelFileZIP[PATH_MAX+1]; char PathRelFileZIP[PATH_MAX+1];
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
char StrUnzip[100+PATH_MAX*2+1]; char StrUnzip[100+PATH_MAX*2+1];
bool WrongType = false; bool WrongType = false;
bool FileIsOK = false; bool FileIsOK = false;

View File

@ -1028,16 +1028,13 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]); Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]);
/* Get the short name of the institution (row[4]) */ /* Get the short name of the institution (row[4]) */
strncpy (Ins->ShrtName,row[4],Ins_MAX_LENGTH_INSTIT_SHRT_NAME); Str_Copy (Ins->ShrtName,row[4],Ins_MAX_LENGTH_INSTIT_SHRT_NAME);
Ins->ShrtName[Ins_MAX_LENGTH_INSTIT_SHRT_NAME] = '\0';
/* Get the full name of the institution (row[5]) */ /* Get the full name of the institution (row[5]) */
strncpy (Ins->FullName,row[5],Ins_MAX_LENGTH_INSTIT_FULL_NAME); Str_Copy (Ins->FullName,row[5],Ins_MAX_LENGTH_INSTIT_FULL_NAME);
Ins->FullName[Ins_MAX_LENGTH_INSTIT_FULL_NAME] = '\0';
/* Get the URL of the institution (row[6]) */ /* Get the URL of the institution (row[6]) */
strncpy (Ins->WWW,row[6],Cns_MAX_LENGTH_WWW); Str_Copy (Ins->WWW,row[6],Cns_MAX_LENGTH_WWW);
Ins->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* Get extra data */ /* Get extra data */
switch (GetExtraData) switch (GetExtraData)
@ -1125,16 +1122,13 @@ bool Ins_GetDataOfInstitutionByCod (struct Instit *Ins,
Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[2]); Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[2]);
/* Get the short name of the institution (row[3]) */ /* Get the short name of the institution (row[3]) */
strncpy (Ins->ShrtName,row[3],Ins_MAX_LENGTH_INSTIT_SHRT_NAME); Str_Copy (Ins->ShrtName,row[3],Ins_MAX_LENGTH_INSTIT_SHRT_NAME);
Ins->ShrtName[Ins_MAX_LENGTH_INSTIT_SHRT_NAME] = '\0';
/* Get the full name of the institution (row[4]) */ /* Get the full name of the institution (row[4]) */
strncpy (Ins->FullName,row[4],Ins_MAX_LENGTH_INSTIT_FULL_NAME); Str_Copy (Ins->FullName,row[4],Ins_MAX_LENGTH_INSTIT_FULL_NAME);
Ins->FullName[Ins_MAX_LENGTH_INSTIT_FULL_NAME] = '\0';
/* Get the URL of the institution (row[5]) */ /* Get the URL of the institution (row[5]) */
strncpy (Ins->WWW,row[5],Cns_MAX_LENGTH_WWW); Str_Copy (Ins->WWW,row[5],Cns_MAX_LENGTH_WWW);
Ins->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* Get extra data */ /* Get extra data */
if (GetExtraData == Ins_GET_EXTRA_DATA) if (GetExtraData == Ins_GET_EXTRA_DATA)
@ -1184,8 +1178,7 @@ void Ins_GetShortNameOfInstitutionByCod (struct Instit *Ins)
/***** Get the short name of this institution *****/ /***** Get the short name of this institution *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Ins->ShrtName,row[0],Ins_MAX_LENGTH_INSTIT_SHRT_NAME); Str_Copy (Ins->ShrtName,row[0],Ins_MAX_LENGTH_INSTIT_SHRT_NAME);
Ins->ShrtName[Ins_MAX_LENGTH_INSTIT_SHRT_NAME] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -1394,8 +1387,7 @@ static void Ins_ListInstitutionsForEdition (void)
} }
else else
{ {
strncpy (WWW,Ins->WWW,Ins_MAX_LENGTH_WWW_ON_SCREEN); Str_Copy (WWW,Ins->WWW,Ins_MAX_LENGTH_WWW_ON_SCREEN);
WWW[Ins_MAX_LENGTH_WWW_ON_SCREEN] = '\0';
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\">%s", fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\">%s",
Ins->WWW,Ins->WWW,WWW); Ins->WWW,Ins->WWW,WWW);
if (strlen (Ins->WWW) > Ins_MAX_LENGTH_WWW_ON_SCREEN) if (strlen (Ins->WWW) > Ins_MAX_LENGTH_WWW_ON_SCREEN)
@ -1717,8 +1709,7 @@ static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtO
CurrentInsName,NewInsName); CurrentInsName,NewInsName);
/* Change current institution name in order to display it properly */ /* Change current institution name in order to display it properly */
strncpy (CurrentInsName,NewInsName,MaxLength); Str_Copy (CurrentInsName,NewInsName,MaxLength);
CurrentInsName[MaxLength] = '\0';
} }
} }
else // The same name else // The same name
@ -1862,9 +1853,7 @@ void Ins_ChangeInsWWW (void)
{ {
/***** Update database changing old WWW by new WWW *****/ /***** Update database changing old WWW by new WWW *****/
Ins_UpdateInsWWWDB (Ins->InsCod,NewWWW); Ins_UpdateInsWWWDB (Ins->InsCod,NewWWW);
Str_Copy (Ins->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
strncpy (Ins->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Ins->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);
@ -1895,9 +1884,7 @@ void Ins_ChangeInsWWWInConfig (void)
{ {
/***** Update database changing old WWW by new WWW *****/ /***** Update database changing old WWW by new WWW *****/
Ins_UpdateInsWWWDB (Gbl.CurrentIns.Ins.InsCod,NewWWW); Ins_UpdateInsWWWDB (Gbl.CurrentIns.Ins.InsCod,NewWWW);
Str_Copy (Gbl.CurrentIns.Ins.WWW,NewWWW,Cns_MAX_LENGTH_WWW);
strncpy (Gbl.CurrentIns.Ins.WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Gbl.CurrentIns.Ins.WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);

View File

@ -556,12 +556,12 @@ static void Lay_WriteScripts (void)
fprintf (Gbl.F.Out," var LstExamAnnouncements = [];\n"); fprintf (Gbl.F.Out," var LstExamAnnouncements = [];\n");
for (NumExamAnnouncement = 0; for (NumExamAnnouncement = 0;
NumExamAnnouncement < Gbl.ExamAnnouncements.NumExaAnns; NumExamAnnouncement < Gbl.ExamAnns.NumExaAnns;
NumExamAnnouncement++) NumExamAnnouncement++)
fprintf (Gbl.F.Out," LstExamAnnouncements.push({ Year: %u, Month: %u, Day: %u });\n", fprintf (Gbl.F.Out," LstExamAnnouncements.push({ Year: %u, Month: %u, Day: %u });\n",
Gbl.ExamAnnouncements.Lst[NumExamAnnouncement].Year, Gbl.ExamAnns.Lst[NumExamAnnouncement].Year,
Gbl.ExamAnnouncements.Lst[NumExamAnnouncement].Month, Gbl.ExamAnns.Lst[NumExamAnnouncement].Month,
Gbl.ExamAnnouncements.Lst[NumExamAnnouncement].Day); Gbl.ExamAnns.Lst[NumExamAnnouncement].Day);
fprintf (Gbl.F.Out,"</script>\n"); fprintf (Gbl.F.Out,"</script>\n");

View File

@ -232,16 +232,13 @@ void Lnk_GetListLinks (void)
Lay_ShowErrorAndExit ("Wrong code of institutional link."); Lay_ShowErrorAndExit ("Wrong code of institutional link.");
/* Get the short name of the link (row[1]) */ /* Get the short name of the link (row[1]) */
strncpy (Lnk->ShrtName,row[1],Lnk_MAX_LENGTH_LINK_SHRT_NAME); Str_Copy (Lnk->ShrtName,row[1],Lnk_MAX_LENGTH_LINK_SHRT_NAME);
Lnk->ShrtName[Lnk_MAX_LENGTH_LINK_SHRT_NAME] = '\0';
/* Get the full name of the link (row[2]) */ /* Get the full name of the link (row[2]) */
strncpy (Lnk->FullName,row[2],Lnk_MAX_LENGTH_LINK_FULL_NAME); Str_Copy (Lnk->FullName,row[2],Lnk_MAX_LENGTH_LINK_FULL_NAME);
Lnk->FullName[Lnk_MAX_LENGTH_LINK_FULL_NAME] = '\0';
/* Get the URL of the link (row[3]) */ /* Get the URL of the link (row[3]) */
strncpy (Lnk->WWW,row[3],Cns_MAX_LENGTH_WWW); Str_Copy (Lnk->WWW,row[3],Cns_MAX_LENGTH_WWW);
Lnk->WWW[Cns_MAX_LENGTH_WWW] = '\0';
} }
} }
else else
@ -280,16 +277,13 @@ void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the short name of the link (row[0]) */ /* Get the short name of the link (row[0]) */
strncpy (Lnk->ShrtName,row[0],Lnk_MAX_LENGTH_LINK_SHRT_NAME); Str_Copy (Lnk->ShrtName,row[0],Lnk_MAX_LENGTH_LINK_SHRT_NAME);
Lnk->ShrtName[Lnk_MAX_LENGTH_LINK_SHRT_NAME] = '\0';
/* Get the full name of the link (row[1]) */ /* Get the full name of the link (row[1]) */
strncpy (Lnk->FullName,row[1],Lnk_MAX_LENGTH_LINK_FULL_NAME); Str_Copy (Lnk->FullName,row[1],Lnk_MAX_LENGTH_LINK_FULL_NAME);
Lnk->FullName[Lnk_MAX_LENGTH_LINK_FULL_NAME] = '\0';
/* Get the URL of the link (row[2]) */ /* Get the URL of the link (row[2]) */
strncpy (Lnk->WWW,row[2],Cns_MAX_LENGTH_WWW); Str_Copy (Lnk->WWW,row[2],Cns_MAX_LENGTH_WWW);
Lnk->WWW[Cns_MAX_LENGTH_WWW] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -551,9 +545,7 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (CurrentLnkName,NewLnkName,MaxLength); Str_Copy (CurrentLnkName,NewLnkName,MaxLength);
CurrentLnkName[MaxLength] = '\0';
Lnk_EditLinks (); Lnk_EditLinks ();
} }
@ -610,9 +602,7 @@ void Lnk_ChangeLinkWWW (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty); Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty);
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (Lnk->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Lnk->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Lnk->WWW[Cns_MAX_LENGTH_WWW] = '\0';
Lnk_EditLinks (); Lnk_EditLinks ();
} }

View File

@ -320,7 +320,7 @@ void Log_ReceiveLogo (Sco_Scope_t Scope)
char Path[PATH_MAX+1]; char Path[PATH_MAX+1];
struct Param *Param; struct Param *Param;
char FileNameLogoSrc[PATH_MAX+1]; char FileNameLogoSrc[PATH_MAX+1];
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
char FileNameLogo[PATH_MAX+1]; // Full name (including path and .png) of the destination file char FileNameLogo[PATH_MAX+1]; // Full name (including path and .png) of the destination file
bool WrongType = false; bool WrongType = false;

View File

@ -288,12 +288,10 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
Lay_ShowErrorAndExit ("Wrong code of mail domain."); Lay_ShowErrorAndExit ("Wrong code of mail domain.");
/* Get the mail domain (row[1]) */ /* Get the mail domain (row[1]) */
strncpy (Mai->Domain,row[1],Mai_MAX_LENGTH_MAIL_DOMAIN); Str_Copy (Mai->Domain,row[1],Mai_MAX_LENGTH_MAIL_DOMAIN);
Mai->Domain[Mai_MAX_LENGTH_MAIL_DOMAIN] = '\0';
/* Get the mail domain info (row[2]) */ /* Get the mail domain info (row[2]) */
strncpy (Mai->Info,row[2],Mai_MAX_LENGTH_MAIL_INFO); Str_Copy (Mai->Info,row[2],Mai_MAX_LENGTH_MAIL_INFO);
Mai->Info[Mai_MAX_LENGTH_MAIL_INFO] = '\0';
/* Get number of users (row[3]) */ /* Get number of users (row[3]) */
if (sscanf (row[3],"%u",&(Mai->NumUsrs)) != 1) if (sscanf (row[3],"%u",&(Mai->NumUsrs)) != 1)
@ -394,12 +392,10 @@ void Mai_GetDataOfMailDomainByCod (struct Mail *Mai)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the short name of the mail (row[0]) */ /* Get the short name of the mail (row[0]) */
strncpy (Mai->Domain,row[0],Mai_MAX_LENGTH_MAIL_DOMAIN); Str_Copy (Mai->Domain,row[0],Mai_MAX_LENGTH_MAIL_DOMAIN);
Mai->Domain[Mai_MAX_LENGTH_MAIL_DOMAIN] = '\0';
/* Get the full name of the mail (row[1]) */ /* Get the full name of the mail (row[1]) */
strncpy (Mai->Info,row[1],Mai_MAX_LENGTH_MAIL_INFO); Str_Copy (Mai->Info,row[1],Mai_MAX_LENGTH_MAIL_INFO);
Mai->Info[Mai_MAX_LENGTH_MAIL_INFO] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -653,9 +649,7 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strncpy (CurrentMaiName,NewMaiName,MaxLength); Str_Copy (CurrentMaiName,NewMaiName,MaxLength);
CurrentMaiName[MaxLength] = '\0';
Mai_EditMailDomains (); Mai_EditMailDomains ();
} }
@ -1036,14 +1030,10 @@ bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat)
} }
else else
{ {
row = mysql_fetch_row (mysql_res);
/* Get email */ /* Get email */
strncpy (UsrDat->Email,row[0],Usr_MAX_BYTES_USR_EMAIL); row = mysql_fetch_row (mysql_res);
UsrDat->Email[Usr_MAX_BYTES_USR_EMAIL] = '\0'; Str_Copy (UsrDat->Email,row[0],Usr_MAX_BYTES_USR_EMAIL);
UsrDat->EmailConfirmed = (row[1][0] == 'Y'); UsrDat->EmailConfirmed = (row[1][0] == 'Y');
Found = true; Found = true;
} }
@ -1690,8 +1680,7 @@ void Mai_ConfirmEmail (void)
UsrCod = Str_ConvertStrCodToLongCod (row[0]); UsrCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get user's email */ /* Get user's email */
strncpy (Email,row[1],Usr_MAX_BYTES_USR_EMAIL); Str_Copy (Email,row[1],Usr_MAX_BYTES_USR_EMAIL);
Email[Usr_MAX_BYTES_USR_EMAIL] = '\0';
KeyIsCorrect = true; KeyIsCorrect = true;
} }

View File

@ -323,10 +323,8 @@ bool Mrk_CheckFileOfMarks (const char *Path,struct MarksProperties *Marks)
// Only one table is allowed // Only one table is allowed
if (Str_FindStrInFile (FileAllMarks,"<table",Str_NO_SKIP_HTML_COMMENTS)) if (Str_FindStrInFile (FileAllMarks,"<table",Str_NO_SKIP_HTML_COMMENTS))
{ {
strncpy (Gbl.Message,Txt_There_are_more_than_one_table_in_the_file_of_marks, Str_Copy (Gbl.Message,Txt_There_are_more_than_one_table_in_the_file_of_marks,
Lay_MAX_BYTES_ALERT); Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
FileIsCorrect = false; FileIsCorrect = false;
} }
else else
@ -387,10 +385,8 @@ bool Mrk_CheckFileOfMarks (const char *Path,struct MarksProperties *Marks)
} }
else else
{ {
strncpy (Gbl.Message,Txt_Table_not_found_in_the_file_of_marks, Str_Copy (Gbl.Message,Txt_Table_not_found_in_the_file_of_marks,
Lay_MAX_BYTES_ALERT); Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
FileIsCorrect = false; FileIsCorrect = false;
} }
@ -462,9 +458,8 @@ static bool Mrk_GetUsrMarks (FILE *FileUsrMarks,struct UsrData *UsrDat,
/***** Open HTML file with the table of marks *****/ /***** Open HTML file with the table of marks *****/
if (!(FileAllMarks = fopen (PathFileAllMarks,"rb"))) if (!(FileAllMarks = fopen (PathFileAllMarks,"rb")))
{ // Can't open the file with the table of marks { // Can't open the file with the table of marks
strncpy (Gbl.Message,"Can not open file of marks.",Lay_MAX_BYTES_ALERT); // TODO: Need translation! Str_Copy (Gbl.Message,"Can not open file of marks.", // TODO: Need translation!
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0'; Lay_MAX_BYTES_ALERT);
return false; return false;
} }
@ -784,13 +779,11 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
&InsCod,&CtrCod,&DegCod,&CrsCod,&GrpCod); &InsCod,&CtrCod,&DegCod,&CrsCod,&GrpCod);
/* Path (row[2]) */ /* Path (row[2]) */
strncpy (FullPathInTreeFromDBMarksTable,row[2],PATH_MAX); Str_Copy (FullPathInTreeFromDBMarksTable,row[2],PATH_MAX);
FullPathInTreeFromDBMarksTable[PATH_MAX] = '\0';
Str_SplitFullPathIntoPathAndFileName (FullPathInTreeFromDBMarksTable, Str_SplitFullPathIntoPathAndFileName (FullPathInTreeFromDBMarksTable,
PathUntilFileName, PathUntilFileName,
FileName); FileName);
strncpy (SummaryStr,FileName,NAME_MAX); Str_Copy (SummaryStr,FileName,NAME_MAX);
SummaryStr[NAME_MAX] = '\0';
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -841,7 +834,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
if ((*ContentStr = (char *) malloc (Length + 1))) if ((*ContentStr = (char *) malloc (Length + 1)))
{ {
/* 9 starting chars */ /* 9 starting chars */
strncpy (*ContentStr,"<![CDATA[",9); Str_Copy (*ContentStr,"<![CDATA[",9);
/* Content */ /* Content */
Ptr = (*ContentStr) + 9; Ptr = (*ContentStr) + 9;
@ -855,10 +848,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
} }
/* 3 ending chars */ /* 3 ending chars */
strncpy (Ptr,"]]>",3); Str_Copy (Ptr,"]]>",3);
/* Ending null char */
(*ContentStr)[Length] = '\0';
} }
} }
else else
@ -870,10 +860,8 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
} }
else else
{ {
strncpy (Gbl.Message,"Can not open file with user's marks!", // TODO: Need translation! Str_Copy (Gbl.Message,"Can not open file with user's marks!", // TODO: Need translation!
Lay_MAX_BYTES_ALERT); Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
if ((*ContentStr = (char *) malloc (9+strlen (Gbl.Message)+3+1))) if ((*ContentStr = (char *) malloc (9+strlen (Gbl.Message)+3+1)))
sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Message); sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Message);
} }
@ -881,9 +869,8 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
} }
else else
{ {
strncpy (Gbl.Message,"User's IDs not found!",Lay_MAX_BYTES_ALERT); // TODO: Need translation! Str_Copy (Gbl.Message,"User's IDs not found!", // TODO: Need translation!
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0'; Lay_MAX_BYTES_ALERT);
if ((*ContentStr = (char *) malloc (9+strlen (Gbl.Message)+3+1))) if ((*ContentStr = (char *) malloc (9+strlen (Gbl.Message)+3+1)))
sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Message); sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Message);
} }

View File

@ -518,12 +518,10 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (char *Content)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get subject */ /* Get subject */
strncpy (Gbl.Msg.Subject,row[0],Cns_MAX_BYTES_SUBJECT); Str_Copy (Gbl.Msg.Subject,row[0],Cns_MAX_BYTES_SUBJECT);
Gbl.Msg.Subject[Cns_MAX_BYTES_SUBJECT] = '\0';
/* Get content */ /* Get content */
strncpy (Content,row[1],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[1],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
/* Free structure that stores the query result */ /* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -2714,8 +2712,7 @@ void Msg_GetMsgSubject (long MsgCod,char *Subject)
{ {
/***** Get subject *****/ /***** Get subject *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Subject,row[0],Cns_MAX_BYTES_SUBJECT); Str_Copy (Subject,row[0],Cns_MAX_BYTES_SUBJECT);
Subject[Cns_MAX_BYTES_SUBJECT] = '\0';
} }
else else
Subject[0] = '\0'; Subject[0] = '\0';
@ -2749,8 +2746,7 @@ static void Msg_GetMsgContent (long MsgCod,char *Content,struct Image *Image)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/ /****** Get content (row[0]) *****/
strncpy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
/****** Get image name (row[1]), title (row[2]) and URL (row[3]) *****/ /****** Get image name (row[1]), title (row[2]) and URL (row[3]) *****/
Img_GetImageNameTitleAndURLFromRow (row[1],row[2],row[3],Image); Img_GetImageNameTitleAndURLFromRow (row[1],row[2],row[3],Image);

View File

@ -225,8 +225,7 @@ void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
{ {
/* Get URL */ /* Get URL */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (URL,row[0],Cns_MAX_BYTES_URL); Str_Copy (URL,row[0],Cns_MAX_BYTES_URL);
URL[Cns_MAX_BYTES_URL] = '\0';
/* Show the web / social network */ /* Show the web / social network */
Net_ShowAWebOrSocialNet (URL, Net_ShowAWebOrSocialNet (URL,
@ -316,8 +315,7 @@ void Net_ShowFormMyWebsAndSocialNets (void)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get URL */ /* Get URL */
strncpy (URL,row[0],Cns_MAX_BYTES_URL); Str_Copy (URL,row[0],Cns_MAX_BYTES_URL);
URL[Cns_MAX_BYTES_URL] = '\0';
} }
else else
URL[0] = '\0'; URL[0] = '\0';
@ -553,8 +551,7 @@ void Net_ShowWebAndSocialNetworksStats (void)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get web / social network (row[0]) */ /* Get web / social network (row[0]) */
strncpy (WebStr,row[0],sizeof (WebStr) - 1); Str_Copy (WebStr,row[0],sizeof (WebStr) - 1);
WebStr[sizeof (WebStr) - 1] = '\0';
for (Web = (Net_WebsAndSocialNetworks_t) 0; for (Web = (Net_WebsAndSocialNetworks_t) 0;
Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS; Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
Web++) Web++)

View File

@ -73,8 +73,8 @@ bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba)
return false; return false;
/***** Make a copy of nickname *****/ /***** Make a copy of nickname *****/
strncpy (NicknameWithoutArroba,NicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Str_Copy (NicknameWithoutArroba,NicknameWithArroba,
NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA] = '\0'; Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
Str_RemoveLeadingArrobas (NicknameWithoutArroba); Str_RemoveLeadingArrobas (NicknameWithoutArroba);
Length = strlen (NicknameWithoutArroba); Length = strlen (NicknameWithoutArroba);
@ -116,8 +116,7 @@ bool Nck_GetNicknameFromUsrCod (long UsrCod,char *Nickname)
{ {
/* Get nickname */ /* Get nickname */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Nickname,row[0],Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA); Str_Copy (Nickname,row[0],Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
Nickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0';
Found = true; Found = true;
} }
else else
@ -150,8 +149,8 @@ long Nck_GetUsrCodFromNickname (const char *Nickname)
if (Nickname[0]) if (Nickname[0])
{ {
/***** Make a copy without possible starting arrobas *****/ /***** Make a copy without possible starting arrobas *****/
strncpy (NicknameWithoutArroba,Nickname,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Str_Copy (NicknameWithoutArroba,Nickname,
NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA] = '\0'; Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
Str_RemoveLeadingArrobas (NicknameWithoutArroba); Str_RemoveLeadingArrobas (NicknameWithoutArroba);
/***** Get user's code from database *****/ /***** Get user's code from database *****/
@ -362,8 +361,8 @@ void Nck_UpdateNick (void)
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
{ {
/***** Remove arrobas at the beginning *****/ /***** Remove arrobas at the beginning *****/
strncpy (NewNicknameWithoutArroba,NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA] = '\0'; Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba); Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
/***** Check if new nickname exists in database *****/ /***** Check if new nickname exists in database *****/

View File

@ -411,9 +411,9 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing)
UsrCod = Str_ConvertStrCodToLongCod (row[2]); UsrCod = Str_ConvertStrCodToLongCod (row[2]);
/* Get the content (row[3]) and insert links */ /* Get the content (row[3]) and insert links */
strncpy (Content,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[3],Cns_MAX_BYTES_TEXT);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT, Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
Not_MaxCharsURLOnScreen[TypeNoticesListing]); Not_MaxCharsURLOnScreen[TypeNoticesListing]);
if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES) if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES)
Str_LimitLengthHTMLStr (Content,Not_MAX_CHARS_ON_NOTICE); Str_LimitLengthHTMLStr (Content,Not_MAX_CHARS_ON_NOTICE);
@ -555,9 +555,9 @@ static void Not_GetDataAndShowNotice (long NotCod)
UsrCod = Str_ConvertStrCodToLongCod (row[1]); UsrCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get the content (row[2]) and insert links*/ /* Get the content (row[2]) and insert links*/
strncpy (Content,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[2],Cns_MAX_BYTES_TEXT);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT, Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]); Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]);
/* Get status of the notice (row[3]) */ /* Get status of the notice (row[3]) */
Status = Not_OBSOLETE_NOTICE; Status = Not_OBSOLETE_NOTICE;

View File

@ -55,6 +55,8 @@ extern struct Globals Gbl;
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
// strings are limited to Ntf_MAX_LENGTH_NOTIFY_EVENT characters
const char *Ntf_WSNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] = const char *Ntf_WSNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
{ {
"unknown", // Ntf_EVENT_UNKNOWN "unknown", // Ntf_EVENT_UNKNOWN

View File

@ -33,11 +33,15 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Ntf_MAX_LENGTH_NOTIFY_EVENT 32
#define Ntf_MAX_LENGTH_NOTIFY_LOCATION (1024 - 1)
/*****************************************************************************/ /*****************************************************************************/
/******************************** Public types *******************************/ /******************************** Public types *******************************/
/*****************************************************************************/ /*****************************************************************************/
#define Ntf_NUM_NOTIFY_EVENTS (1+19) #define Ntf_NUM_NOTIFY_EVENTS (1 + 19)
// If the numbers assigned to each event type change, // If the numbers assigned to each event type change,
// it is necessary to change old numbers to new ones // it is necessary to change old numbers to new ones
// in database tables notif, sta_notif and usr_data // in database tables notif, sta_notif and usr_data

View File

@ -577,8 +577,8 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName,
{ {
case Act_CONT_NORM: case Act_CONT_NORM:
if (PtrDst) if (PtrDst)
strncpy (PtrDst,&Gbl.Params.QueryString[Param->Value.Start], Str_Copy (PtrDst,&Gbl.Params.QueryString[Param->Value.Start],
Param->Value.Length); Param->Value.Length);
break; break;
case Act_CONT_DATA: case Act_CONT_DATA:
if (Param->FileName.Start == 0 && // Copy into destination only if it's not a file if (Param->FileName.Start == 0 && // Copy into destination only if it's not a file

View File

@ -562,18 +562,18 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
extern const char *Txt_X_faces_have_been_detected_in_front_position_1_Z_; extern const char *Txt_X_faces_have_been_detected_in_front_position_1_Z_;
extern const char *Txt_X_faces_have_been_detected_in_front_position_Y_Z_; extern const char *Txt_X_faces_have_been_detected_in_front_position_Y_Z_;
extern const char *Txt_Faces_detected; extern const char *Txt_Faces_detected;
char PathPhotosPriv[PATH_MAX+1]; char PathPhotosPriv[PATH_MAX + 1];
char PathPhotosPubl[PATH_MAX+1]; char PathPhotosPubl[PATH_MAX + 1];
struct Param *Param; struct Param *Param;
char FileNamePhotoSrc[PATH_MAX+1]; char FileNamePhotoSrc[PATH_MAX + 1];
char FileNamePhotoTmp[PATH_MAX+1]; // Full name (including path and .jpg) of the destination temporary file char FileNamePhotoTmp[PATH_MAX + 1]; // Full name (including path and .jpg) of the destination temporary file
char FileNamePhotoMap[PATH_MAX+1]; // Full name (including path) of the temporary file with the original image with faces char FileNamePhotoMap[PATH_MAX + 1]; // Full name (including path) of the temporary file with the original image with faces
char FileNameTxtMap[PATH_MAX+1]; // Full name (including path) of the temporary file with the text neccesary to make the image map char FileNameTxtMap[PATH_MAX + 1]; // Full name (including path) of the temporary file with the text neccesary to make the image map
char PathRelPhoto[PATH_MAX+1]; char PathRelPhoto[PATH_MAX + 1];
FILE *FileTxtMap = NULL; // Temporary file with the text neccesary to make the image map. Initialized to avoid warning FILE *FileTxtMap = NULL; // Temporary file with the text neccesary to make the image map. Initialized to avoid warning
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
bool WrongType = false; bool WrongType = false;
char Command[256+PATH_MAX]; // Command to call the program of preprocessing of photos char Command[256 + PATH_MAX]; // Command to call the program of preprocessing of photos
int ReturnCode; int ReturnCode;
int NumLastForm = 0; // Initialized to avoid warning int NumLastForm = 0; // Initialized to avoid warning
char FormId[32]; char FormId[32];
@ -585,7 +585,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
unsigned Y; unsigned Y;
unsigned Radius; unsigned Radius;
unsigned BackgroundCode; unsigned BackgroundCode;
char StrFileName[NAME_MAX+1]; char StrFileName[NAME_MAX + 1];
/***** Creates directories if not exist *****/ /***** Creates directories if not exist *****/
sprintf (PathPhotosPriv,"%s/%s", sprintf (PathPhotosPriv,"%s/%s",
@ -2369,8 +2369,7 @@ static void Pho_ShowDegreeAvgPhotoAndStat (struct Degree *Deg,
Pho_ComputePhotoSize (NumStds,NumStdsWithPhoto,&PhotoWidth,&PhotoHeight); Pho_ComputePhotoSize (NumStds,NumStdsWithPhoto,&PhotoWidth,&PhotoHeight);
/***** Make a copy of the degree short name *****/ /***** Make a copy of the degree short name *****/
strncpy (CopyOfDegShortName,Deg->ShrtName,Deg_MAX_LENGTH_DEGREE_SHRT_NAME); Str_Copy (CopyOfDegShortName,Deg->ShrtName,Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
CopyOfDegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0';
Str_LimitLengthHTMLStr (CopyOfDegShortName, Str_LimitLengthHTMLStr (CopyOfDegShortName,
SeeOrPrint == Pho_DEGREES_SEE ? 10 : SeeOrPrint == Pho_DEGREES_SEE ? 10 :
15); 15);

View File

@ -340,17 +340,15 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
/***** Check if place code is correct *****/ /***** Check if place code is correct *****/
if (Plc->PlcCod < 0) if (Plc->PlcCod < 0)
{ {
strncpy (Plc->ShrtName,Txt_Place_unspecified,Plc_MAX_LENGTH_PLACE_SHRT_NAME); Str_Copy (Plc->ShrtName,Txt_Place_unspecified,
Plc->ShrtName[Plc_MAX_LENGTH_PLACE_SHRT_NAME] = '\0'; Plc_MAX_LENGTH_PLACE_SHRT_NAME);
strncpy (Plc->FullName,Txt_Place_unspecified,Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Plc->FullName,Txt_Place_unspecified,
Plc->FullName[Plc_MAX_LENGTH_PLACE_FULL_NAME] = '\0'; Plc_MAX_LENGTH_PLACE_FULL_NAME);
} }
else if (Plc->PlcCod == 0) else if (Plc->PlcCod == 0)
{ {
strncpy (Plc->ShrtName,Txt_Another_place,Plc_MAX_LENGTH_PLACE_SHRT_NAME); Str_Copy (Plc->ShrtName,Txt_Another_place,Plc_MAX_LENGTH_PLACE_SHRT_NAME);
Plc->ShrtName[Plc_MAX_LENGTH_PLACE_SHRT_NAME] = '\0'; Str_Copy (Plc->FullName,Txt_Another_place,Plc_MAX_LENGTH_PLACE_FULL_NAME);
strncpy (Plc->FullName,Txt_Another_place,Plc_MAX_LENGTH_PLACE_FULL_NAME);
Plc->FullName[Plc_MAX_LENGTH_PLACE_FULL_NAME] = '\0';
} }
else if (Plc->PlcCod > 0) else if (Plc->PlcCod > 0)
{ {
@ -379,12 +377,10 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the short name of the place (row[0]) */ /* Get the short name of the place (row[0]) */
strncpy (Plc->ShrtName,row[0],Plc_MAX_LENGTH_PLACE_SHRT_NAME); Str_Copy (Plc->ShrtName,row[0],Plc_MAX_LENGTH_PLACE_SHRT_NAME);
Plc->ShrtName[Plc_MAX_LENGTH_PLACE_SHRT_NAME] = '\0';
/* Get the full name of the place (row[1]) */ /* Get the full name of the place (row[1]) */
strncpy (Plc->FullName,row[1],Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Plc->FullName,row[1],Plc_MAX_LENGTH_PLACE_FULL_NAME);
Plc->FullName[Plc_MAX_LENGTH_PLACE_FULL_NAME] = '\0';
/* Get number of centres in this place (row[2]) */ /* Get number of centres in this place (row[2]) */
if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1) if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1)

View File

@ -227,28 +227,22 @@ static void Plg_GetListPlugins (void)
Lay_ShowErrorAndExit ("Wrong code of plugin."); Lay_ShowErrorAndExit ("Wrong code of plugin.");
/* Get the name of the plugin (row[1]) */ /* Get the name of the plugin (row[1]) */
strncpy (Plg->Name,row[1],Plg_MAX_LENGTH_PLUGIN_NAME); Str_Copy (Plg->Name,row[1],Plg_MAX_LENGTH_PLUGIN_NAME);
Plg->Name[Plg_MAX_LENGTH_PLUGIN_NAME] = '\0';
/* Get the description of the plugin (row[2]) */ /* Get the description of the plugin (row[2]) */
strncpy (Plg->Description,row[2],Plg_MAX_LENGTH_PLUGIN_DESCRIPTION); Str_Copy (Plg->Description,row[2],Plg_MAX_LENGTH_PLUGIN_DESCRIPTION);
Plg->Description[Plg_MAX_LENGTH_PLUGIN_DESCRIPTION] = '\0';
/* Get the logo of the plugin (row[3]) */ /* Get the logo of the plugin (row[3]) */
strncpy (Plg->Logo,row[3],Plg_MAX_LENGTH_PLUGIN_LOGO); Str_Copy (Plg->Logo,row[3],Plg_MAX_LENGTH_PLUGIN_LOGO);
Plg->Logo[Plg_MAX_LENGTH_PLUGIN_LOGO] = '\0';
/* Get the application key of the plugin (row[4]) */ /* Get the application key of the plugin (row[4]) */
strncpy (Plg->AppKey,row[4],Plg_MAX_LENGTH_PLUGIN_APP_KEY); Str_Copy (Plg->AppKey,row[4],Plg_MAX_LENGTH_PLUGIN_APP_KEY);
Plg->AppKey[Plg_MAX_LENGTH_PLUGIN_APP_KEY] = '\0';
/* Get the URL of the plugin (row[5]) */ /* Get the URL of the plugin (row[5]) */
strncpy (Plg->URL,row[5],Cns_MAX_LENGTH_WWW); Str_Copy (Plg->URL,row[5],Cns_MAX_LENGTH_WWW);
Plg->URL[Cns_MAX_LENGTH_WWW] = '\0';
/* Get the IP of the plugin (row[6]) */ /* Get the IP of the plugin (row[6]) */
strncpy (Plg->IP,row[6],Cns_MAX_LENGTH_IP); Str_Copy (Plg->IP,row[6],Cns_MAX_LENGTH_IP);
Plg->IP[Cns_MAX_LENGTH_IP] = '\0';
} }
} }
else else
@ -294,28 +288,22 @@ bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the name of the plugin (row[0]) */ /* Get the name of the plugin (row[0]) */
strncpy (Plg->Name,row[0],Plg_MAX_LENGTH_PLUGIN_NAME); Str_Copy (Plg->Name,row[0],Plg_MAX_LENGTH_PLUGIN_NAME);
Plg->Name[Plg_MAX_LENGTH_PLUGIN_NAME] = '\0';
/* Get the description of the plugin (row[1]) */ /* Get the description of the plugin (row[1]) */
strncpy (Plg->Description,row[1],Plg_MAX_LENGTH_PLUGIN_DESCRIPTION); Str_Copy (Plg->Description,row[1],Plg_MAX_LENGTH_PLUGIN_DESCRIPTION);
Plg->Description[Plg_MAX_LENGTH_PLUGIN_DESCRIPTION] = '\0';
/* Get the logo of the plugin (row[2]) */ /* Get the logo of the plugin (row[2]) */
strncpy (Plg->Logo,row[2],Plg_MAX_LENGTH_PLUGIN_LOGO); Str_Copy (Plg->Logo,row[2],Plg_MAX_LENGTH_PLUGIN_LOGO);
Plg->Logo[Plg_MAX_LENGTH_PLUGIN_LOGO] = '\0';
/* Get the application key of the plugin (row[3]) */ /* Get the application key of the plugin (row[3]) */
strncpy (Plg->AppKey,row[3],Plg_MAX_LENGTH_PLUGIN_APP_KEY); Str_Copy (Plg->AppKey,row[3],Plg_MAX_LENGTH_PLUGIN_APP_KEY);
Plg->AppKey[Plg_MAX_LENGTH_PLUGIN_APP_KEY] = '\0';
/* Get the URL of the plugin (row[4]) */ /* Get the URL of the plugin (row[4]) */
strncpy (Plg->URL,row[4],Cns_MAX_LENGTH_WWW); Str_Copy (Plg->URL,row[4],Cns_MAX_LENGTH_WWW);
Plg->URL[Cns_MAX_LENGTH_WWW] = '\0';
/* Get the IP of the plugin (row[5]) */ /* Get the IP of the plugin (row[5]) */
strncpy (Plg->IP,row[5],Cns_MAX_LENGTH_IP); Str_Copy (Plg->IP,row[5],Cns_MAX_LENGTH_IP);
Plg->IP[Cns_MAX_LENGTH_IP] = '\0';
} }
else else
PluginFound = false; PluginFound = false;

View File

@ -232,7 +232,8 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
Lay_ShowErrorAndExit ("Wrong code of field."); Lay_ShowErrorAndExit ("Wrong code of field.");
/* Name of the field (row[1]) */ /* Name of the field (row[1]) */
strncpy (Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].Name,row[1],Rec_MAX_LENGTH_NAME_FIELD); Str_Copy (Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].Name,row[1],
Rec_MAX_LENGTH_NAME_FIELD);
/* Number of lines (row[2]) */ /* Number of lines (row[2]) */
Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].NumLines = Rec_ConvertToNumLinesField (row[2]); Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].NumLines = Rec_ConvertToNumLinesField (row[2]);
@ -2572,20 +2573,17 @@ static void Rec_ShowFullName (struct UsrData *UsrDat)
fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID REC_NAME LEFT_TOP\">"); fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID REC_NAME LEFT_TOP\">");
/***** First name *****/ /***** First name *****/
strncpy (Name,UsrDat->FirstName,Usr_MAX_BYTES_NAME); Str_Copy (Name,UsrDat->FirstName,Usr_MAX_BYTES_NAME);
Name[Usr_MAX_BYTES_NAME] = '\0';
Str_LimitLengthHTMLStr (Name,20); Str_LimitLengthHTMLStr (Name,20);
fprintf (Gbl.F.Out,"%s<br />",Name); fprintf (Gbl.F.Out,"%s<br />",Name);
/***** Surname 1 *****/ /***** Surname 1 *****/
strncpy (Name,UsrDat->Surname1,Usr_MAX_BYTES_NAME); Str_Copy (Name,UsrDat->Surname1,Usr_MAX_BYTES_NAME);
Name[Usr_MAX_BYTES_NAME] = '\0';
Str_LimitLengthHTMLStr (Name,20); Str_LimitLengthHTMLStr (Name,20);
fprintf (Gbl.F.Out,"%s<br />",Name); fprintf (Gbl.F.Out,"%s<br />",Name);
/***** Surname 2 *****/ /***** Surname 2 *****/
strncpy (Name,UsrDat->Surname2,Usr_MAX_BYTES_NAME); Str_Copy (Name,UsrDat->Surname2,Usr_MAX_BYTES_NAME);
Name[Usr_MAX_BYTES_NAME] = '\0';
Str_LimitLengthHTMLStr (Name,20); Str_LimitLengthHTMLStr (Name,20);
fprintf (Gbl.F.Out,"%s",Name); fprintf (Gbl.F.Out,"%s",Name);

View File

@ -314,8 +314,7 @@ bool Ses_GetSessionData (void)
Gbl.Search.WhatToSearch = (Sch_WhatToSearch_t) UnsignedNum; Gbl.Search.WhatToSearch = (Sch_WhatToSearch_t) UnsignedNum;
/* Get search string (row[9]) */ /* Get search string (row[9]) */
strncpy (Gbl.Search.Str,row[9],Sch_MAX_LENGTH_STRING_TO_FIND); Str_Copy (Gbl.Search.Str,row[9],Sch_MAX_LENGTH_STRING_TO_FIND);
Gbl.Search.Str[Sch_MAX_LENGTH_STRING_TO_FIND] = '\0';
} }
Result = true; Result = true;
@ -428,8 +427,7 @@ unsigned Ses_GetHiddenParFromDB (Act_Action_t Action,const char *ParamName,char
{ {
/***** Get the value del parameter *****/ /***** Get the value del parameter *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (ParamValue,row[0],MaxBytes); Str_Copy (ParamValue,row[0],MaxBytes);
ParamValue[MaxBytes] = '\0';
ParameterIsTooBig = (strlen (row[0]) > MaxBytes); ParameterIsTooBig = (strlen (row[0]) > MaxBytes);
} }

View File

@ -1483,8 +1483,7 @@ static void Soc_GetAndWriteSocialPost (long PstCod)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/ /****** Get content (row[0]) *****/
strncpy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
/****** Get image name (row[1]), title (row[2]) and URL (row[3]) *****/ /****** Get image name (row[1]), title (row[2]) and URL (row[3]) *****/
Img_GetImageNameTitleAndURLFromRow (row[1],row[2],row[3],&Image); Img_GetImageNameTitleAndURLFromRow (row[1],row[2],row[3],&Image);
@ -4550,8 +4549,7 @@ static void Soc_GetDataOfSocialCommentFromRow (MYSQL_ROW row,struct SocialCommen
SocCom->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]); SocCom->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
/***** Get content (row[4]) *****/ /***** Get content (row[4]) *****/
strncpy (SocCom->Content,row[4],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (SocCom->Content,row[4],Cns_MAX_BYTES_LONG_TEXT);
SocCom->Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
/***** Get number of times this comment has been favourited *****/ /***** Get number of times this comment has been favourited *****/
SocCom->NumFavs = Soc_GetNumTimesACommHasBeenFav (SocCom); SocCom->NumFavs = Soc_GetNumTimesACommHasBeenFav (SocCom);
@ -4689,8 +4687,7 @@ void Soc_GetNotifSocialPublishing (char *SummaryStr,char **ContentStr,long PubCo
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/ /****** Get content (row[0]) *****/
strncpy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -4723,8 +4720,7 @@ void Soc_GetNotifSocialPublishing (char *SummaryStr,char **ContentStr,long PubCo
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/ /****** Get content (row[0]) *****/
strncpy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT);
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -4808,8 +4804,7 @@ static void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const
if (IsNickname) if (IsNickname)
{ {
/* Copy nickname */ /* Copy nickname */
strncpy (UsrDat.Nickname,Nickname.PtrStart,Nickname.Length); Str_Copy (UsrDat.Nickname,Nickname.PtrStart,Nickname.Length);
UsrDat.Nickname[Nickname.Length] = '\0';
if ((UsrDat.UsrCod = Nck_GetUsrCodFromNickname (UsrDat.Nickname)) > 0) if ((UsrDat.UsrCod = Nck_GetUsrCodFromNickname (UsrDat.Nickname)) > 0)
if (UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // It's not me if (UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // It's not me

View File

@ -255,10 +255,7 @@ The IP address of the remote host making the request.
void Sta_GetRemoteAddr (void) void Sta_GetRemoteAddr (void)
{ {
if (getenv ("REMOTE_ADDR")) if (getenv ("REMOTE_ADDR"))
{ Str_Copy (Gbl.IP,getenv ("REMOTE_ADDR"),Cns_MAX_LENGTH_IP);
strncpy (Gbl.IP,getenv ("REMOTE_ADDR"),Cns_MAX_LENGTH_IP);
Gbl.IP[Cns_MAX_LENGTH_IP] = '\0';
}
else else
Gbl.IP[0] = '\0'; Gbl.IP[0] = '\0';
} }

View File

@ -244,8 +244,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
/* Make a copy of this URL */ /* Make a copy of this URL */
NumBytesToCopy = (Links[NumLinks].NumActualBytes < MAX_BYTES_LIMITED_URL) ? Links[NumLinks].NumActualBytes : NumBytesToCopy = (Links[NumLinks].NumActualBytes < MAX_BYTES_LIMITED_URL) ? Links[NumLinks].NumActualBytes :
MAX_BYTES_LIMITED_URL; MAX_BYTES_LIMITED_URL;
strncpy (LimitedURL,Links[NumLinks].PtrStart,NumBytesToCopy); Str_Copy (LimitedURL,Links[NumLinks].PtrStart,NumBytesToCopy);
LimitedURL[NumBytesToCopy] = '\0';
/* Limit the number of characters on screen of the copy, and calculate its length in bytes */ /* Limit the number of characters on screen of the copy, and calculate its length in bytes */
LengthVisibleLink = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen); LengthVisibleLink = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen);
@ -408,8 +407,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
/* Make a copy of this URL */ /* Make a copy of this URL */
NumBytesToCopy = (Links[NumLink].NumActualBytes < MAX_BYTES_LIMITED_URL) ? Links[NumLink].NumActualBytes : NumBytesToCopy = (Links[NumLink].NumActualBytes < MAX_BYTES_LIMITED_URL) ? Links[NumLink].NumActualBytes :
MAX_BYTES_LIMITED_URL; MAX_BYTES_LIMITED_URL;
strncpy (LimitedURL,Links[NumLink].PtrStart,NumBytesToCopy); Str_Copy (LimitedURL,Links[NumLink].PtrStart,NumBytesToCopy);
LimitedURL[NumBytesToCopy] = '\0';
/* Limit the length of the copy */ /* Limit the length of the copy */
NumBytesToShow = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen); NumBytesToShow = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen);
@ -1316,7 +1314,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
Lay_ShowErrorAndExit ("Space allocated to string is full."); Lay_ShowErrorAndExit ("Space allocated to string is full.");
/* Copy to appropiate place the special character string */ /* Copy to appropiate place the special character string */
strncpy (PtrDst,StrSpecialChar,LengthSpecStrDst); Str_Copy (PtrDst,StrSpecialChar,LengthSpecStrDst);
/* Increment pointer to character after ';' */ /* Increment pointer to character after ';' */
PtrSrc += LengthSpecStrSrc; PtrSrc += LengthSpecStrSrc;
@ -1340,8 +1338,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
} }
/***** Copy destination string with changes to source string *****/ /***** Copy destination string with changes to source string *****/
strncpy (Str,StrDst,LengthStrDst); // Str <-- StrDst Str_Copy (Str,StrDst,LengthStrDst); // Str <-- StrDst
Str[LengthStrDst] = '\0';
/***** Free memory used for the destination string *****/ /***** Free memory used for the destination string *****/
free ((void *) StrDst); free ((void *) StrDst);
@ -2356,24 +2353,14 @@ void Str_SplitFullPathIntoPathAndFileName (const char *FullPath,
/***** Get PathWithoutFileName *****/ /***** Get PathWithoutFileName *****/
LengthUntilFileName = (size_t) (PtrFileName - FullPath); // Last slash included LengthUntilFileName = (size_t) (PtrFileName - FullPath); // Last slash included
if (LengthUntilFileName > 1) if (LengthUntilFileName > 1)
{ Str_Copy (PathWithoutFileName,FullPath,
if (LengthUntilFileName > PATH_MAX) LengthUntilFileName > PATH_MAX ? PATH_MAX :
{ LengthUntilFileName - 1); // Do not copy ending slash
strncpy (PathWithoutFileName,FullPath,PATH_MAX);
PathWithoutFileName[PATH_MAX] = '\0';
}
else
{
strncpy (PathWithoutFileName,FullPath,LengthUntilFileName - 1); // Do not copy ending slash
PathWithoutFileName[LengthUntilFileName - 1] = '\0';
}
}
else else
PathWithoutFileName[0] = '\0'; PathWithoutFileName[0] = '\0';
/***** Get FileName *****/ /***** Get FileName *****/
strncpy (FileName,PtrFileName,NAME_MAX); Str_Copy (FileName,PtrFileName,NAME_MAX);
FileName[NAME_MAX] = '\0';
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2712,13 +2699,10 @@ bool Str_ConvertFilFolLnkNameToValid (char *FileName)
FileName); FileName);
} }
else // FileName is empty else // FileName is empty
{ Str_Copy (Gbl.Message,
strncpy (Gbl.Message, Gbl.FileBrowser.UploadingWithDropzone ? Txt_UPLOAD_FILE_Invalid_name_NO_HTML :
Gbl.FileBrowser.UploadingWithDropzone ? Txt_UPLOAD_FILE_Invalid_name_NO_HTML : Txt_UPLOAD_FILE_Invalid_name,
Txt_UPLOAD_FILE_Invalid_name, Lay_MAX_BYTES_ALERT);
Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
}
return FileNameIsOK; return FileNameIsOK;
} }
@ -2806,18 +2790,25 @@ void Str_GetMailBox (const char *Email,char *MailBox,size_t MaxLength)
{ {
Ptr++; // Skip '@' Ptr++; // Skip '@'
if (strchr (Ptr,(int) '@') == NULL) // No more '@' found if (strchr (Ptr,(int) '@') == NULL) // No more '@' found
{ Str_Copy (MailBox,Ptr,MaxLength);
strncpy (MailBox,Ptr,MaxLength);
MailBox[MaxLength] = '\0';
}
} }
} }
/*****************************************************************************/
/****************************** Safe string copy *****************************/
/*****************************************************************************/
void Str_Copy (char *Dst,const char *Src,size_t MaxLength)
{
strncpy (Dst,Src,MaxLength);
Dst[MaxLength] = '\0';
}
/*****************************************************************************/ /*****************************************************************************/
/************************** Safe string concatenation ************************/ /************************** Safe string concatenation ************************/
/*****************************************************************************/ /*****************************************************************************/
void Str_Concat (char *Src,const char *Dst,size_t MaxLength) void Str_Concat (char *Dst,const char *Src,size_t MaxLength)
{ {
strncat (Src,Dst,MaxLength - strlen (Src)); strncat (Dst,Src,MaxLength - strlen (Dst));
} }

View File

@ -119,6 +119,7 @@ void Str_ConvertToValidFileName (char *Str);
void Str_CreateRandomAlphanumStr (char *Str,size_t Length); void Str_CreateRandomAlphanumStr (char *Str,size_t Length);
void Str_GetMailBox (const char *Email,char *MailBox,size_t MaxLength); void Str_GetMailBox (const char *Email,char *MailBox,size_t MaxLength);
void Str_Concat (char *Src,const char *Dst,size_t MaxLength); void Str_Copy (char *Dst,const char *Src,size_t MaxLength);
void Str_Concat (char *Dst,const char *Src,size_t MaxLength);
#endif #endif

View File

@ -2644,8 +2644,7 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,ch
SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]); SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
/* Get the stem of the question from the database (row[2]) */ /* Get the stem of the question from the database (row[2]) */
strncpy (Txt,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (Txt,row[2],Cns_MAX_BYTES_TEXT);
Txt[Cns_MAX_BYTES_TEXT] = '\0';
/* Free structure that stores the query result */ /* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -2663,8 +2662,7 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,ch
if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns)) if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns))
Lay_ShowErrorAndExit (Gbl.Message); Lay_ShowErrorAndExit (Gbl.Message);
strncpy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER); Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER);
SvyQst->AnsChoice[NumAns].Text[Svy_MAX_BYTES_ANSWER] = '\0';
} }
/* Free structure that stores the query result */ /* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);

View File

@ -53,6 +53,7 @@
/***************************** Public constants ******************************/ /***************************** Public constants ******************************/
/*****************************************************************************/ /*****************************************************************************/
// strings are limited to Tst_MAX_LENGTH_FEEDBACK_TYPE characters
const char *Tst_FeedbackXML[Tst_NUM_TYPES_FEEDBACK] = const char *Tst_FeedbackXML[Tst_NUM_TYPES_FEEDBACK] =
{ {
"nothing", "nothing",
@ -61,6 +62,8 @@ const char *Tst_FeedbackXML[Tst_NUM_TYPES_FEEDBACK] =
"eachGoodBad", "eachGoodBad",
"fullFeedback", "fullFeedback",
}; };
// strings are limited to Tst_MAX_LENGTH_ANSWER_TYPE characters
const char *Tst_StrAnswerTypesXML[Tst_NUM_ANS_TYPES] = const char *Tst_StrAnswerTypesXML[Tst_NUM_ANS_TYPES] =
{ {
"int", "int",
@ -1022,8 +1025,7 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem)
StemLength = strlen (Stem) * Str_MAX_LENGTH_SPEC_CHAR_HTML; StemLength = strlen (Stem) * Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((StemRigorousHTML = malloc (StemLength+1)) == NULL) if ((StemRigorousHTML = malloc (StemLength+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store stem of question."); Lay_ShowErrorAndExit ("Not enough memory to store stem of question.");
strncpy (StemRigorousHTML,Stem,StemLength); Str_Copy (StemRigorousHTML,Stem,StemLength);
StemRigorousHTML[StemLength] = '\0';
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
StemRigorousHTML,StemLength,false); StemRigorousHTML,StemLength,false);
@ -1152,8 +1154,7 @@ void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback)
FeedbackLength = strlen (Feedback) * Str_MAX_LENGTH_SPEC_CHAR_HTML; FeedbackLength = strlen (Feedback) * Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((FeedbackRigorousHTML = malloc (FeedbackLength+1)) == NULL) if ((FeedbackRigorousHTML = malloc (FeedbackLength+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store stem of question."); Lay_ShowErrorAndExit ("Not enough memory to store stem of question.");
strncpy (FeedbackRigorousHTML,Feedback,FeedbackLength); Str_Copy (FeedbackRigorousHTML,Feedback,FeedbackLength);
FeedbackRigorousHTML[FeedbackLength] = '\0';
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
FeedbackRigorousHTML,FeedbackLength,false); FeedbackRigorousHTML,FeedbackLength,false);
@ -3050,8 +3051,7 @@ static void Tst_WriteAnswersOfAQstEdit (long QstCod)
LengthAnswer = strlen (row[1]) * Str_MAX_LENGTH_SPEC_CHAR_HTML; LengthAnswer = strlen (row[1]) * Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((Answer = malloc (LengthAnswer+1)) == NULL) if ((Answer = malloc (LengthAnswer+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store answer."); Lay_ShowErrorAndExit ("Not enough memory to store answer.");
strncpy (Answer,row[1],LengthAnswer); Str_Copy (Answer,row[1],LengthAnswer);
Answer[LengthAnswer] = '\0';
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Answer,LengthAnswer,false); Answer,LengthAnswer,false);
@ -3064,8 +3064,7 @@ static void Tst_WriteAnswersOfAQstEdit (long QstCod)
LengthFeedback = strlen (row[2]) * Str_MAX_LENGTH_SPEC_CHAR_HTML; LengthFeedback = strlen (row[2]) * Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((Feedback = malloc (LengthFeedback+1)) == NULL) if ((Feedback = malloc (LengthFeedback+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store feedback."); Lay_ShowErrorAndExit ("Not enough memory to store feedback.");
strncpy (Feedback,row[2],LengthFeedback); Str_Copy (Feedback,row[2],LengthFeedback);
Feedback[LengthFeedback] = '\0';
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Feedback,LengthFeedback,false); Feedback,LengthFeedback,false);
} }
@ -3383,10 +3382,11 @@ static void Tst_WriteChoiceAnsViewTest (unsigned NumQst,long QstCod,bool Shuffle
Lay_ShowErrorAndExit ("Wrong index of answer when showing a test."); Lay_ShowErrorAndExit ("Wrong index of answer when showing a test.");
/***** Copy text (row[1]) and convert it, that is in HTML, to rigorous HTML ******/ /***** Copy text (row[1]) and convert it, that is in HTML, to rigorous HTML ******/
strncpy (Gbl.Test.Answer.Options[NumOpt].Text,row[1],Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Str_Copy (Gbl.Test.Answer.Options[NumOpt].Text,row[1],
Gbl.Test.Answer.Options[NumOpt].Text[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0'; Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.Test.Answer.Options[NumOpt].Text,Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false); Gbl.Test.Answer.Options[NumOpt].Text,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false);
/***** Copy image *****/ /***** Copy image *****/
Img_GetImageNameTitleAndURLFromRow (row[3],row[4],row[5],&Gbl.Test.Answer.Options[NumOpt].Image); Img_GetImageNameTitleAndURLFromRow (row[3],row[4],row[5],&Gbl.Test.Answer.Options[NumOpt].Image);
@ -3481,10 +3481,11 @@ static void Tst_WriteChoiceAnsAssessTest (unsigned NumQst,MYSQL_RES *mysql_res,
/***** Copy answer text (row[1]) and convert it, /***** Copy answer text (row[1]) and convert it,
that is in HTML, to rigorous HTML ******/ that is in HTML, to rigorous HTML ******/
strncpy (Gbl.Test.Answer.Options[NumOpt].Text,row[1],Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Str_Copy (Gbl.Test.Answer.Options[NumOpt].Text,row[1],
Gbl.Test.Answer.Options[NumOpt].Text[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0'; Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.Test.Answer.Options[NumOpt].Text,Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false); Gbl.Test.Answer.Options[NumOpt].Text,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false);
/***** Copy answer feedback (row[2]) and convert it, /***** Copy answer feedback (row[2]) and convert it,
that is in HTML, to rigorous HTML ******/ that is in HTML, to rigorous HTML ******/
@ -3492,10 +3493,11 @@ static void Tst_WriteChoiceAnsAssessTest (unsigned NumQst,MYSQL_RES *mysql_res,
if (row[2]) if (row[2])
if (row[2][0]) if (row[2][0])
{ {
strncpy (Gbl.Test.Answer.Options[NumOpt].Feedback,row[2],Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Str_Copy (Gbl.Test.Answer.Options[NumOpt].Feedback,row[2],
Gbl.Test.Answer.Options[NumOpt].Feedback[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0'; Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.Test.Answer.Options[NumOpt].Feedback,Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false); Gbl.Test.Answer.Options[NumOpt].Feedback,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false);
} }
/***** Copy image *****/ /***** Copy image *****/
@ -3719,19 +3721,22 @@ static void Tst_WriteTextAnsAssessTest (unsigned NumQst,MYSQL_RES *mysql_res,
Lay_ShowErrorAndExit (Gbl.Message); Lay_ShowErrorAndExit (Gbl.Message);
/***** Copy answer text (row[1]) and convert it, that is in HTML, to rigorous HTML ******/ /***** Copy answer text (row[1]) and convert it, that is in HTML, to rigorous HTML ******/
strncpy (Gbl.Test.Answer.Options[NumOpt].Text,row[1],Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Str_Copy (Gbl.Test.Answer.Options[NumOpt].Text,row[1],
Gbl.Test.Answer.Options[NumOpt].Text[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0'; Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,Gbl.Test.Answer.Options[NumOpt].Text,Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.Test.Answer.Options[NumOpt].Text,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false);
/***** Copy answer feedback (row[2]) and convert it, that is in HTML, to rigorous HTML ******/ /***** Copy answer feedback (row[2]) and convert it, that is in HTML, to rigorous HTML ******/
if (Gbl.Test.Config.FeedbackType == Tst_FEEDBACK_FULL_FEEDBACK) if (Gbl.Test.Config.FeedbackType == Tst_FEEDBACK_FULL_FEEDBACK)
if (row[2]) if (row[2])
if (row[2][0]) if (row[2][0])
{ {
strncpy (Gbl.Test.Answer.Options[NumOpt].Feedback,row[2],Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Str_Copy (Gbl.Test.Answer.Options[NumOpt].Feedback,row[2],
Gbl.Test.Answer.Options[NumOpt].Feedback[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0'; Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Gbl.Test.Answer.Options[NumOpt].Feedback,Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false); Gbl.Test.Answer.Options[NumOpt].Feedback,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false);
} }
/***** Assign correctness (row[6]) of this answer (this option) *****/ /***** Assign correctness (row[6]) of this answer (this option) *****/
@ -5061,17 +5066,13 @@ static void Tst_GetQstDataFromDB (char *Stem,char *Feedback)
Gbl.Test.Shuffle = (row[1][0] == 'Y'); Gbl.Test.Shuffle = (row[1][0] == 'Y');
/* Get the stem of the question from the database (row[2]) */ /* Get the stem of the question from the database (row[2]) */
strncpy (Stem,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (Stem,row[2],Cns_MAX_BYTES_TEXT);
Stem[Cns_MAX_BYTES_TEXT] = '\0';
/* Get the feedback of the question from the database (row[3]) */ /* Get the feedback of the question from the database (row[3]) */
Feedback[0] = '\0'; Feedback[0] = '\0';
if (row[3]) if (row[3])
if (row[3][0]) if (row[3][0])
{ Str_Copy (Feedback,row[3],Cns_MAX_BYTES_TEXT);
strncpy (Feedback,row[3],Cns_MAX_BYTES_TEXT);
Feedback[Cns_MAX_BYTES_TEXT] = '\0';
}
/* Get the image name, title and URL of the question /* Get the image name, title and URL of the question
from the database (row[4], row[5], row[6]) */ from the database (row[4], row[5], row[6]) */
@ -5087,8 +5088,7 @@ static void Tst_GetQstDataFromDB (char *Stem,char *Feedback)
NumRow++) NumRow++)
{ {
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (Gbl.Test.Tags.Txt[NumRow],row[0],Tst_MAX_BYTES_TAG); Str_Copy (Gbl.Test.Tags.Txt[NumRow],row[0],Tst_MAX_BYTES_TAG);
Gbl.Test.Tags.Txt[NumRow][Tst_MAX_BYTES_TAG] = '\0';
} }
/* Free structure that stores the query result */ /* Free structure that stores the query result */
@ -5135,16 +5135,14 @@ static void Tst_GetQstDataFromDB (char *Stem,char *Feedback)
if (!Tst_AllocateTextChoiceAnswer (NumOpt)) if (!Tst_AllocateTextChoiceAnswer (NumOpt))
Lay_ShowErrorAndExit (Gbl.Message); Lay_ShowErrorAndExit (Gbl.Message);
strncpy (Gbl.Test.Answer.Options[NumOpt].Text,row[1],Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Str_Copy (Gbl.Test.Answer.Options[NumOpt].Text,row[1],
Gbl.Test.Answer.Options[NumOpt].Text[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0'; Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
// Feedback (row[2]) is initialized to empty string // Feedback (row[2]) is initialized to empty string
if (row[2]) if (row[2])
if (row[2][0]) if (row[2][0])
{ Str_Copy (Gbl.Test.Answer.Options[NumOpt].Feedback,row[2],
strncpy (Gbl.Test.Answer.Options[NumOpt].Feedback,row[2],Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Gbl.Test.Answer.Options[NumOpt].Feedback[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0';
}
/* Copy image */ /* Copy image */
Img_GetImageNameTitleAndURLFromRow (row[3],row[4],row[5],&Gbl.Test.Answer.Options[NumOpt].Image); Img_GetImageNameTitleAndURLFromRow (row[3],row[4],row[5],&Gbl.Test.Answer.Options[NumOpt].Image);
@ -7931,12 +7929,12 @@ static void Tst_GetTestResultQuestionsFromDB (long TstCod)
Lay_ShowErrorAndExit ("Wrong code of question."); Lay_ShowErrorAndExit ("Wrong code of question.");
/* Get indexes for this question (row[1]) */ /* Get indexes for this question (row[1]) */
strncpy (Gbl.Test.StrIndexesOneQst[NumQst],row[1],Tst_MAX_SIZE_INDEXES_ONE_QST); Str_Copy (Gbl.Test.StrIndexesOneQst[NumQst],row[1],
Gbl.Test.StrIndexesOneQst[NumQst][Tst_MAX_SIZE_INDEXES_ONE_QST] = '\0'; Tst_MAX_SIZE_INDEXES_ONE_QST);
/* Get answers selected by user for this question (row[2]) */ /* Get answers selected by user for this question (row[2]) */
strncpy (Gbl.Test.StrAnswersOneQst[NumQst],row[2],Tst_MAX_SIZE_ANSWERS_ONE_QST); Str_Copy (Gbl.Test.StrAnswersOneQst[NumQst],row[2],
Gbl.Test.StrAnswersOneQst[NumQst][Tst_MAX_SIZE_ANSWERS_ONE_QST] = '\0'; Tst_MAX_SIZE_ANSWERS_ONE_QST);
/* Replace each comma by a separator of multiple parameters */ /* Replace each comma by a separator of multiple parameters */
/* In database commas are used as separators instead of special chars */ /* In database commas are used as separators instead of special chars */

View File

@ -48,6 +48,10 @@
#define Tst_CONFIG_DEFAULT_DEF_QUESTIONS 20 // Number of questions to be generated by default in a self-assessment test #define Tst_CONFIG_DEFAULT_DEF_QUESTIONS 20 // Number of questions to be generated by default in a self-assessment test
#define Tst_CONFIG_DEFAULT_MAX_QUESTIONS 30 // Maximum number of questions to be generated in a self-assessment test #define Tst_CONFIG_DEFAULT_MAX_QUESTIONS 30 // Maximum number of questions to be generated in a self-assessment test
#define Tst_MAX_LENGTH_FEEDBACK_TYPE 32
#define Tst_MAX_LENGTH_ANSWER_TYPE 32
/*****************************************************************************/ /*****************************************************************************/
/******************************* Public types ********************************/ /******************************* Public types ********************************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -397,11 +397,11 @@ static void TsI_WriteAnswersOfAQstXML (long QstCod)
void TsI_ImportQstsFromXML (void) void TsI_ImportQstsFromXML (void)
{ {
extern const char *Txt_The_file_is_not_X; extern const char *Txt_The_file_is_not_X;
char PathTestPriv[PATH_MAX+1]; char PathTestPriv[PATH_MAX + 1];
struct Param *Param; struct Param *Param;
char FileNameXMLSrc[PATH_MAX+1]; char FileNameXMLSrc[PATH_MAX + 1];
char FileNameXMLTmp[PATH_MAX+1]; // Full name (including path and .xml) of the destination temporary file char FileNameXMLTmp[PATH_MAX + 1]; // Full name (including path and .xml) of the destination temporary file
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
bool WrongType = false; bool WrongType = false;
/***** Creates directory if not exists *****/ /***** Creates directory if not exists *****/
@ -570,8 +570,8 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
{ {
if (TagElem->Content) if (TagElem->Content)
{ {
strncpy (Gbl.Test.Tags.Txt[Gbl.Test.Tags.Num],TagElem->Content,Tst_MAX_BYTES_TAG); Str_Copy (Gbl.Test.Tags.Txt[Gbl.Test.Tags.Num],
Gbl.Test.Tags.Txt[Gbl.Test.Tags.Num][Tst_MAX_BYTES_TAG] = '\0'; TagElem->Content,Tst_MAX_BYTES_TAG);
Gbl.Test.Tags.Num++; Gbl.Test.Tags.Num++;
} }
} }
@ -587,8 +587,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
if (StemElem->Content) if (StemElem->Content)
{ {
/* Convert stem from text to HTML (in database stem is stored in HTML) */ /* Convert stem from text to HTML (in database stem is stored in HTML) */
strncpy (Stem,StemElem->Content,Cns_MAX_BYTES_TEXT); Str_Copy (Stem,StemElem->Content,Cns_MAX_BYTES_TEXT);
Stem[Cns_MAX_BYTES_TEXT] = '\0';
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML, Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
Stem,Cns_MAX_BYTES_TEXT,true); Stem,Cns_MAX_BYTES_TEXT,true);
@ -607,8 +606,8 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
if (FeedbackElem->Content) if (FeedbackElem->Content)
{ {
/* Convert feedback from text to HTML (in database feedback is stored in HTML) */ /* Convert feedback from text to HTML (in database feedback is stored in HTML) */
strncpy (Feedback,FeedbackElem->Content,Cns_MAX_BYTES_TEXT); Str_Copy (Feedback,FeedbackElem->Content,
Feedback[Cns_MAX_BYTES_TEXT] = '\0'; Cns_MAX_BYTES_TEXT);
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML, Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
Feedback,Cns_MAX_BYTES_TEXT,true); Feedback,Cns_MAX_BYTES_TEXT,true);
@ -829,11 +828,8 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem)
Lay_ShowErrorAndExit (Gbl.Message); Lay_ShowErrorAndExit (Gbl.Message);
if (AnswerElem->Content) if (AnswerElem->Content)
{ Str_Copy (Gbl.Test.Answer.Options[0].Text,AnswerElem->Content,
strncpy (Gbl.Test.Answer.Options[0].Text,AnswerElem->Content, Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Gbl.Test.Answer.Options[0].Text[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0';
}
break; break;
case Tst_ANS_FLOAT: case Tst_ANS_FLOAT:
if (!Tst_AllocateTextChoiceAnswer (0)) if (!Tst_AllocateTextChoiceAnswer (0))
@ -847,11 +843,8 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem)
if (!strcmp (LowerUpperElem->TagName,"lower")) if (!strcmp (LowerUpperElem->TagName,"lower"))
{ {
if (LowerUpperElem->Content) if (LowerUpperElem->Content)
{ Str_Copy (Gbl.Test.Answer.Options[0].Text,LowerUpperElem->Content,
strncpy (Gbl.Test.Answer.Options[0].Text,LowerUpperElem->Content, Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Gbl.Test.Answer.Options[0].Text[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0';
}
break; // Only first element "lower" break; // Only first element "lower"
} }
for (LowerUpperElem = AnswerElem->FirstChild; for (LowerUpperElem = AnswerElem->FirstChild;
@ -860,11 +853,8 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem)
if (!strcmp (LowerUpperElem->TagName,"upper")) if (!strcmp (LowerUpperElem->TagName,"upper"))
{ {
if (LowerUpperElem->Content) if (LowerUpperElem->Content)
{ Str_Copy (Gbl.Test.Answer.Options[1].Text,LowerUpperElem->Content,
strncpy (Gbl.Test.Answer.Options[1].Text,LowerUpperElem->Content, Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
Gbl.Test.Answer.Options[1].Text[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0';
}
break; // Only first element "upper" break; // Only first element "upper"
} }
break; break;
@ -904,9 +894,9 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem)
{ {
if (TextElem->Content) if (TextElem->Content)
{ {
strncpy (Gbl.Test.Answer.Options[NumOpt].Text,TextElem->Content, Str_Copy (Gbl.Test.Answer.Options[NumOpt].Text,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); TextElem->Content,
Gbl.Test.Answer.Options[NumOpt].Text[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0'; Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
/* Convert answer from text to HTML (in database answer text is stored in HTML) */ /* Convert answer from text to HTML (in database answer text is stored in HTML) */
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML, Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
@ -922,9 +912,9 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem)
{ {
if (FeedbackElem->Content) if (FeedbackElem->Content)
{ {
strncpy (Gbl.Test.Answer.Options[NumOpt].Feedback,FeedbackElem->Content, Str_Copy (Gbl.Test.Answer.Options[NumOpt].Feedback,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); FeedbackElem->Content,
Gbl.Test.Answer.Options[NumOpt].Feedback[Tst_MAX_BYTES_ANSWER_OR_FEEDBACK] = '\0'; Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
/* Convert feedback from text to HTML (in database answer feedback is stored in HTML) */ /* Convert feedback from text to HTML (in database answer feedback is stored in HTML) */
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML, Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
@ -1132,8 +1122,8 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
Str_MAX_LENGTH_SPEC_CHAR_HTML; Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((AnswerText = malloc (AnswerTextLength+1)) == NULL) if ((AnswerText = malloc (AnswerTextLength+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store answer."); Lay_ShowErrorAndExit ("Not enough memory to store answer.");
strncpy (AnswerText,Gbl.Test.Answer.Options[NumOpt].Text,AnswerTextLength); Str_Copy (AnswerText,Gbl.Test.Answer.Options[NumOpt].Text,
AnswerText[AnswerTextLength] = '\0'; AnswerTextLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
AnswerText,AnswerTextLength,false); AnswerText,AnswerTextLength,false);
@ -1147,8 +1137,9 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
Str_MAX_LENGTH_SPEC_CHAR_HTML; Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((AnswerFeedback = malloc (AnswerFeedbackLength+1)) == NULL) if ((AnswerFeedback = malloc (AnswerFeedbackLength+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store feedback."); Lay_ShowErrorAndExit ("Not enough memory to store feedback.");
strncpy (AnswerFeedback,Gbl.Test.Answer.Options[NumOpt].Feedback,AnswerFeedbackLength); Str_Copy (AnswerFeedback,
AnswerFeedback[AnswerFeedbackLength] = '\0'; Gbl.Test.Answer.Options[NumOpt].Feedback,
AnswerFeedbackLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
AnswerFeedback,AnswerFeedbackLength,false); AnswerFeedback,AnswerFeedbackLength,false);
} }

View File

@ -16769,39 +16769,39 @@ const char *Txt_LICENSES[Brw_NUM_LICENSES] =
#endif #endif
, ,
#if L==1 #if L==1
"Tots els drets reservats" // All Rights Reserved "Tots els drets reservats" // All Rights Reserved
#elif L==2 #elif L==2
"Alle Rechte vorbehalten" // All Rights Reserved "Alle Rechte vorbehalten" // All Rights Reserved
#elif L==3 #elif L==3
"All rights reserved" // All Rights Reserved "All rights reserved" // All Rights Reserved
#elif L==4 #elif L==4
"Todos los derechos reservados" // All Rights Reserved "Todos los derechos reservados" // All Rights Reserved
#elif L==5 #elif L==5
"Tous droits r&eacute;serv&eacute;s" // All Rights Reserved "Tous droits r&eacute;serv&eacute;s" // All Rights Reserved
#elif L==6 #elif L==6
"Todos los derechos reservados" // All Rights Reserved // Okoteve traducción "Todos los derechos reservados" // All Rights Reserved // Okoteve traducción
#elif L==7 #elif L==7
"Tutti i diritti riservati" // All Rights Reserved "Tutti i diritti riservati" // All Rights Reserved
#elif L==8 #elif L==8
"Wszelkie prawa zastrze&zdot;one" // All Rights Reserved "Wszelkie prawa zastrze&zdot;one" // All Rights Reserved
#elif L==9 #elif L==9
"Todos os direitos reservados" // All Rights Reserved "Todos os direitos reservados" // All Rights Reserved
#endif #endif
, ,
#if L==1 #if L==1
"CC Reconeixement" // CC Attribution License "CC Reconeixement" // CC Attribution License
#elif L==2 #elif L==2
"CC Namensnennung" // CC Attribution License "CC Namensnennung" // CC Attribution License
#elif L==3 #elif L==3
"CC Attribution" // CC Attribution License "CC Attribution" // CC Attribution License
#elif L==4 #elif L==4
"CC Reconocimiento" // CC Attribution License "CC Reconocimiento" // CC Attribution License
#elif L==5 #elif L==5
"CC Attribution" // CC Attribution License "CC Attribution" // CC Attribution License
#elif L==6 #elif L==6
"CC Reconocimiento" // CC Attribution License // Okoteve traducción "CC Reconocimiento" // CC Attribution License // Okoteve traducción
#elif L==7 #elif L==7
"CC Attribuzione" // CC Attribution License "CC Attribuzione" // CC Attribution License
#elif L==8 #elif L==8
"CC Uznanie autorstwa" // CC Attribution License "CC Uznanie autorstwa" // CC Attribution License
#elif L==9 #elif L==9
@ -16813,15 +16813,15 @@ const char *Txt_LICENSES[Brw_NUM_LICENSES] =
#elif L==2 #elif L==2
"CC Namensnennung - Weitergabe unter gleichen Bedingungen" // CC Attribution-ShareAlike License "CC Namensnennung - Weitergabe unter gleichen Bedingungen" // CC Attribution-ShareAlike License
#elif L==3 #elif L==3
"CC Attribution - Share Alike" // CC Attribution-ShareAlike License "CC Attribution - Share Alike" // CC Attribution-ShareAlike License
#elif L==4 #elif L==4
"CC Reconocimiento - Compartir bajo la misma licencia" // CC Attribution-ShareAlike License "CC Reconocimiento - Compartir bajo la misma licencia" // CC Attribution-ShareAlike License
#elif L==5 #elif L==5
"CC Attribution - Partage &agrave; l'Identique" // CC Attribution-ShareAlike License "CC Attribution - Partage &agrave; l'Identique" // CC Attribution-ShareAlike License
#elif L==6 #elif L==6
"CC Reconocimiento - Compartir bajo la misma licencia" // CC Attribution-ShareAlike License // Okoteve traducción "CC Reconocimiento - Compartir bajo la misma licencia" // CC Attribution-ShareAlike License // Okoteve traducción
#elif L==7 #elif L==7
"CC Attribuzione - Condividi allo stesso modo" // CC Attribution-ShareAlike License "CC Attribuzione - Condividi allo stesso modo" // CC Attribution-ShareAlike License
#elif L==8 #elif L==8
"CC Uznanie autorstwa - Na tych samych warunkach" // CC Attribution-ShareAlike License "CC Uznanie autorstwa - Na tych samych warunkach" // CC Attribution-ShareAlike License
#elif L==9 #elif L==9
@ -16831,17 +16831,17 @@ const char *Txt_LICENSES[Brw_NUM_LICENSES] =
#if L==1 #if L==1
"CC Reconeixement - Sense obra derivada" // CC Attribution-NoDerivs License "CC Reconeixement - Sense obra derivada" // CC Attribution-NoDerivs License
#elif L==2 #elif L==2
"CC Namensnennung - Keine Bearbeitung" // CC Attribution-NoDerivs License "CC Namensnennung - Keine Bearbeitung" // CC Attribution-NoDerivs License
#elif L==3 #elif L==3
"CC Attribution - No Derivative Works" // CC Attribution-NoDerivs License "CC Attribution - No Derivative Works" // CC Attribution-NoDerivs License
#elif L==4 #elif L==4
"CC Reconocimiento - Sin obras derivadas" // CC Attribution-NoDerivs License "CC Reconocimiento - Sin obras derivadas" // CC Attribution-NoDerivs License
#elif L==5 #elif L==5
"CC Attribution - Pas de travaux d&eacute;riv&eacute;s" // CC Attribution-NoDerivs License "CC Attribution - Pas de travaux d&eacute;riv&eacute;s" // CC Attribution-NoDerivs License
#elif L==6 #elif L==6
"CC Reconocimiento - Sin obras derivadas" // CC Attribution-NoDerivs License // Okoteve traducción "CC Reconocimiento - Sin obras derivadas" // CC Attribution-NoDerivs License // Okoteve traducción
#elif L==7 #elif L==7
"CC Attribuzione - Non opere derivate" // CC Attribution-NoDerivs License "CC Attribuzione - Non opere derivate" // CC Attribution-NoDerivs License
#elif L==8 #elif L==8
"CC Uznanie autorstwa - Bez utwor&oacute;w zale&zdot;nych" // CC Attribution-NoDerivs License "CC Uznanie autorstwa - Bez utwor&oacute;w zale&zdot;nych" // CC Attribution-NoDerivs License
#elif L==9 #elif L==9
@ -16851,7 +16851,7 @@ const char *Txt_LICENSES[Brw_NUM_LICENSES] =
#if L==1 #if L==1
"CC Reconeixement - No comercial" // CC Attribution-NonCommercial License "CC Reconeixement - No comercial" // CC Attribution-NonCommercial License
#elif L==2 #elif L==2
"CC Namensnennung - Keine kommerzielle Nutzung" // CC Attribution-NonCommercial License "CC Namensnennung - Keine kommerzielle Nutzung" // CC Attribution-NonCommercial License
#elif L==3 #elif L==3
"CC Attribution - Noncommercial" // CC Attribution-NonCommercial License "CC Attribution - Noncommercial" // CC Attribution-NonCommercial License
#elif L==4 #elif L==4
@ -16869,7 +16869,7 @@ const char *Txt_LICENSES[Brw_NUM_LICENSES] =
#endif #endif
, ,
#if L==1 #if L==1
"CC Reconeixement - No comercial - Compartir igual" // CC Attribution-NonCommercial-ShareAlike License "CC Reconeixement - No comercial - Compartir igual" // CC Attribution-NonCommercial-ShareAlike License
#elif L==2 #elif L==2
"CC Namensnennung - Keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen" // CC Attribution-NonCommercial-ShareAlike License "CC Namensnennung - Keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen" // CC Attribution-NonCommercial-ShareAlike License
#elif L==3 #elif L==3
@ -16881,7 +16881,7 @@ const char *Txt_LICENSES[Brw_NUM_LICENSES] =
#elif L==6 #elif L==6
"CC Reconocimiento - No comercial - Compartir bajo la misma licencia" // CC Attribution-NonCommercial-ShareAlike License // Okoteve traducción "CC Reconocimiento - No comercial - Compartir bajo la misma licencia" // CC Attribution-NonCommercial-ShareAlike License // Okoteve traducción
#elif L==7 #elif L==7
"CC Attribuzione - Non commerciale - Condividi allo stesso modo" // CC Attribution-NonCommercial-ShareAlike License "CC Attribuzione - Non commerciale - Condividi allo stesso modo" // CC Attribution-NonCommercial-ShareAlike License
#elif L==8 #elif L==8
"CC Uznanie autorstwa - U&zdot;ycie niekomercyjne - Na tych samych warunkach" // CC Attribution-NonCommercial-ShareAlike License "CC Uznanie autorstwa - U&zdot;ycie niekomercyjne - Na tych samych warunkach" // CC Attribution-NonCommercial-ShareAlike License
#elif L==9 #elif L==9
@ -16889,21 +16889,21 @@ const char *Txt_LICENSES[Brw_NUM_LICENSES] =
#endif #endif
, ,
#if L==1 #if L==1
"CC Reconeixement - No comercial - Sense obra derivada" // CC Attribution-NonCommercial-NoDerivs License "CC Reconeixement - No comercial - Sense obra derivada" // CC Attribution-NonCommercial-NoDerivs License
#elif L==2 #elif L==2
"CC Namensnennung - Keine kommerzielle Nutzung - Keine Bearbeitung" // CC Attribution-NonCommercial-NoDerivs License "CC Namensnennung - Keine kommerzielle Nutzung - Keine Bearbeitung" // CC Attribution-NonCommercial-NoDerivs License
#elif L==3 #elif L==3
"CC Attribution - Noncommercial - No Derivative Works" // CC Attribution-NonCommercial-NoDerivs License "CC Attribution - Noncommercial - No Derivative Works" // CC Attribution-NonCommercial-NoDerivs License
#elif L==4 #elif L==4
"CC Reconocimiento - No comercial - Sin obras derivadas" // CC Attribution-NonCommercial-NoDerivs License "CC Reconocimiento - No comercial - Sin obras derivadas" // CC Attribution-NonCommercial-NoDerivs License
#elif L==5 #elif L==5
"CC Attribution - Pas dUtilisation Commerciale - Pas de travaux d&eacute;riv&eacute;s" // CC Attribution-NonCommercial-NoDerivs License "CC Attribution - Pas dUtilisation Commerciale - Pas de travaux d&eacute;riv&eacute;s" // CC Attribution-NonCommercial-NoDerivs License
#elif L==6 #elif L==6
"CC Reconocimiento - No comercial - Sin obras derivadas" // CC Attribution-NonCommercial-NoDerivs License // Okoteve traducción "CC Reconocimiento - No comercial - Sin obras derivadas" // CC Attribution-NonCommercial-NoDerivs License // Okoteve traducción
#elif L==7 #elif L==7
"CC Attribuzione - Non commerciale - Non opere derivate" // CC Attribution-NonCommercial-NoDerivs License "CC Attribuzione - Non commerciale - Non opere derivate" // CC Attribution-NonCommercial-NoDerivs License
#elif L==8 #elif L==8
"CC Uznanie autorstwa - U&zdot;ycie niekomercyjne - Bez utwor&oacute;w zale&zdot;nych" // CC Attribution-NonCommercial-NoDerivs License "CC Uznanie autorstwa - U&zdot;ycie niekomercyjne - Bez utwor&oacute;w zale&zdot;nych" // CC Attribution-NonCommercial-NoDerivs License
#elif L==9 #elif L==9
"CC Atribui&ccedil;&atilde;o - N&atilde;oComercial - Trabalhos Derivados Pro&iacute;bidos" // CC Attribution-NonCommercial-NoDerivs License "CC Atribui&ccedil;&atilde;o - N&atilde;oComercial - Trabalhos Derivados Pro&iacute;bidos" // CC Attribution-NonCommercial-NoDerivs License
#endif #endif

View File

@ -429,8 +429,8 @@ void Usr_GetEncryptedUsrCodFromUsrCod (struct UsrData *UsrDat) // TODO: Remove t
/***** Get encrypted user's code *****/ /***** Get encrypted user's code *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strncpy (UsrDat->EncryptedUsrCod,row[0],sizeof (UsrDat->EncryptedUsrCod) - 1); Str_Copy (UsrDat->EncryptedUsrCod,row[0],
UsrDat->EncryptedUsrCod[sizeof (UsrDat->EncryptedUsrCod) - 1] = '\0'; Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -478,12 +478,11 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get encrypted user's code */ /* Get encrypted user's code */
strncpy (UsrDat->EncryptedUsrCod,row[0],sizeof (UsrDat->EncryptedUsrCod) - 1); Str_Copy (UsrDat->EncryptedUsrCod,row[0],
UsrDat->EncryptedUsrCod[sizeof (UsrDat->EncryptedUsrCod) - 1] = '\0'; Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
/* Get encrypted password */ /* Get encrypted password */
strncpy (UsrDat->Password,row[1],sizeof (UsrDat->Password) - 1); Str_Copy (UsrDat->Password,row[1],Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64);
UsrDat->Password[sizeof (UsrDat->Password) - 1] = '\0';
/* Get roles */ /* Get roles */
UsrDat->RoleInCurrentCrsDB = Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod); UsrDat->RoleInCurrentCrsDB = Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod);
@ -495,12 +494,9 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
Rol_VISITOR; // User belongs to some courses Rol_VISITOR; // User belongs to some courses
/* Get name */ /* Get name */
strncpy (UsrDat->Surname1 ,row[2],sizeof (UsrDat->Surname1 ) - 1); Str_Copy (UsrDat->Surname1 ,row[2],Usr_MAX_BYTES_NAME);
UsrDat->Surname1 [sizeof (UsrDat->Surname1 ) - 1] = '\0'; Str_Copy (UsrDat->Surname2 ,row[3],Usr_MAX_BYTES_NAME);
strncpy (UsrDat->Surname2 ,row[3],sizeof (UsrDat->Surname2 ) - 1); Str_Copy (UsrDat->FirstName,row[4],Usr_MAX_BYTES_NAME);
UsrDat->Surname2 [sizeof (UsrDat->Surname2 ) - 1] = '\0';
strncpy (UsrDat->FirstName,row[4],sizeof (UsrDat->FirstName) - 1);
UsrDat->FirstName[sizeof (UsrDat->FirstName) - 1] = '\0';
/* Get sex */ /* Get sex */
UsrDat->Sex = Usr_GetSexFromStr (row[5]); UsrDat->Sex = Usr_GetSexFromStr (row[5]);
@ -545,8 +541,7 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
UsrDat->Prefs.FirstDayOfWeek = UnsignedNum; UsrDat->Prefs.FirstDayOfWeek = UnsignedNum;
/* Get rest of data */ /* Get rest of data */
strncpy (UsrDat->Photo,row[10],sizeof (UsrDat->Photo) - 1); Str_Copy (UsrDat->Photo,row[10],Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
UsrDat->Photo[sizeof (UsrDat->Photo) - 1] = '\0';
UsrDat->PhotoVisibility = Pri_GetVisibilityFromStr (row[11]); UsrDat->PhotoVisibility = Pri_GetVisibilityFromStr (row[11]);
UsrDat->ProfileVisibility = Pri_GetVisibilityFromStr (row[12]); UsrDat->ProfileVisibility = Pri_GetVisibilityFromStr (row[12]);
UsrDat->CtyCod = Str_ConvertStrCodToLongCod (row[13]); UsrDat->CtyCod = Str_ConvertStrCodToLongCod (row[13]);
@ -555,21 +550,14 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
UsrDat->Tch.DptCod = Str_ConvertStrCodToLongCod (row[16]); UsrDat->Tch.DptCod = Str_ConvertStrCodToLongCod (row[16]);
UsrDat->Tch.CtrCod = Str_ConvertStrCodToLongCod (row[17]); UsrDat->Tch.CtrCod = Str_ConvertStrCodToLongCod (row[17]);
strncpy (UsrDat->Tch.Office ,row[18],sizeof (UsrDat->Tch.Office ) - 1); Str_Copy (UsrDat->Tch.Office ,row[18],Cns_MAX_BYTES_STRING);
UsrDat->Tch.Office [sizeof (UsrDat->Tch.Office ) - 1] = '\0'; Str_Copy (UsrDat->Tch.OfficePhone,row[19],Usr_MAX_BYTES_PHONE);
strncpy (UsrDat->Tch.OfficePhone,row[19],sizeof (UsrDat->Tch.OfficePhone) - 1);
UsrDat->Tch.OfficePhone[sizeof (UsrDat->Tch.OfficePhone) - 1] = '\0';
strncpy (UsrDat->LocalAddress ,row[20],sizeof (UsrDat->LocalAddress ) - 1); Str_Copy (UsrDat->LocalAddress ,row[20],Cns_MAX_BYTES_STRING);
UsrDat->LocalAddress [sizeof (UsrDat->LocalAddress ) - 1] = '\0'; Str_Copy (UsrDat->LocalPhone ,row[21],Usr_MAX_BYTES_PHONE);
strncpy (UsrDat->LocalPhone ,row[21],sizeof (UsrDat->LocalPhone ) - 1); Str_Copy (UsrDat->FamilyAddress,row[22],Cns_MAX_BYTES_STRING);
UsrDat->LocalPhone [sizeof (UsrDat->LocalPhone ) - 1] = '\0'; Str_Copy (UsrDat->FamilyPhone ,row[23],Usr_MAX_BYTES_PHONE);
strncpy (UsrDat->FamilyAddress,row[22],sizeof (UsrDat->FamilyAddress) - 1); Str_Copy (UsrDat->OriginPlace ,row[24],Cns_MAX_BYTES_STRING);
UsrDat->FamilyAddress[sizeof (UsrDat->FamilyAddress) - 1] = '\0';
strncpy (UsrDat->FamilyPhone ,row[23],sizeof (UsrDat->FamilyPhone ) - 1);
UsrDat->FamilyPhone [sizeof (UsrDat->FamilyPhone ) - 1] = '\0';
strncpy (UsrDat->OriginPlace ,row[24],sizeof (UsrDat->OriginPlace ) - 1);
UsrDat->OriginPlace [sizeof (UsrDat->OriginPlace ) - 1] = '\0';
strcpy (StrBirthday, strcpy (StrBirthday,
row[25] ? row[25] : row[25] ? row[25] :
"0000-00-00"); "0000-00-00");
@ -632,11 +620,8 @@ static void Usr_GetUsrCommentsFromString (char *Str,struct UsrData *UsrDat)
{ {
/***** Check that memory for comments is allocated *****/ /***** Check that memory for comments is allocated *****/
if (UsrDat->Comments) if (UsrDat->Comments)
{
/***** Copy comments from Str to Comments *****/ /***** Copy comments from Str to Comments *****/
strncpy (UsrDat->Comments,Str,Cns_MAX_BYTES_TEXT); Str_Copy (UsrDat->Comments,Str,Cns_MAX_BYTES_TEXT);
UsrDat->Comments[Cns_MAX_BYTES_TEXT] = '\0';
}
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2230,8 +2215,9 @@ unsigned Usr_GetParamOtherUsrIDNickOrEMailAndGetUsrCods (struct ListUsrCods *Lis
/* Allocate space for the list */ /* Allocate space for the list */
ID_ReallocateListIDs (&Gbl.Usrs.Other.UsrDat,1); ID_ReallocateListIDs (&Gbl.Usrs.Other.UsrDat,1);
strncpy (Gbl.Usrs.Other.UsrDat.IDs.List[0].ID,Gbl.Usrs.Other.UsrDat.UsrIDNickOrEmail,ID_MAX_LENGTH_USR_ID); Str_Copy (Gbl.Usrs.Other.UsrDat.IDs.List[0].ID,
Gbl.Usrs.Other.UsrDat.IDs.List[0].ID[ID_MAX_LENGTH_USR_ID] = '\0'; Gbl.Usrs.Other.UsrDat.UsrIDNickOrEmail,
ID_MAX_LENGTH_USR_ID);
Str_ConvertToUpperText (Gbl.Usrs.Other.UsrDat.IDs.List[0].ID); Str_ConvertToUpperText (Gbl.Usrs.Other.UsrDat.IDs.List[0].ID);
/* Check if user's ID exists in database */ /* Check if user's ID exists in database */
@ -2532,8 +2518,8 @@ static bool Usr_ChkUsrAndGetUsrDataFromDirectLogin (void)
/***** Allocate space for the list *****/ /***** Allocate space for the list *****/
ID_ReallocateListIDs (&Gbl.Usrs.Me.UsrDat,1); ID_ReallocateListIDs (&Gbl.Usrs.Me.UsrDat,1);
strncpy (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID,Gbl.Usrs.Me.UsrIdLogin,ID_MAX_LENGTH_USR_ID); Str_Copy (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID,Gbl.Usrs.Me.UsrIdLogin,
Gbl.Usrs.Me.UsrDat.IDs.List[0].ID[ID_MAX_LENGTH_USR_ID] = '\0'; ID_MAX_LENGTH_USR_ID);
Str_ConvertToUpperText (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID); Str_ConvertToUpperText (Gbl.Usrs.Me.UsrDat.IDs.List[0].ID);
/* Check if user's ID exists in database, and get user's data */ /* Check if user's ID exists in database, and get user's data */
@ -4681,27 +4667,24 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop
UsrInList->UsrCod = Str_ConvertStrCodToLongCod (row[0]); UsrInList->UsrCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get encrypted user's code (row[1]) */ /* Get encrypted user's code (row[1]) */
strncpy (UsrInList->EncryptedUsrCod,row[1],sizeof (UsrInList->EncryptedUsrCod) - 1); Str_Copy (UsrInList->EncryptedUsrCod,row[1],
UsrInList->EncryptedUsrCod[sizeof (UsrInList->EncryptedUsrCod) - 1] = '\0'; Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
/* Get user's surname 1 (row[2]) */ /* Get user's surname 1 (row[2]) */
strncpy (UsrInList->Surname1 ,row[2],sizeof (UsrInList->Surname1 ) - 1); Str_Copy (UsrInList->Surname1 ,row[2],Usr_MAX_BYTES_NAME);
UsrInList->Surname1 [sizeof (UsrInList->Surname1 ) - 1] = '\0';
/* Get user's surname 2 (row[3]) */ /* Get user's surname 2 (row[3]) */
strncpy (UsrInList->Surname2 ,row[3],sizeof (UsrInList->Surname2 ) - 1); Str_Copy (UsrInList->Surname2 ,row[3],Usr_MAX_BYTES_NAME);
UsrInList->Surname2 [sizeof (UsrInList->Surname2 ) - 1] = '\0';
/* Get user's first name (row[4]) */ /* Get user's first name (row[4]) */
strncpy (UsrInList->FirstName,row[4],sizeof (UsrInList->FirstName) - 1); Str_Copy (UsrInList->FirstName,row[4],Usr_MAX_BYTES_NAME);
UsrInList->FirstName[sizeof (UsrInList->FirstName) - 1] = '\0';
/* Get user's sex (row[5]) */ /* Get user's sex (row[5]) */
UsrInList->Sex = Usr_GetSexFromStr (row[5]); UsrInList->Sex = Usr_GetSexFromStr (row[5]);
/* Get user's photo (row[6]) */ /* Get user's photo (row[6]) */
strncpy (UsrInList->Photo,row[6],sizeof (UsrInList->Photo) - 1); Str_Copy (UsrInList->Photo,row[6],
UsrInList->Photo[sizeof (UsrInList->Photo) - 1] = '\0'; Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
/* Get user's photo visibility (row[7]) */ /* Get user's photo visibility (row[7]) */
UsrInList->PhotoVisibility = Pri_GetVisibilityFromStr (row[7]); UsrInList->PhotoVisibility = Pri_GetVisibilityFromStr (row[7]);
@ -5085,8 +5068,8 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs)
/***** Allocate space for the list *****/ /***** Allocate space for the list *****/
ID_ReallocateListIDs (&UsrDat,1); ID_ReallocateListIDs (&UsrDat,1);
strncpy (UsrDat.IDs.List[0].ID,UsrIDNickOrEmail,ID_MAX_LENGTH_USR_ID); Str_Copy (UsrDat.IDs.List[0].ID,UsrIDNickOrEmail,
UsrDat.IDs.List[0].ID[ID_MAX_LENGTH_USR_ID] = '\0'; ID_MAX_LENGTH_USR_ID);
/***** Check if a user exists having this user's ID *****/ /***** Check if a user exists having this user's ID *****/
if (ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false)) if (ID_GetListUsrCodsFromUsrID (&UsrDat,NULL,&ListUsrCods,false))

View File

@ -116,15 +116,15 @@ typedef enum
struct UsrData struct UsrData
{ {
long UsrCod; long UsrCod;
char EncryptedUsrCod [Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+1]; char EncryptedUsrCod [Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64 + 1];
char UsrIDNickOrEmail[Usr_MAX_BYTES_USR_LOGIN+1]; // String to store the ID, nickname or email char UsrIDNickOrEmail[Usr_MAX_BYTES_USR_LOGIN + 1]; // String to store the ID, nickname or email
struct struct
{ {
struct ListIDs *List; struct ListIDs *List;
unsigned Num; unsigned Num;
} IDs; } IDs;
char Nickname [Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1]; char Nickname [Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA + 1];
char Password [Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64+1]; char Password [Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64 + 1];
Rol_Role_t RoleInCurrentCrsDB; Rol_Role_t RoleInCurrentCrsDB;
int Roles; // Check always if filled/calculated int Roles; // Check always if filled/calculated
// >=0 ==> filled/calculated // >=0 ==> filled/calculated
@ -133,7 +133,7 @@ struct UsrData
char Surname1 [Usr_MAX_BYTES_NAME + 1]; char Surname1 [Usr_MAX_BYTES_NAME + 1];
char Surname2 [Usr_MAX_BYTES_NAME + 1]; char Surname2 [Usr_MAX_BYTES_NAME + 1];
char FirstName [Usr_MAX_BYTES_NAME + 1]; char FirstName [Usr_MAX_BYTES_NAME + 1];
char FullName [(Usr_MAX_BYTES_NAME + 1) * 3]; char FullName [Usr_MAX_BYTES_FULL_NAME + 1];
Usr_Sex_t Sex; Usr_Sex_t Sex;
char Email [Usr_MAX_BYTES_USR_EMAIL + 1]; char Email [Usr_MAX_BYTES_USR_EMAIL + 1];
bool EmailConfirmed; bool EmailConfirmed;

View File

@ -192,6 +192,8 @@ Svc_Role_t Svc_RolRole_to_SvcRole[Rol_NUM_ROLES] =
Svc_ROLE_UNKNOWN, // Rol_SYS_ADM Svc_ROLE_UNKNOWN, // Rol_SYS_ADM
}; };
#define Svc_LENGTH_WS_KEY Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64
/*****************************************************************************/ /*****************************************************************************/
/********************************* Data types ********************************/ /********************************* Data types ********************************/
/*****************************************************************************/ /*****************************************************************************/
@ -200,7 +202,6 @@ Svc_Role_t Svc_RolRole_to_SvcRole[Rol_NUM_ROLES] =
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
// static int Svc_CheckIfIPIsAllowed (void);
static int Svc_GetPlgCodFromAppKey (const char *appKey); static int Svc_GetPlgCodFromAppKey (const char *appKey);
static int Svc_CheckIdSession (const char *IdSession); static int Svc_CheckIdSession (const char *IdSession);
static int Svc_CheckWSKey (char *WSKey); static int Svc_CheckWSKey (char *WSKey);
@ -272,38 +273,6 @@ void Svc_Exit (const char *DetailErrorMessage)
exit (ReturnCode); exit (ReturnCode);
} }
/*****************************************************************************/
/*********** Check if the IP of the requester of a web service ***************/
/*********** is one of the IP allowed in the plugins ***************/
/*****************************************************************************/
/*
static int Svc_CheckIfIPIsAllowed (void)
{
char IP[Cns_MAX_LENGTH_IP+1];
char Query[256+Cns_MAX_LENGTH_IP];
***** Get IP *****
if (getenv ("REMOTE_ADDR"))
{
strncpy (IP,getenv ("REMOTE_ADDR"),Cns_MAX_LENGTH_IP);
IP[Cns_MAX_LENGTH_IP] = '\0';
}
else
IP[0] = '\0';
***** Get number of plugins with a IP address *****
sprintf (Query,"SELECT COUNT(*) FROM plugins WHERE IP='%s'",IP);
if (!DB_QueryCOUNT (Query,"can not check IP"))
{
sprintf (Gbl.Message,"Sender's IP (%s) is forbidden",IP);
return soap_sender_fault (Gbl.soap,
Gbl.Message,
"The IP of the requester of a web service is not allowed");
}
return SOAP_OK;
}
*/
/*****************************************************************************/ /*****************************************************************************/
/****** Check if the application key of the requester of a web service *******/ /****** Check if the application key of the requester of a web service *******/
/****** is one of the application keys allowed in the plugins *******/ /****** is one of the application keys allowed in the plugins *******/
@ -581,23 +550,16 @@ static bool Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get user's name */ /* Get user's name */
strncpy (UsrDat->Surname1 ,row[0],sizeof (UsrDat->Surname1 )-1); Str_Copy (UsrDat->Surname1 ,row[0],Usr_MAX_BYTES_NAME);
UsrDat->Surname1 [sizeof (UsrDat->Surname1 )-1] = '\0'; Str_Copy (UsrDat->Surname2 ,row[1],Usr_MAX_BYTES_NAME);
strncpy (UsrDat->Surname2 ,row[1],sizeof (UsrDat->Surname2 )-1); Str_Copy (UsrDat->FirstName,row[2],Usr_MAX_BYTES_NAME);
UsrDat->Surname2 [sizeof (UsrDat->Surname2 )-1] = '\0';
strncpy (UsrDat->FirstName,row[2],sizeof (UsrDat->FirstName)-1);
UsrDat->FirstName[sizeof (UsrDat->FirstName)-1] = '\0';
/* Get user's photo */ /* Get user's photo */
strncpy (UsrDat->Photo,row[3],sizeof (UsrDat->Photo)-1); Str_Copy (UsrDat->Photo,row[3],Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
UsrDat->Photo[sizeof (UsrDat->Photo)-1] = '\0';
/* Get user's brithday */ /* Get user's brithday */
if (row[4]) if (row[4])
{ Str_Copy (UsrDat->Birthday.YYYYMMDD,row[4],Dat_LENGTH_YYYYMMDD);
strncpy (UsrDat->Birthday.YYYYMMDD,row[4],Dat_LENGTH_YYYYMMDD);
UsrDat->Birthday.YYYYMMDD[Dat_LENGTH_YYYYMMDD] = '\0';
}
else else
strcpy (UsrDat->Birthday.YYYYMMDD,"00000000"); strcpy (UsrDat->Birthday.YYYYMMDD,"00000000");
@ -685,7 +647,7 @@ int swad__createAccount (struct soap *soap,
Gbl.WebService.Function = Svc_createAccount; Gbl.WebService.Function = Svc_createAccount;
/***** Allocate space for strings *****/ /***** Allocate space for strings *****/
createAccountOut->wsKey = (char *) soap_malloc (Gbl.soap,256); createAccountOut->wsKey = (char *) soap_malloc (Gbl.soap,Svc_LENGTH_WS_KEY + 1);
/***** Default values returned on error *****/ /***** Default values returned on error *****/
createAccountOut->userCode = 0; // Undefined error createAccountOut->userCode = 0; // Undefined error
@ -753,8 +715,8 @@ static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
/***** Step 1/3: Check new nickname *****/ /***** Step 1/3: Check new nickname *****/
/* Make a copy without possible starting arrobas */ /* Make a copy without possible starting arrobas */
strncpy (NewNicknameWithoutArroba,NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA] = '\0'; Nck_MAX_BYTES_NICKNAME_WITH_ARROBA);
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
{ {
/***** Remove arrobas at the beginning *****/ /***** Remove arrobas at the beginning *****/
@ -798,13 +760,13 @@ int swad__loginByUserPasswordKey (struct soap *soap,
char *userID,char *userPassword,char *appKey, // input char *userID,char *userPassword,char *appKey, // input
struct swad__loginByUserPasswordKeyOutput *loginByUserPasswordKeyOut) // output struct swad__loginByUserPasswordKeyOutput *loginByUserPasswordKeyOut) // output
{ {
char UsrIDNickOrEmail[512]; char UsrIDNickOrEmail[Usr_MAX_BYTES_USR_LOGIN + 1];
int ReturnCode; int ReturnCode;
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumRows; unsigned NumRows;
char PhotoURL[PATH_MAX+1]; char PhotoURL[Cns_MAX_BYTES_URL + 1];
bool UsrFound; bool UsrFound;
/***** Initializations *****/ /***** Initializations *****/
@ -812,14 +774,14 @@ int swad__loginByUserPasswordKey (struct soap *soap,
Gbl.WebService.Function = Svc_loginByUserPasswordKey; Gbl.WebService.Function = Svc_loginByUserPasswordKey;
/***** Allocate space for strings *****/ /***** Allocate space for strings *****/
loginByUserPasswordKeyOut->wsKey = (char *) soap_malloc (Gbl.soap,256); loginByUserPasswordKeyOut->wsKey = (char *) soap_malloc (Gbl.soap,Svc_LENGTH_WS_KEY + 1);
loginByUserPasswordKeyOut->userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1); loginByUserPasswordKeyOut->userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1);
loginByUserPasswordKeyOut->userID = (char *) soap_malloc (Gbl.soap,256); loginByUserPasswordKeyOut->userID = (char *) soap_malloc (Gbl.soap,ID_MAX_LENGTH_USR_ID + 1);
loginByUserPasswordKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginByUserPasswordKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
loginByUserPasswordKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginByUserPasswordKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
loginByUserPasswordKeyOut->userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginByUserPasswordKeyOut->userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
loginByUserPasswordKeyOut->userPhoto = (char *) soap_malloc (Gbl.soap,PATH_MAX+1); loginByUserPasswordKeyOut->userPhoto = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_URL + 1);
loginByUserPasswordKeyOut->userBirthday = (char *) soap_malloc (Gbl.soap,8+2+2+1); loginByUserPasswordKeyOut->userBirthday = (char *) soap_malloc (Gbl.soap,Dat_LENGTH_YYYYMMDD + 1);
/***** Default values returned on error *****/ /***** Default values returned on error *****/
loginByUserPasswordKeyOut->userCode = -1; loginByUserPasswordKeyOut->userCode = -1;
@ -838,8 +800,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
return ReturnCode; return ReturnCode;
/***** Check if user's email, @nickname or ID are valid *****/ /***** Check if user's email, @nickname or ID are valid *****/
strncpy (UsrIDNickOrEmail,userID,255); Str_Copy (UsrIDNickOrEmail,userID,Usr_MAX_BYTES_USR_LOGIN);
UsrIDNickOrEmail[255] = '\0';
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
{ {
Str_RemoveLeadingArrobas (UsrIDNickOrEmail); Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
@ -908,28 +869,26 @@ int swad__loginByUserPasswordKey (struct soap *soap,
loginByUserPasswordKeyOut->userCode = (int) Gbl.Usrs.Me.UsrDat.UsrCod; loginByUserPasswordKeyOut->userCode = (int) Gbl.Usrs.Me.UsrDat.UsrCod;
strncpy (loginByUserPasswordKeyOut->userNickname,Gbl.Usrs.Me.UsrDat.Nickname,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA); Str_Copy (loginByUserPasswordKeyOut->userNickname,
loginByUserPasswordKeyOut->userNickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0'; Gbl.Usrs.Me.UsrDat.Nickname,
Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
if (Gbl.Usrs.Me.UsrDat.IDs.Num) if (Gbl.Usrs.Me.UsrDat.IDs.Num)
{ Str_Copy (loginByUserPasswordKeyOut->userID,
strncpy (loginByUserPasswordKeyOut->userID,Gbl.Usrs.Me.UsrDat.IDs.List[0].ID,255); // TODO: What user's ID? Gbl.Usrs.Me.UsrDat.IDs.List[0].ID,ID_MAX_LENGTH_USR_ID); // TODO: What user's ID?
loginByUserPasswordKeyOut->userID[255] = '\0';
}
strncpy (loginByUserPasswordKeyOut->userSurname1 ,Gbl.Usrs.Me.UsrDat.Surname1 ,Usr_MAX_BYTES_NAME); Str_Copy (loginByUserPasswordKeyOut->userSurname1,
loginByUserPasswordKeyOut->userSurname1 [Usr_MAX_BYTES_NAME] = '\0'; Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME);
strncpy (loginByUserPasswordKeyOut->userSurname2 ,Gbl.Usrs.Me.UsrDat.Surname2 ,Usr_MAX_BYTES_NAME); Str_Copy (loginByUserPasswordKeyOut->userSurname2,
loginByUserPasswordKeyOut->userSurname2 [Usr_MAX_BYTES_NAME] = '\0'; Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_NAME);
strncpy (loginByUserPasswordKeyOut->userFirstname,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Copy (loginByUserPasswordKeyOut->userFirstname,
loginByUserPasswordKeyOut->userFirstname[Usr_MAX_BYTES_NAME] = '\0'; Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
strncpy (loginByUserPasswordKeyOut->userPhoto,PhotoURL,PATH_MAX); Str_Copy (loginByUserPasswordKeyOut->userPhoto,PhotoURL,Cns_MAX_BYTES_URL);
loginByUserPasswordKeyOut->userPhoto[PATH_MAX] = '\0';
strncpy (loginByUserPasswordKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,Dat_LENGTH_YYYYMMDD); Str_Copy (loginByUserPasswordKeyOut->userBirthday,
loginByUserPasswordKeyOut->userBirthday[Dat_LENGTH_YYYYMMDD] = '\0'; Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,Dat_LENGTH_YYYYMMDD);
loginByUserPasswordKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB]; loginByUserPasswordKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
@ -966,7 +925,7 @@ int swad__loginBySessionKey (struct soap *soap,
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumRows; unsigned NumRows;
char PhotoURL[PATH_MAX+1]; char PhotoURL[Cns_MAX_BYTES_URL + 1];
bool UsrFound; bool UsrFound;
/***** Initializations *****/ /***** Initializations *****/
@ -974,16 +933,16 @@ int swad__loginBySessionKey (struct soap *soap,
Gbl.WebService.Function = Svc_loginBySessionKey; Gbl.WebService.Function = Svc_loginBySessionKey;
/***** Allocate space for strings *****/ /***** Allocate space for strings *****/
loginBySessionKeyOut->wsKey = (char *) soap_malloc (Gbl.soap,256); loginBySessionKeyOut->wsKey = (char *) soap_malloc (Gbl.soap,Svc_LENGTH_WS_KEY + 1);
loginBySessionKeyOut->userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA + 1); loginBySessionKeyOut->userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA + 1);
loginBySessionKeyOut->userID = (char *) soap_malloc (Gbl.soap,256); loginBySessionKeyOut->userID = (char *) soap_malloc (Gbl.soap,ID_MAX_LENGTH_USR_ID + 1);
loginBySessionKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginBySessionKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
loginBySessionKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginBySessionKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
loginBySessionKeyOut->userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginBySessionKeyOut->userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
loginBySessionKeyOut->userPhoto = (char *) soap_malloc (Gbl.soap,PATH_MAX+1); loginBySessionKeyOut->userPhoto = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_URL + 1);
loginBySessionKeyOut->userBirthday = (char *) soap_malloc (Gbl.soap,8+2+2+1); loginBySessionKeyOut->userBirthday = (char *) soap_malloc (Gbl.soap,Dat_LENGTH_YYYYMMDD + 1);
loginBySessionKeyOut->degreeName = (char *) soap_malloc (Gbl.soap,256); loginBySessionKeyOut->degreeName = (char *) soap_malloc (Gbl.soap,Deg_MAX_LENGTH_DEGREE_FULL_NAME + 1);
loginBySessionKeyOut->courseName = (char *) soap_malloc (Gbl.soap,256); loginBySessionKeyOut->courseName = (char *) soap_malloc (Gbl.soap,Crs_MAX_LENGTH_COURSE_FULL_NAME + 1);
/***** Default values returned on error *****/ /***** Default values returned on error *****/
loginBySessionKeyOut->userCode = -1; loginBySessionKeyOut->userCode = -1;
@ -1005,10 +964,6 @@ int swad__loginBySessionKey (struct soap *soap,
if ((ReturnCode = Svc_GetPlgCodFromAppKey ((const char *) appKey)) != SOAP_OK) if ((ReturnCode = Svc_GetPlgCodFromAppKey ((const char *) appKey)) != SOAP_OK)
return ReturnCode; return ReturnCode;
/***** Check IP of the sender *****/
// if ((ReturnCode = Svc_CheckIfIPIsAllowed ()) != SOAP_OK)
// return ReturnCode;
/***** Check length of session identifier *****/ /***** Check length of session identifier *****/
if (sessionID == NULL) if (sessionID == NULL)
return soap_sender_fault (Gbl.soap, return soap_sender_fault (Gbl.soap,
@ -1031,8 +986,8 @@ int swad__loginBySessionKey (struct soap *soap,
Gbl.CurrentCrs.Crs.CrsCod = Str_ConvertStrCodToLongCod (row[2]); Gbl.CurrentCrs.Crs.CrsCod = Str_ConvertStrCodToLongCod (row[2]);
Crs_GetDataOfCourseByCod (&Gbl.CurrentCrs.Crs); Crs_GetDataOfCourseByCod (&Gbl.CurrentCrs.Crs);
loginBySessionKeyOut->courseCode = (int) Gbl.CurrentCrs.Crs.CrsCod; loginBySessionKeyOut->courseCode = (int) Gbl.CurrentCrs.Crs.CrsCod;
strncpy (loginBySessionKeyOut->courseName,Gbl.CurrentCrs.Crs.FullName,255); Str_Copy (loginBySessionKeyOut->courseName,Gbl.CurrentCrs.Crs.FullName,
loginBySessionKeyOut->courseName[255] = '\0'; Crs_MAX_LENGTH_COURSE_FULL_NAME);
/***** Get user code (row[0]) *****/ /***** Get user code (row[0]) *****/
Gbl.Usrs.Me.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); Gbl.Usrs.Me.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
@ -1042,8 +997,8 @@ int swad__loginBySessionKey (struct soap *soap,
Gbl.CurrentDeg.Deg.DegCod = Str_ConvertStrCodToLongCod (row[1]); Gbl.CurrentDeg.Deg.DegCod = Str_ConvertStrCodToLongCod (row[1]);
Deg_GetDataOfDegreeByCod (&Gbl.CurrentDeg.Deg); Deg_GetDataOfDegreeByCod (&Gbl.CurrentDeg.Deg);
loginBySessionKeyOut->degreeCode = (int) Gbl.CurrentDeg.Deg.DegCod; loginBySessionKeyOut->degreeCode = (int) Gbl.CurrentDeg.Deg.DegCod;
strncpy (loginBySessionKeyOut->degreeName,Gbl.CurrentDeg.Deg.FullName,255); Str_Copy (loginBySessionKeyOut->degreeName,Gbl.CurrentDeg.Deg.FullName,
loginBySessionKeyOut->degreeName[255] = '\0'; Deg_MAX_LENGTH_DEGREE_FULL_NAME);
} }
else else
UsrFound = false; UsrFound = false;
@ -1062,28 +1017,26 @@ int swad__loginBySessionKey (struct soap *soap,
loginBySessionKeyOut->userCode = (int) Gbl.Usrs.Me.UsrDat.UsrCod; loginBySessionKeyOut->userCode = (int) Gbl.Usrs.Me.UsrDat.UsrCod;
strncpy (loginBySessionKeyOut->userNickname,Gbl.Usrs.Me.UsrDat.Nickname,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA); Str_Copy (loginBySessionKeyOut->userNickname,Gbl.Usrs.Me.UsrDat.Nickname,
loginBySessionKeyOut->userNickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0'; Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
if (Gbl.Usrs.Me.UsrDat.IDs.Num) if (Gbl.Usrs.Me.UsrDat.IDs.Num)
{ Str_Copy (loginBySessionKeyOut->userID,
strncpy (loginBySessionKeyOut->userID,Gbl.Usrs.Me.UsrDat.IDs.List[0].ID,255); // TODO: What user's ID? Gbl.Usrs.Me.UsrDat.IDs.List[0].ID, // TODO: What user's ID?
loginBySessionKeyOut->userID[255] = '\0'; ID_MAX_LENGTH_USR_ID);
}
strncpy (loginBySessionKeyOut->userSurname1 ,Gbl.Usrs.Me.UsrDat.Surname1 ,Usr_MAX_BYTES_NAME); Str_Copy (loginBySessionKeyOut->userSurname1,
loginBySessionKeyOut->userSurname1 [Usr_MAX_BYTES_NAME] = '\0'; Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME);
strncpy (loginBySessionKeyOut->userSurname2 ,Gbl.Usrs.Me.UsrDat.Surname2 ,Usr_MAX_BYTES_NAME); Str_Copy (loginBySessionKeyOut->userSurname2,
loginBySessionKeyOut->userSurname2 [Usr_MAX_BYTES_NAME] = '\0'; Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_NAME);
strncpy (loginBySessionKeyOut->userFirstname,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Copy (loginBySessionKeyOut->userFirstname,
loginBySessionKeyOut->userFirstname[Usr_MAX_BYTES_NAME] = '\0'; Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
strncpy (loginBySessionKeyOut->userPhoto,PhotoURL,PATH_MAX); Str_Copy (loginBySessionKeyOut->userPhoto,PhotoURL,Cns_MAX_BYTES_URL);
loginBySessionKeyOut->userPhoto[PATH_MAX] = '\0';
strncpy (loginBySessionKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,Dat_LENGTH_YYYYMMDD); Str_Copy (loginBySessionKeyOut->userBirthday,
loginBySessionKeyOut->userBirthday[Dat_LENGTH_YYYYMMDD] = '\0'; Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,Dat_LENGTH_YYYYMMDD);
loginBySessionKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB]; loginBySessionKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
@ -1106,7 +1059,7 @@ int swad__getNewPassword (struct soap *soap,
struct swad__getNewPasswordOutput *getNewPasswordOut) // output struct swad__getNewPasswordOutput *getNewPasswordOut) // output
{ {
int ReturnCode; int ReturnCode;
char UsrIDNickOrEmail[512]; char UsrIDNickOrEmail[Usr_MAX_BYTES_USR_LOGIN + 1];
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
@ -1125,8 +1078,7 @@ int swad__getNewPassword (struct soap *soap,
return ReturnCode; return ReturnCode;
/***** Check if user's email, @nickname or ID are valid *****/ /***** Check if user's email, @nickname or ID are valid *****/
strncpy (UsrIDNickOrEmail,userID,255); Str_Copy (UsrIDNickOrEmail,userID,Usr_MAX_BYTES_USR_LOGIN);
UsrIDNickOrEmail[255] = '\0';
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
{ {
Str_RemoveLeadingArrobas (UsrIDNickOrEmail); Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
@ -1202,7 +1154,8 @@ int swad__getCourses (struct soap *soap,
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumRow,NumRows; unsigned NumRow;
unsigned NumRows;
Rol_Role_t Role; Rol_Role_t Role;
/***** Initializations *****/ /***** Initializations *****/
@ -1252,14 +1205,14 @@ int swad__getCourses (struct soap *soap,
getCoursesOut->coursesArray.__ptr[NumRow].courseCode = (int) Str_ConvertStrCodToLongCod (row[0]); getCoursesOut->coursesArray.__ptr[NumRow].courseCode = (int) Str_ConvertStrCodToLongCod (row[0]);
/* Get course short name (row[1]) */ /* Get course short name (row[1]) */
getCoursesOut->coursesArray.__ptr[NumRow].courseShortName = (char *) soap_malloc (Gbl.soap,256); getCoursesOut->coursesArray.__ptr[NumRow].courseShortName = (char *) soap_malloc (Gbl.soap,Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1);
strncpy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName,row[1],255); Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName,
getCoursesOut->coursesArray.__ptr[NumRow].courseShortName[255] = '\0'; row[1],Crs_MAX_LENGTH_COURSE_SHRT_NAME);
/* Get course full name (row[2]) */ /* Get course full name (row[2]) */
getCoursesOut->coursesArray.__ptr[NumRow].courseFullName = (char *) soap_malloc (Gbl.soap,256); getCoursesOut->coursesArray.__ptr[NumRow].courseFullName = (char *) soap_malloc (Gbl.soap,Crs_MAX_LENGTH_COURSE_FULL_NAME + 1);
strncpy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName,row[2],255); Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName,
getCoursesOut->coursesArray.__ptr[NumRow].courseFullName[255] = '\0'; row[2],Crs_MAX_LENGTH_COURSE_FULL_NAME);
/* Get role (row[3]) */ /* Get role (row[3]) */
if (sscanf (row[3],"%u",&Role) != 1) // Role in this course if (sscanf (row[3],"%u",&Role) != 1) // Role in this course
@ -1384,7 +1337,7 @@ int swad__getCourseInfo (struct soap *soap,
Result = Inf_WritePageIntoHTMLBuffer (&(getCourseInfo->infoTxt)); Result = Inf_WritePageIntoHTMLBuffer (&(getCourseInfo->infoTxt));
break; break;
case Inf_INFO_SRC_URL: // Link to a web page case Inf_INFO_SRC_URL: // Link to a web page
getCourseInfo->infoTxt = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_URL+1); getCourseInfo->infoTxt = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_URL + 1);
Inf_WriteURLIntoTxtBuffer (getCourseInfo->infoTxt); Inf_WriteURLIntoTxtBuffer (getCourseInfo->infoTxt);
break; break;
} }
@ -1538,8 +1491,7 @@ int swad__findUsers (struct soap *soap,
Role = Svc_SvcRole_to_RolRole[userRole]; Role = Svc_SvcRole_to_RolRole[userRole];
/***** Query users beloging to course or group from database *****/ /***** Query users beloging to course or group from database *****/
strncpy (Gbl.Search.Str,filter,Sch_MAX_LENGTH_STRING_TO_FIND); Str_Copy (Gbl.Search.Str,filter,Sch_MAX_LENGTH_STRING_TO_FIND);
Gbl.Search.Str[Sch_MAX_LENGTH_STRING_TO_FIND] = '\0';
if (Gbl.Search.Str[0]) // Search some users if (Gbl.Search.Str[0]) // Search some users
{ {
@ -1643,7 +1595,8 @@ int swad__getGroupTypes (struct soap *soap,
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumRow,NumRows; unsigned NumRow;
unsigned NumRows;
long OpenTime; long OpenTime;
/***** Initializations *****/ /***** Initializations *****/
@ -1712,9 +1665,9 @@ int swad__getGroupTypes (struct soap *soap,
getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeCode = (int) Str_ConvertStrCodToLongCod (row[0]); getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeCode = (int) Str_ConvertStrCodToLongCod (row[0]);
/* Get group type name (row[1]) */ /* Get group type name (row[1]) */
getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,256); getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1);
strncpy (getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName,row[1],255); Str_Copy (getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName,
getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName[255] = '\0'; row[1],Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Get whether enrollment is mandatory ('Y') or voluntary ('N') (row[2]) */ /* Get whether enrollment is mandatory ('Y') or voluntary ('N') (row[2]) */
getGroupTypesOut->groupTypesArray.__ptr[NumRow].mandatory = (row[2][0] == 'Y') ? 1 : getGroupTypesOut->groupTypesArray.__ptr[NumRow].mandatory = (row[2][0] == 'Y') ? 1 :
@ -1823,18 +1776,18 @@ int swad__getGroups (struct soap *soap,
getGroupsOut->groupsArray.__ptr[NumRow].groupTypeCode = (int) Str_ConvertStrCodToLongCod (row[0]); getGroupsOut->groupsArray.__ptr[NumRow].groupTypeCode = (int) Str_ConvertStrCodToLongCod (row[0]);
/* Get group type name (row[1]) */ /* Get group type name (row[1]) */
getGroupsOut->groupsArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,256); getGroupsOut->groupsArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1);
strncpy (getGroupsOut->groupsArray.__ptr[NumRow].groupTypeName,row[1],255); Str_Copy (getGroupsOut->groupsArray.__ptr[NumRow].groupTypeName,
getGroupsOut->groupsArray.__ptr[NumRow].groupTypeName[255] = '\0'; row[1],Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Get group code (row[2]) */ /* Get group code (row[2]) */
GrpCod = Str_ConvertStrCodToLongCod (row[2]); GrpCod = Str_ConvertStrCodToLongCod (row[2]);
getGroupsOut->groupsArray.__ptr[NumRow].groupCode = (int) GrpCod; getGroupsOut->groupsArray.__ptr[NumRow].groupCode = (int) GrpCod;
/* Get group name (row[3]) */ /* Get group name (row[3]) */
getGroupsOut->groupsArray.__ptr[NumRow].groupName = (char *) soap_malloc (Gbl.soap,256); getGroupsOut->groupsArray.__ptr[NumRow].groupName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_NAME + 1);
strncpy (getGroupsOut->groupsArray.__ptr[NumRow].groupName,row[3],255); Str_Copy (getGroupsOut->groupsArray.__ptr[NumRow].groupName,
getGroupsOut->groupsArray.__ptr[NumRow].groupName[255] = '\0'; row[3],Grp_MAX_LENGTH_GROUP_NAME);
/* Get max number of students of group (row[4]) and number of current students */ /* Get max number of students of group (row[4]) and number of current students */
MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[4]); MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[4]);
@ -1984,18 +1937,18 @@ int swad__sendMyGroups (struct soap *soap,
SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeCode = (int) Str_ConvertStrCodToLongCod (row[0]); SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeCode = (int) Str_ConvertStrCodToLongCod (row[0]);
/* Get group type name (row[1]) */ /* Get group type name (row[1]) */
SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,256); SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1);
strncpy (SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeName,row[1],255); Str_Copy (SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeName,
SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeName[255] = '\0'; row[1],Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Get group code (row[2]) */ /* Get group code (row[2]) */
GrpCod = Str_ConvertStrCodToLongCod (row[2]); GrpCod = Str_ConvertStrCodToLongCod (row[2]);
SendMyGroupsOut->groupsArray.__ptr[NumRow].groupCode = (int) GrpCod; SendMyGroupsOut->groupsArray.__ptr[NumRow].groupCode = (int) GrpCod;
/* Get group name (row[3]) */ /* Get group name (row[3]) */
SendMyGroupsOut->groupsArray.__ptr[NumRow].groupName = (char *) soap_malloc (Gbl.soap,256); SendMyGroupsOut->groupsArray.__ptr[NumRow].groupName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_NAME + 1);
strncpy (SendMyGroupsOut->groupsArray.__ptr[NumRow].groupName,row[3],255); Str_Copy (SendMyGroupsOut->groupsArray.__ptr[NumRow].groupName,
SendMyGroupsOut->groupsArray.__ptr[NumRow].groupName[255] = '\0'; row[3],Grp_MAX_LENGTH_GROUP_NAME);
/* Get max number of students of group (row[4]) and number of current students */ /* Get max number of students of group (row[4]) and number of current students */
MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[4]); MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[4]);
@ -2031,7 +1984,7 @@ int swad__sendMyGroups (struct soap *soap,
static void Svc_CopyUsrData (struct swad__user *Usr,struct UsrData *UsrDat,bool UsrIDIsVisible) static void Svc_CopyUsrData (struct swad__user *Usr,struct UsrData *UsrDat,bool UsrIDIsVisible)
{ {
char PhotoURL[PATH_MAX+1]; char PhotoURL[Cns_MAX_BYTES_URL + 1];
const char *FirstID; const char *FirstID;
/* Copy user's code */ /* Copy user's code */
@ -2063,7 +2016,7 @@ static void Svc_CopyUsrData (struct swad__user *Usr,struct UsrData *UsrDat,bool
/* User's photo URL */ /* User's photo URL */
Pho_BuildLinkToPhoto (UsrDat,PhotoURL); Pho_BuildLinkToPhoto (UsrDat,PhotoURL);
Usr->userPhoto = (char *) soap_malloc (Gbl.soap,strlen (PhotoURL) + 1); Usr->userPhoto = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_URL + 1);
strcpy (Usr->userPhoto,PhotoURL); strcpy (Usr->userPhoto,PhotoURL);
} }
@ -2081,7 +2034,7 @@ int swad__getAttendanceEvents (struct soap *soap,
MYSQL_ROW row; MYSQL_ROW row;
int NumAttEvent; int NumAttEvent;
long AttCod; long AttCod;
char PhotoURL[PATH_MAX+1]; char PhotoURL[Cns_MAX_BYTES_URL + 1];
long StartTime; long StartTime;
long EndTime; long EndTime;
size_t Length; size_t Length;
@ -2357,8 +2310,7 @@ int swad__sendAttendanceEvent (struct soap *soap,
return soap_receiver_fault (Gbl.soap, return soap_receiver_fault (Gbl.soap,
"Request forbidden", "Request forbidden",
"Title of attendance event is empty"); "Title of attendance event is empty");
strncpy (Att.Title,title,Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE); Str_Copy (Att.Title,title,Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE);
Att.Title[Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE] = '\0';
/* Create a list of groups selected */ /* Create a list of groups selected */
Svc_GetLstGrpsSel (groups); Svc_GetLstGrpsSel (groups);
@ -2498,7 +2450,7 @@ int swad__getAttendanceUsers (struct soap *soap,
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumRow,NumRows; unsigned NumRow,NumRows;
char PhotoURL[PATH_MAX+1]; char PhotoURL[Cns_MAX_BYTES_URL + 1];
size_t Length; size_t Length;
/***** Initializations *****/ /***** Initializations *****/
@ -2797,7 +2749,7 @@ int swad__getNotifications (struct soap *soap,
long NtfCod; long NtfCod;
Ntf_NotifyEvent_t NotifyEvent; Ntf_NotifyEvent_t NotifyEvent;
long EventTime; long EventTime;
char PhotoURL[PATH_MAX+1]; char PhotoURL[Cns_MAX_BYTES_URL + 1];
struct Instit Ins; struct Instit Ins;
struct Centre Ctr; struct Centre Ctr;
struct Degree Deg; struct Degree Deg;
@ -2859,9 +2811,9 @@ int swad__getNotifications (struct soap *soap,
/* Get notification event type (row[1]) */ /* Get notification event type (row[1]) */
NotifyEvent = Ntf_GetNotifyEventFromDB ((const char *) row[1]); NotifyEvent = Ntf_GetNotifyEventFromDB ((const char *) row[1]);
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType = (char *) soap_malloc (Gbl.soap,256); getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType = (char *) soap_malloc (Gbl.soap,Ntf_MAX_LENGTH_NOTIFY_EVENT + 1);
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType,Ntf_WSNotifyEvents[NotifyEvent],255); Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType,
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType[255] = '\0'; Ntf_WSNotifyEvents[NotifyEvent],Ntf_MAX_LENGTH_NOTIFY_EVENT);
/* Get time of the event (row[2]) */ /* Get time of the event (row[2]) */
EventTime = 0L; EventTime = 0L;
@ -2878,26 +2830,27 @@ int swad__getNotifications (struct soap *soap,
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Crs.CrsCod)) // Get some user's data from database if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Crs.CrsCod)) // Get some user's data from database
{ {
getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1); getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA + 1);
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname,Gbl.Usrs.Other.UsrDat.Nickname,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA); Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname,
getNotificationsOut->notificationsArray.__ptr[NumNotif].userNickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0'; Gbl.Usrs.Other.UsrDat.Nickname,
Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 ,Gbl.Usrs.Other.UsrDat.Surname1 ,Usr_MAX_BYTES_NAME); Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1,
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 [Usr_MAX_BYTES_NAME] = '\0'; Gbl.Usrs.Other.UsrDat.Surname1 ,Usr_MAX_BYTES_NAME);
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 ,Gbl.Usrs.Other.UsrDat.Surname2 ,Usr_MAX_BYTES_NAME); Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2,
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 [Usr_MAX_BYTES_NAME] = '\0'; Gbl.Usrs.Other.UsrDat.Surname2 ,Usr_MAX_BYTES_NAME);
getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname,Gbl.Usrs.Other.UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname,
getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname[Usr_MAX_BYTES_NAME] = '\0'; Gbl.Usrs.Other.UsrDat.FirstName,Usr_MAX_BYTES_NAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto = (char *) soap_malloc (Gbl.soap,PATH_MAX+1); getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_URL + 1);
strncpy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto,PhotoURL,PATH_MAX); Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto,
getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto[PATH_MAX] = '\0'; PhotoURL,Cns_MAX_BYTES_URL);
} }
else else
{ {
@ -2925,7 +2878,7 @@ int swad__getNotifications (struct soap *soap,
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventCode = (int) Cod; getNotificationsOut->notificationsArray.__ptr[NumNotif].eventCode = (int) Cod;
/* Set location */ /* Set location */
getNotificationsOut->notificationsArray.__ptr[NumNotif].location = (char *) soap_malloc (Gbl.soap,1024); getNotificationsOut->notificationsArray.__ptr[NumNotif].location = (char *) soap_malloc (Gbl.soap,Ntf_MAX_LENGTH_NOTIFY_LOCATION + 1);
if (NotifyEvent == Ntf_EVENT_FORUM_POST_COURSE || if (NotifyEvent == Ntf_EVENT_FORUM_POST_COURSE ||
NotifyEvent == Ntf_EVENT_FORUM_REPLY) NotifyEvent == Ntf_EVENT_FORUM_REPLY)
@ -3489,7 +3442,7 @@ int swad__getTestConfig (struct soap *soap,
/***** Set default result to empty *****/ /***** Set default result to empty *****/
getTestConfigOut->numQuestions = getTestConfigOut->minQuestions = getTestConfigOut->defQuestions = getTestConfigOut->maxQuestions = 0; getTestConfigOut->numQuestions = getTestConfigOut->minQuestions = getTestConfigOut->defQuestions = getTestConfigOut->maxQuestions = 0;
getTestConfigOut->feedback = (char *) soap_malloc (Gbl.soap,256); getTestConfigOut->feedback = (char *) soap_malloc (Gbl.soap,Tst_MAX_LENGTH_FEEDBACK_TYPE + 1);
getTestConfigOut->feedback[0] = '\0'; getTestConfigOut->feedback[0] = '\0';
/***** Get test configuration *****/ /***** Get test configuration *****/
@ -3500,10 +3453,9 @@ int swad__getTestConfig (struct soap *soap,
getTestConfigOut->minQuestions = (int) Gbl.Test.Config.Min; getTestConfigOut->minQuestions = (int) Gbl.Test.Config.Min;
getTestConfigOut->defQuestions = (int) Gbl.Test.Config.Def; getTestConfigOut->defQuestions = (int) Gbl.Test.Config.Def;
getTestConfigOut->maxQuestions = (int) Gbl.Test.Config.Max; getTestConfigOut->maxQuestions = (int) Gbl.Test.Config.Max;
// if (Gbl.Test.Config.FeedbackType == Tst_FEEDBACK_FULL_FEEDBACK) Str_Copy (getTestConfigOut->feedback,
// Gbl.Test.Config.FeedbackType = Tst_FEEDBACK_EACH_GOOD_BAD; // TODO: remove this when SWADroid uses it Tst_FeedbackXML[Gbl.Test.Config.FeedbackType],
strncpy (getTestConfigOut->feedback,Tst_FeedbackXML[Gbl.Test.Config.FeedbackType],255); Tst_MAX_LENGTH_FEEDBACK_TYPE);
getTestConfigOut->feedback[255] = '\0';
/***** Get number of tests *****/ /***** Get number of tests *****/
if (Gbl.Test.Config.Pluggable == Tst_PLUGGABLE_YES && if (Gbl.Test.Config.Pluggable == Tst_PLUGGABLE_YES &&
@ -3665,7 +3617,8 @@ static int Svc_GetTstTags (long CrsCod,struct swad__getTestsOutput *getTestsOut)
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumRow,NumRows; unsigned NumRow;
unsigned NumRows;
/***** Get available tags from database *****/ /***** Get available tags from database *****/
sprintf (Query,"SELECT TagCod,TagTxt" sprintf (Query,"SELECT TagCod,TagTxt"
@ -3694,9 +3647,9 @@ static int Svc_GetTstTags (long CrsCod,struct swad__getTestsOutput *getTestsOut)
getTestsOut->tagsArray.__ptr[NumRow].tagCode = (int) Str_ConvertStrCodToLongCod (row[0]); getTestsOut->tagsArray.__ptr[NumRow].tagCode = (int) Str_ConvertStrCodToLongCod (row[0]);
/* Get tag text (row[1]) */ /* Get tag text (row[1]) */
getTestsOut->tagsArray.__ptr[NumRow].tagText = (char *) soap_malloc (Gbl.soap,256); getTestsOut->tagsArray.__ptr[NumRow].tagText = (char *) soap_malloc (Gbl.soap,Tst_MAX_BYTES_TAG + 1);
strncpy (getTestsOut->tagsArray.__ptr[NumRow].tagText,row[1],255); Str_Copy (getTestsOut->tagsArray.__ptr[NumRow].tagText,row[1],
getTestsOut->tagsArray.__ptr[NumRow].tagText[255] = '\0'; Tst_MAX_BYTES_TAG);
} }
} }
@ -3766,23 +3719,23 @@ static int Svc_GetTstQuestions (long CrsCod,long BeginTime,struct swad__getTests
/* Get answer type (row[1]) */ /* Get answer type (row[1]) */
AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
getTestsOut->questionsArray.__ptr[NumRow].answerType = (char *) soap_malloc (Gbl.soap,256); getTestsOut->questionsArray.__ptr[NumRow].answerType = (char *) soap_malloc (Gbl.soap,Tst_MAX_LENGTH_ANSWER_TYPE + 1);
strncpy (getTestsOut->questionsArray.__ptr[NumRow].answerType,Tst_StrAnswerTypesXML[AnswerType],255); Str_Copy (getTestsOut->questionsArray.__ptr[NumRow].answerType,
getTestsOut->questionsArray.__ptr[NumRow].answerType[255] = '\0'; Tst_StrAnswerTypesXML[AnswerType],Tst_MAX_LENGTH_ANSWER_TYPE);
/* Get shuffle (row[2]) */ /* Get shuffle (row[2]) */
getTestsOut->questionsArray.__ptr[NumRow].shuffle = (row[2][0] == 'Y') ? 1 : getTestsOut->questionsArray.__ptr[NumRow].shuffle = (row[2][0] == 'Y') ? 1 :
0; 0;
/* Get question stem (row[3]) */ /* Get question stem (row[3]) */
getTestsOut->questionsArray.__ptr[NumRow].stem = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT+1); getTestsOut->questionsArray.__ptr[NumRow].stem = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
strncpy (getTestsOut->questionsArray.__ptr[NumRow].stem,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (getTestsOut->questionsArray.__ptr[NumRow].stem,row[3],
getTestsOut->questionsArray.__ptr[NumRow].stem[Cns_MAX_BYTES_TEXT] = '\0'; Cns_MAX_BYTES_TEXT);
/* Get question feedback (row[4]) */ /* Get question feedback (row[4]) */
getTestsOut->questionsArray.__ptr[NumRow].feedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT+1); getTestsOut->questionsArray.__ptr[NumRow].feedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
strncpy (getTestsOut->questionsArray.__ptr[NumRow].feedback,row[4],Cns_MAX_BYTES_TEXT); Str_Copy (getTestsOut->questionsArray.__ptr[NumRow].feedback,row[4],
getTestsOut->questionsArray.__ptr[NumRow].feedback[Cns_MAX_BYTES_TEXT] = '\0'; Cns_MAX_BYTES_TEXT);
} }
} }
@ -3860,14 +3813,14 @@ static int Svc_GetTstAnswers (long CrsCod,long BeginTime,struct swad__getTestsOu
0; 0;
/* Get answer (row[3]) */ /* Get answer (row[3]) */
getTestsOut->answersArray.__ptr[NumRow].answerText = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT+1); getTestsOut->answersArray.__ptr[NumRow].answerText = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
strncpy (getTestsOut->answersArray.__ptr[NumRow].answerText,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerText,
getTestsOut->answersArray.__ptr[NumRow].answerText[Cns_MAX_BYTES_TEXT] = '\0'; row[3],Cns_MAX_BYTES_TEXT);
/* Get feedback (row[4]) */ /* Get feedback (row[4]) */
getTestsOut->answersArray.__ptr[NumRow].answerFeedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT+1); getTestsOut->answersArray.__ptr[NumRow].answerFeedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
strncpy (getTestsOut->answersArray.__ptr[NumRow].answerFeedback,row[4],Cns_MAX_BYTES_TEXT); Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerFeedback,
getTestsOut->answersArray.__ptr[NumRow].answerFeedback[Cns_MAX_BYTES_TEXT] = '\0'; row[4],Cns_MAX_BYTES_TEXT);
} }
} }
@ -4092,35 +4045,26 @@ int swad__getTrivialQuestion (struct soap *soap,
/* Get answer type (row[1]) */ /* Get answer type (row[1]) */
AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
getTrivialQuestionOut->question.answerType = (char *) soap_malloc (Gbl.soap,256); getTrivialQuestionOut->question.answerType = (char *) soap_malloc (Gbl.soap,Tst_MAX_LENGTH_ANSWER_TYPE + 1);
strncpy (getTrivialQuestionOut->question.answerType,Tst_StrAnswerTypesXML[AnswerType],255); Str_Copy (getTrivialQuestionOut->question.answerType,
getTrivialQuestionOut->question.answerType[255] = '\0'; Tst_StrAnswerTypesXML[AnswerType],Tst_MAX_LENGTH_ANSWER_TYPE);
/* Get shuffle (row[2]) */ /* Get shuffle (row[2]) */
getTrivialQuestionOut->question.shuffle = (row[2][0] == 'Y') ? 1 : getTrivialQuestionOut->question.shuffle = (row[2][0] == 'Y') ? 1 :
0; 0;
/* Get question stem (row[3]) */ /* Get question stem (row[3]) */
getTrivialQuestionOut->question.stem = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT+1); getTrivialQuestionOut->question.stem = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
strncpy (getTrivialQuestionOut->question.stem,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (getTrivialQuestionOut->question.stem,row[3],
getTrivialQuestionOut->question.stem[Cns_MAX_BYTES_TEXT] = '\0'; Cns_MAX_BYTES_TEXT);
/* Get question feedback (row[4]) */ /* Get question feedback (row[4]) */
getTrivialQuestionOut->question.feedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT+1); getTrivialQuestionOut->question.feedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
strncpy (getTrivialQuestionOut->question.feedback,row[4],Cns_MAX_BYTES_TEXT); Str_Copy (getTrivialQuestionOut->question.feedback,row[4],
getTrivialQuestionOut->question.feedback[Cns_MAX_BYTES_TEXT] = '\0'; Cns_MAX_BYTES_TEXT);
} }
else // Empty question else // Empty question
{ {
/*
if (Gbl.Usrs.Me.UsrDat.UsrCod == 19543)
{
char QueryDebug[512*1024];
sprintf (QueryDebug,"INSERT INTO debug (DebugTime,Txt) VALUES (NOW(),'Ninguna pregunta devuelta')");
DB_QueryINSERT (QueryDebug,"Error inserting in debug table");
}
*/
/* Question code (row[0]) */ /* Question code (row[0]) */
QstCod = -1L; QstCod = -1L;
getTrivialQuestionOut->question.questionCode = -1; getTrivialQuestionOut->question.questionCode = -1;
@ -4182,14 +4126,14 @@ int swad__getTrivialQuestion (struct soap *soap,
0; 0;
/* Get answer (row[3]) */ /* Get answer (row[3]) */
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT+1); getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
strncpy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText,
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText[Cns_MAX_BYTES_TEXT] = '\0'; row[3],Cns_MAX_BYTES_TEXT);
/* Get feedback (row[4]) */ /* Get feedback (row[4]) */
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT+1); getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
strncpy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback,row[4],Cns_MAX_BYTES_TEXT); Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback,
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback[Cns_MAX_BYTES_TEXT] = '\0'; row[4],Cns_MAX_BYTES_TEXT);
} }
} }
@ -4421,7 +4365,7 @@ static bool Svc_WriteRowFileBrowser (unsigned Level,Brw_FileType_t FileType,cons
extern const char *Txt_NEW_LINE; extern const char *Txt_NEW_LINE;
extern const char *Txt_LICENSES[Brw_NUM_LICENSES]; extern const char *Txt_LICENSES[Brw_NUM_LICENSES];
struct FileMetadata FileMetadata; struct FileMetadata FileMetadata;
char PhotoURL[PATH_MAX+1]; char PhotoURL[Cns_MAX_BYTES_URL + 1];
/***** Is this row hidden or visible? *****/ /***** Is this row hidden or visible? *****/
if (Gbl.FileBrowser.Type == Brw_SHOW_DOCUM_CRS || if (Gbl.FileBrowser.Type == Brw_SHOW_DOCUM_CRS ||
@ -4497,19 +4441,19 @@ int swad__getFile (struct soap *soap,
extern const char *Txt_LICENSES[Brw_NUM_LICENSES]; extern const char *Txt_LICENSES[Brw_NUM_LICENSES];
int ReturnCode; int ReturnCode;
struct FileMetadata FileMetadata; struct FileMetadata FileMetadata;
char URL[PATH_MAX+1]; char URL[Cns_MAX_BYTES_URL + 1];
char PhotoURL[PATH_MAX+1]; char PhotoURL[Cns_MAX_BYTES_URL + 1];
/***** Initializations *****/ /***** Initializations *****/
Gbl.soap = soap; Gbl.soap = soap;
Gbl.WebService.Function = Svc_getFile; Gbl.WebService.Function = Svc_getFile;
/***** Allocate space for strings *****/ /***** Allocate space for strings *****/
getFileOut->fileName = (char *) soap_malloc (Gbl.soap,NAME_MAX+1); getFileOut->fileName = (char *) soap_malloc (Gbl.soap,NAME_MAX + 1);
getFileOut->URL = (char *) soap_malloc (Gbl.soap,PATH_MAX+1); getFileOut->URL = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_URL + 1);
getFileOut->license = (char *) soap_malloc (Gbl.soap,256); getFileOut->license = (char *) soap_malloc (Gbl.soap,Brw_MAX_LENGTH_LICENSE + 1);
getFileOut->publisherName = (char *) soap_malloc (Gbl.soap,255+1+255+1+255+1); getFileOut->publisherName = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_FULL_NAME + 1);
getFileOut->publisherPhoto = (char *) soap_malloc (Gbl.soap,PATH_MAX+1); getFileOut->publisherPhoto = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_URL + 1);
/***** Default values returned on error *****/ /***** Default values returned on error *****/
getFileOut->fileName[0] = '\0'; getFileOut->fileName[0] = '\0';
@ -4615,30 +4559,27 @@ int swad__getFile (struct soap *soap,
URL); URL);
/***** Copy data into output structure *****/ /***** Copy data into output structure *****/
strncpy (getFileOut->fileName,FileMetadata.FilFolLnkName,NAME_MAX); Str_Copy (getFileOut->fileName,FileMetadata.FilFolLnkName,NAME_MAX);
getFileOut->fileName[NAME_MAX] = '\0';
strncpy (getFileOut->URL,URL,PATH_MAX); Str_Copy (getFileOut->URL,URL,Cns_MAX_BYTES_URL);
getFileOut->URL[PATH_MAX] = '\0';
getFileOut->size = (int) FileMetadata.Size; getFileOut->size = (int) FileMetadata.Size;
getFileOut->time = (int) FileMetadata.Time; getFileOut->time = (int) FileMetadata.Time;
strncpy (getFileOut->license,Txt_LICENSES[FileMetadata.License],255); Str_Copy (getFileOut->license,Txt_LICENSES[FileMetadata.License],
getFileOut->license[255] = '\0'; Brw_MAX_LENGTH_LICENSE);
if ((Gbl.Usrs.Other.UsrDat.UsrCod = FileMetadata.PublisherUsrCod) > 0) if ((Gbl.Usrs.Other.UsrDat.UsrCod = FileMetadata.PublisherUsrCod) > 0)
/* Get publisher's data */ /* Get publisher's data */
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
/* Copy publisher's data into output structure */ /* Copy publisher's data into output structure */
{ {
strncpy (getFileOut->publisherName,Gbl.Usrs.Other.UsrDat.FullName,255+1+255+1+255); Str_Copy (getFileOut->publisherName,Gbl.Usrs.Other.UsrDat.FullName,
getFileOut->publisherName[255+1+255+1+255] = '\0'; Usr_MAX_BYTES_FULL_NAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
strncpy (getFileOut->publisherPhoto,PhotoURL,PATH_MAX); Str_Copy (getFileOut->publisherPhoto,PhotoURL,Cns_MAX_BYTES_URL);
getFileOut->publisherPhoto[PATH_MAX] = '\0';
} }
return SOAP_OK; return SOAP_OK;

View File

@ -180,8 +180,7 @@ static void XML_GetElement (struct XMLElement *ParentElem)
{ {
if ((ParentElem->Content = malloc (ContentLength+1)) == NULL) if ((ParentElem->Content = malloc (ContentLength+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory."); Lay_ShowErrorAndExit ("Not enough memory.");
strncpy (ParentElem->Content,StartContent,ContentLength); Str_Copy (ParentElem->Content,StartContent,ContentLength);
ParentElem->Content[ContentLength] = '\0';
ParentElem->ContentLength = ContentLength; ParentElem->ContentLength = ContentLength;
} }
@ -217,8 +216,7 @@ static void XML_GetElement (struct XMLElement *ParentElem)
ChildElem->TagNameLength = strcspn (Gbl.XMLPtr,">/ \t"); ChildElem->TagNameLength = strcspn (Gbl.XMLPtr,">/ \t");
if ((ChildElem->TagName = malloc (ChildElem->TagNameLength+1)) == NULL) if ((ChildElem->TagName = malloc (ChildElem->TagNameLength+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory."); Lay_ShowErrorAndExit ("Not enough memory.");
strncpy (ChildElem->TagName,Gbl.XMLPtr,ChildElem->TagNameLength); Str_Copy (ChildElem->TagName,Gbl.XMLPtr,ChildElem->TagNameLength);
ChildElem->TagName[ChildElem->TagNameLength] = '\0';
Gbl.XMLPtr += ChildElem->TagNameLength; Gbl.XMLPtr += ChildElem->TagNameLength;
/* /*
@ -337,8 +335,7 @@ static void XML_GetAttributes (struct XMLElement *Elem)
Attribute->AttributeNameLength = strcspn (Gbl.XMLPtr,"="); Attribute->AttributeNameLength = strcspn (Gbl.XMLPtr,"=");
if ((Attribute->AttributeName = malloc (Attribute->AttributeNameLength+1)) == NULL) if ((Attribute->AttributeName = malloc (Attribute->AttributeNameLength+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory."); Lay_ShowErrorAndExit ("Not enough memory.");
strncpy (Attribute->AttributeName,Gbl.XMLPtr,Attribute->AttributeNameLength); Str_Copy (Attribute->AttributeName,Gbl.XMLPtr,Attribute->AttributeNameLength);
Attribute->AttributeName[Attribute->AttributeNameLength] = '\0';
Gbl.XMLPtr += Attribute->AttributeNameLength; Gbl.XMLPtr += Attribute->AttributeNameLength;
/* End of attribute name: /* End of attribute name:
<parent><child attribute1="value" attribute2="value">...</child>...</parent> <parent><child attribute1="value" attribute2="value">...</child>...</parent>
@ -367,8 +364,7 @@ static void XML_GetAttributes (struct XMLElement *Elem)
if ((Attribute->Content = malloc (Attribute->ContentLength+1)) == NULL) if ((Attribute->Content = malloc (Attribute->ContentLength+1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory."); Lay_ShowErrorAndExit ("Not enough memory.");
strncpy (Attribute->Content,Gbl.XMLPtr,Attribute->ContentLength); Str_Copy (Attribute->Content,Gbl.XMLPtr,Attribute->ContentLength);
Attribute->Content[Attribute->ContentLength] = '\0';
Gbl.XMLPtr += Attribute->ContentLength; Gbl.XMLPtr += Attribute->ContentLength;
Gbl.XMLPtr++; Gbl.XMLPtr++;

View File

@ -598,12 +598,11 @@ static void ZIP_ShowLinkToDownloadZIP (const char *FileName,const char *URL,
extern const char *Txt_Filename; extern const char *Txt_Filename;
extern const char *Txt_File_size; extern const char *Txt_File_size;
extern const char *Txt_FILE_uncompressed; extern const char *Txt_FILE_uncompressed;
char FileNameShort[NAME_MAX+1]; char FileNameShort[NAME_MAX + 1];
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING]; char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1];
/***** Limit length of the name of the file *****/ /***** Limit length of the name of the file *****/
strncpy (FileNameShort,FileName,NAME_MAX); Str_Copy (FileNameShort,FileName,NAME_MAX);
FileNameShort[NAME_MAX] = '\0';
Str_LimitLengthHTMLStr (FileNameShort,50); Str_LimitLengthHTMLStr (FileNameShort,50);
/***** Start frame *****/ /***** Start frame *****/