"
@@ -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_LENGTH_CENTRE_SHRT_NAME);
+ Par_GetParToText ("ShortName",Ctr->ShrtName,Ctr_MAX_BYTES_CENTRE_SHRT_NAME);
/* Get centre full name */
- Par_GetParToText ("FullName",Ctr->FullName,Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
+ Par_GetParToText ("FullName",Ctr->FullName,Ctr_MAX_BYTES_CENTRE_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_LENGTH_CENTRE_SHRT_NAME +
- Ctr_MAX_LENGTH_CENTRE_FULL_NAME +
+ Ctr_MAX_BYTES_CENTRE_SHRT_NAME +
+ Ctr_MAX_BYTES_CENTRE_FULL_NAME +
Cns_MAX_BYTES_WWW];
/***** Create a new centre *****/
diff --git a/swad_centre.h b/swad_centre.h
index 4883ec0c..96409ab3 100644
--- a/swad_centre.h
+++ b/swad_centre.h
@@ -57,9 +57,14 @@ typedef enum
#define Ctr_MAX_CENTRES_PER_USR 10 // Used in list of my centres
-#define Ctr_MAX_LENGTH_CENTRE_SHRT_NAME 32
-#define Ctr_MAX_LENGTH_CENTRE_FULL_NAME 127
-#define Ctr_MAX_LENGTH_PHOTO_ATTRIBUTION (4 * 1024)
+#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
{
@@ -68,8 +73,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_LENGTH_CENTRE_SHRT_NAME + 1];
- char FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME + 1];
+ char ShrtName[Ctr_MAX_BYTES_CENTRE_SHRT_NAME + 1];
+ char FullName[Ctr_MAX_BYTES_CENTRE_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 2b104631..6154ca89 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -204,13 +204,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 16.149 (2017-03-07)"
+#define Log_PLATFORM_VERSION "SWAD 16.150 (2017-03-07)"
#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.150: Mar 07, 2017 Code refactoring related to number of chars and bytes. (216409 lines)
Version 16.149: Mar 07, 2017 Code refactoring related to number of chars and bytes. (216385 lines)
Version 16.148: Mar 06, 2017 Code refactoring in notifications. (216393 lines)
Version 16.147.11:Mar 06, 2017 Changes in names of zipped files. (216388 lines)
diff --git a/swad_chat.c b/swad_chat.c
index 588af333..bf2427b8 100644
--- a/swad_chat.c
+++ b/swad_chat.c
@@ -51,15 +51,20 @@ extern struct Globals Gbl;
#define Cht_CHAT_MAX_LEVELS 3
-#define MAX_LENGTH_ROOM_CODE 16 // Maximum length of the code of a chat room
-#define MAX_LENGTH_ROOM_SHRT_NAME 128 // Maximum length of the short name of a chat room
-#define MAX_LENGTH_ROOM_FULL_NAME 256 // Maximum length of the full name of a chat room
+#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_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)
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
-static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShortName,const char *RoomFullName,
+static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShrtName,const char *RoomFullName,
unsigned Level,bool IsLastItemInLevel[1 + Cht_CHAT_MAX_LEVELS]);
static void Cht_WriteLinkToChat2 (const char *RoomCode,const char *RoomFullName);
static unsigned Cht_GetNumUsrsInChatRoom (const char *RoomCode);
@@ -108,9 +113,9 @@ void Cht_ShowListOfAvailableChatRooms (void)
MYSQL_ROW row;
unsigned long NumRow;
unsigned long NumRows;
- char ThisRoomCode [MAX_LENGTH_ROOM_CODE + 1];
- char ThisRoomShrtName[MAX_LENGTH_ROOM_SHRT_NAME + 1];
- char ThisRoomFullName[MAX_LENGTH_ROOM_FULL_NAME + 1];
+ char ThisRoomCode [Cht_MAX_BYTES_ROOM_CODE + 1];
+ char ThisRoomShrtName[Cht_MAX_BYTES_ROOM_SHRT_NAME + 1];
+ char ThisRoomFullName[Cht_MAX_BYTES_ROOM_FULL_NAME + 1];
/***** Fill the list with the degrees I belong to *****/
Usr_GetMyDegrees ();
@@ -294,7 +299,7 @@ void Cht_ShowListOfChatRoomsWithUsrs (void)
/******************** Write title and link to a chat room ********************/
/*****************************************************************************/
-static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShortName,const char *RoomFullName,
+static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShrtName,const char *RoomFullName,
unsigned Level,bool IsLastItemInLevel[1 + Cht_CHAT_MAX_LEVELS])
{
extern const char *The_ClassForm[The_NUM_THEMES];
@@ -302,7 +307,7 @@ static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShortName
fprintf (Gbl.F.Out,"
",
- Crs_MAX_LENGTH_COURSE_FULL_NAME,Crs->FullName);
+ Crs_MAX_CHARS_COURSE_FULL_NAME,Crs->FullName);
/***** Current number of teachers in this course *****/
fprintf (Gbl.F.Out,"
"
@@ -1916,17 +1914,17 @@ static void Crs_GetParamsNewCourse (struct Course *Crs)
/***** Get parameters of the course from form *****/
/* Get institutional code */
- Par_GetParToText ("InsCrsCod",Crs->InstitutionalCrsCod,Crs_LENGTH_INSTITUTIONAL_CRS_COD);
+ Par_GetParToText ("InsCrsCod",Crs->InstitutionalCrsCod,Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
/* Get year */
Par_GetParToText ("OthCrsYear",YearStr,2);
Crs->Year = Deg_ConvStrToYear (YearStr);
/* Get course short name */
- Par_GetParToText ("ShortName",Crs->ShrtName,Crs_MAX_LENGTH_COURSE_SHRT_NAME);
+ Par_GetParToText ("ShortName",Crs->ShrtName,Crs_MAX_BYTES_COURSE_SHRT_NAME);
/* Get course full name */
- Par_GetParToText ("FullName",Crs->FullName,Crs_MAX_LENGTH_COURSE_FULL_NAME);
+ Par_GetParToText ("FullName",Crs->FullName,Crs_MAX_BYTES_COURSE_FULL_NAME);
}
/*****************************************************************************/
@@ -1954,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_LENGTH_COURSE_SHRT_NAME +
- Crs_MAX_LENGTH_COURSE_FULL_NAME];
+ Crs_MAX_BYTES_COURSE_SHRT_NAME +
+ Crs_MAX_BYTES_COURSE_FULL_NAME];
/***** Insert new course into pending requests *****/
sprintf (Query,"INSERT INTO courses (DegCod,Year,InsCrsCod,"
@@ -2076,7 +2074,7 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row)
/***** Get institutional course code (row[3]) *****/
Str_Copy (Crs->InstitutionalCrsCod,row[3],
- Crs_LENGTH_INSTITUTIONAL_CRS_COD);
+ Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
/***** Get course status (row[4]) *****/
if (sscanf (row[4],"%u",&(Crs->Status)) != 1)
@@ -2087,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_LENGTH_COURSE_SHRT_NAME);
+ Crs_MAX_BYTES_COURSE_SHRT_NAME);
/***** Get the full name of the course (row[7]) *****/
Str_Copy (Crs->FullName,row[7],
- Crs_MAX_LENGTH_COURSE_FULL_NAME);
+ Crs_MAX_BYTES_COURSE_FULL_NAME);
/***** Get number of teachers *****/
Crs->NumTchs = Usr_GetNumUsrsInCrs (Rol_TEACHER,Crs->CrsCod);
@@ -2108,8 +2106,8 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row)
/*****************************************************************************/
static void Crs_GetShortNamesByCod (long CrsCod,
- char CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1],
- char DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME + 1])
+ char CrsShortName[Crs_MAX_BYTES_COURSE_SHRT_NAME + 1],
+ char DegShortName[Deg_MAX_BYTES_DEGREE_SHRT_NAME + 1])
{
char Query[512];
MYSQL_RES *mysql_res;
@@ -2131,9 +2129,9 @@ static void Crs_GetShortNamesByCod (long CrsCod,
row = mysql_fetch_row (mysql_res);
Str_Copy (CrsShortName,row[0],
- Crs_MAX_LENGTH_COURSE_SHRT_NAME);
+ Crs_MAX_BYTES_COURSE_SHRT_NAME);
Str_Copy (DegShortName,row[1],
- Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
+ Deg_MAX_BYTES_DEGREE_SHRT_NAME);
}
/***** Free structure that stores the query result *****/
@@ -2300,10 +2298,10 @@ void Crs_ChangeInsCrsCodInConfig (void)
extern const char *Txt_The_institutional_code_of_the_course_X_has_changed_to_Y;
extern const char *Txt_The_institutional_code_of_the_course_X_has_not_changed;
extern const char *Txt_You_dont_have_permission_to_edit_this_course;
- char NewInstitutionalCrsCod[Crs_LENGTH_INSTITUTIONAL_CRS_COD + 1];
+ char NewInstitutionalCrsCod[Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD + 1];
/***** Get institutional code from form *****/
- Par_GetParToText ("InsCrsCod",NewInstitutionalCrsCod,Crs_LENGTH_INSTITUTIONAL_CRS_COD);
+ Par_GetParToText ("InsCrsCod",NewInstitutionalCrsCod,Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
/***** Change the institutional course code *****/
if (strcmp (NewInstitutionalCrsCod,Gbl.CurrentCrs.Crs.InstitutionalCrsCod))
@@ -2327,7 +2325,7 @@ void Crs_ChangeInsCrsCod (void)
extern const char *Txt_The_institutional_code_of_the_course_X_has_changed_to_Y;
extern const char *Txt_The_institutional_code_of_the_course_X_has_not_changed;
extern const char *Txt_You_dont_have_permission_to_edit_this_course;
- char NewInstitutionalCrsCod[Crs_LENGTH_INSTITUTIONAL_CRS_COD + 1];
+ char NewInstitutionalCrsCod[Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD + 1];
struct Course *Crs;
Crs = &Gbl.Degs.EditingCrs;
@@ -2337,7 +2335,7 @@ void Crs_ChangeInsCrsCod (void)
Crs->CrsCod = Crs_GetAndCheckParamOtherCrsCod ();
/* Get institutional code */
- Par_GetParToText ("InsCrsCod",NewInstitutionalCrsCod,Crs_LENGTH_INSTITUTIONAL_CRS_COD);
+ Par_GetParToText ("InsCrsCod",NewInstitutionalCrsCod,Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
/* Get data of the course */
Crs_GetDataOfCourseByCod (Crs);
@@ -2600,7 +2598,7 @@ void Crs_UpdateInstitutionalCrsCod (struct Course *Crs,const char *NewInstitutio
/***** Copy institutional course code *****/
Str_Copy (Crs->InstitutionalCrsCod,NewInstitutionalCrsCod,
- Crs_LENGTH_INSTITUTIONAL_CRS_COD);
+ Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
}
/*****************************************************************************/
@@ -2644,32 +2642,32 @@ 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_LENGTH_COURSE_FULL_NAME];
+ char Query[128 + Crs_MAX_BYTES_COURSE_FULL_NAME];
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
- unsigned MaxLength = 0; // Initialized to avoid warning
+ unsigned MaxBytes = 0; // Initialized to avoid warning
char *CurrentCrsName = NULL; // Initialized to avoid warning
- char NewCrsName[Crs_MAX_LENGTH_COURSE_FULL_NAME + 1];
+ char NewCrsName[Crs_MAX_BYTES_COURSE_FULL_NAME + 1];
switch (ShrtOrFullName)
{
case Cns_SHRT_NAME:
ParamName = "ShortName";
FieldName = "ShortName";
- MaxLength = Crs_MAX_LENGTH_COURSE_SHRT_NAME;
+ MaxBytes = Crs_MAX_BYTES_COURSE_SHRT_NAME;
CurrentCrsName = Crs->ShrtName;
break;
case Cns_FULL_NAME:
ParamName = "FullName";
FieldName = "FullName";
- MaxLength = Crs_MAX_LENGTH_COURSE_FULL_NAME;
+ MaxBytes = Crs_MAX_BYTES_COURSE_FULL_NAME;
CurrentCrsName = Crs->FullName;
break;
}
/***** Get parameters from form *****/
/* Get the new name for the course */
- Par_GetParToText (ParamName,NewCrsName,MaxLength);
+ Par_GetParToText (ParamName,NewCrsName,MaxBytes);
/***** Get from the database the data of the degree *****/
Crs_GetDataOfCourseByCod (Crs);
@@ -2709,7 +2707,7 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull
/* Change current course name in order to display it properly */
Str_Copy (CurrentCrsName,NewCrsName,
- MaxLength);
+ MaxBytes);
}
}
else // The same name
diff --git a/swad_course.h b/swad_course.h
index 83d569fd..dd7a1721 100644
--- a/swad_course.h
+++ b/swad_course.h
@@ -39,9 +39,14 @@
#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_LENGTH_INSTITUTIONAL_CRS_COD 7
-#define Crs_MAX_LENGTH_COURSE_SHRT_NAME 32
-#define Crs_MAX_LENGTH_COURSE_FULL_NAME (128 - 1)
+#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_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 6
#define Crs_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 12
@@ -79,13 +84,13 @@ typedef enum
struct Course
{
long CrsCod;
- char InstitutionalCrsCod[Crs_LENGTH_INSTITUTIONAL_CRS_COD + 1]; // Institutional code of the course
+ char InstitutionalCrsCod[Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD + 1]; // Institutional code of the course
long DegCod;
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_LENGTH_COURSE_SHRT_NAME + 1]; // Short name of course
- char FullName[Crs_MAX_LENGTH_COURSE_FULL_NAME + 1]; // Full name of 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
unsigned NumUsrs; // Number of users (students + teachers)
unsigned NumTchs; // Number of teachers
unsigned NumStds; // Number of students
diff --git a/swad_cryptography.c b/swad_cryptography.c
index 964496ab..3fc2a045 100644
--- a/swad_cryptography.c
+++ b/swad_cryptography.c
@@ -146,7 +146,7 @@ void Cry_EncryptSHA512Base64 (const char *PlainText,
void Cry_CreateUniqueNameEncrypted (char UniqueNameEncrypted[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1])
{
static unsigned NumCall = 0; // When this function is called several times in the same execution of the program, each time a new name is created
- char UniqueNamePlain[Cns_MAX_LENGTH_IP + 1 + 10 + 1 + 10 + 1 + 10 + 1];
+ char UniqueNamePlain[Cns_MAX_BYTES_IP + 1 + 10 + 1 + 10 + 1 + 10 + 1];
NumCall++;
sprintf (UniqueNamePlain,"%s-%lx-%x-%x",
diff --git a/swad_degree.c b/swad_degree.c
index de142b61..525dc8a1 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_LENGTH_DEGREE_FULL_NAME,
+ Deg_MAX_CHARS_DEGREE_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_LENGTH_DEGREE_SHRT_NAME,
+ Deg_MAX_CHARS_DEGREE_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_LENGTH_DEGREE_SHRT_NAME,Deg->ShrtName,Gbl.Form.Id);
+ Deg_MAX_CHARS_DEGREE_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_LENGTH_DEGREE_FULL_NAME,Deg->FullName,Gbl.Form.Id);
+ Deg_MAX_CHARS_DEGREE_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_LENGTH_DEGREE_SHRT_NAME,Deg->ShrtName);
+ Deg_MAX_CHARS_DEGREE_SHRT_NAME,Deg->ShrtName);
/***** Degree full name *****/
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_LENGTH_DEGREE_SHRT_NAME +
- Deg_MAX_LENGTH_DEGREE_FULL_NAME +
+ Deg_MAX_BYTES_DEGREE_SHRT_NAME +
+ Deg_MAX_BYTES_DEGREE_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_LENGTH_DEGREE_SHRT_NAME);
+ Par_GetParToText ("ShortName",Deg->ShrtName,Deg_MAX_BYTES_DEGREE_SHRT_NAME);
/* Get degree full name */
- Par_GetParToText ("FullName",Deg->FullName,Deg_MAX_LENGTH_DEGREE_FULL_NAME);
+ Par_GetParToText ("FullName",Deg->FullName,Deg_MAX_BYTES_DEGREE_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_LENGTH_DEGREE_SHRT_NAME);
+ Deg_MAX_BYTES_DEGREE_SHRT_NAME);
/***** Get degree full name (row[6]) *****/
Str_Copy (Deg->FullName,row[6],
- Deg_MAX_LENGTH_DEGREE_FULL_NAME);
+ Deg_MAX_BYTES_DEGREE_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_LENGTH_DEGREE_SHRT_NAME);
+ Deg_MAX_BYTES_DEGREE_SHRT_NAME);
}
/***** Free structure that stores the query result *****/
@@ -1939,32 +1939,32 @@ 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_LENGTH_DEGREE_FULL_NAME];
+ char Query[512 + Deg_MAX_BYTES_DEGREE_FULL_NAME];
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
- unsigned MaxLength = 0; // Initialized to avoid warning
+ unsigned MaxBytes = 0; // Initialized to avoid warning
char *CurrentDegName = NULL; // Initialized to avoid warning
- char NewDegName[Deg_MAX_LENGTH_DEGREE_FULL_NAME + 1];
+ char NewDegName[Deg_MAX_BYTES_DEGREE_FULL_NAME + 1];
switch (ShrtOrFullName)
{
case Cns_SHRT_NAME:
ParamName = "ShortName";
FieldName = "ShortName";
- MaxLength = Deg_MAX_LENGTH_DEGREE_SHRT_NAME;
+ MaxBytes = Deg_MAX_BYTES_DEGREE_SHRT_NAME;
CurrentDegName = Deg->ShrtName;
break;
case Cns_FULL_NAME:
ParamName = "FullName";
FieldName = "FullName";
- MaxLength = Deg_MAX_LENGTH_DEGREE_FULL_NAME;
+ MaxBytes = Deg_MAX_BYTES_DEGREE_FULL_NAME;
CurrentDegName = Deg->FullName;
break;
}
/***** Get parameters from form *****/
/* Get the new name for the degree */
- Par_GetParToText (ParamName,NewDegName,MaxLength);
+ Par_GetParToText (ParamName,NewDegName,MaxBytes);
/***** Get data of degree *****/
Deg_GetDataOfDegreeByCod (Deg);
@@ -2001,7 +2001,7 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull
/* Change current degree name in order to display it properly */
Str_Copy (CurrentDegName,NewDegName,
- MaxLength);
+ MaxBytes);
}
}
else // The same name
diff --git a/swad_degree.h b/swad_degree.h
index cfbc738e..3470a38c 100644
--- a/swad_degree.h
+++ b/swad_degree.h
@@ -40,8 +40,11 @@
#define Deg_MAX_DEGREES_PER_USR 20 // Used in list of my degrees
-#define Deg_MAX_LENGTH_DEGREE_SHRT_NAME 32
-#define Deg_MAX_LENGTH_DEGREE_FULL_NAME (128 - 1)
+#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 ********************************/
@@ -73,8 +76,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_LENGTH_DEGREE_SHRT_NAME + 1]; // Short name of degree
- char FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME + 1]; // Full name of 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 WWW[Cns_MAX_BYTES_WWW + 1];
struct Course *LstCrss; // List of courses in this degree
};
diff --git a/swad_degree_type.c b/swad_degree_type.c
index e38b4368..c1ab97e7 100644
--- a/swad_degree_type.c
+++ b/swad_degree_type.c
@@ -311,7 +311,7 @@ static void DT_ListDegreeTypesForEdition (void)
fprintf (Gbl.F.Out,"",
- Deg_MAX_LENGTH_DEGREE_TYPE_NAME,
+ Deg_MAX_CHARS_DEGREE_TYPE_NAME,
Gbl.Degs.DegTypes.Lst[NumDegTyp].DegTypName,
Gbl.Form.Id);
Act_FormEnd ();
@@ -361,7 +361,7 @@ static void DT_PutFormToCreateDegreeType (void)
" size=\"25\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />"
"
",
- Deg_MAX_LENGTH_DEGREE_TYPE_NAME,Gbl.Degs.EditingDegTyp.DegTypName);
+ Deg_MAX_CHARS_DEGREE_TYPE_NAME,Gbl.Degs.EditingDegTyp.DegTypName);
/***** Send button and end frame *****/
Lay_EndRoundFrameTableWithButton (Lay_CREATE_BUTTON,Txt_Create_type_of_degree);
@@ -426,7 +426,7 @@ static void DT_PutHeadDegreeTypesForEdition (void)
static void DT_CreateDegreeType (struct DegreeType *DegTyp)
{
extern const char *Txt_Created_new_type_of_degree_X;
- char Query[128 + Deg_MAX_LENGTH_DEGREE_TYPE_NAME];
+ char Query[128 + Deg_MAX_BYTES_DEGREE_TYPE_NAME];
/***** Create a new degree type *****/
sprintf (Query,"INSERT INTO deg_types SET DegTypName='%s'",
@@ -482,7 +482,7 @@ void DT_GetListDegreeTypes (void)
/* Get degree type name (row[1]) */
Str_Copy (Gbl.Degs.DegTypes.Lst[NumRow].DegTypName,row[1],
- Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
+ Deg_MAX_BYTES_DEGREE_TYPE_NAME);
/* Number of degrees of this type (row[2]) */
if (sscanf (row[2],"%u",&Gbl.Degs.DegTypes.Lst[NumRow].NumDegs) != 1)
@@ -523,7 +523,7 @@ void DT_RecFormNewDegreeType (void)
/***** Get parameters from form *****/
/* Get the name of degree type */
- Par_GetParToText ("DegTypName",DegTyp->DegTypName,Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
+ Par_GetParToText ("DegTypName",DegTyp->DegTypName,Deg_MAX_BYTES_DEGREE_TYPE_NAME);
if (DegTyp->DegTypName[0]) // If there's a degree type name
{
@@ -648,7 +648,7 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp)
/* Get the name of the degree type (row[0]) */
Str_Copy (DegTyp->DegTypName,row[0],
- Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
+ Deg_MAX_BYTES_DEGREE_TYPE_NAME);
/* Count number of degrees of this type */
DegTyp->NumDegs = DT_CountNumDegsOfType (DegTyp->DegTypCod);
@@ -725,7 +725,7 @@ void DT_RenameDegreeType (void)
extern const char *Txt_The_name_of_the_type_of_degree_X_has_not_changed;
struct DegreeType *DegTyp;
char Query[1024];
- char NewNameDegTyp[Deg_MAX_LENGTH_DEGREE_TYPE_NAME + 1];
+ char NewNameDegTyp[Deg_MAX_BYTES_DEGREE_TYPE_NAME + 1];
DegTyp = &Gbl.Degs.EditingDegTyp;
@@ -735,7 +735,7 @@ void DT_RenameDegreeType (void)
Lay_ShowErrorAndExit ("Code of type of degree is missing.");
/* Get the new name for the degree type */
- Par_GetParToText ("DegTypName",NewNameDegTyp,Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
+ Par_GetParToText ("DegTypName",NewNameDegTyp,Deg_MAX_BYTES_DEGREE_TYPE_NAME);
/***** Get from the database the old name of the degree type *****/
if (!DT_GetDataOfDegreeTypeByCod (DegTyp))
@@ -784,7 +784,7 @@ void DT_RenameDegreeType (void)
/***** Show the form again *****/
Str_Copy (DegTyp->DegTypName,NewNameDegTyp,
- Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
+ Deg_MAX_BYTES_DEGREE_TYPE_NAME);
DT_ReqEditDegreeTypes ();
}
diff --git a/swad_degree_type.h b/swad_degree_type.h
index ad92c947..3f66c0c6 100644
--- a/swad_degree_type.h
+++ b/swad_degree_type.h
@@ -31,7 +31,8 @@
/***************************** Public constants ******************************/
/*****************************************************************************/
-#define Deg_MAX_LENGTH_DEGREE_TYPE_NAME 32
+#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)
/*****************************************************************************/
/******************************* Public types ********************************/
@@ -39,9 +40,9 @@
struct DegreeType
{
- long DegTypCod; // Degree type code
- char DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME + 1]; // Degree type name
- unsigned NumDegs; // Number of degrees of this type
+ long DegTypCod; // Degree type code
+ char DegTypName[Deg_MAX_BYTES_DEGREE_TYPE_NAME + 1]; // Degree type name
+ unsigned NumDegs; // Number of degrees of this type
};
/*****************************************************************************/
diff --git a/swad_department.c b/swad_department.c
index 940aa605..cfe5ad5d 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_LENGTH_DEPARTMENT_SHRT_NAME);
+ Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME);
/* Get the full name of the department (row[3]) */
Str_Copy (Dpt->FullName,row[3],
- Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME);
+ Dpt_MAX_BYTES_DEPARTMENT_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_LENGTH_DEPARTMENT_SHRT_NAME);
+ Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME);
Str_Copy (Dpt->FullName,Txt_Another_department,
- Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME);
+ Dpt_MAX_BYTES_DEPARTMENT_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_LENGTH_DEPARTMENT_SHRT_NAME);
+ Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME);
/* Get the full name of the department (row[2]) */
Str_Copy (Dpt->FullName,row[2],
- Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME);
+ Dpt_MAX_BYTES_DEPARTMENT_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_LENGTH_DEPARTMENT_SHRT_NAME,Dpt->ShrtName,Gbl.Form.Id);
+ Dpt_MAX_CHARS_DEPARTMENT_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_LENGTH_DEPARTMENT_FULL_NAME,Dpt->FullName,Gbl.Form.Id);
+ Dpt_MAX_CHARS_DEPARTMENT_FULL_NAME,Dpt->FullName,Gbl.Form.Id);
Act_FormEnd ();
fprintf (Gbl.F.Out,"");
@@ -718,9 +718,9 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
struct Department *Dpt;
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
- size_t MaxLength = 0; // Initialized to avoid warning
+ size_t MaxBytes = 0; // Initialized to avoid warning
char *CurrentDptName = NULL; // Initialized to avoid warning
- char NewDptName[Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME + 1];
+ char NewDptName[Dpt_MAX_BYTES_DEPARTMENT_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";
- MaxLength = Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME;
+ MaxBytes = Dpt_MAX_BYTES_DEPARTMENT_SHRT_NAME;
CurrentDptName = Dpt->ShrtName;
break;
case Cns_FULL_NAME:
ParamName = "FullName";
FieldName = "FullName";
- MaxLength = Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME;
+ MaxBytes = Dpt_MAX_BYTES_DEPARTMENT_FULL_NAME;
CurrentDptName = Dpt->FullName;
break;
}
@@ -745,7 +745,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
Lay_ShowErrorAndExit ("Code of department is missing.");
/* Get the new name for the department */
- Par_GetParToText (ParamName,NewDptName,MaxLength);
+ Par_GetParToText (ParamName,NewDptName,MaxBytes);
/***** Get from the database the old names of the department *****/
Dpt_GetDataOfDepartmentByCod (Dpt);
@@ -792,7 +792,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
/***** Show the form again *****/
Str_Copy (CurrentDptName,NewDptName,
- MaxLength);
+ MaxBytes);
Dpt_EditDepartments ();
}
@@ -930,7 +930,7 @@ static void Dpt_PutFormToCreateDepartment (void)
" class=\"INPUT_SHORT_NAME\""
" required=\"required\" />"
"",
- Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME,Dpt->ShrtName);
+ Dpt_MAX_CHARS_DEPARTMENT_SHRT_NAME,Dpt->ShrtName);
/***** Department full name *****/
fprintf (Gbl.F.Out,"
",
- Grp_MAX_LENGTH_GROUP_NAME,Gbl.CurrentCrs.Grps.GrpName);
+ Grp_MAX_CHARS_GROUP_NAME,Gbl.CurrentCrs.Grps.GrpName);
/***** Maximum number of students *****/
fprintf (Gbl.F.Out,"
"
@@ -2332,7 +2332,7 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
/* Get group type name (row[1]) */
Str_Copy (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].GrpTypName,row[1],
- Grp_MAX_LENGTH_GROUP_TYPE_NAME);
+ Grp_MAX_BYTES_GROUP_TYPE_NAME);
/* Is it mandatory to register in any groups of this type? (row[2]) */
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].MandatoryEnrollment = (row[2][0] == 'Y');
@@ -2463,7 +2463,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
/* Get group name (row[1]) */
Str_Copy (Grp->GrpName,row[1],
- Grp_MAX_LENGTH_GROUP_NAME);
+ Grp_MAX_BYTES_GROUP_NAME);
/* Get max number of students of group (row[2]) and number of current students */
Grp->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[2]);
@@ -2592,7 +2592,7 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
/***** Get some data of group type *****/
row = mysql_fetch_row (mysql_res);
Str_Copy (GrpTyp->GrpTypName,row[0],
- Grp_MAX_LENGTH_GROUP_TYPE_NAME);
+ Grp_MAX_BYTES_GROUP_TYPE_NAME);
GrpTyp->MandatoryEnrollment = (row[1][0] == 'Y');
GrpTyp->MultipleEnrollment = (row[2][0] == 'Y');
GrpTyp->MustBeOpened = (row[3][0] == 'Y');
@@ -2679,14 +2679,14 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
/* Get the name of the group type (row[2]) */
Str_Copy (GrpDat->GrpTypName,row[2],
- Grp_MAX_LENGTH_GROUP_TYPE_NAME);
+ Grp_MAX_BYTES_GROUP_TYPE_NAME);
/* Get whether a student may be in one or multiple groups (row[3]) */
GrpDat->MultipleEnrollment = (row[3][0] == 'Y');
/* Get the name of the group (row[4]) */
Str_Copy (GrpDat->GrpName,row[4],
- Grp_MAX_LENGTH_GROUP_NAME);
+ Grp_MAX_BYTES_GROUP_NAME);
/* Get maximum number of students (row[5]) */
GrpDat->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[5]);
@@ -3050,7 +3050,7 @@ void Grp_GetNamesGrpsStdBelongsTo (long GrpTypCod,long UsrCod,char *GroupNames)
MYSQL_ROW row;
unsigned long NumRow;
unsigned long NumRows;
- size_t MaxLength = (Grp_MAX_LENGTH_GROUP_NAME + 2) * Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal;
+ size_t MaxLength = (Grp_MAX_BYTES_GROUP_NAME + 2) * Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal;
/***** Get the names of groups which a user belongs to, from database *****/
sprintf (Query,"SELECT crs_grp.GrpName FROM crs_grp,crs_grp_usr"
@@ -3094,7 +3094,7 @@ void Grp_RecFormNewGrpTyp (void)
/***** Get parameters from form *****/
/* Get the name of group type */
Par_GetParToText ("GrpTypName",Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,
- Grp_MAX_LENGTH_GROUP_TYPE_NAME);
+ Grp_MAX_BYTES_GROUP_TYPE_NAME);
/* Get whether it is mandatory to regisrer in any group of this type */
Gbl.CurrentCrs.Grps.GrpTyp.MandatoryEnrollment = Par_GetParToBool ("MandatoryEnrollment");
@@ -3156,7 +3156,7 @@ void Grp_RecFormNewGrp (void)
{
/* Get group name */
Par_GetParToText ("GrpName",Gbl.CurrentCrs.Grps.GrpName,
- Grp_MAX_LENGTH_GROUP_NAME);
+ Grp_MAX_BYTES_GROUP_NAME);
/* Get maximum number of students */
Gbl.CurrentCrs.Grps.MaxStudents = (unsigned)
@@ -3931,7 +3931,7 @@ void Grp_RenameGroupType (void)
extern const char *Txt_The_type_of_group_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_type_of_group_X_has_not_changed;
char Query[1024];
- char NewNameGrpTyp[Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1];
+ char NewNameGrpTyp[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1];
/***** Get parameters from form *****/
/* Get the code of the group type */
@@ -3939,7 +3939,7 @@ void Grp_RenameGroupType (void)
Lay_ShowErrorAndExit ("Code of type of group is missing.");
/* Get the new name for the group type */
- Par_GetParToText ("GrpTypName",NewNameGrpTyp,Grp_MAX_LENGTH_GROUP_TYPE_NAME);
+ Par_GetParToText ("GrpTypName",NewNameGrpTyp,Grp_MAX_BYTES_GROUP_TYPE_NAME);
/***** Get from the database the old name of the group type *****/
Grp_GetDataOfGroupTypeByCod (&Gbl.CurrentCrs.Grps.GrpTyp);
@@ -3989,7 +3989,7 @@ void Grp_RenameGroupType (void)
/***** Show the form again *****/
Str_Copy (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,NewNameGrpTyp,
- Grp_MAX_LENGTH_GROUP_TYPE_NAME);
+ Grp_MAX_BYTES_GROUP_TYPE_NAME);
Grp_ReqEditGroups ();
}
@@ -4005,7 +4005,7 @@ void Grp_RenameGroup (void)
extern const char *Txt_The_name_of_the_group_X_has_not_changed;
struct GroupData GrpDat;
char Query[512];
- char NewNameGrp[Grp_MAX_LENGTH_GROUP_NAME + 1];
+ char NewNameGrp[Grp_MAX_BYTES_GROUP_NAME + 1];
/***** Get parameters from form *****/
/* Get the code of the group */
@@ -4013,7 +4013,7 @@ void Grp_RenameGroup (void)
Lay_ShowErrorAndExit ("Code of group is missing.");
/* Get the new name for the group */
- Par_GetParToText ("GrpName",NewNameGrp,Grp_MAX_LENGTH_GROUP_NAME);
+ Par_GetParToText ("GrpName",NewNameGrp,Grp_MAX_BYTES_GROUP_NAME);
/***** Get from the database the type and the old name of the group *****/
GrpDat.GrpCod = Gbl.CurrentCrs.Grps.GrpCod;
@@ -4061,7 +4061,7 @@ void Grp_RenameGroup (void)
/***** Show the form again *****/
Str_Copy (Gbl.CurrentCrs.Grps.GrpName,NewNameGrp,
- Grp_MAX_LENGTH_GROUP_NAME);
+ Grp_MAX_BYTES_GROUP_NAME);
Grp_ReqEditGroups ();
}
diff --git a/swad_group.h b/swad_group.h
index 77994eff..aa6f46be 100644
--- a/swad_group.h
+++ b/swad_group.h
@@ -34,8 +34,11 @@
/***************************** Public constants ******************************/
/*****************************************************************************/
-#define Grp_MAX_LENGTH_GROUP_TYPE_NAME (256 - 1)
-#define Grp_MAX_LENGTH_GROUP_NAME (256 - 1)
+#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_NAME (128 - 1)
+#define Grp_MAX_BYTES_GROUP_NAME (Grp_MAX_CHARS_GROUP_NAME * Str_MAX_BYTES_PER_CHAR)
#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...
@@ -57,8 +60,8 @@ struct GroupData
long GrpCod;
long GrpTypCod;
long CrsCod;
- char GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1];
- char GrpName[Grp_MAX_LENGTH_GROUP_NAME + 1];
+ char GrpTypName[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1];
+ char GrpName[Grp_MAX_BYTES_GROUP_NAME + 1];
unsigned MaxStudents;
int Vacant;
bool Open; // Group is open?
@@ -69,7 +72,7 @@ struct GroupData
struct Group
{
long GrpCod; // Code of group
- char GrpName[Grp_MAX_LENGTH_GROUP_NAME + 1]; // Name of group
+ char GrpName[Grp_MAX_BYTES_GROUP_NAME + 1]; // Name of group
unsigned MaxStudents;
unsigned NumStudents; // Number of students in the group
bool Open; // Group is open?
@@ -80,7 +83,7 @@ struct Group
struct GroupType
{
long GrpTypCod; // Code of type of group
- char GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1]; // Name of type of group
+ char GrpTypName[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1]; // Name of type of group
bool MandatoryEnrollment; // Enrollment is mandatory?
bool MultipleEnrollment; // Enrollment is multiple?
bool MustBeOpened; // Groups must be opened?
diff --git a/swad_image.c b/swad_image.c
index 0a1e88db..41f4d6b4 100644
--- a/swad_image.c
+++ b/swad_image.c
@@ -411,8 +411,8 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
return;
LengthExtension = strlen (PtrExtension);
- if (LengthExtension < Fil_MIN_LENGTH_FILE_EXTENSION ||
- LengthExtension > Fil_MAX_LENGTH_FILE_EXTENSION)
+ if (LengthExtension < Fil_MIN_BYTES_FILE_EXTENSION ||
+ LengthExtension > Fil_MAX_BYTES_FILE_EXTENSION)
return;
/* Check if the file type is image/ or application/octet-stream */
diff --git a/swad_mail.c b/swad_mail.c
index 9312138f..aeaba2e3 100644
--- a/swad_mail.c
+++ b/swad_mail.c
@@ -67,8 +67,8 @@ extern struct Globals Gbl;
static void Mai_GetParamMaiOrder (void);
static void Mai_PutIconToEditMailDomains (void);
static void Mai_GetListMailDomainsAllowedForNotif (void);
-static void Mai_GetMailBox (const char *Email,char MailBox[Usr_MAX_BYTES_USR_EMAIL + 1]);
-static bool Mai_CheckIfMailDomainIsAllowedForNotif (const char *MailDomain);
+static void Mai_GetMailDomain (const char *Email,char MailDomain[Mai_MAX_LENGTH_MAIL_DOMAIN + 1]);
+static bool Mai_CheckIfMailDomainIsAllowedForNotif (const char MailDomain[Mai_MAX_LENGTH_MAIL_DOMAIN + 1]);
static void Mai_ListMailDomainsForEdition (void);
static void Mai_PutParamMaiCod (long MaiCod);
@@ -317,14 +317,14 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
bool Mai_CheckIfUsrCanReceiveEmailNotif (const struct UsrData *UsrDat)
{
- char MailDomain[Usr_MAX_BYTES_USR_EMAIL + 1];
+ char MailDomain[Mai_MAX_LENGTH_MAIL_DOMAIN + 1];
/***** Check #1: is my email address confirmed? *****/
if (!UsrDat->EmailConfirmed)
return false;
/***** Check #2: if my mail domain allowed? *****/
- Mai_GetMailBox (UsrDat->Email,MailDomain);
+ Mai_GetMailDomain (UsrDat->Email,MailDomain);
return Mai_CheckIfMailDomainIsAllowedForNotif (MailDomain);
}
@@ -332,19 +332,19 @@ bool Mai_CheckIfUsrCanReceiveEmailNotif (const struct UsrData *UsrDat)
/********************** Get mailbox from email address ***********************/
/*****************************************************************************/
-static void Mai_GetMailBox (const char *Email,char MailBox[Usr_MAX_BYTES_USR_EMAIL + 1])
+static void Mai_GetMailDomain (const char *Email,char MailDomain[Mai_MAX_LENGTH_MAIL_DOMAIN + 1])
{
const char *Ptr;
- MailBox[0] = '\0'; // Return empty mailbox on error
+ MailDomain[0] = '\0'; // Return empty mailbox on error
if ((Ptr = strchr (Email,(int) '@'))) // Find first '@' in address
if (Ptr != Email) // '@' is not the first character in Email
{
Ptr++; // Skip '@'
if (strchr (Ptr,(int) '@') == NULL) // No more '@' found
- Str_Copy (MailBox,Ptr,
- Usr_MAX_BYTES_USR_EMAIL);
+ Str_Copy (MailDomain,Ptr,
+ Mai_MAX_LENGTH_MAIL_DOMAIN);
}
}
@@ -352,7 +352,7 @@ static void Mai_GetMailBox (const char *Email,char MailBox[Usr_MAX_BYTES_USR_EMA
/************ Check if a mail domain is allowed for notifications ************/
/*****************************************************************************/
-static bool Mai_CheckIfMailDomainIsAllowedForNotif (const char *MailDomain)
+static bool Mai_CheckIfMailDomainIsAllowedForNotif (const char MailDomain[Mai_MAX_LENGTH_MAIL_DOMAIN + 1])
{
char Query[512];
@@ -1310,7 +1310,7 @@ void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe)
""
"",
- Usr_MAX_BYTES_USR_EMAIL,
+ Usr_MAX_CHARS_USR_EMAIL,
Gbl.Usrs.Me.UsrDat.Email);
Lay_PutCreateButtonInline (NumEmails ? Txt_Change_email : // User already has an email address
Txt_Save); // User has no email address yet
diff --git a/swad_message.c b/swad_message.c
index f2ad5b9b..c8ee1193 100644
--- a/swad_message.c
+++ b/swad_message.c
@@ -1013,11 +1013,11 @@ void Msg_GetParamMsgsCrsCod (void)
Crs_GetDataOfCourseByCod (&Crs);
Str_Copy (Gbl.Msg.FilterCrsShrtName,Crs.ShrtName,
- Crs_MAX_LENGTH_COURSE_SHRT_NAME);
+ Crs_MAX_BYTES_COURSE_SHRT_NAME);
}
else
Str_Copy (Gbl.Msg.FilterCrsShrtName,Txt_any_course,
- Crs_MAX_LENGTH_COURSE_SHRT_NAME);
+ Crs_MAX_BYTES_COURSE_SHRT_NAME);
}
/*****************************************************************************/
@@ -2512,7 +2512,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_LENGTH_COURSE_SHRT_NAME);
+ Crs_MAX_BYTES_COURSE_SHRT_NAME);
Gbl.Msg.NumCourses++;
}
}
diff --git a/swad_parameter.c b/swad_parameter.c
index 56bc640c..0e5c2421 100644
--- a/swad_parameter.c
+++ b/swad_parameter.c
@@ -174,7 +174,7 @@ static void Par_GetBoundary (void)
PtrToBoundary = strstr (getenv ("CONTENT_TYPE"),"boundary=") + strlen ("boundary=");
/***** Check that boundary string is not too long *****/
- if (2 + 2 + strlen (PtrToBoundary) > Par_MAX_LENGTH_BOUNDARY_WITH_CR_LF)
+ if (2 + 2 + strlen (PtrToBoundary) > Par_MAX_BYTES_BOUNDARY_WITH_CR_LF)
Lay_ShowErrorAndExit ("Delimiter string too long.");
/***** Create boundary strings *****/
diff --git a/swad_parameter.h b/swad_parameter.h
index bfe31e88..efb8b016 100644
--- a/swad_parameter.h
+++ b/swad_parameter.h
@@ -34,7 +34,7 @@
/************************** Public types and constants ***********************/
/*****************************************************************************/
-#define Par_MAX_LENGTH_BOUNDARY_WITH_CR_LF 100
+#define Par_MAX_BYTES_BOUNDARY_WITH_CR_LF (128 - 1)
struct StartLength
{
diff --git a/swad_plugin.c b/swad_plugin.c
index ba911cb9..7c89a7bb 100644
--- a/swad_plugin.c
+++ b/swad_plugin.c
@@ -248,7 +248,7 @@ static void Plg_GetListPlugins (void)
/* Get the IP of the plugin (row[6]) */
Str_Copy (Plg->IP,row[6],
- Cns_MAX_LENGTH_IP);
+ Cns_MAX_BYTES_IP);
}
}
else
@@ -315,7 +315,7 @@ bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
/* Get the IP of the plugin (row[5]) */
Str_Copy (Plg->IP,row[5],
- Cns_MAX_LENGTH_IP);
+ Cns_MAX_BYTES_IP);
}
else
PluginFound = false;
@@ -452,7 +452,8 @@ static void Plg_ListPluginsForEdition (void)
fprintf (Gbl.F.Out,"",
- Cns_MAX_LENGTH_IP,Plg->IP,Gbl.Form.Id);
+ Cns_MAX_CHARS_IP,Plg->IP,
+ Gbl.Form.Id);
Act_FormEnd ();
fprintf (Gbl.F.Out,"