richter     00/12/03 05:54:35

  Modified:    .        Embperl.pod ep.h epdat.h epeval.c epmain.c
                        epnames.h
  Log:
  Source Sync 1 <-> 2
  
  Revision  Changes    Path
  1.64      +0 -1      embperl/Embperl.pod
  
  Index: Embperl.pod
  ===================================================================
  RCS file: /home/cvs/embperl/Embperl.pod,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- Embperl.pod       2000/11/15 08:15:40     1.63
  +++ Embperl.pod       2000/12/03 13:54:34     1.64
  @@ -1758,7 +1758,6 @@
   B<NOTE 2:> If you want to output binary data, you must set the escmode
   to zero. (only 1.3b6 and above)
   
  - 
   =over 4
   
   =item B<$escmode = 3 (or 7)>
  
  
  
  1.32      +6 -0      embperl/ep.h
  
  Index: ep.h
  ===================================================================
  RCS file: /home/cvs/embperl/ep.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ep.h      2000/11/07 11:28:20     1.31
  +++ ep.h      2000/12/03 13:54:34     1.32
  @@ -526,6 +526,12 @@
   
   int EvalMain (/*i/o*/ register req *  r) ;
   
  +int EvalConfig (/*i/o*/ register req *  r,
  +             /*in*/  SV *            pSV, 
  +                /*in*/  int          numArgs,
  +                /*in*/  SV **                pArgs,
  +             /*out*/ CV **           pCV) ;
  +
   
   #ifdef EP2
   int CallStoredCV  (/*i/o*/ register req * r,
  
  
  
  1.26      +32 -4     embperl/epdat.h
  
  Index: epdat.h
  ===================================================================
  RCS file: /home/cvs/embperl/epdat.h,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- epdat.h   2000/11/07 11:28:20     1.25
  +++ epdat.h   2000/12/03 13:54:34     1.26
  @@ -17,6 +17,22 @@
   #ifdef EP2
   /*-----------------------------------------------------------------*/
   /*                                                              */
  +/*  cache Options                                               */
  +/*                                                              */
  +/*-----------------------------------------------------------------*/
  +
  +typedef enum tCacheOptions
  +    {
  +    ckoptCarryOver = 1,   /* use result from CacheKeyCV of preivious step if any */
  +    ckoptPathInfo  = 2,   /* include the PathInfo into CacheKey */
  +    ckoptQueryInfo = 4,        /* include the QueryInfo into CacheKey */
  +    ckoptDontCachePost = 8,    /* don't cache POST requests */
  +    ckoptDefault    = 15,      /* default is all options set */
  +    } tCacheOptions ;
  +
  +
  +/*-----------------------------------------------------------------*/
  +/*                                                              */
   /*  Processor                                                           */
   /*                                                              */
   /*-----------------------------------------------------------------*/
  @@ -36,6 +52,11 @@
                                     /*in*/  tDomTree **  ppDomTree,
                                     /*in*/  SV **        ppPreCompResult,
                                     /*out*/ SV **        ppCompResult) ;
  +    int (* pPreExecuter)            (/*in*/  tReq *    r,
  +                                  /*in*/  struct tProcessor * pProcessor,
  +                                  /*in*/  tDomTree **  pDomTree,
  +                                  /*in*/  SV **        ppPreCompResult,
  +                                  /*in*/  SV **        ppCompResult) ;
       int (* pExecuter)               (/*in*/  tReq *    r,
                                     /*in*/  struct tProcessor * pProcessor,
                                     /*in*/  tDomTree **  pDomTree,
  @@ -43,7 +64,9 @@
                                     /*in*/  SV **        ppCompResult,
                                     /*out*/ SV **        ppExecResult) ;
   
  -    const char *    sCacheKey ;
  +    const char *    sCacheKey ;          /* literal to add to key for cache */
  +    CV *         pCacheKeyCV ;   /* CV to call and add result to key for cache */
  +    tCacheOptions   bCacheKeyOptions ;
       double          nOutputExpiresIn ;
       CV *            pOutputExpiresCV ;
   
  @@ -99,9 +122,11 @@
   #ifdef EP2
       bool    bEP1Compat ;    /* run in Embperl 1.x compatible mode */
       tProcessor ** pProcessor ;   /* [array] processors used to process the file */
  -    char **  sExpiresKey ;  /* [array] Key used to store expires setting */
  -    double * nExpiresAt ;   /* [array] Data expiers at */
  -    SV **    pExpiresCV ;   /* [array] sub that is called to determinate expiration 
*/
  +    char *  sCacheKey ;    /* Key used to store expires setting */
  +    CV *         pCacheKeyCV ;   /* CV to call and add result to key for cache */
  +    tCacheOptions   bCacheKeyOptions ;
  +    double  nExpiresIn ;   /* Data expiers at */
  +    CV *    pExpiresCV ;   /* sub that is called to determinate expiration */
   #endif    
       char *  sPath ;      /* file search path */
       char *  sReqFilename ;  /* filename of original request */
  @@ -330,6 +355,9 @@
       bool    bEP1Compat ;     /* run in Embperl 1.x compatible mode */    
       tPhase  nPhase ;         /* which phase of the request we are in */
   
  +    char *  sPathInfo ;
  +    char *  sQueryInfo ;
  +    
       /* --- DomTree ---*/
   
       tNode    xDocument ;
  
  
  
  1.27      +89 -0     embperl/epeval.c
  
  Index: epeval.c
  ===================================================================
  RCS file: /home/cvs/embperl/epeval.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- epeval.c  2000/11/08 07:49:08     1.26
  +++ epeval.c  2000/12/03 13:54:34     1.27
  @@ -71,6 +71,95 @@
       }
   
   
  +/* -------------------------------------------------------------------------------
  +*
  +* Eval Config Statements 
  +* 
  +* in  pSV    pointer to string or CV
  +* out pCV    pointer to SV contains an CV to the evaled code
  +*
  +------------------------------------------------------------------------------- */
  +
  +int EvalConfig (/*i/o*/ register req *  r,
  +             /*in*/  SV *            pSV, 
  +                /*in*/  int          numArgs,
  +                /*in*/  SV **                pArgs,
  +             /*out*/ CV **           pCV)
  +    {
  +    dTHXsem 
  +    dSP;
  +    SV *  pSVErr  ;
  +    int   num ;         
  +    char * s = "Needs CodeRef" ;
  +
  +    EPENTRY (EvalDirect) ;
  +
  +    tainted = 0 ;
  +    pCurrReq = r ;
  +
  +    *pCV = NULL ;
  +    if (SvPOK (pSV))
  +     {
  +     STRLEN l ;
  +     s = SvPV (pSV, l) ;
  +     if (strncmp (s, "sub ", 4) == 0)
  +         {
  +         SV * pSVErr ;
  +         SV * pRV ;
  +
  +         pRV = perl_eval_pv (s, 0) ;
  +         if (SvROK (pRV))
  +             {
  +             *pCV = (CV *)SvRV (pRV) ;
  +             SvREFCNT_inc (*pCV) ;
  +             }
  +
  +         pSVErr = ERRSV ;
  +         if (SvTRUE (pSVErr))
  +             {
  +             STRLEN l ;
  +             char * p = SvPV (pSVErr, l) ;
  +             if (l > sizeof (r -> errdat1) - 1)
  +                 l = sizeof (r -> errdat1) - 1 ;
  +             strncpy (r -> errdat1, p, l) ;
  +             if (l > 0 && r -> errdat1[l-1] == '\n')
  +                 l-- ;
  +             r -> errdat1[l] = '\0' ;
  +         
  +             LogError (r, rcEvalErr) ;
  +
  +             sv_setpv(pSVErr,"");
  +             *pCV = NULL ;
  +             return rcEvalErr ;
  +             }
  +         }
  +     else
  +         {
  +         *pCV = perl_get_cv (s, 0) ;
  +         SvREFCNT_inc (*pCV) ;
  +         }
  +     }
  +    else 
  +     {
  +     if (SvROK (pSV))
  +         {
  +         *pCV = (CV *)SvRV (pSV) ;
  +         }
  +     }
  +
  +    if (!*pCV || SvTYPE (*pCV) != SVt_PVCV)
  +     {
  +     *pCV = NULL ;
  +     strcpy (r -> errdat1 ,"Config: ") ;
  +     strncpy (r -> errdat2, s, sizeof (r -> errdat2) - 1) ;
  +     return rcEvalErr ;
  +     }
  +
  +    return ok ;
  +    }
  +
  +
  +    
   
   /* -------------------------------------------------------------------------------
   *
  
  
  
  1.89      +84 -23    embperl/epmain.c
  
  Index: epmain.c
  ===================================================================
  RCS file: /home/cvs/embperl/epmain.c,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- epmain.c  2000/11/11 13:28:29     1.88
  +++ epmain.c  2000/12/03 13:54:34     1.89
  @@ -692,9 +692,24 @@
   
       rc = GetFormData (r, p, len) ;
       
  +#ifdef EP2
  +    if (!f && len > 0)
  +     {
  +        if ((f = _malloc (r, len + 1)) == NULL)
  +            return rcOutOfMemory ;
  +
  +     memcpy (f, p, len) ;
  +        p[len] = '\0' ;
  +     }
  +    if (len > 0)
  +     {
  +     r -> sQueryInfo = f ;
  +     f[len] = '\0' ;
  +     }
  +#else
       if (f)
           _free (r, f) ;
  -        
  +#endif        
       
       return rc ;
       }
  @@ -1675,6 +1690,8 @@
   #ifdef EP2
       SV * *   ppSV ;
       SV *     pSV ;
  +    SV * *   ppCV ;
  +    int           rc ;
   #endif
       tConf *  pConf = malloc (sizeof (tConf)) ;
       
  @@ -1700,22 +1717,31 @@
   
   
   #ifdef EP2
  -    pConf -> bEP1Compat =   GetHashValueInt (pReqInfo, "ep1compat",  pCurrReq -> 
pConf?pCurrReq -> pConf -> bEP1Compat:pCurrReq -> bEP1Compat) ;  /* EP1Compat */
  -    /* ##ep2##
  -    pConf -> sExpiresKey   = sstrdup (GetHashValueStr (pReqInfo, "expires_key",  
pCurrReq -> pConf?pCurrReq -> pConf -> sExpiresKey:NULL)) ; ;
  -
  -    pConf -> nExpiresAt    = 0 ;
  -    pConf -> pExpiresCV    = NULL ;
  -    ppSV = hv_fetch (pReqInfo, "expires_at", 10, 0) ;
  -    if (ppSV && *ppSV && SvTYPE (*ppSV) == SVt_RV &&
  -     SvTYPE (pSV = SvRV (*ppSV)) == SVt_PVCV)
  -     pConf -> pExpiresCV = pSV ;
  -    else if (ppSV && *ppSV)
  -     pConf -> nExpiresAt = SvNV (*ppSV) ;
  -    */
  -    pConf -> sExpiresKey   = NULL ;
  -    pConf -> nExpiresAt    = 0 ;
  -    pConf -> pExpiresCV    = NULL ;
  +    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
   
   
  @@ -1763,9 +1789,12 @@
        free (pConf -> sReqFilename) ;
   
   #ifdef EP2
  -    if (pConf -> sExpiresKey)
  -     free (pConf -> sExpiresKey) ;
  +    if (pConf -> sCacheKey)
  +     free (pConf -> sCacheKey) ;
    
  +    if (pConf -> pCacheKeyCV)
  +     SvREFCNT_dec (pConf -> pCacheKeyCV) ;
  +
       if (pConf -> pExpiresCV)
        SvREFCNT_dec (pConf -> pExpiresCV) ;
   #endif
  @@ -2049,6 +2078,10 @@
       char *  sMode ;
       tFile * pFile ;
       HV * pReqHV  ;
  +#ifdef EP2
  +    SV * * ppSV ;
  +    STRLEN len ;
  +#endif
   
       dTHR ;
   
  @@ -2119,6 +2152,9 @@
       r -> bDebug          = pConf -> bDebug ;
   #ifdef EP2
       r -> bEP1Compat      = pConf -> bEP1Compat ;
  +    ppSV = hv_fetch(r -> pEnvHash, "PATH_INFO", sizeof ("PATH_INFO") - 1, 0) ;  
  +    if (ppSV)
  +        r -> sPathInfo = SvPV (*ppSV ,len) ;
   #endif
       if (rc != ok)
           r -> bDebug = 0 ; /* Turn debbuging off, only errors will go to stderr if 
logfile not open */
  @@ -2910,10 +2946,26 @@
   #ifdef EP2
       if (!r -> bEP1Compat)
        {
  -     tProcessor p2 = {2, "Embperl", embperl_CompileProcessor, NULL, 
embperl_ExecuteProcessor, "", 0, NULL, NULL } ; 
  -     tProcessor p1 = {1, "Parser",  embperl_ParseProcessor,   NULL, NULL,           
          "", 0, NULL, &p2  } ; 
  +     tConf * pConf = r -> pConf ;
  +     
  +     tProcessor p2 = {2, "Embperl", embperl_CompileProcessor, NULL, 
embperl_PreExecuteProcessor, embperl_ExecuteProcessor, "", 
  +                        pConf -> pCacheKeyCV, pConf -> bCacheKeyOptions, pConf -> 
nExpiresIn, pConf -> pExpiresCV, NULL } ; 
  +     tProcessor p1 = {1, "Parser",  embperl_ParseProcessor,   NULL, NULL,           
             NULL,                     "", NULL, 0, 0, NULL, &p2  } ; 
   
  +     if (p2.pCacheKeyCV)
  +         SvREFCNT_inc (p2.pCacheKeyCV) ;
  +
  +     if (p2.pOutputExpiresCV)
  +         SvREFCNT_inc (p2.pOutputExpiresCV) ;
  +
        rc = embperl_CompileDocument (r, &p1) ;
  +
  +     if (p2.pCacheKeyCV)
  +         SvREFCNT_dec (p2.pCacheKeyCV) ;
  +
  +     if (p2.pOutputExpiresCV)
  +         SvREFCNT_dec (p2.pOutputExpiresCV) ;
  +
        }
       else
           {
  @@ -3080,16 +3132,20 @@
   /*                                                                              */
   /* ---------------------------------------------------------------------------- */
   
  -static int ReadInputFile     (/*i/o*/ register req * r)
  +int ReadInputFile    (/*i/o*/ register req * r)
   
       {
       int          rc = ok ;
       SV *    pBufSV = NULL ;
       req *   pMain = r ;
   
  -#ifdef EP2
  +#ifdef xxxEP2
       if (!r -> bEP1Compat)
        {
  +     r -> Buf.pBuf               = NULL ;
  +     r -> Buf.pFile -> nFilesize     = 1 ;
  +     return ok ;
  +/*
        SV * * ppSV ;
        
        ppSV = hv_fetch (r -> Buf.pFile -> pCacheHash, "SRCDOM", 6, 0) ;
  @@ -3099,6 +3155,7 @@
            r -> Buf.pFile -> nFilesize     = 1 ;
            return ok ;  /* source already parsed */
            }
  +*/
        }
   #endif
   
  @@ -3253,7 +3310,11 @@
           rc = StartOutput (r) ;
   
       /* --- read input file or get input file from memory --- */
  +#ifdef EP2
  +    if (rc == ok && r -> bEP1Compat)
  +#else
       if (rc == ok)
  +#endif
        rc = ReadInputFile (r) ;
   
       if (rc == ok && r -> Buf.pBuf == NULL && r -> Buf.pFile -> nFilesize == 0)
  
  
  
  1.23      +2 -0      embperl/epnames.h
  
  Index: epnames.h
  ===================================================================
  RCS file: /home/cvs/embperl/epnames.h,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- epnames.h 2000/11/28 19:24:00     1.22
  +++ epnames.h 2000/12/03 13:54:34     1.23
  @@ -24,6 +24,7 @@
   #define oCommitToMem           EMBPERL_oCommitToMem
   #define OpenInput              EMBPERL_OpenInput         
   #define CloseInput             EMBPERL_CloseInput        
  +#define ReadInputFile          EMBPERL_ReadInputFile        
   #define iread                  EMBPERL_iread             
   #define igets                  EMBPERL_igets             
   #define OpenOutput             EMBPERL_OpenOutput        
  @@ -44,6 +45,7 @@
   #define Eval                   EMBPERL_Eval              
   #define EvalNum                EMBPERL_EvalNum           
   #define EvalBool               EMBPERL_EvalBool           
  +#define EvalConfig             EMBPERL_EvalConfig
   #define stristr                EMBPERL_stristr           
   #define strlower               EMBPERL_strlower          
   #define TransHtml              EMBPERL_TransHtml         
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to