G:/ScriptBasic/source/extensions/cgi/cgi.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <ctype.h>
#include <fcntl.h>
#include <string.h>
#include "cgi.h"

Go to the source code of this file.

Defines

#define _getenv(X)   (pCO->pfEnv ? pCO->pfEnv(pCO->pEmbed,(X),0) : getenv(X))
#define CR   '\r'
#define LF   '\n'
#define BUFFER_INCREASE   1024
#define BUFFER_MAX   10240
#define CONTENT_MAX   0xA00000
#define FILE_MAX   0xA00000
#define ISAPI_BUFFER   0xA000
#define DEBUGFP   (pCO->pDebugInfo->fpDebugInput)
#define GETCHAR()   (pCO->CharacterInput(pCO))
#define ALLOC(x)   (pCO->maf((x),pCO->pSegment))
#define FREE(x)   (pCO->mrf((x),pCO->pSegment))
#define TOHEX(x)   ((x) >= 'A' ? (((x) & 0xdf) - 'A')+10 : ((x) - '0'))
#define READL(x)
#define ISAPIVAR(X, Y)

Functions

static int stricmp (char *a, char *b)
static char x2c (char *what)
static void unescape (char *s, long *len)
static void * my_maf (long size, void *p)
static void my_mrf (void *q, void *p)
static int CgiGetChar (pCgiObject pCO)
static void CgiPutChar (pCgiObject pCO, int ch)
static int DebugGetChar (pCgiObject pCO)
void cgi_InitCgi (pCgiObject pCO)
void cgi_InitIsapi (pCgiObject pCO, LPEXTENSION_CONTROL_BLOCK lpECB)
long cgi_ReadHttpRequest (pCgiObject pCO)
char * cgi_PostParam (pCgiObject pCO, char *pszParam)
char * cgi_GetParam (pCgiObject pCO, char *pszParam)
char * cgi_PostParamEx (pCgiObject pCO, char *pszParam, pSymbolList *p)
char * cgi_GetParamEx (pCgiObject pCO, char *pszParam, pSymbolList *p)
FILE * cgi_FILEp (pCgiObject pCO, char *pszParam)
char * cgi_OriginalFileName (pCgiObject pCO, char *pszParam)
long cgi_FileLength (pCgiObject pCO, char *pszParam)
pSymbolList cgi_PartHeader (pCgiObject pCO, char *pszParam)
char * cgi_Header (pCgiObject pCO, char *symbol, pSymbolList pHeader)
char * cgi_Referer (pCgiObject pCO)
char * cgi_Cookie (pCgiObject pCO)
char * cgi_ServerSoftware (pCgiObject pCO)
char * cgi_ServerName (pCgiObject pCO)
char * cgi_GatewayInterface (pCgiObject pCO)
char * cgi_ServerProtocol (pCgiObject pCO)
char * cgi_ServerPort (pCgiObject pCO)
char * cgi_RequestMethod (pCgiObject pCO)
char * cgi_PathInfo (pCgiObject pCO)
char * cgi_PathTranslated (pCgiObject pCO)
char * cgi_ScriptName (pCgiObject pCO)
char * cgi_QueryString (pCgiObject pCO)
char * cgi_RemoteHost (pCgiObject pCO)
char * cgi_RemoteAddress (pCgiObject pCO)
char * cgi_AuthType (pCgiObject pCO)
char * cgi_RemoteUser (pCgiObject pCO)
char * cgi_RemoteIdent (pCgiObject pCO)
char * cgi_ContentType (pCgiObject pCO)
char * cgi_ContentLength (pCgiObject pCO)
char * cgi_UserAgent (pCgiObject pCO)
int cgi_ResizeBuffer (pCgiObject pCO, unsigned long lNewSize)
long cgi_FillBuffer (pCgiObject pCO)
void cgi_ShiftBuffer (pCgiObject pCO, unsigned long nch)
void cgi_NormalizeBuffer (pCgiObject pCO)
long cgi_SkipAfterBoundary (pCgiObject pCO)
int cgi_GetNextByte (pCgiObject pCO)
int cgi_GetNextChar (pCgiObject pCO)
long cgi_ReadHeader (pCgiObject pCO, pSymbolList *pHeader)
int cgi_ResizeThisBuffer (pCgiObject pCO, char **ppszBuffer, long *plOldSize, long lNewSize)
void cgi_FillSymbolAndFile (pCgiObject pCO, char *pszContentDisposition, pSymbolList pHeader)
long cgi_GetMultipartParameters (pCgiObject pCO)
long cgi_GetGetParameters (pCgiObject pCO)
long cgi_GetPostParameters (pCgiObject pCO)


