#include <stdio.h>
#include <string.h>
#include "../../basext.h"
#include "cgi.h"
Go to the source code of this file.
Data Structures | |
struct | _ModuleObject |
Defines | |
#define | ENVIRFUNC(XXX) |
Typedefs | |
typedef _ModuleObject | ModuleObject |
typedef _ModuleObject * | pModuleObject |
Functions | |
static void | DBGPR (char *s,...) |
besVERSION_NEGOTIATE | return (int) |
if (besMODULEPOINTER==NULL) | |
if (p->Cgi.lBufferIncrease=lOptionValue=besOPTION("cgi$bufferincrease")) | |
if (p->symboltable!=NULL) | |
besEND | besFUNCTION (getget) |
besCONVERT2ZCHAR (Argument, pszArgument) | |
besFREE (pszArgument) | |
if (pszResult) | |
besDEREFERENCE (Argument) | |
if (Argument==NULL) | |
besLEFTVALUE (SymVAR, pSymVAR) | |
if (pSymVAR) | |
besDEREFERENCE (FileName) | |
if (fi==NULL) | |
besCONVERT2ZCHAR (FileName, pszFileName) | |
DBGPR ("file %s handle is %p\n", pszFileName, fp) | |
besFREE (pszFileName) | |
if (fp==NULL) | |
while ((ch=fgetc(fi))!=EOF) | |
if (besRETURNVALUE==NULL) | |
if (besARGNR >=1) | |
if (p->symboltable==NULL) | |
besFREE (pszName) | |
static besEND void | freesymbol_callback (char *SymbolName, char *SymbolValue, void *p) |
besFUNCTION (resetsymt) | |
besEND | besFUNCTION (defsfile) |
besFREE (pszFile) | |
for (i=0;i< lFileLength &&(ch=besFGETC(fp))!=EOF;i++) | |
besFCLOSE (fp) | |
besEND | besFUNCTION (getfile) |
for (i=0;pszValue[i];i++) | |
besALLOC_RETURN_STRING (cTotalChars) | |
for (j=i=0;pszValue[i];i++) | |
Variables | |
return Unknown CGI module | error |
besEND besSUB_START pModuleObject | p |
long | lOptionValue |
long | lErrorCode |
char * | s |
besMODULEPOINTER = besALLOC(sizeof(ModuleObject)) | |
return | |
Argument = besCONVERT2STRING(Argument) | |
pszResult = cgi_GetParam(&(p->Cgi),pszArgument) | |
VARIABLE | Argument |
char * | pszArgument |
char * | pszResult |
long | slen |
p = (pModuleObject)besMODULEPOINTER | |
Argument = besARGUMENT(1) | |
Argument = besCONVERT2STRING(Argument) | |
pszResult = cgi_PostParam(&(p->Cgi),pszArgument) | |
VARIABLE | Argument |
VARIABLE * | pSymVAR |
VARIABLE | SymVAR |
pSymbolList | pSYM |
char * | pszArgument |
char * | pszResult |
long | slen |
unsigned long | __refcount_ |
p = (pModuleObject)besMODULEPOINTER | |
Argument = besARGUMENT(1) | |
SymVAR = besARGUMENT(2) | |
pszResult = cgi_GetParamEx(&(p->Cgi),pszArgument,&pSYM) | |
VARIABLE | Argument |
VARIABLE * | pSymVAR |
VARIABLE | SymVAR |
pSymbolList | pSYM |
char * | pszArgument |
char * | pszResult |
long | slen |
unsigned long | __refcount_ |
p = (pModuleObject)besMODULEPOINTER | |
Argument = besARGUMENT(1) | |
SymVAR = besARGUMENT(2) | |
pszResult = cgi_PostParamEx(&(p->Cgi),pszArgument,&pSYM) | |
VARIABLE | Argument |
VARIABLE | FileName |
char * | pszArgument |
char * | pszFileName |
FILE * | fp |
FILE * | fi |
int | ch |
p = (pModuleObject)besMODULEPOINTER | |
Argument = besARGUMENT(1) | |
FileName = besARGUMENT(2) | |
Argument = besCONVERT2STRING(Argument) | |
FileName = besCONVERT2STRING(FileName) | |
fi = cgi_FILEp(&(p->Cgi),pszArgument) | |
fp = besHOOK_FOPEN(pszFileName,"wb") | |
Argument = besCONVERT2STRING(Argument) | |
pszResult = cgi_OriginalFileName(&(p->Cgi),pszArgument) | |
VARIABLE | Argument |
char * | pszArgument |
long | lResult |
p = (pModuleObject)besMODULEPOINTER | |
Argument = besARGUMENT(1) | |
Argument = besCONVERT2STRING(Argument) | |
lResult = cgi_FileLength(&(p->Cgi),pszArgument) | |
besRETURNVALUE = besNEWMORTALLONG | |
long | slen |
pModuleObject | p |
p = (pModuleObject)besMODULEPOINTER | |
pszResult = cgi_Cookie( &(p->Cgi) ) | |
VARIABLE | Argument |
char * | pszName |
char * | pszValue = (char)0 |
void ** | q |
p = (pModuleObject)besMODULEPOINTER | |
pszName = pszValue = NULL | |
q = besLOOKUPSYMBOL(pszName,p->symboltable,1) | |
if q besFREE * | q |
* | q = pszValue |
fp = besFOPEN(pszFile,"rb") | |
lFileLength = besSIZE(pszFile) | |
pszValue = besALLOC(lFileLength+1) | |
q = besLOOKUPSYMBOL(pszName,p->symboltable,1) | |
if q besFREE * | q |
* | q = pszValue |
else return | COMMAND_ERROR_FILE_CANNOT_BE_OPENED |
cInsertedChars = 0 | |
cTotalChars = i - cRemovedChars + cInsertedChars | |
pszResult = STRINGVALUE(besRETURNVALUE ) | |
return | |
besEND SLFST | CGI_SLFST [] |
|
Value: besFUNCTION(XXX)\ char *pszResult;\ long slen;\ pModuleObject p;\ p = (pModuleObject)besMODULEPOINTER;\ pszResult = cgi_##XXX( &(p->Cgi) );\ if( pszResult ){\ slen = strlen(pszResult);\ besALLOC_RETURN_STRING(slen);\ memcpy(STRINGVALUE(besRETURNVALUE),pszResult,slen);\ return COMMAND_ERROR_SUCCESS;\ }else{\ besRETURNVALUE = NULL;\ return COMMAND_ERROR_SUCCESS;\ }\ besEND |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Referenced by besFUNCTION(), and CHECK_OPTION(). |
|
|
|
|
|
|
|
|
|
Definition at line 1321 of file interface.c. |
|
Definition at line 1264 of file interface.c. |
|
Definition at line 1247 of file interface.c. |
|
=section GetParam =H cgi::GetParam("name") This function returns the value of the GET parameter named in the argument. If there are multiple GET parameter with the same name the function returns the first one. The CGI parameter names are case sensitive according to the CGI standard. Definition at line 322 of file interface.c. |
|
Referenced by besFUNCTION(). |
|
|
|
=H Handle CGI input and output =abstract Functions that handle web input data for the standalone module running as CGI or ISAPI or Eszter SB Engine variation. =end The module CGI is implemented as an external module written in the language C. Whenever the programmer wants to write a program using the language ScriptBasic that uses the CGI interface of the web server he or she can use this module. Although this is not a must to use this module for CGI programming it IS a wise choice. The module comes from the developers of the language interpreter. Most of its code is implemented as C code, executing fast and efficient. In its very first version of the module it already supports such advanced features as file upload in a robust and secure way. It handles cookies, POST and GET operations and will support other interfaces in the future like Apache Module interface or FastCGI in a compatible manner. The basic programs using the ISAPI interpreter should use the module the same way as CGI versions. In other words if you write a CGI program it should work executed by the ISAPI version of the interpreter without modification. /** =section ack =H Acknowledgements The core code of the CGI handling routines was not written just looking at the RFC. I have learned a lot from other works. The most important to mention is the CGI.pm Perl module written by Lincoln D. Stein (http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html) Another work was named cgi-lib.c created by eekim@eekim.com. This piece of code gave me the last push to finish looking for readily available free library to interface with ScriptBasic and write instead a new one. The ISAPI interface was developed using the Microsoft Developer Network CD documentation and I really learned a lot while testing the different uses of the function ReadClient until I could figure out that the official Microsoft documentation is wrong. It says: "If more than lpdwSize bytes are immediately available to be read, ReadClient will block until some amount of data has been returned, and will return with less than the requested amount of data." In fact it has to be "If less than lpdwSize bytes are immediately available to be read, ReadClient will block until some amount of data has been returned, and will return with possibly less than the requested amount of data." Definition at line 200 of file interface.c. |
|
Definition at line 1460 of file interface.c. |
|
Definition at line 1367 of file interface.c. |
|
Definition at line 1299 of file interface.c. |
|
Definition at line 1236 of file interface.c. |
|
Definition at line 1224 of file interface.c. |
|
Definition at line 1210 of file interface.c. |
|
Definition at line 664 of file interface.c. |
|
Definition at line 590 of file interface.c. |
|
Definition at line 582 of file interface.c. |
|
Definition at line 434 of file interface.c. |
|
Definition at line 369 of file interface.c. |
|
Definition at line 339 of file interface.c. |
|
Definition at line 306 of file interface.c. |
|
Definition at line 262 of file interface.c. |
|
Definition at line 250 of file interface.c. |
|
=H Error Codes Definition at line 211 of file interface.c. |
|
Definition at line 594 of file interface.c. |
|
Definition at line 488 of file interface.c. |
|
Definition at line 426 of file interface.c. Referenced by execute_LeftValueArray(), and execute_LeftValueSarray(). |
|
Definition at line 1202 of file interface.c. |
|
Definition at line 659 of file interface.c. |
|
Definition at line 653 of file interface.c. |
|
Definition at line 647 of file interface.c. |
|
Definition at line 622 of file interface.c. |
|
Definition at line 576 of file interface.c. |
|
Definition at line 572 of file interface.c. |
|
Definition at line 564 of file interface.c. |
|
Definition at line 492 of file interface.c. |
|
Definition at line 483 of file interface.c. |
|
Definition at line 430 of file interface.c. |
|
Definition at line 421 of file interface.c. |
|
Definition at line 373 of file interface.c. |
|
Definition at line 367 of file interface.c. |
|
Definition at line 361 of file interface.c. |
|
Definition at line 335 of file interface.c. |
|
Definition at line 249 of file interface.c. Referenced by __InsertImage(), __RemoveImage(), besFUNCTION(), F_LibraryLoaded(), and if(). |
|
Definition at line 663 of file interface.c. Referenced by besFUNCTION(), if(), and switch(). |
|
Definition at line 1543 of file interface.c. |
|
Definition at line 568 of file interface.c. |
|
Definition at line 1363 of file interface.c. |
|
Definition at line 1342 of file interface.c. Referenced by besFUNCTION(), CHECK_OPTION(), and if(). |
|
Definition at line 1455 of file interface.c. |
|
Definition at line 241 of file interface.c. Referenced by main(). |
|
Definition at line 580 of file interface.c. |
|
Definition at line 567 of file interface.c. Referenced by build_SaveECode(). |
|
Definition at line 577 of file interface.c. |
|
Definition at line 573 of file interface.c. |
|
Definition at line 564 of file interface.c. |
|
Definition at line 1290 of file interface.c. |
|
Definition at line 587 of file interface.c. |
|
Definition at line 567 of file interface.c. |
|
Definition at line 246 of file interface.c. Referenced by cgi_GetMultipartParameters(). |
|
Definition at line 1296 of file interface.c. |
|
Definition at line 246 of file interface.c. |
|
Definition at line 661 of file interface.c. |
|
Definition at line 650 of file interface.c. |
|
Definition at line 1207 of file interface.c. |
|
Definition at line 936 of file interface.c. |
|
Definition at line 935 of file interface.c. |
|
Definition at line 651 of file interface.c. |
|
Definition at line 570 of file interface.c. |
|
Definition at line 490 of file interface.c. |
|
Definition at line 428 of file interface.c. |
|
Definition at line 365 of file interface.c. |
|
Definition at line 245 of file interface.c. |
|
Definition at line 485 of file interface.c. |
|
Definition at line 423 of file interface.c. |
|
Definition at line 483 of file interface.c. |
|
Definition at line 421 of file interface.c. |
|
Definition at line 649 of file interface.c. |
|
Definition at line 566 of file interface.c. |
|
Definition at line 486 of file interface.c. |
|
Definition at line 424 of file interface.c. |
|
Definition at line 363 of file interface.c. |
|
Definition at line 566 of file interface.c. Referenced by ex_Command_l(), GetSourceLineNumber(), if(), and lex_ReadInput(). |
|
Definition at line 1208 of file interface.c. |
|
Definition at line 1204 of file interface.c. |
|
Definition at line 1457 of file interface.c. |
|
Definition at line 937 of file interface.c. |
|
Definition at line 624 of file interface.c. |
|
Definition at line 514 of file interface.c. |
|
Definition at line 486 of file interface.c. |
|
Definition at line 452 of file interface.c. |
|
Definition at line 424 of file interface.c. |
|
Definition at line 375 of file interface.c. |
|
Definition at line 363 of file interface.c. |
|
Definition at line 337 of file interface.c. |
|
Definition at line 1298 of file interface.c. |
|
Definition at line 1204 of file interface.c. Referenced by cgi_ReadHeader(), and main(). |
|
Definition at line 1313 of file interface.c. |
|
Definition at line 1312 of file interface.c. |
|
Definition at line 1310 of file interface.c. |
|
Definition at line 1232 of file interface.c. |
|
Definition at line 1231 of file interface.c. |
|
Definition at line 1229 of file interface.c. |
|
Definition at line 1205 of file interface.c. |
|
Definition at line 1540 of file interface.c. |
|
Definition at line 310 of file interface.c. |
|
Definition at line 247 of file interface.c. |
|
Definition at line 933 of file interface.c. |
|
Definition at line 487 of file interface.c. |
|
Definition at line 425 of file interface.c. |
|
Definition at line 364 of file interface.c. |
|
Definition at line 493 of file interface.c. |
|
Definition at line 483 of file interface.c. |
|
Definition at line 431 of file interface.c. |
|
Definition at line 421 of file interface.c. |