G:/ScriptBasic/source/variations/httpd/websrv.c File Reference

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include "../../thread.h"
#include "../../filesys.h"
#include "../../httpd.h"
#include "../../logger.h"
#include "../../scriba.h"

Go to the source code of this file.

Data Structures

struct  _WebData
struct  _ApplicationThreadData
struct  _RunServiceProgram

Defines

#define FULL_PATH_BUFFER_LENGTH   256
#define INBLEN   10
#define ERRMSGCLIENT   0x01
#define ERRMSGERRLOG   0x02
#define OBLEN   20
#define ENVLEN   256
#define DEC(c)   pr2six[(int)c]
#define MAXVAL   63
#define CONFIG(X)   cft_GetString(pWD->pProgramConfig->pCONF,(X))
#define GET_FTP_PARAMETER(X)
#define X(a, b)   case a: pszEVN = b; strcpy(pATD->szEnvBuf,b); strcat(pATD->szEnvBuf,"=");break;
#define envRETURN(X)
#define X(a, b)   case a: pszEVN = b; strcpy(pATD->szEnvBuf,b); strcat(pATD->szEnvBuf,"=");break;
#define envRETURN(X)
#define GET_BAS_P_NAME(X, Y)   if( ! strnicmp(Buffer,#X,Y) )s = pHT->server[pT->server_index].X;

Typedefs

typedef _WebData WebData
typedef _WebDatapWebData
typedef _ApplicationThreadData ApplicationThreadData
typedef _ApplicationThreadDatapApplicationThreadData

Functions

static int uudecode (char *bufcoded, unsigned char *bufplain, int outbufsize)
static char * prefix (char *t, char *p)
static int maskip (char *s, unsigned long *ip, unsigned long *mask)
static void httpd_report (void *pEmbedPointer, char *FileName, long LineNumber, unsigned int iErrorCode, int iErrorSeverity, int *piErrorCounter, char *szErrorString, unsigned long *fFlags)
static void ftp_report (void *pEmbedPointer, char *FileName, long LineNumber, unsigned int iErrorCode, int iErrorSeverity, int *piErrorCounter, char *szErrorString, unsigned long *fFlags)
int AppInit (int argc, char *argv[], pHttpdThread pHT, void **AppData)
static void GuardThread (void *p)
static void ExecuteProgramThread (void *p)
static void ExecuteProgram (pWebData pWD, char *pszProgramFileName, int iRestart)
int AppStart (void **AppData)
static void pfFtpOut (int ch, void *pE)
static int pfFtpIn (void *pE)
static void pfStdOut (int ch, void *pE)
static int pfStdIn (void *pE)
static char * pfFtpEnv (void *pE, char *pszEVN, long lEVSN)
static char * pfEnv (void *pE, char *pszEVN, long lEVSN)
static void send404 (pHttpdThread pHT, pThreadData pT)
int FtpProc (pHttpdThread pHT, pThreadData pT, char *Buffer)
void HttpProc (pHttpdThread pHT, pThreadData pT)
 main (int argc, char *argv[])

Variables

static char six2pr [64]
static unsigned char pr2six [256]


Define Documentation

#define CONFIG  )     cft_GetString(pWD->pProgramConfig->pCONF,(X))
 

Definition at line 400 of file websrv.c.

Referenced by AppStart().

#define DEC  )     pr2six[(int)c]
 

Referenced by uudecode().

#define ENVLEN   256
 

Definition at line 163 of file websrv.c.

#define envRETURN  ) 
 

Value:

do{ pszRet=X;\
                      if( isLong ){\
                        if( pszRet && strlen(pszRet) < ENVLEN - strlen(pATD->szEnvBuf) -1 )\
                          strcat(pATD->szEnvBuf,pszRet);\
                        return pATD->szEnvBuf;\
                        }else return pszRet;\
                     }while(0)

#define envRETURN  ) 
 

Value:

