You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl-cvs@perl.apache.org by ri...@apache.org on 2002/01/25 08:04:32 UTC

cvs commit: embperl/Embperl Util.pm

richter     02/01/24 23:04:32

  Modified:    .        Tag: Embperl2c Embperl.pm Embperl.xs Old.xs ep.h
                        epdat2.h epinit.c epio.c epmain.c eppriv.h
                        eppublic.h
               Embperl  Tag: Embperl2c Util.pm
  Log:
  add output object
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.118.4.81 +15 -3     embperl/Embperl.pm
  
  Index: Embperl.pm
  ===================================================================
  RCS file: /home/cvs/embperl/Embperl.pm,v
  retrieving revision 1.118.4.80
  retrieving revision 1.118.4.81
  diff -u -r1.118.4.80 -r1.118.4.81
  --- Embperl.pm	24 Jan 2002 08:37:05 -0000	1.118.4.80
  +++ Embperl.pm	25 Jan 2002 07:04:30 -0000	1.118.4.81
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: Embperl.pm,v 1.118.4.80 2002/01/24 08:37:05 richter Exp $
  +#   $Id: Embperl.pm,v 1.118.4.81 2002/01/25 07:04:30 richter Exp $
   #
   ###################################################################################
   
  @@ -58,6 +58,8 @@
   
   1 ;
   
  +#######################################################################################
  +
   sub Execute
       
       {
  @@ -66,8 +68,7 @@
   
       local $SIG{__WARN__} = \&Warn ;
   
  -    my $r = Embperl::Req::RunRequest (undef, $param) ;
  -
  +    Embperl::Req::RunRequest (undef, $param) ;
       }
   
   #######################################################################################
  @@ -99,6 +100,17 @@
       { 
       eval 'use Apache::Constants qw(&OPT_EXECCGI &DECLINED &OK &FORBIDDEN)' ;
       die "use Apache::Constants failed: $@" if ($@); 
  +    }
  +
  +#######################################################################################
  +
  +sub ExecuteComponent
  +    
  +    {
  +    my $rc ;
  +    my $param = shift ;
  +
  +    Embperl::Req::RunComponent ($Embperl::req, $param) ;
       }
   
   #######################################################################################
  
  
  
  1.29.4.42 +6 -0      embperl/Embperl.xs
  
  Index: Embperl.xs
  ===================================================================
  RCS file: /home/cvs/embperl/Embperl.xs,v
  retrieving revision 1.29.4.41
  retrieving revision 1.29.4.42
  diff -u -r1.29.4.41 -r1.29.4.42
  --- Embperl.xs	24 Jan 2002 08:37:05 -0000	1.29.4.41
  +++ Embperl.xs	25 Jan 2002 07:04:30 -0000	1.29.4.42
  @@ -65,6 +65,12 @@
       RETVAL
   
   
  +int
  +embperl_RunComponent(pReq, pPerlParam)
  +    tReq * pReq;
  +    SV * pPerlParam
  +
  +
   
   INCLUDE: Old.xs
   
  
  
  
  1.1.2.4   +0 -8      embperl/Attic/Old.xs
  
  Index: Old.xs
  ===================================================================
  RCS file: /home/cvs/embperl/Attic/Old.xs,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- Old.xs	23 Jan 2002 15:09:00 -0000	1.1.2.3
  +++ Old.xs	25 Jan 2002 07:04:31 -0000	1.1.2.4
  @@ -21,14 +21,6 @@
       RETVAL
   
   
  -int
  -embperl_ResetHandler(pReqSV)
  -    SV * pReqSV
  -CODE:
  -    RETVAL = ResetHandler(pReqSV) ;
  -OUTPUT:
  -    RETVAL
  -
   
   
   #if defined (__GNUC__) && defined (__i386__)
  
  
  
  1.27.4.38 +1 -1      embperl/ep.h
  
  Index: ep.h
  ===================================================================
  RCS file: /home/cvs/embperl/ep.h,v
  retrieving revision 1.27.4.37
  retrieving revision 1.27.4.38
  diff -u -r1.27.4.37 -r1.27.4.38
  --- ep.h	18 Jan 2002 16:22:36 -0000	1.27.4.37
  +++ ep.h	25 Jan 2002 07:04:31 -0000	1.27.4.38
  @@ -326,7 +326,7 @@
   
   int OpenOutput (/*i/o*/ register req * r,
   			/*in*/ const char *  sFilename) ;
  -int CloseOutput (/*i/o*/ register req * r) ;
  +int CloseOutput (/*i/o*/ tReq *             r, tComponentOutput * pOutput) ;
   int owrite (/*i/o*/ register req * r,
   			/*in*/ const void * ptr, 
                           /*in*/ size_t size) ;
  
  
  
  1.1.2.16  +28 -20    embperl/Attic/epdat2.h
  
  Index: epdat2.h
  ===================================================================
  RCS file: /home/cvs/embperl/Attic/epdat2.h,v
  retrieving revision 1.1.2.15
  retrieving revision 1.1.2.16
  diff -u -r1.1.2.15 -r1.1.2.16
  --- epdat2.h	24 Jan 2002 08:37:05 -0000	1.1.2.15
  +++ epdat2.h	25 Jan 2002 07:04:31 -0000	1.1.2.16
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: epdat2.h,v 1.1.2.15 2002/01/24 08:37:05 richter Exp $
  +#   $Id: epdat2.h,v 1.1.2.16 2002/01/25 07:04:31 richter Exp $
   #
   ###################################################################################*/
   
  @@ -143,6 +143,7 @@
       char *  sSub ;            /* subroutine to call */
       int     nImport ;
       int     nFirstLine ;
  +    int     nMtime ;        /**< last modification time of pInput */
       } tComponentParam ;
   
   
  @@ -187,6 +188,31 @@
       } tApp ;
   
   
  +typedef struct tComponentOutput
  +    {
  +    SV *    _perlsv ;         /**< The perl reference to this structure */
  +    tMemPool *         pPool ;  /**< pool for memorymanagement */
  +
  +    bool    bDisableOutput ;   /* no output is generated */
  +
  +    struct tBuf *   pFirstBuf  ;    /* First buffer */
  +    struct tBuf *   pLastBuf   ;    /* Last written buffer */
  +    struct tBuf *   pFreeBuf   ;    /* List of unused buffers */
  +    struct tBuf *   pLastFreeBuf ;  /* End of list of unused buffers */
  +
  +    char *          pMemBuf ;	    /* temporary output */
  +    char *          pMemBufPtr ;    /* temporary output */
  +    size_t          nMemBufSize ;   /* size of pMemBuf */
  +    size_t          nMemBufSizeFree;/* remaining space in pMemBuf */
  +
  +    int     nMarker ;               /*  Makers for rollback output */
  +
  +    FILEIO *  ofd  ;                /* output file descriptor */
  +
  +    SV *    ofdobj ;	            /* perl object that is tied to stdout, if any */
  +    } tComponentOutput ;
  +
  +
   
   typedef struct tComponent
       {
  @@ -195,6 +221,7 @@
   
       tComponentConfig    Config ;    /**< request configuration data */
       tComponentParam     Param ;     /**< parameter passed to current request */
  +    tComponentOutput *  pOutput ;   /**< output channel for this component */
   
       bool    bReqRunning  ;	/* we are inside of a request */
       bool    bSubReq ;           /* This is a sub request (called inside an Embperl page) */
  @@ -245,35 +272,16 @@
       int                 bEscInUrl ;     /* we are inside an url */
       
   
  -    /* --- buffering output */
  -
  -    struct tBuf *   pFirstBuf  ;    /* First buffer */
  -    struct tBuf *   pLastBuf   ;    /* Last written buffer */
  -    struct tBuf *   pFreeBuf   ;    /* List of unused buffers */
  -    struct tBuf *   pLastFreeBuf ;  /* End of list of unused buffers */
  -
  -    char *          pMemBuf ;	    /* temporary output */
  -    char *          pMemBufPtr ;    /* temporary output */
  -    size_t          nMemBufSize ;   /* size of pMemBuf */
  -    size_t          nMemBufSizeFree;/* remaining space in pMemBuf */
  -
  -    int     nMarker ;               /*  Makers for rollback output */
  -
       /* --- i/o filehandles --- */
   
       FILEIO *  ifd  ;      /* input file */
  -    FILEIO *  ofd  ;      /* output file */
  -
  -    SV *    ofdobj ;	/* perl object that is tied to stdout, if any */
       SV *    ifdobj ;	/* perl object that is tied to stdin, if any */
   
       bool    bAppendToMainReq ; /* append output to main request */
  -    bool    bDisableOutput ;   /* no output is generated */
   
       /* ------------------------ */
   
       struct tComponent *  pPrev ;  /* Component from which this one is called */
  -    struct tComponent *  pOrg  ;  /* Original Component from which it is copied into the tReq object */
   
       /* ------------------------ */
       
  
  
  
  1.1.2.17  +131 -15   embperl/Attic/epinit.c
  
  Index: epinit.c
  ===================================================================
  RCS file: /home/cvs/embperl/Attic/epinit.c,v
  retrieving revision 1.1.2.16
  retrieving revision 1.1.2.17
  diff -u -r1.1.2.16 -r1.1.2.17
  --- epinit.c	24 Jan 2002 08:37:05 -0000	1.1.2.16
  +++ epinit.c	25 Jan 2002 07:04:31 -0000	1.1.2.17
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: epinit.c,v 1.1.2.16 2002/01/24 08:37:05 richter Exp $
  +#   $Id: epinit.c,v 1.1.2.17 2002/01/25 07:04:31 richter Exp $
   #
   ###################################################################################*/
   
  @@ -966,6 +966,45 @@
       }
       
   /*---------------------------------------------------------------------------
  +* embperl_CleanupOutput
  +*/
  +/*!
  +*
  +* \_en									   
  +* cleanup data for component output object
  +* \endif                                                                       
  +*
  +* \_de									   
  +* R�umt das Component-Ausgabe Objekt auf
  +* \endif                                                                       
  +*                                                                          
  +* ------------------------------------------------------------------------ */
  +
  +
  +
  +int    embperl_CleanupOutput   (/*in*/ tReq *                r,
  +                                /*in*/ tComponent *           c)
  +                     
  +                     
  +    {
  +    epTHX_
  +    tComponentOutput * pOutput = c -> pOutput ;
  +
  +    if (c -> pPrev && c -> pPrev -> pOutput == pOutput)
  +        { /* this component uses the main output object */
  +        return ok ;
  +        }
  +
  +    CloseOutput (r, pOutput) ;
  +
  +    SvREFCNT_dec (pOutput -> _perlsv) ;
  +    ep_destroy_pool (pOutput -> pPool) ;
  +
  +    return ok ;
  +    }
  +
  +    
  +/*---------------------------------------------------------------------------
   * embperl_CleanupComponent
   */
   /*!
  @@ -989,10 +1028,26 @@
       {
       epTHX_
   
  +    embperl_CleanupOutput (r, c) ;
  +
       SvREFCNT_dec (c -> Config._perlsv) ;
       SvREFCNT_dec (c -> Param._perlsv) ;
       SvREFCNT_dec (c -> _perlsv) ;
   
  +    if (c == &r -> Component && c -> pPrev)
  +        { /* we have a previous component, so let restore it */
  +        tComponent * pPrev = c -> pPrev;
  +        SV * pHV ;
  +
  +        memcpy (c, pPrev, sizeof (*c)) ;
  +        
  +	/* adjust pointer in perl magic */
  +        pHV = SvRV (c -> _perlsv) ;
  +	sv_unmagic (pHV, '~') ;
  +	sv_magic (pHV, NULL, '~', (char *)&pPrev, sizeof (pPrev)) ;
  +        }
  +   
  +    
       return ok ;
       }
   
  @@ -1017,9 +1072,7 @@
       {
       epTHX_
       int i ;
  -    SV *   psv ;
       HE *   pEntry ;
  -    char * pKey ;
       I32    l ;
       
       sv_setsv(r -> pThread -> pReqRV, &sv_undef) ;   
  @@ -1113,7 +1166,63 @@
       }
   
   
  -    
  +/*---------------------------------------------------------------------------
  +* embperl_SetupOutput
  +*/
  +/*!
  +*
  +* \_en									   
  +* setup data for component output object
  +* \endif                                                                       
  +*
  +* \_de									   
  +* Initialisiert das Component-Ausgabe Objekt
  +* \endif                                                                       
  +*                                                                          
  +* ------------------------------------------------------------------------ */
  +
  +
  +
  +int    embperl_SetupOutput     (/*in*/ tReq *                r,
  +                                /*in*/tComponent *           c)
  +                     
  +                     
  +    {
  +    epTHX_
  +    int          rc ;
  +    SV *         pSV ;
  +    SV *         pRV ;
  +    tComponentOutput * pOutput ;
  +    tMemPool * pPool  ;
  +
  +    if (!c -> Param.pOutput && !c -> Param.sOutputfile && c -> pPrev)
  +        { /* this component uses the main output object */
  +        c -> pOutput = c -> pPrev -> pOutput ;
  +        return ok ;
  +        }
  +
  +    pPool = ep_make_sub_pool (r -> pPool) ;
  +
  +    epxs_Embperl__Req_create_obj(pOutput,pSV,pRV,ep_palloc(pPool,sizeof(tComponentOutput))) ;
  +    pOutput -> pPool         = pPool ;
  +    c -> pOutput = pOutput ;
  +
  +    if (r -> Component.pImportStash)
  +	pOutput -> bDisableOutput = 1 ;
  +    else if (c -> Param.pOutput)
  +        {
  +        if ((rc = OpenOutput (r, "")) != ok)
  +            return rc ;
  +        }
  +    else
  +        {
  +        if ((rc = OpenOutput (r, c -> Param.sOutputfile)) != ok)
  +            return rc ;
  +        }
  +
  +    return ok ;
  +    }
  +
   
   /*---------------------------------------------------------------------------
   * embperl_SetupComponent
  @@ -1147,18 +1256,25 @@
       tComponentConfig * pConfig ;
       epTHX ;
   
  -#if 0
  -    epxs_Embperl__Component_create_obj(c,pComponentSV, pComponentRV,ep_palloc(r->pPool,sizeof(*c))) ;
   
  +    if (r -> Component._perlsv)
  +        { /* we have already a component, so let safe it first */
  +        tComponent * pPrev ;
  +        SV * pHV ;
   
  -    /* for performance reason we copy the actual component directly into the request object */
  -    c -> pPrev      = r -> Component.pOrg ;
  -    if (c -> pPrev)
  -        memcpy (c -> pPrev, &r -> Component, sizeof (*c -> pPrev)) ;
  -    c -> pOrg = c ;
  -    memcpy (&r -> Component, c, sizeof (r -> Component)) ;
  -#endif
  -    
  +        pPrev = ep_palloc(r->pPool,sizeof(*pPrev)) ;
  +
  +        memcpy (pPrev, &r -> Component, sizeof (*pPrev)) ;
  +        
  +        r -> Component.pPrev = pPrev ;
  +
  +	/* adjust pointer in perl magic */
  +        pHV = SvRV (pPrev -> _perlsv) ;
  +	sv_unmagic (pHV, '~') ;
  +	sv_magic (pHV, NULL, '~', (char *)&pPrev, sizeof (pPrev)) ;
  +        }
  +
  +   
       epxs_Embperl__Component_create_obj(c,pComponentSV, pComponentRV,&r->Component) ;
       epxs_Embperl__Component__Param_create_obj(pParam,pSV, pRV,&r->Component.Param) ;
       epxs_Embperl__Component__Config_create_obj(pConfig,pSV, pRV,&r->Component.Config) ;
  @@ -1216,7 +1332,7 @@
   
       *ppComponent = c ;
   
  -    return ok ;
  +    return embperl_SetupOutput (r, c) ;
       }
   
   
  
  
  
  1.16.4.8  +111 -116  embperl/epio.c
  
  Index: epio.c
  ===================================================================
  RCS file: /home/cvs/embperl/epio.c,v
  retrieving revision 1.16.4.7
  retrieving revision 1.16.4.8
  diff -u -r1.16.4.7 -r1.16.4.8
  --- epio.c	19 Jan 2002 14:13:41 -0000	1.16.4.7
  +++ epio.c	25 Jan 2002 07:04:31 -0000	1.16.4.8
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: epio.c,v 1.16.4.7 2002/01/19 14:13:41 richter Exp $
  +#   $Id: epio.c,v 1.16.4.8 2002/01/25 07:04:31 richter Exp $
   #
   ###################################################################################*/
   
  @@ -74,11 +74,11 @@
   struct tBuf *   oBegin (/*i/o*/ register req * r)
   
       {
  -    EPENTRY1N (oBegin, r -> Component.nMarker) ;
  +    EPENTRY1N (oBegin, r -> Component.pOutput -> nMarker) ;
       
  -    r -> Component.nMarker++ ;
  +    r -> Component.pOutput -> nMarker++ ;
       
  -    return r -> Component.pLastBuf ;
  +    return r -> Component.pOutput -> pLastBuf ;
       }
   
   /* -------------------------------------------------------------------------------------
  @@ -91,37 +91,37 @@
   			struct tBuf *   pBuf) 
   
       {
  -    EPENTRY1N (oRollback, r -> Component.nMarker) ;
  +    EPENTRY1N (oRollback, r -> Component.pOutput -> nMarker) ;
   
       if (pBuf == NULL)
           {
  -        if (r -> Component.pLastFreeBuf)
  -            r -> Component.pLastFreeBuf -> pNext = r -> Component.pFirstBuf ;
  +        if (r -> Component.pOutput -> pLastFreeBuf)
  +            r -> Component.pOutput -> pLastFreeBuf -> pNext = r -> Component.pOutput -> pFirstBuf ;
           else 
  -            r -> Component.pFreeBuf = r -> Component.pFirstBuf ;
  +            r -> Component.pOutput -> pFreeBuf = r -> Component.pOutput -> pFirstBuf ;
           
  -        r -> Component.pLastFreeBuf = r -> Component.pLastBuf ;
  +        r -> Component.pOutput -> pLastFreeBuf = r -> Component.pOutput -> pLastBuf ;
           
  -        r -> Component.pFirstBuf   = NULL ;
  -        r -> Component.nMarker     = 0 ;
  +        r -> Component.pOutput -> pFirstBuf   = NULL ;
  +        r -> Component.pOutput -> nMarker     = 0 ;
           }
       else
   	{
  -        if (r -> Component.pLastBuf == pBuf || pBuf -> pNext == NULL)
  -            r -> Component.nMarker-- ;
  +        if (r -> Component.pOutput -> pLastBuf == pBuf || pBuf -> pNext == NULL)
  +            r -> Component.pOutput -> nMarker-- ;
           else
               {
  -            r -> Component.nMarker = pBuf -> pNext -> nMarker - 1 ;
  -            if (r -> Component.pLastFreeBuf)
  -                r -> Component.pLastFreeBuf -> pNext = pBuf -> pNext ;
  +            r -> Component.pOutput -> nMarker = pBuf -> pNext -> nMarker - 1 ;
  +            if (r -> Component.pOutput -> pLastFreeBuf)
  +                r -> Component.pOutput -> pLastFreeBuf -> pNext = pBuf -> pNext ;
               else
  -                r -> Component.pFreeBuf = pBuf -> pNext ;
  -            r -> Component.pLastFreeBuf = r -> Component.pLastBuf ;
  +                r -> Component.pOutput -> pFreeBuf = pBuf -> pNext ;
  +            r -> Component.pOutput -> pLastFreeBuf = r -> Component.pOutput -> pLastBuf ;
               }
           pBuf -> pNext = NULL ;
           }
           
  -    r -> Component.pLastBuf = pBuf ;
  +    r -> Component.pOutput -> pLastBuf = pBuf ;
   
       }
   
  @@ -152,21 +152,21 @@
                      char *          pOut) 
   
       {
  -    EPENTRY1N (oCommit, r -> Component.nMarker) ;
  +    EPENTRY1N (oCommit, r -> Component.pOutput -> nMarker) ;
   
       
       if (pBuf == NULL)
  -        r -> Component.nMarker = 0 ;
  +        r -> Component.pOutput -> nMarker = 0 ;
       else
  -        if (r -> Component.pLastBuf == pBuf)
  -            r -> Component.nMarker-- ;
  +        if (r -> Component.pOutput -> pLastBuf == pBuf)
  +            r -> Component.pOutput -> nMarker-- ;
           else
  -            r -> Component.nMarker = pBuf -> pNext -> nMarker - 1 ;
  +            r -> Component.pOutput -> nMarker = pBuf -> pNext -> nMarker - 1 ;
       
  -    if (r -> Component.nMarker == 0)
  +    if (r -> Component.pOutput -> nMarker == 0)
           {
           if (pBuf == NULL)
  -            pBuf = r -> Component.pFirstBuf ;
  +            pBuf = r -> Component.pOutput -> pFirstBuf ;
           else
               pBuf = pBuf -> pNext ;
           
  @@ -203,7 +203,7 @@
   		      struct tBuf *   pBuf) 
   
       {
  -    EPENTRY1N (oCommit, r -> Component.nMarker) ;
  +    EPENTRY1N (oCommit, r -> Component.pOutput -> nMarker) ;
   
       oCommitToMem (r, pBuf, NULL) ;
       }
  @@ -213,7 +213,7 @@
   /* write to a buffer                                                            */
   /*                                                                              */
   /* we will alloc a new buffer for every write                                   */
  -/* this is fast with apache palloc or for malloc if no free is call in between  */
  +/* this is fast with ep_palloc                                                  */
   /*                                                                              */
   /* ---------------------------------------------------------------------------- */
   
  @@ -225,9 +225,9 @@
       {
       struct tBuf * pBuf ;
   
  -    EPENTRY1N (bufwrite, r -> Component.nMarker) ;
  +    EPENTRY1N (bufwrite, r -> Component.pOutput -> nMarker) ;
   
  -    pBuf = (struct tBuf *)_malloc (r, size + sizeof (struct tBuf)) ;
  +    pBuf = (struct tBuf *)ep_palloc (r -> Component.pOutput -> pPool, size + sizeof (struct tBuf)) ;
   
       if (pBuf == NULL)
           return 0 ;
  @@ -235,25 +235,25 @@
       memcpy (pBuf + 1,  ptr, size) ;
       pBuf -> pNext   = NULL ;
       pBuf -> nSize   = size ;
  -    pBuf -> nMarker = r -> Component.nMarker ;
  +    pBuf -> nMarker = r -> Component.pOutput -> nMarker ;
   
  -    if (r -> Component.pLastBuf)
  +    if (r -> Component.pOutput -> pLastBuf)
           {
  -        r -> Component.pLastBuf -> pNext = pBuf ;
  -        pBuf -> nCount    = r -> Component.pLastBuf -> nCount + size ;
  +        r -> Component.pOutput -> pLastBuf -> pNext = pBuf ;
  +        pBuf -> nCount    = r -> Component.pOutput -> pLastBuf -> nCount + size ;
           }
       else
           pBuf -> nCount    = size ;
           
  -    if (r -> Component.pFirstBuf == NULL)
  -        r -> Component.pFirstBuf = pBuf ;
  -    r -> Component.pLastBuf = pBuf ;
  +    if (r -> Component.pOutput -> pFirstBuf == NULL)
  +        r -> Component.pOutput -> pFirstBuf = pBuf ;
  +    r -> Component.pOutput -> pLastBuf = pBuf ;
   
   
       return size ;
       }
   
  -
  +#if 0
   /* ---------------------------------------------------------------------------- */
   /*                                                                              */
   /* free buffers                                                                 */
  @@ -274,17 +274,17 @@
   #ifdef APACHE
       if ((r -> Component.Config.bDebug & dbgMem) == 0 && pAllocReq != NULL)
           {
  -        r -> Component.pFirstBuf    = NULL ;
  -        r -> Component.pLastBuf     = NULL ;
  -        r -> Component.pFreeBuf     = NULL ;
  -        r -> Component.pLastFreeBuf = NULL ;
  +        r -> Component.pOutput -> pFirstBuf    = NULL ;
  +        r -> Component.pOutput -> pLastBuf     = NULL ;
  +        r -> Component.pOutput -> pFreeBuf     = NULL ;
  +        r -> Component.pOutput -> pLastFreeBuf = NULL ;
           return ; /* no need for apache to free memory */
           }
   #endif
           
       /* first walk thru the used buffers */
   
  -    pBuf = r -> Component.pFirstBuf ;
  +    pBuf = r -> Component.pOutput -> pFirstBuf ;
       while (pBuf)
           {
           pNext = pBuf -> pNext ;
  @@ -292,13 +292,13 @@
           pBuf = pNext ;
           }
   
  -    r -> Component.pFirstBuf = NULL ;
  -    r -> Component.pLastBuf  = NULL ;
  +    r -> Component.pOutput -> pFirstBuf = NULL ;
  +    r -> Component.pOutput -> pLastBuf  = NULL ;
   
   
       /* now walk thru the unused buffers */
       
  -    pBuf = r -> Component.pFreeBuf ;
  +    pBuf = r -> Component.pOutput -> pFreeBuf ;
       while (pBuf)
           {
           pNext = pBuf -> pNext ;
  @@ -306,9 +306,10 @@
           pBuf = pNext ;
           }
   
  -    r -> Component.pFreeBuf = NULL ;
  -    r -> Component.pLastFreeBuf  = NULL ;
  +    r -> Component.pOutput -> pFreeBuf = NULL ;
  +    r -> Component.pOutput -> pLastFreeBuf  = NULL ;
       }
  +#endif
   
   /* ---------------------------------------------------------------------------- */
   /*                                                                              */
  @@ -318,8 +319,8 @@
   
   int GetContentLength (/*i/o*/ register req * r)
       {
  -    if (r -> Component.pLastBuf)
  -        return r -> Component.pLastBuf -> nCount ;
  +    if (r -> Component.pOutput -> pLastBuf)
  +        return r -> Component.pOutput -> pLastBuf -> nCount ;
       else
           return 0 ;
       
  @@ -650,20 +651,20 @@
       GV *handle ;
       epTHX ;
       
  -    r -> Component.pFirstBuf = NULL ; 
  -    r -> Component.pLastBuf  = NULL ; 
  -    r -> Component.nMarker   = 0 ;
  -    r -> Component.pMemBuf   = NULL ;
  -    r -> Component.nMemBufSize = 0 ;
  -    r -> Component.pFreeBuf     = NULL ;
  -    r -> Component.pLastFreeBuf = NULL ;
  +    r -> Component.pOutput -> pFirstBuf = NULL ; 
  +    r -> Component.pOutput -> pLastBuf  = NULL ; 
  +    r -> Component.pOutput -> nMarker   = 0 ;
  +    r -> Component.pOutput -> pMemBuf   = NULL ;
  +    r -> Component.pOutput -> nMemBufSize = 0 ;
  +    r -> Component.pOutput -> pFreeBuf     = NULL ;
  +    r -> Component.pOutput -> pLastFreeBuf = NULL ;
   
   
       
  -    if (r -> Component.ofd && r -> Component.ofd != PerlIO_stdoutF)
  -        PerlIO_close (r -> Component.ofd) ;
  +    if (r -> Component.pOutput -> ofd && r -> Component.pOutput -> ofd != PerlIO_stdoutF)
  +        PerlIO_close (r -> Component.pOutput -> ofd) ;
   
  -    r -> Component.ofd = NULL ;
  +    r -> Component.pOutput -> ofd = NULL ;
   
       if (sFilename == NULL || *sFilename == '\0')
           {
  @@ -679,7 +680,7 @@
   	handle = gv_fetchpv("STDOUT", TRUE, SVt_PVIO) ;
   	if (handle && SvMAGICAL(handle) && (mg = mg_find((SV*)handle, 'q')) && mg->mg_obj) 
   	    {
  -	    r -> Component.ofdobj = mg->mg_obj ;
  +	    r -> Component.pOutput -> ofdobj = mg->mg_obj ;
   	    if (r -> Component.Config.bDebug)
   		{
   		char *package = HvNAME(SvSTASH((SV*)SvRV(mg->mg_obj)));
  @@ -688,7 +689,7 @@
   	    return ok ;
   	    }
   	
  -	r -> Component.ofd = PerlIO_stdoutF ;
  +	r -> Component.pOutput -> ofd = PerlIO_stdoutF ;
           
           if (r -> Component.Config.bDebug)
               {
  @@ -706,9 +707,9 @@
           lprintf (r -> pApp,  "[%d]Open %s for output...\n", r -> pThread -> nPid, sFilename) ;
   
   #ifdef WIN32
  -    if ((r -> Component.ofd = PerlIO_open (sFilename, "wb")) == NULL)
  +    if ((r -> Component.pOutput -> ofd = PerlIO_open (sFilename, "wb")) == NULL)
   #else
  -    if ((r -> Component.ofd = PerlIO_open (sFilename, "w")) == NULL)
  +    if ((r -> Component.pOutput -> ofd = PerlIO_open (sFilename, "w")) == NULL)
   #endif        
           {
           strncpy (r -> errdat1, sFilename, sizeof (r -> errdat1) - 1) ;
  @@ -727,40 +728,32 @@
   /* ---------------------------------------------------------------------------- */
   
   
  -int CloseOutput (/*i/o*/ register req * r)
  +int CloseOutput (/*in*/ tReq *             r,
  +                        tComponentOutput * pOutput)
   
       {
       epTHX ;
       
  -    /* make sure all buffers are freed */
  -
  -    buffree (r) ; 
  -
  -/* #if defined (APACHE)
  -    if (r -> pApacheReq)
  -        return ok ;
  -  #endif */
  -
   #if 0
  -    if (0) /* r -> Component.ofdobj) */
  +    if (0) /* r -> Component.pOutput -> ofdobj) */
   	{	    
   	dSP;
   	ENTER;
   	SAVETMPS;
   	PUSHMARK(sp);
  -	XPUSHs(r -> Component.ifdobj);
  +	XPUSHs(pOutput -> ofdobj);
   	PUTBACK;
   	perl_call_method ("CLOSE", G_VOID | G_EVAL) ; 
   	FREETMPS;
   	LEAVE;
  -	r -> Component.ofdobj = NULL ;
  +	pOutput -> ofdobj = NULL ;
   	}
   #endif
   
  -    if (r -> Component.ofd && r -> Component.ofd != PerlIO_stdoutF)
  -        PerlIO_close (r -> Component.ofd) ;
  +    if (pOutput -> ofd && pOutput -> ofd != PerlIO_stdoutF)
  +        PerlIO_close (pOutput -> ofd) ;
   
  -    r -> Component.ofd = NULL ;
  +    pOutput -> ofd = NULL ;
   
       return ok ;
       }
  @@ -780,13 +773,13 @@
   
       {
       if (pBuf == NULL)
  -	pBuf = _malloc (r, nBufSize) ;
  +	pBuf = ep_palloc (r -> Component.pOutput -> pPool, nBufSize) ;
   
       *pBuf = '\0' ;
  -    r -> Component.pMemBuf	 = pBuf ;
  -    r -> Component.pMemBufPtr      = pBuf ;
  -    r -> Component.nMemBufSize     = nBufSize ;
  -    r -> Component.nMemBufSizeFree = nBufSize ;
  +    r -> Component.pOutput -> pMemBuf	 = pBuf ;
  +    r -> Component.pOutput -> pMemBufPtr      = pBuf ;
  +    r -> Component.pOutput -> nMemBufSize     = nBufSize ;
  +    r -> Component.pOutput -> nMemBufSizeFree = nBufSize ;
       }
   
   
  @@ -800,10 +793,10 @@
   char * OutputToStd (/*i/o*/ register req * r)
   
       {
  -    char * p = r -> Component.pMemBuf ;
  -    r -> Component.pMemBuf         = NULL ;
  -    r -> Component.nMemBufSize     = 0 ;
  -    r -> Component.nMemBufSizeFree = 0 ;
  +    char * p = r -> Component.pOutput -> pMemBuf ;
  +    r -> Component.pOutput -> pMemBuf         = NULL ;
  +    r -> Component.pOutput -> nMemBufSize     = 0 ;
  +    r -> Component.pOutput -> nMemBufSizeFree = 0 ;
       return p ;
       }
   
  @@ -836,51 +829,53 @@
       size_t n = size ;
       epTHX ;
   
  -    if (n == 0 || r -> Component.bDisableOutput)
  +    if (n == 0 || r -> Component.pOutput -> bDisableOutput)
           return 0 ;
   
  -    if (r -> Component.pMemBuf)
  +    if (r -> Component.pOutput -> pMemBuf)
           {
           char * p ;
  -        size_t s = r -> Component.nMemBufSize ;
  -        if (n >= r -> Component.nMemBufSizeFree)
  +        size_t s = r -> Component.pOutput -> nMemBufSize ;
  +        if (n >= r -> Component.pOutput -> nMemBufSizeFree)
               {
               size_t oldsize = s ;
               if (s < n)
  -                s = n + r -> Component.nMemBufSize ;
  +                s = n + r -> Component.pOutput -> nMemBufSize ;
               
  -            r -> Component.nMemBufSize      += s ;
  -            r -> Component.nMemBufSizeFree  += s ;
  +            r -> Component.pOutput -> nMemBufSize      += s ;
  +            r -> Component.pOutput -> nMemBufSizeFree  += s ;
               /*lprintf (r -> pApp,  "[%d]MEM:  Realloc pMemBuf, nMemSize = %d\n", nPid, nMemBufSize) ; */
  -            p = _realloc (r, r -> Component.pMemBuf, oldsize, r -> Component.nMemBufSize) ;
  +            
  +            p = ep_palloc (r -> Component.pOutput -> pPool, r -> Component.pOutput -> nMemBufSize) ;
               if (p == NULL)
                   {
  -                r -> Component.nMemBufSize      -= s ;
  -                r -> Component.nMemBufSizeFree  -= s ;
  +                r -> Component.pOutput -> nMemBufSize      -= s ;
  +                r -> Component.pOutput -> nMemBufSizeFree  -= s ;
                   return 0 ;
                   }
  -            r -> Component.pMemBufPtr = p + (r -> Component.pMemBufPtr - r -> Component.pMemBuf) ;
  -            r -> Component.pMemBuf = p ;
  +            memcpy (p, r -> Component.pOutput -> pMemBuf, oldsize) ;
  +            r -> Component.pOutput -> pMemBufPtr = p + (r -> Component.pOutput -> pMemBufPtr - r -> Component.pOutput -> pMemBuf) ;
  +            r -> Component.pOutput -> pMemBuf = p ;
               }
                   
  -        memcpy (r -> Component.pMemBufPtr, ptr, n) ;
  -        r -> Component.pMemBufPtr += n ;
  -        *(r -> Component.pMemBufPtr) = '\0' ;
  -        r -> Component.nMemBufSizeFree -= n ;
  +        memcpy (r -> Component.pOutput -> pMemBufPtr, ptr, n) ;
  +        r -> Component.pOutput -> pMemBufPtr += n ;
  +        *(r -> Component.pOutput -> pMemBufPtr) = '\0' ;
  +        r -> Component.pOutput -> nMemBufSizeFree -= n ;
           return n ;
           }
   
       
  -    if (r -> Component.nMarker)
  +    if (r -> Component.pOutput -> nMarker)
           return bufwrite (r, ptr, n) ;
   
  -    if (r -> Component.ofdobj)
  +    if (r -> Component.pOutput -> ofdobj)
   	{	    
   	dSP;
   	ENTER;
   	SAVETMPS;
   	PUSHMARK(sp);
  -	XPUSHs(r -> Component.ofdobj);
  +	XPUSHs(r -> Component.pOutput -> ofdobj);
   	XPUSHs(sv_2mortal(newSVpv((char *)ptr,size)));
   	PUTBACK;
   	perl_call_method ("PRINT", G_SCALAR) ; 
  @@ -891,7 +886,7 @@
   
   
   #if defined (APACHE)
  -    if (r -> pApacheReq && r -> Component.ofd == NULL)
  +    if (r -> pApacheReq && r -> Component.pOutput -> ofd == NULL)
           {
           if (n > 0)
               {
  @@ -904,12 +899,12 @@
               return 0 ;
           }
   #endif
  -    if (n > 0)
  +    if (n > 0 && r -> Component.pOutput -> ofd)
           {
  -        n = PerlIO_write (r -> Component.ofd, (void *)ptr, size) ;
  +        n = PerlIO_write (r -> Component.pOutput -> ofd, (void *)ptr, size) ;
   
           if (r -> Component.Config.bDebug & dbgFlushOutput)
  -            PerlIO_flush (r -> Component.ofd) ;
  +            PerlIO_flush (r -> Component.pOutput -> ofd) ;
           }
   
       return n ;
  @@ -930,14 +925,14 @@
       {
       epTHX ;
       
  -    if (r -> Component.nMarker || r -> Component.pMemBuf || r -> Component.ofdobj)
  +    if (r -> Component.pOutput -> nMarker || r -> Component.pOutput -> pMemBuf || r -> Component.pOutput -> ofdobj)
           {
           owrite (r, &c, 1) ;
           return ;
           }
   
   #if defined (APACHE)
  -    if (r -> pApacheReq && r -> Component.ofd == NULL)
  +    if (r -> pApacheReq && r -> Component.pOutput -> ofd == NULL)
           {
           rputc (c, r -> pApacheReq) ;
           if (r -> Component.Config.bDebug & dbgFlushOutput)
  @@ -945,10 +940,10 @@
           return ;
           }
   #endif
  -    PerlIO_putc (r -> Component.ofd, c) ;
  +    PerlIO_putc (r -> Component.pOutput -> ofd, c) ;
   
       if (r -> Component.Config.bDebug & dbgFlushOutput)
  -        PerlIO_flush (r -> Component.ofd) ;
  +        PerlIO_flush (r -> Component.pOutput -> ofd) ;
       }
   
   
  
  
  
  1.75.4.90 +130 -948  embperl/epmain.c
  
  Index: epmain.c
  ===================================================================
  RCS file: /home/cvs/embperl/epmain.c,v
  retrieving revision 1.75.4.89
  retrieving revision 1.75.4.90
  diff -u -r1.75.4.89 -r1.75.4.90
  --- epmain.c	23 Jan 2002 15:09:00 -0000	1.75.4.89
  +++ epmain.c	25 Jan 2002 07:04:31 -0000	1.75.4.90
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: epmain.c,v 1.75.4.89 2002/01/23 15:09:00 richter Exp $
  +#   $Id: epmain.c,v 1.75.4.90 2002/01/25 07:04:31 richter Exp $
   #
   ###################################################################################*/
   
  @@ -385,41 +385,6 @@
       }
   
   
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* clean up embperl module                                                      */
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -int Term ()
  -
  -    {
  -#if 0
  -    dTHX ;
  -    req * r = CurrReq ;
  -
  -    EPENTRY (iembperl_term) ;
  -    
  -    if (!bInitDone)
  -        return ok ; 
  -
  -    CloseLog (r->pApp) ;
  -    CloseOutput (r) ;
  -#endif    
  -    return ok ;
  -    }
  -
  -
  -
  -int ResetHandler (/*in*/ SV * pApacheReqSV)
  -    {
  -#ifdef APACHE
  -    request_rec * pReq = (request_rec *)SvIV((SV*)SvRV(pApacheReqSV));
  -    pReq -> handler = NULL ;
  -#endif
  -
  -    return ok ;
  -    }
   
   
   /* ---------------------------------------------------------------------------- */
  @@ -467,428 +432,6 @@
           }
       }
   
  -#if 0
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Setup Configuration specficy data                                            */
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -
  -tConf * SetupConfData   (/*in*/ HV *   pReqInfo,
  -                         /*in*/ SV *   pOpcodeMask)
  -
  -    {
  -#ifdef EP2
  -    SV * *   ppSV ;
  -    SV *     pSV ;
  -    SV * *   ppCV ;
  -    int	     rc ;
  -#endif
  -
  -    tConf *  pConf = malloc (sizeof (tConf)) ;
  -    
  -    tainted = 0 ;
  -
  -    if (!pConf)
  -        return NULL ;
  -
  -    pConf -> bDebug =	    GetHashValueUInt (pReqInfo, "debug", pCurrReq -> pConf?pCurrReq -> pConf -> bDebug:CurrComponent -> Config.bDebug) ;	    /* Debugging options */
  -    pConf -> bOptions =	    GetHashValueUInt (pReqInfo, "options",  pCurrReq -> pConf?pCurrReq -> pConf -> bOptions:CurrComponent -> Config.bOptions) ;  /* Options */
  -    pConf -> nEscMode =	    GetHashValueInt (pReqInfo, "escmode",  pCurrReq -> pConf?pCurrReq -> pConf -> nEscMode:escStd) ;  /* EscMode */
  -    pConf -> sPackage =	    sstrdup (GetHashValueStr (pReqInfo, "package", NULL)) ;         /* Packagename */
  -    pConf -> sLogFilename = sstrdup (GetHashValueStr (pReqInfo, "log",  NULL)) ;            /* name of logfile */
  -    pConf -> sVirtLogURI  = sstrdup (GetHashValueStr (pReqInfo, "virtlog",  pCurrReq -> pConf?pCurrReq -> pConf -> sVirtLogURI:NULL)) ;        /* name of logfile */
  -    pConf -> pOpcodeMask  = pOpcodeMask ;                                                   /* Opcode mask (if any) */
  -    pConf -> sCookieName  = sstrdup (GetHashValueStr (pReqInfo, "cookie_name",  sCookieNameDefault))  ;   /* Name to use for cookie */
  -    pConf -> sCookieExpires = sstrdup (GetHashValueStr (pReqInfo, "cookie_expires",  ""))  ; /* cookie expiration time */
  -    pConf -> sCookieDomain = sstrdup (GetHashValueStr (pReqInfo, "cookie_domain",  "")) ; ; /* domain patter for which the cookie should be returned */
  -    pConf -> sCookiePath   = sstrdup (GetHashValueStr (pReqInfo, "cookie_path",  "")) ; ;   /* path to which cookie should be returned */
  -    pConf -> cMultFieldSep = '\t' ;
  -    pConf -> pOpenBracket  = "[*" ;
  -    pConf -> pCloseBracket = "*]" ;
  -    pConf -> sPath         = sstrdup (GetHashValueStr (pReqInfo, "path",  pCurrReq -> pConf?pCurrReq -> pConf -> sPath:NULL)) ;        /* file search path */
  -    pConf -> sReqFilename  = sstrdup (GetHashValueStr (pReqInfo, "reqfilename",  pCurrReq -> pConf?pCurrReq -> pConf -> sReqFilename:NULL)) ;        /* filename of original request */
  -    pConf -> pReqParameter = pReqInfo ;
  -    pConf -> nSessionMode  =	    GetHashValueInt (pReqInfo, "session_mode",  pCurrReq -> pConf?pCurrReq -> pConf -> nSessionMode:smodeStd) ;
  -
  -#ifdef EP2
  -    pConf -> sRecipe =	    sstrdup (GetHashValueStr (pReqInfo, "recipe", "Embperl")) ;         /* Recipe name */
  -    pConf -> bEP1Compat	    = GetHashValueInt (pReqInfo, "ep1compat",  pCurrReq -> pConf?pCurrReq -> pConf -> bEP1Compat:pCurrReq -> bEP1Compat) ;  /* EP1Compat */
  -
  -    pConf -> sCacheKey	    = sstrdup (GetHashValueStr (pReqInfo, "cache_key",  pCurrReq -> pConf?pCurrReq -> pConf -> sCacheKey:NULL)) ; ;
  -    pConf -> bCacheKeyOptions = GetHashValueInt (pReqInfo, "cache_key_options",  pCurrReq -> pConf?pCurrReq -> pConf -> bCacheKeyOptions:ckoptDefault) ;  
  -
  -    ppCV			    =     hv_fetch(pReqInfo, "expires_func", sizeof ("expires_func") - 1, 0) ;  
  -    if (ppCV && *ppCV && SvOK (*ppCV))
  -	{
  -	if ((rc = EvalConfig (pCurrReq, *ppCV, 0, NULL, &pConf -> pExpiresCV)) != ok)
  -	    LogError (pCurrReq, rc) ;
  -	}
  -    else
  -	pConf -> pExpiresCV     =  pCurrReq -> pConf?pCurrReq -> pConf -> pExpiresCV:NULL ;
  -    
  -
  -    ppCV			    =     hv_fetch(pReqInfo, "cache_key_func", sizeof ("cache_key_func") - 1, 0) ;  
  -    if (ppCV && *ppCV && SvOK (*ppCV))
  -	{
  -	if ((rc = EvalConfig (pCurrReq, *ppCV, 0, NULL, &pConf -> pCacheKeyCV)) != ok)
  -	    LogError (pCurrReq, rc) ;
  -	}
  -    else
  -	pConf -> pCacheKeyCV     =  pCurrReq -> pConf?pCurrReq -> pConf -> pCacheKeyCV:NULL ;
  -    
  -    pConf -> nExpiresIn	    = GetHashValueInt (pReqInfo, "expires_in",  pCurrReq -> pConf?pCurrReq -> pConf -> nExpiresIn:0) ;  
  -#endif
  -
  -
  -    return pConf ;
  -    }
  -
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Free Configuration specficy data                                             */
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -
  -void FreeConfData       (/*in*/ tConf *   pConf)
  -
  -    {
  -    if (!pConf)
  -        return ;
  -
  -    if (pConf -> sPackage)
  -        free (pConf -> sPackage) ;
  -    
  -    if (pConf -> sLogFilename)
  -        free (pConf -> sLogFilename) ;
  -
  -    if (pConf -> sVirtLogURI)
  -        free (pConf -> sVirtLogURI) ;
  -
  -    if (pConf -> sCookieName)
  -	free (pConf -> sCookieName) ;
  -
  -    if (pConf -> sCookieExpires)
  -	free (pConf -> sCookieExpires) ;
  -
  -    if (pConf -> sCookieDomain)
  -	free (pConf -> sCookieDomain) ;
  -
  -    if (pConf -> sCookiePath)
  -	free (pConf -> sCookiePath) ;
  -
  -    if (pConf -> sPath)
  -	free (pConf -> sPath) ;
  -
  -    if (pConf -> sReqFilename)
  -	free (pConf -> sReqFilename) ;
  -
  -#ifdef EP2
  -    if (pConf -> sRecipe)
  -	free (pConf -> sRecipe) ;
  - 
  -    if (pConf -> sCacheKey)
  -	free (pConf -> sCacheKey) ;
  - 
  -    if (pConf -> pCacheKeyCV)
  -	SvREFCNT_dec (pConf -> pCacheKeyCV) ;
  -
  -    if (pConf -> pExpiresCV)
  -	SvREFCNT_dec (pConf -> pExpiresCV) ;
  -#endif
  -
  -    free (pConf) ;
  -    }
  -
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Setup File specficy data                                                     */
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -
  -tFile * SetupFileData   (/*i/o*/ register req * r,
  -                         /*in*/  char *  sSourcefile,
  -                         /*in*/  double  mtime,
  -                         /*in*/  long    nFilesize,
  -                         /*in*/  int     nFirstLine,
  -                         /*in*/  tConf * pConf)
  -
  -    {
  -    SV * *      ppSV ;
  -    tFile *     f ;
  -    char	txt [sizeof (sDefaultPackageName) + 50] ;
  -    char *	cache_key;
  -    int		cache_key_len;
  -    char olddir[PATH_MAX] = "" ;
  -    char *      pNew ;
  -
  -    EPENTRY (SetupFileData) ;
  -
  -    tainted = 0 ;
  -
  -    /* Have we seen this sourcefile/package already ? */
  -    cache_key_len = strlen( sSourcefile ) ;
  -    if ( pConf->sPackage )
  -	cache_key_len += strlen( pConf->sPackage );
  -    
  -    /* is it a relativ filename? -> append path */
  -    if (!(sSourcefile[0] == '/' || 
  -          sSourcefile[0] == '\\' || 
  -          (isalpha(sSourcefile[0]) && sSourcefile[1] == ':' && 
  -	          (sSourcefile[2] == '\\' || sSourcefile[2] == '/')) ||
  -	    (r -> Component.Param.pInput && SvROK(r -> Component.Param.pInput))))
  -        getcwd (olddir, sizeof (olddir) - 1) ;
  -
  -    if ( olddir[0] )
  -	cache_key_len += strlen( olddir );
  -        
  -    cache_key = _malloc( r, cache_key_len + 5 );
  -    cache_key_len += 2 ;
  -    strcpy( cache_key, "--" );
  -    strcat( cache_key, sSourcefile );
  -    if ( pConf->sPackage )
  -	strcat( cache_key, pConf->sPackage );
  -
  -    if ( olddir[0] )
  -	strcat( cache_key, olddir );
  -
  -
  -#ifdef EP2
  -    if ( pConf->bEP1Compat && !pConf->sPackage )
  -	{
  -	strcat( cache_key, "-1" ); /* make sure Embperl 1.x compatible files get another namespace */
  -	cache_key_len += 2 ;
  -	}
  -#endif
  -
  -    ppSV = hv_fetch(pCacheHash, cache_key, cache_key_len, 0);  
  -    
  -    if (ppSV && *ppSV)
  -        {
  -        f = (tFile *)SvIV((SV*)SvRV(*ppSV)) ;
  -        
  -        if (mtime == 0 || f -> mtime != mtime)
  -            {
  -            hv_clear (f -> pCacheHash) ;
  -
  -            if (r -> Component.Config.bDebug)
  -                lprintf (r -> pApp,  "[%d]MEM: Reload %s in %s\n", r -> pThread -> nPid,  sSourcefile, f -> sCurrPackage) ;
  -#ifdef EP2	
  -	    UndefSub (r, f -> sMainSub, f -> sCurrPackage) ;
  -#endif
  -
  -            f -> mtime       = mtime ;	 /* last modification time of file */
  -            f -> nFilesize   = nFilesize ;	 /* size of File */
  -	    f -> bKeep       = (r -> Component.Config.bOptions & optKeepSrcInMemory) != 0 ;
  -	    f -> nFirstLine  = nFirstLine ;
  -	    if (f -> pExportHash)
  -		{
  -		SvREFCNT_dec (f -> pExportHash) ;
  -		f -> pExportHash = NULL ;
  -		}
  -	    if (f -> pBufSV)
  -		{
  -		SvREFCNT_dec (f -> pBufSV) ;
  -		f -> pBufSV = NULL ;
  -		}
  -	    }
  -        pNew = "Found" ;
  -        }
  -    else
  -        { /* create new file structure */
  -        if ((f = malloc (sizeof (*f))) == NULL)
  -	    {
  -	    _free(r,cache_key);
  -            return NULL ;
  -	    }
  -
  -        f -> sSourcefile = sstrdup (sSourcefile) ; /* Name of sourcefile */
  -        f -> mtime       = mtime ;	 /* last modification time of file */
  -        f -> nFilesize   = nFilesize ;	 /* size of File */
  -	f -> pBufSV      = NULL ;
  -	f -> pNext2Free  = NULL ;
  -	f -> bKeep       = (r -> Component.Config.bOptions & optKeepSrcInMemory) != 0;
  -	f -> pExportHash = NULL ;
  -	f -> nFirstLine  = nFirstLine ;
  -
  -        f -> pCacheHash  = newHV () ;    /* Hash containing CVs to precompiled subs */
  -
  -        if (pConf -> sPackage)
  -            f -> sCurrPackage = strdup (pConf -> sPackage) ; /* Package of file  */
  -        else
  -            {
  -            sprintf (txt, sDefaultPackageName, nPackNo ) ;
  -            f -> sCurrPackage = strdup (txt) ; /* Package of file  */
  -            }
  -        sprintf (txt, sDefaultSubName, nPackNo ) ;
  -        f -> sMainSub = strdup (txt) ; /* Package of file  */
  -        nPackNo++ ;
  -        f -> nCurrPackage = strlen (f -> sCurrPackage); /* Package of file (length) */
  -
  -        hv_store(pCacheHash, cache_key, cache_key_len, newRV_noinc (newSViv ((IV)f)), 0) ;  
  -    
  -        if (r -> Component.Config.bDebug)
  -            lprintf (r -> pApp,  "[%d]MEM: Load %s in %s\n", r -> pThread -> nPid,  sSourcefile, f -> sCurrPackage) ;
  -        pNew = "New" ;
  -        }
  -    if (r -> Component.Config.bDebug)
  -        lprintf (r -> pApp,  "[%d]CACHE: %s File for '%s' (%x) in '%s' hash cache-key '%s'\n", r -> pThread -> nPid,  pNew, f -> sSourcefile, f, f -> sCurrPackage, cache_key) ;
  -    
  -    _free(r,cache_key);
  -
  -    return f ;
  -    }
  -
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Get file data from filename; preset if not present                           */
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -
  -tFile * GetFileData     (/*in*/  char *  sSourcefile,
  -                         /*in*/  char *  sPackage,
  -			 /*in*/  double  mtime,
  -			 /*in*/  int     bEP1Compat)
  -                        
  -    {
  -    SV * *      ppSV ;
  -    tFile *     f ;
  -    char	txt [sizeof (sDefaultPackageName) + 50] ;
  -    char *	cache_key;
  -    int		cache_key_len;
  -    char olddir[PATH_MAX] = "" ;
  -    char *      pNew ;
  -    
  -    EPENTRY (GetFileData) ;
  -
  -    /* Have we seen this sourcefile/package already ? */
  -    cache_key_len = strlen( sSourcefile ) ;
  -    if ( sPackage && *sPackage)
  -	cache_key_len += strlen( sPackage );
  -    
  -    /* is it a relativ filename? -> append path */
  -    if (!(sSourcefile[0] == '/' || 
  -        sSourcefile[0] == '\\' || 
  -        (isalpha(sSourcefile[0]) && sSourcefile[1] == ':' && 
  -            (sSourcefile[2] == '\\' || sSourcefile[2] == '/'))))
  -        getcwd (olddir, sizeof (olddir) - 1) ;
  -
  -    if ( olddir[0] )
  -	cache_key_len += strlen( olddir );
  -        
  -    cache_key = malloc(cache_key_len + 5 );
  -    cache_key_len += 2 ;
  -    strcpy( cache_key, "--" );
  -    strcat( cache_key, sSourcefile );
  -    if ( sPackage && *sPackage)
  -	strcat( cache_key, sPackage );
  -
  -    if ( olddir[0] )
  -	strcat( cache_key, olddir );
  -
  -
  -#ifdef EP2
  -    if ( bEP1Compat )
  -	{
  -	strcat( cache_key, "-1" ); /* make sure Embperl 1.x compatible files get another namespace */
  -	cache_key_len += 2 ;
  -	}
  -#endif
  -
  -    ppSV = hv_fetch(pCacheHash, cache_key, cache_key_len, 0);  
  -    
  -    if (ppSV && *ppSV)
  -        {
  -        f = (tFile *)SvIV((SV*)SvRV(*ppSV)) ;
  -        
  -        if (mtime == 0 || f -> mtime != mtime)
  -            {
  -            hv_clear (f -> pCacheHash) ;
  -#ifdef EP2	
  -	    UndefSub (pCurrReq, f -> sMainSub, f -> sCurrPackage) ;
  -#endif
  -        
  -            f -> mtime       = -1 ;	 /* reset last modification time of file */
  -	    if (f -> pExportHash)
  -		{
  -		SvREFCNT_dec (f -> pExportHash) ;
  -		f -> pExportHash = NULL ;
  -		}
  -	    }
  -        pNew = "Found " ;
  -        }
  -    else
  -        { /* create new file structure */
  -        if ((f = malloc (sizeof (*f))) == NULL)
  -	    {
  -	    free(cache_key);
  -            return NULL ;
  -	    }
  -
  -        f -> sSourcefile = sstrdup (sSourcefile) ; /* Name of sourcefile */
  -        f -> mtime       = -1 ;	 /* last modification time of file */
  -        f -> nFilesize   = 0 ;	 /* size of File */
  -	f -> pBufSV      = NULL ;
  -	f -> pNext2Free  = NULL ;
  -	f -> bKeep       = 0 ;
  -	f -> pExportHash = NULL ;
  -	f -> nFirstLine  = 0 ;
  -
  -        f -> pCacheHash  = newHV () ;    /* Hash containing CVs to precompiled subs */
  -
  -	if ( sPackage && *sPackage)
  -            f -> sCurrPackage = strdup (sPackage) ; /* Package of file  */
  -        else
  -            {
  -            sprintf (txt, sDefaultPackageName, nPackNo ) ;
  -            f -> sCurrPackage = strdup (txt) ; /* Package of file  */
  -            }
  -        sprintf (txt, sDefaultSubName, nPackNo ) ;
  -        f -> sMainSub = strdup (txt) ; /* Package of file  */
  -        nPackNo++ ;
  -        f -> nCurrPackage = strlen (f -> sCurrPackage); /* Package of file (length) */
  -
  -        hv_store(pCacheHash, cache_key, cache_key_len, newRV_noinc (newSViv ((IV)f)), 0) ;  
  -    
  -        pNew = "New " ;
  -        }
  -
  -    if (CurrComponent -> Config.bDebug)
  -        lprintf (pCurrReq, "[%d]CACHE: %s File for %s (%x) in %s hash cache-key %s\n", pCurrReq -> nPid,  pNew, f -> sSourcefile, f, f -> sCurrPackage, cache_key) ;
  -    
  -    free(cache_key);
  -
  -    return f ;
  -    }
  -
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Free File buffer								*/
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -
  -static void FreeFileBuf     (/*i/o*/ register req * r,
  -			     /*i/o*/ tFile * f)
  -
  -
  -    {
  -    if (!f -> bKeep && f -> pBufSV)
  -	{
  -	SvREFCNT_dec (f -> pBufSV) ;
  -	f -> pBufSV = NULL ;
  -        if (r -> Component.Config.bDebug)
  -            lprintf (r -> pApp,  "[%d]MEM: Free buffer for %s in %s\n", r -> pThread -> nPid,  f -> sSourcefile, f -> sCurrPackage) ;
  -	}
  -    else if (r -> Component.Config.bDebug && !f -> pBufSV)
  -        lprintf (r -> pApp,  "[%d]MEM: Warning! buffer for %s in %s is NULL\n", r -> pThread -> nPid,  f -> sSourcefile, f -> sCurrPackage) ;
  -    }
  -
  -#endif
   
   /* ---------------------------------------------------------------------------- */
   /*                                                                              */
  @@ -984,164 +527,109 @@
       }
       
   
  -#if 0
  -
  +                     
   /* ---------------------------------------------------------------------------- */
   /*                                                                              */
  -/* Free Request                                                                 */
  +/* Setup Safe Namespace                                                         */
   /*                                                                              */
   /* ---------------------------------------------------------------------------- */
   
   
  -void FreeRequest (/*i/o*/ register req * r)
  +static void SetupSafeNamespace (/*i/o*/ register req * r)
   
  -    {
  -    FreeConfData (r -> pConf) ;
  -    r -> pConf = NULL ;
  +    {                 
  +    GV *    gv;
   
  -    if (!r -> Component.bAppendToMainReq && r -> Component.ofd)
  -        CloseOutput (r) ; /* just to be sure */
  -    
  -    if (r -> pApplication)
  -	SvREFCNT_dec (r -> pApplication) ;
  +    dTHR ;
  +    epTHX ;
   
  -    lprintf (r -> pApp,  "****free fh setup = %d  sub req = %d imp = %d\n", r -> bIsFormHashSetup, r -> Component.pPrev, r -> Component.pImportStash) ;
  +	/* The following is borrowed from Opcode.xs */
   
  -    if (r -> Component.pPrev)
  -        {
  -        tReq * l = r -> pLastReq ;
  +    if (r -> Component.Config.bOptions & optOpcodeMask)
  +        opmask_addlocal(aTHX_ r -> Component.Config.pOpcodeMask, r -> Component.op_mask_buf);
   
  -        l -> bError      = r -> bError ;
  -        l -> nLastErrFill= r -> nLastErrFill ;
  -        l -> bLastErrState= r -> bLastErrState ;
  -        }
  -    else
  +        
  +    if (r -> Component.Config.bOptions & optSafeNamespace)
           {
  -        tFile * pFile ;
  -        tFile * pNext ;
  -	int     i ;
  -
  -#ifdef HASHTEST
  -	pHash = perl_get_hv (sFormHashName, FALSE) ;
  -	if (pHash != r -> pThread -> pFormHash)
  -	    {
  -	    strcpy (r -> errdat1, sFormHashName) ;
  -	    strcpy (r -> errdat2, " !!C-Adress differs from Perl-Adress!! in FreeRequest") ;
  -	    LogError (r, rcHashError) ;
  -	    }
  -#endif
  -
  -        hv_clear (r -> pThread -> pHeaderHash) ;
  -        hv_clear (r -> pThread -> pInputHash) ;
  -        if (!r -> Component.pImportStash)
  -            {                
  -	    tReq * l = r -> pLastReq ;
  -            av_clear (r -> pThread -> pFormArray) ;
  -            hv_clear (r -> pThread -> pFormHash) ;
  -            hv_clear (r -> pThread -> pFormSplitHash) ;
  -            if (l)
  -		l -> bIsFormHashSetup = 0 ;
  -            }
  -#ifdef EP2 
  -        av_clear (r -> pDomTreeAV) ;
  -	for (i = 0 ; i < AvFILL (r -> pCleanupAV); i++)
  -	    {
  -	    sv_setsv (SvRV(*av_fetch (r -> pCleanupAV, i, 0)), &sv_undef) ;
  -	    }
  -        av_clear (r -> pCleanupAV) ;
  -
  -        Cache_CleanupRequest (r) ;
  -
  -#endif
  -	if ((pFile = r -> pFiles2Free))
  -	    {
  -	    do
  -		{
  -		FreeFileBuf (r, pFile) ;
  -		pNext = pFile -> pNext2Free ;
  -		pFile -> pNext2Free = NULL ;
  -		}
  -	    while (pFile != pNext && (pFile = pNext)) ;
  -	    }
  -#ifdef APACHE
  -	r -> pApacheReq   = NULL ;
  -	r -> pApacheReqSV = &sv_undef ;
  -#endif
  -	}
  -
  -    if (r -> sSessionID)
  -	_free (r, r -> sSessionID) ;
  -
  -    SvREFCNT_dec (r -> _perlsv) ;
  +        save_aptr(&endav);
  +        endav = (AV*)sv_2mortal((SV*)newAV()); /* ignore END blocks for now	*/
   
  -    pCurrReq = r -> pLastReq ;
  -    if (pCurrReq && pCurrReq -> _perlsv)
  -	{
  -	SV * pReqHV = SvRV (pCurrReq -> _perlsv) ;
  -	sv_unmagic (pReqHV, '~') ;
  -	sv_magic (pReqHV, NULL, '~', (char *)&pCurrReq, sizeof (pCurrReq)) ;
  -	}
  +        save_hptr(&defstash);		/* save current default stack	*/
  +        /* the assignment to global defstash changes our sense of 'main'	*/
  +        defstash = gv_stashpv(r -> Component.sCurrPackage, GV_ADDWARN); /* should exist already	*/
   
  -#if defined (_DEBUG) && defined (WIN32)
  -    _CrtMemDumpAllObjectsSince(&r -> MemCheckpoint);    
  -#endif    
  -#ifdef DMALLOC
  -			    /* unsigned long mark, int not_freed_b, int freed_b, int details_b */
  -    dmalloc_log_changed (r -> MemCheckpoint, 1, 0, 1) ;
  -    dmalloc_message ( "[%d]%sRequest freed. Entry-SVs: %d -OBJs: %d Exit-SVs: %d -OBJs: %d\n", r -> pThread -> nPid,
  -	    (r -> Component.pPrev?"Sub-":""), r -> stsv_count, r -> stsv_objcount, sv_count, sv_objcount) ;
  -#endif    
  -    if (r -> Component.Config.bDebug)
  -	DomStats (r -> pApp) ;
  +        if (r -> Component.Config.bDebug)
  +            lprintf (r -> pApp,  "[%d]REQ:  switch to safe namespace %s\n", r -> pThread -> nPid, r -> Component.sCurrPackage) ;
   
  -    r -> pNext = pReqFree ;
  -    pReqFree = r ;
   
  +        /* defstash must itself contain a main:: so we'll add that now	*/
  +        /* take care with the ref counts (was cause of long standing bug)	*/
  +        /* XXX I'm still not sure if this is right, GV_ADDWARN should warn!	*/
  +        gv = gv_fetchpv("main::", GV_ADDWARN, SVt_PVHV);
  +        sv_free((SV*)GvHV(gv));
  +        GvHV(gv) = (HV*)SvREFCNT_inc(defstash);
  +        }
       }
   
  -#endif
  -                     
   /* ---------------------------------------------------------------------------- */
   /*                                                                              */
  -/* Setup Safe Namespace                                                         */
  +/* Reset Request                                                                */
   /*                                                                              */
   /* ---------------------------------------------------------------------------- */
   
   
  -static void SetupSafeNamespace (/*i/o*/ register req * r)
  +static int ResetRequest (/*i/o*/ register req * r,
  +			/*in*/ char *  sInputfile)
   
  -    {                 
  -    GV *    gv;
  +    {
  +    epTHX ;    
   
  -    dTHR ;
  -    epTHX ;
  +    if (r -> Component.Config.bDebug)
  +        {
  +        clock_t cl = clock () ;
  +        time_t t ;
  +        struct tm * tm ;
  +        
  +        time (&t) ;        
  +        tm =localtime (&t) ;
  +        
  +        lprintf (r -> pApp,  "[%d]PERF: input = %s\n", r -> pThread -> nPid, sInputfile) ;
  +#ifdef CLOCKS_PER_SEC
  +        lprintf (r -> pApp,  "[%d]PERF: Time: %d ms ", r -> pThread -> nPid, ((cl - r -> startclock) * 1000 / CLOCKS_PER_SEC)) ;
  +#else
  +        lprintf (r -> pApp,  "[%d]PERF: ", r -> pThread -> nPid) ;
  +#endif        
  +        lprintf (r -> pApp,  "\n") ;    
  +        lprintf (r -> pApp,  "[%d]%sRequest finished. %s. Entry-SVs: %d  Exit-SVs: %d \n", r -> pThread -> nPid,
  +	    (r -> Component.pPrev?"Sub-":""), asctime(tm), r -> stsv_count, sv_count) ;
  +#ifdef DMALLOC
  +        dmalloc_message ( "[%d]%sRequest finished. Entry-SVs: %d Exit-SVs: %d \n", r -> pThread -> nPid,
  +	    (r -> Component.pPrev?"Sub-":""), r -> stsv_count, sv_count) ;
  +#endif        
  +        }
   
  -	/* The following is borrowed from Opcode.xs */
  +    
  +    r -> Component.pCurrPos = NULL ;
   
  -    if (r -> Component.Config.bOptions & optOpcodeMask)
  -        opmask_addlocal(aTHX_ r -> Component.Config.pOpcodeMask, r -> Component.op_mask_buf);
   
  -        
  -    if (r -> Component.Config.bOptions & optSafeNamespace)
  -        {
  -        save_aptr(&endav);
  -        endav = (AV*)sv_2mortal((SV*)newAV()); /* ignore END blocks for now	*/
  +    FlushLog (r -> pApp) ;
   
  -        save_hptr(&defstash);		/* save current default stack	*/
  -        /* the assignment to global defstash changes our sense of 'main'	*/
  -        defstash = gv_stashpv(r -> Component.sCurrPackage, GV_ADDWARN); /* should exist already	*/
  +    r -> Component.nSourceline = 1 ;
  +    r -> Component.pSourcelinePos = NULL ;    
  +    r -> Component.pLineNoCurrPos = NULL ;    
   
  -        if (r -> Component.Config.bDebug)
  -            lprintf (r -> pApp,  "[%d]REQ:  switch to safe namespace %s\n", r -> pThread -> nPid, r -> Component.sCurrPackage) ;
  +    r -> Component.bReqRunning = 0 ;
   
  +    /*
  +    av_clear (r -> pErrFill) ;
  +    av_clear (r -> pErrState) ;
  +    */
   
  -        /* defstash must itself contain a main:: so we'll add that now	*/
  -        /* take care with the ref counts (was cause of long standing bug)	*/
  -        /* XXX I'm still not sure if this is right, GV_ADDWARN should warn!	*/
  -        gv = gv_fetchpv("main::", GV_ADDWARN, SVt_PVHV);
  -        sv_free((SV*)GvHV(gv));
  -        GvHV(gv) = (HV*)SvREFCNT_inc(defstash);
  -        }
  +#ifdef APACHE
  +    /* This must be the very very very last !!!!! */
  +    r -> pApacheReq = NULL ;
  +#endif
  +    return ok ;
       }
   
       
  @@ -1155,31 +643,8 @@
   static int StartOutput (/*i/o*/ register req * r)
   
       {
  -    int rc ;
  -    SV * pOutData  = r -> Component.Param.pOutput ;
  -    int  bOutToMem = pOutData && SvROK (pOutData) ;
  -    epTHX ;    
  -
  -    if (r -> Component.pImportStash)
  -	{ /* import does not generate any output */
  -	r -> Component.bDisableOutput = 1 ;
  -	}
  -    else if (!bOutToMem)
  -        {
  -        if (!r -> Component.bAppendToMainReq)
  -            {
  -            if ((rc = OpenOutput (r, r -> Component.Param.sOutputfile)) != ok)
  -                return rc ;
  -            }
  -        else
  -            OutputToStd (r) ;
  -        }
  -    else
  -        { /* only reset output buffers */
  -        r -> Component.ofd = NULL ;
  -        OpenOutput (r, NULL) ;
  -        }
  -
  +    int  bOutToMem = r -> Component.Param.pOutput && SvROK (r -> Component.Param.pOutput) ;
  +    epTHX_
   
   #ifdef APACHE
       if (r -> pApacheReq && r -> pApacheReq -> main)
  @@ -1469,7 +934,7 @@
   		if (r -> nIOType == epIOCGI)
   		    {            
   		    char txt[100] ;
  -		    int  save = r -> Component.nMarker ;
  +		    int  save = r -> Component.pOutput -> nMarker ;
   		    SV *   pHeader ;
   		    char * p ;
   		    HE *   pEntry ;
  @@ -1477,7 +942,7 @@
   		    I32    l ;
   		    char * pContentType = "text/html";
   
  -		    r -> Component.nMarker = 0 ; /* output directly */
  +		    r -> Component.pOutput -> nMarker = 0 ; /* output directly */
           
   		    hv_iterinit (r -> pThread -> pHeaderHash) ;
   		    while ((pEntry = hv_iternext (r -> pThread -> pHeaderHash)))
  @@ -1547,7 +1012,7 @@
   
   		    oputs (r, "\n") ;
   
  -		    r -> Component.nMarker = save ;
  +		    r -> Component.pOutput -> nMarker = save ;
   		    }
   		}
   	    }
  @@ -1665,16 +1130,6 @@
   
   
   #ifdef EP2
  -		if (r -> Component.Config.bEP1Compat)
  -		    {
  -#endif
  -		    lc -> pFirstBuf    = r -> Component.pFirstBuf  ;  
  -		    lc -> pLastBuf     = r -> Component.pLastBuf   ;  
  -		    lc -> pFreeBuf     = r -> Component.pFreeBuf   ;  
  -		    lc -> pLastFreeBuf = r -> Component.pLastFreeBuf ;
  -#ifdef EP2
  -		    }
  -		else
   		    {
   		    if (!bError && !r -> Component.pImportStash)
   			{
  @@ -1755,72 +1210,10 @@
   #endif
           }    
   
  -    if (!r -> Component.bAppendToMainReq)
  -        CloseOutput (r) ;
   
       return ok ;
       }
       
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Reset Request                                                                */
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -
  -static int ResetRequest (/*i/o*/ register req * r,
  -			/*in*/ char *  sInputfile)
  -
  -    {
  -    epTHX ;    
  -
  -    if (r -> Component.Config.bDebug)
  -        {
  -        clock_t cl = clock () ;
  -        time_t t ;
  -        struct tm * tm ;
  -        
  -        time (&t) ;        
  -        tm =localtime (&t) ;
  -        
  -        lprintf (r -> pApp,  "[%d]PERF: input = %s\n", r -> pThread -> nPid, sInputfile) ;
  -#ifdef CLOCKS_PER_SEC
  -        lprintf (r -> pApp,  "[%d]PERF: Time: %d ms ", r -> pThread -> nPid, ((cl - r -> startclock) * 1000 / CLOCKS_PER_SEC)) ;
  -#else
  -        lprintf (r -> pApp,  "[%d]PERF: ", r -> pThread -> nPid) ;
  -#endif        
  -        lprintf (r -> pApp,  "\n") ;    
  -        lprintf (r -> pApp,  "[%d]%sRequest finished. %s. Entry-SVs: %d  Exit-SVs: %d \n", r -> pThread -> nPid,
  -	    (r -> Component.pPrev?"Sub-":""), asctime(tm), r -> stsv_count, sv_count) ;
  -#ifdef DMALLOC
  -        dmalloc_message ( "[%d]%sRequest finished. Entry-SVs: %d Exit-SVs: %d \n", r -> pThread -> nPid,
  -	    (r -> Component.pPrev?"Sub-":""), r -> stsv_count, sv_count) ;
  -#endif        
  -        }
  -
  -    
  -    r -> Component.pCurrPos = NULL ;
  -
  -
  -    FlushLog (r -> pApp) ;
  -
  -    r -> Component.nSourceline = 1 ;
  -    r -> Component.pSourcelinePos = NULL ;    
  -    r -> Component.pLineNoCurrPos = NULL ;    
  -
  -    r -> Component.bReqRunning = 0 ;
  -
  -    /*
  -    av_clear (r -> pErrFill) ;
  -    av_clear (r -> pErrState) ;
  -    */
  -
  -#ifdef APACHE
  -    /* This must be the very very very last !!!!! */
  -    r -> pApacheReq = NULL ;
  -#endif
  -    return ok ;
  -    }
   
   
   /* ---------------------------------------------------------------------------- */
  @@ -1873,7 +1266,15 @@
   	XPUSHs(&sv_undef) ;  /*sv_2mortal(newRV_inc((SV *)pRP))); */
   	XPUSHs(pRecipe);                
   	PUTBACK;                        
  -	num = perl_call_pv ("Embperl::Recipe::GetRecipe", G_SCALAR /*| G_EVAL*/) ;
  +	num = perl_call_pv ("Embperl::Recipe::GetRecipe", G_SCALAR | G_EVAL) ;
  +        if (SvTRUE (ERRSV))
  +	    {
  +            STRLEN l ;
  +            strncpy (r -> errdat1, SvPV (ERRSV, l), sizeof (r -> errdat1) - 1) ;
  +	    LogError (r, rcEvalErr) ; 
  +	    sv_setpv(ERRSV,"");
  +            num = 0 ;
  +            }
   	tainted = 0 ;
   	SPAGAIN;                        
   	if (num == 1)
  @@ -1918,270 +1319,6 @@
       }
   
   
  -#if 0
  -
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Process a block of the file  						*/
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -    
  -
  -int ProcessBlock	(/*i/o*/ register req * r,
  -			 /*in*/  int	 nBlockStart,
  -			 /*in*/  int	 nBlockSize,
  -                         /*in*/  int     nBlockNo)
  -
  -    {
  -    int     rc ;
  -    char *  p ;
  -    int     n ;
  -
  -
  -    r -> Component.pCurrPos = r -> Component.pBuf + nBlockStart ;
  -    r -> Component.pEndPos  = r -> Component.pCurrPos + nBlockSize ;
  -    r -> Buf.nBlockNo = nBlockNo ;
  -
  -
  -    if (r -> Component.pTokenTable && strcmp ((char *)r -> Component.pTokenTable, "Text") == 0)
  -	{ /* --- emulate Embperl 2  syntax => 'Text' --- */	    
  -	owrite (r, r -> Component.pCurrPos, r -> Component.pEndPos - r -> Component.pCurrPos) ;
  -	return r -> Buf.nBlockNo ;
  -	}
  -
  -    rc = ok ;
  -    p = r -> Component.pCurrPos ;
  -    while (p && *p && p < r -> Component.pEndPos && rc == ok)
  -        {
  -        if ((r -> Component.Config.bDebug & dbgMem) && (sv_count != r -> lstsv_count || sv_objcount != r -> lstsv_objcount))
  -            {
  -            lprintf (r -> pApp,  "[%d]SVs:  Entry-SVs: %d -OBJs: %d Curr-SVs: %d -OBJs: %d\n", r -> pThread -> nPid, r -> stsv_count, r -> stsv_objcount, sv_count, sv_objcount) ;
  -            r -> lstsv_count = sv_count ;
  -            r -> lstsv_objcount = sv_objcount ;
  -            }
  -        
  -        /* */
  -        /* execute [x ... x] and special html tags and replace them if nessecary */
  -        /* */
  -
  -        if (r -> CmdStack.State.bProcessCmds == cmdAll && !(r -> Component.Config.bOptions & optDisableHtmlScan))
  -            {
  -            n = strcspn (p, "[<") ;
  -            p += n ;
  -            }
  -        else
  -            p = strchr (p, '[') ;
  -            
  -            
  -        if (p == NULL)
  -            { /* output the rest of html */
  -            owrite (r, r -> Component.pCurrPos, r -> Component.pEndPos - r -> Component.pCurrPos) ;
  -            break ;
  -            }
  -        
  -        if (r -> CmdStack.State.bProcessCmds == cmdAll)
  -            /* output until next cmd */
  -            owrite (r, r -> Component.pCurrPos, p - r -> Component.pCurrPos) ;
  -        
  -        if (*p == '\0')
  -            break ;
  -
  -        if (r -> Component.Config.bDebug & dbgSource)
  -            {
  -            char * s = p ;
  -            char * n ;
  -
  -            while (*s && isspace (*s))
  -                s++ ;
  -            
  -            if (*s)
  -                {
  -                GetLineNo (r) ;    
  -                n = strchr (s, '\n') ;
  -    
  -#ifdef CLOCKS_PER_SEC
  -                if (r -> Component.Config.bDebug & dbgProfile)
  -                    if (n)
  -                        lprintf (r -> pApp,  "[%d]SRC: Line %d: Time %d ms  %*.*s\n", r -> pThread -> nPid, r -> Component.nSourceline, ((clock () - r -> startclock) * 1000 / CLOCKS_PER_SEC), n-s, n-s, s) ;
  -                    else
  -                        lprintf (r -> pApp,  "[%d]SRC: Line %d: Time %d ms  %60.60s\n", r -> pThread -> nPid, r -> Component.nSourceline, ((clock () - r -> startclock) * 1000 / CLOCKS_PER_SEC), s) ;
  -                else
  -#endif
  -                    if (n)
  -                        lprintf (r -> pApp,  "[%d]SRC: Line %d: %*.*s\n", r -> pThread -> nPid, r -> Component.nSourceline, n-s, n-s, s) ;
  -                    else
  -                        lprintf (r -> pApp,  "[%d]SRC: Line %d: %60.60s\n", r -> pThread -> nPid, r -> Component.nSourceline, s) ;
  -
  -                }
  -            }        
  -
  -        
  -        r -> Buf.pCurrStart = p ;
  -        if (*p == '<')
  -            { /* HTML Tag */
  -            rc = ScanHtmlTag (r, p) ;
  -            }
  -         else
  -            { /* [x ... x] sequenz */
  -            if (p[1] == '*')
  -                break ;
  -            
  -            rc = ScanCmdEvals (r, p) ;
  -            }
  -        p = r -> Component.pCurrPos ;
  -        }
  -
  -    if (rc != ok)
  -        {
  -        if (rc != rcExit)
  -            LogError (r, rc) ;
  -        return 0 ;
  -        }
  -    
  -    return r -> Buf.nBlockNo ;
  -    }
  -
  -
  -	    
  -	    
  -	    
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Read input file into memory  						*/
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -int ReadInputFile	(/*i/o*/ register req * r)
  -
  -    {
  -    int	    rc = ok ;
  -    SV *    pBufSV = NULL ;
  -    req *   pMain = r ;
  -
  -#ifdef EP2
  -    if (!r -> Component.Config.bEP1Compat)
  -    	{
  -    	SV * * ppSV ;
  -    	
  -    	ppSV = hv_fetch (r -> Buf.pFile -> pCacheHash, "P-1----", 7, 0) ;
  -    	if (ppSV && *ppSV)
  -    	    {
  -	    r -> Component.pBuf		    = NULL ;
  -	    r -> Buf.pFile -> nFilesize     = 1 ;
  -	    return ok ;  /* source already parsed */
  -	    }
  -	}
  -#endif
  -
  -    if ((pBufSV = r -> Buf.pFile -> pBufSV) == NULL || !SvPOK (pBufSV))
  -	{
  -	if (SvROK(r -> Component.Param.pInput))
  -	    { /* --- get input from memory --- */
  -	    STRLEN n ;
  -	    r -> Component.pBuf = SvPV (pBufSV = SvRV(r -> Component.Param.pInput), n) ;
  -	    r -> Buf.pFile -> nFilesize = n ; 
  -	    }
  -
  -	else
  -	    {
  -	    /* --- read input file --- */
  -    	    rc = ReadHTML (r, r -> Component.sSourcefile, &r -> Buf.pFile -> nFilesize, &pBufSV) ;
  -	    if (rc == ok)
  -		r -> Component.pBuf = SvPVX (pBufSV) ;
  -	    }
  -	
  -	if (rc == ok)
  -	    {
  -	    SvREFCNT_inc (pBufSV) ;
  -	    r -> Buf.pFile -> pBufSV = pBufSV ;
  -	    r -> Component.pEndPos  = r -> Component.pBuf + r -> Buf.pFile -> nFilesize ;
  -	    
  -	    if (r -> Buf.pFile -> pNext2Free == NULL)
  -		{
  -		/* --- add to list for freeing --- */
  -	    
  -		while (pMain && pMain -> pLastReq != &InitialReq)
  -		    pMain = pMain -> pLastReq ;
  -
  -		if ((r -> Buf.pFile -> pNext2Free = pMain -> pFiles2Free) == NULL)
  -		    r -> Buf.pFile -> pNext2Free  = r -> Buf.pFile ; /* last one points to itself !! */
  -		pMain -> pFiles2Free = r -> Buf.pFile ;
  -		}
  -	    
  -	    /* SetupDebugger (r) ; */
  -	    }
  -	}
  -    else
  -	{
  -	r -> Component.pBuf		    = SvPVX (pBufSV) ;
  -	r -> Buf.pFile -> nFilesize = SvCUR (pBufSV) ;
  -	}
  -
  -    return rc ;
  -    }
  -
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Process a block of the file  						*/
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
  -    
  -
  -int ProcessSub		(/*i/o*/ register req * r,
  -			 /*in*/  tFile * pFile,
  -			 /*in*/  int	 nBlockStart,
  -                         /*in*/  int     nBlockNo)
  -
  -    {
  -    int	    rc ;
  -    tSrcBuf Buf ;
  -    char *  sEvalPackage = r -> Component.sEvalPackage ; 
  -    STRLEN  nEvalPackage = r -> Component.nEvalPackage ;  
  -    SV *    pInData      = r -> Component.Param.pInput  ;  
  -
  -
  -    /*av_unshift (GvAV (PL_defgv), 1) ;
  -    av_store   (GvAV (PL_defgv), 0, r -> _perlsv) ; */
  -    
  -    memcpy (&Buf, &r -> Buf, sizeof (Buf)) ;
  -
  -    
  -    if (pFile != r -> Buf.pFile)
  -	{ /* get other file */
  -	r -> Buf.pFile = pFile ;
  -	r -> Component.Param.pInput = &sv_undef ;
  -
  -	if ((rc = ReadInputFile (r)) != ok)
  -	    {
  -	    LogError (r, rc) ;
  -	    return rc ;
  -	    }
  -
  -	r -> Component.pSourcelinePos =  r -> Component.pBuf ;
  -	r -> Component.nSourceline = r -> Component.Param.nFirstLine ;
  -	r -> Component.pLineNoCurrPos = NULL ;    
  -	r -> Component.sEvalPackage   = r -> Buf.pFile -> sCurrPackage ; 
  -	r -> Component.nEvalPackage   = r -> Buf.pFile -> nCurrPackage ; 
  -	}
  -
  -    r -> nInsideSub++ ;
  -    rc = ProcessBlock (r, nBlockStart, r -> Buf.pFile -> nFilesize - nBlockStart, nBlockNo) ;
  -    r -> nInsideSub-- ;
  -
  -    memcpy (&r -> Buf, &Buf, sizeof (Buf)) ;
  -    r -> Component.sEvalPackage = sEvalPackage ; 
  -    r -> Component.nEvalPackage = nEvalPackage ; 
  -    r -> Component.Param.pInput          = pInData ;  
  -
  -    if (rc != ok)
  -	LogError (r, rc) ;
  -
  -    return rc ;
  -    }
  -
  -#endif
       
   /* ---------------------------------------------------------------------------- */
   /*                                                                              */
  @@ -2361,6 +1498,51 @@
           embperl_ExecuteRequest (r) ;
   
       embperl_CleanupRequest (r) ;
  +
  +    return rc ;
  +    }
  +    
  +
  +
  +int     embperl_RunComponent(/*in*/ tReq *           r,
  +                             /*in*/ SV *             pPerlParam)
  +
  +
  +    {
  +    epTHX_
  +    int rc ;
  +    tComponent * pComponent ;
  +
  +    rc = embperl_SetupComponent  (r, pPerlParam, &pComponent) ;
  +
  +    if (rc == ok)
  +        {
  +        ENTER;
  +        SAVETMPS ;
  +	
  +        r -> Component.bReqRunning     = 1 ;
  +
  +        if ((r -> Component.Config.bOptions & optEarlyHttpHeader) == 0)
  +            oBegin (r) ;
  +
  +        if ((rc = ProcessFile (r, 0 /*r -> Buf.pFile -> nFilesize*/)) != ok)
  +            if (rc == rcExit)
  +                rc = ok ;
  +            else
  +                LogError (r, rc) ;
  +
  +        
  +        /* --- Restore Operatormask and Package, destroy temp perl sv's --- */
  +        FREETMPS ;
  +        LEAVE;
  +        r -> Component.bReqRunning = 0 ;
  +
  +        /* --- send http header and data to the browser if not already done --- */
  +        if ((rc = EndOutput (r, rc, r -> Component.Param.pOutput)) != ok)
  +            LogError (r, rc) ;
  +
  +        embperl_CleanupComponent  (r, pComponent) ;
  +        }
   
       return rc ;
       }
  
  
  
  1.1.2.11  +8 -2      embperl/Attic/eppriv.h
  
  Index: eppriv.h
  ===================================================================
  RCS file: /home/cvs/embperl/Attic/eppriv.h,v
  retrieving revision 1.1.2.10
  retrieving revision 1.1.2.11
  diff -u -r1.1.2.10 -r1.1.2.11
  --- eppriv.h	24 Jan 2002 08:37:05 -0000	1.1.2.10
  +++ eppriv.h	25 Jan 2002 07:04:31 -0000	1.1.2.11
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: eppriv.h,v 1.1.2.10 2002/01/24 08:37:05 richter Exp $
  +#   $Id: eppriv.h,v 1.1.2.11 2002/01/25 07:04:31 richter Exp $
   #
   ###################################################################################*/
   
  @@ -45,6 +45,7 @@
   void boot_Embperl__Component (pTHX_ CV * cv) ;
   void boot_Embperl__Component__Config (pTHX_ CV * cv) ;
   void boot_Embperl__Component__Param (pTHX_ CV * cv) ;
  +void boot_Embperl__Syntax (pTHX_ CV * cv) ;
   
   
   struct tCacheItem ;
  @@ -196,7 +197,12 @@
                                   /*in*/ tMemPool    * pPool,
                                   /*out*/ tReqParam  * pParam) ;
   
  +int    embperl_SetupComponent  (/*in*/ tReq *                 r,
  +                                /*in*/ SV *                   pPerlParam,
  +                                /*out*/tComponent * *         ppComponent) ;
   
  +int    embperl_CleanupComponent  (/*in*/ tReq *                r,
  +                                  /*in*/ tComponent *          c) ;
   
   /* --- init --- */
   
  @@ -205,7 +211,7 @@
   void embperl_DefaultComponentConfig (/*in*/ tComponentConfig  *pCfg) ;
   
   void Embperl__App_new_init(pTHX_ tApp * pApp, SV * pPerlParam, int overwrite) ;
  -void Embperl__App__Config_new_init(pTHX_ tApp * pApp, SV * pPerlParam, int overwrite) ;
  +void Embperl__App__Config_new_init(pTHX_ tApp * pAppConfig, SV * pPerlParam, int overwrite) ;
   void Embperl__Req_new_init (pTHX_ tReq * r, SV * pPerlParam, int overwrite) ;
   void Embperl__Req__Config_new_init (pTHX_ tReqConfig * r, SV * pPerlParam, int overwrite) ;
   void Embperl__Req__Param_new_init (pTHX_ tReqParam * r, SV * pPerlParam, int overwrite) ;
  
  
  
  1.1.2.6   +4 -1      embperl/Attic/eppublic.h
  
  Index: eppublic.h
  ===================================================================
  RCS file: /home/cvs/embperl/Attic/eppublic.h,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- eppublic.h	23 Jan 2002 07:58:27 -0000	1.1.2.5
  +++ eppublic.h	25 Jan 2002 07:04:31 -0000	1.1.2.6
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: eppublic.h,v 1.1.2.5 2002/01/23 07:58:27 richter Exp $
  +#   $Id: eppublic.h,v 1.1.2.6 2002/01/25 07:04:31 richter Exp $
   #
   ###################################################################################*/
   
  @@ -32,6 +32,9 @@
   int     embperl_RunRequest  (pTHX_
                                SV *             pApacheReqSV,
                                SV *             pPerlParam) ;
  +
  +int     embperl_RunComponent(/*in*/ tReq *           r,
  +                             /*in*/ SV *             pPerlParam) ;
   
   int    embperl_CleanupRequest (tReq *  r) ;
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +2 -2      embperl/Embperl/Attic/Util.pm
  
  Index: Util.pm
  ===================================================================
  RCS file: /home/cvs/embperl/Embperl/Attic/Util.pm,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Util.pm	24 Jan 2002 08:37:06 -0000	1.1.2.2
  +++ Util.pm	25 Jan 2002 07:04:32 -0000	1.1.2.3
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: Util.pm,v 1.1.2.2 2002/01/24 08:37:06 richter Exp $
  +#   $Id: Util.pm,v 1.1.2.3 2002/01/25 07:04:32 richter Exp $
   #
   ###################################################################################
   
  @@ -103,7 +103,7 @@
                       
   
           *{"$package\:\:MailFormTo"} = \&Embperl::MailFormTo ;
  -        *{"$package\:\:Execute"} = \&Embperl::Execute ;
  +        *{"$package\:\:Execute"} = \&Embperl::Req::ExecuteComponent ;
   
           tie *{"$package\:\:LOG"}, 'Embperl::Log' ;
           tie *{"$package\:\:OUT"}, 'Embperl::Out' ;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org