From 08f6026aee86be1a80459e1f88a4e86aafd3e050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 8 Mar 2017 14:12:33 +0100 Subject: [PATCH] Version 16.154 --- swad_MFU.c | 8 ++--- swad_QR.c | 4 +-- swad_action.h | 5 +-- swad_agenda.h | 8 ++--- swad_assignment.c | 4 +-- swad_assignment.h | 7 +++-- swad_attendance.h | 4 +-- swad_banner.h | 10 +++--- swad_centre.c | 46 +++++++++++++-------------- swad_centre.h | 13 ++------ swad_changelog.h | 4 ++- swad_chat.c | 8 ++--- swad_connected.c | 4 +-- swad_constant.h | 15 ++++----- swad_country.c | 46 +++++++++++++-------------- swad_country.h | 11 ++----- swad_course.c | 48 ++++++++++++++-------------- swad_course.h | 14 +++------ swad_database.c | 76 ++++++++++++++++++++++----------------------- swad_degree.c | 34 ++++++++++---------- swad_degree.h | 11 ++----- swad_degree_type.h | 4 +-- swad_department.c | 30 +++++++++--------- swad_department.h | 12 +++---- swad_enrollment.c | 8 ++--- swad_enrollment.h | 5 +-- swad_exam.c | 30 +++++++++++------- swad_exam.h | 10 ++++-- swad_file_browser.c | 4 +-- swad_file_browser.h | 9 +++--- swad_follow.c | 2 +- swad_follow.h | 3 +- swad_forum.c | 10 +++--- swad_forum.h | 3 +- swad_global.h | 4 +-- swad_group.h | 8 ++--- swad_hierarchy.h | 6 ++++ swad_holiday.h | 4 +-- swad_image.c | 8 ++--- swad_image.h | 7 +++-- swad_institution.c | 62 ++++++++++++++++++------------------ swad_institution.h | 10 ++---- swad_link.h | 8 ++--- swad_mail.h | 8 ++--- swad_mark.c | 2 +- swad_mark.h | 2 +- swad_message.c | 16 +++++----- swad_message.h | 6 ++-- swad_notice.c | 10 +++--- swad_notice.h | 2 +- swad_notification.c | 4 +-- swad_notification.h | 11 ++++--- swad_place.h | 8 ++--- swad_plugin.h | 16 +++++----- swad_record.c | 18 +++++------ swad_record.h | 4 +-- swad_report.c | 2 +- swad_search.h | 8 ++--- swad_social.c | 16 +++++----- swad_social.h | 2 +- swad_string.h | 3 +- swad_survey.c | 8 ++--- swad_survey.h | 6 ++-- swad_syllabus.c | 4 +-- swad_test.c | 8 +++-- swad_test.h | 8 ++--- swad_theme.c | 6 ++-- swad_timetable.h | 4 +-- swad_user.c | 8 ++--- swad_user.h | 23 ++++++++------ swad_web_service.c | 20 ++++++------ 71 files changed, 430 insertions(+), 430 deletions(-) diff --git a/swad_MFU.c b/swad_MFU.c index 74c8bc09..719507d0 100644 --- a/swad_MFU.c +++ b/swad_MFU.c @@ -45,11 +45,11 @@ /***************************** Private constants *****************************/ /*****************************************************************************/ -#define MFU_MAX_CHARS_TAB (128 - 1) -#define MFU_MAX_BYTES_TAB (MFU_MAX_CHARS_TAB * Str_MAX_BYTES_PER_CHAR) +#define MFU_MAX_CHARS_TAB (128 - 1) // 127 +#define MFU_MAX_BYTES_TAB ((MFU_MAX_CHARS_TAB + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 -#define MFU_MAX_CHARS_MENU (128 - 1) -#define MFU_MAX_BYTES_MENU (MFU_MAX_CHARS_MENU * Str_MAX_BYTES_PER_CHAR) +#define MFU_MAX_CHARS_MENU (128 - 1) // 127 +#define MFU_MAX_BYTES_MENU ((MFU_MAX_CHARS_MENU + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 /*****************************************************************************/ /****************************** Internal types *******************************/ diff --git a/swad_QR.c b/swad_QR.c index 2a2d2f32..96270427 100644 --- a/swad_QR.c +++ b/swad_QR.c @@ -90,10 +90,10 @@ void QR_PutParamQRString (void) void QR_PrintQRCode (void) { - char QRString[Cns_MAX_BYTES_STRING + 1]; + char QRString[Cns_MAX_BYTES_WWW + 1]; /***** Get QR string *****/ - Par_GetParToText ("QRString",QRString,Cns_MAX_BYTES_STRING); + Par_GetParToText ("QRString",QRString,Cns_MAX_BYTES_WWW); /***** Show QR code *****/ QR_ImageQRCode (QRString); diff --git a/swad_action.h b/swad_action.h index 3f1c0afa..494782c9 100644 --- a/swad_action.h +++ b/swad_action.h @@ -30,6 +30,7 @@ #include // For boolean type #include "swad_cryptography.h" +#include "swad_string.h" #include "swad_tab.h" #include "swad_text.h" @@ -37,8 +38,8 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Act_MAX_CHARS_ACTION_TXT (256 - 1) -#define Act_MAX_BYTES_ACTION_TXT Act_MAX_CHARS_ACTION_TXT +#define Act_MAX_CHARS_ACTION_TXT (64 - 1) // 63 +#define Act_MAX_BYTES_ACTION_TXT ((Act_MAX_CHARS_ACTION_TXT + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 1023 typedef enum { diff --git a/swad_agenda.h b/swad_agenda.h index f4cd49c4..76723c09 100644 --- a/swad_agenda.h +++ b/swad_agenda.h @@ -34,11 +34,11 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Agd_MAX_CHARS_LOCATION (256 - 1) -#define Agd_MAX_BYTES_LOCATION (Agd_MAX_CHARS_LOCATION * Str_MAX_BYTES_PER_CHAR) +#define Agd_MAX_CHARS_LOCATION (128 - 1) // 127 +#define Agd_MAX_BYTES_LOCATION ((Agd_MAX_CHARS_LOCATION + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 -#define Agd_MAX_CHARS_EVENT (256 - 1) -#define Agd_MAX_BYTES_EVENT (Agd_MAX_CHARS_EVENT * Str_MAX_BYTES_PER_CHAR) +#define Agd_MAX_CHARS_EVENT (128 - 1) // 127 +#define Agd_MAX_BYTES_EVENT ((Agd_MAX_CHARS_EVENT + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Agd_NUM_DATES 2 typedef enum diff --git a/swad_assignment.c b/swad_assignment.c index bafd9e4b..c61a9d54 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -830,7 +830,7 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT /*****************************************************************************/ // This function may be called inside a web service -void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long AsgCod,bool GetContent) { @@ -855,7 +855,7 @@ void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], /***** Get summary *****/ Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); /***** Get content *****/ if (GetContent) diff --git a/swad_assignment.h b/swad_assignment.h index b3adf5cb..8d1375b0 100644 --- a/swad_assignment.h +++ b/swad_assignment.h @@ -28,14 +28,15 @@ /*****************************************************************************/ #include "swad_date.h" +#include "swad_notification.h" #include "swad_user.h" /*****************************************************************************/ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Asg_MAX_CHARS_ASSIGNMENT_TITLE (256 - 1) -#define Asg_MAX_BYTES_ASSIGNMENT_TITLE (Asg_MAX_CHARS_ASSIGNMENT_TITLE * Str_MAX_BYTES_PER_CHAR) +#define Asg_MAX_CHARS_ASSIGNMENT_TITLE (128 - 1) // 127 +#define Asg_MAX_BYTES_ASSIGNMENT_TITLE ((Asg_MAX_CHARS_ASSIGNMENT_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Asg_MAX_CHARS_FOLDER 32 #define Asg_MAX_BYTES_FOLDER Asg_MAX_CHARS_FOLDER @@ -77,7 +78,7 @@ void Asg_GetDataOfAssignmentByCod (struct Assignment *Asg); void Asg_GetDataOfAssignmentByFolder (struct Assignment *Asg); void Asg_FreeListAssignments (void); -void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long AsgCod,bool GetContent); diff --git a/swad_attendance.h b/swad_attendance.h index 2977b1fc..f44a38f8 100644 --- a/swad_attendance.h +++ b/swad_attendance.h @@ -34,8 +34,8 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Att_MAX_CHARS_ATTENDANCE_EVENT_TITLE (256 - 1) -#define Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE (Att_MAX_CHARS_ATTENDANCE_EVENT_TITLE * Str_MAX_BYTES_PER_CHAR) +#define Att_MAX_CHARS_ATTENDANCE_EVENT_TITLE (128 - 1) // 127 +#define Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE ((Att_MAX_CHARS_ATTENDANCE_EVENT_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Att_NUM_DATES 2 typedef enum diff --git a/swad_banner.h b/swad_banner.h index c317281a..2f8b0d6e 100644 --- a/swad_banner.h +++ b/swad_banner.h @@ -33,13 +33,13 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Ban_MAX_CHARS_SHRT_NAME 32 -#define Ban_MAX_BYTES_SHRT_NAME (Ban_MAX_CHARS_SHRT_NAME * Str_MAX_BYTES_PER_CHAR) +#define Ban_MAX_CHARS_SHRT_NAME (32 - 1) // 31 +#define Ban_MAX_BYTES_SHRT_NAME ((Ban_MAX_CHARS_SHRT_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 -#define Ban_MAX_CHARS_FULL_NAME (128 - 1) -#define Ban_MAX_BYTES_FULL_NAME (Ban_MAX_CHARS_FULL_NAME * Str_MAX_BYTES_PER_CHAR) +#define Ban_MAX_CHARS_FULL_NAME (128 - 1) // 127 +#define Ban_MAX_BYTES_FULL_NAME ((Ban_MAX_CHARS_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 -#define Ban_MAX_CHARS_IMAGE (256 - 1) +#define Ban_MAX_CHARS_IMAGE NAME_MAX #define Ban_MAX_BYTES_IMAGE Ban_MAX_CHARS_IMAGE struct Banner diff --git a/swad_centre.c b/swad_centre.c index 6dda6d65..c47cc9cf 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -436,7 +436,7 @@ static void Ctr_Configuration (bool PrintView) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_FULL_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Ctr_MAX_CHARS_CENTRE_FULL_NAME, + Hie_MAX_CHARS_FULL_NAME, Gbl.CurrentCtr.Ctr.FullName, Gbl.Form.Id); Act_FormEnd (); @@ -465,7 +465,7 @@ static void Ctr_Configuration (bool PrintView) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_SHORT_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Ctr_MAX_CHARS_CENTRE_SHRT_NAME, + Hie_MAX_CHARS_SHRT_NAME, Gbl.CurrentCtr.Ctr.ShrtName, Gbl.Form.Id); Act_FormEnd (); @@ -1036,11 +1036,11 @@ void Ctr_GetListCentres (long InsCod) /* Get the short name of the centre (row[5]) */ Str_Copy (Ctr->ShrtName,row[5], - Ctr_MAX_BYTES_CENTRE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); /* Get the full name of the centre (row[6]) */ Str_Copy (Ctr->FullName,row[6], - Ctr_MAX_BYTES_CENTRE_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /* Get the URL of the centre (row[7]) */ Str_Copy (Ctr->WWW,row[7], @@ -1134,11 +1134,11 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr) /* Get the short name of the centre (row[4]) */ Str_Copy (Ctr->ShrtName,row[4], - Ctr_MAX_BYTES_CENTRE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); /* Get the full name of the centre (row[5]) */ Str_Copy (Ctr->FullName,row[5], - Ctr_MAX_BYTES_CENTRE_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /* Get the URL of the centre (row[6]) */ Str_Copy (Ctr->WWW,row[6], @@ -1221,7 +1221,7 @@ void Ctr_GetShortNameOfCentreByCod (struct Centre *Ctr) row = mysql_fetch_row (mysql_res); Str_Copy (Ctr->ShrtName,row[0], - Ctr_MAX_BYTES_CENTRE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); } /***** Free structure that stores the query result *****/ @@ -1470,7 +1470,7 @@ static void Ctr_ListCentresForEdition (void) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_SHORT_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Ctr_MAX_CHARS_CENTRE_SHRT_NAME,Ctr->ShrtName,Gbl.Form.Id); + Hie_MAX_CHARS_SHRT_NAME,Ctr->ShrtName,Gbl.Form.Id); Act_FormEnd (); fprintf (Gbl.F.Out,""); } @@ -1488,7 +1488,7 @@ static void Ctr_ListCentresForEdition (void) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_FULL_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Ctr_MAX_CHARS_CENTRE_FULL_NAME,Ctr->FullName,Gbl.Form.Id); + Hie_MAX_CHARS_FULL_NAME,Ctr->FullName,Gbl.Form.Id); Act_FormEnd (); fprintf (Gbl.F.Out,""); } @@ -1884,25 +1884,25 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull extern const char *Txt_The_centre_X_already_exists; extern const char *Txt_The_centre_X_has_been_renamed_as_Y; extern const char *Txt_The_name_of_the_centre_X_has_not_changed; - char Query[128 + Ctr_MAX_BYTES_CENTRE_FULL_NAME]; + char Query[128 + Hie_MAX_BYTES_FULL_NAME]; const char *ParamName = NULL; // Initialized to avoid warning const char *FieldName = NULL; // Initialized to avoid warning unsigned NaxBytes = 0; // Initialized to avoid warning char *CurrentCtrName = NULL; // Initialized to avoid warning - char NewCtrName[Ctr_MAX_BYTES_CENTRE_FULL_NAME + 1]; + char NewCtrName[Hie_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - NaxBytes = Ctr_MAX_BYTES_CENTRE_SHRT_NAME; + NaxBytes = Hie_MAX_BYTES_SHRT_NAME; CurrentCtrName = Ctr->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - NaxBytes = Ctr_MAX_BYTES_CENTRE_FULL_NAME; + NaxBytes = Hie_MAX_BYTES_FULL_NAME; CurrentCtrName = Ctr->FullName; break; } @@ -1961,7 +1961,7 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull static bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,long CtrCod,long InsCod) { - char Query[256 + Ctr_MAX_BYTES_CENTRE_FULL_NAME]; + char Query[256 + Hie_MAX_BYTES_FULL_NAME]; /***** Get number of centres with a name from database *****/ sprintf (Query,"SELECT COUNT(*) FROM centres" @@ -2355,12 +2355,12 @@ void Ctr_ReceivePhoto (void) void Ctr_ChangeCtrPhotoAttribution (void) { - char Query[256 + Ctr_MAX_BYTES_PHOTO_ATTRIBUTION]; - char NewPhotoAttribution[Ctr_MAX_BYTES_PHOTO_ATTRIBUTION + 1]; + char Query[256 + Img_MAX_BYTES_ATTRIBUTION]; + char NewPhotoAttribution[Img_MAX_BYTES_ATTRIBUTION + 1]; /***** Get parameters from form *****/ /* Get the new photo attribution for the centre */ - Par_GetParToText ("Attribution",NewPhotoAttribution,Ctr_MAX_BYTES_PHOTO_ATTRIBUTION); + Par_GetParToText ("Attribution",NewPhotoAttribution,Img_MAX_BYTES_ATTRIBUTION); /***** Update the table changing old attribution by new attribution *****/ sprintf (Query,"UPDATE centres SET PhotoAttribution='%s'" @@ -2443,7 +2443,7 @@ static void Ctr_PutFormToCreateCentre (void) " class=\"INPUT_SHORT_NAME\"" " required=\"required\" />" "", - Ctr_MAX_CHARS_CENTRE_SHRT_NAME,Ctr->ShrtName); + Hie_MAX_CHARS_SHRT_NAME,Ctr->ShrtName); /***** Centre full name *****/ fprintf (Gbl.F.Out,"" @@ -2452,7 +2452,7 @@ static void Ctr_PutFormToCreateCentre (void) " class=\"INPUT_FULL_NAME\"" " required=\"required\" />" "", - Ctr_MAX_CHARS_CENTRE_FULL_NAME,Ctr->FullName); + Hie_MAX_CHARS_FULL_NAME,Ctr->FullName); /***** Centre WWW *****/ fprintf (Gbl.F.Out,"" @@ -2671,10 +2671,10 @@ static void Ctr_RecFormRequestOrCreateCtr (unsigned Status) Lay_ShowAlert (Lay_ERROR,"Wrong place."); /* Get centre short name */ - Par_GetParToText ("ShortName",Ctr->ShrtName,Ctr_MAX_BYTES_CENTRE_SHRT_NAME); + Par_GetParToText ("ShortName",Ctr->ShrtName,Hie_MAX_BYTES_SHRT_NAME); /* Get centre full name */ - Par_GetParToText ("FullName",Ctr->FullName,Ctr_MAX_BYTES_CENTRE_FULL_NAME); + Par_GetParToText ("FullName",Ctr->FullName,Hie_MAX_BYTES_FULL_NAME); /* Get centre WWW */ Par_GetParToText ("WWW",Ctr->WWW,Cns_MAX_BYTES_WWW); @@ -2723,8 +2723,8 @@ static void Ctr_CreateCentre (struct Centre *Ctr,unsigned Status) { extern const char *Txt_Created_new_centre_X; char Query[512 + - Ctr_MAX_BYTES_CENTRE_SHRT_NAME + - Ctr_MAX_BYTES_CENTRE_FULL_NAME + + Hie_MAX_BYTES_SHRT_NAME + + Hie_MAX_BYTES_FULL_NAME + Cns_MAX_BYTES_WWW]; /***** Create a new centre *****/ diff --git a/swad_centre.h b/swad_centre.h index 96409ab3..57a7fed7 100644 --- a/swad_centre.h +++ b/swad_centre.h @@ -57,15 +57,6 @@ typedef enum #define Ctr_MAX_CENTRES_PER_USR 10 // Used in list of my centres -#define Ctr_MAX_CHARS_CENTRE_SHRT_NAME 32 -#define Ctr_MAX_BYTES_CENTRE_SHRT_NAME (Ctr_MAX_CHARS_CENTRE_SHRT_NAME * Str_MAX_BYTES_PER_CHAR) - -#define Ctr_MAX_CHARS_CENTRE_FULL_NAME (128 - 1) -#define Ctr_MAX_BYTES_CENTRE_FULL_NAME (Ctr_MAX_CHARS_CENTRE_FULL_NAME * Str_MAX_BYTES_PER_CHAR) - -#define Ctr_MAX_CHARS_PHOTO_ATTRIBUTION 512 -#define Ctr_MAX_BYTES_PHOTO_ATTRIBUTION (Ctr_MAX_CHARS_PHOTO_ATTRIBUTION * Str_MAX_BYTES_PER_CHAR) - struct Centre { long CtrCod; // Centre code @@ -73,8 +64,8 @@ struct Centre long PlcCod; // Place code Ctr_Status_t Status; // Centre status long RequesterUsrCod; // User code of the person who requested the creation of this centre - char ShrtName[Ctr_MAX_BYTES_CENTRE_SHRT_NAME + 1]; - char FullName[Ctr_MAX_BYTES_CENTRE_FULL_NAME + 1]; + char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; char WWW[Cns_MAX_BYTES_WWW + 1]; unsigned NumUsrsWhoClaimToBelongToCtr; // Number of users who claim to belong in this centre struct ListDegrees Degs; // List of degrees in this centre diff --git a/swad_changelog.h b/swad_changelog.h index bf4b4287..690c1ce7 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -204,13 +204,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.153 (2017-03-08)" +#define Log_PLATFORM_VERSION "SWAD 16.154 (2017-03-08)" #define CSS_FILE "swad16.147.css" #define JS_FILE "swad16.144.js" // 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 /* + Version 16.154: Mar 08, 2017 Adjusting size of database fields. + Code refactoring related to number of chars and bytes. (216458 lines) Version 16.153: Mar 08, 2017 Code refactoring related to number of chars and bytes. (216450 lines) Version 16.152: Mar 07, 2017 Code refactoring related to number of chars and bytes. (216428 lines) Version 16.151: Mar 07, 2017 Code refactoring related to number of chars and bytes. (216422 lines) diff --git a/swad_chat.c b/swad_chat.c index bf2427b8..8c52d433 100644 --- a/swad_chat.c +++ b/swad_chat.c @@ -54,11 +54,11 @@ extern struct Globals Gbl; #define Cht_MAX_CHARS_ROOM_CODE 16 // Maximum number of chars of the code of a chat room #define Cht_MAX_BYTES_ROOM_CODE Cht_MAX_CHARS_ROOM_CODE -#define Cht_MAX_CHARS_ROOM_SHRT_NAME (128 - 1) // Maximum number of chars of the short name of a chat room -#define Cht_MAX_BYTES_ROOM_SHRT_NAME (Cht_MAX_CHARS_ROOM_SHRT_NAME * Str_MAX_BYTES_PER_CHAR) +#define Cht_MAX_CHARS_ROOM_SHRT_NAME (128 - 1) // 127, maximum number of chars of the short name of a chat room +#define Cht_MAX_BYTES_ROOM_SHRT_NAME ((Cht_MAX_CHARS_ROOM_SHRT_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 -#define Cht_MAX_CHARS_ROOM_FULL_NAME (256 - 1) // Maximum number of chars of the full name of a chat room -#define Cht_MAX_BYTES_ROOM_FULL_NAME (Cht_MAX_CHARS_ROOM_FULL_NAME * Str_MAX_BYTES_PER_CHAR) +#define Cht_MAX_CHARS_ROOM_FULL_NAME (256 - 1) // 255, maximum number of chars of the full name of a chat room +#define Cht_MAX_BYTES_ROOM_FULL_NAME ((Cht_MAX_CHARS_ROOM_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 4095 /*****************************************************************************/ /***************************** Private prototypes ****************************/ diff --git a/swad_connected.c b/swad_connected.c index 6636a596..a295a757 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -497,7 +497,7 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void) { extern const char *Txt_Connected_users; extern const char *Txt_from; - char CourseName[Crs_MAX_BYTES_COURSE_SHRT_NAME + 1]; + char CourseName[Hie_MAX_BYTES_SHRT_NAME + 1]; struct ConnectedUsrs Usrs; if (Gbl.CurrentCrs.Crs.CrsCod <= 0) // There is no course selected @@ -513,7 +513,7 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void) // is dynamically updated via AJAX Act_LinkFormSubmitUnique (Txt_Connected_users,"CONNECTED_TXT"); Str_Copy (CourseName,Gbl.CurrentCrs.Crs.ShrtName, - Crs_MAX_BYTES_COURSE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNKNOWN,&Usrs); fprintf (Gbl.F.Out,"%u %s %s" "", diff --git a/swad_constant.h b/swad_constant.h index b7e5e0fb..915019e0 100644 --- a/swad_constant.h +++ b/swad_constant.h @@ -36,24 +36,21 @@ #define Cns_MAX_CHARS_WWW (256 - 1) // Max. number of chars of a URL #define Cns_MAX_BYTES_WWW Cns_MAX_CHARS_WWW -#define Cns_MAX_CHARS_IP (16 - 1) // Max. number of chars of an IP address +#define Cns_MAX_CHARS_IP (3 + 1 + 3 + 1 + 3 + 1 + 3) // Max. number of chars of an IP address + // Example: 255.255.255.255 + // 3+1+3+1+3+1+3 + // 123456789012345 #define Cns_MAX_BYTES_IP Cns_MAX_CHARS_IP #define Cns_MAX_CHARS_DATE (4 + 1 + 2 + 1 + 2) #define Cns_MAX_BYTES_DATE Cns_MAX_CHARS_DATE -#define Cns_MAX_CHARS_SUBJECT (256 - 1) -#define Cns_MAX_BYTES_SUBJECT (Cns_MAX_CHARS_SUBJECT * Str_MAX_BYTES_PER_CHAR) - -#define Cns_MAX_CHARS_SUMMARY_STRING (256 - 1) -#define Cns_MAX_BYTES_SUMMARY_STRING (Cns_MAX_CHARS_SUMMARY_STRING * Str_MAX_BYTES_PER_CHAR) +#define Cns_MAX_CHARS_SUBJECT (256 - 1) // 255 +#define Cns_MAX_BYTES_SUBJECT ((Cns_MAX_CHARS_SUBJECT + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 4095 #define Cns_MAX_BYTES_TEXT ( 64 * 1024 - 1) // Used for medium texts #define Cns_MAX_BYTES_LONG_TEXT (256 * 1024 - 1) // Used for big contents -#define Cns_MAX_CHARS_STRING (128 - 1) -#define Cns_MAX_BYTES_STRING (Cns_MAX_CHARS_STRING * Str_MAX_BYTES_PER_CHAR) - /*****************************************************************************/ /******************************* Public types ********************************/ /*****************************************************************************/ diff --git a/swad_country.c b/swad_country.c index bcf06d82..0b85322f 100644 --- a/swad_country.c +++ b/swad_country.c @@ -803,7 +803,7 @@ void Cty_DrawCountryMapAndNameWithLink (struct Country *Cty,Act_Action_t Action, const char *ClassLink) { extern const char *Txt_Go_to_X; - char CountryName[Cty_MAX_BYTES_COUNTRY_NAME + 1]; + char CountryName[Hie_MAX_BYTES_FULL_NAME + 1]; /***** Start form *****/ Act_FormGoToStart (Action); @@ -819,7 +819,7 @@ void Cty_DrawCountryMapAndNameWithLink (struct Country *Cty,Act_Action_t Action, /***** Write country name and end link *****/ Str_Copy (CountryName,Cty->Name[Gbl.Prefs.Language], - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); fprintf (Gbl.F.Out," %s (%s)" "" "", @@ -1099,7 +1099,7 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData) /* Get the name of the country in current language */ Str_Copy (Cty->Name[Gbl.Prefs.Language],row[2], - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); break; case Cty_GET_EXTRA_DATA: /* Get the name of the country in several languages */ @@ -1108,7 +1108,7 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData) Lan++) { Str_Copy (Cty->Name[Lan],row[1 + Lan], - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); Str_Copy (Cty->WWW[Lan],row[1 + Txt_NUM_LANGUAGES + Lan], Cns_MAX_BYTES_WWW); } @@ -1212,7 +1212,7 @@ void Cty_WriteSelectorOfCountry (void) void Cty_WriteCountryName (long CtyCod,const char *ClassLink) { extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; - char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]; + char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; char ActTxt[Act_MAX_BYTES_ACTION_TXT + 1]; bool PutForm = ClassLink && !Gbl.Form.Inside && // Only if not inside another form @@ -1279,7 +1279,7 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD Lan++) if (Lan == Gbl.Prefs.Language) Str_Copy (Cty->Name[Lan],Txt_Another_country, - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); else Cty->Name[Lan][0] = '\0'; return false; @@ -1355,7 +1355,7 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD case Cty_GET_BASIC_DATA: /* Get name and WWW of the country in current language */ Str_Copy (Cty->Name[Gbl.Prefs.Language],row[1], - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); Str_Copy (Cty->WWW[Gbl.Prefs.Language],row[2], Cns_MAX_BYTES_WWW); break; @@ -1366,7 +1366,7 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD Lan++) { Str_Copy (Cty->Name[Lan],row[Lan], - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); Str_Copy (Cty->WWW[Lan],row[Txt_NUM_LANGUAGES + Lan], Cns_MAX_BYTES_WWW); } @@ -1398,7 +1398,7 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD /***************************** Get country name ******************************/ /*****************************************************************************/ -void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]) +void Cty_GetCountryName (long CtyCod,char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]) { extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES]; char Query[128]; @@ -1407,7 +1407,7 @@ void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1 static struct { long CtyCod; - char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]; + char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; } Cached = { -1L, @@ -1433,7 +1433,7 @@ void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1 /* Get the name of the country */ Str_Copy (Cached.CtyName,row[0], - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); } else Cached.CtyName[0] = '\0'; @@ -1443,7 +1443,7 @@ void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1 } Str_Copy (CtyName,Cached.CtyName, - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); } } @@ -1604,7 +1604,7 @@ static void Cty_ListCountriesForEdition (void) fprintf (Gbl.F.Out,"", - Cty_MAX_CHARS_COUNTRY_NAME, + Hie_MAX_CHARS_FULL_NAME, Cty->Name[Lan],Gbl.Form.Id); Act_FormEnd (); fprintf (Gbl.F.Out,""); @@ -1723,7 +1723,7 @@ void Cty_RenameCountry (void) extern const char *Txt_The_name_of_the_country_X_has_not_changed; char Query[512]; struct Country *Cty; - char NewCtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]; + char NewCtyName[Hie_MAX_BYTES_FULL_NAME + 1]; Txt_Language_t Language; Cty = &Gbl.Ctys.EditingCty; @@ -1736,7 +1736,7 @@ void Cty_RenameCountry (void) Language = Pre_GetParamLanguage (); /* Get the new name for the country */ - Par_GetParToText ("Name",NewCtyName,Cty_MAX_BYTES_COUNTRY_NAME); + Par_GetParToText ("Name",NewCtyName,Hie_MAX_BYTES_FULL_NAME); /***** Get from the database the data of the country *****/ Cty_GetDataOfCountryByCod (Cty,Cty_GET_EXTRA_DATA); @@ -1784,7 +1784,7 @@ void Cty_RenameCountry (void) /***** Show the form again *****/ Str_Copy (Cty->Name[Language],NewCtyName, - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); Cty_EditCountries (); } @@ -1855,7 +1855,7 @@ void Cty_ChangeCtyWWW (void) Language = Pre_GetParamLanguage (); /* Get the new WWW for the country */ - Par_GetParToText ("WWW",NewWWW,Cty_MAX_BYTES_COUNTRY_NAME); + Par_GetParToText ("WWW",NewWWW,Hie_MAX_BYTES_FULL_NAME); /***** Get from the database the data of the country *****/ Cty_GetDataOfCountryByCod (Cty,Cty_GET_EXTRA_DATA); @@ -1882,12 +1882,12 @@ void Cty_ChangeCtyWWW (void) void Cty_ChangeCtyMapAttribution (void) { - char Query[256 + Cty_MAX_BYTES_MAP_ATTRIBUTION]; - char NewMapAttribution[Cty_MAX_BYTES_MAP_ATTRIBUTION + 1]; + char Query[256 + Img_MAX_BYTES_ATTRIBUTION]; + char NewMapAttribution[Img_MAX_BYTES_ATTRIBUTION + 1]; /***** Get parameters from form *****/ /* Get the new map attribution for the country */ - Par_GetParToText ("Attribution",NewMapAttribution,Cty_MAX_BYTES_MAP_ATTRIBUTION); + Par_GetParToText ("Attribution",NewMapAttribution,Img_MAX_BYTES_ATTRIBUTION); /***** Update the table changing old attribution by new attribution *****/ sprintf (Query,"UPDATE countries SET MapAttribution='%s'" @@ -1983,7 +1983,7 @@ static void Cty_PutFormToCreateCountry (void) " required=\"required\" />" "", Txt_STR_LANG_ID[Lan], - Cty_MAX_CHARS_COUNTRY_NAME, + Hie_MAX_CHARS_FULL_NAME, Cty->Name[Lan]); /* WWW */ @@ -2116,7 +2116,7 @@ void Cty_RecFormNewCountry (void) Lan++) { sprintf (ParamName,"Name_%s",Txt_STR_LANG_ID[Lan]); - Par_GetParToText (ParamName,Cty->Name[Lan],Cty_MAX_BYTES_COUNTRY_NAME); + Par_GetParToText (ParamName,Cty->Name[Lan],Hie_MAX_BYTES_FULL_NAME); if (Cty->Name[Lan][0]) // If there's a country name { @@ -2155,7 +2155,7 @@ void Cty_RecFormNewCountry (void) /**************************** Create a new country ***************************/ /*****************************************************************************/ -#define Cty_MAX_BYTES_SUBQUERY_CTYS_NAME ((1 + Txt_NUM_LANGUAGES) * Cty_MAX_BYTES_COUNTRY_NAME) +#define Cty_MAX_BYTES_SUBQUERY_CTYS_NAME ((1 + Txt_NUM_LANGUAGES) * Hie_MAX_BYTES_FULL_NAME) #define Cty_MAX_BYTES_SUBQUERY_CTYS_WWW ((1 + Txt_NUM_LANGUAGES) * Cns_MAX_BYTES_WWW) static void Cty_CreateCountry (struct Country *Cty) diff --git a/swad_country.h b/swad_country.h index 3ec2ede4..689a88e1 100644 --- a/swad_country.h +++ b/swad_country.h @@ -30,6 +30,7 @@ #include // For boolean type #include "swad_action.h" +#include "swad_hierarchy.h" #include "swad_role_type.h" #include "swad_text.h" @@ -37,19 +38,13 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Cty_MAX_CHARS_COUNTRY_NAME (128 - 1) -#define Cty_MAX_BYTES_COUNTRY_NAME (Cty_MAX_CHARS_COUNTRY_NAME * Str_MAX_BYTES_PER_CHAR) - -#define Cty_MAX_CHARS_MAP_ATTRIBUTION 512 -#define Cty_MAX_BYTES_MAP_ATTRIBUTION (Cty_MAX_CHARS_MAP_ATTRIBUTION * Str_MAX_BYTES_PER_CHAR) - #define Cty_MAX_COUNTRS_PER_USR 10 // Used in list of my countries struct Country { long CtyCod; char Alpha2[2 + 1]; - char Name[1 + Txt_NUM_LANGUAGES][Cty_MAX_BYTES_COUNTRY_NAME + 1]; + char Name[1 + Txt_NUM_LANGUAGES][Hie_MAX_BYTES_FULL_NAME + 1]; char WWW [1 + Txt_NUM_LANGUAGES][Cns_MAX_BYTES_WWW + 1]; unsigned NumUsrsWhoClaimToBelongToCty; unsigned NumInss; @@ -101,7 +96,7 @@ void Cty_FreeListCountries (void); void Cty_WriteSelectorOfCountry (void); void Cty_WriteCountryName (long CtyCod,const char *ClassLink); bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraData); -void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]); +void Cty_GetCountryName (long CtyCod,char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]); void Cty_PutParamCtyCod (long CtyCod); long Cty_GetAndCheckParamOtherCtyCod (void); void Cty_RemoveCountry (void); diff --git a/swad_course.c b/swad_course.c index 704e3166..01ce0674 100644 --- a/swad_course.c +++ b/swad_course.c @@ -104,8 +104,8 @@ static void Crs_UpdateCrsDegDB (long CrsCod,long DegCod); static void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear); static void Crs_GetShortNamesByCod (long CrsCod, - char CrsShortName[Crs_MAX_BYTES_COURSE_SHRT_NAME + 1], - char DegShortName[Deg_MAX_BYTES_DEGREE_SHRT_NAME + 1]); + char CrsShortName[Hie_MAX_BYTES_SHRT_NAME + 1], + char DegShortName[Hie_MAX_BYTES_SHRT_NAME + 1]); static void Crs_EmptyCourseCompletely (long CrsCod); @@ -276,7 +276,7 @@ static void Crs_Configuration (bool PrintView) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_FULL_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Crs_MAX_CHARS_COURSE_FULL_NAME, + Hie_MAX_CHARS_FULL_NAME, Gbl.CurrentCrs.Crs.FullName, Gbl.Form.Id); Act_FormEnd (); @@ -305,7 +305,7 @@ static void Crs_Configuration (bool PrintView) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_SHORT_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Crs_MAX_CHARS_COURSE_SHRT_NAME, + Hie_MAX_CHARS_SHRT_NAME, Gbl.CurrentCrs.Crs.ShrtName, Gbl.Form.Id); Act_FormEnd (); @@ -1066,8 +1066,8 @@ void Crs_WriteSelectorMyCourses (void) long CrsCod; long DegCod; long LastDegCod; - char CrsShortName[Crs_MAX_BYTES_COURSE_SHRT_NAME + 1]; - char DegShortName[Deg_MAX_BYTES_DEGREE_SHRT_NAME + 1]; + char CrsShortName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char DegShortName[Hie_MAX_BYTES_SHRT_NAME + 1]; /***** Fill the list with the courses I belong to, if not filled *****/ if (Gbl.Usrs.Me.Logged) @@ -1479,7 +1479,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_SHORT_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Crs_MAX_CHARS_COURSE_SHRT_NAME,Crs->ShrtName, + Hie_MAX_CHARS_SHRT_NAME,Crs->ShrtName, Gbl.Form.Id); Act_FormEnd (); } @@ -1497,7 +1497,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_FULL_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Crs_MAX_CHARS_COURSE_FULL_NAME,Crs->FullName, + Hie_MAX_CHARS_FULL_NAME,Crs->FullName, Gbl.Form.Id); Act_FormEnd (); } @@ -1682,7 +1682,7 @@ static void Crs_PutFormToCreateCourse (void) " class=\"INPUT_SHORT_NAME\"" " required=\"required\" />" "", - Crs_MAX_CHARS_COURSE_SHRT_NAME,Crs->ShrtName); + Hie_MAX_CHARS_SHRT_NAME,Crs->ShrtName); /***** Course full name *****/ fprintf (Gbl.F.Out,"" @@ -1691,7 +1691,7 @@ static void Crs_PutFormToCreateCourse (void) " class=\"INPUT_FULL_NAME\"" " required=\"required\" />" "", - Crs_MAX_CHARS_COURSE_FULL_NAME,Crs->FullName); + Hie_MAX_CHARS_FULL_NAME,Crs->FullName); /***** Current number of teachers in this course *****/ fprintf (Gbl.F.Out,"" @@ -1921,10 +1921,10 @@ static void Crs_GetParamsNewCourse (struct Course *Crs) Crs->Year = Deg_ConvStrToYear (YearStr); /* Get course short name */ - Par_GetParToText ("ShortName",Crs->ShrtName,Crs_MAX_BYTES_COURSE_SHRT_NAME); + Par_GetParToText ("ShortName",Crs->ShrtName,Hie_MAX_BYTES_SHRT_NAME); /* Get course full name */ - Par_GetParToText ("FullName",Crs->FullName,Crs_MAX_BYTES_COURSE_FULL_NAME); + Par_GetParToText ("FullName",Crs->FullName,Hie_MAX_BYTES_FULL_NAME); } /*****************************************************************************/ @@ -1952,8 +1952,8 @@ static void Crs_CreateCourse (struct Course *Crs,unsigned Status) { extern const char *Txt_Created_new_course_X; char Query[512 + - Crs_MAX_BYTES_COURSE_SHRT_NAME + - Crs_MAX_BYTES_COURSE_FULL_NAME]; + Hie_MAX_BYTES_SHRT_NAME + + Hie_MAX_BYTES_FULL_NAME]; /***** Insert new course into pending requests *****/ sprintf (Query,"INSERT INTO courses (DegCod,Year,InsCrsCod," @@ -2085,11 +2085,11 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row) /***** Get the short name of the course (row[6]) *****/ Str_Copy (Crs->ShrtName,row[6], - Crs_MAX_BYTES_COURSE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); /***** Get the full name of the course (row[7]) *****/ Str_Copy (Crs->FullName,row[7], - Crs_MAX_BYTES_COURSE_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /***** Get number of teachers *****/ Crs->NumTchs = Usr_GetNumUsrsInCrs (Rol_TEACHER,Crs->CrsCod); @@ -2106,8 +2106,8 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row) /*****************************************************************************/ static void Crs_GetShortNamesByCod (long CrsCod, - char CrsShortName[Crs_MAX_BYTES_COURSE_SHRT_NAME + 1], - char DegShortName[Deg_MAX_BYTES_DEGREE_SHRT_NAME + 1]) + char CrsShortName[Hie_MAX_BYTES_SHRT_NAME + 1], + char DegShortName[Hie_MAX_BYTES_SHRT_NAME + 1]) { char Query[512]; MYSQL_RES *mysql_res; @@ -2129,9 +2129,9 @@ static void Crs_GetShortNamesByCod (long CrsCod, row = mysql_fetch_row (mysql_res); Str_Copy (CrsShortName,row[0], - Crs_MAX_BYTES_COURSE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); Str_Copy (DegShortName,row[1], - Deg_MAX_BYTES_DEGREE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); } /***** Free structure that stores the query result *****/ @@ -2642,25 +2642,25 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull extern const char *Txt_The_name_of_the_course_X_has_changed_to_Y; extern const char *Txt_The_name_of_the_course_X_has_not_changed; extern const char *Txt_You_dont_have_permission_to_edit_this_course; - char Query[128 + Crs_MAX_BYTES_COURSE_FULL_NAME]; + char Query[128 + Hie_MAX_BYTES_FULL_NAME]; const char *ParamName = NULL; // Initialized to avoid warning const char *FieldName = NULL; // Initialized to avoid warning unsigned MaxBytes = 0; // Initialized to avoid warning char *CurrentCrsName = NULL; // Initialized to avoid warning - char NewCrsName[Crs_MAX_BYTES_COURSE_FULL_NAME + 1]; + char NewCrsName[Hie_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - MaxBytes = Crs_MAX_BYTES_COURSE_SHRT_NAME; + MaxBytes = Hie_MAX_BYTES_SHRT_NAME; CurrentCrsName = Crs->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - MaxBytes = Crs_MAX_BYTES_COURSE_FULL_NAME; + MaxBytes = Hie_MAX_BYTES_FULL_NAME; CurrentCrsName = Crs->FullName; break; } diff --git a/swad_course.h b/swad_course.h index dd7a1721..6f607277 100644 --- a/swad_course.h +++ b/swad_course.h @@ -39,14 +39,8 @@ #define Crs_MAX_COURSES_PER_USR 100 // Used in list of my courses and list of distinct courses in sent or received messages -#define Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD 8 -#define Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD (Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD * Str_MAX_BYTES_PER_CHAR) - -#define Crs_MAX_CHARS_COURSE_SHRT_NAME 32 -#define Crs_MAX_BYTES_COURSE_SHRT_NAME (Crs_MAX_CHARS_COURSE_SHRT_NAME * Str_MAX_BYTES_PER_CHAR) - -#define Crs_MAX_CHARS_COURSE_FULL_NAME (128 - 1) -#define Crs_MAX_BYTES_COURSE_FULL_NAME (Crs_MAX_CHARS_COURSE_FULL_NAME * Str_MAX_BYTES_PER_CHAR) +#define Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD (16 - 1) // 15 +#define Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD ((Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 255 #define Crs_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 6 #define Crs_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 12 @@ -89,8 +83,8 @@ struct Course unsigned Year; // Year: 0 (optatives), 1, 2, 3... Crs_Status_t Status; // Course status long RequesterUsrCod; // User code of the person who requested the creation of this course - char ShrtName[Crs_MAX_BYTES_COURSE_SHRT_NAME + 1]; // Short name of course - char FullName[Crs_MAX_BYTES_COURSE_FULL_NAME + 1]; // Full name of course + char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; // Short name of course + char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; // Full name of course unsigned NumUsrs; // Number of users (students + teachers) unsigned NumTchs; // Number of teachers unsigned NumStds; // Number of students diff --git a/swad_database.c b/swad_database.c index 98f5459a..16f49c65 100644 --- a/swad_database.c +++ b/swad_database.c @@ -103,17 +103,17 @@ mysql> DESCRIBE IP_prefs; 8 rows in set (0.01 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS IP_prefs (" - "IP CHAR(15) NOT NULL," - "UsrCod INT NOT NULL DEFAULT -1," - "LastChange DATETIME NOT NULL," - "FirstDayOfWeek TINYINT NOT NULL DEFAULT 0," - "Theme CHAR(16) NOT NULL," - "IconSet CHAR(16) NOT NULL," - "Menu TINYINT NOT NULL DEFAULT 0," - "SideCols TINYINT NOT NULL," - "PRIMARY KEY (IP)," - "INDEX(UsrCod)," - "INDEX(LastChange))"); + "IP CHAR(15) NOT NULL," // Cns_MAX_BYTES_IP + "UsrCod INT NOT NULL DEFAULT -1," + "LastChange DATETIME NOT NULL," + "FirstDayOfWeek TINYINT NOT NULL DEFAULT 0," + "Theme CHAR(16) NOT NULL," // The_MAX_BYTES_THEME_ID + "IconSet CHAR(16) NOT NULL," // Ico_MAX_BYTES_ICON_SET_ID + "Menu TINYINT NOT NULL DEFAULT 0," + "SideCols TINYINT NOT NULL," + "PRIMARY KEY (IP)," + "INDEX(UsrCod)," + "INDEX(LastChange))"); /***** Table actions *****/ /* @@ -129,12 +129,12 @@ mysql> DESCRIBE actions; 4 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS actions (" - "ActCod INT NOT NULL DEFAULT -1," - "Language CHAR(2) NOT NULL," - "Obsolete ENUM('N','Y') NOT NULL DEFAULT 'N'," - "Txt VARCHAR(255) NOT NULL," - "UNIQUE INDEX(ActCod,Language)," - "INDEX(Txt))"); + "ActCod INT NOT NULL DEFAULT -1," + "Language CHAR(2) NOT NULL," + "Obsolete ENUM('N','Y') NOT NULL DEFAULT 'N'," + "Txt VARCHAR(255) NOT NULL," // Act_MAX_BYTES_ACTION_TXT + "UNIQUE INDEX(ActCod,Language)," + "INDEX(Txt))"); /***** Table actions_MFU *****/ /* @@ -150,11 +150,11 @@ mysql> DESCRIBE actions_MFU; 4 rows in set (0.01 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS actions_MFU (" - "UsrCod INT NOT NULL," - "ActCod INT NOT NULL," - "Score FLOAT NOT NULL," - "LastClick DATETIME NOT NULL," - "UNIQUE INDEX(UsrCod,ActCod))"); + "UsrCod INT NOT NULL," + "ActCod INT NOT NULL," + "Score FLOAT NOT NULL," + "LastClick DATETIME NOT NULL," + "UNIQUE INDEX(UsrCod,ActCod))"); /***** Table admin *****/ /* @@ -169,11 +169,11 @@ mysql> DESCRIBE admin; 3 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS admin (" - "UsrCod INT NOT NULL," - "Scope ENUM('Sys','Ins','Ctr','Deg') NOT NULL," - "Cod INT NOT NULL," - "UNIQUE INDEX(UsrCod,Scope,Cod)," - "INDEX (Scope,Cod))"); + "UsrCod INT NOT NULL," + "Scope ENUM('Sys','Ins','Ctr','Deg') NOT NULL," + "Cod INT NOT NULL," + "UNIQUE INDEX(UsrCod,Scope,Cod)," + "INDEX (Scope,Cod))"); /***** Table agendas *****/ /* @@ -194,17 +194,17 @@ mysql> DESCRIBE agendas; 9 rows in set (0,00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS agendas (" - "AgdCod INT NOT NULL AUTO_INCREMENT," - "UsrCod INT NOT NULL," - "Public ENUM('N','Y') NOT NULL DEFAULT 'N'," - "Hidden ENUM('N','Y') NOT NULL DEFAULT 'N'," - "StartTime DATETIME NOT NULL," - "EndTime DATETIME NOT NULL," - "Event VARCHAR(255) NOT NULL," - "Location VARCHAR(255) NOT NULL," - "Txt TEXT NOT NULL," - "UNIQUE INDEX(AgdCod)," - "INDEX(UsrCod,Public,Hidden))"); + "AgdCod INT NOT NULL AUTO_INCREMENT," + "UsrCod INT NOT NULL," + "Public ENUM('N','Y') NOT NULL DEFAULT 'N'," + "Hidden ENUM('N','Y') NOT NULL DEFAULT 'N'," + "StartTime DATETIME NOT NULL," + "EndTime DATETIME NOT NULL," + "Event VARCHAR(255) NOT NULL," // Agd_MAX_BYTES_EVENT + "Location VARCHAR(255) NOT NULL," + "Txt TEXT NOT NULL," + "UNIQUE INDEX(AgdCod)," + "INDEX(UsrCod,Public,Hidden))"); /***** Table ann_seen *****/ /* diff --git a/swad_degree.c b/swad_degree.c index 525dc8a1..535ec952 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -392,7 +392,7 @@ static void Deg_Configuration (bool PrintView) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_FULL_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Deg_MAX_CHARS_DEGREE_FULL_NAME, + Hie_MAX_CHARS_FULL_NAME, Gbl.CurrentDeg.Deg.FullName, Gbl.Form.Id); Act_FormEnd (); @@ -422,7 +422,7 @@ static void Deg_Configuration (bool PrintView) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_SHORT_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Deg_MAX_CHARS_DEGREE_SHRT_NAME, + Hie_MAX_CHARS_SHRT_NAME, Gbl.CurrentDeg.Deg.ShrtName, Gbl.Form.Id); Act_FormEnd (); @@ -748,7 +748,7 @@ static void Deg_ListDegreesForEdition (void) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_SHORT_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Deg_MAX_CHARS_DEGREE_SHRT_NAME,Deg->ShrtName,Gbl.Form.Id); + Hie_MAX_CHARS_SHRT_NAME,Deg->ShrtName,Gbl.Form.Id); Act_FormEnd (); } else @@ -765,7 +765,7 @@ static void Deg_ListDegreesForEdition (void) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_FULL_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Deg_MAX_CHARS_DEGREE_FULL_NAME,Deg->FullName,Gbl.Form.Id); + Hie_MAX_CHARS_FULL_NAME,Deg->FullName,Gbl.Form.Id); Act_FormEnd (); } else @@ -988,7 +988,7 @@ static void Deg_PutFormToCreateDegree (void) " class=\"INPUT_SHORT_NAME\"" " required=\"required\" />" "", - Deg_MAX_CHARS_DEGREE_SHRT_NAME,Deg->ShrtName); + Hie_MAX_CHARS_SHRT_NAME,Deg->ShrtName); /***** Degree full name *****/ fprintf (Gbl.F.Out,"" @@ -997,7 +997,7 @@ static void Deg_PutFormToCreateDegree (void) " class=\"INPUT_FULL_NAME\"" " required=\"required\" />" "", - Deg_MAX_CHARS_DEGREE_FULL_NAME,Deg->FullName); + Hie_MAX_CHARS_FULL_NAME,Deg->FullName); /***** Degree type *****/ fprintf (Gbl.F.Out,"" @@ -1164,8 +1164,8 @@ static void Deg_CreateDegree (struct Degree *Deg,unsigned Status) { extern const char *Txt_Created_new_degree_X; char Query[512 + - Deg_MAX_BYTES_DEGREE_SHRT_NAME + - Deg_MAX_BYTES_DEGREE_FULL_NAME + + Hie_MAX_BYTES_SHRT_NAME + + Hie_MAX_BYTES_FULL_NAME + Cns_MAX_BYTES_WWW]; /***** Create a new degree *****/ @@ -1541,10 +1541,10 @@ static void Deg_RecFormRequestOrCreateDeg (unsigned Status) Deg->CtrCod = Gbl.CurrentCtr.Ctr.CtrCod; /* Get degree short name */ - Par_GetParToText ("ShortName",Deg->ShrtName,Deg_MAX_BYTES_DEGREE_SHRT_NAME); + Par_GetParToText ("ShortName",Deg->ShrtName,Hie_MAX_BYTES_SHRT_NAME); /* Get degree full name */ - Par_GetParToText ("FullName",Deg->FullName,Deg_MAX_BYTES_DEGREE_FULL_NAME); + Par_GetParToText ("FullName",Deg->FullName,Hie_MAX_BYTES_FULL_NAME); /* Get degree type */ if ((Deg->DegTypCod = DT_GetParamOtherDegTypCod ()) <= 0) @@ -1728,11 +1728,11 @@ static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row) /***** Get degree short name (row[5]) *****/ Str_Copy (Deg->ShrtName,row[5], - Deg_MAX_BYTES_DEGREE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); /***** Get degree full name (row[6]) *****/ Str_Copy (Deg->FullName,row[6], - Deg_MAX_BYTES_DEGREE_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /***** Get WWW (row[7]) *****/ Str_Copy (Deg->WWW,row[7], @@ -1762,7 +1762,7 @@ void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg) row = mysql_fetch_row (mysql_res); Str_Copy (Deg->ShrtName,row[0], - Deg_MAX_BYTES_DEGREE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); } /***** Free structure that stores the query result *****/ @@ -1939,25 +1939,25 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull extern const char *Txt_The_degree_X_already_exists; extern const char *Txt_The_name_of_the_degree_X_has_changed_to_Y; extern const char *Txt_The_name_of_the_degree_X_has_not_changed; - char Query[512 + Deg_MAX_BYTES_DEGREE_FULL_NAME]; + char Query[512 + Hie_MAX_BYTES_FULL_NAME]; const char *ParamName = NULL; // Initialized to avoid warning const char *FieldName = NULL; // Initialized to avoid warning unsigned MaxBytes = 0; // Initialized to avoid warning char *CurrentDegName = NULL; // Initialized to avoid warning - char NewDegName[Deg_MAX_BYTES_DEGREE_FULL_NAME + 1]; + char NewDegName[Hie_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - MaxBytes = Deg_MAX_BYTES_DEGREE_SHRT_NAME; + MaxBytes = Hie_MAX_BYTES_SHRT_NAME; CurrentDegName = Deg->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - MaxBytes = Deg_MAX_BYTES_DEGREE_FULL_NAME; + MaxBytes = Hie_MAX_BYTES_FULL_NAME; CurrentDegName = Deg->FullName; break; } diff --git a/swad_degree.h b/swad_degree.h index 3470a38c..f5b2c882 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -29,6 +29,7 @@ #include "swad_action.h" #include "swad_constant.h" +#include "swad_hierarchy.h" #include "swad_role_type.h" #include "swad_string.h" @@ -40,12 +41,6 @@ #define Deg_MAX_DEGREES_PER_USR 20 // Used in list of my degrees -#define Deg_MAX_CHARS_DEGREE_SHRT_NAME 32 -#define Deg_MAX_BYTES_DEGREE_SHRT_NAME (Deg_MAX_CHARS_DEGREE_SHRT_NAME * Str_MAX_BYTES_PER_CHAR) - -#define Deg_MAX_CHARS_DEGREE_FULL_NAME (128 - 1) -#define Deg_MAX_BYTES_DEGREE_FULL_NAME (Deg_MAX_CHARS_DEGREE_FULL_NAME * Str_MAX_BYTES_PER_CHAR) - /*****************************************************************************/ /******************************* Public types ********************************/ /*****************************************************************************/ @@ -76,8 +71,8 @@ struct Degree long CtrCod; // Centre code Deg_Status_t Status; // Degree status long RequesterUsrCod; // User code of the person who requested the creation of this degree - char ShrtName[Deg_MAX_BYTES_DEGREE_SHRT_NAME + 1]; // Short name of degree - char FullName[Deg_MAX_BYTES_DEGREE_FULL_NAME + 1]; // Full name of degree + char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; // Short name of degree + char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; // Full name of degree char WWW[Cns_MAX_BYTES_WWW + 1]; struct Course *LstCrss; // List of courses in this degree }; diff --git a/swad_degree_type.h b/swad_degree_type.h index 3f66c0c6..da98802d 100644 --- a/swad_degree_type.h +++ b/swad_degree_type.h @@ -31,8 +31,8 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -#define Deg_MAX_CHARS_DEGREE_TYPE_NAME 32 -#define Deg_MAX_BYTES_DEGREE_TYPE_NAME (Deg_MAX_CHARS_DEGREE_TYPE_NAME * Str_MAX_BYTES_PER_CHAR) +#define Deg_MAX_CHARS_DEGREE_TYPE_NAME (32 - 1) // 31 +#define Deg_MAX_BYTES_DEGREE_TYPE_NAME ((Deg_MAX_CHARS_DEGREE_TYPE_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 /*****************************************************************************/ /******************************* Public types ********************************/ diff --git a/swad_department.c b/swad_department.c index cfe5ad5d..c1b547e5 100644 --- a/swad_department.c +++ b/swad_department.c @@ -349,11 +349,11 @@ void Dpt_GetListDepartments (long InsCod) /* Get the short name of the department (row[2]) */ Str_Copy (Dpt->ShrtName,row[2], - Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); /* Get the full name of the department (row[3]) */ Str_Copy (Dpt->FullName,row[3], - Dpt_MAX_BYTES_DEPARTMENT_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /* Get the URL of the department (row[4]) */ Str_Copy (Dpt->WWW,row[4], @@ -392,9 +392,9 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt) if (Dpt->DptCod == 0) { Str_Copy (Dpt->ShrtName,Txt_Another_department, - Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); Str_Copy (Dpt->FullName,Txt_Another_department, - Dpt_MAX_BYTES_DEPARTMENT_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); } else if (Dpt->DptCod > 0) { @@ -427,11 +427,11 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt) /* Get the short name of the department (row[1]) */ Str_Copy (Dpt->ShrtName,row[1], - Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); /* Get the full name of the department (row[2]) */ Str_Copy (Dpt->FullName,row[2], - Dpt_MAX_BYTES_DEPARTMENT_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /* Get the URL of the department (row[3]) */ Str_Copy (Dpt->WWW,row[3], @@ -559,7 +559,7 @@ static void Dpt_ListDepartmentsForEdition (void) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_SHORT_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Dpt_MAX_CHARS_DEPARTMENT_SHRT_NAME,Dpt->ShrtName,Gbl.Form.Id); + Hie_MAX_CHARS_SHRT_NAME,Dpt->ShrtName,Gbl.Form.Id); Act_FormEnd (); fprintf (Gbl.F.Out,""); @@ -571,7 +571,7 @@ static void Dpt_ListDepartmentsForEdition (void) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_FULL_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Dpt_MAX_CHARS_DEPARTMENT_FULL_NAME,Dpt->FullName,Gbl.Form.Id); + Hie_MAX_CHARS_FULL_NAME,Dpt->FullName,Gbl.Form.Id); Act_FormEnd (); fprintf (Gbl.F.Out,""); @@ -720,7 +720,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName) const char *FieldName = NULL; // Initialized to avoid warning size_t MaxBytes = 0; // Initialized to avoid warning char *CurrentDptName = NULL; // Initialized to avoid warning - char NewDptName[Dpt_MAX_BYTES_DEPARTMENT_FULL_NAME + 1]; + char NewDptName[Hie_MAX_BYTES_FULL_NAME + 1]; Dpt = &Gbl.Dpts.EditingDpt; switch (ShrtOrFullName) @@ -728,13 +728,13 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName) case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - MaxBytes = Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME; + MaxBytes = Hie_MAX_BYTES_SHRT_NAME; CurrentDptName = Dpt->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - MaxBytes = Dpt_MAX_BYTES_DEPARTMENT_FULL_NAME; + MaxBytes = Hie_MAX_BYTES_FULL_NAME; CurrentDptName = Dpt->FullName; break; } @@ -930,7 +930,7 @@ static void Dpt_PutFormToCreateDepartment (void) " class=\"INPUT_SHORT_NAME\"" " required=\"required\" />" "", - Dpt_MAX_CHARS_DEPARTMENT_SHRT_NAME,Dpt->ShrtName); + Hie_MAX_CHARS_SHRT_NAME,Dpt->ShrtName); /***** Department full name *****/ fprintf (Gbl.F.Out,"" @@ -939,7 +939,7 @@ static void Dpt_PutFormToCreateDepartment (void) " class=\"INPUT_FULL_NAME\"" " required=\"required\" />" "", - Dpt_MAX_CHARS_DEPARTMENT_FULL_NAME,Dpt->FullName); + Hie_MAX_CHARS_FULL_NAME,Dpt->FullName); /***** Department WWW *****/ fprintf (Gbl.F.Out,"" @@ -1019,10 +1019,10 @@ void Dpt_RecFormNewDpt (void) Dpt->InsCod = Ins_GetAndCheckParamOtherInsCod (); /* Get department short name */ - Par_GetParToText ("ShortName",Dpt->ShrtName,Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME); + Par_GetParToText ("ShortName",Dpt->ShrtName,Hie_MAX_BYTES_SHRT_NAME); /* Get department full name */ - Par_GetParToText ("FullName",Dpt->FullName,Dpt_MAX_BYTES_DEPARTMENT_FULL_NAME); + Par_GetParToText ("FullName",Dpt->FullName,Hie_MAX_BYTES_FULL_NAME); /* Get department WWW */ Par_GetParToText ("WWW",Dpt->WWW,Cns_MAX_BYTES_WWW); diff --git a/swad_department.h b/swad_department.h index 678b2153..9d5b69c5 100644 --- a/swad_department.h +++ b/swad_department.h @@ -27,22 +27,18 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ +#include "swad_hierarchy.h" + /*****************************************************************************/ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Dpt_MAX_CHARS_DEPARTMENT_SHRT_NAME 32 -#define Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME (Dpt_MAX_CHARS_DEPARTMENT_SHRT_NAME * Str_MAX_BYTES_PER_CHAR) - -#define Dpt_MAX_CHARS_DEPARTMENT_FULL_NAME (128 - 1) -#define Dpt_MAX_BYTES_DEPARTMENT_FULL_NAME (Dpt_MAX_CHARS_DEPARTMENT_FULL_NAME * Str_MAX_BYTES_PER_CHAR) - struct Department { long DptCod; long InsCod; - char ShrtName[Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME + 1]; - char FullName[Dpt_MAX_BYTES_DEPARTMENT_FULL_NAME + 1]; + char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; char WWW[Cns_MAX_BYTES_WWW + 1]; unsigned NumTchs; }; diff --git a/swad_enrollment.c b/swad_enrollment.c index fff52fd1..38bba7b1 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -385,7 +385,7 @@ void Enr_ReqAcceptRegisterInCrs (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Enr_GetNotifEnrollment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], long CrsCod,long UsrCod) { extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; @@ -422,7 +422,7 @@ void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], /* Role (row[0]) */ Role = Rol_ConvertUnsignedStrToRole (row[0]); Str_Copy (SummaryStr,Txt_ROLES_SINGUL_Abc[Role][UsrDat.Sex], - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); /* Free memory used for user's data */ Usr_UsrDataDestructor (&UsrDat); @@ -1947,7 +1947,7 @@ void Enr_SignUpInCrs (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Enr_GetNotifEnrollmentRequest (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long ReqCod,bool GetContent) { @@ -1985,7 +1985,7 @@ void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING /* Role (row[1]) */ DesiredRole = Rol_ConvertUnsignedStrToRole (row[1]); Str_Copy (SummaryStr,Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex], - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); if (GetContent) if ((*ContentStr = (char *) malloc (256))) diff --git a/swad_enrollment.h b/swad_enrollment.h index 48b1bd12..30dd77b4 100644 --- a/swad_enrollment.h +++ b/swad_enrollment.h @@ -27,6 +27,7 @@ /********************************** Headers **********************************/ /*****************************************************************************/ +#include "swad_notification.h" #include "swad_user.h" /*****************************************************************************/ @@ -81,7 +82,7 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, void Enr_WriteFormToReqAnotherUsrID (Act_Action_t NextAction); void Enr_ReqAcceptRegisterInCrs (void); -void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Enr_GetNotifEnrollment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], long CrsCod,long UsrCod); void Enr_UpdateUsrData (struct UsrData *UsrDat); void Enr_FilterUsrDat (struct UsrData *UsrDat); @@ -105,7 +106,7 @@ void Enr_RemAllStdsThisCrs (void); unsigned Enr_RemAllStdsInCrs (struct Course *Crs); void Enr_ReqSignUpInCrs (void); void Enr_SignUpInCrs (void); -void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Enr_GetNotifEnrollmentRequest (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long ReqCod,bool GetContent); void Enr_AskIfRejectSignUp (void); diff --git a/swad_exam.c b/swad_exam.c index 7eb8977a..d435f111 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -122,11 +122,11 @@ static long Exa_GetParamsExamAnnouncement (void) ExaCod = Exa_GetParamExaCod (); /***** Get the name of the course (it is allowed to be different from the official name of the course) *****/ - Par_GetParToText ("CrsName",Gbl.ExamAnns.ExaDat.CrsFullName,Cns_MAX_BYTES_STRING); + Par_GetParToText ("CrsName",Gbl.ExamAnns.ExaDat.CrsFullName,Hie_MAX_BYTES_FULL_NAME); // If the parameter is not present or is empty, initialize the string to the full name of the current course if (!Gbl.ExamAnns.ExaDat.CrsFullName[0]) Str_Copy (Gbl.ExamAnns.ExaDat.CrsFullName,Gbl.CurrentCrs.Crs.FullName, - Crs_MAX_BYTES_COURSE_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /***** Get the year *****/ Gbl.ExamAnns.ExaDat.Year = (unsigned) @@ -136,7 +136,7 @@ static long Exa_GetParamsExamAnnouncement (void) (unsigned long) Gbl.CurrentCrs.Crs.Year); /***** Get the type of exam announcement *****/ - Par_GetParToText ("ExamSession",Gbl.ExamAnns.ExaDat.Session,Cns_MAX_BYTES_STRING); + Par_GetParToText ("ExamSession",Gbl.ExamAnns.ExaDat.Session,Exa_MAX_BYTES_SESSION); /***** Get the data of the exam *****/ Dat_GetDateFromForm ("ExamDay","ExamMonth","ExamYear", @@ -737,7 +737,10 @@ static long Exa_AddExamAnnouncementToDB (void) long ExaCod; /***** Add exam announcement *****/ - if ((Query = malloc (512 + 2 * Cns_MAX_BYTES_STRING + 7 * Cns_MAX_BYTES_TEXT)) == NULL) + if ((Query = malloc (512 + + Hie_MAX_BYTES_FULL_NAME + + Exa_MAX_BYTES_SESSION + + 7 * Cns_MAX_BYTES_TEXT)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to query database."); sprintf (Query,"INSERT INTO exam_announcements " "(CrsCod,Status,NumNotif,CrsFullName,Year,ExamSession," @@ -781,7 +784,10 @@ static void Exa_ModifyExamAnnouncementInDB (void) char *Query; /***** Modify exam announcement *****/ - if ((Query = malloc (512 + 2 * Cns_MAX_BYTES_STRING + 7 * Cns_MAX_BYTES_TEXT)) == NULL) + if ((Query = malloc (512 + + Hie_MAX_BYTES_FULL_NAME + + Exa_MAX_BYTES_SESSION + + 7 * Cns_MAX_BYTES_TEXT)) == NULL) Lay_ShowErrorAndExit ("Not enough memory to query database."); sprintf (Query,"UPDATE exam_announcements" " SET CrsFullName='%s',Year='%u',ExamSession='%s'," @@ -926,7 +932,7 @@ static void Exa_GetDataExamAnnouncementFromDB (void) /* Name of the course (row[2]) */ Str_Copy (Gbl.ExamAnns.ExaDat.CrsFullName,row[2], - Crs_MAX_BYTES_COURSE_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /* Year (row[3]) */ if (sscanf (row[3],"%u",&Gbl.ExamAnns.ExaDat.Year) != 1) @@ -934,7 +940,7 @@ static void Exa_GetDataExamAnnouncementFromDB (void) /* Exam session (row[4]) */ Str_Copy (Gbl.ExamAnns.ExaDat.Session,row[4], - Cns_MAX_BYTES_STRING); + Exa_MAX_BYTES_SESSION); /* Date of exam announcement (row[5]) */ if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u", @@ -1136,7 +1142,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa { fprintf (Gbl.F.Out,"", - Cns_MAX_CHARS_STRING,Gbl.ExamAnns.ExaDat.CrsFullName); + Hie_MAX_CHARS_FULL_NAME,Gbl.ExamAnns.ExaDat.CrsFullName); } else fprintf (Gbl.F.Out,"%s", @@ -1189,7 +1195,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa fprintf (Gbl.F.Out,"", - Cns_MAX_CHARS_STRING,Gbl.ExamAnns.ExaDat.Session); + Exa_MAX_CHARS_SESSION,Gbl.ExamAnns.ExaDat.Session); else fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.Session); fprintf (Gbl.F.Out,"" @@ -1606,12 +1612,12 @@ static long Exa_GetParamExaCod (void) /************ Get summary and content about an exam announcement *************/ /*****************************************************************************/ -void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long ExaCod,bool GetContent) { extern const char *Txt_hours_ABBREVIATION; - char CrsNameAndDate[Crs_MAX_BYTES_COURSE_FULL_NAME + (2 + Cns_MAX_BYTES_DATE + 6) + 1]; + char CrsNameAndDate[Hie_MAX_BYTES_FULL_NAME + (2 + Cns_MAX_BYTES_DATE + 6) + 1]; /***** Initializations *****/ Gbl.ExamAnns.ExaDat.ExaCod = ExaCod; @@ -1637,7 +1643,7 @@ void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Cns_MAX_BYTES_SUM Gbl.ExamAnns.ExaDat.StartTime.Hour, Gbl.ExamAnns.ExaDat.StartTime.Minute); Str_Copy (SummaryStr,CrsNameAndDate, - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); /***** Free memory of the exam announcement *****/ Exa_FreeMemExamAnnouncement (); diff --git a/swad_exam.h b/swad_exam.h index e3a6c767..d654d8f7 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -32,6 +32,7 @@ #include "swad_constant.h" #include "swad_course.h" #include "swad_date.h" +#include "swad_notification.h" /*****************************************************************************/ /************************** Public types and constants ***********************/ @@ -53,14 +54,17 @@ typedef enum Exa_DELETED_EXAM_ANNOUNCEMENT = 2, } Exa_ExamAnnouncementStatus_t; // Don't change these numbers because they are used in database +#define Exa_MAX_CHARS_SESSION (128 - 1) // 127 +#define Exa_MAX_BYTES_SESSION ((Exa_MAX_CHARS_SESSION + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 + struct ExamData { long ExaCod; long CrsCod; Exa_ExamAnnouncementStatus_t Status; - char CrsFullName[Crs_MAX_BYTES_COURSE_FULL_NAME + 1]; + char CrsFullName[Hie_MAX_BYTES_FULL_NAME + 1]; unsigned Year; // Number of year (0 (N.A.), 1, 2, 3, 4, 5, 6) in the degree - char Session[Cns_MAX_BYTES_STRING + 1]; // Exam session is june, september, etc. + char Session[Exa_MAX_BYTES_SESSION + 1]; // Exam session is june, september, etc. struct Date CallDate; struct Date ExamDate; struct Hour StartTime; @@ -99,7 +103,7 @@ void Exa_GetDateToHighlight (void); void Exa_CreateListDatesOfExamAnnouncements (void); void Exa_PutHiddenParamExaCod (long ExaCod); -void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long ExaCod,bool GetContent); diff --git a/swad_file_browser.c b/swad_file_browser.c index 7f593d69..2e28ee36 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -11141,7 +11141,7 @@ void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat,Cns_QuietOrVerbose_t Qu #define Brw_MAX_BYTES_FILE_CONTENT_STR (100 + NAME_MAX + 100 + PATH_MAX + 100 + Usr_MAX_BYTES_FULL_NAME + 100 + Fil_MAX_BYTES_FILE_SIZE_STRING) -void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Brw_GetSummaryAndContentOfFile (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long FilCod,bool GetContent) { @@ -11164,7 +11164,7 @@ void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRIN /***** Copy file name into summary string *****/ Str_Copy (SummaryStr,FileMetadata.FilFolLnkName, - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); /***** Copy some file metadata into content string *****/ if (GetContent && ContentStr) diff --git a/swad_file_browser.h b/swad_file_browser.h index c31cb8d9..8dbf96d4 100644 --- a/swad_file_browser.h +++ b/swad_file_browser.h @@ -30,6 +30,7 @@ #include // For PATH_MAX #include "swad_group.h" +#include "swad_notification.h" /*****************************************************************************/ /******************************* Public types ********************************/ @@ -136,10 +137,10 @@ struct FileMetadata #define Brw_MAX_DIR_LEVELS 10 // Maximum number of subdirectory levels in file browsers -#define Brw_MAX_BYTES_MIME_TYPE (128 - 1) // Maximum size in bytes of "image/jpeg", "text/html", etc. +#define Brw_MAX_BYTES_MIME_TYPE (128 - 1) // 127: maximum size in bytes of "image/jpeg", "text/html", etc. -#define Brw_MAX_CHARS_LICENSE (128 - 1) -#define Brw_MAX_BYTES_LICENSE (Brw_MAX_CHARS_LICENSE * Str_MAX_BYTES_PER_CHAR) +#define Brw_MAX_CHARS_LICENSE (128 - 1) // 127 +#define Brw_MAX_BYTES_LICENSE ((Brw_MAX_CHARS_LICENSE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Brw_INTERNAL_NAME_ROOT_FOLDER_DOCUMENTS "doc" #define Brw_INTERNAL_NAME_ROOT_FOLDER_SHARED_FILES "sha" @@ -248,7 +249,7 @@ void Brw_RemoveGrpZones (long CrsCod,long GrpCod); void Brw_RemoveUsrWorksInCrs (struct UsrData *UsrDat,struct Course *Crs,Cns_QuietOrVerbose_t QuietOrVerbose); void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat,Cns_QuietOrVerbose_t QuietOrVerbose); -void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Brw_GetSummaryAndContentOfFile (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long FilCod,bool GetContent); diff --git a/swad_follow.c b/swad_follow.c index e779e811..01d95107 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -1176,7 +1176,7 @@ void Fol_GetAndShowRankingFollowers (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Fol_GetNotifFollower (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Fol_GetNotifFollower (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr) { SummaryStr[0] = '\0'; // Return nothing on error diff --git a/swad_follow.h b/swad_follow.h index f2fc7c1c..fd2e62fb 100644 --- a/swad_follow.h +++ b/swad_follow.h @@ -29,6 +29,7 @@ #include // For malloc +#include "swad_notification.h" #include "swad_user.h" /*****************************************************************************/ @@ -63,7 +64,7 @@ void Fol_UnfollowUsr2 (void); void Fol_GetAndShowRankingFollowers (void); -void Fol_GetNotifFollower (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Fol_GetNotifFollower (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr); void Fol_RemoveUsrFromUsrFollow (long UsrCod); diff --git a/swad_forum.c b/swad_forum.c index f995a0d5..0ceb1c2f 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -1399,7 +1399,7 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC, /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long PstCod,bool GetContent) { @@ -1424,15 +1424,15 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STR /***** Copy subject *****/ // TODO: Do only direct copy when Subject will be VARCHAR(255) - if (strlen (row[0]) > Cns_MAX_BYTES_SUMMARY_STRING) + if (strlen (row[0]) > Ntf_MAX_BYTES_SUMMARY) { strncpy (SummaryStr,row[0], - Cns_MAX_BYTES_SUMMARY_STRING); - SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING] = '\0'; + Ntf_MAX_BYTES_SUMMARY); + SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0'; } else Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); /***** Copy content *****/ if (GetContent) diff --git a/swad_forum.h b/swad_forum.h index 0ccd89c9..044e9c19 100644 --- a/swad_forum.h +++ b/swad_forum.h @@ -30,6 +30,7 @@ #include "swad_centre.h" #include "swad_degree.h" #include "swad_institution.h" +#include "swad_notification.h" #include "swad_pagination.h" #include "swad_scope.h" #include "swad_string.h" @@ -101,7 +102,7 @@ unsigned long For_GetNumPostsUsr (long UsrCod); void For_DeleteThrFromReadThrs (long ThrCod); void For_RemoveUsrFromReadThrs (long UsrCod); -void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long PstCod,bool GetContent); diff --git a/swad_global.h b/swad_global.h index 7be17943..9773186f 100644 --- a/swad_global.h +++ b/swad_global.h @@ -600,10 +600,10 @@ struct Globals struct { long CrsCod; - char ShrtName[Crs_MAX_BYTES_COURSE_SHRT_NAME + 1]; + char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; } Courses[Crs_MAX_COURSES_PER_USR]; // Distinct courses in my messages sent or received long FilterCrsCod; // Show only messages sent from this course code - char FilterCrsShrtName[Crs_MAX_BYTES_COURSE_SHRT_NAME + 1]; + char FilterCrsShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; char FilterFromTo[Usr_MAX_BYTES_FULL_NAME + 1]; // Show only messages from/to these users char FilterContent[Msg_MAX_BYTES_FILTER_CONTENT + 1]; // Show only messages that match this content bool ShowOnlyUnreadMsgs; // Show only unread messages (this option is applicable only for received messages) diff --git a/swad_group.h b/swad_group.h index aa6f46be..1bd51676 100644 --- a/swad_group.h +++ b/swad_group.h @@ -34,11 +34,11 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -#define Grp_MAX_CHARS_GROUP_TYPE_NAME (128 - 1) -#define Grp_MAX_BYTES_GROUP_TYPE_NAME (Grp_MAX_CHARS_GROUP_TYPE_NAME * Str_MAX_BYTES_PER_CHAR) +#define Grp_MAX_CHARS_GROUP_TYPE_NAME (128 - 1) // 127 +#define Grp_MAX_BYTES_GROUP_TYPE_NAME ((Grp_MAX_CHARS_GROUP_TYPE_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 -#define Grp_MAX_CHARS_GROUP_NAME (128 - 1) -#define Grp_MAX_BYTES_GROUP_NAME (Grp_MAX_CHARS_GROUP_NAME * Str_MAX_BYTES_PER_CHAR) +#define Grp_MAX_CHARS_GROUP_NAME (128 - 1) // 127 +#define Grp_MAX_BYTES_GROUP_NAME ((Grp_MAX_CHARS_GROUP_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Grp_MAX_STUDENTS_IN_A_GROUP 10000 // If max of students in a group is greater than this, it is considered infinite #define Grp_NUM_STUDENTS_NOT_LIMITED INT_MAX // This number can be stored in database as an integer... diff --git a/swad_hierarchy.h b/swad_hierarchy.h index 9d0f11e2..fc3e11f0 100644 --- a/swad_hierarchy.h +++ b/swad_hierarchy.h @@ -31,6 +31,12 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ +#define Hie_MAX_CHARS_SHRT_NAME (32 - 1) // 31 +#define Hie_MAX_BYTES_SHRT_NAME ((Hie_MAX_CHARS_SHRT_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 + +#define Hie_MAX_CHARS_FULL_NAME (128 - 1) // 127 +#define Hie_MAX_BYTES_FULL_NAME ((Hie_MAX_CHARS_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 + /*****************************************************************************/ /******************************* Public types ********************************/ /*****************************************************************************/ diff --git a/swad_holiday.h b/swad_holiday.h index 621bbf8a..b18e2fb0 100644 --- a/swad_holiday.h +++ b/swad_holiday.h @@ -34,8 +34,8 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Hld_MAX_CHARS_HOLIDAY_NAME (128 - 1) -#define Hld_MAX_BYTES_HOLIDAY_NAME (Hld_MAX_CHARS_HOLIDAY_NAME * Str_MAX_BYTES_PER_CHAR) +#define Hld_MAX_CHARS_HOLIDAY_NAME (128 - 1) // 127 +#define Hld_MAX_BYTES_HOLIDAY_NAME ((Hld_MAX_CHARS_HOLIDAY_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Hld_NUM_TYPES_HOLIDAY 2 typedef enum diff --git a/swad_image.c b/swad_image.c index c1536904..521c6f12 100644 --- a/swad_image.c +++ b/swad_image.c @@ -235,14 +235,14 @@ void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTitURL) " class=\"%s\" maxlength=\"%u\" value=\"\" />", ParamUploadImg.Title, Txt_Image_title_attribution,Txt_optional, - ClassImgTitURL,Img_MAX_BYTES_TITLE); + ClassImgTitURL,Img_MAX_CHARS_TITLE); fprintf (Gbl.F.Out,"
" "", ParamUploadImg.URL, Txt_Link,Txt_optional, - ClassImgTitURL,Img_MAX_BYTES_URL); + ClassImgTitURL,Cns_MAX_CHARS_WWW); fprintf (Gbl.F.Out,""); /***** End container *****/ @@ -260,7 +260,7 @@ void Img_GetImageFromForm (int NumImgInForm,struct Image *Image, { struct ParamUploadImg ParamUploadImg; char Title[Img_MAX_BYTES_TITLE + 1]; - char URL[Img_MAX_BYTES_URL + 1]; + char URL[Cns_MAX_BYTES_WWW + 1]; size_t Length; /***** Set names of parameters depending on number of image in form *****/ @@ -325,7 +325,7 @@ void Img_GetImageFromForm (int NumImgInForm,struct Image *Image, } /***** By last, get image URL from form *****/ - Par_GetParToText (ParamUploadImg.URL,URL,Img_MAX_BYTES_URL); + Par_GetParToText (ParamUploadImg.URL,URL,Cns_MAX_BYTES_WWW); /* If the URL coming from the form is empty, keep current image URL unchanged If not empty, copy it to current image URL */ if ((Length = strlen (URL)) > 0) diff --git a/swad_image.h b/swad_image.h index 4fa811e7..0e667dc7 100644 --- a/swad_image.h +++ b/swad_image.h @@ -31,8 +31,11 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -#define Img_MAX_BYTES_TITLE 255 -#define Img_MAX_BYTES_URL 255 +#define Img_MAX_CHARS_TITLE (128 - 1) // 127 +#define Img_MAX_BYTES_TITLE ((Img_MAX_CHARS_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 + +#define Img_MAX_CHARS_ATTRIBUTION (256 - 1) // 255 +#define Img_MAX_BYTES_ATTRIBUTION ((Img_MAX_CHARS_ATTRIBUTION + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 4095 /*****************************************************************************/ /******************************* Public types ********************************/ diff --git a/swad_institution.c b/swad_institution.c index 3b2ec69c..08105b51 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -76,7 +76,7 @@ static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable); static void Ins_GetParamInsOrder (void); static void Ins_GetFullNameAndCtyOfInstitutionByCod (struct Instit *Ins, - char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]); + char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]); static void Ins_ListInstitutionsForEdition (void); static bool Ins_CheckIfICanEdit (struct Instit *Ins); @@ -385,7 +385,7 @@ static void Ins_Configuration (bool PrintView) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_FULL_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Ins_MAX_CHARS_INSTIT_FULL_NAME, + Hie_MAX_CHARS_FULL_NAME, Gbl.CurrentIns.Ins.FullName, Gbl.Form.Id); Act_FormEnd (); @@ -414,7 +414,7 @@ static void Ins_Configuration (bool PrintView) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_SHORT_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Ins_MAX_CHARS_INSTIT_SHRT_NAME, + Hie_MAX_CHARS_SHRT_NAME, Gbl.CurrentIns.Ins.ShrtName, Gbl.Form.Id); Act_FormEnd (); @@ -1030,11 +1030,11 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData) /* Get the short name of the institution (row[4]) */ Str_Copy (Ins->ShrtName,row[4], - Ins_MAX_BYTES_INSTIT_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); /* Get the full name of the institution (row[5]) */ Str_Copy (Ins->FullName,row[5], - Ins_MAX_BYTES_INSTIT_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /* Get the URL of the institution (row[6]) */ Str_Copy (Ins->WWW,row[6], @@ -1086,7 +1086,7 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData) void Ins_WriteInstitutionNameAndCty (long InsCod) { struct Instit Ins; - char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]; + char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; /***** Get institution full name *****/ Ins.InsCod = InsCod; @@ -1145,11 +1145,11 @@ bool Ins_GetDataOfInstitutionByCod (struct Instit *Ins, /* Get the short name of the institution (row[3]) */ Str_Copy (Ins->ShrtName,row[3], - Ins_MAX_BYTES_INSTIT_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); /* Get the full name of the institution (row[4]) */ Str_Copy (Ins->FullName,row[4], - Ins_MAX_BYTES_INSTIT_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /* Get the URL of the institution (row[5]) */ Str_Copy (Ins->WWW,row[5], @@ -1194,7 +1194,7 @@ void Ins_GetShortNameOfInstitutionByCod (struct Instit *Ins) static struct { long InsCod; - char ShrtName[Ins_MAX_BYTES_INSTIT_SHRT_NAME + 1]; + char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; } Cached = { -1L, @@ -1217,7 +1217,7 @@ void Ins_GetShortNameOfInstitutionByCod (struct Instit *Ins) row = mysql_fetch_row (mysql_res); Str_Copy (Cached.ShrtName,row[0], - Ins_MAX_BYTES_INSTIT_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); } else Cached.ShrtName[0] = '\0'; @@ -1227,7 +1227,7 @@ void Ins_GetShortNameOfInstitutionByCod (struct Instit *Ins) } Str_Copy (Ins->ShrtName,Cached.ShrtName, - Ins_MAX_BYTES_INSTIT_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); } } @@ -1236,7 +1236,7 @@ void Ins_GetShortNameOfInstitutionByCod (struct Instit *Ins) /*****************************************************************************/ static void Ins_GetFullNameAndCtyOfInstitutionByCod (struct Instit *Ins, - char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]) + char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]) { extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES]; char Query[256]; @@ -1245,8 +1245,8 @@ static void Ins_GetFullNameAndCtyOfInstitutionByCod (struct Instit *Ins, static struct { long InsCod; - char FullName[Ins_MAX_BYTES_INSTIT_FULL_NAME + 1]; - char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]; + char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; + char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; } Cached = { -1L, @@ -1276,11 +1276,11 @@ static void Ins_GetFullNameAndCtyOfInstitutionByCod (struct Instit *Ins, /* Get the full name of this institution (row[0]) */ Str_Copy (Cached.FullName,row[0], - Ins_MAX_BYTES_INSTIT_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /* Get the name of the country (row[1]) */ Str_Copy (Cached.CtyName,row[1], - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); } else { @@ -1293,9 +1293,9 @@ static void Ins_GetFullNameAndCtyOfInstitutionByCod (struct Instit *Ins, } Str_Copy (Ins->FullName,Cached.FullName, - Ins_MAX_BYTES_INSTIT_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); Str_Copy (CtyName,Cached.CtyName, - Cty_MAX_BYTES_COUNTRY_NAME); + Hie_MAX_BYTES_FULL_NAME); } } @@ -1453,7 +1453,7 @@ static void Ins_ListInstitutionsForEdition (void) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_SHORT_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Ins_MAX_CHARS_INSTIT_SHRT_NAME,Ins->ShrtName, + Hie_MAX_CHARS_SHRT_NAME,Ins->ShrtName, Gbl.Form.Id); Act_FormEnd (); } @@ -1471,7 +1471,7 @@ static void Ins_ListInstitutionsForEdition (void) " maxlength=\"%u\" value=\"%s\"" " class=\"INPUT_FULL_NAME\"" " onchange=\"document.getElementById('%s').submit();\" />", - Ins_MAX_CHARS_INSTIT_FULL_NAME, + Hie_MAX_CHARS_FULL_NAME, Ins->FullName, Gbl.Form.Id); Act_FormEnd (); @@ -1767,20 +1767,20 @@ static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtO const char *FieldName = NULL; // Initialized to avoid warning unsigned MaxBytes = 0; // Initialized to avoid warning char *CurrentInsName = NULL; // Initialized to avoid warning - char NewInsName[Ins_MAX_BYTES_INSTIT_FULL_NAME + 1]; + char NewInsName[Hie_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - MaxBytes = Ins_MAX_BYTES_INSTIT_SHRT_NAME; + MaxBytes = Hie_MAX_BYTES_SHRT_NAME; CurrentInsName = Ins->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - MaxBytes = Ins_MAX_BYTES_INSTIT_FULL_NAME; + MaxBytes = Hie_MAX_BYTES_FULL_NAME; CurrentInsName = Ins->FullName; break; } @@ -1835,7 +1835,7 @@ static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtO static bool Ins_CheckIfInsNameExistsInCty (const char *FieldName,const char *Name,long InsCod,long CtyCod) { - char Query[256 + Ins_MAX_BYTES_INSTIT_FULL_NAME]; + char Query[256 + Hie_MAX_BYTES_FULL_NAME]; /***** Get number of institutions in current country with a name from database *****/ sprintf (Query,"SELECT COUNT(*) FROM institutions" @@ -1850,7 +1850,7 @@ static bool Ins_CheckIfInsNameExistsInCty (const char *FieldName,const char *Nam static void Ins_UpdateInsNameDB (long InsCod,const char *FieldName,const char *NewInsName) { - char Query[128 + Ins_MAX_BYTES_INSTIT_FULL_NAME]; + char Query[128 + Hie_MAX_BYTES_FULL_NAME]; /***** Update institution changing old name by new name */ sprintf (Query,"UPDATE institutions SET %s='%s' WHERE InsCod='%ld'", @@ -2196,7 +2196,7 @@ static void Ins_PutFormToCreateInstitution (void) " class=\"INPUT_SHORT_NAME\"" " required=\"required\" />" "", - Ins_MAX_CHARS_INSTIT_SHRT_NAME,Ins->ShrtName); + Hie_MAX_CHARS_SHRT_NAME,Ins->ShrtName); /***** Institution full name *****/ fprintf (Gbl.F.Out,"" @@ -2205,7 +2205,7 @@ static void Ins_PutFormToCreateInstitution (void) " class=\"INPUT_FULL_NAME\"" " required=\"required\" />" "", - Ins_MAX_CHARS_INSTIT_FULL_NAME,Ins->FullName); + Hie_MAX_CHARS_FULL_NAME,Ins->FullName); /***** Institution WWW *****/ fprintf (Gbl.F.Out,"" @@ -2349,10 +2349,10 @@ static void Ins_RecFormRequestOrCreateIns (unsigned Status) Ins->CtyCod = Gbl.CurrentCty.Cty.CtyCod; /* Get institution short name */ - Par_GetParToText ("ShortName",Ins->ShrtName,Ins_MAX_BYTES_INSTIT_SHRT_NAME); + Par_GetParToText ("ShortName",Ins->ShrtName,Hie_MAX_BYTES_SHRT_NAME); /* Get institution full name */ - Par_GetParToText ("FullName",Ins->FullName,Ins_MAX_BYTES_INSTIT_FULL_NAME); + Par_GetParToText ("FullName",Ins->FullName,Hie_MAX_BYTES_FULL_NAME); /* Get institution WWW */ Par_GetParToText ("WWW",Ins->WWW,Cns_MAX_BYTES_WWW); @@ -2395,8 +2395,8 @@ static void Ins_CreateInstitution (struct Instit *Ins,unsigned Status) { extern const char *Txt_Created_new_institution_X; char Query[512 + - Ins_MAX_BYTES_INSTIT_SHRT_NAME + - Ins_MAX_BYTES_INSTIT_FULL_NAME + + Hie_MAX_BYTES_SHRT_NAME + + Hie_MAX_BYTES_FULL_NAME + Cns_MAX_BYTES_WWW]; /***** Create a new institution *****/ diff --git a/swad_institution.h b/swad_institution.h index 0a391a0e..15609f45 100644 --- a/swad_institution.h +++ b/swad_institution.h @@ -55,20 +55,14 @@ typedef enum #define Ins_MAX_INSTITS_PER_USR 10 // Used in list of my institutions -#define Ins_MAX_CHARS_INSTIT_SHRT_NAME 32 -#define Ins_MAX_BYTES_INSTIT_SHRT_NAME (Ins_MAX_CHARS_INSTIT_SHRT_NAME * Str_MAX_BYTES_PER_CHAR) - -#define Ins_MAX_CHARS_INSTIT_FULL_NAME (128 - 1) -#define Ins_MAX_BYTES_INSTIT_FULL_NAME (Ins_MAX_CHARS_INSTIT_FULL_NAME * Str_MAX_BYTES_PER_CHAR) - struct Instit { long InsCod; long CtyCod; Ins_Status_t Status; // Institution status long RequesterUsrCod; // User code of the person who requested the creation of this institution - char ShrtName[Ins_MAX_BYTES_INSTIT_SHRT_NAME + 1]; - char FullName[Ins_MAX_BYTES_INSTIT_FULL_NAME + 1]; + char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; char WWW[Cns_MAX_BYTES_WWW + 1]; unsigned NumUsrsWhoClaimToBelongToIns; unsigned NumCtrs; diff --git a/swad_link.h b/swad_link.h index 326cb1a4..b5a64737 100644 --- a/swad_link.h +++ b/swad_link.h @@ -31,11 +31,11 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Lnk_MAX_CHARS_LINK_SHRT_NAME 32 -#define Lnk_MAX_BYTES_LINK_SHRT_NAME (Lnk_MAX_CHARS_LINK_SHRT_NAME * Str_MAX_BYTES_PER_CHAR) +#define Lnk_MAX_CHARS_LINK_SHRT_NAME (32 - 1) // 31 +#define Lnk_MAX_BYTES_LINK_SHRT_NAME ((Lnk_MAX_CHARS_LINK_SHRT_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 -#define Lnk_MAX_CHARS_LINK_FULL_NAME (128 - 1) -#define Lnk_MAX_BYTES_LINK_FULL_NAME (Lnk_MAX_CHARS_LINK_FULL_NAME * Str_MAX_BYTES_PER_CHAR) +#define Lnk_MAX_CHARS_LINK_FULL_NAME (128 - 1) // 127 +#define Lnk_MAX_BYTES_LINK_FULL_NAME ((Lnk_MAX_CHARS_LINK_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 struct Link { diff --git a/swad_mail.h b/swad_mail.h index 98a5945b..bb093bbd 100644 --- a/swad_mail.h +++ b/swad_mail.h @@ -33,11 +33,11 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Mai_MAX_CHARS_MAIL_DOMAIN (128 - 1) -#define Mai_MAX_BYTES_MAIL_DOMAIN (Mai_MAX_CHARS_MAIL_DOMAIN * Str_MAX_BYTES_PER_CHAR) +#define Mai_MAX_CHARS_MAIL_DOMAIN (128 - 1) // 127 +#define Mai_MAX_BYTES_MAIL_DOMAIN ((Mai_MAX_CHARS_MAIL_DOMAIN + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 -#define Mai_MAX_CHARS_MAIL_INFO (128 - 1) -#define Mai_MAX_BYTES_MAIL_INFO (Mai_MAX_CHARS_MAIL_INFO * Str_MAX_BYTES_PER_CHAR) +#define Mai_MAX_CHARS_MAIL_INFO (128 - 1) // 127 +#define Mai_MAX_BYTES_MAIL_INFO ((Mai_MAX_CHARS_MAIL_INFO + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Mai_NUM_ORDERS 3 typedef enum diff --git a/swad_mark.c b/swad_mark.c index e89300ec..4fb36705 100644 --- a/swad_mark.c +++ b/swad_mark.c @@ -709,7 +709,7 @@ void Mrk_ShowMyMarks (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long MrkCod,long UsrCod,bool GetContent) { diff --git a/swad_mark.h b/swad_mark.h index 303dc60b..dd466592 100644 --- a/swad_mark.h +++ b/swad_mark.h @@ -52,7 +52,7 @@ void Mrk_ChangeNumRowsFooter (void); bool Mrk_CheckFileOfMarks (const char *Path,struct MarksProperties *Marks); void Mrk_ShowMyMarks (void); -void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long MrkCod,long UsrCod,bool GetContent); diff --git a/swad_message.c b/swad_message.c index 99df7aeb..be80d060 100644 --- a/swad_message.c +++ b/swad_message.c @@ -1003,11 +1003,11 @@ void Msg_GetParamMsgsCrsCod (void) Crs_GetDataOfCourseByCod (&Crs); Str_Copy (Gbl.Msg.FilterCrsShrtName,Crs.ShrtName, - Crs_MAX_BYTES_COURSE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); } else Str_Copy (Gbl.Msg.FilterCrsShrtName,Txt_any_course, - Crs_MAX_BYTES_COURSE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); } /*****************************************************************************/ @@ -2503,7 +2503,7 @@ void Msg_GetDistinctCoursesInMyMessages (void) { Gbl.Msg.Courses[Gbl.Msg.NumCourses].CrsCod = Crs.CrsCod; Str_Copy (Gbl.Msg.Courses[Gbl.Msg.NumCourses].ShrtName,Crs.ShrtName, - Crs_MAX_BYTES_COURSE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); Gbl.Msg.NumCourses++; } } @@ -2995,7 +2995,7 @@ static void Msg_ShowASentOrReceivedMessage (long MsgNum,long MsgCod) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Msg_GetNotifMessage (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr,long MsgCod,bool GetContent) { extern const char *Txt_MSG_Subject; @@ -3020,15 +3020,15 @@ void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], /***** Copy subject *****/ // TODO: Do only direct copy when Subject will be VARCHAR(255) - if (strlen (row[0]) > Cns_MAX_BYTES_SUMMARY_STRING) + if (strlen (row[0]) > Ntf_MAX_BYTES_SUMMARY) { strncpy (SummaryStr,row[0], - Cns_MAX_BYTES_SUMMARY_STRING); - SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING] = '\0'; + Ntf_MAX_BYTES_SUMMARY); + SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0'; } else Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); /***** Copy subject *****/ if (GetContent) diff --git a/swad_message.h b/swad_message.h index a9ec4644..a97555dc 100644 --- a/swad_message.h +++ b/swad_message.h @@ -33,8 +33,8 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Msg_MAX_CHARS_FILTER_CONTENT (128 - 1) -#define Msg_MAX_BYTES_FILTER_CONTENT (Msg_MAX_CHARS_FILTER_CONTENT * Str_MAX_BYTES_PER_CHAR) +#define Msg_MAX_CHARS_FILTER_CONTENT (128 - 1) // 127 +#define Msg_MAX_BYTES_FILTER_CONTENT ((Msg_MAX_CHARS_FILTER_CONTENT + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 /*****************************************************************************/ /******************************** Public types *******************************/ @@ -95,7 +95,7 @@ void Msg_GetDistinctCoursesInMyMessages (void); void Msg_ShowFormSelectCourseSentOrRecMsgs (void); void Msg_ShowFormToFilterMsgs (void); void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1]); -void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Msg_GetNotifMessage (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr,long MsgCod,bool GetContent); void Msg_WriteMsgNumber (unsigned long MsgNum,bool NewMsg); diff --git a/swad_notice.c b/swad_notice.c index f503f280..bc3e8ac7 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -745,7 +745,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long NotCod,bool GetContent) { @@ -770,15 +770,15 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRIN /***** Copy summary *****/ // TODO: Do only direct copy when a Subject of type VARCHAR(255) is available - if (strlen (row[0]) > Cns_MAX_BYTES_SUMMARY_STRING) + if (strlen (row[0]) > Ntf_MAX_BYTES_SUMMARY) { strncpy (SummaryStr,row[0], - Cns_MAX_BYTES_SUMMARY_STRING); - SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING] = '\0'; + Ntf_MAX_BYTES_SUMMARY); + SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0'; } else Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); /***** Copy content *****/ if (GetContent) diff --git a/swad_notice.h b/swad_notice.h index 89816e00..28765920 100644 --- a/swad_notice.h +++ b/swad_notice.h @@ -68,7 +68,7 @@ void Not_RemoveNotice (void); void Not_GetNotCodToHighlight (void); void Not_ShowNotices (Not_Listing_t TypeNoticesListing); -void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long NotCod,bool GetContent); unsigned Not_GetNumNotices (Sco_Scope_t Scope,Not_Status_t Status,unsigned *NumNotif); diff --git a/swad_notification.c b/swad_notification.c index 8d237a2c..87493b50 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -324,7 +324,7 @@ void Ntf_ShowMyNotifications (void) time_t DateTimeUTC; // Date-time of the event Ntf_Status_t Status; Ntf_StatusTxt_t StatusTxt; - char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]; + char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]; char *ContentStr; const char *ClassBackground; const char *ClassAnchor; @@ -853,7 +853,7 @@ Ntf_StatusTxt_t Ntf_GetStatusTxtFromStatusBits (Ntf_Status_t Status) /******************* Get notification summary and content ********************/ /*****************************************************************************/ -void Ntf_GetNotifSummaryAndContent (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Ntf_GetNotifSummaryAndContent (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, Ntf_NotifyEvent_t NotifyEvent, long Cod,long CrsCod,long UsrCod, diff --git a/swad_notification.h b/swad_notification.h index 5e2d92d9..5a5acbe9 100644 --- a/swad_notification.h +++ b/swad_notification.h @@ -33,10 +33,13 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Ntf_MAX_BYTES_NOTIFY_EVENT 32 +#define Ntf_MAX_BYTES_NOTIFY_EVENT (32 - 1) // 31 -#define Ntf_MAX_CHARS_NOTIFY_LOCATION (128 - 1) -#define Ntf_MAX_BYTES_NOTIFY_LOCATION (1024 + Ntf_MAX_CHARS_NOTIFY_LOCATION * Str_MAX_BYTES_PER_CHAR) +#define Ntf_MAX_CHARS_NOTIFY_LOCATION (128 - 1) // 127 +#define Ntf_MAX_BYTES_NOTIFY_LOCATION (2048 + (Ntf_MAX_CHARS_NOTIFY_LOCATION + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 4095 + +#define Ntf_MAX_CHARS_SUMMARY (256 - 1) // 255 +#define Ntf_MAX_BYTES_SUMMARY ((Ntf_MAX_CHARS_SUMMARY + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 4095 /*****************************************************************************/ /******************************** Public types *******************************/ @@ -112,7 +115,7 @@ void Ntf_ShowMyNotifications (void); Ntf_NotifyEvent_t Ntf_GetParamNotifyEvent (void); Ntf_StatusTxt_t Ntf_GetStatusTxtFromStatusBits (Ntf_Status_t Status); -void Ntf_GetNotifSummaryAndContent (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Ntf_GetNotifSummaryAndContent (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, Ntf_NotifyEvent_t NotifyEvent, long Cod,long CrsCod,long UsrCod, diff --git a/swad_place.h b/swad_place.h index 9d681db4..8c0934df 100644 --- a/swad_place.h +++ b/swad_place.h @@ -31,11 +31,11 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Plc_MAX_CHARS_PLACE_SHRT_NAME 32 -#define Plc_MAX_BYTES_PLACE_SHRT_NAME (Plc_MAX_CHARS_PLACE_SHRT_NAME * Str_MAX_BYTES_PER_CHAR) +#define Plc_MAX_CHARS_PLACE_SHRT_NAME (32 - 1) // 31 +#define Plc_MAX_BYTES_PLACE_SHRT_NAME ((Plc_MAX_CHARS_PLACE_SHRT_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 -#define Plc_MAX_CHARS_PLACE_FULL_NAME (128 - 1) -#define Plc_MAX_BYTES_PLACE_FULL_NAME (Plc_MAX_CHARS_PLACE_FULL_NAME * Str_MAX_BYTES_PER_CHAR) +#define Plc_MAX_CHARS_PLACE_FULL_NAME (128 - 1) // 127 +#define Plc_MAX_BYTES_PLACE_FULL_NAME ((Plc_MAX_CHARS_PLACE_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 struct Place { diff --git a/swad_plugin.h b/swad_plugin.h index cd4f6941..257e69a4 100644 --- a/swad_plugin.h +++ b/swad_plugin.h @@ -31,17 +31,17 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Plg_MAX_CHARS_PLUGIN_NAME (128 - 1) -#define Plg_MAX_BYTES_PLUGIN_NAME (Plg_MAX_CHARS_PLUGIN_NAME * Str_MAX_BYTES_PER_CHAR) +#define Plg_MAX_CHARS_PLUGIN_NAME (32 - 1) // 31 +#define Plg_MAX_BYTES_PLUGIN_NAME ((Plg_MAX_CHARS_PLUGIN_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 -#define Plg_MAX_CHARS_PLUGIN_DESCRIPTION (128 - 1) -#define Plg_MAX_BYTES_PLUGIN_DESCRIPTION (Plg_MAX_CHARS_PLUGIN_DESCRIPTION * Str_MAX_BYTES_PER_CHAR) +#define Plg_MAX_CHARS_PLUGIN_DESCRIPTION (128 - 1) // 127 +#define Plg_MAX_BYTES_PLUGIN_DESCRIPTION (Plg_MAX_CHARS_PLUGIN_DESCRIPTION * Str_MAX_BYTES_PER_CHAR) // 2047 -#define Plg_MAX_CHARS_PLUGIN_LOGO 32 -#define Plg_MAX_BYTES_PLUGIN_LOGO Plg_MAX_CHARS_PLUGIN_LOGO +#define Plg_MAX_CHARS_PLUGIN_LOGO (32 - 1) // 31 +#define Plg_MAX_BYTES_PLUGIN_LOGO Plg_MAX_CHARS_PLUGIN_LOGO // 31 -#define Plg_MAX_CHARS_PLUGIN_APP_KEY 32 -#define Plg_MAX_BYTES_PLUGIN_APP_KEY Plg_MAX_CHARS_PLUGIN_APP_KEY +#define Plg_MAX_CHARS_PLUGIN_APP_KEY (32 - 1) // 31 +#define Plg_MAX_BYTES_PLUGIN_APP_KEY Plg_MAX_CHARS_PLUGIN_APP_KEY // 31 /*****************************************************************************/ /******************************* Public types ********************************/ diff --git a/swad_record.c b/swad_record.c index d6bea173..78abc5e9 100644 --- a/swad_record.c +++ b/swad_record.c @@ -3124,7 +3124,7 @@ static void Rec_ShowOriginPlace (struct UsrData *UsrDat, " id=\"OriginPlace\" name=\"OriginPlace\"" " maxlength=\"%u\" value=\"%s\"" " class=\"REC_C2_BOT_INPUT\" />", - Cns_MAX_CHARS_STRING, + Usr_MAX_CHARS_ADDRESS, UsrDat->OriginPlace); else if (UsrDat->OriginPlace[0]) fprintf (Gbl.F.Out,"%s",UsrDat->OriginPlace); @@ -3189,7 +3189,7 @@ static void Rec_ShowLocalAddress (struct UsrData *UsrDat, " id=\"LocalAddress\" name=\"LocalAddress\"" " maxlength=\"%u\" value=\"%s\"" " class=\"REC_C2_BOT_INPUT\" />", - Cns_MAX_CHARS_STRING, + Usr_MAX_CHARS_ADDRESS, UsrDat->LocalAddress); else if (UsrDat->LocalAddress[0]) fprintf (Gbl.F.Out,"%s",UsrDat->LocalAddress); @@ -3259,7 +3259,7 @@ static void Rec_ShowFamilyAddress (struct UsrData *UsrDat, " id=\"FamilyAddress\" name=\"FamilyAddress\"" " maxlength=\"%u\" value=\"%s\"" " class=\"REC_C2_BOT_INPUT\" />", - Cns_MAX_CHARS_STRING, + Usr_MAX_CHARS_ADDRESS, UsrDat->FamilyAddress); else if (UsrDat->FamilyAddress[0]) fprintf (Gbl.F.Out,"%s",UsrDat->FamilyAddress); @@ -3623,7 +3623,7 @@ static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat) /***** Get country code *****/ UsrDat->CtyCod = Par_GetParToLong ("OthCtyCod"); - Par_GetParToText ("OriginPlace",UsrDat->OriginPlace,Cns_MAX_BYTES_STRING); + Par_GetParToText ("OriginPlace",UsrDat->OriginPlace,Usr_MAX_BYTES_ADDRESS); Str_ConvertToTitleType (UsrDat->OriginPlace); Dat_GetDateFromForm ("BirthDay","BirthMonth","BirthYear", @@ -3632,11 +3632,11 @@ static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat) &(UsrDat->Birthday.Year )); Dat_ConvDateToDateStr (&(UsrDat->Birthday),UsrDat->StrBirthday); - Par_GetParToText ("LocalAddress",UsrDat->LocalAddress,Cns_MAX_BYTES_STRING); + Par_GetParToText ("LocalAddress",UsrDat->LocalAddress,Usr_MAX_BYTES_ADDRESS); Par_GetParToText ("LocalPhone",UsrDat->LocalPhone,Usr_MAX_BYTES_PHONE); - Par_GetParToText ("FamilyAddress",UsrDat->FamilyAddress,Cns_MAX_BYTES_STRING); + Par_GetParToText ("FamilyAddress",UsrDat->FamilyAddress,Usr_MAX_BYTES_ADDRESS); Par_GetParToText ("FamilyPhone",UsrDat->FamilyPhone,Usr_MAX_BYTES_PHONE); @@ -3917,7 +3917,7 @@ void Rec_ShowFormMyInsCtrDpt (void) " maxlength=\"%u\" value=\"%s\"" " style=\"width:500px;\"" " onchange=\"document.getElementById('%s').submit();\" />", - Cns_MAX_CHARS_STRING, + Usr_MAX_CHARS_ADDRESS, Gbl.Usrs.Me.UsrDat.Tch.Office, Gbl.Form.Id); Act_FormEnd (); @@ -4071,10 +4071,10 @@ void Rec_UpdateMyDepartment (void) void Rec_UpdateMyOffice (void) { - char Query[128 + Cns_MAX_BYTES_STRING]; + char Query[128 + Usr_MAX_BYTES_ADDRESS]; /***** Get my office *****/ - Par_GetParToText ("Office",Gbl.Usrs.Me.UsrDat.Tch.Office,Cns_MAX_BYTES_STRING); + Par_GetParToText ("Office",Gbl.Usrs.Me.UsrDat.Tch.Office,Usr_MAX_BYTES_ADDRESS); /***** Update office *****/ sprintf (Query,"UPDATE usr_data SET Office='%s'" diff --git a/swad_record.h b/swad_record.h index d58ebc17..3ba429b7 100644 --- a/swad_record.h +++ b/swad_record.h @@ -37,8 +37,8 @@ #define Rec_RECORD_WIDTH 560 -#define Rec_MAX_CHARS_NAME_FIELD (128 - 1) -#define Rec_MAX_BYTES_NAME_FIELD (Rec_MAX_CHARS_NAME_FIELD * Str_MAX_BYTES_PER_CHAR) +#define Rec_MAX_CHARS_NAME_FIELD (128 - 1) // 127 +#define Rec_MAX_BYTES_NAME_FIELD ((Rec_MAX_CHARS_NAME_FIELD + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Rec_MIN_LINES_IN_EDITION_FIELD 1 #define Rec_MAX_LINES_IN_EDITION_FIELD 50 diff --git a/swad_report.c b/swad_report.c index 136ec8b8..3a3e1ad2 100644 --- a/swad_report.c +++ b/swad_report.c @@ -520,7 +520,7 @@ static void Rep_WriteSectionUsrInfo (void) extern const char *Txt_Email; extern const char *Txt_Country; extern const char *Txt_Institution; - char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]; + char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; struct Instit Ins; /***** Start of section *****/ diff --git a/swad_search.h b/swad_search.h index d415808f..b8eff09a 100644 --- a/swad_search.h +++ b/swad_search.h @@ -31,13 +31,13 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Sch_MAX_CHARS_STRING_TO_FIND (128 - 1) -#define Sch_MAX_BYTES_STRING_TO_FIND (Sch_MAX_CHARS_STRING_TO_FIND * Str_MAX_BYTES_PER_CHAR) +#define Sch_MAX_CHARS_STRING_TO_FIND (128 - 1) // 127 +#define Sch_MAX_BYTES_STRING_TO_FIND ((Sch_MAX_CHARS_STRING_TO_FIND + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Sch_MAX_WORDS_IN_SEARCH 10 -#define Sch_MAX_CHARS_SEARCH_WORD (128 - 1) -#define Sch_MAX_BYTES_SEARCH_WORD (Sch_MAX_CHARS_SEARCH_WORD * Str_MAX_BYTES_PER_CHAR) +#define Sch_MAX_CHARS_SEARCH_WORD (128 - 1) // 127 +#define Sch_MAX_BYTES_SEARCH_WORD ((Sch_MAX_CHARS_SEARCH_WORD - 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Sch_MAX_BYTES_SEARCH_QUERY (Sch_MAX_WORDS_IN_SEARCH * Sch_MAX_BYTES_SEARCH_WORD) diff --git a/swad_social.c b/swad_social.c index 9d43c945..46d214bc 100644 --- a/swad_social.c +++ b/swad_social.c @@ -173,7 +173,7 @@ static void Soc_WriteDateTime (time_t TimeUTC); static void Soc_GetAndWriteSocialPost (long PstCod); static void Soc_PutFormGoToAction (const struct SocialNote *SocNot); static void Soc_GetNoteSummary (const struct SocialNote *SocNot, - char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]); + char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]); static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub); static void Soc_PutFormToWriteNewPost (void); @@ -1263,7 +1263,7 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot, bool ShowPhoto = false; char PhotoURL[PATH_MAX + 1]; char ForumName[For_MAX_BYTES_FORUM_NAME + 1]; - char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]; + char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]; unsigned NumComments; char IdNewComment[Act_MAX_BYTES_ID]; @@ -1871,7 +1871,7 @@ static void Soc_PutFormGoToAction (const struct SocialNote *SocNot) /*****************************************************************************/ static void Soc_GetNoteSummary (const struct SocialNote *SocNot, - char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]) + char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]) { SummaryStr[0] = '\0'; @@ -4732,7 +4732,7 @@ static void Soc_AddNotesJustRetrievedToTimelineThisSession (void) /******************* Get notification of a new social post *******************/ /*****************************************************************************/ -void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Soc_GetNotifSocialPublishing (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long PubCod,bool GetContent) { @@ -4808,9 +4808,9 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING } /***** Copy summary string *****/ - Str_LimitLengthHTMLStr (Content,Cns_MAX_BYTES_SUMMARY_STRING); + Str_LimitLengthHTMLStr (Content,Ntf_MAX_BYTES_SUMMARY); Str_Copy (SummaryStr,Content, - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); } else Soc_GetNoteSummary (&SocNot,SummaryStr); @@ -4847,9 +4847,9 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING } /***** Copy summary string *****/ - Str_LimitLengthHTMLStr (Content,Cns_MAX_BYTES_SUMMARY_STRING); + Str_LimitLengthHTMLStr (Content,Ntf_MAX_BYTES_SUMMARY); Str_Copy (SummaryStr,Content, - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); break; } diff --git a/swad_social.h b/swad_social.h index 5d9ed09f..1353e19c 100644 --- a/swad_social.h +++ b/swad_social.h @@ -174,7 +174,7 @@ void Soc_RemoveUsrSocialContent (long UsrCod); void Soc_ClearOldTimelinesDB (void); -void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Soc_GetNotifSocialPublishing (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long PubCod,bool GetContent); diff --git a/swad_string.h b/swad_string.h index e12a0269..5c8dfce7 100644 --- a/swad_string.h +++ b/swad_string.h @@ -51,7 +51,8 @@ So, each char from a form may be transformed finally into a sequence of 1 to 10 bytes, but temporarily it may need 16 bytes */ -#define Str_MAX_BYTES_PER_CHAR 16 // Maximum number of bytes of a char +#define Str_MAX_BYTES_PER_CHAR 16 // Maximum number of bytes of a char. + // Do not change (or change carefully) because it is used to compute size of database fields /*****************************************************************************/ /******************************* Public types *******************************/ diff --git a/swad_survey.c b/swad_survey.c index eb12c13b..1ad50440 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -49,8 +49,8 @@ extern struct Globals Gbl; /***************************** Private constants *****************************/ /*****************************************************************************/ -#define Svy_MAX_CHARS_ANSWER 1000 -#define Svy_MAX_BYTES_ANSWER (Svy_MAX_CHARS_ANSWER * Str_MAX_BYTES_PER_CHAR) +#define Svy_MAX_CHARS_ANSWER (1024 - 1) // 1023 +#define Svy_MAX_BYTES_ANSWER ((Svy_MAX_CHARS_ANSWER + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 16383 #define Svy_MAX_BYTES_LIST_ANSWER_TYPES (10 + (Svy_NUM_ANS_TYPES - 1) * (1 + 10)) @@ -1401,7 +1401,7 @@ static void Svy_GetSurveyTxtFromDB (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1] /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long SvyCod,bool GetContent) { @@ -1426,7 +1426,7 @@ void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], /***** Get summary *****/ Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_SUMMARY_STRING); + Ntf_MAX_BYTES_SUMMARY); /***** Get content *****/ if (GetContent) diff --git a/swad_survey.h b/swad_survey.h index 55d848c1..47c92d69 100644 --- a/swad_survey.h +++ b/swad_survey.h @@ -33,8 +33,8 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define Svy_MAX_CHARS_SURVEY_TITLE (256 - 1) -#define Svy_MAX_BYTES_SURVEY_TITLE (Svy_MAX_CHARS_SURVEY_TITLE * Str_MAX_BYTES_PER_CHAR) +#define Svy_MAX_CHARS_SURVEY_TITLE (128 - 1) // 127 +#define Svy_MAX_BYTES_SURVEY_TITLE ((Svy_MAX_CHARS_SURVEY_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Svy_NUM_DATES 2 typedef enum @@ -95,7 +95,7 @@ void Svy_GetListSurveys (void); void Svy_GetDataOfSurveyByCod (struct Survey *Svy); void Svy_GetDataOfSurveyByFolder (struct Survey *Svy); void Svy_FreeListSurveys (void); -void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], +void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long SvyCod,bool GetContent); void Svy_AskRemSurvey (void); diff --git a/swad_syllabus.c b/swad_syllabus.c index b9f0ba97..9e1b8282 100644 --- a/swad_syllabus.c +++ b/swad_syllabus.c @@ -55,8 +55,8 @@ extern struct Globals Gbl; #define Syl_MAX_BYTES_ITEM_COD (Syl_MAX_LEVELS_SYLLABUS * (10 + 1) - 1) -#define Syl_MAX_CHARS_TEXT_ITEM 1000 -#define Syl_MAX_BYTES_TEXT_ITEM (Syl_MAX_CHARS_TEXT_ITEM * Str_MAX_BYTES_PER_CHAR) +#define Syl_MAX_CHARS_TEXT_ITEM (1024 - 1) // 1023 +#define Syl_MAX_BYTES_TEXT_ITEM ((Syl_MAX_CHARS_TEXT_ITEM + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 16383 #define Syl_WIDTH_NUM_SYLLABUS 20 diff --git a/swad_test.c b/swad_test.c index 3fcea476..f0dba607 100644 --- a/swad_test.c +++ b/swad_test.c @@ -1119,7 +1119,9 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,int NumImgInForm, " placeholder=\"%s (%s)\"" " class=\"%s\" maxlength=\"%u\" value=\"%s\">", ParamUploadImg.Title,Txt_Image_title_attribution,Txt_optional, - ClassImgTitURL,Img_MAX_BYTES_TITLE,Image->Title ? Image->Title : ""); + ClassImgTitURL,Img_MAX_CHARS_TITLE, + Image->Title ? Image->Title : + ""); /***** Image URL *****/ fprintf (Gbl.F.Out,"
" @@ -1127,7 +1129,9 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,int NumImgInForm, " placeholder=\"%s (%s)\"" " class=\"%s\" maxlength=\"%u\" value=\"%s\">", ParamUploadImg.URL,Txt_Link,Txt_optional, - ClassImgTitURL,Img_MAX_BYTES_URL,Image->URL ? Image->URL : ""); + ClassImgTitURL,Cns_MAX_CHARS_WWW, + Image->URL ? Image->URL : + ""); /***** End container *****/ fprintf (Gbl.F.Out,""); diff --git a/swad_test.h b/swad_test.h index 22fa61d0..93046f0f 100644 --- a/swad_test.h +++ b/swad_test.h @@ -36,15 +36,15 @@ #define Tst_MAX_QUESTIONS_PER_TEST 100 // Absolute maximum number of questions in a test #define Tst_MAX_TAGS_PER_QUESTION 5 -#define Tst_MAX_CHARS_TAG (128 - 1) -#define Tst_MAX_BYTES_TAG (Tst_MAX_CHARS_TAG * Str_MAX_BYTES_PER_CHAR) +#define Tst_MAX_CHARS_TAG (128 - 1) // 127 +#define Tst_MAX_BYTES_TAG ((Tst_MAX_CHARS_TAG + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Tst_MAX_OPTIONS_PER_QUESTION 10 #define Tst_MAX_SIZE_INDEXES_ONE_QST (Tst_MAX_OPTIONS_PER_QUESTION * (10 + 1)) #define Tst_MAX_SIZE_ANSWERS_ONE_QST (Tst_MAX_OPTIONS_PER_QUESTION * (10 + 1)) -#define Tst_MAX_CHARS_ANSWER_OR_FEEDBACK 1000 -#define Tst_MAX_BYTES_ANSWER_OR_FEEDBACK (Tst_MAX_CHARS_ANSWER_OR_FEEDBACK * Str_MAX_BYTES_PER_CHAR) +#define Tst_MAX_CHARS_ANSWER_OR_FEEDBACK (1024 - 1) // 1023 +#define Tst_MAX_BYTES_ANSWER_OR_FEEDBACK ((Tst_MAX_CHARS_ANSWER_OR_FEEDBACK + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 16383 #define Tst_CONFIG_DEFAULT_MIN_QUESTIONS 1 #define Tst_CONFIG_DEFAULT_DEF_QUESTIONS 20 // Number of questions to be generated by default in a self-assessment test diff --git a/swad_theme.c b/swad_theme.c index 6efd21b9..feb81e0a 100644 --- a/swad_theme.c +++ b/swad_theme.c @@ -46,7 +46,7 @@ extern struct Globals Gbl; /******************************** Private constants **************************/ /*****************************************************************************/ -#define MAX_THEME_ID 16 +#define The_MAX_BYTES_THEME_ID 16 const char *The_ThemeId[The_NUM_THEMES] = { @@ -309,10 +309,10 @@ void The_ChangeTheme (void) The_Theme_t The_GetParamTheme (void) { - char ThemeId[MAX_THEME_ID + 1]; + char ThemeId[The_MAX_BYTES_THEME_ID + 1]; The_Theme_t Theme; - Par_GetParToText ("Theme",ThemeId,MAX_THEME_ID); + Par_GetParToText ("Theme",ThemeId,The_MAX_BYTES_THEME_ID); for (Theme = (The_Theme_t) 0; Theme < The_NUM_THEMES; Theme++) diff --git a/swad_timetable.h b/swad_timetable.h index c31aeccb..be2e2750 100644 --- a/swad_timetable.h +++ b/swad_timetable.h @@ -33,8 +33,8 @@ /************************* Public constants and types ************************/ /*****************************************************************************/ -#define TT_MAX_CHARS_PLACE 32 -#define TT_MAX_BYTES_PLACE (TT_MAX_CHARS_PLACE * Str_MAX_BYTES_PER_CHAR) +#define TT_MAX_CHARS_PLACE (32 - 1) // 31 +#define TT_MAX_BYTES_PLACE ((TT_MAX_CHARS_PLACE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 #define TT_NUM_TIMETABLE_TYPES 3 typedef enum diff --git a/swad_user.c b/swad_user.c index 9ae49884..6c9e9afb 100644 --- a/swad_user.c +++ b/swad_user.c @@ -560,20 +560,20 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat) UsrDat->Tch.DptCod = Str_ConvertStrCodToLongCod (row[16]); UsrDat->Tch.CtrCod = Str_ConvertStrCodToLongCod (row[17]); Str_Copy (UsrDat->Tch.Office,row[18], - Cns_MAX_BYTES_STRING); + Usr_MAX_BYTES_ADDRESS); Str_Copy (UsrDat->Tch.OfficePhone,row[19], Usr_MAX_BYTES_PHONE); Str_Copy (UsrDat->LocalAddress,row[20], - Cns_MAX_BYTES_STRING); + Usr_MAX_BYTES_ADDRESS); Str_Copy (UsrDat->LocalPhone,row[21], Usr_MAX_BYTES_PHONE); Str_Copy (UsrDat->FamilyAddress,row[22], - Cns_MAX_BYTES_STRING); + Usr_MAX_BYTES_ADDRESS); Str_Copy (UsrDat->FamilyPhone,row[23], Usr_MAX_BYTES_PHONE); Str_Copy (UsrDat->OriginPlace,row[24], - Cns_MAX_BYTES_STRING); + Usr_MAX_BYTES_ADDRESS); Dat_GetDateFromYYYYMMDD (&(UsrDat->Birthday),row[25]); diff --git a/swad_user.h b/swad_user.h index 2fe7b737..1b81a4b2 100644 --- a/swad_user.h +++ b/swad_user.h @@ -53,8 +53,8 @@ #define Usr_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 12 #define Usr_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 60 -#define Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME 32 -#define Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME (Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME * Str_MAX_BYTES_PER_CHAR) +#define Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME (32 - 1) // 31 +#define Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME ((Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 #define Usr_MAX_BYTES_SURNAMES (Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1 + Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME) // Surname1 +' '+ Surname2 @@ -62,14 +62,17 @@ // Surname1 +' '+ Surname2 + ','+' ' + FirstName // Surname1 +' '+ Surname2 + '
' + FirstName -#define Usr_MAX_CHARS_USR_EMAIL (128 - 1) -#define Usr_MAX_BYTES_USR_EMAIL Usr_MAX_CHARS_USR_EMAIL +#define Usr_MAX_CHARS_USR_EMAIL (128 - 1) // 127 +#define Usr_MAX_BYTES_USR_EMAIL Usr_MAX_CHARS_USR_EMAIL // 127 -#define Usr_MAX_CHARS_USR_LOGIN Usr_MAX_CHARS_USR_EMAIL // Maximum number of chars of @nick, email or ID -#define Usr_MAX_BYTES_USR_LOGIN (Usr_MAX_CHARS_USR_LOGIN * Str_MAX_BYTES_PER_CHAR) +#define Usr_MAX_CHARS_USR_LOGIN Usr_MAX_CHARS_USR_EMAIL // 127, maximum number of chars of @nick, email or ID +#define Usr_MAX_BYTES_USR_LOGIN ((Usr_MAX_CHARS_USR_LOGIN + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Usr_BIRTHDAY_STR_DB_LENGTH (4 + 1 + 2 + 1 + 2) // "'%04u-%02u-%02u'" +#define Usr_MAX_CHARS_ADDRESS (128 - 1) // 127 +#define Usr_MAX_BYTES_ADDRESS ((Usr_MAX_CHARS_ADDRESS + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 + #define Usr_MAX_CHARS_PHONE 16 #define Usr_MAX_BYTES_PHONE Usr_MAX_CHARS_PHONE @@ -145,12 +148,12 @@ struct UsrData Pri_Visibility_t PhotoVisibility; // Who can see user's photo Pri_Visibility_t ProfileVisibility; // Who can see user's public profile long CtyCod; // Country - char OriginPlace [Cns_MAX_BYTES_STRING + 1]; + char OriginPlace [Usr_MAX_BYTES_ADDRESS + 1]; struct Date Birthday; char StrBirthday [Cns_MAX_BYTES_DATE + 1]; - char LocalAddress [Cns_MAX_BYTES_STRING + 1]; + char LocalAddress [Usr_MAX_BYTES_ADDRESS + 1]; char LocalPhone [Usr_MAX_BYTES_PHONE + 1]; - char FamilyAddress [Cns_MAX_BYTES_STRING + 1]; + char FamilyAddress [Usr_MAX_BYTES_ADDRESS + 1]; char FamilyPhone [Usr_MAX_BYTES_PHONE + 1]; char *Comments; long InsCtyCod; // Country of the institution @@ -159,7 +162,7 @@ struct UsrData { long CtrCod; // Centre long DptCod; // Department - char Office [Cns_MAX_BYTES_STRING + 1]; + char Office [Usr_MAX_BYTES_ADDRESS + 1]; char OfficePhone [Usr_MAX_BYTES_PHONE + 1]; } Tch; struct diff --git a/swad_web_service.c b/swad_web_service.c index 5b22e694..d28fdd3e 100644 --- a/swad_web_service.c +++ b/swad_web_service.c @@ -955,8 +955,8 @@ int swad__loginBySessionKey (struct soap *soap, loginBySessionKeyOut->userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1); loginBySessionKeyOut->userPhoto = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_WWW + 1); loginBySessionKeyOut->userBirthday = (char *) soap_malloc (Gbl.soap,Dat_LENGTH_YYYYMMDD + 1); - loginBySessionKeyOut->degreeName = (char *) soap_malloc (Gbl.soap,Deg_MAX_BYTES_DEGREE_FULL_NAME + 1); - loginBySessionKeyOut->courseName = (char *) soap_malloc (Gbl.soap,Crs_MAX_BYTES_COURSE_FULL_NAME + 1); + loginBySessionKeyOut->degreeName = (char *) soap_malloc (Gbl.soap,Hie_MAX_BYTES_FULL_NAME + 1); + loginBySessionKeyOut->courseName = (char *) soap_malloc (Gbl.soap,Hie_MAX_BYTES_FULL_NAME + 1); /***** Default values returned on error *****/ loginBySessionKeyOut->userCode = -1; @@ -1001,7 +1001,7 @@ int swad__loginBySessionKey (struct soap *soap, Crs_GetDataOfCourseByCod (&Gbl.CurrentCrs.Crs); loginBySessionKeyOut->courseCode = (int) Gbl.CurrentCrs.Crs.CrsCod; Str_Copy (loginBySessionKeyOut->courseName,Gbl.CurrentCrs.Crs.FullName, - Crs_MAX_BYTES_COURSE_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /***** Get user code (row[0]) *****/ Gbl.Usrs.Me.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); @@ -1012,7 +1012,7 @@ int swad__loginBySessionKey (struct soap *soap, Deg_GetDataOfDegreeByCod (&Gbl.CurrentDeg.Deg); loginBySessionKeyOut->degreeCode = (int) Gbl.CurrentDeg.Deg.DegCod; Str_Copy (loginBySessionKeyOut->degreeName,Gbl.CurrentDeg.Deg.FullName, - Deg_MAX_BYTES_DEGREE_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); } else UsrFound = false; @@ -1225,14 +1225,14 @@ int swad__getCourses (struct soap *soap, getCoursesOut->coursesArray.__ptr[NumRow].courseCode = (int) Str_ConvertStrCodToLongCod (row[0]); /* Get course short name (row[1]) */ - getCoursesOut->coursesArray.__ptr[NumRow].courseShortName = (char *) soap_malloc (Gbl.soap,Crs_MAX_BYTES_COURSE_SHRT_NAME + 1); + getCoursesOut->coursesArray.__ptr[NumRow].courseShortName = (char *) soap_malloc (Gbl.soap,Hie_MAX_BYTES_SHRT_NAME + 1); Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName,row[1], - Crs_MAX_BYTES_COURSE_SHRT_NAME); + Hie_MAX_BYTES_SHRT_NAME); /* Get course full name (row[2]) */ - getCoursesOut->coursesArray.__ptr[NumRow].courseFullName = (char *) soap_malloc (Gbl.soap,Crs_MAX_BYTES_COURSE_FULL_NAME + 1); + getCoursesOut->coursesArray.__ptr[NumRow].courseFullName = (char *) soap_malloc (Gbl.soap,Hie_MAX_BYTES_FULL_NAME + 1); Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName,row[2], - Crs_MAX_BYTES_COURSE_FULL_NAME); + Hie_MAX_BYTES_FULL_NAME); /* Get role (row[3]) */ if (sscanf (row[3],"%u",&Role) != 1) // Role in this course @@ -2815,7 +2815,7 @@ int swad__getNotifications (struct soap *soap, struct Course Crs; long Cod; char ForumName[For_MAX_BYTES_FORUM_NAME + 1]; - char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]; + char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]; char *ContentStr; Ntf_Status_t Status; size_t Length; @@ -4681,7 +4681,7 @@ int swad__getMarks (struct soap *soap, { int ReturnCode; struct FileMetadata FileMetadata; - char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]; // Not used + char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]; // Not used char *ContentStr; size_t Length;