do{ pszRet=X;\
                      if( isLong ){\
                        if( pszRet && strlen(pszRet) < ENVLEN - strlen(pATD->szEnvBuf) -1 )\
                          strcat(pATD->szEnvBuf,pszRet);\
                        return pATD->szEnvBuf;\
                        }else return pszRet;\
                     }while(0)

Referenced by pfEnv(), and pfFtpEnv().

#define ERRMSGCLIENT   0x01
 

Definition at line 147 of file websrv.c.

Referenced by ftp_report(), and httpd_report().

#define ERRMSGERRLOG   0x02
 

Definition at line 148 of file websrv.c.

Referenced by ftp_report(), and httpd_report().

#define FULL_PATH_BUFFER_LENGTH   256
 

Definition at line 79 of file websrv.c.

#define GET_BAS_P_NAME X,
 )     if( ! strnicmp(Buffer,#X,Y) )s = pHT->server[pT->server_index].X;
 

Referenced by FtpProc().

#define GET_FTP_PARAMETER  ) 
 

Value:

Node = cft_FindNode(pWD->pProgramConfig->pCONF,ServerStartNode,"programs." #X);\
                              if( ! cft_GetEx(pWD->pProgramConfig->pCONF,NULL,&Node,&s,NULL,NULL,NULL) ){\
                                pHT->server[i].X = s;\
                                }else pHT->server[i].X = NULL;

#define INBLEN   10
 

Definition at line 80 of file websrv.c.

Referenced by pfStdIn().

#define MAXVAL   63
 

Referenced by uudecode().

#define OBLEN   20
 

Definition at line 162 of file websrv.c.

Referenced by pfStdOut().

#define X a,
 )     case a: pszEVN = b; strcpy(pATD->szEnvBuf,b); strcat(pATD->szEnvBuf,"=");break;
 

#define X a,
 )     case a: pszEVN = b; strcpy(pATD->szEnvBuf,b); strcat(pATD->szEnvBuf,"=");break;
 


Typedef Documentation

typedef struct _ApplicationThreadData ApplicationThreadData
 

typedef struct _ApplicationThreadData * pApplicationThreadData
 

typedef struct _WebData * pWebData
 

typedef struct _WebData WebData
 


Function Documentation

int AppInit int  argc,
char *  argv[],
pHttpdThread  pHT,
void **  AppData
 

Definition at line 402 of file websrv.c.

References free(), i, iError, _WebData::nolog, NULL, _WebData::pHT, _WebData::pProgramConfig, s, scriba_InitModuleInterface(), scriba_LoadConfiguration(), scriba_new(), and _WebData::XForwarded.

Referenced by httpd(), and main().

int AppStart void **  AppData  ) 
 

Definition at line 897 of file websrv.c.

References alloc_Alloc(), alloc_Free(), alloc_InitSegment(), _WebData::AppLog, cft_EnumFirst(), cft_EnumNext(), cft_FindNode(), cft_GetEx(), cft_GetKey(), CONFIG, _WebData::ErrLog, ExecuteProgram(), fp, free(), GuardThread(), _WebData::HitLog, iError, _RunServiceProgram::iRestart, log_init(), log_printf(), _WebData::lWaitLoop, _WebData::nolog, NULL, _WebData::PanicLog, _WebData::pHT, _WebData::pProgramConfig, _WebData::pszPid, _RunServiceProgram::pWD, s, _WebData::StatLog, thread_CreateThread(), and thread_InitMutex().

Referenced by main().

static void ExecuteProgram pWebData  pWD,
char *  pszProgramFileName,
int  iRestart
[static]
 

Definition at line 873 of file websrv.c.

References _WebData::ErrLog, ExecuteProgramThread(), _RunServiceProgram::iRestart, log_printf(), NULL, _RunServiceProgram::pszProgramFileName, _RunServiceProgram::pWD, strcpy(), and thread_CreateThread().

