1
/*###################################################################################
3
# Embperl - Copyright (c) 1997-2004 Gerald Richter / ecos gmbh www.ecos.de
5
# You may distribute under the terms of either the GNU General Public
6
# License or the Artistic License, as specified in the Perl README file.
7
# For use with Apache httpd and mod_perl, see also Apache copyright.
9
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13
# $Id: epdat2.h,v 1.7 2004/01/23 06:50:55 richter Exp $
15
###################################################################################*/
21
#ifdef PERL_IMPLICIT_CONTEXT
23
#define tPerlInterpreter struct perl_thread
25
#define tPerlInterpreter PerlInterpreter
28
#define tPerlInterpreter void
37
struct tReq; /* forward */
39
/*-----------------------------------------------------------------*/
41
/* Parser data structures */
43
/*-----------------------------------------------------------------*/
45
typedef unsigned char tCharMap [256/(sizeof(unsigned char)*8)] ;
51
void * pCompilerInfo ; /* stores tables of the compiler , !!!must be first item!!! */
52
SV * _perlsv ; /**< The perl reference to this structure */
53
const char * sName ; /* name of syntax */
54
const char * sRootNode ; /* name of root node */
55
tCharMap cStartChars ; /* for every vaild start char there is one bit set */
56
tCharMap cAllChars ; /* for every vaild char there is one bit set */
57
struct tToken * pTokens ; /* table with all tokens */
58
int numTokens ; /* number of tokens in above table */
59
int bLSearch ; /* when set perform a linear, instead of a binary search */
60
int nDefNodeType ; /* either ntypCDATA or ntypText */
61
struct tToken * pContainsToken ;/* pointer to the token that has a pContains defined (could be only one per table) */
64
typedef struct tTokenTable tTokenTable ;
69
typedef struct tComponentConfig
72
SV * _perlsv ; /**< The perl reference to this structure */
73
tMemPool * pPool ; /**< pool for memorymanagement */
74
bool bUseEnv ; /**< Take configuration values out of the environment */
75
bool bUseRedirectEnv ; /**< Take configuration values out of the environment. Remove REDIRECT_ prefix. */
77
char * sTopInclude ; /**< Include this text at the top of the page */
83
char * sInputCharset ;
86
unsigned bCacheKeyOptions;
90
char * sExpiresFilename ;
93
char * sXsltstylesheet ;
96
SV * pOpcodeMask ; /* Opcode mask (if any) */
100
typedef struct tReqConfig
102
SV * _perlsv ; /**< The perl reference to this structure */
103
tMemPool * pPool ; /**< pool for memorymanagement */
104
bool bUseEnv ; /**< Take configuration values out of the environment */
105
bool bUseRedirectEnv ; /**< Take configuration values out of the environment. Remove REDIRECT_ prefix. */
113
int nSessionMode ; /**< sets how to pass the session id, see smodeXXX constants */
116
typedef struct tReqParam
118
SV * _perlsv ; /**< The perl reference to this structure */
119
tMemPool * pPool ; /**< pool for memorymanagement */
121
char * sUnparsedUri ;
123
char * sServerAddr ; /**< protocol://server:port */
126
char * sLanguage ; /**< Language for the current request */
127
HV * pCookies ; /**< Received Cookies */
130
typedef struct tAppConfig
132
SV * _perlsv ; /**< The perl reference to this structure */
133
tMemPool * pPool ; /**< pool for memorymanagement */
135
bool bUseEnv ; /**< Take configuration values out of the environment */
136
bool bUseRedirectEnv ; /**< Take configuration values out of the environment. Remove REDIRECT_ prefix. */
137
char * sAppHandlerClass ;
138
char * sSessionHandlerClass ;
140
AV * pSessionClasses ;
141
char * sSessionConfig ;
143
char * sCookieDomain ;
145
char * sCookieExpires ;
153
char * sMailErrorsTo ;
154
int nMailErrorsLimit ;
155
int nMailErrorsResetTime ;
156
int nMailErrorsResendTime ;
159
AV * pObjectAddpathAV ;
160
char * sObjectStopdir ;
161
char * sObjectFallback ;
162
char * sObjectHandlerClass ;
167
typedef struct tComponentParam
169
SV * _perlsv ; /**< The perl reference to this structure */
170
tMemPool * pPool ; /**< pool for memorymanagement */
171
char * sInputfile ; /**< name of sourcefile */
172
char * sOutputfile ; /**< name of outputfile */
173
char * sSubreq ; /**< sub request uri */
176
char * sSub ; /* subroutine to call */
178
char * sObject ; /**< create an object */
179
char * sISA ; /**< make this a base class */
180
AV * pErrArray ; /**< return error messages in this hash */
182
int nMtime ; /**< last modification time of pInput */
183
AV * pParam ; /**< parameters passed via Execute */
184
HV * pFormHash; /**< fdat for this component */
185
AV * pFormArray ; /**< ffld for this component */
186
HV * pXsltParam ; /**< parameter for xslt proc */
190
typedef struct tThreadData
192
SV * _perlsv ; /**< The perl reference to this structure */
193
tPerlInterpreter * pPerlTHX ; /* pointer to Perl interpreter */
194
tMemPool * pPool ; /**< pool for memorymanagement */
195
tMemPool * pMainPool ; /**< global pool. Only use during initialisation! */
196
HV * pApplications ; /**< Hash with available applications */
197
struct tReq * pCurrReq ; /**< Current running request if any */
198
pid_t nPid ; /**< process/thread id */
200
/* --- Embperl special hashs/arrays --- */
202
HV * pEnvHash ; /* environement from CGI Script */
203
HV * pFormHash ; /* Formular data */
205
HV * pFormSplitHash ; /* Formular data split up at \t */
206
HV * pInputHash ; /* Data of input fields */
207
AV * pFormArray ; /* Fieldnames */
209
HV * pHeaderHash ;/* http headers */
210
SV * pReqRV ; /* the request object global */
211
SV * pAppRV ; /* the application object global */
220
SV * _perlsv ; /**< The perl reference to this structure */
221
tPerlInterpreter * pPerlTHX ; /* pointer to Perl interpreter */
222
tMemPool * pPool ; /**< pool for memorymanagement */
223
tThreadData * pThread ;
224
struct tReq * pCurrReq ; /**< Current running request if any */
225
tAppConfig Config ; /**< application configuration data */
226
FILEIO * lfd ; /**< log file handle */
228
HV * pUserHash ; /**< Session User data */
229
SV * pUserObj ; /**< Session User object */
230
HV * pStateHash ; /**< Session State data */
231
SV * pStateObj ; /**< Session State object */
232
HV * pAppHash ; /**< Session Application data */
233
SV * pAppObj ; /**< Session Application object */
235
int nErrorsCount ; /**< Number of errors */
236
int nErrorsLastTime ; /**< Time last error has occured */
237
int nErrorsLastSendTime ;/**< Time last error was send via mail */
242
typedef struct tComponentOutput
244
SV * _perlsv ; /**< The perl reference to this structure */
245
tMemPool * pPool ; /**< pool for memorymanagement */
247
bool bDisableOutput ; /* no output is generated */
249
struct tBuf * pFirstBuf ; /* First buffer */
250
struct tBuf * pLastBuf ; /* Last written buffer */
251
struct tBuf * pFreeBuf ; /* List of unused buffers */
252
struct tBuf * pLastFreeBuf ; /* End of list of unused buffers */
254
char * pMemBuf ; /* temporary output */
255
char * pMemBufPtr ; /* temporary output */
256
size_t nMemBufSize ; /* size of pMemBuf */
257
size_t nMemBufSizeFree;/* remaining space in pMemBuf */
259
int nMarker ; /* Makers for rollback output */
261
FILEIO * ofd ; /* output file descriptor */
263
SV * ofdobj ; /* perl object that is tied to stdout, if any */
270
SV * _perlsv ; /**< The perl reference to this structure */
271
tMemPool * pPool ; /**< pool for memorymanagement */
273
tComponentConfig Config ; /**< request configuration data */
274
tComponentParam Param ; /**< parameter passed to current request */
275
tComponentOutput * pOutput ; /**< output channel for this component */
278
bool bReqRunning ; /* we are inside of a request */
279
bool bSubReq ; /* This is a sub request (called inside an Embperl page) */
280
int nInsideSub ; /* Are we inside of a sub? */
281
int bExit ; /* We should exit the page */
282
int nPathNdx ; /* gives the index in the path where the current file is found */
283
char * sCWD ; /**< Current working directory */
285
bool bEP1Compat ; /* run in Embperl 1.x compatible mode */
286
int nPhase ; /* which phase of the request we are in */
289
char * sSourcefile ; /**< Contains the current sourefilename */
290
char * pBuf ; /**< Contains a pointer to the start of the current source in memory */
291
char * pEndPos ; /**< First byte after sourcebuffer */
292
char * pCurrPos ; /**< Current position in sourcebuffer */
293
int nSourceline ; /**< Currentline in sourcefile */
294
char * pSourcelinePos ; /**< Positon of nSourceline in sourcebuffer */
295
char * pLineNoCurrPos ; /**< save pCurrPos for line no calculation */
300
tNode xDocument ; /* Document node */
301
tNode xCurrNode ; /* node that was last executed */
302
tRepeatLevel nCurrRepeatLevel ; /* repeat level for node that was last executed */
303
tIndex nCurrCheckpoint ; /* next checkpoint that should be passed if execution order is unchanged (i.e. no loop/if) */
304
tIndex xCurrDomTree ; /* DomTree we are currently working on */
305
tIndex xSourceDomTree ;/* DomTree which contains the source */
307
struct tCacheItem * pOutputCache ; /**< Cache which hold the final output */
308
SV * pOutputSV ; /**< set if output is text and not a tree */
309
struct tTokenTable * pTokenTable ; /**< holds the current syntax */
311
/* --- Escaping --- */
313
struct tCharTrans * pCurrEscape ; /* pointer to current escape table */
314
struct tCharTrans * pNextEscape ; /* pointer to next escape table (after end of block) */
315
int nCurrEscMode ; /* current active escape mode */
316
int bEscModeSet ; /* escape mode already set in this block */
317
int bEscInUrl ; /* we are inside an url */
320
/* --- i/o filehandles --- */
322
FILEIO * ifd ; /* input file */
323
SV * ifdobj ; /* perl object that is tied to stdin, if any */
325
bool bAppendToMainReq ; /* append output to main request */
327
/* ------------------------ */
329
struct tComponent * pPrev ; /* Component from which this one is called */
331
/* ------------------------ */
333
/* --- more infos for eval --- */
335
int bStrict ; /* aply use strict in each eval */
337
char op_mask_buf[MAXO + 100]; /* save buffer for opcode mask - maxo shouldn't differ from MAXO but leave room anyway (see BOOT:) */
339
char * sImportPackage ; /**< name of caller macro that should be used to import new subs */
340
HV * pImportStash ; /* stash for package, where new subs should be imported */
344
/* --- compiler --- */
346
char * sCurrPackage ; /**< Package name for current sourcefile */
347
char * sEvalPackage ; /**< Package for eval (normaly same sCurrPackage,
348
differs when running in a safe namespace */
349
STRLEN nEvalPackage ; /**< Length of package name for eval */
350
char * sMainSub ; /**< Name of sub to call when executing the current source */
352
char * * pProg ; /* pointer into currently compiled code */
353
char * pProgRun ; /* pointer into currently compiled run code */
354
char * pProgDef ; /* pointer into currently compiled define code */
356
SV * pCodeSV ; /* contains currently compiled line */
366
SV * _perlsv ; /**< The perl reference to this structure */
368
tPerlInterpreter * pPerlTHX ; /* pointer to Perl interpreter */
369
tMemPool * pPool ; /**< pool for memorymanagement */
371
request_rec * pApacheReq ; /* apache request record */
373
tApacheDirConfig * pApacheConfig ;
375
tReqConfig Config ; /**< request configuration data */
376
tReqParam Param ; /**< request parameter data */
377
tComponent Component ;
379
tThreadData * pThread ;
381
int nRequestCount ; /**< increments by one on each request */
382
time_t nRequestTime ; /**< time when request starts */
386
int nSessionMgnt ; /* how to retrieve the session id */
387
char * sSessionID ; /**< stores session name and id for status session data */
388
char * sSessionUserID ; /**< received id of user session data */
389
char * sSessionStateID ; /**< received id of state session data */
391
int bExit ; /**< We should exit the request */
392
long nLogFileStartPos ; /**< file position of logfile, when logfile started */
394
int bError ; /* Error has occured somewhere */
395
AV * pErrArray ; /* Errors to show on Error response */
397
char errdat1 [ERRDATLEN] ; /* Additional error information */
398
char errdat2 [ERRDATLEN] ;
399
char lastwarn [ERRDATLEN] ; /* last warning */
401
AV * pDomTreeAV ; /* holds all DomTrees alocated during the request */
402
AV * pCleanupAV ; /* set all sv's that are conatined in that array to undef after the whole request */
403
HV * pCleanupPackagesHV ; /* packages that should be cleaned up at end of request */
405
char * sInitialCWD ; /**< Reset directory to */
408
AV * pDefaultMessages ;
410
/* --- for statistics --- */
415
#if defined (_MDEBUG) && defined (WIN32)
416
_CrtMemState MemCheckpoint ; /* memory leak debugging */
420
unsigned long MemCheckpoint ; /* memory leak debugging */