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.
|
2020-01-01 14:53:57 +01:00
|
|
|
|
Copyright (C) 1999-2020 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 ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-04 21:57:25 +02:00
|
|
|
|
#define Par_MAX_BYTES_BOUNDARY_WITHOUT_CR_LF (128 - 1)
|
|
|
|
|
#define Par_MAX_BYTES_BOUNDARY_WITH_CR_LF (2 + Par_MAX_BYTES_BOUNDARY_WITHOUT_CR_LF)
|
2016-03-31 10:11:36 +02:00
|
|
|
|
|
2016-03-30 14:25:04 +02:00
|
|
|
|
struct StartLength
|
|
|
|
|
{
|
|
|
|
|
unsigned long Start;
|
|
|
|
|
size_t Length;
|
|
|
|
|
};
|
|
|
|
|
struct Param
|
|
|
|
|
{
|
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
|
2016-03-30 14:25:04 +02:00
|
|
|
|
struct Param *Next;
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-07 21:44:24 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Par_PARAM_SINGLE,
|
|
|
|
|
Par_PARAM_MULTIPLE,
|
|
|
|
|
} tParamType; // Parameter is present only one time / multiple times
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public prototypes *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
bool Par_GetQueryString (void);
|
2016-03-31 15:03:00 +02:00
|
|
|
|
void Par_CreateListOfParams (void);
|
2016-03-30 16:33:08 +02:00
|
|
|
|
void Par_FreeParams (void);
|
2016-03-30 17:37:56 +02:00
|
|
|
|
unsigned Par_GetParameter (tParamType ParamType,const char *ParamName,
|
2016-03-31 20:09:47 +02:00
|
|
|
|
char *ParamValue,size_t MaxBytes,
|
2016-04-01 01:59:27 +02:00
|
|
|
|
struct Param **ParamPtr);
|
2016-03-30 17:37:56 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Par_GetMainParameters (void);
|
|
|
|
|
|
|
|
|
|
unsigned Par_GetParToText (const char *ParamName,char *ParamValue,size_t MaxBytes);
|
2017-01-29 21:41:08 +01:00
|
|
|
|
unsigned long Par_GetParToUnsignedLong (const char *ParamName,
|
|
|
|
|
unsigned long Min,
|
|
|
|
|
unsigned long Max,
|
|
|
|
|
unsigned long Default);
|
2017-01-28 20:32:50 +01:00
|
|
|
|
long Par_GetParToLong (const char *ParamName);
|
|
|
|
|
bool Par_GetParToBool (const char *ParamName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
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,
|
|
|
|
|
Str_ChangeTo_t ChangeTo,bool RemoveLeadingAndTrailingSpaces);
|
|
|
|
|
|
|
|
|
|
bool Par_GetNextStrUntilSeparParamMult (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
|
|
|
|
|
2019-11-03 13:19:32 +01:00
|
|
|
|
void Par_PutHiddenParamUnsigned (const char *Id,const char *ParamName,unsigned Value);
|
|
|
|
|
void Par_PutHiddenParamUnsignedDisabled (const char *Id,const char *ParamName,unsigned Value);
|
|
|
|
|
void Par_PutHiddenParamLong (const char *Id,const char *ParamName,long Value);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Par_PutHiddenParamChar (const char *ParamName,char Value);
|
2020-03-26 21:39:44 +01:00
|
|
|
|
void Par_PutHiddenParamString (const char *Id,const char *ParamName,
|
|
|
|
|
const char *Value);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
#endif
|