Version 20.68: Apr 26, 2021 New module swad_error.

This commit is contained in:
acanas 2021-04-26 15:27:27 +02:00
parent 660147563c
commit 9af6b0d4f9
107 changed files with 2146 additions and 1948 deletions

View File

@ -35,7 +35,7 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \
swad_course_config.o swad_cryptography.o \
swad_database.o swad_date.o swad_degree.o swad_degree_config.o \
swad_degree_type.o swad_department.o swad_duplicate.o \
swad_enrolment.o swad_exam.o swad_exam_log.o \
swad_enrolment.o swad_error.o swad_exam.o swad_exam_log.o \
swad_exam_print.o swad_exam_result.o swad_exam_session.o \
swad_exam_set.o \
swad_figure.o swad_figure_cache.o swad_file.o swad_file_browser.o \

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -105,6 +105,7 @@ cp -f /home/acanas/swad/swad/swad /var/www/cgi-bin/
#include "swad_API.h"
#include "swad_attendance.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_file_browser.h"
#include "swad_forum.h"
#include "swad_global.h"
@ -1653,7 +1654,7 @@ static int API_WritePageIntoHTMLBuffer (struct soap *soap,
/***** Write page from file to text buffer *****/
/* Open file */
if ((FileHTML = fopen (PathRelFileHTML,"rb")) == NULL)
Lay_ShowErrorAndExit ("Can not open XML file.");
Err_ShowErrorAndExit ("Can not open XML file.");
/* Compute file size */
fseek (FileHTML,0L,SEEK_END);
@ -1664,7 +1665,7 @@ static int API_WritePageIntoHTMLBuffer (struct soap *soap,
if ((*HTMLBuffer = malloc (Length + 1)) == NULL)
{
fclose (FileHTML);
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
return soap_receiver_fault (soap,
"Web page can not be copied into buffer",
"Not enough memory for buffer");
@ -2262,7 +2263,7 @@ int swad__sendMyGroups (struct soap *soap,
/***** Create a list of groups selected from myGroups *****/
if ((LstGrpsIWant.GrpCods = calloc (LstGrpsIWant.NumGrps,
sizeof (*LstGrpsIWant.GrpCods))) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
for (NumGrp = 0, Ptr = myGroups;
*Ptr;
NumGrp++)
@ -2836,7 +2837,7 @@ static void API_GetLstGrpsSel (const char *Groups)
// Here NestedCalls is always 1
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
for (Ptr = Groups, NumGrp = 0;
*Ptr;
@ -3636,7 +3637,7 @@ int swad__sendMessage (struct soap *soap,
/***** Allocate space for query *****/
if ((Query = malloc (API_MAX_BYTES_QUERY_RECIPIENTS + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Build query for recipients from database *****/
if (ReplyUsrCod > 0)

View File

@ -30,6 +30,7 @@
#include <stdio.h> // For vasprintf
#include <stdlib.h> // For free
#include "swad_error.h"
#include "swad_global.h"
#include "swad_HTML.h"
@ -128,7 +129,7 @@ void HTM_TABLE_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Class,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<table class=\"%s\">",Class);
@ -252,7 +253,7 @@ void HTM_TBODY_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<tbody %s>",Attr);
@ -294,7 +295,7 @@ void HTM_TR_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<tr %s>",Attr);
@ -391,7 +392,7 @@ static void HTM_TH_BeginAttr (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<th %s>",Attr);
@ -453,7 +454,7 @@ void HTM_TD_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<td %s>",Attr);
@ -528,7 +529,7 @@ void HTM_DIV_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<div %s>",Attr);
@ -619,7 +620,7 @@ void HTM_SPAN_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<span %s>",Attr);
@ -685,7 +686,7 @@ void HTM_UL_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<ul %s>",Attr);
@ -734,7 +735,7 @@ void HTM_LI_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<li %s>",Attr);
@ -838,7 +839,7 @@ void HTM_A_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<a %s>",Attr);
@ -915,7 +916,7 @@ void HTM_PARAM (const char *Name,
NumBytesPrinted = vasprintf (&Value,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("\n<param name=\"%s\" value=\"%s\">",Name,Value);
@ -942,7 +943,7 @@ void HTM_LABEL_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<label %s>",Attr);
@ -996,7 +997,7 @@ void HTM_INPUT_TEXT (const char *Name,unsigned MaxLength,const char *Value,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1030,7 +1031,7 @@ void HTM_INPUT_SEARCH (const char *Name,unsigned MaxLength,const char *Value,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1061,7 +1062,7 @@ void HTM_INPUT_TEL (const char *Name,const char *Value,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1095,7 +1096,7 @@ void HTM_INPUT_EMAIL (const char *Name,unsigned MaxLength,const char *Value,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1126,7 +1127,7 @@ void HTM_INPUT_URL (const char *Name,const char *Value,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1161,7 +1162,7 @@ void HTM_INPUT_FILE (const char *Name,const char *Accept,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1221,7 +1222,7 @@ void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1254,7 +1255,7 @@ void HTM_INPUT_LONG (const char *Name,long Min,long Max,long Value,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1301,7 +1302,7 @@ void HTM_INPUT_FLOAT (const char *Name,double Min,double Max,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1330,7 +1331,7 @@ void HTM_INPUT_RADIO (const char *Name,bool SubmitOnClick,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1362,7 +1363,7 @@ void HTM_INPUT_CHECKBOX (const char *Name,HTM_SubmitOnChange_t SubmitOnChange,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1476,7 +1477,7 @@ void HTM_TEXTAREA_Begin (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<textarea %s>",Attr);
@ -1526,7 +1527,7 @@ void HTM_SELECT_Begin (HTM_SubmitOnChange_t SubmitOnChange,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_TxtF ("<select %s",Attr);
@ -1614,7 +1615,7 @@ void HTM_OPTION (HTM_Type_t Type,const void *ValuePtr,bool Selected,bool Disable
NumBytesPrinted = vasprintf (&Content,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_Txt (Content);
@ -1661,7 +1662,7 @@ void HTM_IMG (const char *URL,const char *Icon,const char *Title,
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print attributes *****/
HTM_SPTxt (Attr);
@ -1762,7 +1763,7 @@ void HTM_TxtF (const char *fmt,...)
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Print HTML *****/
HTM_Txt (Attr);

View File

@ -33,6 +33,7 @@
#include "swad_account.h"
#include "swad_box.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_HTML.h"
@ -151,7 +152,7 @@ void ID_ReallocateListIDs (struct UsrData *UsrDat,unsigned NumIDs)
/***** Allocate space for the list *****/
if ((UsrDat->IDs.List = malloc (NumIDs * sizeof (*UsrDat->IDs.List))) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
}
/*****************************************************************************/
@ -197,7 +198,7 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
/***** Allocate memory for subquery string *****/
MaxLength = 512 + UsrDat->IDs.Num * (1 + ID_MAX_BYTES_USR_ID + 1) - 1;
if ((SubQueryAllUsrs = malloc (MaxLength + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
SubQueryAllUsrs[0] = '\0';
/***** Get user's code(s) from database *****/

View File

@ -33,6 +33,7 @@
#include "swad_box.h"
#include "swad_config.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_HTML.h"
@ -80,7 +81,7 @@ void MFU_AllocateMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned
{
if ((ListMFUActions->Actions = malloc (MaxActionsShown *
sizeof (*ListMFUActions->Actions))) == NULL)
Lay_ShowErrorAndExit ("Can not allocate memory for list of most frequently used actions.");
Err_ShowErrorAndExit ("Can not allocate memory for list of most frequently used actions.");
}
/*****************************************************************************/
@ -357,7 +358,7 @@ void MFU_UpdateMFUActions (void)
{
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%lf",&Score) != 1)
Lay_ShowErrorAndExit ("Error when getting score for current action.");
Err_ShowErrorAndExit ("Error when getting score for current action.");
Score *= MFU_INCREASE_FACTOR;
if (Score > MFU_MAX_SCORE)
Score = MFU_MAX_SCORE;

View File

@ -30,6 +30,7 @@
#include <stdlib.h> // For free
#include "swad_action.h"
#include "swad_error.h"
#include "swad_global.h"
#include "swad_HTML.h"
#include "swad_ID.h"
@ -118,7 +119,7 @@ void QR_ImageQRCode (const char *QRString)
if (asprintf (&URL,"https://chart.googleapis.com/chart?cht=qr&amp;chs=%ux%u&amp;chl=%s",
QR_CODE_SIZE,QR_CODE_SIZE,QRString) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
HTM_IMG (URL,NULL,QRString,
"style=\"width:%upx;height:%upx;border:1px dashed silver;\"",
QR_CODE_SIZE,QR_CODE_SIZE);
@ -141,13 +142,13 @@ void QR_LinkTo (unsigned Size,const char *ParamName,long Cod)
{
if (asprintf (&URL,"https://chart.googleapis.com/chart?cht=qr&amp;chs=%ux%u&amp;chl=%s/?%s=%ld",
Size,Size,Cfg_URL_SWAD_CGI,ParamName,Cod) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
}
else
{
if (asprintf (&URL,"https://chart.googleapis.com/chart?cht=qr&amp;chs=%ux%u&amp;chl=%s/",
Size,Size,Cfg_URL_SWAD_CGI) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
}
HTM_IMG (URL,NULL,Txt_Shortcut,
"style=\"width:%upx;height:%upx;\"",Size,Size);
@ -170,7 +171,7 @@ void QR_ExamAnnnouncement (void)
300,300,
Cfg_URL_SWAD_CGI,Gbl.Hierarchy.Crs.CrsCod,
Act_GetActCod (ActSeeAllExaAnn)) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
HTM_IMG (URL,NULL,Txt_Link_to_call_for_exam,
"style=\"width:250px;height:250px;\"");
free (URL);

View File

@ -32,6 +32,7 @@
#include "swad_call_for_exam.h"
#include "swad_changelog.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_global.h"
#include "swad_notice.h"
#include "swad_RSS.h"
@ -74,7 +75,7 @@ void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs)
snprintf (PathRelPublRSSFile,sizeof (PathRelPublRSSFile),"%s/%s",
PathRelPublRSSDir,Cfg_RSS_FILE);
if ((FileRSS = fopen (PathRelPublRSSFile,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not create RSS file.");
Err_ShowErrorAndExit ("Can not create RSS file.");
/***** Write RSS header *****/
fprintf (FileRSS,"<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n");
@ -186,7 +187,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
/* Get notice code */
if (sscanf (row[0],"%ld",&NotCod) != 1)
Lay_WrongNoticeExit ();
Err_WrongNoticeExit ();
/* Get UTC date-time of publication */
CreatTimeUTC = 0L;
@ -290,7 +291,7 @@ static void RSS_WriteCallsForExams (FILE *FileRSS,struct Crs_Course *Crs)
/* Get call for exam code */
if (sscanf (row[0],"%ld",&ExaCod) != 1)
Lay_WrongCallForExamExit ();
Err_WrongCallForExamExit ();
/* Get UTC date-time of publication */
CallTimeUTC = 0L;

View File

@ -36,6 +36,7 @@
#include "swad_database.h"
#include "swad_duplicate.h"
#include "swad_enrolment.h"
#include "swad_error.h"
#include "swad_exam_print.h"
#include "swad_follow.h"
#include "swad_form.h"
@ -738,7 +739,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
/***** Trivial check: user's code should be <= 0 *****/
if (UsrDat->UsrCod > 0)
Lay_ShowErrorAndExit ("Can not create new user.");
Err_ShowErrorAndExit ("Can not create new user.");
/***** Create encrypted user's code *****/
Acc_CreateNewEncryptedUsrCod (UsrDat);
@ -844,7 +845,7 @@ static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat)
break;
}
if (NumTry == MAX_TRY)
Lay_ShowErrorAndExit ("Can not create a new encrypted user's code.");
Err_ShowErrorAndExit ("Can not create a new encrypted user's code.");
}
/*****************************************************************************/

View File

@ -36,6 +36,7 @@
#include "swad_box.h"
#include "swad_database.h"
#include "swad_date.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_group.h"
@ -821,7 +822,7 @@ static void Agd_ShowOneEvent (struct Agd_Agenda *Agenda,
StartEndTime++)
{
if (asprintf (&Id,"agd_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
HTM_TD_Begin ("id=\"%s\" class=\"%s LB COLOR%u\"",
Id,
AgdEvent.Hidden ? Dat_TimeStatusClassHidden[AgdEvent.TimeStatus] :
@ -1074,7 +1075,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
{
if (asprintf (&UsrSubQuery,"UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
if (AgendaType == Agd_MY_AGENDA_TODAY)
Str_Copy (Past__FutureEventsSubQuery,
" AND DATE(StartTime)<=CURDATE()"
@ -1131,7 +1132,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
case Agd_ANOTHER_AGENDA:
if (asprintf (&UsrSubQuery,"UsrCod=%ld",
Gbl.Usrs.Other.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
if (AgendaType == Agd_ANOTHER_AGENDA_TODAY)
Str_Copy (Past__FutureEventsSubQuery,
" AND DATE(StartTime)<=CURDATE()"
@ -1170,7 +1171,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
/***** Create list of events *****/
if ((Agenda->LstAgdCods = calloc ((size_t) Agenda->Num,
sizeof (*Agenda->LstAgdCods))) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Get the events codes *****/
for (NumEvent = 0;
@ -1178,7 +1179,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
NumEvent++)
/* Get next event code */
if ((Agenda->LstAgdCods[NumEvent] = DB_GetNextCode (mysql_res)) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
}
/***** Free structure that stores the query result *****/
@ -1327,7 +1328,7 @@ void Agd_AskRemEvent (void)
/***** Get event code *****/
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the event from database *****/
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
@ -1363,7 +1364,7 @@ void Agd_RemoveEvent (void)
/***** Get event code *****/
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the event from database *****/
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
@ -1402,7 +1403,7 @@ void Agd_HideEvent (void)
/***** Get event code *****/
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the event from database *****/
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
@ -1438,7 +1439,7 @@ void Agd_UnhideEvent (void)
/***** Get event code *****/
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the event from database *****/
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
@ -1475,7 +1476,7 @@ void Agd_MakeEventPrivate (void)
/***** Get event code *****/
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the event from database *****/
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
@ -1516,7 +1517,7 @@ void Agd_MakeEventPublic (void)
/***** Get event code *****/
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the event from database *****/
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
@ -1932,7 +1933,7 @@ unsigned Agd_GetNumUsrsWithEvents (Hie_Lvl_Level_t Scope)
" AND crs_users.UsrCod=agd_agendas.UsrCod",
Gbl.Hierarchy.Crs.CrsCod);
default:
Lay_WrongScopeExit ();
Err_WrongScopeExit ();
return 0; // Not reached
}
}
@ -2023,7 +2024,7 @@ unsigned Agd_GetNumEvents (Hie_Lvl_Level_t Scope)
" AND crs_users.UsrCod=agd_agendas.UsrCod",
Gbl.Hierarchy.Crs.CrsCod);
default:
Lay_WrongScopeExit ();
Err_WrongScopeExit ();
return 0; // Not reached
}
}

View File

@ -33,6 +33,7 @@
#include <string.h> // For string functions
#include "swad_alert.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_HTML.h"
@ -78,7 +79,7 @@ void Ale_CreateAlert (Ale_AlertType_t Type,const char *Section,
size_t i;
if (Gbl.Alerts.Num + 1 > Ale_MAX_ALERTS)
Lay_ShowErrorAndExit ("Too many alerts.");
Err_ShowErrorAndExit ("Too many alerts.");
i = Gbl.Alerts.Num;
Gbl.Alerts.Num++;
@ -90,13 +91,13 @@ void Ale_CreateAlert (Ale_AlertType_t Type,const char *Section,
if (Section[0])
if (asprintf (&Gbl.Alerts.List[i].Section,"%s",
Section) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
va_start (ap,fmt);
NumBytesPrinted = vasprintf (&Gbl.Alerts.List[i].Text,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
}
/*****************************************************************************/
@ -203,7 +204,7 @@ static void Ale_ResetAlert (size_t i)
void Ale_ShowAlertsAndExit ()
{
Ale_ShowAlerts (NULL);
Lay_ShowErrorAndExit (NULL);
Err_ShowErrorAndExit (NULL);
}
/*****************************************************************************/
@ -254,7 +255,7 @@ void Ale_ShowAlert (Ale_AlertType_t AlertType,const char *fmt,...)
NumBytesPrinted = vasprintf (&Txt,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Show alert *****/
Ale_ShowFixAlert (AlertType,Txt);
@ -328,7 +329,7 @@ void Ale_ShowAlertAndButton (Act_Action_t NextAction,const char *Anchor,const ch
NumBytesPrinted = vasprintf (&Txt,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/****** Print fix alert and button ******/
Ale_ShowFixAlertAndButton1 (AlertType,Txt);
@ -355,7 +356,7 @@ void Ale_ShowAlertAndButton1 (Ale_AlertType_t AlertType,const char *fmt,...)
NumBytesPrinted = vasprintf (&Txt,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // -1 if no memory or any other error
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/****** Print start of fix alert and button ******/
Ale_ShowFixAlertAndButton1 (AlertType,Txt);

View File

@ -28,6 +28,7 @@
#include "swad_announcement.h"
#include "swad_box.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_HTML.h"
@ -155,7 +156,7 @@ void Ann_ShowAllAnnouncements (void)
/* Get announcement code (row[0]) */
if (sscanf (row[0],"%ld",&AnnCod) != 1)
Lay_WrongAnnouncementExit ();
Err_WrongAnnouncementExit ();
/* Get status of the announcement (row[1]) */
Status = Ann_OBSOLETE_ANNOUNCEMENT;
@ -165,7 +166,7 @@ void Ann_ShowAllAnnouncements (void)
/* Get roles (row[2]) */
if (sscanf (row[2],"%u",&Roles) != 1)
Lay_ShowErrorAndExit ("Error when reading roles of announcement.");
Err_ShowErrorAndExit ("Error when reading roles of announcement.");
/* Get the subject (row[3]), the content (row[4]), and insert links */
Str_Copy (Subject,row[3],sizeof (Subject) - 1);
@ -260,7 +261,7 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
/* Get announcement code (row[0]) */
if (sscanf (row[0],"%ld",&AnnCod) != 1)
Lay_WrongAnnouncementExit ();
Err_WrongAnnouncementExit ();
/* Get the subject (row[1]), the content (row[2]), and insert links */
Str_Copy (Subject,row[1],sizeof (Subject) - 1);
@ -395,7 +396,7 @@ static long Ann_GetParamAnnCod (void)
/***** Get announcement code *****/
if ((AnnCod = Par_GetParToLong ("AnnCod")) <= 0)
Lay_WrongAnnouncementExit ();
Err_WrongAnnouncementExit ();
return AnnCod;
}

View File

@ -35,6 +35,7 @@
#include "swad_assignment.h"
#include "swad_box.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_figure.h"
#include "swad_form.h"
#include "swad_global.h"
@ -416,7 +417,7 @@ static void Asg_ShowOneAssignment (struct Asg_Assignments *Assignments,
StartEndTime++)
{
if (asprintf (&Id,"asg_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
if (PrintView)
HTM_TD_Begin ("id=\"%s\" class=\"%s LB\"",
Id,
@ -549,7 +550,7 @@ static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView
Frm_BeginForm (ActFrmCreAsgCrs);
break;
default:
Lay_WrongRoleExit ();
Err_WrongRoleExit ();
break;
}
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS,
@ -734,7 +735,7 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
/***** Create list of assignments *****/
if ((Assignments->LstAsgCods = calloc (NumAsgs,
sizeof (*Assignments->LstAsgCods))) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Get the assignments codes *****/
for (NumAsg = 0;
@ -743,7 +744,7 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
{
/* Get next assignment code */
if ((Assignments->LstAsgCods[NumAsg] = DB_GetNextCode (mysql_res)) <= 0)
Lay_WrongAssignmentExit ();
Err_WrongAssignmentExit ();
}
}
else
@ -985,7 +986,7 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
{
Length = strlen (row[1]);
if ((*ContentStr = malloc (Length + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
Str_Copy (*ContentStr,row[1],Length);
}
}
@ -1034,7 +1035,7 @@ void Asg_ReqRemAssignment (void)
/***** Get assignment code *****/
if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0)
Lay_WrongAssignmentExit ();
Err_WrongAssignmentExit ();
/***** Get data of the assignment from database *****/
Asg_GetDataOfAssignmentByCod (&Asg);
@ -1071,7 +1072,7 @@ void Asg_RemoveAssignment (void)
/***** Get assignment code *****/
if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0)
Lay_WrongAssignmentExit ();
Err_WrongAssignmentExit ();
/***** Get data of the assignment from database *****/
Asg_GetDataOfAssignmentByCod (&Asg); // Inside this function, the course is checked to be the current one
@ -1121,7 +1122,7 @@ void Asg_HideAssignment (void)
/***** Get assignment code *****/
if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0)
Lay_WrongAssignmentExit ();
Err_WrongAssignmentExit ();
/***** Get data of the assignment from database *****/
Asg_GetDataOfAssignmentByCod (&Asg);
@ -1158,7 +1159,7 @@ void Asg_ShowAssignment (void)
/***** Get assignment code *****/
if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0)
Lay_WrongAssignmentExit ();
Err_WrongAssignmentExit ();
/***** Get data of the assignment from database *****/
Asg_GetDataOfAssignmentByCod (&Asg);
@ -1926,7 +1927,7 @@ unsigned Asg_GetNumCoursesWithAssignments (Hie_Lvl_Level_t Scope)
" WHERE CrsCod=%ld",
Gbl.Hierarchy.Crs.CrsCod);
default:
Lay_WrongScopeExit ();
Err_WrongScopeExit ();
return 0;
}
}
@ -2014,20 +2015,20 @@ unsigned Asg_GetNumAssignments (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
Gbl.Hierarchy.Crs.CrsCod);
break;
default:
Lay_WrongScopeExit ();
Err_WrongScopeExit ();
break;
}
/***** Get number of assignments *****/
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%u",&NumAssignments) != 1)
Lay_ShowErrorAndExit ("Error when getting number of assignments.");
Err_ShowErrorAndExit ("Error when getting number of assignments.");
/***** Get number of notifications by email *****/
if (row[1])
{
if (sscanf (row[1],"%u",NumNotif) != 1)
Lay_ShowErrorAndExit ("Error when getting number of notifications of assignments.");
Err_ShowErrorAndExit ("Error when getting number of notifications of assignments.");
}
else
*NumNotif = 0;

View File

@ -36,6 +36,7 @@
#include "swad_attendance.h"
#include "swad_box.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_group.h"
@ -486,7 +487,7 @@ static void Att_ShowOneAttEvent (struct Att_Events *Events,
StartEndTime++)
{
if (asprintf (&Id,"att_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
if (ShowOnlyThisAttEventComplete)
HTM_TD_Begin ("id=\"%s\" class=\"%s LB\"",
Id,
@ -711,7 +712,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
{
/***** Create list of attendance events *****/
if ((Events->Lst = calloc (Events->Num,sizeof (*Events->Lst))) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Get the attendance events codes *****/
for (NumAttEvent = 0;
@ -720,7 +721,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
{
/* Get next attendance event code */
if ((Events->Lst[NumAttEvent].AttCod = DB_GetNextCode (mysql_res)) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
}
}
@ -739,10 +740,10 @@ static void Att_GetDataOfAttEventByCodAndCheckCrs (struct Att_Event *Event)
if (Att_GetDataOfAttEventByCod (Event))
{
if (Event->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
Lay_WrongEventExit ();
Err_WrongEventExit ();
}
else // Attendance event not found
Lay_WrongEventExit ();
Err_WrongEventExit ();
}
/*****************************************************************************/
@ -920,7 +921,7 @@ void Att_AskRemAttEvent (void)
/***** Get attendance event code *****/
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the attendance event from database *****/
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
@ -955,7 +956,7 @@ void Att_GetAndRemAttEvent (void)
/***** Get attendance event code *****/
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the attendance event from database *****/
// Inside this function, the course is checked to be the current one
@ -998,7 +999,7 @@ void Att_HideAttEvent (void)
/***** Get attendance event code *****/
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the attendance event from database *****/
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
@ -1026,7 +1027,7 @@ void Att_ShowAttEvent (void)
/***** Get attendance event code *****/
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Get data of the attendance event from database *****/
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
@ -1753,7 +1754,7 @@ unsigned Att_GetNumCoursesWithAttEvents (Hie_Lvl_Level_t Scope)
" WHERE CrsCod=%ld",
Gbl.Hierarchy.Crs.CrsCod);
default:
Lay_WrongScopeExit ();
Err_WrongScopeExit ();
return 0; // Not reached
}
}
@ -1825,20 +1826,20 @@ unsigned Att_GetNumAttEvents (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
Gbl.Hierarchy.Crs.CrsCod);
break;
default:
Lay_WrongScopeExit ();
Err_WrongScopeExit ();
break;
}
/***** Get number of attendance events *****/
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%u",&NumAttEvents) != 1)
Lay_ShowErrorAndExit ("Error when getting number of attendance events.");
Err_ShowErrorAndExit ("Error when getting number of attendance events.");
/***** Get number of notifications by email *****/
if (row[1])
{
if (sscanf (row[1],"%u",NumNotif) != 1)
Lay_ShowErrorAndExit ("Error when getting number of notifications of attendance events.");
Err_ShowErrorAndExit ("Error when getting number of notifications of attendance events.");
}
else
*NumNotif = 0;
@ -1862,7 +1863,7 @@ void Att_SeeOneAttEvent (void)
/***** Get attendance event code *****/
if ((Events.AttCod = Att_GetParamAttCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
/***** Show event *****/
Att_ShowEvent (&Events);
@ -2097,7 +2098,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
// A student can see only her/his attendance
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
if (!ItsMe)
Lay_ShowErrorAndExit ("Wrong call.");
Err_ShowErrorAndExit ("Wrong call.");
ICanChangeStdAttendance = false;
ICanEditStdComment = Event->Open; // Attendance event is open
ICanEditTchComment = false;
@ -2260,7 +2261,7 @@ static void Att_PutParamsCodGrps (long AttCod)
{
MaxLengthGrpCods = NumGrps * (1 + 20) - 1;
if ((GrpCods = malloc (MaxLengthGrpCods + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
GrpCods[0] = '\0';
/* Get groups */
@ -2307,7 +2308,7 @@ void Att_RegisterMeAsStdInAttEvent (void)
/***** Get attendance event code *****/
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
Att_GetDataOfAttEventByCodAndCheckCrs (&Event); // This checks that event belong to current course
if (Event.Open)
@ -2372,7 +2373,7 @@ void Att_RegisterStudentsInAttEvent (void)
/***** Get attendance event code *****/
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
Lay_WrongEventExit ();
Err_WrongEventExit ();
Att_GetDataOfAttEventByCodAndCheckCrs (&Event); // This checks that event belong to current course
/***** Get groups selected *****/
@ -2739,7 +2740,7 @@ static void Att_ReqListOrPrintUsrsAttendanceCrs (void *TypeOfView)
Att_FreeListAttEvents (&Events);
break;
default:
Lay_WrongTypeOfViewExit ();
Err_WrongTypeOfViewExit ();
break;
}
}
@ -2807,7 +2808,7 @@ static void Att_ListOrPrintMyAttendanceCrs (Att_TypeOfView_t TypeOfView)
NULL,Box_NOT_CLOSABLE);
break;
default:
Lay_WrongTypeOfViewExit ();
Err_WrongTypeOfViewExit ();
break;
}
@ -2837,7 +2838,7 @@ static void Att_ListOrPrintMyAttendanceCrs (Att_TypeOfView_t TypeOfView)
Att_FreeListAttEvents (&Events);
break;
default:
Lay_WrongTypeOfViewExit ();
Err_WrongTypeOfViewExit ();
break;
}
}
@ -2923,7 +2924,7 @@ static void Att_ListOrPrintUsrsAttendanceCrs (void *TypeOfView)
NULL,Box_NOT_CLOSABLE);
break;
default:
Lay_WrongTypeOfViewExit ();
Err_WrongTypeOfViewExit ();
}
/***** List events to select *****/
@ -2957,7 +2958,7 @@ static void Att_ListOrPrintUsrsAttendanceCrs (void *TypeOfView)
Grp_FreeListCodSelectedGrps ();
break;
default:
Lay_WrongTypeOfViewExit ();
Err_WrongTypeOfViewExit ();
break;
}
}
@ -2982,7 +2983,7 @@ static void Att_GetListSelectedAttCods (struct Att_Events *Events)
/***** Allocate memory for list of attendance events selected *****/
MaxSizeListAttCodsSelected = (size_t) Events->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
if ((Events->StrAttCodsSelected = malloc (MaxSizeListAttCodsSelected + 1)) == NULL)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
/***** Get parameter multiple with list of attendance events selected *****/
Par_GetParMultiToText ("AttCods",Events->StrAttCodsSelected,MaxSizeListAttCodsSelected);
@ -3241,7 +3242,7 @@ static void Att_ListEventsToSelect (const struct Att_Events *Events,
HTM_TD_End ();
if (asprintf (&Id,"att_date_start_%u",UniqueId) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd);
HTM_LABEL_Begin ("for=\"Event%u\"",NumAttEvent);
HTM_SPAN_Begin ("id=\"%s\"",Id);
@ -3684,7 +3685,7 @@ static void Att_ListAttEventsForAStd (const struct Att_Events *Events,
HTM_TD_End ();
if (asprintf (&Id,"att_date_start_%u_%u",NumUsr,UniqueId) < 0)
Lay_NotEnoughMemoryExit ();
Err_NotEnoughMemoryExit ();
HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd);
HTM_SPAN_Begin ("id=\"%s\"",Id);
HTM_SPAN_End ();

View File

@ -33,6 +33,7 @@
#include "swad_box.h"
#include "swad_constant.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_HTML.h"
@ -311,7 +312,7 @@ static void Ban_GetListBanners (struct Ban_Banners *Banners,
/***** Create list with banners *****/