Define Documentation

#define _getenv  )     (pCO->pfEnv ? pCO->pfEnv(pCO->pEmbed,(X),0) : getenv(X))
 

Definition at line 151 of file cgi.c.

Referenced by cgi_AuthType(), cgi_ContentLength(), cgi_ContentType(), cgi_Cookie(), cgi_GatewayInterface(), cgi_PathInfo(), cgi_PathTranslated(), cgi_QueryString(), cgi_Referer(), cgi_RemoteAddress(), cgi_RemoteHost(), cgi_RemoteIdent(), cgi_RemoteUser(), cgi_RequestMethod(), cgi_ScriptName(), cgi_ServerName(), cgi_ServerPort(), cgi_ServerProtocol(), cgi_ServerSoftware(), and cgi_UserAgent().

#define ALLOC  )     (pCO->maf((x),pCO->pSegment))
 

Definition at line 183 of file cgi.c.

#define BUFFER_INCREASE   1024
 

Definition at line 172 of file cgi.c.

#define BUFFER_MAX   10240
 

Definition at line 173 of file cgi.c.

Referenced by cgi_InitCgi().

#define CONTENT_MAX   0xA00000
 

Definition at line 175 of file cgi.c.

Referenced by cgi_InitCgi().

#define CR   '\r'
 

Definition at line 169 of file cgi.c.

Referenced by cgi_GetMultipartParameters(), cgi_GetNextByte(), cgi_ReadHeader(), and cgi_SkipAfterBoundary().

#define DEBUGFP   (pCO->pDebugInfo->fpDebugInput)
 

Definition at line 180 of file cgi.c.

Referenced by cgi_ReadHttpRequest(), and DebugGetChar().

#define FILE_MAX   0xA00000
 

Definition at line 176 of file cgi.c.

Referenced by cgi_InitCgi().

#define FREE  )     (pCO->mrf((x),pCO->pSegment))
 

Definition at line 184 of file cgi.c.

 
#define GETCHAR  )     (pCO->CharacterInput(pCO))
 

Definition at line 182 of file cgi.c.

Referenced by cgi_FillBuffer().

#define ISAPI_BUFFER   0xA000
 

Definition at line 178 of file cgi.c.

Referenced by cgi_InitCgi().

#define ISAPIVAR X,
 ) 
 

Value:

if( pCO->pDebugInfo->X )return pCO->pDebugInfo->X;\
      { DWORD cbBuffer;\
      cbBuffer = 0;\
      pCO->lpECB->GetServerVariable(pCO->lpECB->ConnID,Y,NULL,&cbBuffer);\
      if( cbBuffer == 0 )return NULL;\
      pCO->pDebugInfo->X = ALLOC(cbBuffer);\
      if( pCO->pDebugInfo->X == NULL )return NULL;\
      pCO->lpECB->GetServerVariable(pCO->lpECB->ConnID,Y,pCO->pDebugInfo->X,&cbBuffer);\
      return pCO->pDebugInfo->X;}

Definition at line 914 of file cgi.c.

