~ubuntu-branches/debian/sid/libembperl-perl/sid

« back to all changes in this revision

Viewing changes to epdat2.h

  • Committer: Bazaar Package Importer
  • Author(s): Angus Lees
  • Date: 2004-02-15 14:23:39 UTC
  • Revision ID: james.westby@ubuntu.com-20040215142339-n21gqf7mx9tmyb8d
Tags: upstream-2.0b10
ImportĀ upstreamĀ versionĀ 2.0b10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*###################################################################################
 
2
#
 
3
#   Embperl - Copyright (c) 1997-2004 Gerald Richter / ecos gmbh   www.ecos.de
 
4
#
 
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.
 
8
#
 
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.
 
12
#
 
13
#   $Id: epdat2.h,v 1.7 2004/01/23 06:50:55 richter Exp $
 
14
#
 
15
###################################################################################*/
 
16
 
 
17
 
 
18
#ifndef __EPDAT2_H
 
19
#define __EPDAT2_H
 
20
 
 
21
#ifdef PERL_IMPLICIT_CONTEXT
 
22
#ifdef USE_THREADS
 
23
#define tPerlInterpreter struct perl_thread 
 
24
#else
 
25
#define tPerlInterpreter PerlInterpreter 
 
26
#endif
 
27
#else
 
28
#define tPerlInterpreter void
 
29
#endif
 
30
 
 
31
#ifdef PerlIO
 
32
#define FILEIO PerlIO 
 
33
#else
 
34
#define FILEIO FILE
 
35
#endif
 
36
 
 
37
struct tReq; /* forward */
 
38
 
 
39
/*-----------------------------------------------------------------*/
 
40
/*                                                                 */
 
41
/*  Parser data structures                                         */
 
42
/*                                                                 */
 
43
/*-----------------------------------------------------------------*/
 
44
 
 
45
typedef   unsigned char tCharMap [256/(sizeof(unsigned char)*8)]   ;
 
46
 
 
47
struct tToken ;
 
48
 
 
49
struct tTokenTable
 
50
    {
 
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) */
 
62
    } ;
 
63
 
 
64
typedef struct tTokenTable tTokenTable ;
 
65
    
 
66
 
 
67
 
 
68
 
 
69
typedef struct tComponentConfig
 
70
 
 
71
    {
 
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. */
 
76
    char *      sPackage ;
 
77
    char *      sTopInclude ;           /**< Include this text at the top of the page */
 
78
    unsigned    bDebug ;
 
79
    unsigned    bOptions ;
 
80
    int         nCleanup ;
 
81
    int         nEscMode ;
 
82
    int         nInputEscMode ;
 
83
    char *      sInputCharset ;
 
84
    int         bEP1Compat;
 
85
    char *      sCacheKey ;
 
86
    unsigned    bCacheKeyOptions;
 
87
    CV *        pExpiredFunc ;
 
88
    CV *        pCacheKeyFunc ;
 
89
    int         nExpiresIn ;
 
90
    char *      sExpiresFilename ;
 
91
    char *      sSyntax ;
 
92
    SV   *      pRecipe ;
 
93
    char *      sXsltstylesheet ;
 
94
    char *      sXsltproc ;
 
95
    char *      sCompartment ;
 
96
    SV *        pOpcodeMask ;   /* Opcode mask (if any) */
 
97
    } tComponentConfig ;
 
98
 
 
99
 
 
100
typedef struct tReqConfig
 
101
    {
 
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. */
 
106
    CV *        pAllow ;
 
107
    CV *        pUriMatch ;
 
108
    char        cMultFieldSep ;
 
109
    AV *        pPathAV ;
 
110
    int         nOutputMode ;
 
111
    unsigned    bDebug ;
 
112
    unsigned    bOptions ;
 
113
    int         nSessionMode ;      /**< sets how to pass the session id, see smodeXXX constants */
 
114
    } tReqConfig ;
 
115
 
 
116
typedef struct tReqParam
 
117
    {
 
118
    SV *        _perlsv ;         /**< The perl reference to this structure */
 
119
    tMemPool *  pPool ;  /**< pool for memorymanagement */
 
120
    char *  sFilename ;
 
121
    char *  sUnparsedUri ;
 
122
    char *  sUri ;
 
123
    char *  sServerAddr ;       /**< protocol://server:port */
 
124
    char *  sPathInfo ;
 
125
    char *  sQueryInfo ;
 
126
    char *  sLanguage ;         /**< Language for the current request */
 
127
    HV *    pCookies ;          /**< Received Cookies */
 
128
    } tReqParam ;
 
