brian       97/09/15 20:51:30

  Modified:    src/modules/standard mod_usertrack.c
               src      INDENT
  Log:
  indent.  Hopefully this was done right.
  
  Revision  Changes    Path
  1.19      +143 -136  apachen/src/modules/standard/mod_usertrack.c
  
  Index: mod_usertrack.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_usertrack.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- mod_usertrack.c   1997/09/11 19:32:50     1.18
  +++ mod_usertrack.c   1997/09/16 03:51:19     1.19
  @@ -6,7 +6,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -54,7 +54,7 @@
    *
    * This Apache module is designed to track users paths through a site.
    * It uses the client-side state ("Cookie") protocol developed by Netscape.
  - * It is known to work on Netscape browsers, Microsoft Internet 
  + * It is known to work on Netscape browsers, Microsoft Internet
    * Explorer and others currently being developed.
    *
    * Each time a page is requested we look to see if the browser is sending
  @@ -72,7 +72,7 @@
    *
    * Example 1 : If you currently use the standard Log file format (CLF)
    * and use the command "TransferLog somefilename", add the line
  - *       LogFormat "%h %l %u %t \"%r\" %s %b %{Cookie}n" 
  + *       LogFormat "%h %l %u %t \"%r\" %s %b %{Cookie}n"
    * to your config file.
    *
    * Example 2 : If you used to use the old "CookieLog" directive, you
  @@ -81,7 +81,7 @@
    *
    * Notes:
    * 1.  This code now logs the initial transaction (the one that created
  - *     the cookie to start with).  
  + *     the cookie to start with).
    * 2.  This module has been designed to not interfere with other Cookies
    *     your site may be using; just avoid sending out cookies with
    *     the name "Apache=" or things will get confused.
  @@ -106,10 +106,10 @@
   typedef struct {
       int always;
       time_t expires;
  -} cookie_log_state;
  +}      cookie_log_state;
   
   static const char month_names[12][4] = {
  -    "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
  +    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", 
"Nov", "Dec"
   };
   
   /* Define this to allow post-2000 cookies. Cookies use two-digit dates,
  @@ -124,189 +124,196 @@
   
   void make_cookie(request_rec *r)
   {
  -    cookie_log_state *cls = get_module_config (r->server->module_config,
  -                                            &usertrack_module);
  +    cookie_log_state *cls = get_module_config(r->server->module_config,
  +                                              &usertrack_module);
   #if defined(NO_GETTIMEOFDAY) && !defined(NO_TIMES)
       clock_t mpe_times;
       struct tms mpe_tms;
   #elif !defined(WIN32)
       struct timeval tv;
  -    struct timezone tz = { 0 , 0 };
  +    struct timezone tz = {0, 0};
   #endif
       /* 1024 == hardcoded constants */
  -    char *new_cookie = palloc( r->pool, 1024);       
  -    char *cookiebuf = palloc( r->pool, 1024);
  +    char *new_cookie = palloc(r->pool, 1024);
  +    char *cookiebuf = palloc(r->pool, 1024);
       char *dot;
  -    const char *rname = pstrdup(r->pool, 
  -                         get_remote_host(r->connection, r->per_dir_config,
  -                                             REMOTE_NAME));
  +    const char *rname = pstrdup(r->pool,
  +                           get_remote_host(r->connection, r->per_dir_config,
  +                                           REMOTE_NAME));
   
  -    if ((dot = strchr(rname,'.'))) *dot='\0';        /* First bit of 
hostname */
  +    if ((dot = strchr(rname, '.')))
  +        *dot = '\0';            /* First bit of hostname */
   
   #if defined(NO_GETTIMEOFDAY) && !defined(NO_TIMES)
   /* We lack gettimeofday(), so we must use time() to obtain the epoch
      seconds, and then times() to obtain CPU clock ticks (milliseconds).
      Combine this together to obtain a hopefully unique cookie ID. */
   
  -    mpe_times=times(&mpe_tms);
  +    mpe_times = times(&mpe_tms);
   
  -    ap_snprintf(cookiebuf, 1024, "%s%d%ld%ld", rname, (int)getpid(),
  -              (long)r->request_time, (long)mpe_tms.tms_utime);
  +    ap_snprintf(cookiebuf, 1024, "%s%d%ld%ld", rname, (int) getpid(),
  +                (long) r->request_time, (long) mpe_tms.tms_utime);
   #elif defined(WIN32)
  -    /* We lack gettimeofday() and we lack times(). So we'll use
  -     * a combination of time() and GetTickCount(), which returns
  -     * milliseconds since Windows was started. It should be relatively
  -     * unique.
  +    /*
  +     * We lack gettimeofday() and we lack times(). So we'll use a combination
  +     * of time() and GetTickCount(), which returns milliseconds since Windows
  +     * was started. It should be relatively unique.
        */
   
  -     ap_snprintf(cookiebuf, 1024, "%s%d%ld%ld", rname, (int)getpid(),
  -                 (long)r->request_time, (long)GetTickCount());
  +    ap_snprintf(cookiebuf, 1024, "%s%d%ld%ld", rname, (int) getpid(),
  +                (long) r->request_time, (long) GetTickCount());
   
   #else
       gettimeofday(&tv, &tz);
   
  -    ap_snprintf(cookiebuf, 1024, "%s%d%ld%d", rname, (int)getpid(),
  -           (long)tv.tv_sec, (int)tv.tv_usec/1000);       
  +    ap_snprintf(cookiebuf, 1024, "%s%d%ld%d", rname, (int) getpid(),
  +                (long) tv.tv_sec, (int) tv.tv_usec / 1000);
   #endif
   
       if (cls->expires) {
  -      static const char *const days[7]=
  -          {"Sun","Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  -      struct tm *tms;
  -      time_t when = r->request_time + cls->expires;
  -
  -#ifndef MILLENIAL_COOKIES      
  -      /* Only two-digit date string, so we can't trust "00" or more.
  -       * Therefore, we knock it all back to just before midnight on
  -       * 1/1/2000 (which is 946684799)
  -       */
  +        static const char *const days[7] =
  +        {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  +        struct tm *tms;
  +        time_t when = r->request_time + cls->expires;
  +
  +#ifndef MILLENIAL_COOKIES
  +        /*
  +         * Only two-digit date string, so we can't trust "00" or more.
  +         * Therefore, we knock it all back to just before midnight on
  +         * 1/1/2000 (which is 946684799)
  +         */
   
  -      if (when > 946684799)
  -     when = 946684799;
  +        if (when > 946684799)
  +            when = 946684799;
   #endif
  -      tms = gmtime(&when);
  +        tms = gmtime(&when);
   
  -      /* Cookie with date; as strftime '%a, %d-%h-%y %H:%M:%S GMT' */
  -      ap_snprintf(new_cookie, 1024,
  -        "%s%s; path=/; expires=%s, %.2d-%s-%.2d %.2d:%.2d:%.2d GMT",
  -           COOKIE_NAME, cookiebuf, days[tms->tm_wday],
  -           tms->tm_mday, month_names[tms->tm_mon],
  -           (tms->tm_year >= 100) ? tms->tm_year - 100 : tms->tm_year,
  -           tms->tm_hour, tms->tm_min, tms->tm_sec);
  +        /* Cookie with date; as strftime '%a, %d-%h-%y %H:%M:%S GMT' */
  +        ap_snprintf(new_cookie, 1024,
  +                "%s%s; path=/; expires=%s, %.2d-%s-%.2d %.2d:%.2d:%.2d GMT",
  +                    COOKIE_NAME, cookiebuf, days[tms->tm_wday],
  +                    tms->tm_mday, month_names[tms->tm_mon],
  +                  (tms->tm_year >= 100) ? tms->tm_year - 100 : tms->tm_year,
  +                    tms->tm_hour, tms->tm_min, tms->tm_sec);
       }
       else
  -      ap_snprintf(new_cookie, 1024, "%s%s; path=/", COOKIE_NAME, cookiebuf);
  +        ap_snprintf(new_cookie, 1024, "%s%s; path=/", COOKIE_NAME, 
cookiebuf);
   
  -    table_set(r->headers_out,"Set-Cookie",new_cookie);
  -    table_set(r->notes, "cookie", cookiebuf); /* log first time */
  +    table_set(r->headers_out, "Set-Cookie", new_cookie);
  +    table_set(r->notes, "cookie", cookiebuf);   /* log first time */
       return;
   }
   
   int spot_cookie(request_rec *r)
   {
  -    int *enable = (int *)get_module_config(r->per_dir_config,
  -                                         &usertrack_module);
  +    int *enable = (int *) get_module_config(r->per_dir_config,
  +                                            &usertrack_module);
       char *cookie;
       char *value;
   
  -    if (!*enable) return DECLINED;
  +    if (!*enable)
  +        return DECLINED;
   
  -    if ((cookie = table_get (r->headers_in, "Cookie")))
  -      if ((value=strstr(cookie,COOKIE_NAME))) {
  -     char *cookiebuf, *cookieend;
  -
  -     value+=strlen(COOKIE_NAME);
  -     cookiebuf=pstrdup( r->pool, value );
  -     cookieend=strchr(cookiebuf,';');
  -     if (cookieend) *cookieend='\0'; /* Ignore anything after a ; */
  +    if ((cookie = table_get(r->headers_in, "Cookie")))
  +        if ((value = strstr(cookie, COOKIE_NAME))) {
  +            char *cookiebuf, *cookieend;
  +
  +            value += strlen(COOKIE_NAME);
  +            cookiebuf = pstrdup(r->pool, value);
  +            cookieend = strchr(cookiebuf, ';');
  +            if (cookieend)
  +                *cookieend = '\0';      /* Ignore anything after a ; */
   
  -     /* Set the cookie in a note, for logging */
  -     table_set(r->notes, "cookie", cookiebuf);
  +            /* Set the cookie in a note, for logging */
  +            table_set(r->notes, "cookie", cookiebuf);
   
  -     return DECLINED;          /* Theres already a cookie, no new one */
  -      }
  +            return DECLINED;    /* Theres already a cookie, no new one */
  +        }
       make_cookie(r);
  -    return OK;                        /* We set our cookie */
  +    return OK;                  /* We set our cookie */
   }
   
  -void *make_cookie_log_state (pool *p, server_rec *s)
  +void *make_cookie_log_state(pool *p, server_rec *s)
   {
       cookie_log_state *cls =
  -      (cookie_log_state *)palloc (p, sizeof (cookie_log_state));
  +    (cookie_log_state *) palloc(p, sizeof(cookie_log_state));
   
       cls->expires = 0;
   
  -    return (void *)cls;
  +    return (void *) cls;
   }
   
  -void *make_cookie_dir (pool *p, char *d) {
  -    return (void *)pcalloc(p, sizeof(int));
  +void *make_cookie_dir(pool *p, char *d)
  +{
  +    return (void *) pcalloc(p, sizeof(int));
   }
   
  -const char *set_cookie_enable (cmd_parms *cmd, int *c, int arg)
  +const char *set_cookie_enable(cmd_parms *cmd, int *c, int arg)
   {
       *c = arg;
       return NULL;
   }
   
  -const char *set_cookie_exp (cmd_parms *parms, void *dummy, const char *arg)
  +const char *set_cookie_exp(cmd_parms *parms, void *dummy, const char *arg)
   {
  -    cookie_log_state *cls = get_module_config (parms->server->module_config,
  -                           &usertrack_module);
  +    cookie_log_state *cls = get_module_config(parms->server->module_config,
  +                                              &usertrack_module);
       time_t factor, modifier = 0;
       time_t num = 0;
       char *word;
   
       /* The simple case first - all numbers (we assume) */
  -    if (isdigit(arg[0]) && isdigit(arg[strlen(arg)-1])) {
  -      cls->expires = atol(arg);
  -      return NULL;
  +    if (isdigit(arg[0]) && isdigit(arg[strlen(arg) - 1])) {
  +        cls->expires = atol(arg);
  +        return NULL;
       }
   
  -    /* The harder case - stolen from mod_expires
  +    /*
  +     * The harder case - stolen from mod_expires 
  +     *
        * CookieExpires "[plus] {<num> <type>}*"
        */
   
  -    word = getword_conf( parms->pool, &arg );
  -    if ( !strncasecmp( word, "plus", 1 ) ) {
  -        word = getword_conf( parms->pool, &arg );
  +    word = getword_conf(parms->pool, &arg);
  +    if (!strncasecmp(word, "plus", 1)) {
  +        word = getword_conf(parms->pool, &arg);
       };
   
       /* {<num> <type>}* */
  -    while ( word[0] ) {
  +    while (word[0]) {
           /* <num> */
  -        if ( strchr("0123456789", word[0]) != NULL )
  -       num = atoi( word );
  -     else
  -       return "bad expires code, numeric value expected.";
  -      
  -     /* <type> */
  -     word = getword_conf( parms->pool, &arg );
  -     if (!word[0] )
  -       return "bad expires code, missing <type>";
  -       
  -     factor = 0;
  -     if ( !strncasecmp( word, "years", 1 ) )
  -       factor = 60*60*24*365;
  -     else if ( !strncasecmp( word, "months", 2 ) )
  -       factor = 60*60*24*30;
  -     else if ( !strncasecmp( word, "weeks", 1 ) )
  -       factor = 60*60*24*7;
  -     else if ( !strncasecmp( word, "days", 1 ) )
  -       factor = 60*60*24;
  -     else if ( !strncasecmp( word, "hours", 1 ) )
  -       factor = 60*60;
  -     else if ( !strncasecmp( word, "minutes", 2 ) )
  -       factor = 60;
  -     else if ( !strncasecmp( word, "seconds", 1 ) )
  -       factor = 1;
  -     else
  -       return "bad expires code, unrecognized type";
  +        if (strchr("0123456789", word[0]) != NULL)
  +            num = atoi(word);
  +        else
  +            return "bad expires code, numeric value expected.";
  +
  +        /* <type> */
  +        word = getword_conf(parms->pool, &arg);
  +        if (!word[0])
  +            return "bad expires code, missing <type>";
  +
  +        factor = 0;
  +        if (!strncasecmp(word, "years", 1))
  +            factor = 60 * 60 * 24 * 365;
  +        else if (!strncasecmp(word, "months", 2))
  +            factor = 60 * 60 * 24 * 30;
  +        else if (!strncasecmp(word, "weeks", 1))
  +            factor = 60 * 60 * 24 * 7;
  +        else if (!strncasecmp(word, "days", 1))
  +            factor = 60 * 60 * 24;
  +        else if (!strncasecmp(word, "hours", 1))
  +            factor = 60 * 60;
  +        else if (!strncasecmp(word, "minutes", 2))
  +            factor = 60;
  +        else if (!strncasecmp(word, "seconds", 1))
  +            factor = 1;
  +        else
  +            return "bad expires code, unrecognized type";
   
  -     modifier = modifier + factor * num;
  +        modifier = modifier + factor * num;
   
  -     /* next <num> */
  -     word = getword_conf( parms->pool, &arg );
  +        /* next <num> */
  +        word = getword_conf(parms->pool, &arg);
       }
   
       cls->expires = modifier;
  @@ -315,31 +322,31 @@
   }
   
   command_rec cookie_log_cmds[] = {
  -{ "CookieExpires", set_cookie_exp, NULL, RSRC_CONF, TAKE1,
  -    "an expiry date code" },
  -{ "CookieTracking", set_cookie_enable, NULL, OR_FILEINFO, FLAG,
  -    "whether or not to enable cookies" },
  -{ NULL }
  +    {"CookieExpires", set_cookie_exp, NULL, RSRC_CONF, TAKE1,
  +    "an expiry date code"},
  +    {"CookieTracking", set_cookie_enable, NULL, OR_FILEINFO, FLAG,
  +    "whether or not to enable cookies"},
  +    {NULL}
   };
   
   module MODULE_VAR_EXPORT usertrack_module = {
  -   STANDARD_MODULE_STUFF,
  -   NULL,                     /* initializer */
  -   make_cookie_dir,          /* dir config creater */
  -   NULL,                     /* dir merger --- default is to override */
  -   make_cookie_log_state,    /* server config */
  -   NULL,                     /* merge server configs */
  -   cookie_log_cmds,          /* command table */
  -   NULL,                     /* handlers */
  -   NULL,                     /* filename translation */
  -   NULL,                     /* check_user_id */
  -   NULL,                     /* check auth */
  -   NULL,                     /* check access */
  -   NULL,                     /* type_checker */
  -   spot_cookie,                      /* fixups */
  -   NULL,                     /* logger */
  -   NULL,                     /* header parser */
  -   NULL,                     /* child_init */
  -   NULL,                     /* child_exit */
  -   NULL                              /* post read-request */
  +    STANDARD_MODULE_STUFF,
  +    NULL,                       /* initializer */
  +    make_cookie_dir,            /* dir config creater */
  +    NULL,                       /* dir merger --- default is to override */
  +    make_cookie_log_state,      /* server config */
  +    NULL,                       /* merge server configs */
  +    cookie_log_cmds,            /* command table */
  +    NULL,                       /* handlers */
  +    NULL,                       /* filename translation */
  +    NULL,                       /* check_user_id */
  +    NULL,                       /* check auth */
  +    NULL,                       /* check access */
  +    NULL,                       /* type_checker */
  +    spot_cookie,                /* fixups */
  +    NULL,                       /* logger */
  +    NULL,                       /* header parser */
  +    NULL,                       /* child_init */
  +    NULL,                       /* child_exit */
  +    NULL                        /* post read-request */
   };
  
  
  
  1.23      +5 -5      apachen/src/INDENT
  
  Index: INDENT
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/INDENT,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- INDENT    1997/09/16 03:44:36     1.22
  +++ INDENT    1997/09/16 03:51:29     1.23
  @@ -82,16 +82,16 @@
      mod_log_referer.c
      mod_mime.c
      mod_mime.h
  -   mod_mime_magic.c
  +   mod_mime_magic.c          RESERVED by Brian
      mod_negotiation.c         DONE by Ken
      mod_rewrite.c
      mod_rewrite.h
      mod_setenvif.c            DONE by Ken
  -   mod_speling.c
  +   mod_speling.c             RESERVED by Brian
      mod_status.c
  -   mod_unique_id.c
  -   mod_userdir.c
  -   mod_usertrack.c           RESERVED by Brian
  +   mod_unique_id.c           RESERVED by Brian
  +   mod_userdir.c             RESERVED by Brian
  +   mod_usertrack.c           DONE by Brian
   
   ./os/unix:
      os-inline.c
  
  
  

Reply via email to