Referenced by cgi_AuthType(), cgi_ContentLength(), cgi_ContentType(), cgi_Cookie(), cgi_PathInfo(), cgi_PathTranslated(), cgi_QueryString(), cgi_Referer(), cgi_RemoteAddress(), cgi_RemoteHost(), cgi_RemoteUser(), cgi_RequestMethod(), cgi_ScriptName(), cgi_ServerName(), cgi_ServerPort(), cgi_ServerProtocol(), and cgi_ServerSoftware().

#define LF   '\n'
 

Definition at line 170 of file cgi.c.

Referenced by cgi_GetMultipartParameters(), cgi_GetNextByte(), cgi_ReadHeader(), and cgi_SkipAfterBoundary().

#define READL  ) 
 

Value:

if( fgets(LocalBuffer,1024,DEBUGFP) ){\
                 LocalBuffer[w=strlen(LocalBuffer)-2] = (char)0; /* remove terminating \r\n (we read binary)*/ \
                 pCO->pDebugInfo->x = ALLOC(w);\
                 if( pCO->pDebugInfo->x == NULL )return CGI_ERROR_MEMORY_LOW;\
                 strcpy(pCO->pDebugInfo->x,LocalBuffer);\
                 }else pCO->pDebugInfo->x = "";

Referenced by cgi_ReadHttpRequest().

#define TOHEX  )     ((x) >= 'A' ? (((x) & 0xdf) - 'A')+10 : ((x) - '0'))
 

Referenced by x2c().


Function Documentation

char* cgi_AuthType pCgiObject  pCO  ) 
 

Definition at line 1218 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_ContentLength pCgiObject  pCO  ) 
 

Definition at line 1302 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

Referenced by cgi_ReadHttpRequest().

char* cgi_ContentType pCgiObject  pCO  ) 
 

Definition at line 1281 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

Referenced by cgi_GetMultipartParameters(), and cgi_ReadHttpRequest().

char* cgi_Cookie pCgiObject  pCO  ) 
 

Definition at line 946 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

long cgi_FileLength pCgiObject  pCO,
char *  pszParam
 

Definition at line 798 of file cgi.c.

References p.

FILE* cgi_FILEp pCgiObject  pCO,
char *  pszParam
 

Definition at line 737 of file cgi.c.

References NULL, and p.

long cgi_FillBuffer pCgiObject  pCO  ) 
 

Definition at line 1415 of file cgi.c.

References GETCHAR.

Referenced by cgi_GetMultipartParameters(), cgi_GetNextByte(), cgi_GetNextChar(), cgi_GetPostParameters(), cgi_ReadHeader(), and cgi_SkipAfterBoundary().

void cgi_FillSymbolAndFile pCgiObject  pCO,
char *  pszContentDisposition,
pSymbolList  pHeader
 

Definition at line 1796 of file cgi.c.

References ALLOC, memcpy(), NULL, r, and s.

Referenced by cgi_GetMultipartParameters().

char* cgi_GatewayInterface pCgiObject  pCO  ) 
 

Definition at line 1008 of file cgi.c.

References _getenv, and NULL.

long cgi_GetGetParameters pCgiObject  pCO  ) 
 

Definition at line 1979 of file cgi.c.

References ALLOC, cgi_QueryString(), memcpy(), NULL, s, and unescape().

Referenced by cgi_GetMultipartParameters(), cgi_GetPostParameters(), and cgi_ReadHttpRequest().

long cgi_GetMultipartParameters pCgiObject  pCO  ) 
 

Definition at line 1864 of file cgi.c.

References ALLOC, cbBuffer, cgi_ContentType(), cgi_FillBuffer(), cgi_FillSymbolAndFile(), cgi_GetGetParameters(), cgi_GetNextByte(), cgi_Header(), cgi_ReadHeader(), cgi_ResizeBuffer(), cgi_ResizeThisBuffer(), cgi_ShiftBuffer(), cgi_SkipAfterBoundary(), CR, FREE, fseek(), i, lErrorCode, LF, memcpy(), NULL, pszBuffer, s, and SEEK_SET.