129
 
 
130
typedef struct tAppConfig
 
131
    {
 
132
    SV *        _perlsv ;         /**< The perl reference to this structure */
 
133
    tMemPool *  pPool ;  /**< pool for memorymanagement */
 
134
    char *  sAppName ;
 
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 ;
 
139
    HV *    pSessionArgs ;
 
140
    AV *    pSessionClasses ;
 
141
    char *  sSessionConfig ;
 
142
    char *  sCookieName ;
 
143
    char *  sCookieDomain ;
 
144
    char *  sCookiePath ;
 
145
    char *  sCookieExpires ;
 
146
    bool    bCookieSecure ;
 
147
    char *  sLog ;
 
148
    unsigned    bDebug ;
 
149
    char *  sMailhost ;
 
150
    char *  sMailhelo ;
 
151
    char *  sMailfrom ;
 
152
    bool    bMaildebug ;
 
153
    char *  sMailErrorsTo ;
 
154
    int     nMailErrorsLimit ;
 
155
    int     nMailErrorsResetTime ;
 
156
    int     nMailErrorsResendTime ;
 
157
    char *  sObjectBase ;
 
158
    char *  sObjectApp ;
 
159
    AV *    pObjectAddpathAV ;
 
160
    char *  sObjectStopdir ;
 
161
    char *  sObjectFallback ;
 
162
    char *  sObjectHandlerClass ;
 
163
    } tAppConfig ;
 
164
 
 
165
 
 
166
 
 
167
typedef struct tComponentParam
 
168
    {
 
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 */
 
174
    SV *    pInput ;
 
175
    SV *    pOutput ;
 
176
    char *  sSub ;          /* subroutine to call */
 
177
    int     nImport ;
 
178
    char *  sObject ;       /**< create an object */
 
179
    char *  sISA ;          /**< make this a base class */
 
180
    AV *    pErrArray ;     /**< return error messages in this hash */
 
181
    int     nFirstLine ;
 
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 */    
 
187
    } tComponentParam ;
 
188
 
 
189
 
 
190
typedef struct tThreadData
 
191
    {
 
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 */
 
199
 
 
200
    /* --- Embperl special hashs/arrays --- */
 
201
 
 
202
    HV *    pEnvHash ;   /* environement from CGI Script */
 
203
    HV *    pFormHash ;  /* Formular data */
 
204
    GV *    pFormHashGV ;  
 
205
    HV *    pFormSplitHash ;  /* Formular data split up at \t */
 
206
    HV *    pInputHash ; /* Data of input fields */
 
207
    AV *    pFormArray ; /* Fieldnames */
 
208
    GV *    pFormArrayGV ; 
 
209
    HV *    pHeaderHash ;/* http headers */
 
210
    SV *    pReqRV ;       /* the request object global */
 
211
    SV *    pAppRV ;       /* the application object global */
 
212
    AV *    pParamArray ;
 
213
    GV *    pParamArrayGV ;
 
214
 
 
215
    } tThreadData ;
 
216
 
 
217
 
 
218
typedef struct tApp
 
219
    {
 
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 */
 
227
 
 
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 */
 
234
 
 
235
    int             nErrorsCount ;      /**< Number of errors */
 
236
    int             nErrorsLastTime ;   /**< Time last error has occured */
 
237
    int             nErrorsLastSendTime ;/**< Time last error was send via mail */
 
238
    
 
239
    } tApp ;
 
240
 
 
241
 
 
242
typedef struct tComponentOutput
 
243
    {
 
244
    SV *    _perlsv ;         /**< The perl reference to this structure */
 
245
    tMemPool *         pPool ;  /**< pool for memorymanagement */
 
246
 
 
247
    bool    bDisableOutput ;   /* no output is generated */
 
248
 
 
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 */
 
253
 
 
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 */
 
258
 
 
259
    int     nMarker ;               /*  Makers for rollback output */
 
260
 
 
261
    FILEIO *  ofd  ;                /* output file descriptor */
 
262
 
 
263
    SV *    ofdobj ;                /* perl object that is tied to stdout, if any */
 
264
    } tComponentOutput ;
 
265
 
 
266
 
 
267
 
 
268
struct tComponent
 
