2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_parameter.h: CGI parameters
|
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_PAR
|
|
|
|
|
#define _SWAD_PAR
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance in Spanish),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2022-09-21 10:46:14 +02:00
|
|
|
|
Copyright (C) 1999-2022 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-10-16 02:24:29 +02:00
|
|
|
|
#include <stdbool.h> // For boolean type
|
|
|
|
|
#include <stddef.h> // For size_t
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-02-18 09:19:33 +01:00
|
|
|
|
#include "swad_string.h"
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Public types and constants ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-03-30 14:25:04 +02:00
|
|
|
|
struct StartLength
|
|
|
|
|
{
|
|
|
|
|
unsigned long Start;
|
|
|
|
|
size_t Length;
|
|
|
|
|
};
|
2022-10-18 20:52:52 +02:00
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
struct Par_Param
|
2016-03-30 14:25:04 +02:00
|
|
|
|
{
|
2016-03-31 02:15:17 +02:00
|
|
|
|
struct StartLength Name; // Parameter name
|
2016-04-01 01:59:27 +02:00
|
|
|
|
struct StartLength FileName; // optional, present only when uploading files
|
|
|
|
|
struct StartLength ContentType; // optional, present only when uploading files
|
2016-03-31 02:15:17 +02:00
|
|
|
|
struct StartLength Value; // Parameter value or file content
|
2023-03-10 00:13:55 +01:00
|
|
|
|
struct Par_Param *Next;
|
2016-03-30 14:25:04 +02:00
|
|
|
|
};
|
|
|
|
|
|
2022-10-18 20:52:52 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Par_METHOD_GET,
|
|
|
|
|
Par_METHOD_POST
|
|
|
|
|
} Par_Method_t;
|
|
|
|
|
|
2015-04-07 21:44:24 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Par_PARAM_SINGLE,
|
|
|
|
|
Par_PARAM_MULTIPLE,
|
2022-10-18 20:52:52 +02:00
|
|
|
|
} Par_ParamType_t; // Parameter is present only one time / multiple times
|
2015-04-07 21:44:24 +02:00
|
|
|
|
|
2023-03-04 22:07:29 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Par_None, // Special code
|
|
|
|
|
Par_AgdCod, // Agenda event code
|
|
|
|
|
Par_AnnCod, // Announcement code
|
|
|
|
|
Par_AsgCod, // Assignment code
|
|
|
|
|
Par_AttCod, // Attendance event code
|
|
|
|
|
Par_BanCod, // Banner code
|
|
|
|
|
Par_BldCod, // Building code
|
|
|
|
|
Par_CrsCod, // Course code
|
|
|
|
|
Par_CtrCod, // Center code
|
|
|
|
|
Par_CtyCod, // Country code
|
|
|
|
|
Par_DegCod, // Degree code
|
|
|
|
|
Par_DptCod, // Department code
|
|
|
|
|
Par_ExaCod, // Exam code in calls-for-exam/exam
|
|
|
|
|
Par_FilCod, // File code
|
|
|
|
|
Par_FldCod, // Field code in course record
|
|
|
|
|
Par_GamCod, // Game code
|
|
|
|
|
Par_GrpCod, // Group code
|
|
|
|
|
Par_GrpTypCod, // Group type code
|
|
|
|
|
Par_HldCod, // Holiday code
|
|
|
|
|
Par_InsCod, // Institution code
|
|
|
|
|
Par_ItmCod, // Item code in course program
|
|
|
|
|
Par_LnkCod, // Link code
|
|
|
|
|
Par_MaiCod, // Domain mail code
|
|
|
|
|
Par_MchCod, // Match code in game
|
|
|
|
|
Par_MsgCod, // Message code
|
|
|
|
|
Par_NotCod, // Note code in timeline
|
|
|
|
|
Par_OrgActCod, // Original action code
|
|
|
|
|
Par_OthCrsCod, // Other course code
|
|
|
|
|
Par_OthCtrCod, // Other center code
|
|
|
|
|
Par_OthCtyCod, // Other country code
|
|
|
|
|
Par_OthDegCod, // Other degree code
|
|
|
|
|
Par_OthDegTypCod, // Other degree type code
|
|
|
|
|
Par_OthHieCod, // Other hierarchy code
|
|
|
|
|
Par_OthInsCod, // Other institution code
|
|
|
|
|
Par_PlcCod, // Place code
|
|
|
|
|
Par_PlgCod, // Plugin code
|
|
|
|
|
Par_PrjCod, // Project code
|
|
|
|
|
Par_PrnCod, // Print code in assessment test
|
|
|
|
|
Par_PstCod, // Post code in forum
|
|
|
|
|
Par_PubCod, // Publication code in timeline
|
|
|
|
|
Par_QstCod, // Question code in assessment/survey
|
|
|
|
|
Par_RooCod, // Room code
|
|
|
|
|
Par_RscCod, // Resource code in course program
|
|
|
|
|
Par_RubCod, // Rubric code
|
|
|
|
|
Par_SesCod, // Session code in exam
|
|
|
|
|
Par_SvyCod, // Syrvey code
|
|
|
|
|
Par_TagCod, // Tag code in assessment question
|
|
|
|
|
Par_ThrCod, // Thread code in forum
|
2023-03-04 22:07:29 +01:00
|
|
|
|
} Par_Code_t;
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public prototypes *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-10-18 08:41:54 +02:00
|
|
|
|
Act_Content_t Par_GetContentReceivedByCGI (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Par_GetQueryString (void);
|
2022-10-18 20:52:52 +02:00
|
|
|
|
Par_Method_t Par_GetMethod (void);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
void Par_CreateListOfPars (void);
|
|
|
|
|
void Par_FreePars (void);
|
|
|
|
|
unsigned Par_GetPar (Par_ParamType_t ParType,const char *ParName,
|
|
|
|
|
char *ParValue,size_t MaxBytes,
|
|
|
|
|
struct Par_Param **ParPtr);
|
2016-03-30 17:37:56 +02:00
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
void Par_GetMainPars (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-03-07 09:55:39 +01:00
|
|
|
|
//------------------------------ Get parameters -------------------------------
|
2023-03-10 00:13:55 +01:00
|
|
|
|
unsigned Par_GetParText (const char *ParName,char *ParValue,size_t MaxBytes);
|
|
|
|
|
unsigned long Par_GetParUnsignedLong (const char *ParName,
|
2023-03-07 09:55:39 +01:00
|
|
|
|
unsigned long Min,
|
|
|
|
|
unsigned long Max,
|
|
|
|
|
unsigned long Default);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
long Par_GetParLong (const char *ParName);
|
2023-03-07 09:55:39 +01:00
|
|
|
|
long Par_GetAndCheckParCode (Par_Code_t ParCod);
|
|
|
|
|
long Par_GetAndCheckParCodeMin (Par_Code_t ParCod,long MinCodAllowed);
|
|
|
|
|
long Par_GetParCode (Par_Code_t ParCod);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
bool Par_GetParBool (const char *ParName);
|
|
|
|
|
unsigned Par_GetParHTML (const char *ParName,char *ParValue,size_t MaxBytes);
|
|
|
|
|
unsigned Par_GetParMultiToText (const char *ParName,char *ParValue,size_t MaxBytes);
|
|
|
|
|
unsigned Par_GetParAndChangeFormat (const char *ParName,char *ParValue,size_t MaxBytes,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Str_ChangeTo_t ChangeTo,bool RemoveLeadingAndTrailingSpaces);
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
bool Par_GetNextStrUntilSeparParMult (const char **StrSrc,char *StrDst,size_t LongMax);
|
2019-09-24 01:41:51 +02:00
|
|
|
|
bool Par_GetNextStrUntilComma (const char **StrSrc,char *StrDst,size_t LongMax);
|
2020-05-12 02:45:03 +02:00
|
|
|
|
void Par_ReplaceSeparatorMultipleByComma (char *Str);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-03-07 09:55:39 +01:00
|
|
|
|
//------------------------------ Put parameters -------------------------------
|
2023-03-10 00:13:55 +01:00
|
|
|
|
void Par_PutParUnsigned (const char *Id,const char *ParName,unsigned Value);
|
|
|
|
|
void Par_PutParUnsignedDisabled (const char *Id,const char *ParName,unsigned Value);
|
2023-03-07 09:55:39 +01:00
|
|
|
|
void Par_PutParCode (Par_Code_t ParCod,long Cod);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
void Par_PutParLong (const char *Id,const char *ParName,long Value);
|
|
|
|
|
void Par_PutParChar (const char *ParName,char Value);
|
|
|
|
|
void Par_PutParString (const char *Id,const char *ParName,const char *Value);
|
2023-03-07 09:55:39 +01:00
|
|
|
|
void Par_PutParOrder (unsigned SelectedOrder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2022-10-27 22:09:44 +02:00
|
|
|
|
//----------------------------- Client IP address -----------------------------
|
|
|
|
|
void Par_SetIP (void);
|
|
|
|
|
const char *Par_GetIP (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#endif
|