Referenced by cgi_ReadHttpRequest().

int cgi_GetNextByte pCgiObject  pCO  ) 
 

Definition at line 1572 of file cgi.c.

References cgi_FillBuffer(), cgi_NormalizeBuffer(), cgi_ResizeBuffer(), CR, and LF.

Referenced by cgi_GetMultipartParameters().

int cgi_GetNextChar pCgiObject  pCO  ) 
 

Definition at line 1631 of file cgi.c.

References cgi_FillBuffer(), and cgi_ResizeBuffer().

char* cgi_GetParam pCgiObject  pCO,
char *  pszParam
 

Definition at line 629 of file cgi.c.

References NULL, and p.

char* cgi_GetParamEx pCgiObject  pCO,
char *  pszParam,
pSymbolList *  p
 

Definition at line 704 of file cgi.c.

References NULL.

long cgi_GetPostParameters pCgiObject  pCO  ) 
 

Definition at line 2030 of file cgi.c.

References ALLOC, cgi_FillBuffer(), cgi_GetGetParameters(), cgi_ResizeBuffer(), memcpy(), NULL, s, and unescape().

Referenced by cgi_ReadHttpRequest().

char* cgi_Header pCgiObject  pCO,
char *  symbol,
pSymbolList  pHeader
 

Definition at line 863 of file cgi.c.

References NULL, and stricmp().

Referenced by cgi_GetMultipartParameters().

void cgi_InitCgi pCgiObject  pCO  ) 
 

Definition at line 398 of file cgi.c.

References BUFFER_INCREASE, BUFFER_MAX, CgiGetChar(), CONTENT_MAX, FILE_MAX, ISAPI_BUFFER, my_maf(), my_mrf(), and NULL.

void cgi_InitIsapi pCgiObject  pCO,
LPEXTENSION_CONTROL_BLOCK  lpECB
 

Definition at line 476 of file cgi.c.

void cgi_NormalizeBuffer pCgiObject  pCO  ) 
 

Definition at line 1479 of file cgi.c.

References cgi_ShiftBuffer().

Referenced by cgi_GetNextByte(), and cgi_ReadHeader().

char* cgi_OriginalFileName pCgiObject  pCO,
char *  pszParam
 

Definition at line 767 of file cgi.c.

References NULL, and p.

pSymbolList cgi_PartHeader pCgiObject  pCO,
char *  pszParam
 

Definition at line 829 of file cgi.c.

References NULL, and p.

char* cgi_PathInfo pCgiObject  pCO  ) 
 

Definition at line 1092 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_PathTranslated pCgiObject  pCO  ) 
 

Definition at line 1113 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_PostParam pCgiObject  pCO,
char *  pszParam
 

Definition at line 598 of file cgi.c.

References NULL, and p.

char* cgi_PostParamEx pCgiObject  pCO,
char *  pszParam,
pSymbolList *  p
 

Definition at line 665 of file cgi.c.

References NULL.

char* cgi_QueryString pCgiObject  pCO  ) 
 

Definition at line 1155 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

Referenced by cgi_GetGetParameters().

long cgi_ReadHeader pCgiObject  pCO,
pSymbolList *  pHeader
 

Definition at line 1668 of file cgi.c.

References cgi_FillBuffer(), cgi_NormalizeBuffer(), cgi_ResizeBuffer(), CR, i, j, LF, pszValue, and w.

Referenced by cgi_GetMultipartParameters().

long cgi_ReadHttpRequest pCgiObject  pCO  ) 
 

Definition at line 497 of file cgi.c.

References ALLOC, cgi_ContentLength(), cgi_ContentType(), cgi_GetGetParameters(), cgi_GetMultipartParameters(), cgi_GetPostParameters(), cgi_RequestMethod(), DEBUGFP, DebugGetChar(), memset(), NULL, r, READL, s, and w.

char* cgi_Referer pCgiObject  pCO  ) 
 