Referenced by AppStart().

static void ExecuteProgramThread void *  p  )  [static]
 

Definition at line 833 of file websrv.c.

References _WebData::AppLog, _WebData::ErrLog, free(), FULL_PATH_BUFFER_LENGTH, _RunServiceProgram::iRestart, log_printf(), NULL, _WebData::pProgramConfig, _RunServiceProgram::pszProgramFileName, _RunServiceProgram::pWD, scriba_destroy(), scriba_IsFileBinaryFormat(), scriba_LoadBinaryProgram(), scriba_LoadSourceProgram(), scriba_new(), scriba_Run(), scriba_RunExternalPreprocessor(), scriba_SaveCacheFile(), scriba_SetEmbedPointer(), scriba_SetFileName(), scriba_SetProcessSbObject(), scriba_UseCacheFile(), and strcpy().

Referenced by ExecuteProgram().

static void ftp_report void *  pEmbedPointer,
char *  FileName,
long  LineNumber,
unsigned int  iErrorCode,
int  iErrorSeverity,
int *  piErrorCounter,
char *  szErrorString,
unsigned long *  fFlags
[static]
 

Definition at line 353 of file websrv.c.

References _WebData::bErrMsgDest, buf, _WebData::ErrLog, ERRMSGCLIENT, ERRMSGERRLOG, log_printf(), s, and sprintf().

Referenced by FtpProc().

int FtpProc pHttpdThread  pHT,
pThreadData  pT,
char *  Buffer
 

Definition at line 1300 of file websrv.c.

References _WebData::ErrLog, file_fclose(), file_fopen(), fp, free(), ftp_report(), FULL_PATH_BUFFER_LENGTH, GET_BAS_P_NAME, _WebData::HitLog, log_printf(), NULL, pfFtpEnv(), pfFtpIn(), pfFtpOut(), _WebData::pProgramConfig, _ApplicationThreadData::pszFtpCommand, r, s, scriba_destroy(), scriba_IsFileBinaryFormat(), scriba_LoadBinaryProgram(), scriba_LoadSourceProgram(), scriba_new(), scriba_Run(), scriba_RunExternalPreprocessor(), scriba_SaveCacheFile(), scriba_SetEmbedPointer(), scriba_SetEnvironment(), scriba_SetFileName(), scriba_SetProcessSbObject(), scriba_SetReportFunction(), scriba_SetReportPointer(), scriba_SetStdin(), scriba_SetStdout(), scriba_UseCacheFile(), sprintf(), strcpy(), and _ApplicationThreadData::szThreadIndex.

Referenced by main().

static void GuardThread void *  p  )  [static]
 

Definition at line 791 of file websrv.c.

References _WebData::AppLog, buf, fp, i, log_printf(), _WebData::lWaitLoop, memcpy(), NULL, _WebData::pszPid, sprintf(), thread_LockMutex(), and thread_UnlockMutex().

Referenced by AppStart().

static void httpd_report void *  pEmbedPointer,
char *  FileName,
long  LineNumber,
unsigned int  iErrorCode,
int  iErrorSeverity,
int *  piErrorCounter,
char *  szErrorString,
unsigned long *  fFlags
[static]
 

Definition at line 286 of file websrv.c.

References _WebData::bErrMsgDest, buf, _WebData::ErrLog, ERRMSGCLIENT, ERRMSGERRLOG, log_printf(), s, and sprintf().

Referenced by HttpProc().

void HttpProc pHttpdThread  pHT,
pThreadData  pT
 

Definition at line 1458 of file websrv.c.