269
    {
 
270
    SV *    _perlsv ;         /**< The perl reference to this structure */
 
271
    tMemPool *         pPool ;  /**< pool for memorymanagement */
 
272
 
 
273
    tComponentConfig    Config ;    /**< request configuration data */
 
274
    tComponentParam     Param ;     /**< parameter passed to current request */
 
275
    tComponentOutput *  pOutput ;   /**< output channel for this component */
 
276
    tReq *              pReq ;
 
277
 
 
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 */
 
284
 
 
285
    bool    bEP1Compat ;        /* run in Embperl 1.x compatible mode */    
 
286
    int     nPhase ;            /* which phase of the request we are in */
 
287
 
 
288
    /* --- source --- */
 
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 */
 
296
 
 
297
 
 
298
    /* --- DomTree ---*/
 
299
 
 
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 */
 
306
 
 
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 */
 
310
 
 
311
    /* --- Escaping --- */
 
312
 
 
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 */
 
318
    
 
319
 
 
320
    /* --- i/o filehandles --- */
 
321
 
 
322
    FILEIO *  ifd  ;      /* input file */
 
323
    SV *    ifdobj ;    /* perl object that is tied to stdin, if any */
 
324
 
 
325
    bool    bAppendToMainReq ; /* append output to main request */
 
326
 
 
327
    /* ------------------------ */
 
328
 
 
329
    struct tComponent *  pPrev ;  /* Component from which this one is called */
 
330
 
 
331
    /* ------------------------ */
 
332
    
 
333
    /* --- more infos for eval --- */
 
334
 
 
335
    int  bStrict ; /* aply use strict in each eval */
 
336
 
 
337
    char op_mask_buf[MAXO + 100]; /* save buffer for opcode mask - maxo shouldn't differ from MAXO but leave room anyway (see BOOT:)    */
 
338
 
 
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 */
 
341
    HV *  pExportHash ;
 
342
 
 
343
 
 
344
    /* --- compiler --- */    
 
345
 
 
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 */
 
351
 
 
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 */
 
355
 
 
356
    SV *   pCodeSV ;            /* contains currently compiled line */
 
357
 
 
358
    }  ;
 
359
 
 
360
 
 
361
 
 
362
    
 
363
    
 
364
struct tReq
 
365
    {
 
366
    SV *    _perlsv ;         /**< The perl reference to this structure */
 
367
 
 
368
    tPerlInterpreter * pPerlTHX ;                  /* pointer to Perl interpreter */
 
369
    tMemPool *         pPool ;  /**< pool for memorymanagement */
 
370
 
 
371
    request_rec * pApacheReq ;  /* apache request record */
 
372
    SV *          pApacheReqSV ;
 
373
    tApacheDirConfig * pApacheConfig ;
 
374
  
 
375
    tReqConfig    Config ;    /**< request configuration data */
 
376
    tReqParam     Param ;     /**< request parameter data */
 
377
    tComponent    Component ;
 
378
    tApp *        pApp ;
 
379
    tThreadData * pThread ;
 
380
 
 
381
    int     nRequestCount ;     /**< increments by one on each request */
 
382
    time_t  nRequestTime ;      /**< time when request starts */
 
383
 
 
384
    int     nIOType ;
 
385
    
 
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 */
 
390
 
 
391
    int     bExit ;             /**< We should exit the request */
 
392
    long    nLogFileStartPos ;  /**< file position of logfile, when logfile started */
 
393
 
 
394
    int     bError  ;           /* Error has occured somewhere */
 
395
    AV *    pErrArray ;         /* Errors to show on Error response */
 
396
 
 
397
    char    errdat1 [ERRDATLEN] ; /* Additional error information */
 
398
    char    errdat2 [ERRDATLEN] ;
 
399
    char    lastwarn [ERRDATLEN] ; /* last warning */
 
400
 
 
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 */
 
404
 
 
405
    char *  sInitialCWD ;         /**< Reset directory to */
 
406
    
 
407
    AV *    pMessages ;
 
408
    AV *    pDefaultMessages ;
 
409
    
 
410
    /* --- for statistics --- */
 
411
 
 
412
    clock_t startclock ;
 
413
    I32     stsv_count ;
 
414
 
 
415
#if defined (_MDEBUG) && defined (WIN32)
 
416
    _CrtMemState MemCheckpoint ;             /* memory leak debugging */    
 
417
#endif    
 
418
 
 
419
#ifdef DMALLOC
 
420
    unsigned long MemCheckpoint ;             /* memory leak debugging */    
 
421
#endif    
 
422
    } ;
 
423
 
 
424
 
 
425
#endif