Definition at line 926 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_RemoteAddress pCgiObject  pCO  ) 
 

Definition at line 1197 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_RemoteHost pCgiObject  pCO  ) 
 

Definition at line 1176 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_RemoteIdent pCgiObject  pCO  ) 
 

Definition at line 1260 of file cgi.c.

References _getenv, and NULL.

char* cgi_RemoteUser pCgiObject  pCO  ) 
 

Definition at line 1239 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_RequestMethod pCgiObject  pCO  ) 
 

Definition at line 1071 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

Referenced by cgi_ReadHttpRequest().

int cgi_ResizeBuffer pCgiObject  pCO,
unsigned long  lNewSize
 

Definition at line 1380 of file cgi.c.

References ALLOC, cbBuffer, FREE, memcpy(), NULL, and s.

Referenced by cgi_GetMultipartParameters(), cgi_GetNextByte(), cgi_GetNextChar(), cgi_GetPostParameters(), cgi_ReadHeader(), and cgi_SkipAfterBoundary().

int cgi_ResizeThisBuffer pCgiObject  pCO,
char **  ppszBuffer,
long *  plOldSize,
long  lNewSize
 

Definition at line 1758 of file cgi.c.

References ALLOC, FREE, memcpy(), NULL, and s.

Referenced by cgi_GetMultipartParameters().

char* cgi_ScriptName pCgiObject  pCO  ) 
 

Definition at line 1134 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_ServerName pCgiObject  pCO  ) 
 

Definition at line 987 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_ServerPort pCgiObject  pCO  ) 
 

Definition at line 1050 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_ServerProtocol pCgiObject  pCO  ) 
 

Definition at line 1029 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

char* cgi_ServerSoftware pCgiObject  pCO  ) 
 

Definition at line 966 of file cgi.c.

References _getenv, ISAPIVAR, and NULL.

void cgi_ShiftBuffer pCgiObject  pCO,
unsigned long  nch
 

Definition at line 1447 of file cgi.c.

References i, and j.

Referenced by cgi_GetMultipartParameters(), cgi_NormalizeBuffer(), and cgi_SkipAfterBoundary().

long cgi_SkipAfterBoundary pCgiObject  pCO  ) 
 

Definition at line 1504 of file cgi.c.

References cgi_FillBuffer(), cgi_ResizeBuffer(), cgi_ShiftBuffer(), CR, i, and LF.

Referenced by cgi_GetMultipartParameters().

char* cgi_UserAgent pCgiObject  pCO  ) 
 

Definition at line 1323 of file cgi.c.

References _getenv, and NULL.

static int CgiGetChar pCgiObject  pCO  )  [static]
 

Definition at line 267 of file cgi.c.

Referenced by cgi_InitCgi().

static void CgiPutChar pCgiObject  pCO,
int  ch
[static]
 

Definition at line 286 of file cgi.c.

static int DebugGetChar pCgiObject  pCO  )  [static]
 

Definition at line 292 of file cgi.c.

References DEBUGFP.

Referenced by cgi_ReadHttpRequest().

static void* my_maf long  size,
void *  p
[static]
 

Definition at line 228 of file cgi.c.

Referenced by cgi_InitCgi().

static void my_mrf void *  q,
void *  p
[static]
 

Definition at line 231 of file cgi.c.

References free().

Referenced by cgi_InitCgi().

static int stricmp char *  a,
char *  b
[static]
 

Definition at line 154 of file cgi.c.

static void unescape char *  s,
long *  len
[static]
 

Definition at line 198 of file cgi.c.

References p, and x2c().

Referenced by cgi_GetGetParameters(), and cgi_GetPostParameters().

static char x2c char *  what  )  [static]
 

Definition at line 186 of file cgi.c.

References TOHEX.

Referenced by unescape().


Generated on Sun Mar 12 23:56:36 2006 for ScriptBasic by  doxygen 1.4.6-NO