richter     2003/02/14 14:54:04

  Modified:    .        epcfg.h epcgiinit.c eppriv.h eputil.c mod_embperl.c
               podsrc   Config.spod
  Log:
  cookie expires relativ times
  
  Revision  Changes    Path
  1.4       +1 -1      embperl/epcfg.h
  
  Index: epcfg.h
  ===================================================================
  RCS file: /home/cvs/embperl/epcfg.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- epcfg.h   26 Nov 2002 10:03:40 -0000      1.3
  +++ epcfg.h   14 Feb 2003 22:54:03 -0000      1.4
  @@ -55,7 +55,7 @@
   EPCFG_STR(AppConfig,     char *,  sCookieName,      COOKIE_NAME) 
   EPCFG_STR(AppConfig,     char *,  sCookieDomain,    COOKIE_DOMAIN)
   EPCFG_STR(AppConfig,     char *,  sCookiePath,      COOKIE_PATH) 
  -EPCFG_STR(AppConfig,     char *,  sCookieExpires,   COOKIE_EXPIRES) 
  +EPCFG_EXPIRES(AppConfig,     char *,  sCookieExpires,   COOKIE_EXPIRES) 
   EPCFG_BOOL(AppConfig,     bool,    bCookieSecure,    COOKIE_SECURE) 
   EPCFG_STR(AppConfig,     char *,  sLog,             LOG) 
   EPCFG_INTOPT(AppConfig,     unsigned,bDebug,           DEBUG) 
  
  
  
  1.5       +11 -1     embperl/epcgiinit.c
  
  Index: epcgiinit.c
  ===================================================================
  RCS file: /home/cvs/embperl/epcgiinit.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- epcgiinit.c       2 Jan 2003 07:39:44 -0000       1.4
  +++ epcgiinit.c       14 Feb 2003 22:54:03 -0000      1.5
  @@ -61,6 +61,16 @@
       pConfig -> NAME   = GetHashValueStrDup (aTHX_ pPool, pThread -> pEnvHash, 
REDIR"EMBPERL_"#CFGNAME, pConfig -> NAME) ; \
       tainted = 0 ; 
   
  +#undef EPCFG_EXPIRES
  +#define EPCFG_EXPIRES(STRUCT,TYPE,NAME,CFGNAME) \
  +    tainted = 0 ; \
  +    { \
  +    char buf [256] ; \
  +    pConfig -> NAME   = ep_pstrdup (pPool, embperl_CalcExpires (GetHashValueStr 
(aTHX_ pThread -> pEnvHash, REDIR"EMBPERL_"#CFGNAME, pConfig -> NAME), \
  +                                                                buf, 0)) ; \
  +    } \
  +    tainted = 0 ; 
  +
   #undef EPCFG_CHAR
   #define EPCFG_CHAR(STRUCT,TYPE,NAME,CFGNAME) \
       { \
  
  
  
  1.4       +2 -1      embperl/eppriv.h
  
  Index: eppriv.h
  ===================================================================
  RCS file: /home/cvs/embperl/eppriv.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- eppriv.h  26 Nov 2002 10:03:42 -0000      1.3
  +++ eppriv.h  14 Feb 2003 22:54:03 -0000      1.4
  @@ -232,6 +232,7 @@
                                 /*in*/ const char *  sOptions,
                                 /*in*/ int *         pnValue) ;
   
  +char * embperl_CalcExpires(char *sTime, char * sResult, int bHTTP) ;
   
   
   
  
  
  
  1.30      +95 -1     embperl/eputil.c
  
  Index: eputil.c
  ===================================================================
  RCS file: /home/cvs/embperl/eputil.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- eputil.c  8 Jan 2003 06:03:23 -0000       1.29
  +++ eputil.c  14 Feb 2003 22:54:03 -0000      1.30
  @@ -1899,6 +1899,100 @@
       return ok ;
       }
   
  +/* ------------------------------------------------------------------------ */
  +/*                                                                          */
  +/* embperl_CalcExpires                                                           */
  +/*                                                                          */
  +/*! 
  +*   \_en
  +*   Convert Expires time to HTTP format
  +*   @param  sTime           Time to convert
  +*   @param  sResult      Buffer for result
  +*   @param  bHTTP           http format
  +*   @return                 error code
  +*   
  +*   \endif                                                                       
  +*
  +*   \_de                                                                        
  +*   Kovertiert Zeitangabe in HTTP Format
  +*   @param  sTime           Zeit die konvertioert werden soll
  +*   @param  sResult      Buffer f�r resultat
  +*   @param  bHTTP           http format
  +*   @return                 Fehlercode
  +*   
  +*   \endif                                                                       
  +*                                                                          
  +* ------------------------------------------------------------------------ */
  +
  +/* parts from libareq */
  +
  +static time_t expire_calc(char *time_str)
  +{
  +    int is_neg = 0, offset = 0;
  +    char buf[256];
  +    int ix = 0;
  +
  +    if (*time_str == '-') {
  +     is_neg = 1;
  +     ++time_str;
  +    }
  +    else if (*time_str == '+') {
  +     ++time_str;
  +    }
  +    else if (strcaseEQ(time_str, "now")) {
  +     /*ok*/
  +    }
  +    else {
  +     return 0;
  +    }
  +
  +    /* wtf, ap_isdigit() returns false for '1' !? */
  +    while (*time_str && (ap_isdigit(*time_str) || (*time_str == '1'))) {
  +     buf[ix++] = *time_str++;
  +    }
  +    buf[ix] = '\0';
  +    offset = atoi(buf);
  +
  +    return time(NULL) +
  +     (expire_mult(*time_str) * (is_neg ? (0 - offset) : offset));
  +}
  +
  +static const char ep_month_snames[12][4] =
  +    {
  +    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", 
"Dec"
  +    };
  +static const char ep_day_snames[7][4] =
  +    {
  +    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  +    };
  +        
  +
  +char * embperl_CalcExpires(char *sTime, char * sResult, int bHTTP)
  +{
  +    time_t when;
  +    struct tm *tms;
  +    int sep = bHTTP ? ' ' : '-';
  +
  +    if (!sTime) {
  +     return NULL;
  +    }
  +
  +    when = expire_calc(sTime);
  +
  +    if (!when) {
  +     return sTime ;
  +    }
  +
  +    tms = gmtime(&when);
  +    return sprintf(sResult,
  +                    "%s, %.2d%c%s%c%.2d %.2d:%.2d:%.2d GMT",
  +                    ep_day_snames[tms->tm_wday],
  +                    tms->tm_mday, sep, ep_month_snames[tms->tm_mon], sep,
  +                    tms->tm_year + 1900,
  +                    tms->tm_hour, tms->tm_min, tms->tm_sec);
  +}
  +
  +
   
   
   
  
  
  
  1.7       +15 -1     embperl/mod_embperl.c
  
  Index: mod_embperl.c
  ===================================================================
  RCS file: /home/cvs/embperl/mod_embperl.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mod_embperl.c     28 Jan 2003 07:21:27 -0000      1.6
  +++ mod_embperl.c     14 Feb 2003 22:54:03 -0000      1.7
  @@ -56,6 +56,7 @@
   #define EPCFG_INTOPT EPCFG
   #define EPCFG_BOOL EPCFG
   #define EPCFG_CHAR EPCFG
  +#define EPCFG_EXPIRES EPCFG_STR
   
   #define EPCFG_CV EPCFG_SAVE
   #define EPCFG_SV EPCFG_SAVE
  @@ -612,6 +613,19 @@
       { \
       apr_pool_t * p = cmd -> pool ;    \
       ((tApacheDirConfig *)pDirCfg) -> STRUCT.NAME = ap_pstrdup(p, arg) ; \
  +    ((tApacheDirConfig *)pDirCfg) -> set_##STRUCT##NAME = 1 ; \
  +    if (bApDebug) \
  +        ap_log_error (APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, APLOG_STATUSCODE 
NULL, "Embperl: Set "#CFGNAME" (type="#TYPE";STR) = %s\n", arg) ; \
  +    return NULL; \
  +    } 
  +
  +#undef EPCFG_EXPIRES
  +#define EPCFG_EXPIRES(STRUCT,TYPE,NAME,CFGNAME) \
  +const char * embperl_Apache_Config_##STRUCT##NAME (cmd_parms *cmd, /* 
tApacheDirConfig */ void * pDirCfg, const char* arg) \
  +    { \
  +    apr_pool_t * p = cmd -> pool ;    \
  +    char buf[256] ; \
  +    ((tApacheDirConfig *)pDirCfg) -> STRUCT.NAME = ap_pstrdup(p, 
embperl_CalcExpires(arg, buf, 0)) ; \
       ((tApacheDirConfig *)pDirCfg) -> set_##STRUCT##NAME = 1 ; \
       if (bApDebug) \
           ap_log_error (APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, APLOG_STATUSCODE 
NULL, "Embperl: Set "#CFGNAME" (type="#TYPE";STR) = %s\n", arg) ; \
  
  
  
  1.7       +12 -1     embperl/podsrc/Config.spod
  
  Index: Config.spod
  ===================================================================
  RCS file: /home/cvs/embperl/podsrc/Config.spod,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Config.spod       3 Jan 2003 05:49:38 -0000       1.6
  +++ Config.spod       14 Feb 2003 22:54:04 -0000      1.7
  @@ -367,7 +367,18 @@
   =head2 *CFG $application / Embperl_COOKIE_EXPIRES / cookie_expires / 1.3b5 / no / 
at the end of the session / Session Handling
   
   Set the expiration date that Embperl uses for the cookie with the session id.
  -You can specify the full date or relativ values. Examples: +30s +10m +1h -1d +3M 
+10y
  +You can specify the full date or relativ values. 
  +The following forms are all valid times:
  +
  +        +30s                              30 seconds from now
  +        +10m                              ten minutes from now
  +        +1h                               one hour from now
  +        -1d                               yesterday (i.e. "ASAP!")
  +        now                               immediately
  +        +3M                               in three months
  +        +10y                              in ten years time
  +        Thursday, 25-Apr-1999 00:40:33 GMT  at the indicated time & date
  +
   
   =head2 *CFG $application / Embperl_COOKIE_SECURE / cookie_secure / 2.0b9 / no / at 
the end of the session / Session Handling
   
  
  
  

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

Reply via email to