diff --git a/swad_agenda.c b/swad_agenda.c index 0805c68c..d90af5ae 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -1039,11 +1039,8 @@ static void Agd_PutParamAgdCod (long AgdCod) long Agd_GetParamAgdCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of event *****/ - Par_GetParToText ("AgdCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of event *****/ + return Par_GetParToLong ("AgdCod"); } /*****************************************************************************/ diff --git a/swad_announcement.c b/swad_announcement.c index 06a09e41..c5e8d203 100644 --- a/swad_announcement.c +++ b/swad_announcement.c @@ -387,12 +387,10 @@ static void Ann_PutParams (void) static long Ann_GetParamAnnCod (void) { - char LongStr[1 + 10 + 1]; // String that holds the announcement code long AnnCod; - /* Get announcement code */ - Par_GetParToText ("AnnCod",LongStr,1 + 10); - if (sscanf (LongStr,"%ld",&AnnCod) != 1) + /***** Get announcement code *****/ + if ((AnnCod = Par_GetParToLong ("AnnCod")) <= 0) Lay_ShowErrorAndExit ("Wrong code of announcement."); return AnnCod; diff --git a/swad_assignment.c b/swad_assignment.c index 0bb52001..fc22544e 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -929,11 +929,8 @@ static void Asg_PutParamAsgCod (long AsgCod) long Asg_GetParamAsgCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of assignment *****/ - Par_GetParToText ("AsgCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of assignment *****/ + return Par_GetParToLong ("AsgCod"); } /*****************************************************************************/ diff --git a/swad_attendance.c b/swad_attendance.c index 9a1cfaaa..9eeb0608 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -893,11 +893,8 @@ void Att_PutParamAttCod (long AttCod) long Att_GetParamAttCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of attendance event *****/ - Par_GetParToText ("AttCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of attendance event *****/ + return Par_GetParToLong ("AttCod"); } /*****************************************************************************/ @@ -1280,7 +1277,6 @@ void Att_RecFormAttEvent (void) extern const char *Txt_The_event_has_been_modified; struct AttendanceEvent OldAtt; struct AttendanceEvent ReceivedAtt; - char YN[1 + 1]; bool ItsANewAttEvent; bool ReceivedAttEventIsCorrect = true; char Txt[Cns_MAX_BYTES_TEXT + 1]; @@ -1301,8 +1297,7 @@ void Att_RecFormAttEvent (void) ReceivedAtt.TimeUTC[Att_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" ); /***** Get boolean parameter that indicates if teacher's comments are visible by students *****/ - Par_GetParToText ("ComTchVisible",YN,1); - ReceivedAtt.CommentTchVisible = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + ReceivedAtt.CommentTchVisible = Par_GetParToBool ("ComTchVisible"); /***** Get attendance event title *****/ Par_GetParToText ("Title",ReceivedAtt.Title,Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE); @@ -2719,14 +2714,12 @@ void Usr_PrintMyAttendanceCrs (void) static void Usr_ListOrPrintMyAttendanceCrs (Att_TypeOfView_t TypeOfView) { unsigned NumAttEvent; - char YN[1 + 1]; /***** Get list of attendance events *****/ Att_GetListAttEvents (Att_OLDEST_FIRST); /***** Get boolean parameter that indicates if details must be shown *****/ - Par_GetParToText ("ShowDetails",YN,1); - Gbl.AttEvents.ShowDetails = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.AttEvents.ShowDetails = Par_GetParToBool ("ShowDetails"); /***** Get list of groups selected ******/ Grp_GetParCodsSeveralGrpsToShowUsrs (); @@ -2785,7 +2778,6 @@ static void Usr_ListOrPrintStdsAttendanceCrs (Att_TypeOfView_t TypeOfView) unsigned NumStdsInList; long *LstSelectedUsrCods; unsigned NumAttEvent; - char YN[1 + 1]; /***** Get list of attendance events *****/ Att_GetListAttEvents (Att_OLDEST_FIRST); @@ -2797,8 +2789,7 @@ static void Usr_ListOrPrintStdsAttendanceCrs (Att_TypeOfView_t TypeOfView) if ((NumStdsInList = Usr_CountNumUsrsInListOfSelectedUsrs ())) { /***** Get boolean parameter that indicates if details must be shown *****/ - Par_GetParToText ("ShowDetails",YN,1); - Gbl.AttEvents.ShowDetails = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.AttEvents.ShowDetails = Par_GetParToBool ("ShowDetails"); /***** Get list of groups selected ******/ Grp_GetParCodsSeveralGrpsToShowUsrs (); diff --git a/swad_banner.c b/swad_banner.c index 8b11099e..386d0ce9 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -423,11 +423,8 @@ static void Ban_PutParamBanCod (long BanCod) long Ban_GetParamBanCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of banner *****/ - Par_GetParToText ("BanCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of banner *****/ + return Par_GetParToLong ("BanCod"); } /*****************************************************************************/ diff --git a/swad_centre.c b/swad_centre.c index f28b735d..a70e312e 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -94,7 +94,6 @@ static Ctr_StatusTxt_t Ctr_GetStatusTxtFromStatusBits (Ctr_Status_t Status); static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt); static void Ctr_PutParamOtherCtrCod (long CtrCod); -static long Ctr_GetParamOtherCtrCod (void); static void Ctr_UpdateCtrInsDB (long CtrCod,long InsCod); static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName); @@ -1670,21 +1669,12 @@ long Ctr_GetAndCheckParamOtherCtrCod (void) long CtrCod; /***** Get and check parameter with code of centre *****/ - if ((CtrCod = Ctr_GetParamOtherCtrCod ()) < 0) + if ((CtrCod = Par_GetParToLong ("OthCtrCod")) <= 0) Lay_ShowErrorAndExit ("Code of centre is missing."); return CtrCod; } -static long Ctr_GetParamOtherCtrCod (void) - { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of centre *****/ - Par_GetParToText ("OthCtrCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); - } - /*****************************************************************************/ /******************************* Remove a centre *****************************/ /*****************************************************************************/ diff --git a/swad_changelog.h b/swad_changelog.h index aa114c8d..eeaade7a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -191,13 +191,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.127.3 (2017-01-28)" +#define Log_PLATFORM_VERSION "SWAD 16.129 (2017-01-28)" #define CSS_FILE "swad16.123.css" #define JS_FILE "swad16.123.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.129: Jan 28, 2017 Code refactoring in Y/N parameters. (211974 lines) + Version 16.128: Jan 28, 2017 Code refactoring in long parameters. (212037 lines) Version 16.127.3: Jan 28, 2017 Fixed bug in permissions to change another user's data. (212127 lines) Version 16.127.2: Jan 28, 2017 Fixed bug creating a new account. (212124 lines) Version 16.127.1: Jan 28, 2017 Fixed bug in listing of users. (212125 lines) diff --git a/swad_country.c b/swad_country.c index 9652cc0e..7635eb2a 100644 --- a/swad_country.c +++ b/swad_country.c @@ -1601,11 +1601,8 @@ long Cty_GetAndCheckParamOtherCtyCod (void) static long Cty_GetParamOtherCtyCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of country *****/ - Par_GetParToText ("OthCtyCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of country *****/ + return Par_GetParToLong ("OthCtyCod"); } /*****************************************************************************/ diff --git a/swad_course.c b/swad_course.c index 7082cb47..3080dd85 100644 --- a/swad_course.c +++ b/swad_course.c @@ -120,7 +120,6 @@ static void Sch_PutLinkToSearchCoursesParams (void); static void Crs_PutParamOtherCrsCod (long CrsCod); static long Crs_GetAndCheckParamOtherCrsCod (void); -static long Crs_GetParamOtherCrsCod (void); static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnAccepted); @@ -2977,21 +2976,12 @@ static long Crs_GetAndCheckParamOtherCrsCod (void) long CrsCod; /***** Get and check parameter with code of course *****/ - if ((CrsCod = Crs_GetParamOtherCrsCod ()) < 0) + if ((CrsCod = Par_GetParToLong ("OthCrsCod")) <= 0) Lay_ShowErrorAndExit ("Code of course is missing."); return CrsCod; } -static long Crs_GetParamOtherCrsCod (void) - { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of course *****/ - Par_GetParToText ("OthCrsCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); - } - /*****************************************************************************/ /************************** Write courses of a user **************************/ /*****************************************************************************/ diff --git a/swad_date.c b/swad_date.c index d64fc1bf..2b7da2da 100644 --- a/swad_date.c +++ b/swad_date.c @@ -519,11 +519,8 @@ void Dat_WriteFormClientLocalDateTimeFromTimeUTC (const char *Id, time_t Dat_GetTimeUTCFromForm (const char *ParamName) { - char LongStr[1 + 10 + 1]; - /**** Get time ****/ - Par_GetParToText (ParamName,LongStr,1 + 10); - return Dat_GetUNIXTimeFromStr (LongStr); + return Par_GetParToLong (ParamName); } /*****************************************************************************/ diff --git a/swad_degree.c b/swad_degree.c index 5e6d6460..8e272839 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -102,7 +102,6 @@ static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg); static void Deg_RecFormRequestOrCreateDeg (unsigned Status); static void Deg_PutParamOtherDegCod (long DegCod); -static long Deg_GetParamOtherDegCod (void); static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row); static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName); @@ -1652,21 +1651,12 @@ long Deg_GetAndCheckParamOtherDegCod (void) long DegCod; /***** Get and check parameter with code of degree *****/ - if ((DegCod = Deg_GetParamOtherDegCod ()) < 0) + if ((DegCod = Par_GetParToLong ("OthDegCod")) <= 0) Lay_ShowErrorAndExit ("Code of degree is missing."); return DegCod; } -static long Deg_GetParamOtherDegCod (void) - { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of degree *****/ - Par_GetParToText ("OthDegCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); - } - /*****************************************************************************/ /********************* Get data of a degree from its code ********************/ /*****************************************************************************/ diff --git a/swad_degree_type.c b/swad_degree_type.c index 3faa8aed..e38b4368 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -598,11 +598,8 @@ static void DT_PutParamOtherDegTypCod (long DegTypCod) long DT_GetParamOtherDegTypCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of degree type *****/ - Par_GetParToText ("OthDegTypCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of degree type *****/ + return Par_GetParToLong ("OthDegTypCod"); } /*****************************************************************************/ diff --git a/swad_department.c b/swad_department.c index 9d3ed509..56ac36c9 100644 --- a/swad_department.c +++ b/swad_department.c @@ -616,11 +616,8 @@ static void Dpt_PutParamDptCod (long DptCod) long Dpt_GetParamDptCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of department *****/ - Par_GetParToText ("DptCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of department *****/ + return Par_GetParToLong ("DptCod"); } /*****************************************************************************/ diff --git a/swad_exam.c b/swad_exam.c index 6abce7cc..2f15d1ab 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -1611,11 +1611,8 @@ void Exa_PutHiddenParamExaCod (long ExaCod) static long Exa_GetParamExaCod (void) { - char LongStr[1 + 10 + 1]; // String that holds the exam announcement code - /* Get notice code */ - Par_GetParToText ("ExaCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + return Par_GetParToLong ("ExaCod"); } /*****************************************************************************/ diff --git a/swad_file_browser.c b/swad_file_browser.c index c7f6b4a3..50938c3a 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -2413,11 +2413,8 @@ void Brw_PutHiddenParamFilCod (long FilCod) long Brw_GetParamFilCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of file *****/ - Par_GetParToText ("FilCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of file *****/ + return Par_GetParToLong ("FilCod"); } /*****************************************************************************/ @@ -4705,10 +4702,7 @@ void Brw_PutHiddenParamFullTreeIfSelected (void) static bool Brw_GetFullTreeFromForm (void) { - char YN[1 + 1]; - - Par_GetParToText ("FullTree",YN,1); - return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + return Par_GetParToBool ("FullTree"); } /*****************************************************************************/ @@ -9867,10 +9861,7 @@ void Brw_ChgFileMetadata (void) static bool Brw_GetParamPublicFile (void) { - char YN[1 + 1]; - - Par_GetParToText ("PublicFile",YN,1); - return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + return Par_GetParToBool ("PublicFile"); } /*****************************************************************************/ diff --git a/swad_forum.c b/swad_forum.c index 4c641f8f..31ce5339 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -3729,7 +3729,6 @@ void For_GetParamsForum (void) { char UnsignedStr[10 + 1]; unsigned UnsignedNum; - char LongStr[1 + 10 + 1]; /***** Get which forums I want to see *****/ Par_GetParToText ("WhichForum",UnsignedStr,10); @@ -3746,23 +3745,19 @@ void For_GetParamsForum (void) Gbl.Forum.SelectedOrderType = For_DEFAULT_ORDER; /***** Get parameter with code of institution *****/ - Par_GetParToText ("ForInsCod",LongStr,1 + 10); - Gbl.Forum.Ins.InsCod = Str_ConvertStrCodToLongCod (LongStr); + Gbl.Forum.Ins.InsCod = Par_GetParToLong ("ForInsCod"); Ins_GetDataOfInstitutionByCod (&Gbl.Forum.Ins,Ins_GET_BASIC_DATA); /***** Get parameter with code of institution *****/ - Par_GetParToText ("ForCtrCod",LongStr,1 + 10); - Gbl.Forum.Ctr.CtrCod = Str_ConvertStrCodToLongCod (LongStr); + Gbl.Forum.Ctr.CtrCod = Par_GetParToLong ("ForCtrCod"); Ctr_GetDataOfCentreByCod (&Gbl.Forum.Ctr); /***** Get parameter with code of degree *****/ - Par_GetParToText ("ForDegCod",LongStr,1 + 10); - Gbl.Forum.Deg.DegCod = Str_ConvertStrCodToLongCod (LongStr); + Gbl.Forum.Deg.DegCod = Par_GetParToLong ("ForDegCod"); Deg_GetDataOfDegreeByCod (&Gbl.Forum.Deg); /***** Get parameter with code of course *****/ - Par_GetParToText ("ForCrsCod",LongStr,1 + 10); - Gbl.Forum.Crs.CrsCod = Str_ConvertStrCodToLongCod (LongStr); + Gbl.Forum.Crs.CrsCod = Par_GetParToLong ("ForCrsCod"); Crs_GetDataOfCourseByCod (&Gbl.Forum.Crs); } @@ -3781,12 +3776,10 @@ void For_PutHiddenParamThrCod (long ThrCod) static long For_GetParamThrCod (void) { - char StrThrCod[1 + 10 + 1]; // String that holds the thread code long ThrCod; - /* Get thread code */ - Par_GetParToText ("ThrCod",StrThrCod,1 + 10); - if (sscanf (StrThrCod,"%ld",&ThrCod) != 1) + /***** Get thread code *****/ + if ((ThrCod = Par_GetParToLong ("ThrCod")) <= 0) Lay_ShowErrorAndExit ("Wrong thread code."); return ThrCod; @@ -3807,12 +3800,10 @@ static void For_PutHiddenParamPstCod (long PstCod) static long For_GetParamPstCod (void) { - char StrPstCod[1 + 10 + 1]; // String that holds the post code long PstCod; - /* Get post code */ - Par_GetParToText ("PstCod",StrPstCod,1 + 10); - if (sscanf (StrPstCod,"%ld",&PstCod) != 1) + /***** Get post code *****/ + if ((PstCod = Par_GetParToLong ("PstCod")) <= 0) Lay_ShowErrorAndExit ("Wrong post code."); return PstCod; diff --git a/swad_group.c b/swad_group.c index af4e6dd7..add272cb 100644 --- a/swad_group.c +++ b/swad_group.c @@ -342,7 +342,6 @@ void Grp_PutParamsCodGrps (void) void Grp_GetParCodsSeveralGrpsToShowUsrs (void) { - char YN[1 + 1]; struct ListCodGrps LstGrpsIBelong; unsigned NumGrp; @@ -350,8 +349,7 @@ void Grp_GetParCodsSeveralGrpsToShowUsrs (void) return; /***** Get boolean parameter that indicates if all groups must be listed *****/ - Par_GetParToText ("AllGroups",YN,1); - Gbl.Usrs.ClassPhoto.AllGroups = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.Usrs.ClassPhoto.AllGroups = Par_GetParToBool ("AllGroups"); /***** Get parameter with list of groups selected *****/ Grp_GetParCodsSeveralGrps (); @@ -3084,19 +3082,16 @@ void Grp_RecFormNewGrpTyp (void) { extern const char *Txt_The_type_of_group_X_already_exists; extern const char *Txt_You_must_specify_the_name_of_the_new_type_of_group; - char YN[1 + 1]; /***** Get parameters from form *****/ /* Get the name of group type */ Par_GetParToText ("GrpTypName",Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,Grp_MAX_LENGTH_GROUP_TYPE_NAME); /* Get whether it is mandatory to regisrer in any group of this type */ - Par_GetParToText ("MandatoryEnrollment",YN,1); - Gbl.CurrentCrs.Grps.GrpTyp.MandatoryEnrollment = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.CurrentCrs.Grps.GrpTyp.MandatoryEnrollment = Par_GetParToBool ("MandatoryEnrollment"); /* Get whether it is possible to register in multiple groups of this type */ - Par_GetParToText ("MultipleEnrollment",YN,1); - Gbl.CurrentCrs.Grps.GrpTyp.MultipleEnrollment = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.CurrentCrs.Grps.GrpTyp.MultipleEnrollment = Par_GetParToBool ("MultipleEnrollment"); /* Get open time */ Gbl.CurrentCrs.Grps.GrpTyp.OpenTimeUTC = Dat_GetTimeUTCFromForm ("OpenTimeUTC"); @@ -3691,7 +3686,6 @@ void Grp_ChangeMandatGrpTyp (void) extern const char *Txt_The_enrollment_of_students_into_groups_of_type_X_is_now_mandatory; extern const char *Txt_The_enrollment_of_students_into_groups_of_type_X_is_now_voluntary; char Query[1024]; - char YN[1 + 1]; bool NewMandatoryEnrollment; /***** Get parameters of the form *****/ @@ -3700,8 +3694,7 @@ void Grp_ChangeMandatGrpTyp (void) Lay_ShowErrorAndExit ("Code of type of group is missing."); /* Get the new type of enrollment (mandatory or voluntaria) of this type of group */ - Par_GetParToText ("MandatoryEnrollment",YN,1); - NewMandatoryEnrollment = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + NewMandatoryEnrollment = Par_GetParToBool ("MandatoryEnrollment"); /* Get from the database the name of the type and the old type of enrollment */ Grp_GetDataOfGroupTypeByCod (&Gbl.CurrentCrs.Grps.GrpTyp); @@ -3746,7 +3739,6 @@ void Grp_ChangeMultiGrpTyp (void) extern const char *Txt_Now_each_student_can_belong_to_multiple_groups_of_type_X; extern const char *Txt_Now_each_student_can_only_belong_to_a_group_of_type_X; char Query[1024]; - char YN[1 + 1]; bool NewMultipleEnrollment; /***** Get parameters from the form *****/ @@ -3755,8 +3747,7 @@ void Grp_ChangeMultiGrpTyp (void) Lay_ShowErrorAndExit ("Code of type of group is missing."); /* Get the new type of enrollment (single or multiple) of this type of group */ - Par_GetParToText ("MultipleEnrollment",YN,1); - NewMultipleEnrollment = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + NewMultipleEnrollment = Par_GetParToBool ("MultipleEnrollment"); /* Get from the database the name of the type and the old type of enrollment */ Grp_GetDataOfGroupTypeByCod (&Gbl.CurrentCrs.Grps.GrpTyp); @@ -4064,11 +4055,8 @@ void Grp_RenameGroup (void) static long Grp_GetParamGrpTypCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of group type *****/ - Par_GetParToText ("GrpTypCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of group type *****/ + return Par_GetParToLong ("GrpTypCod"); } /*****************************************************************************/ @@ -4077,11 +4065,8 @@ static long Grp_GetParamGrpTypCod (void) static long Grp_GetParamGrpCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with group code *****/ - Par_GetParToText ("GrpCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get group code *****/ + return Par_GetParToLong ("GrpCod"); } /*****************************************************************************/ diff --git a/swad_holiday.c b/swad_holiday.c index b07052a2..c6b7face 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -622,11 +622,8 @@ static void Hld_PutParamHldCod (long HldCod) long Hld_GetParamHldCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of holiday *****/ - Par_GetParToText ("HldCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of holiday *****/ + return Par_GetParToLong ("HldCod"); } /*****************************************************************************/ diff --git a/swad_indicator.c b/swad_indicator.c index 0f985bce..e6017081 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -494,15 +494,13 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res) static bool Ind_GetIfShowBigList (unsigned NumCrss) { bool ShowBigList; - char YN[1 + 1]; /***** If list of courses is too big... *****/ if (NumCrss <= Cfg_MIN_NUM_COURSES_TO_CONFIRM_SHOW_BIG_LIST) return true; // List is not too big ==> show it /***** Get parameter with user's confirmation to see a big list of courses *****/ - Par_GetParToText ("ShowBigList",YN,1); - if (!(ShowBigList = (Str_ConvertToUpperLetter (YN[0]) == 'Y'))) + if (!(ShowBigList = Par_GetParToBool ("ShowBigList"))) Ind_PutButtonToConfirmIWantToSeeBigList (NumCrss); return ShowBigList; diff --git a/swad_info.c b/swad_info.c index cd9fcc59..97ffe022 100644 --- a/swad_info.c +++ b/swad_info.c @@ -669,11 +669,7 @@ void Inf_ChangeIHaveReadInfo (void) static bool Inf_GetMustBeReadFromForm (void) { - char YN[1 + 1]; - - /***** Get a parameter that indicates if info must be read by students ******/ - Par_GetParToText ("MustBeRead",YN,1); - return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + return Par_GetParToBool ("MustBeRead"); } /*****************************************************************************/ @@ -682,11 +678,7 @@ static bool Inf_GetMustBeReadFromForm (void) static bool Inf_GetIfIHaveReadFromForm (void) { - char YN[1 + 1]; - - /***** Get a parameter that indicates if I have read a course info ******/ - Par_GetParToText ("IHaveRead",YN,1); - return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + return Par_GetParToBool ("IHaveRead"); } /*****************************************************************************/ diff --git a/swad_institution.c b/swad_institution.c index 29377ebf..33058070 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -1556,11 +1556,8 @@ long Ins_GetAndCheckParamOtherInsCod (void) static long Ins_GetParamOtherInsCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of institution *****/ - Par_GetParToText ("OthInsCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of institution *****/ + return Par_GetParToLong ("OthInsCod"); } /*****************************************************************************/ diff --git a/swad_link.c b/swad_link.c index c1c10e30..42b42333 100644 --- a/swad_link.c +++ b/swad_link.c @@ -409,11 +409,8 @@ static void Lnk_PutParamLnkCod (long LnkCod) long Lnk_GetParamLnkCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of link *****/ - Par_GetParToText ("LnkCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of link *****/ + return Par_GetParToLong ("LnkCod"); } /*****************************************************************************/ diff --git a/swad_mail.c b/swad_mail.c index 13182e60..e2843ffd 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -533,11 +533,8 @@ static void Mai_PutParamMaiCod (long MaiCod) long Mai_GetParamMaiCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of mail *****/ - Par_GetParToText ("MaiCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of mail *****/ + return Par_GetParToLong ("MaiCod"); } /*****************************************************************************/ diff --git a/swad_message.c b/swad_message.c index 91d1761d..edb6183b 100644 --- a/swad_message.c +++ b/swad_message.c @@ -173,7 +173,6 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1]) extern const char *Txt_New_message; extern const char *Txt_MSG_To; extern const char *Txt_Send_message; - char YN[1 + 1]; unsigned NumUsrsInCrs = 0; // Initialized to avoid warning bool ShowUsrsInCrs = false; bool GetUsrsInCrs; @@ -182,21 +181,17 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1]) Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs = 0; /***** Get parameter that indicates if the message is a reply to another message *****/ - Par_GetParToText ("IsReply",YN,1); - if ((Gbl.Msg.Reply.IsReply = (Str_ConvertToUpperLetter (YN[0]) == 'Y'))) + if ((Gbl.Msg.Reply.IsReply = Par_GetParToBool ("IsReply"))) /* Get original message code */ if ((Gbl.Msg.Reply.OriginalMsgCod = Msg_GetParamMsgCod ()) <= 0) Lay_ShowErrorAndExit ("Wrong code of message."); /***** Get user's code of possible preselected recipient *****/ if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) // There is a preselected recipient - { /* Get who to show as potential recipients: - only the selected recipient - any user (default) */ - Par_GetParToText ("ShowOnlyOneRecipient",YN,1); - Gbl.Msg.ShowOnlyOneRecipient = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); - } + Gbl.Msg.ShowOnlyOneRecipient = Par_GetParToBool ("ShowOnlyOneRecipient"); else Gbl.Msg.ShowOnlyOneRecipient = false; @@ -637,7 +632,6 @@ void Msg_RecMsgFromUsr (void) extern const char *Txt_The_message_has_been_sent_to_1_recipient; extern const char *Txt_The_message_has_been_sent_to_X_recipients; extern const char *Txt_There_have_been_X_errors_in_sending_the_message; - char YN[1 + 1]; bool IsReply; bool RecipientHasBannedMe; bool Replied = false; @@ -665,8 +659,7 @@ void Msg_RecMsgFromUsr (void) Str_DONT_CHANGE,false); /* Get parameter that indicates if the message is a reply to a previous message */ - Par_GetParToText ("IsReply",YN,1); - if ((IsReply = (Str_ConvertToUpperLetter (YN[0]) == 'Y'))) + if ((IsReply = Par_GetParToBool ("IsReply"))) /* Get original message code */ if ((OriginalMsgCod = Msg_GetParamMsgCod ()) <= 0) Lay_ShowErrorAndExit ("Wrong code of message."); @@ -1011,12 +1004,9 @@ static void Msg_ShowNumMsgsDeleted (unsigned NumMsgs) void Msg_GetParamMsgsCrsCod (void) { extern const char *Txt_any_course; - char LongStr[1 + 10 + 1]; struct Course Crs; - Par_GetParToText ("FilterCrsCod",LongStr,1 + 10); - Gbl.Msg.FilterCrsCod = Str_ConvertStrCodToLongCod (LongStr); - if (Gbl.Msg.FilterCrsCod > 0) // If origin course specified + if ((Gbl.Msg.FilterCrsCod = Par_GetParToLong ("FilterCrsCod")) > 0) // If origin course specified { /* Get data of course */ Crs.CrsCod = Gbl.Msg.FilterCrsCod; @@ -2649,11 +2639,8 @@ static void Msg_ShowFormToShowOnlyUnreadMessages (void) static void Msg_GetParamOnlyUnreadMsgs (void) { - char YN[1 + 1]; - /***** Get parameter to show only unread (received) messages *****/ - Par_GetParToText ("OnlyUnreadMsgs",YN,1); - Gbl.Msg.ShowOnlyUnreadMsgs = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.Msg.ShowOnlyUnreadMsgs = Par_GetParToBool ("OnlyUnreadMsgs"); } /*****************************************************************************/ @@ -3362,7 +3349,6 @@ static void Msg_WriteMsgTo (long MsgCod) unsigned NumRecipientsKnown; unsigned NumRecipientsUnknown; unsigned NumRecipientsToShow; - char YN[1 + 1]; struct UsrData UsrDat; bool Deleted; bool OpenByDst; @@ -3408,12 +3394,9 @@ static void Msg_WriteMsgTo (long MsgCod) if (NumRecipientsKnown <= Msg_MAX_RECIPIENTS_TO_SHOW) NumRecipientsToShow = NumRecipientsKnown; else // A lot of recipients - { /***** Get parameter that indicates if I want to see all recipients *****/ - Par_GetParToText ("SeeAllRcpts",YN,1); - NumRecipientsToShow = (Str_ConvertToUpperLetter (YN[0]) == 'Y') ? NumRecipientsKnown : - Msg_DEF_RECIPIENTS_TO_SHOW; - } + NumRecipientsToShow = Par_GetParToBool ("SeeAllRcpts") ? NumRecipientsKnown : + Msg_DEF_RECIPIENTS_TO_SHOW; /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); @@ -3599,11 +3582,8 @@ void Msg_PutHiddenParamMsgCod (long MsgCod) static long Msg_GetParamMsgCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of message *****/ - Par_GetParToText ("MsgCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of message *****/ + return Par_GetParToLong ("MsgCod"); } /*****************************************************************************/ diff --git a/swad_notice.c b/swad_notice.c index fa990e80..225933a2 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -996,12 +996,10 @@ void Not_PutHiddenParamNotCod (long NotCod) static long Not_GetParamNotCod (void) { - char LongStr[1 + 10 + 1]; // String that holds the notice code long NotCod; - /* Get notice code */ - Par_GetParToText ("NotCod",LongStr,1 + 10); - if (sscanf (LongStr,"%ld",&NotCod) != 1) + /***** Get notice code *****/ + if ((NotCod = Par_GetParToLong ("NotCod")) <= 0) Lay_ShowErrorAndExit ("Wrong code of notice."); return NotCod; diff --git a/swad_notification.c b/swad_notification.c index 1849d359..d34c6389 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -673,10 +673,7 @@ static void Ntf_WriteFormAllNotifications (bool AllNotifications) static bool Ntf_GetAllNotificationsFromForm (void) { - char YN[1 + 1]; - - Par_GetParToText ("All",YN,1); - return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + return Par_GetParToBool ("All"); } /*****************************************************************************/ @@ -1956,7 +1953,6 @@ void Ntf_PutFormChangeNotifSentByEMail (void) static void Ntf_GetParamsNotifyEvents (void) { Ntf_NotifyEvent_t NotifyEvent; - char YN[1 + 1]; bool CreateNotifForThisEvent; Gbl.Usrs.Me.UsrDat.Prefs.NotifNtfEvents = 0; @@ -1965,14 +1961,13 @@ static void Ntf_GetParamsNotifyEvents (void) NotifyEvent < Ntf_NUM_NOTIFY_EVENTS; NotifyEvent++) // 0 is reserved for Ntf_EVENT_UNKNOWN { - Par_GetParToText (Ntf_ParamNotifMeAboutNotifyEvents[NotifyEvent],YN,1); - if ((CreateNotifForThisEvent = (Str_ConvertToUpperLetter (YN[0]) == 'Y'))) + if ((CreateNotifForThisEvent = Par_GetParToBool (Ntf_ParamNotifMeAboutNotifyEvents[NotifyEvent]))) Gbl.Usrs.Me.UsrDat.Prefs.NotifNtfEvents |= (1 << NotifyEvent); if (CreateNotifForThisEvent) { - Par_GetParToText (Ntf_ParamEmailMeAboutNotifyEvents[NotifyEvent],YN,1); - if (Str_ConvertToUpperLetter (YN[0]) == 'Y') + Par_GetParToBool (Ntf_ParamEmailMeAboutNotifyEvents[NotifyEvent]); + if (Par_GetParToBool (Ntf_ParamEmailMeAboutNotifyEvents[NotifyEvent])) Gbl.Usrs.Me.UsrDat.Prefs.EmailNtfEvents |= (1 << NotifyEvent); } } diff --git a/swad_parameter.c b/swad_parameter.c index bd697f3c..0edf9f8c 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -872,6 +872,32 @@ unsigned Par_GetParToText (const char *ParamName,char *ParamValue,size_t MaxByte Str_TO_TEXT,true); } +/*****************************************************************************/ +/******************** Get the long value of a parameter **********************/ +/*****************************************************************************/ + +long Par_GetParToLong (const char *ParamName) + { + char LongStr[1 + 10 + 1]; + + /***** Get parameter with long number *****/ + Par_GetParToText (ParamName,LongStr,1 + 10); + return Str_ConvertStrCodToLongCod (LongStr); + } + +/*****************************************************************************/ +/************************** Get a boolean parameter **************************/ +/*****************************************************************************/ + +bool Par_GetParToBool (const char *ParamName) + { + char YN[1 + 1]; + + /***** Get parameter "Y"/"N" and convert to boolean *****/ + Par_GetParToText (ParamName,YN,1); + return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + } + /*****************************************************************************/ /*** Get value of a single parameter and change format to not rigorous HTML **/ /*****************************************************************************/ diff --git a/swad_parameter.h b/swad_parameter.h index f1c6e7f0..b20dce07 100644 --- a/swad_parameter.h +++ b/swad_parameter.h @@ -72,6 +72,8 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, void Par_GetMainParameters (void); unsigned Par_GetParToText (const char *ParamName,char *ParamValue,size_t MaxBytes); +long Par_GetParToLong (const char *ParamName); +bool Par_GetParToBool (const char *ParamName); unsigned Par_GetParToHTML (const char *ParamName,char *ParamValue,size_t MaxBytes); unsigned Par_GetParMultiToText (const char *ParamName,char *ParamValue,size_t MaxBytes); unsigned Par_GetParAndChangeFormat (const char *ParamName,char *ParamValue,size_t MaxBytes, diff --git a/swad_password.c b/swad_password.c index a32132ca..a6edd9de 100644 --- a/swad_password.c +++ b/swad_password.c @@ -927,8 +927,7 @@ bool Pwd_GetConfirmationOnDangerousAction (void) char EncryptedPassword[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64 + 1]; /***** Get if consent has been done *****/ - Par_GetParToText ("Consent",YN,1); - if (Str_ConvertToUpperLetter (YN[0]) != 'Y') + if (Par_GetParToBool ("Consent")) { Lay_ShowAlert (Lay_WARNING,Txt_You_have_not_confirmed_the_action); return false; diff --git a/swad_place.c b/swad_place.c index a9b325ba..2be7a3d1 100644 --- a/swad_place.c +++ b/swad_place.c @@ -507,11 +507,8 @@ static void Plc_PutParamPlcCod (long PlcCod) long Plc_GetParamPlcCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of place *****/ - Par_GetParToText ("PlcCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of place *****/ + return Par_GetParToLong ("PlcCod"); } /*****************************************************************************/ diff --git a/swad_plugin.c b/swad_plugin.c index 389183c6..c08a68cc 100644 --- a/swad_plugin.c +++ b/swad_plugin.c @@ -476,11 +476,8 @@ static void Plg_PutParamPlgCod (long PlgCod) long Plg_GetParamPlgCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of plugin *****/ - Par_GetParToText ("PlgCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of plugin *****/ + return Par_GetParToLong ("PlgCod"); } /*****************************************************************************/ diff --git a/swad_record.c b/swad_record.c index 1e6d21d1..5e603f45 100644 --- a/swad_record.c +++ b/swad_record.c @@ -590,11 +590,8 @@ void Rec_ReqRemField (void) long Rec_GetFieldCod (void) { - char LongStr[1 + 10 + 1]; - /***** Get the code of the field *****/ - Par_GetParToText ("FieldCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + return Par_GetParToLong ("FieldCod"); } /*****************************************************************************/ @@ -1492,14 +1489,9 @@ static void Rec_PutParamsShowOfficeHoursSeveralTchs (void) static bool Rec_GetParamShowOfficeHours (void) { - char YN[1 + 1]; + if (Par_GetParToBool ("ParamOfficeHours")) + return Par_GetParToBool ("ShowOfficeHours"); - Par_GetParToText ("ParamOfficeHours",YN,1); - if (Str_ConvertToUpperLetter (YN[0]) == 'Y') - { - Par_GetParToText ("ShowOfficeHours",YN,1); - return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); - } return Rec_SHOW_OFFICE_HOURS_DEFAULT; } @@ -3614,7 +3606,6 @@ void Rec_GetUsrNameFromRecordForm (struct UsrData *UsrDat) static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat) { char UnsignedStr[10 + 1]; - char LongStr[1 + 10 + 1]; unsigned UnsignedNum; /***** Get sex from form *****/ @@ -3625,8 +3616,7 @@ static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat) UsrDat->Sex = (Usr_Sex_t) UnsignedNum; /***** Get country code *****/ - Par_GetParToText ("OthCtyCod",LongStr,1 + 10); - UsrDat->CtyCod = Str_ConvertStrCodToLongCod (LongStr); + UsrDat->CtyCod = Par_GetParToLong ("OthCtyCod"); Par_GetParToText ("OriginPlace",UsrDat->OriginPlace,Cns_MAX_BYTES_STRING); Str_ConvertToTitleType (UsrDat->OriginPlace); diff --git a/swad_social.c b/swad_social.c index ac37af1a..9ab45759 100644 --- a/swad_social.c +++ b/swad_social.c @@ -2790,15 +2790,8 @@ void Soc_PutHiddenParamPubCod (long PubCod) static long Soc_GetParamNotCod (void) { - char LongStr[1 + 10 + 1]; // String that holds the social note code - long NotCod; - - /* Get social note code */ - Par_GetParToText ("NotCod",LongStr,1 + 10); - if (sscanf (LongStr,"%ld",&NotCod) != 1) - return -1L; - - return NotCod; + /***** Get social note code *****/ + return Par_GetParToLong ("NotCod"); } /*****************************************************************************/ @@ -2807,15 +2800,8 @@ static long Soc_GetParamNotCod (void) static long Soc_GetParamPubCod (void) { - char LongStr[1 + 10 + 1]; // String that holds the code - long PubCod; - - /* Get social comment code */ - Par_GetParToText ("PubCod",LongStr,1 + 10); - if (sscanf (LongStr,"%ld",&PubCod) != 1) - return -1L; - - return PubCod; + /***** Get social comment code *****/ + return Par_GetParToLong ("PubCod"); } /*****************************************************************************/ diff --git a/swad_survey.c b/swad_survey.c index aa323bf2..c4b6e27f 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -1508,11 +1508,8 @@ static void Svy_PutParamSvyCod (long SvyCod) static long Svy_GetParamSvyCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of survey *****/ - Par_GetParToText ("SvyCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of survey *****/ + return Par_GetParToLong ("SvyCod"); } /*****************************************************************************/ @@ -2834,11 +2831,8 @@ static void Svy_PutParamQstCod (long QstCod) static long Svy_GetParamQstCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of survey *****/ - Par_GetParToText ("QstCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of question *****/ + return Par_GetParToLong ("QstCod"); } /*****************************************************************************/ diff --git a/swad_test.c b/swad_test.c index 761d61cc..6a4709c6 100644 --- a/swad_test.c +++ b/swad_test.c @@ -497,7 +497,6 @@ void Tst_AssessTest (void) extern const char *Txt_The_test_X_has_already_been_assessed_previously; extern const char *Txt_There_was_an_error_in_assessing_the_test_X; unsigned NumTst; - char YN[1 + 1]; long TstCod = -1L; // Initialized to avoid warning unsigned NumQstsNotBlank; double TotalScore; @@ -517,8 +516,7 @@ void Tst_AssessTest (void) Tst_GetParamNumQst (); /***** Get if test must be saved *****/ - Par_GetParToText ("Save",YN,1); - Gbl.Test.AllowTeachers = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.Test.AllowTeachers = Par_GetParToBool ("Save"); /***** Get questions and answers from form to assess a test *****/ Tst_GetQuestionsAndAnswersFromForm (); @@ -581,7 +579,6 @@ static void Tst_GetQuestionsAndAnswersFromForm (void) { unsigned NumQst; char StrQstIndOrAns[3 + 10 + 1]; // "Qstxx...x", "Indxx...x" or "Ansxx...x" - char LongStr[1 + 10 + 1]; /***** Get questions and answers *****/ for (NumQst = 0; @@ -590,8 +587,7 @@ static void Tst_GetQuestionsAndAnswersFromForm (void) { /* Get question code */ sprintf (StrQstIndOrAns,"Qst%06u",NumQst); - Par_GetParToText (StrQstIndOrAns,LongStr,1 + 10); - if ((Gbl.Test.QstCodes[NumQst] = Str_ConvertStrCodToLongCod (LongStr)) < 0) + if ((Gbl.Test.QstCodes[NumQst] = Par_GetParToLong (StrQstIndOrAns)) <= 0) Lay_ShowErrorAndExit ("Code of question is missing."); /* Get indexes for this question */ @@ -1418,11 +1414,10 @@ void Tst_DisableTag (void) static long Tst_GetParamTagCode (void) { - char StrLong[1 + 10 + 1]; long TagCod; - Par_GetParToText ("TagCod",StrLong,1 + 10); - if ((TagCod = Str_ConvertStrCodToLongCod (StrLong)) < 0) + /***** Get tag code *****/ + if ((TagCod = Par_GetParToLong ("TagCod")) <= 0) Lay_ShowErrorAndExit ("Code of tag is missing."); return TagCod; @@ -4274,15 +4269,13 @@ static bool Tst_GetParamsTst (void) extern const char *Txt_You_must_select_one_ore_more_tags; extern const char *Txt_You_must_select_one_ore_more_types_of_answer; extern const char *Txt_The_number_of_questions_must_be_in_the_interval_X; - char YN[1 + 1]; bool Error = false; char UnsignedStr[10 + 1]; unsigned UnsignedNum; /***** Tags *****/ /* Get parameter that indicates whether all tags are selected */ - Par_GetParToText ("AllTags",YN,1); - Gbl.Test.Tags.All = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.Test.Tags.All = Par_GetParToBool ("AllTags"); /* Get the tags */ if ((Gbl.Test.Tags.List = malloc (Tst_MAX_BYTES_TAGS_LIST + 1)) == NULL) @@ -4298,8 +4291,7 @@ static bool Tst_GetParamsTst (void) /***** Types of answer *****/ /* Get parameter that indicates if all types of answer are selected */ - Par_GetParToText ("AllAnsTypes",YN,1); - Gbl.Test.AllAnsTypes = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.Test.AllAnsTypes = Par_GetParToBool ("AllAnsTypes"); /* Get types of answer */ Par_GetParMultiToText ("AnswerType",Gbl.Test.ListAnsTypes,Tst_MAX_BYTES_LIST_ANSWER_TYPES); @@ -4394,10 +4386,7 @@ static void Tst_GetParamNumQst (void) static bool Tst_GetCreateXMLFromForm (void) { - char YN[1 + 1]; - - Par_GetParToText ("CreateXML",YN,1); - return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + return Par_GetParToBool ("CreateXML"); } /*****************************************************************************/ @@ -5322,7 +5311,6 @@ void Tst_ReceiveQst (void) static void Tst_GetQstFromForm (char *Stem,char *Feedback) { char UnsignedStr[10 + 1]; - char YN[1 + 1]; unsigned NumTag; unsigned NumTagRead; unsigned NumOpt; @@ -5397,14 +5385,12 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback) Par_GetParToText ("AnsFloatMax",Gbl.Test.Answer.Options[1].Text,Tst_MAX_BYTES_FLOAT_ANSWER); break; case Tst_ANS_TRUE_FALSE: - Par_GetParToText ("AnsTF",YN,1); - Gbl.Test.Answer.TF = YN[0]; + Gbl.Test.Answer.TF = Par_GetParToBool ("AnsTF"); break; case Tst_ANS_UNIQUE_CHOICE: case Tst_ANS_MULTIPLE_CHOICE: /* Get shuffle */ - Par_GetParToText ("Shuffle",YN,1); - Gbl.Test.Shuffle = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.Test.Shuffle = Par_GetParToBool ("Shuffle"); // No break case Tst_ANS_TEXT: /* Get the texts of the answers */ @@ -5880,7 +5866,6 @@ void Tst_RequestRemoveQst (void) { extern const char *Txt_Do_you_really_want_to_remove_the_question_X; extern const char *Txt_Remove_question; - char YN[1 + 1]; bool EditingOnlyThisQst; /***** Get main parameters from form *****/ @@ -5891,8 +5876,7 @@ void Tst_RequestRemoveQst (void) /* Get a parameter that indicates whether it's necessary to continue listing the rest of questions */ - Par_GetParToText ("OnlyThisQst",YN,1); - EditingOnlyThisQst = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + EditingOnlyThisQst = Par_GetParToBool ("OnlyThisQst"); /***** Start form *****/ Act_FormStart (ActRemTstQst); @@ -5934,7 +5918,6 @@ void Tst_RemoveQst (void) { extern const char *Txt_Question_removed; char Query[512]; - char YN[1 + 1]; bool EditingOnlyThisQst; /***** Get the question code *****/ @@ -5944,8 +5927,7 @@ void Tst_RemoveQst (void) /***** Get a parameter that indicates whether it's necessary to continue listing the rest of questions ******/ - Par_GetParToText ("OnlyThisQst",YN,1); - EditingOnlyThisQst = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + EditingOnlyThisQst = Par_GetParToBool ("OnlyThisQst"); /***** Remove images associated to question *****/ Tst_RemoveAllImgFilesFromAnsOfQst (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod); @@ -5983,7 +5965,6 @@ void Tst_ChangeShuffleQst (void) extern const char *Txt_The_answers_of_the_question_with_code_X_will_appear_shuffled; extern const char *Txt_The_answers_of_the_question_with_code_X_will_appear_without_shuffling; char Query[512]; - char YN[1 + 1]; bool EditingOnlyThisQst; bool Shuffle; @@ -5993,12 +5974,10 @@ void Tst_ChangeShuffleQst (void) Lay_ShowErrorAndExit ("Wrong code of question."); /***** Get a parameter that indicates whether it's necessary to continue listing the rest of questions ******/ - Par_GetParToText ("OnlyThisQst",YN,1); - EditingOnlyThisQst = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + EditingOnlyThisQst = Par_GetParToBool ("OnlyThisQst"); /***** Get a parameter that indicates whether it's possible to shuffle the answers of this question ******/ - Par_GetParToText ("Shuffle",YN,1); - Shuffle = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Shuffle = Par_GetParToBool ("Shuffle"); /***** Remove the question from all the tables *****/ /* Update the question changing the current shuffle */ @@ -6029,10 +6008,8 @@ void Tst_ChangeShuffleQst (void) static long Tst_GetQstCod (void) { - char LongStr[1 + 10 + 1]; - - Par_GetParToText ("QstCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of test question *****/ + return Par_GetParToLong ("QstCod"); } /*****************************************************************************/ @@ -7573,11 +7550,8 @@ static void Tst_PutParamTstCod (long TstCod) static long Tst_GetParamTstCod (void) { - char LongStr[1 + 10 + 1]; - - /***** Get parameter with code of test *****/ - Par_GetParToText ("TstCod",LongStr,1 + 10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get code of test *****/ + return Par_GetParToLong ("TstCod"); } /*****************************************************************************/ diff --git a/swad_user.c b/swad_user.c index 689ad257..33c9f705 100644 --- a/swad_user.c +++ b/swad_user.c @@ -5060,16 +5060,13 @@ void Usr_FreeUsrsList (Rol_Role_t Role) bool Usr_GetIfShowBigList (unsigned NumUsrs,const char *OnSubmit) { bool ShowBigList; - char YN[1 + 1]; /***** If list of users is too big... *****/ if (NumUsrs > Cfg_MIN_NUM_USERS_TO_CONFIRM_SHOW_BIG_LIST) { /***** Get parameter with user's confirmation to see a big list of users *****/ - Par_GetParToText ("ShowBigList",YN,1); - ShowBigList = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); - if (!ShowBigList) + if (!(ShowBigList = Par_GetParToBool ("ShowBigList"))) Usr_PutButtonToConfirmIWantToSeeBigList (NumUsrs,OnSubmit); return ShowBigList; @@ -6986,19 +6983,15 @@ void Usr_PutParamListWithPhotos (void) static bool Usr_GetParamListWithPhotosFromForm (void) { - char YN[1 + 1]; - /***** Get if exists parameter with preference about photos in users' list *****/ - Par_GetParToText ("WithPhotosExists",YN,1); - if (Str_ConvertToUpperLetter (YN[0]) != 'Y') + if (Par_GetParToBool ("WithPhotosExists")) { Gbl.Usrs.Listing.WithPhotos = Usr_LIST_WITH_PHOTOS_DEF; return false; } /***** Parameter with preference about photos in users' list exists, so get it *****/ - Par_GetParToText ("WithPhotos",YN,1); - Gbl.Usrs.Listing.WithPhotos = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + Gbl.Usrs.Listing.WithPhotos = Par_GetParToBool ("WithPhotos"); return true; } diff --git a/swad_zip.c b/swad_zip.c index 9f1dc16c..6ff705a1 100644 --- a/swad_zip.c +++ b/swad_zip.c @@ -140,10 +140,7 @@ static void ZIP_PutLinkToCreateZIPAsgWrkParams (void) bool ZIP_GetCreateZIPFromForm (void) { - char YN[1 + 1]; - - Par_GetParToText ("CreateZIP",YN,1); - return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + return Par_GetParToBool ("CreateZIP"); } /*****************************************************************************/