References _ApplicationThreadData::cbBuffer, _ApplicationThreadData::cbInBuffer, _WebData::cVdir, _ApplicationThreadData::FirstHeaderLine, free(), FULL_PATH_BUFFER_LENGTH, httpd_report(), i, NULL, pfEnv(), pfStdIn(), pfStdOut(), _WebData::pProgramConfig, _WebData::ppszVdir, prefix(), _ApplicationThreadData::pszClientIP, _ApplicationThreadData::pszPassword, _ApplicationThreadData::pszRemoteUser, s, scriba_new(), scriba_SetCgiFlag(), scriba_SetEmbedPointer(), scriba_SetEnvironment(), scriba_SetProcessSbObject(), scriba_SetReportFunction(), scriba_SetReportPointer(), scriba_SetStdin(), scriba_SetStdout(), sprintf(), uudecode(), and _WebData::XForwarded.

Referenced by main().

main int  argc,
char *  argv[]
 

Definition at line 1601 of file websrv.c.

References AppInit(), _WebData::AppLog, AppStart(), buf, fork(), FtpProc(), httpd(), HttpProc(), i, log_printf(), main(), memcpy(), NULL, ReportStatusToSCMgr(), scriba_InitStaticModules(), ServiceStart(), ServiceStop(), sprintf(), thread_LockMutex(), and thread_UnlockMutex().

static int maskip char *  s,
unsigned long *  ip,
unsigned long *  mask
[static]
 

Definition at line 255 of file websrv.c.

References i.

static char* pfEnv void *  pE,
char *  pszEVN,
long  lEVSN
[static]
 

Definition at line 1150 of file websrv.c.

References envRETURN, NULL, _WebData::pHT, _ApplicationThreadData::pszClientIP, _ApplicationThreadData::pszPassword, _ApplicationThreadData::pszPathTranslated, _ApplicationThreadData::pszRemoteUser, s, _WebData::szPort, and X.

Referenced by HttpProc().

static char* pfFtpEnv void *  pE,
char *  pszEVN,
long  lEVSN
[static]
 

Definition at line 1116 of file websrv.c.

References envRETURN, NULL, _ApplicationThreadData::pszFtpCommand, _ApplicationThreadData::szThreadIndex, and X.

Referenced by FtpProc().

static int pfFtpIn void *  pE  )  [static]
 

Definition at line 1047 of file websrv.c.

Referenced by FtpProc().

static void pfFtpOut int  ch,
void *  pE
[static]
 

Definition at line 1038 of file websrv.c.

Referenced by FtpProc().

static int pfStdIn void *  pE  )  [static]
 

Definition at line 1090 of file websrv.c.

References _ApplicationThreadData::cbInBuffer, INBLEN, _ApplicationThreadData::pszInBuffer, and _ApplicationThreadData::szInBuffer.

Referenced by HttpProc().

static void pfStdOut int  ch,
void *  pE
[static]
 

Definition at line 1051 of file websrv.c.

References _ApplicationThreadData::cbBuffer, _ApplicationThreadData::FirstHeaderLine, OBLEN, and _ApplicationThreadData::szBuffer.

Referenced by HttpProc().

static char* prefix char *  t,
char *  p
[static]
 

Definition at line 237 of file websrv.c.

References NULL.

Referenced by HttpProc().

static void send404 pHttpdThread  pHT,
pThreadData  pT
[static]
 

Definition at line 1277 of file websrv.c.

References _WebData::code404, and _WebData::msg404.

static int uudecode char *  bufcoded,
unsigned char *  bufplain,
int  outbufsize
[static]
 

Definition at line 187 of file websrv.c.

References DEC, j, and MAXVAL.

Referenced by HttpProc().


Variable Documentation

unsigned char pr2six[256] [static]
 

Definition at line 186 of file websrv.c.

char six2pr[64] [static]
 

Initial value:

 {
    'A','B','C','D','E','F','G','H','I','J','K','L','M',
    'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
    'a','b','c','d','e','f','g','h','i','j','k','l','m',
    'n','o','p','q','r','s','t','u','v','w','x','y','z',
    '0','1','2','3','4','5','6','7','8','9','+','/'
}

Definition at line 179 of file websrv.c.


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