/*################################################################################### # # Embperl - Copyright (c) 1997-1998 Gerald Richter / ECOS # # You may distribute under the terms of either the GNU General Public # License or the Artistic License, as specified in the Perl README file. # For use with Apache httpd and mod_perl, see also Apache copyright. # # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # ###################################################################################*/ #include "ep.h" #include "epmacro.h" /* Version */ static char sVersion [] = VERSION ; /* pid */ pid_t nPid ; /* Apache Request Record */ #ifdef APACHE request_rec * pReq = NULL ; #endif int bDebug = 0 ; /* Debugging options */ int bOptions ; /* Options */ int bReqRunning = 0 ; /* we are inside of a request */ int bError = 0 ; /* Error has occured somewhere */ static I32 nLastErrFill ; static int bLastErrState ; static int bInitDone = 0 ; /* c part is already initialized */ int nIOType = epIOPerl ; /* what mode we are run as */ static char sCmdFifo [] = "/local/www/cgi-bin/embperl/cmd.fifo" ; static char sRetFifo [1024] ; static char sRetFifoName [] = "__RETFIFO" ; char cMultFieldSep = '\t' ; /* Separator if a form filed is multiplie defined */ static char sEnvHashName [] = "ENV" ; static char sFormHashName [] = "HTML::Embperl::fdat" ; static char sFormSplitHashName [] = "HTML::Embperl::fsplitdat" ; static char sFormArrayName [] = "HTML::Embperl::ffld" ; static char sInputHashName [] = "HTML::Embperl::idat" ; static char sErrArrayName [] = "HTML::Embperl::errors" ; static char sErrFillName [] = "HTML::Embperl::errfill" ; static char sErrStateName [] = "HTML::Embperl::errstate" ; static char sHeaderArrayName [] = "HTML::Embperl::headers" ; static char sTabCountName [] = "HTML::Embperl::cnt" ; static char sTabRowName [] = "HTML::Embperl::row" ; static char sTabColName [] = "HTML::Embperl::col" ; static char sTabMaxRowName [] = "HTML::Embperl::maxrow" ; static char sTabMaxColName [] = "HTML::Embperl::maxcol" ; static char sTabModeName [] = "HTML::Embperl::tabmode" ; static char sEscModeName [] = "HTML::Embperl::escmode" ; char sLogfileURLName[] = "HTML::Embperl::LogfileURL" ; static char sOpcodeMaskName[] = "HTML::Embperl::opcodemask" ; static char sPackageName[] = "HTML::Embperl::package" ; static char sEvalPackageName[]= "HTML::Embperl::evalpackage" ; HV * pEnvHash ; /* environement from CGI Script */ HV * pFormHash ; /* Formular data */ HV * pFormSplitHash ; /* Formular data split up at \t */ HV * pInputHash ; /* Data of input fields */ AV * pFormArray ; /* Fieldnames */ AV * pErrArray ; /* Errors to show on Error response */ AV * pErrFill ; /* AvFILL of pErrArray, index is nMarker */ AV * pErrState ; /* bError, index is nMarker */ /*AV * pHeaderArray ;*/ /* contains http headers in cgi mode */ HV * pCacheHash ; /* Hash containing CVs to precompiled subs */ SV * pPackage ; /* Currently active Package */ SV * pEvalPackage ; /* Currently active Package */ char * sEvalPackage ; /* Currently active Package */ STRLEN nEvalPackage ; /* Currently active Package (length) */ SV * pOpcodeMask ;/* Currently active Opcode mask (if any) */ static char * sCurrPackage ; /* Name of package to eval everything */ char * pBuf ; /* Buffer which holds the html source file */ char * pCurrPos ; /* Current position in html file */ char * pCurrStart ; /* Current start position of html tag / eval expression */ char * pEndPos ; /* end of html file */ char * pCurrTag ; /* Current start position of html tag */ char * sSourcefile ; /* Name of sourcefile */ int nSourceline ; /* Currentline in sourcefile */ char * pSourcelinePos ; /* Positon of nSourceline in sourcefile */ char * pLineNoCurrPos ; /* save pCurrPos for line no calculation */ /* Additional Error info */ char errdat1 [ERRDATLEN] ; char errdat2 [ERRDATLEN] ; char lastwarn [ERRDATLEN] ; /* for statistics */ static clock_t startclock ; static I32 stsv_count ; static I32 stsv_objcount ; static I32 lstsv_count ; static I32 lstsv_objcount ; /* */ /* print error */ /* */ char * LogError (/*in*/ int rc) { const char * msg ; char * sText ; SV * pSV ; SV ** ppSV ; int n ; EPENTRY (LogError) ; errdat1 [sizeof (errdat1) - 1] = '\0' ; errdat2 [sizeof (errdat2) - 1] = '\0' ; GetLineNo () ; if (rc != rcPerlWarn) bError = 1 ; switch (rc) { case ok: msg ="[%d]ERR: %d: Line %d: ok%s%s" ; break ; case rcStackOverflow: msg ="[%d]ERR: %d: Line %d: Stack Overflow%s%s" ; break ; case rcArgStackOverflow: msg ="[%d]ERR: %d: Line %d: Argumnet Stack Overflow (%s)%s" ; break ; case rcStackUnderflow: msg ="[%d]ERR: %d: Line %d: Stack Underflow%s%s" ; break ; case rcEndifWithoutIf: msg ="[%d]ERR: %d: Line %d: endif without if%s%s" ; break ; case rcElseWithoutIf: msg ="[%d]ERR: %d: Line %d: else without if%s%s" ; break ; case rcEndwhileWithoutWhile: msg ="[%d]ERR: %d: Line %d: endwhile without while%s%s" ; break ; case rcEndtableWithoutTable: msg ="[%d]ERR: %d: Line %d: blockend <%s> does not match blockstart <%s>" ; break ; case rcTablerowOutsideOfTable: msg ="[%d]ERR: %d: Line %d: