randy       97/09/14 15:19:04

  Modified:    src/main util.c util_date.c util_date.h util_md5.c
                        util_md5.h util_script.c util_script.h
                        util_snprintf.c
  Log:
  indent
  
  Revision  Changes    Path
  1.69      +693 -594  apachen/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util.c,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- util.c    1997/08/28 01:37:00     1.68
  +++ util.c    1997/09/14 22:18:57     1.69
  @@ -61,51 +61,56 @@
   #include "httpd.h"
   #include "http_conf_globals.h"       /* for user_id & group_id */
   
  -const char month_snames[12][4] = {
  -    "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
  +const char month_snames[12][4] =
  +{
  +    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", 
"Nov", "Dec"
   };
   
  -API_EXPORT(char *) get_time() {
  +API_EXPORT(char *) get_time()
  +{
       time_t t;
       char *time_string;
   
  -    t=time(NULL);
  +    t = time(NULL);
       time_string = ctime(&t);
       time_string[strlen(time_string) - 1] = '\0';
       return (time_string);
   }
   
  -API_EXPORT(char *) ht_time(pool *p, time_t t, const char *fmt, int gmt) {
  +API_EXPORT(char *) ht_time(pool *p, time_t t, const char *fmt, int gmt)
  +{
       char ts[MAX_STRING_LEN];
       struct tm *tms;
   
       tms = (gmt ? gmtime(&t) : localtime(&t));
   
       /* check return code? */
  -    strftime(ts,MAX_STRING_LEN,fmt,tms);
  -    return pstrdup (p, ts);
  +    strftime(ts, MAX_STRING_LEN, fmt, tms);
  +    return pstrdup(p, ts);
   }
   
  -API_EXPORT(char *) gm_timestr_822(pool *p, time_t sec) {
  -    static const char *const days[7]=
  -       {"Sun","Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  +API_EXPORT(char *) gm_timestr_822(pool *p, time_t sec)
  +{
  +    static const char *const days[7] =
  +    {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
       char ts[50];
       struct tm *tms;
   
       tms = gmtime(&sec);
   
  -/* RFC date format; as strftime '%a, %d %b %Y %T GMT' */
  -    ap_snprintf(ts, sizeof(ts), 
  -         "%s, %.2d %s %d %.2d:%.2d:%.2d GMT", days[tms->tm_wday],
  -         tms->tm_mday, month_snames[tms->tm_mon], tms->tm_year + 1900,
  -         tms->tm_hour, tms->tm_min, tms->tm_sec);
  +    /* RFC date format; as strftime '%a, %d %b %Y %T GMT' */
  +    ap_snprintf(ts, sizeof(ts),
  +             "%s, %.2d %s %d %.2d:%.2d:%.2d GMT", days[tms->tm_wday],
  +             tms->tm_mday, month_snames[tms->tm_mon], tms->tm_year + 1900,
  +             tms->tm_hour, tms->tm_min, tms->tm_sec);
   
  -    return pstrdup (p, ts);
  +    return pstrdup(p, ts);
   }
   
   /* What a pain in the ass. */
   #if defined(HAVE_GMTOFF)
  -API_EXPORT(struct tm *) get_gmtoff(int *tz) {
  +API_EXPORT(struct tm *) get_gmtoff(int *tz)
  +{
       time_t tt = time(NULL);
       struct tm *t;
   
  @@ -114,18 +119,19 @@
       return t;
   }
   #else
  -API_EXPORT(struct tm *) get_gmtoff(int *tz) {
  +API_EXPORT(struct tm *) get_gmtoff(int *tz)
  +{
       time_t tt = time(NULL);
       struct tm gmt;
       struct tm *t;
       int days, hours, minutes;
   
       /* Assume we are never more than 24 hours away. */
  -    gmt = *gmtime(&tt); /* remember gmtime/localtime return ptr to static */
  -    t = localtime(&tt); /* buffer... so be careful */
  +    gmt = *gmtime(&tt);              /* remember gmtime/localtime return ptr 
to static */
  +    t = localtime(&tt);              /* buffer... so be careful */
       days = t->tm_yday - gmt.tm_yday;
       hours = ((days < -1 ? 24 : 1 < days ? -24 : days * 24)
  -              + t->tm_hour - gmt.tm_hour);
  +          + t->tm_hour - gmt.tm_hour);
       minutes = hours * 60 + t->tm_min - gmt.tm_min;
       *tz = minutes;
       return t;
  @@ -133,62 +139,65 @@
   #endif
   
   
  -/* Match = 0, NoMatch = 1, Abort = -1 */
  -/* Based loosely on sections of wildmat.c by Rich Salz
  +/* Match = 0, NoMatch = 1, Abort = -1
  + * Based loosely on sections of wildmat.c by Rich Salz
    * Hmmm... shouldn't this really go component by component?
    */
  -API_EXPORT(int) strcmp_match(const char *str, const char *exp) {
  -    int x,y;
  +API_EXPORT(int) strcmp_match(const char *str, const char *exp)
  +{
  +    int x, y;
   
  -    for(x=0,y=0;exp[y];++y,++x) {
  -        if((!str[x]) && (exp[y] != '*'))
  -            return -1;
  -        if(exp[y] == '*') {
  -            while(exp[++y] == '*');
  -            if(!exp[y])
  -                return 0;
  -            while(str[x]) {
  -                int ret;
  -                if((ret = strcmp_match(&str[x++],&exp[y])) != 1)
  -                    return ret;
  -            }
  -            return -1;
  -        } else 
  -            if((exp[y] != '?') && (str[x] != exp[y]))
  -                return 1;
  +    for (x = 0, y = 0; exp[y]; ++y, ++x) {
  +     if ((!str[x]) && (exp[y] != '*'))
  +         return -1;
  +     if (exp[y] == '*') {
  +         while (exp[++y] == '*');
  +         if (!exp[y])
  +             return 0;
  +         while (str[x]) {
  +             int ret;
  +             if ((ret = strcmp_match(&str[x++], &exp[y])) != 1)
  +                 return ret;
  +         }
  +         return -1;
  +     }
  +     else if ((exp[y] != '?') && (str[x] != exp[y]))
  +         return 1;
       }
       return (str[x] != '\0');
   }
   
  -API_EXPORT(int) strcasecmp_match(const char *str, const char *exp) {
  -    int x,y;
  +API_EXPORT(int) strcasecmp_match(const char *str, const char *exp)
  +{
  +    int x, y;
   
  -    for(x=0,y=0;exp[y];++y,++x) {
  -        if((!str[x]) && (exp[y] != '*'))
  -            return -1;
  -        if(exp[y] == '*') {
  -            while(exp[++y] == '*');
  -            if(!exp[y])
  -                return 0;
  -            while(str[x]) {
  -                int ret;
  -                if((ret = strcasecmp_match(&str[x++],&exp[y])) != 1)
  -                    return ret;
  -            }
  -            return -1;
  -        } else 
  -            if((exp[y] != '?') && (tolower(str[x]) != tolower(exp[y])))
  -                return 1;
  +    for (x = 0, y = 0; exp[y]; ++y, ++x) {
  +     if ((!str[x]) && (exp[y] != '*'))
  +         return -1;
  +     if (exp[y] == '*') {
  +         while (exp[++y] == '*');
  +         if (!exp[y])
  +             return 0;
  +         while (str[x]) {
  +             int ret;
  +             if ((ret = strcasecmp_match(&str[x++], &exp[y])) != 1)
  +                 return ret;
  +         }
  +         return -1;
  +     }
  +     else if ((exp[y] != '?') && (tolower(str[x]) != tolower(exp[y])))
  +         return 1;
       }
       return (str[x] != '\0');
   }
   
  -API_EXPORT(int) is_matchexp(const char *str) {
  +API_EXPORT(int) is_matchexp(const char *str)
  +{
       register int x;
   
  -    for(x=0;str[x];x++)
  -        if((str[x] == '*') || (str[x] == '?'))
  -            return 1;
  +    for (x = 0; str[x]; x++)
  +     if ((str[x] == '*') || (str[x] == '?'))
  +         return 1;
       return 0;
   }
   
  @@ -207,15 +216,18 @@
    */
   
   API_EXPORT(char *) pregsub(pool *p, const char *input, const char *source,
  -           size_t nmatch, regmatch_t pmatch[]) {
  +                        size_t nmatch, regmatch_t pmatch[])
  +{
       const char *src = input;
       char *dest, *dst;
       char c;
       size_t no;
       int len;
   
  -    if (!source) return NULL;
  -    if (!nmatch) return pstrdup(p, src);
  +    if (!source)
  +     return NULL;
  +    if (!nmatch)
  +     return pstrdup(p, src);
   
       /* First pass, find the size */
   
  @@ -228,12 +240,13 @@
            no = *src++ - '0';
        else
            no = 10;
  -     
  -     if (no > 9) {   /* Ordinary character. */
  +
  +     if (no > 9) {           /* Ordinary character. */
            if (c == '\\' && (*src == '$' || *src == '&'))
                c = *src++;
            len++;
  -     } else if (no < nmatch && pmatch[no].rm_so < pmatch[no].rm_eo) {
  +     }
  +     else if (no < nmatch && pmatch[no].rm_so < pmatch[no].rm_eo) {
            len += pmatch[no].rm_eo - pmatch[no].rm_so;
        }
   
  @@ -252,22 +265,23 @@
            no = *src++ - '0';
        else
            no = 10;
  -     
  -     if (no > 9) {   /* Ordinary character. */
  +
  +     if (no > 9) {           /* Ordinary character. */
            if (c == '\\' && (*src == '$' || *src == '&'))
                c = *src++;
            *dst++ = c;
  -     } else if (no < nmatch && pmatch[no].rm_so < pmatch[no].rm_eo) {
  +     }
  +     else if (no < nmatch && pmatch[no].rm_so < pmatch[no].rm_eo) {
            len = pmatch[no].rm_eo - pmatch[no].rm_so;
            strncpy(dst, source + pmatch[no].rm_so, len);
            dst += len;
  -         if (*(dst-1) == '\0') /* strncpy hit NULL. */
  +         if (*(dst - 1) == '\0')     /* strncpy hit NULL. */
                return NULL;
        }
   
       }
       *dst = '\0';
  -    
  +
       return dest;
   }
   
  @@ -281,62 +295,70 @@
       /* Four paseses, as per RFC 1808 */
       /* a) remove ./ path segments */
   
  -    for (l=0, w=0; name[l] != '\0';)
  -    {
  -     if (name[l] == '.' && name[l+1] == '/' && (l == 0 || name[l-1] == '/'))
  +    for (l = 0, w = 0; name[l] != '\0';) {
  +     if (name[l] == '.' && name[l + 1] == '/' && (l == 0 || name[l - 1] == 
'/'))
            l += 2;
        else
            name[w++] = name[l++];
       }
   
       /* b) remove trailing . path, segment */
  -    if (w == 1 && name[0] == '.') w--;
  -    else if (w > 1 && name[w-1] == '.' && name[w-2] == '/') w--;
  +    if (w == 1 && name[0] == '.')
  +     w--;
  +    else if (w > 1 && name[w - 1] == '.' && name[w - 2] == '/')
  +     w--;
       name[w] = '\0';
   
       /* c) remove all xx/../ segments. (including leading ../ and /../) */
       l = 0;
   
  -    while(name[l]!='\0') {
  -        if(name[l] == '.' && name[l+1] == '.' && name[l+2] == '/' &&
  -         (l == 0 || name[l-1] == '/')) {
  -             register int m=l+3,n;
  -
  -             l=l-2;
  -             if(l>=0) {
  -                 while(l >= 0 && name[l] != '/') l--;
  -                 l++;
  -             }
  -             else l=0;
  -             n=l;
  -             while((name[n]=name[m])) (++n,++m);
  -            }
  -     else ++l;
  +    while (name[l] != '\0') {
  +     if (name[l] == '.' && name[l + 1] == '.' && name[l + 2] == '/' &&
  +         (l == 0 || name[l - 1] == '/')) {
  +         register int m = l + 3, n;
  +
  +         l = l - 2;
  +         if (l >= 0) {
  +             while (l >= 0 && name[l] != '/')
  +                 l--;
  +             l++;
  +         }
  +         else
  +             l = 0;
  +         n = l;
  +         while ((name[n] = name[m]))
  +             (++n, ++m);
  +     }
  +     else
  +         ++l;
       }
   
       /* d) remove trailing xx/.. segment. */
  -    if (l == 2 && name[0] == '.' && name[1] == '.') name[0] = '\0';
  -    else if (l > 2 && name[l-1] == '.' && name[l-2] == '.' && name[l-3] == 
'/')
  -    {
  +    if (l == 2 && name[0] == '.' && name[1] == '.')
  +     name[0] = '\0';
  +    else if (l > 2 && name[l - 1] == '.' && name[l - 2] == '.' && name[l - 
3] == '/') {
        l = l - 4;
  -     if (l >= 0)
  -     {
  -         while (l >= 0 && name[l] != '/') l--;
  +     if (l >= 0) {
  +         while (l >= 0 && name[l] != '/')
  +             l--;
            l++;
        }
  -     else l = 0;
  +     else
  +         l = 0;
        name[l] = '\0';
       }
  -} 
  +}
   
  -API_EXPORT(void) no2slash(char *name) {
  -    register int x,y;
  +API_EXPORT(void) no2slash(char *name)
  +{
  +    register int x, y;
   
  -    for(x=0; name[x];)
  -        if(x && (name[x-1] == '/') && (name[x] == '/'))
  -            for(y=x+1;name[y-1];y++)
  -                name[y-1] = name[y];
  -     else x++;
  +    for (x = 0; name[x];)
  +     if (x && (name[x - 1] == '/') && (name[x] == '/'))
  +         for (y = x + 1; name[y - 1]; y++)
  +             name[y - 1] = name[y];
  +     else
  +         x++;
   }
   
   
  @@ -352,15 +374,16 @@
    *    /a/b, 3  ==> /a/b/
    *    /a/b, 4  ==> /a/b/
    */
  -API_EXPORT(char *) make_dirstr_prefix (char *d, const char *s, int n)
  +API_EXPORT(char *) make_dirstr_prefix(char *d, const char *s, int n)
   {
  -    for(;;) {
  +    for (;;) {
        *d = *s;
        if (*d == '\0') {
            *d = '/';
            break;
        }
  -     if (*d == '/' && (--n) == 0 ) break;
  +     if (*d == '/' && (--n) == 0)
  +         break;
        ++d;
        ++s;
       }
  @@ -372,19 +395,19 @@
   /*
    * return the parent directory name including trailing / of the file s
    */
  -API_EXPORT(char *) make_dirstr_parent (pool *p, const char *s)
  +API_EXPORT(char *) make_dirstr_parent(pool *p, const char *s)
   {
  -    char *last_slash = strrchr (s, '/');
  +    char *last_slash = strrchr(s, '/');
       char *d;
       int l;
   
       if (last_slash == NULL) {
        /* XXX: well this is really broken if this happens */
  -     return (pstrdup (p,"/"));
  +     return (pstrdup(p, "/"));
       }
  -    l = (last_slash-s)+1;
  -    d = palloc (p, l+1);
  -    memcpy (d, s, l);
  +    l = (last_slash - s) + 1;
  +    d = palloc(p, l + 1);
  +    memcpy(d, s, l);
       d[l] = 0;
       return (d);
   }
  @@ -394,32 +417,35 @@
    * This function is deprecated.  Use one of the preceeding two functions
    * which are faster.
    */
  -API_EXPORT(char *) make_dirstr(pool *p, const char *s, int n) {
  -    register int x,f;
  +API_EXPORT(char *) make_dirstr(pool *p, const char *s, int n)
  +{
  +    register int x, f;
       char *res;
   
  -    for(x=0,f=0;s[x];x++) {
  -        if(s[x] == '/')
  -            if((++f) == n) {
  +    for (x = 0, f = 0; s[x]; x++) {
  +     if (s[x] == '/')
  +         if ((++f) == n) {
                res = palloc(p, x + 2);
  -             strncpy (res, s, x);
  +             strncpy(res, s, x);
                res[x] = '/';
  -             res[x+1] = '\0';
  -                return res;
  -            }
  +             res[x + 1] = '\0';
  +             return res;
  +         }
       }
   
       if (s[strlen(s) - 1] == '/')
  -        return pstrdup (p, s);
  +     return pstrdup(p, s);
       else
  -        return pstrcat (p, s, "/", NULL);
  +     return pstrcat(p, s, "/", NULL);
   }
   
  -API_EXPORT(int) count_dirs(const char *path) {
  -    register int x,n;
  +API_EXPORT(int) count_dirs(const char *path)
  +{
  +    register int x, n;
   
  -    for(x=0,n=0;path[x];x++)
  -        if(path[x] == '/') n++;
  +    for (x = 0, n = 0; path[x]; x++)
  +     if (path[x] == '/')
  +         n++;
       return n;
   }
   
  @@ -429,100 +455,106 @@
       const char *x;
       char buf[HUGE_STRING_LEN];
   
  -    x = strrchr (file, '/');
  +    x = strrchr(file, '/');
       if (x == NULL) {
  -     chdir (file);
  -    } else if (x - file < sizeof(buf)-1) {
  -     memcpy (buf, file, x - file);
  +     chdir(file);
  +    }
  +    else if (x - file < sizeof(buf) - 1) {
  +     memcpy(buf, file, x - file);
        buf[x - file] = '\0';
  -     chdir (buf);
  +     chdir(buf);
       }
       /* XXX: well, this is a silly function, no method of reporting an
        * error... ah well. */
   }
   
  -API_EXPORT(char *) getword_nc(pool* atrans, char **line, char stop)
  -    {
  -    return getword(atrans,(const char **)line,stop);
  -    }
  +API_EXPORT(char *) getword_nc(pool *atrans, char **line, char stop)
  +{
  +    return getword(atrans, (const char **) line, stop);
  +}
   
  -API_EXPORT(char *) getword(pool* atrans, const char **line, char stop) {
  +API_EXPORT(char *) getword(pool *atrans, const char **line, char stop)
  +{
       int pos = ind(*line, stop);
       char *res;
   
       if (pos == -1) {
  -        res = pstrdup (atrans, *line);
  -     *line += strlen (*line);
  +     res = pstrdup(atrans, *line);
  +     *line += strlen(*line);
        return res;
       }
  -  
  +
       res = palloc(atrans, pos + 1);
  -    strncpy (res, *line, pos);
  +    strncpy(res, *line, pos);
       res[pos] = '\0';
  -    
  -    while ((*line)[pos] == stop) ++pos;
  -    
  +
  +    while ((*line)[pos] == stop)
  +     ++pos;
  +
       *line += pos;
  -    
  +
       return res;
   }
   
  -API_EXPORT(char *) getword_white_nc(pool* atrans, char **line)
  +API_EXPORT(char *) getword_white_nc(pool *atrans, char **line)
   {
  -    return getword_white(atrans,(const char **)line);
  +    return getword_white(atrans, (const char **) line);
   }
   
  -API_EXPORT(char *) getword_white(pool* atrans, const char **line) {
  +API_EXPORT(char *) getword_white(pool *atrans, const char **line)
  +{
       int pos = -1, x;
       char *res;
   
  -    for(x=0;(*line)[x];x++) {
  -        if (isspace((*line)[x])) {
  -          pos=x;
  -          break;
  -      }
  -   }
  +    for (x = 0; (*line)[x]; x++) {
  +     if (isspace((*line)[x])) {
  +         pos = x;
  +         break;
  +     }
  +    }
   
       if (pos == -1) {
  -        res = pstrdup (atrans, *line);
  -      *line += strlen (*line);
  -      return res;
  +     res = pstrdup(atrans, *line);
  +     *line += strlen(*line);
  +     return res;
       }
   
       res = palloc(atrans, pos + 1);
  -    strncpy (res, *line, pos);
  +    strncpy(res, *line, pos);
       res[pos] = '\0';
   
  -    while (isspace((*line)[pos])) ++pos;
  +    while (isspace((*line)[pos]))
  +     ++pos;
   
       *line += pos;
   
       return res;
   }
   
  -API_EXPORT(char *) getword_nulls_nc(pool* atrans, char **line, char stop)
  +API_EXPORT(char *) getword_nulls_nc(pool *atrans, char **line, char stop)
   {
  -    return getword_nulls(atrans,(const char **)line,stop);
  +    return getword_nulls(atrans, (const char **) line, stop);
   }
   
  -API_EXPORT(char *) getword_nulls(pool* atrans, const char **line, char stop) 
{
  +API_EXPORT(char *) getword_nulls(pool *atrans, const char **line, char stop)
  +{
       int pos = ind(*line, stop);
       char *res;
   
       if (pos == -1) {
  -        res = pstrdup (atrans, *line);
  -     *line += strlen (*line);
  +     res = pstrdup(atrans, *line);
  +     *line += strlen(*line);
        return res;
       }
  -  
  +
       res = palloc(atrans, pos + 1);
  -    strncpy (res, *line, pos);
  +    strncpy(res, *line, pos);
       res[pos] = '\0';
  -    
  +
       ++pos;
  -    
  +
       *line += pos;
  -    
  +
       return res;
   }
   
  @@ -530,15 +562,15 @@
    * all honored
    */
   
  -static char *substring_conf (pool *p, const char *start, int len, char quote)
  +static char *substring_conf(pool *p, const char *start, int len, char quote)
   {
  -    char *result = palloc (p, len + 2);
  +    char *result = palloc(p, len + 2);
       char *resp = result;
       int i;
   
       for (i = 0; i < len; ++i) {
  -        if (start[i] == '\\' && (start[i+1] == '/'
  -                              || (quote && start[i+1] == quote)))
  +     if (start[i] == '\\' && (start[i + 1] == '/'
  +                              || (quote && start[i + 1] == quote)))
            *resp++ = start[++i];
        else
            *resp++ = start[i];
  @@ -548,42 +580,48 @@
       return result;
   }
   
  -API_EXPORT(char *) getword_conf_nc(pool* p, char **line) {
  -    return getword_conf(p,(const char **)line);
  +API_EXPORT(char *) getword_conf_nc(pool *p, char **line)
  +{
  +    return getword_conf(p, (const char **) line);
   }
   
  -API_EXPORT(char *) getword_conf(pool* p, const char **line) {
  +API_EXPORT(char *) getword_conf(pool *p, const char **line)
  +{
       const char *str = *line, *strend;
       char *res;
       char quote;
   
  -    while (*str && isspace (*str))
  -        ++str;
  +    while (*str && isspace(*str))
  +     ++str;
   
       if (!*str) {
  -        *line = str;
  -        return "";
  +     *line = str;
  +     return "";
       }
   
       if ((quote = *str) == '"' || quote == '\'') {
  -        strend = str + 1;
  +     strend = str + 1;
        while (*strend && *strend != quote) {
            if (*strend == '\\' && strend[1] && strend[1] == quote)
                strend += 2;
  -         else ++strend;
  +         else
  +             ++strend;
        }
  -     res = substring_conf (p, str + 1, strend - str - 1, quote);
  +     res = substring_conf(p, str + 1, strend - str - 1, quote);
   
  -     if (*strend == quote) ++strend;
  -    } else {
  -        strend = str;
  -     while (*strend && !isspace (*strend))
  +     if (*strend == quote)
  +         ++strend;
  +    }
  +    else {
  +     strend = str;
  +     while (*strend && !isspace(*strend))
            ++strend;
   
  -     res = substring_conf (p, str, strend - str, 0);
  +     res = substring_conf(p, str, strend - str, 0);
       }
   
  -    while (*strend && isspace(*strend)) ++ strend;
  +    while (*strend && isspace(*strend))
  +     ++strend;
       *line = strend;
       return res;
   }
  @@ -591,56 +629,61 @@
   #ifdef UNDEF
   /* this function is dangerous, and superceded by getword_white, so don't use 
it
    */
  -void cfg_getword(char *word, char *line) {
  -    int x=0,y;
  -    
  -    for(x=0;line[x] && isspace(line[x]);x++);
  -    y=0;
  -    while(1) {
  -        if(!(word[y] = line[x]))
  -            break;
  -        if(isspace(line[x]))
  -            if((!x) || (line[x-1] != '\\'))
  -                break;
  -        if(line[x] != '\\') ++y;
  -        ++x;
  +void cfg_getword(char *word, char *line)
  +{
  +    int x = 0, y;
  +
  +    for (x = 0; line[x] && isspace(line[x]); x++);
  +    y = 0;
  +    while (1) {
  +     if (!(word[y] = line[x]))
  +         break;
  +     if (isspace(line[x]))
  +         if ((!x) || (line[x - 1] != '\\'))
  +             break;
  +     if (line[x] != '\\')
  +         ++y;
  +     ++x;
       }
       word[y] = '\0';
  -    while(line[x] && isspace(line[x])) ++x;
  -    for(y=0;(line[y] = line[x]);++x,++y);
  +    while (line[x] && isspace(line[x]))
  +     ++x;
  +    for (y = 0; (line[y] = line[x]); ++x, ++y);
   }
   #endif
   
  -API_EXPORT(int) cfg_getline(char *s, int n, FILE *f) {
  -    register int i=0, c;
  +API_EXPORT(int) cfg_getline(char *s, int n, FILE *f)
  +{
  +    register int i = 0, c;
   
       s[0] = '\0';
       /* skip leading whitespace */
       do {
  -        c = getc(f);
  +     c = getc(f);
       } while (c == '\t' || c == ' ');
   
  -    if(c == EOF)
  +    if (c == EOF)
        return 1;
   
  -    while(1) {
  -        if((c == '\t') || (c == ' ')) {
  -            s[i++] = ' ';
  -            while((c == '\t') || (c == ' ')) 
  -                c = getc(f);
  -        }
  -        if(c == CR) {
  -            c = getc(f);
  -        }
  -        if(c == EOF || c == 0x4 || c == LF || i == (n-1)) {
  -            /* blast trailing whitespace */
  -            while(i && (s[i-1] == ' ')) --i;
  -            s[i] = '\0';
  +    while (1) {
  +     if ((c == '\t') || (c == ' ')) {
  +         s[i++] = ' ';
  +         while ((c == '\t') || (c == ' '))
  +             c = getc(f);
  +     }
  +     if (c == CR) {
  +         c = getc(f);
  +     }
  +     if (c == EOF || c == 0x4 || c == LF || i == (n - 1)) {
  +         /* blast trailing whitespace */
  +         while (i && (s[i - 1] == ' '))
  +             --i;
  +         s[i] = '\0';
            return 0;
  -        }
  -        s[i] = c;
  -        ++i;
  -        c = getc(f);
  +     }
  +     s[i] = c;
  +     ++i;
  +     c = getc(f);
       }
   }
   
  @@ -650,160 +693,175 @@
    * by whitespace at the caller's option.
    */
   
  -API_EXPORT(char *) get_token (pool *p, char **accept_line, int accept_white)
  +API_EXPORT(char *) get_token(pool *p, char **accept_line, int accept_white)
   {
       char *ptr = *accept_line;
       char *tok_start;
       char *token;
       int tok_len;
  -  
  +
       /* Find first non-white byte */
  -    
  +
       while (*ptr && isspace(*ptr))
  -      ++ptr;
  +     ++ptr;
   
       tok_start = ptr;
  -    
  +
       /* find token end, skipping over quoted strings.
        * (comments are already gone).
        */
  -    
  +
       while (*ptr && (accept_white || !isspace(*ptr))
  -        && *ptr != ';' && *ptr != ',')
  -    {
  +        && *ptr != ';' && *ptr != ',') {
        if (*ptr++ == '"')
            while (*ptr)
  -             if (*ptr++ == '"') break;
  +             if (*ptr++ == '"')
  +                 break;
       }
  -       
  +
       tok_len = ptr - tok_start;
  -    token = palloc (p, tok_len + 1);
  -    strncpy (token, tok_start, tok_len);
  +    token = palloc(p, tok_len + 1);
  +    strncpy(token, tok_start, tok_len);
       token[tok_len] = '\0';
  -    
  +
       /* Advance accept_line pointer to the next non-white byte */
   
       while (*ptr && isspace(*ptr))
  -      ++ptr;
  +     ++ptr;
   
       *accept_line = ptr;
       return token;
   }
   
  -static char* tspecials = " \t()<>@,;:\\/[]?={}";
  +static char *tspecials = " \t()<>@,;:\\/[]?={}";
   
   /* Next HTTP token from a header line.  Warning --- destructive!
    * Use only with a copy!
    */
   
  -static char *next_token (char **toks) {
  +static char *next_token(char **toks)
  +{
       char *cp = *toks;
       char *ret;
   
  -    while (*cp && (iscntrl (*cp) || strchr (tspecials, *cp))) {
  -        if (*cp == '"')
  -       while (*cp && (*cp != '"')) ++cp;
  +    while (*cp && (iscntrl(*cp) || strchr(tspecials, *cp))) {
  +     if (*cp == '"')
  +         while (*cp && (*cp != '"'))
  +             ++cp;
        else
  -       ++cp;
  +         ++cp;
       }
   
  -    if (!*cp) ret = NULL;
  +    if (!*cp)
  +     ret = NULL;
       else {
  -        ret = cp;
  +     ret = cp;
   
  -        while (*cp && !iscntrl(*cp) && !strchr (tspecials, *cp))
  -            ++cp;
  +     while (*cp && !iscntrl(*cp) && !strchr(tspecials, *cp))
  +         ++cp;
   
  -        if (*cp) {
  -            *toks = cp + 1;
  -            *cp = '\0';
  +     if (*cp) {
  +         *toks = cp + 1;
  +         *cp = '\0';
        }
  -        else *toks = cp;
  +     else
  +         *toks = cp;
       }
   
       return ret;
   }
   
  -API_EXPORT(int) find_token (pool *p, const char *line, const char *tok) {
  +API_EXPORT(int) find_token(pool *p, const char *line, const char *tok)
  +{
       char *ltok;
       char *lcopy;
   
  -    if (!line) return 0;
  +    if (!line)
  +     return 0;
   
  -    lcopy = pstrdup (p, line);
  -    while ((ltok = next_token (&lcopy)))
  -        if (!strcasecmp (ltok, tok))
  -            return 1;
  +    lcopy = pstrdup(p, line);
  +    while ((ltok = next_token(&lcopy)))
  +     if (!strcasecmp(ltok, tok))
  +         return 1;
   
       return 0;
   }
   
  -API_EXPORT(int) find_last_token (pool *p, const char *line, const char *tok)
  +API_EXPORT(int) find_last_token(pool *p, const char *line, const char *tok)
   {
       int llen, tlen, lidx;
   
  -    if (!line) return 0;
  +    if (!line)
  +     return 0;
   
       llen = strlen(line);
       tlen = strlen(tok);
       lidx = llen - tlen;
   
       if ((lidx < 0) ||
  -        ((lidx > 0) && !(isspace(line[lidx-1]) || line[lidx-1] == ',')))
  -        return 0;
  +     ((lidx > 0) && !(isspace(line[lidx - 1]) || line[lidx - 1] == ',')))
  +     return 0;
   
       return (strncasecmp(&line[lidx], tok, tlen) == 0);
   }
   
  -API_EXPORT(char *) escape_shell_cmd(pool *p, const char *s) {
  -    register int x,y,l;
  +API_EXPORT(char *) escape_shell_cmd(pool *p, const char *s)
  +{
  +    register int x, y, l;
       char *cmd;
   
  -    l=strlen(s);
  -    cmd = palloc (p, 2 * l + 1); /* Be safe */
  -    strcpy (cmd, s);
  -    
  -    for(x=0;cmd[x];x++) {
  -    
  +    l = strlen(s);
  +    cmd = palloc(p, 2 * l + 1);      /* Be safe */
  +    strcpy(cmd, s);
  +
  +    for (x = 0; cmd[x]; x++) {
  +
   #if defined(__EMX__) || defined(WIN32)
  -        /* Don't allow '&' in parameters under OS/2. */
  -        /* This can be used to send commands to the shell. */
  -        if (cmd[x] == '&') {
  -            cmd[x] = ' ';
  -        }
  +     /* Don't allow '&' in parameters under OS/2. */
  +     /* This can be used to send commands to the shell. */
  +     if (cmd[x] == '&') {
  +         cmd[x] = ' ';
  +     }
   #endif
   
  -        if(ind("&;`'\"|*?~<>^()[]{}$\\\n",cmd[x]) != -1){
  -            for(y=l+1;y>x;y--)
  -                cmd[y] = cmd[y-1];
  -            l++; /* length has been increased */
  -            cmd[x] = '\\';
  -            x++; /* skip the character */
  -        }
  +     if (ind("&;`'\"|*?~<>^()[]{}$\\\n", cmd[x]) != -1) {
  +         for (y = l + 1; y > x; y--)
  +             cmd[y] = cmd[y - 1];
  +         l++;                /* length has been increased */
  +         cmd[x] = '\\';
  +         x++;                /* skip the character */
  +     }
       }
   
       return cmd;
   }
   
  -void plustospace(char *str) {
  +void plustospace(char *str)
  +{
       register int x;
   
  -    for(x=0;str[x];x++) if(str[x] == '+') str[x] = ' ';
  +    for (x = 0; str[x]; x++)
  +     if (str[x] == '+')
  +         str[x] = ' ';
   }
   
  -void spacetoplus(char *str) {
  +void spacetoplus(char *str)
  +{
       register int x;
   
  -    for(x=0;str[x];x++) if(str[x] == ' ') str[x] = '+';
  +    for (x = 0; str[x]; x++)
  +     if (str[x] == ' ')
  +         str[x] = '+';
   }
   
  -static char x2c(const char *what) {
  +static char x2c(const char *what)
  +{
       register char digit;
   
  -    digit = ((what[0] >= 'A') ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - 
'0'));
  +    digit = ((what[0] >= 'A') ? ((what[0] & 0xdf) - 'A') + 10 : (what[0] - 
'0'));
       digit *= 16;
  -    digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - 
'0'));
  -    return(digit);
  +    digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A') + 10 : (what[1] - 
'0'));
  +    return (digit);
   }
   
   /*
  @@ -816,117 +874,120 @@
    *   decoding %2f -> /   (a special character)
    *                      returns NOT_FOUND
    */
  -API_EXPORT(int) unescape_url(char *url) {
  -    register int x,y, badesc, badpath;
  +API_EXPORT(int) unescape_url(char *url)
  +{
  +    register int x, y, badesc, badpath;
   
       badesc = 0;
       badpath = 0;
  -    for(x=0,y=0;url[y];++x,++y) {
  -     if (url[y] != '%') url[x] = url[y];
  -     else
  -     {
  -         if (!isxdigit(url[y+1]) || !isxdigit(url[y+2]))
  -         {
  +    for (x = 0, y = 0; url[y]; ++x, ++y) {
  +     if (url[y] != '%')
  +         url[x] = url[y];
  +     else {
  +         if (!isxdigit(url[y + 1]) || !isxdigit(url[y + 2])) {
                badesc = 1;
                url[x] = '%';
  -         } else
  -         {
  -             url[x] = x2c(&url[y+1]);
  +         }
  +         else {
  +             url[x] = x2c(&url[y + 1]);
                y += 2;
  -             if (url[x] == '/' || url[x] == '\0') badpath = 1;
  +             if (url[x] == '/' || url[x] == '\0')
  +                 badpath = 1;
            }
  -        }
  +     }
       }
       url[x] = '\0';
  -    if (badesc) return BAD_REQUEST;
  -    else if (badpath) return NOT_FOUND;
  -    else return OK;
  +    if (badesc)
  +     return BAD_REQUEST;
  +    else if (badpath)
  +     return NOT_FOUND;
  +    else
  +     return OK;
   }
   
   API_EXPORT(char *) construct_server(pool *p, const char *hostname,
  -                                 unsigned port) {
  -    char portnum[22];                
  -     /* Long enough, even if port > 16 bits for some reason */
  -  
  +                                 unsigned port)
  +{
  +    char portnum[22];
  +    /* Long enough, even if port > 16 bits for some reason */
  +
       if (port == DEFAULT_PORT)
  -     return pstrdup (p, hostname);
  +     return pstrdup(p, hostname);
       else {
  -        ap_snprintf (portnum, sizeof(portnum), "%u", port);
  -     return pstrcat (p, hostname, ":", portnum, NULL);
  +     ap_snprintf(portnum, sizeof(portnum), "%u", port);
  +     return pstrcat(p, hostname, ":", portnum, NULL);
       }
   }
   
  -API_EXPORT(char *) construct_url(pool *p, const char *uri, const server_rec 
*s) {
  -    return pstrcat (p, "http://";,
  -                 construct_server(p, s->server_hostname, s->port),
  -                 uri, NULL);
  +API_EXPORT(char *) construct_url(pool *p, const char *uri, const server_rec 
*s)
  +{
  +    return pstrcat(p, "http://";,
  +                construct_server(p, s->server_hostname, s->port),
  +                uri, NULL);
   }
   
   #define c2x(what,where) sprintf(where,"%%%02x",(unsigned char)what)
   
   /*
  -escape_path_segment() escapes a path segment, as defined in RFC 1808. This
  -routine is (should be) OS independent.
  + * escape_path_segment() escapes a path segment, as defined in RFC 1808. This
  + * routine is (should be) OS independent.
  + *
  + * os_escape_path() converts an OS path to a URL, in an OS dependent way. In 
all
  + * cases if a ':' occurs before the first '/' in the URL, the URL should be
  + * prefixed with "./" (or the ':' escaped). In the case of Unix, this means
  + * leaving '/' alone, but otherwise doing what escape_path_segment() does. 
For
  + * efficiency reasons, we don't use escape_path_segment(), which is provided 
for
  + * reference. Again, RFC 1808 is where this stuff is defined.
  + *
  + * If partial is set, os_escape_path() assumes that the path will be 
appended to
  + * something with a '/' in it (and thus does not prefix "./").
  + */
   
  -os_escape_path() converts an OS path to a URL, in an OS dependent way. In all
  -cases if a ':' occurs before the first '/' in the URL, the URL should be
  -prefixed with "./" (or the ':' escaped). In the case of Unix, this means
  -leaving '/' alone, but otherwise doing what escape_path_segment() does. For
  -efficiency reasons, we don't use escape_path_segment(), which is provided for
  -reference. Again, RFC 1808 is where this stuff is defined.
  -
  -If partial is set, os_escape_path() assumes that the path will be appended to
  -something with a '/' in it (and thus does not prefix "./").
  -*/
  -
  -API_EXPORT(char *) escape_path_segment(pool *p, const char *segment) {
  -    register int x,y;
  -    char *copy = palloc (p, 3 * strlen (segment) + 1);
  -            
  -    for(x=0,y=0; segment[x]; x++,y++) {
  -      char c=segment[x];
  -      if((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c >'9')
  -      && ind("$-_.+!*'(),:@&=~",c) == -1)
  -     {
  -       c2x(c,&copy[y]);
  -       y+=2;
  +API_EXPORT(char *) escape_path_segment(pool *p, const char *segment)
  +{
  +    register int x, y;
  +    char *copy = palloc(p, 3 * strlen(segment) + 1);
  +
  +    for (x = 0, y = 0; segment[x]; x++, y++) {
  +     char c = segment[x];
  +     if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9')
  +         && ind("$-_.+!*'(),:@&=~", c) == -1) {
  +         c2x(c, &copy[y]);
  +         y += 2;
        }
  -      else
  -     copy[y]=c;
  +     else
  +         copy[y] = c;
       }
       copy[y] = '\0';
       return copy;
   }
   
  -API_EXPORT(char *) os_escape_path(pool *p,const char *path,int partial) {
  -  char *copy=palloc(p,3*strlen(path)+3);
  -  char *s=copy;
  -
  -  if(!partial)
  -    {
  -      int colon=ind(path,':');
  -      int slash=ind(path,'/');
  -
  -      if(colon >= 0 && (colon < slash || slash < 0))
  -     {
  -       *s++='.';
  -       *s++='/';
  -     }
  -    }
  -  for( ; *path ; ++path)
  -    {
  -      char c=*path;
  -      if((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c >'9')
  -      && ind("$-_.+!*'(),:@&=/~",c) == -1)
  -     {
  -       c2x(c,s);
  -       s+=3;
  +API_EXPORT(char *) os_escape_path(pool *p, const char *path, int partial)
  +{
  +    char *copy = palloc(p, 3 * strlen(path) + 3);
  +    char *s = copy;
  +
  +    if (!partial) {
  +     int colon = ind(path, ':');
  +     int slash = ind(path, '/');
  +
  +     if (colon >= 0 && (colon < slash || slash < 0)) {
  +         *s++ = '.';
  +         *s++ = '/';
        }
  -      else
  -     *s++=c;
       }
  -  *s='\0';
  -  return copy;
  +    for (; *path; ++path) {
  +     char c = *path;
  +     if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9')
  +         && ind("$-_.+!*'(),:@&=/~", c) == -1) {
  +         c2x(c, s);
  +         s += 3;
  +     }
  +     else
  +         *s++ = c;
  +    }
  +    *s = '\0';
  +    return copy;
   }
   
   /* escape_uri is now a macro for os_escape_path */
  @@ -936,141 +997,155 @@
       int i, j;
       char *x;
   
  -/* first, count the number of extra characters */
  -    for (i=0, j=0; s[i] != '\0'; i++)
  -     if (s[i] == '<' || s[i] == '>') j += 3;
  -     else if (s[i] == '&') j += 4;
  +    /* first, count the number of extra characters */
  +    for (i = 0, j = 0; s[i] != '\0'; i++)
  +     if (s[i] == '<' || s[i] == '>')
  +         j += 3;
  +     else if (s[i] == '&')
  +         j += 4;
   
  -    if (j == 0) return pstrdup(p, s);
  +    if (j == 0)
  +     return pstrdup(p, s);
       x = palloc(p, i + j + 1);
  -    for (i=0, j=0; s[i] != '\0'; i++, j++)
  -     if (s[i] == '<')
  -     {
  +    for (i = 0, j = 0; s[i] != '\0'; i++, j++)
  +     if (s[i] == '<') {
            memcpy(&x[j], "&lt;", 4);
            j += 3;
  -     } else if (s[i] == '>')
  -     {
  +     }
  +     else if (s[i] == '>') {
            memcpy(&x[j], "&gt;", 4);
            j += 3;
  -     } else if (s[i] == '&')
  -     {
  +     }
  +     else if (s[i] == '&') {
            memcpy(&x[j], "&amp;", 5);
            j += 4;
  -     } else
  -            x[j] = s[i];
  +     }
  +     else
  +         x[j] = s[i];
   
       x[j] = '\0';
       return x;
   }
   
  -API_EXPORT(int) is_directory(const char *path) {
  +API_EXPORT(int) is_directory(const char *path)
  +{
       struct stat finfo;
   
  -    if(stat(path,&finfo) == -1)
  -        return 0; /* in error condition, just return no */
  +    if (stat(path, &finfo) == -1)
  +     return 0;               /* in error condition, just return no */
   
  -    return(S_ISDIR(finfo.st_mode));
  +    return (S_ISDIR(finfo.st_mode));
   }
   
   API_EXPORT(char *) make_full_path(pool *a, const char *src1,
  -                               const char *src2) {
  +                               const char *src2)
  +{
       register int x;
   
       x = strlen(src1);
  -    if (x == 0) return pstrcat (a, "/", src2, NULL);
  +    if (x == 0)
  +     return pstrcat(a, "/", src2, NULL);
   
  -    if (src1[x - 1] != '/') return pstrcat (a, src1, "/", src2, NULL);
  -    else return pstrcat (a, src1, src2, NULL);
  +    if (src1[x - 1] != '/')
  +     return pstrcat(a, src1, "/", src2, NULL);
  +    else
  +     return pstrcat(a, src1, src2, NULL);
   }
   
   /*
    * Check for an absoluteURI syntax (see section 3.2 in RFC2068).
    */
  -API_EXPORT(int) is_url(const char *u) {
  +API_EXPORT(int) is_url(const char *u)
  +{
       register int x;
   
       for (x = 0; u[x] != ':'; x++) {
  -        if ((! u[x]) ||
  -         ((! isalpha(u[x])) && (! isdigit(u[x])) &&
  +     if ((!u[x]) ||
  +         ((!isalpha(u[x])) && (!isdigit(u[x])) &&
             (u[x] != '+') && (u[x] != '-') && (u[x] != '.'))) {
  -            return 0;
  +         return 0;
        }
       }
   
  -    return (x ? 1 : 0);  /* If the first character is ':', it's broken, too 
*/
  +    return (x ? 1 : 0);              /* If the first character is ':', it's 
broken, too */
   }
   
  -API_EXPORT(int) can_exec(const struct stat *finfo) {
  +API_EXPORT(int) can_exec(const struct stat *finfo)
  +{
   #ifdef MULTIPLE_GROUPS
  -  int cnt;
  +    int cnt;
   #endif
   #if defined(__EMX__) || defined(WIN32)
       /* OS/2 dosen't have Users and Groups */
       return 1;
  -#else    
  -    if(user_id == finfo->st_uid)
  -        if(finfo->st_mode & S_IXUSR)
  -            return 1;
  -    if(group_id == finfo->st_gid)
  -        if(finfo->st_mode & S_IXGRP)
  -            return 1;
  +#else
  +    if (user_id == finfo->st_uid)
  +     if (finfo->st_mode & S_IXUSR)
  +         return 1;
  +    if (group_id == finfo->st_gid)
  +     if (finfo->st_mode & S_IXGRP)
  +         return 1;
   #ifdef MULTIPLE_GROUPS
  -    for(cnt=0; cnt < NGROUPS_MAX; cnt++) {
  -        if(group_id_list[cnt] == finfo->st_gid)
  -            if(finfo->st_mode & S_IXGRP)
  -                return 1;
  +    for (cnt = 0; cnt < NGROUPS_MAX; cnt++) {
  +     if (group_id_list[cnt] == finfo->st_gid)
  +         if (finfo->st_mode & S_IXGRP)
  +             return 1;
       }
   #endif
       return (finfo->st_mode & S_IXOTH);
  -#endif    
  +#endif
   }
   
   #ifdef NEED_STRDUP
  -char *strdup (const char *str)
  +char *strdup(const char *str)
   {
  -  char *dup;
  +    char *dup;
   
  -  if(!(dup = (char *)malloc (strlen (str) + 1)))
  -      return NULL;
  -  dup = strcpy (dup, str);
  +    if (!(dup = (char *) malloc(strlen(str) + 1)))
  +     return NULL;
  +    dup = strcpy(dup, str);
   
  -  return dup;
  +    return dup;
   }
   #endif
   
   /* The following two routines were donated for SVR4 by Andreas Vogel */
   #ifdef NEED_STRCASECMP
  -int strcasecmp (const char *a, const char *b)
  +int strcasecmp(const char *a, const char *b)
   {
       const char *p = a;
       const char *q = b;
  -    for (p = a, q = b; *p && *q; p++, q++)
  -    {
  -      int diff = tolower(*p) - tolower(*q);
  -      if (diff) return diff;
  -    }
  -    if (*p) return 1;       /* p was longer than q */
  -    if (*q) return -1;      /* p was shorter than q */
  -    return 0;               /* Exact match */
  +    for (p = a, q = b; *p && *q; p++, q++) {
  +     int diff = tolower(*p) - tolower(*q);
  +     if (diff)
  +         return diff;
  +    }
  +    if (*p)
  +     return 1;               /* p was longer than q */
  +    if (*q)
  +     return -1;              /* p was shorter than q */
  +    return 0;                        /* Exact match */
   }
   
   #endif
   
   #ifdef NEED_STRNCASECMP
  -int strncasecmp (const char *a, const char *b, int n)
  +int strncasecmp(const char *a, const char *b, int n)
   {
       const char *p = a;
       const char *q = b;
   
  -    for (p = a, q = b; /*NOTHING*/; p++, q++)
  -    {
  -      int diff;
  -      if (p == a + n) return 0;     /*   Match up to n characters */
  -      if (!(*p && *q)) return *p - *q;
  -      diff = tolower(*p) - tolower(*q);
  -      if (diff) return diff;
  +    for (p = a, q = b; /*NOTHING */ ; p++, q++) {
  +     int diff;
  +     if (p == a + n)
  +         return 0;           /*   Match up to n characters */
  +     if (!(*p && *q))
  +         return *p - *q;
  +     diff = tolower(*p) - tolower(*q);
  +     if (diff)
  +         return diff;
       }
  -    /*NOTREACHED*/
  +    /*NOTREACHED */
   }
   #endif
   
  @@ -1081,196 +1156,210 @@
   {
   #if defined(QNX) || defined(MPE) || defined(BEOS)
   /* QNX, MPE and BeOS do not appear to support supplementary groups. */
  -     return 0;
  +    return 0;
   #else /* ndef QNX */
  -  gid_t groups[NGROUPS_MAX];
  -  struct group *g;
  -  int index = 0;
  +    gid_t groups[NGROUPS_MAX];
  +    struct group *g;
  +    int index = 0;
   
  -  setgrent();
  +    setgrent();
   
  -  groups[index++] = basegid;
  +    groups[index++] = basegid;
   
  -  while (index < NGROUPS_MAX && ((g = getgrent()) != NULL))
  -    if (g->gr_gid != basegid)
  -    {
  -      char **names;
  +    while (index < NGROUPS_MAX && ((g = getgrent()) != NULL))
  +     if (g->gr_gid != basegid) {
  +         char **names;
   
  -      for (names = g->gr_mem; *names != NULL; ++names)
  -        if (!strcmp(*names, name))
  -          groups[index++] = g->gr_gid;
  -    }
  +         for (names = g->gr_mem; *names != NULL; ++names)
  +             if (!strcmp(*names, name))
  +                 groups[index++] = g->gr_gid;
  +     }
   
  -  endgrent();
  +    endgrent();
   
  -  return setgroups(index, groups);
  +    return setgroups(index, groups);
   #endif /* def QNX */
   }
   #endif /* def NEED_INITGROUPS */
   
   #ifdef NEED_WAITPID
  -/* From [EMAIL PROTECTED] */
  -/* this is not ideal but it works for SVR3 variants */
  -/* httpd does not use the options so this doesn't implement them */
  +/* From [EMAIL PROTECTED]
  + * this is not ideal but it works for SVR3 variants
  + * httpd does not use the options so this doesn't implement them
  + */
   int waitpid(pid_t pid, int *statusp, int options)
   {
       int tmp_pid;
  -    if ( kill ( pid,0 ) == -1) {
  -        errno=ECHILD;
  -        return -1;
  +    if (kill(pid, 0) == -1) {
  +     errno = ECHILD;
  +     return -1;
       }
  -    while ((( tmp_pid = wait(statusp)) != pid) && ( tmp_pid != -1 ));
  +    while (((tmp_pid = wait(statusp)) != pid) && (tmp_pid != -1));
       return tmp_pid;
   }
   #endif
   
  -API_EXPORT(int) ind(const char *s, char c) {
  +API_EXPORT(int) ind(const char *s, char c)
  +{
       register int x;
   
  -    for(x=0;s[x];x++)
  -        if(s[x] == c) return x;
  +    for (x = 0; s[x]; x++)
  +     if (s[x] == c)
  +         return x;
   
       return -1;
   }
   
  -API_EXPORT(int) rind(const char *s, char c) {
  +API_EXPORT(int) rind(const char *s, char c)
  +{
       register int x;
   
  -    for(x=strlen(s)-1;x != -1;x--)
  -        if(s[x] == c) return x;
  +    for (x = strlen(s) - 1; x != -1; x--)
  +     if (s[x] == c)
  +         return x;
   
       return -1;
   }
   
  -API_EXPORT(void) str_tolower(char *str) {
  -    while(*str) {
  -        *str = tolower(*str);
  -        ++str;
  +API_EXPORT(void) str_tolower(char *str)
  +{
  +    while (*str) {
  +     *str = tolower(*str);
  +     ++str;
       }
   }
  -        
  -API_EXPORT(uid_t) uname2id(const char *name) {
  +
  +API_EXPORT(uid_t) uname2id(const char *name)
  +{
   #ifdef WIN32
  -    return(1);
  +    return (1);
   #else
       struct passwd *ent;
   
  -    if(name[0] == '#') 
  -        return(atoi(&name[1]));
  +    if (name[0] == '#')
  +     return (atoi(&name[1]));
   
  -    if(!(ent = getpwnam(name))) {
  -        fprintf(stderr,"httpd: bad user name %s\n",name);
  -        exit(1);
  +    if (!(ent = getpwnam(name))) {
  +     fprintf(stderr, "httpd: bad user name %s\n", name);
  +     exit(1);
       }
  -    return(ent->pw_uid);
  +    return (ent->pw_uid);
   #endif
   }
   
  -API_EXPORT(gid_t) gname2id(const char *name) {
  +API_EXPORT(gid_t) gname2id(const char *name)
  +{
   #ifdef WIN32
  -    return(1);
  +    return (1);
   #else
       struct group *ent;
   
  -    if(name[0] == '#') 
  -        return(atoi(&name[1]));
  +    if (name[0] == '#')
  +     return (atoi(&name[1]));
   
  -    if(!(ent = getgrnam(name))) {
  -        fprintf(stderr,"httpd: bad group name %s\n",name);
  -        exit(1);
  +    if (!(ent = getgrnam(name))) {
  +     fprintf(stderr, "httpd: bad group name %s\n", name);
  +     exit(1);
       }
  -    return(ent->gr_gid);
  +    return (ent->gr_gid);
   #endif
   }
   
   #if 0
  -int get_portnum(int sd) {
  +int get_portnum(int sd)
  +{
       struct sockaddr addr;
       int len;
   
       len = sizeof(struct sockaddr);
  -    if(getsockname(sd,&addr,&len) < 0)
  -        return -1;
  -    return ntohs(((struct sockaddr_in *)&addr)->sin_port);
  +    if (getsockname(sd, &addr, &len) < 0)
  +     return -1;
  +    return ntohs(((struct sockaddr_in *) &addr)->sin_port);
   }
   
  -struct in_addr get_local_addr(int sd) {
  +struct in_addr get_local_addr(int sd)
  +{
       struct sockaddr addr;
       int len;
   
       len = sizeof(struct sockaddr);
  -    if(getsockname(sd,&addr,&len) < 0) {
  -     perror ("getsockname");
  -        fprintf (stderr, "Can't get local host address!\n");
  +    if (getsockname(sd, &addr, &len) < 0) {
  +     perror("getsockname");
  +     fprintf(stderr, "Can't get local host address!\n");
        exit(1);
       }
  -         
  -    return ((struct sockaddr_in *)&addr)->sin_addr;
  +
  +    return ((struct sockaddr_in *) &addr)->sin_addr;
   }
  +
   #endif
   
   /*
    * Parses a host of the form <address>[:port]
    * :port is permitted if 'port' is not NULL
    */
  -unsigned long get_virthost_addr (const char *w, unsigned short *ports) {
  +unsigned long get_virthost_addr(const char *w, unsigned short *ports)
  +{
       struct hostent *hep;
       unsigned long my_addr;
       char *p;
   
       p = strchr(w, ':');
  -    if (ports != NULL)
  -    {
  +    if (ports != NULL) {
        *ports = 0;
  -     if (p != NULL && strcmp(p+1, "*") != 0) *ports = atoi(p+1);
  +     if (p != NULL && strcmp(p + 1, "*") != 0)
  +         *ports = atoi(p + 1);
       }
   
  -    if (p != NULL) *p = '\0';
  -    if (strcmp(w, "*") == 0)
  -    {
  -     if (p != NULL) *p = ':';
  +    if (p != NULL)
  +     *p = '\0';
  +    if (strcmp(w, "*") == 0) {
  +     if (p != NULL)
  +         *p = ':';
        return htonl(INADDR_ANY);
       }
  -     
  +
       my_addr = ap_inet_addr(w);
  -    if (my_addr != INADDR_NONE)
  -    {
  -     if (p != NULL) *p = ':';
  +    if (my_addr != INADDR_NONE) {
  +     if (p != NULL)
  +         *p = ':';
        return my_addr;
       }
   
       hep = gethostbyname(w);
  -         
  +
       if ((!hep) || (hep->h_addrtype != AF_INET || !hep->h_addr_list[0])) {
  -     fprintf (stderr, "Cannot resolve host name %s --- exiting!\n", w);
  +     fprintf(stderr, "Cannot resolve host name %s --- exiting!\n", w);
        exit(1);
       }
  -         
  +
       if (hep->h_addr_list[1]) {
        fprintf(stderr, "Host %s has multiple addresses ---\n", w);
        fprintf(stderr, "you must choose one explicitly for use as\n");
        fprintf(stderr, "a virtual host.  Exiting!!!\n");
        exit(1);
       }
  -         
  -    if (p != NULL) *p = ':';
   
  -    return ((struct in_addr *)(hep->h_addr))->s_addr;
  +    if (p != NULL)
  +     *p = ':';
  +
  +    return ((struct in_addr *) (hep->h_addr))->s_addr;
   }
   
   
  -static char *find_fqdn(pool *a, struct hostent *p) {
  +static char *find_fqdn(pool *a, struct hostent *p)
  +{
       int x;
   
  -    if(ind(p->h_name,'.') == -1) {
  -        for(x=0;p->h_aliases[x];++x) {
  -            if((ind(p->h_aliases[x],'.') != -1) && 
  -               (!strncmp(p->h_aliases[x],p->h_name,strlen(p->h_name))))
  -                return pstrdup(a, p->h_aliases[x]);
  -        }
  -        return NULL;
  +    if (ind(p->h_name, '.') == -1) {
  +     for (x = 0; p->h_aliases[x]; ++x) {
  +         if ((ind(p->h_aliases[x], '.') != -1) &&
  +             (!strncmp(p->h_aliases[x], p->h_name, strlen(p->h_name))))
  +             return pstrdup(a, p->h_aliases[x]);
  +     }
  +     return NULL;
       }
  -    return pstrdup(a, (void *)p->h_name);
  +    return pstrdup(a, (void *) p->h_name);
   }
   
   char *get_local_host(pool *a)
  @@ -1278,18 +1367,18 @@
   #ifndef MAXHOSTNAMELEN
   #define MAXHOSTNAMELEN 256
   #endif
  -    char str[MAXHOSTNAMELEN+1];
  +    char str[MAXHOSTNAMELEN + 1];
       char *server_hostname;
       struct hostent *p;
   
  -    if( gethostname( str, sizeof( str ) - 1 ) != 0 ) {
  -     perror( "Unable to gethostname" );
  +    if (gethostname(str, sizeof(str) - 1) != 0) {
  +     perror("Unable to gethostname");
        exit(1);
       }
       str[MAXHOSTNAMELEN] = '\0';
  -    if((!(p=gethostbyname(str))) || (!(server_hostname = find_fqdn(a, p)))) {
  -        fprintf(stderr,"httpd: cannot determine local host name.\n");
  -     fprintf(stderr,"Use ServerName to set it manually.\n");
  +    if ((!(p = gethostbyname(str))) || (!(server_hostname = find_fqdn(a, 
p)))) {
  +     fprintf(stderr, "httpd: cannot determine local host name.\n");
  +     fprintf(stderr, "Use ServerName to set it manually.\n");
        exit(1);
       }
   
  @@ -1297,82 +1386,91 @@
   }
   
   /* aaaack but it's fast and const should make it shared text page. */
  -const int pr2six[256]={
  -    64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
  -    64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,62,64,64,64,63,
  -    52,53,54,55,56,57,58,59,60,61,64,64,64,64,64,64,64,0,1,2,3,4,5,6,7,8,9,
  -    10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,64,64,64,64,64,64,26,27,
  -    28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
  -    64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
  -    64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
  -    64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
  -    64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
  -    64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
  -    64,64,64,64,64,64,64,64,64,64,64,64,64
  +const int pr2six[256] =
  +{
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, 52, 53, 54,
  +    55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3,
  +    4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
  +    22, 23, 24, 25, 64, 64, 64, 64, 64, 64, 26, 27, 28, 29, 30, 31, 32,
  +    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
  +    50, 51, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  +    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
   };
   
  -API_EXPORT(char *) uudecode(pool *p, const char *bufcoded) {
  +API_EXPORT(char *) uudecode(pool *p, const char *bufcoded)
  +{
       int nbytesdecoded;
       register const unsigned char *bufin;
       register char *bufplain;
       register unsigned char *bufout;
       register int nprbytes;
  -    
  +
       /* Strip leading whitespace. */
  -    
  -    while(*bufcoded==' ' || *bufcoded == '\t') bufcoded++;
  -    
  +
  +    while (*bufcoded == ' ' || *bufcoded == '\t')
  +     bufcoded++;
  +
       /* Figure out how many characters are in the input buffer.
        * Allocate this many from the per-transaction pool for the result.
        */
  -    bufin = (const unsigned char *)bufcoded;
  -    while(pr2six[*(bufin++)] <= 63);
  -    nprbytes = (bufin - (const unsigned char *)bufcoded) - 1;
  -    nbytesdecoded = ((nprbytes+3)/4) * 3;
  +    bufin = (const unsigned char *) bufcoded;
  +    while (pr2six[*(bufin++)] <= 63);
  +    nprbytes = (bufin - (const unsigned char *) bufcoded) - 1;
  +    nbytesdecoded = ((nprbytes + 3) / 4) * 3;
   
       bufplain = palloc(p, nbytesdecoded + 1);
  -    bufout = (unsigned char *)bufplain;
  -    
  -    bufin = (const unsigned char *)bufcoded;
  -    
  +    bufout = (unsigned char *) bufplain;
  +
  +    bufin = (const unsigned char *) bufcoded;
  +
       while (nprbytes > 0) {
  -        *(bufout++) = 
  -            (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
  -        *(bufout++) = 
  -            (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
  -        *(bufout++) = 
  -            (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
  -        bufin += 4;
  -        nprbytes -= 4;
  -    }
  -    
  -    if(nprbytes & 03) {
  -        if(pr2six[bufin[-2]] > 63)
  -            nbytesdecoded -= 2;
  -        else
  -            nbytesdecoded -= 1;
  +     *(bufout++) =
  +         (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
  +     *(bufout++) =
  +         (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
  +     *(bufout++) =
  +         (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
  +     bufin += 4;
  +     nprbytes -= 4;
  +    }
  +
  +    if (nprbytes & 03) {
  +     if (pr2six[bufin[-2]] > 63)
  +         nbytesdecoded -= 2;
  +     else
  +         nbytesdecoded -= 1;
       }
       bufplain[nbytesdecoded] = '\0';
       return bufplain;
   }
   
   #ifdef __EMX__
  -void os2pathname(char *path) {
  +void os2pathname(char *path)
  +{
       char newpath[MAX_STRING_LEN];
       int loop;
       int offset;
   
       offset = 0;
  -    for (loop=0; loop < (strlen(path) + 1) && loop < sizeof(newpath)-1; 
loop++) {
  -        if (path[loop] == '/') {
  -            newpath[offset] = '\\';
  -            /*
  -            offset = offset + 1;
  -            newpath[offset] = '\\';
  -            */
  -        } else
  -            newpath[offset] = path[loop];
  -        offset = offset + 1;
  +    for (loop = 0; loop < (strlen(path) + 1) && loop < sizeof(newpath) - 1; 
loop++) {
  +     if (path[loop] == '/') {
  +         newpath[offset] = '\\';
  +         /*
  +            offset = offset + 1;
  +            newpath[offset] = '\\';
  +          */
  +     }
  +     else
  +         newpath[offset] = path[loop];
  +     offset = offset + 1;
       };
       /* Debugging code */
       /* fprintf(stderr, "%s \n", newpath); */
  @@ -1384,7 +1482,8 @@
   
   #ifdef NEED_STRERROR
   char *
  -strerror (int err) {
  +     strerror(int err)
  +{
   
       char *p;
       extern char *const sys_errlist[];
  @@ -1395,7 +1494,7 @@
   #endif
   
   #ifndef NO_SLACK
  -int ap_slack (int fd, int line)
  +int ap_slack(int fd, int line)
   {
   #if !defined(F_DUPFD)
       return fd;
  @@ -1404,9 +1503,9 @@
   
   #ifdef HIGH_SLACK_LINE
       if (line == AP_SLACK_HIGH && fd < HIGH_SLACK_LINE) {
  -     new_fd = fcntl (fd, F_DUPFD, HIGH_SLACK_LINE);
  +     new_fd = fcntl(fd, F_DUPFD, HIGH_SLACK_LINE);
        if (new_fd != -1) {
  -         close (fd);
  +         close(fd);
            return new_fd;
        }
       }
  @@ -1415,11 +1514,11 @@
       if (fd >= LOW_SLACK_LINE) {
        return fd;
       }
  -    new_fd = fcntl (fd, F_DUPFD, LOW_SLACK_LINE);
  +    new_fd = fcntl(fd, F_DUPFD, LOW_SLACK_LINE);
       if (new_fd == -1) {
  -      return fd;
  +     return fd;
       }
  -    close (fd);
  +    close(fd);
       return new_fd;
   #endif
   }
  @@ -1428,6 +1527,6 @@
   #if defined(NEED_DIFFTIME)
   double difftime(time_t time1, time_t time0)
   {
  -        return(time1 - time0);
  +    return (time1 - time0);
   }
   #endif
  
  
  
  1.5       +109 -90   apachen/src/main/util_date.c
  
  Index: util_date.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_date.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- util_date.c       1997/07/19 20:16:15     1.4
  +++ util_date.c       1997/09/14 22:18:58     1.5
  @@ -83,27 +83,41 @@
       char d;
   
       for (i = 0; i < 256; i++) {
  -        d  = data[i];
  -        switch (mask[i]) {
  -          case '\0': return (d == '\0');
  -
  -          case '*':  return 1;
  -
  -          case '@':  if (!isupper(d)) return 0;
  -                     break;
  -          case '$':  if (!islower(d)) return 0;
  -                     break;
  -          case '#':  if (!isdigit(d)) return 0;
  -                     break;
  -          case '&':  if (!isxdigit(d)) return 0;
  -                     break;
  -          case '~':  if ((d != ' ') && !isdigit(d)) return 0;
  -                     break;
  -          default:   if (mask[i] != d) return 0;
  -                     break;
  -        }
  +     d = data[i];
  +     switch (mask[i]) {
  +     case '\0':
  +         return (d == '\0');
  +
  +     case '*':
  +         return 1;
  +
  +     case '@':
  +         if (!isupper(d))
  +             return 0;
  +         break;
  +     case '$':
  +         if (!islower(d))
  +             return 0;
  +         break;
  +     case '#':
  +         if (!isdigit(d))
  +             return 0;
  +         break;
  +     case '&':
  +         if (!isxdigit(d))
  +             return 0;
  +         break;
  +     case '~':
  +         if ((d != ' ') && !isdigit(d))
  +             return 0;
  +         break;
  +     default:
  +         if (mask[i] != d)
  +             return 0;
  +         break;
  +     }
       }
  -    return 0;  /* We only get here if mask is corrupted (exceeds 256) */
  +    return 0;                        /* We only get here if mask is 
corrupted (exceeds 256) */
   }
   
   /*
  @@ -117,34 +131,35 @@
    *
    * This routine is intended to be very fast, much faster than mktime().
    */
  -time_t tm2sec(const struct tm *t)
  +time_t tm2sec(const struct tm * t)
   {
  -    int  year;
  +    int year;
       time_t days;
       const int dayoffset[12] =
  -        {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
  +    {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
   
       year = t->tm_year;
   
       if (year < 70 || ((sizeof(time_t) <= 4) && (year >= 138)))
  -        return BAD_DATE;
  +     return BAD_DATE;
   
       /* shift new year to 1st March in order to make leap year calc easy */
   
  -    if (t->tm_mon < 2) year--;
  +    if (t->tm_mon < 2)
  +     year--;
   
       /* Find number of days since 1st March 1900 (in the Gregorian calendar). 
*/
   
  -    days  = year * 365 + year/4 - year/100 + (year/100 + 3)/4;
  +    days = year * 365 + year / 4 - year / 100 + (year / 100 + 3) / 4;
       days += dayoffset[t->tm_mon] + t->tm_mday - 1;
  -    days -= 25508; /* 1 jan 1970 is 25508 days since 1 mar 1900 */
  +    days -= 25508;           /* 1 jan 1970 is 25508 days since 1 mar 1900 */
   
       days = ((days * 24 + t->tm_hour) * 60 + t->tm_min) * 60 + t->tm_sec;
   
       if (days < 0)
  -        return BAD_DATE;       /* must have overflowed */
  +     return BAD_DATE;        /* must have overflowed */
       else
  -        return days;           /* must be a valid time */
  +     return days;            /* must be a valid time */
   }
   
   /*
  @@ -199,99 +214,103 @@
       struct tm ds;
       int mint, mon;
       const char *monstr, *timstr;
  -    const int months[12] = {
  -        ('J' << 16) | ( 'a' << 8) | 'n',  ('F' << 16) | ( 'e' << 8) | 'b',
  -        ('M' << 16) | ( 'a' << 8) | 'r',  ('A' << 16) | ( 'p' << 8) | 'r',
  -        ('M' << 16) | ( 'a' << 8) | 'y',  ('J' << 16) | ( 'u' << 8) | 'n',
  -        ('J' << 16) | ( 'u' << 8) | 'l',  ('A' << 16) | ( 'u' << 8) | 'g',
  -        ('S' << 16) | ( 'e' << 8) | 'p',  ('O' << 16) | ( 'c' << 8) | 't',
  -        ('N' << 16) | ( 'o' << 8) | 'v',  ('D' << 16) | ( 'e' << 8) | 'c'};
  +    const int months[12] =
  +    {
  +     ('J' << 16) | ('a' << 8) | 'n', ('F' << 16) | ('e' << 8) | 'b',
  +     ('M' << 16) | ('a' << 8) | 'r', ('A' << 16) | ('p' << 8) | 'r',
  +     ('M' << 16) | ('a' << 8) | 'y', ('J' << 16) | ('u' << 8) | 'n',
  +     ('J' << 16) | ('u' << 8) | 'l', ('A' << 16) | ('u' << 8) | 'g',
  +     ('S' << 16) | ('e' << 8) | 'p', ('O' << 16) | ('c' << 8) | 't',
  +     ('N' << 16) | ('o' << 8) | 'v', ('D' << 16) | ('e' << 8) | 'c'};
   
       if (!date)
  -        return BAD_DATE;
  +     return BAD_DATE;
   
  -    while (*date && isspace(*date))      /* Find first non-whitespace char */
  -        ++date;
  +    while (*date && isspace(*date))  /* Find first non-whitespace char */
  +     ++date;
   
       if (*date == '\0')
  -        return BAD_DATE;
  +     return BAD_DATE;
   
  -    if ((date = strchr(date,' ')) == NULL)   /* Find space after weekday */
  -        return BAD_DATE;
  +    if ((date = strchr(date, ' ')) == NULL)  /* Find space after weekday */
  +     return BAD_DATE;
   
  -    ++date;    /* Now pointing to first char after space, which should be */
  -               /* start of the actual date information for all 3 formats. */
  -    
  -    if (checkmask(date, "## @$$ #### ##:##:## *")) {     /* RFC 1123 format 
*/
  -        ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100;
  -        if (ds.tm_year < 0)
  -            return BAD_DATE;
  +    ++date;                  /* Now pointing to first char after space, 
which should be */
  +    /* start of the actual date information for all 3 formats. */
   
  -        ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0');
  +    if (checkmask(date, "## @$$ #### ##:##:## *")) { /* RFC 1123 format */
  +     ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100;
  +     if (ds.tm_year < 0)
  +         return BAD_DATE;
   
  -        ds.tm_mday  = ((date[0] - '0') * 10) + (date[1] - '0');
  +     ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0');
   
  -        monstr = date + 3;
  -        timstr = date + 12;
  +     ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0');
  +
  +     monstr = date + 3;
  +     timstr = date + 12;
       }
  -    else if (checkmask(date, "[EMAIL PROTECTED] ##:##:## *")) {  /* RFC 850 
format  */
  -        ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0');
  -        if (ds.tm_year < 70)
  -            ds.tm_year += 100;
  +    else if (checkmask(date, "[EMAIL PROTECTED] ##:##:## *")) {              
/* RFC 850 format  */
  +     ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0');
  +     if (ds.tm_year < 70)
  +         ds.tm_year += 100;
   
  -        ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0');
  +     ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0');
   
  -        monstr = date + 3;
  -        timstr = date + 10;
  +     monstr = date + 3;
  +     timstr = date + 10;
       }
  -    else if (checkmask(date, "@$$ ~# ##:##:## ####*")) { /* asctime format  
*/
  -        ds.tm_year = ((date[16] - '0') * 10 + (date[17] - '0') - 19) * 100;
  -        if (ds.tm_year < 0)
  -            return BAD_DATE;
  -
  -        ds.tm_year += ((date[18] - '0') * 10) + (date[19] - '0');
  -
  -        if (date[4] == ' ')
  -            ds.tm_mday = 0;
  -        else
  -            ds.tm_mday = (date[4] - '0') * 10;
  +    else if (checkmask(date, "@$$ ~# ##:##:## ####*")) {     /* asctime 
format  */
  +     ds.tm_year = ((date[16] - '0') * 10 + (date[17] - '0') - 19) * 100;
  +     if (ds.tm_year < 0)
  +         return BAD_DATE;
  +
  +     ds.tm_year += ((date[18] - '0') * 10) + (date[19] - '0');
  +
  +     if (date[4] == ' ')
  +         ds.tm_mday = 0;
  +     else
  +         ds.tm_mday = (date[4] - '0') * 10;
   
  -        ds.tm_mday += (date[5] - '0');
  +     ds.tm_mday += (date[5] - '0');
   
  -        monstr = date;
  -        timstr = date + 7;
  +     monstr = date;
  +     timstr = date + 7;
       }
  -    else return BAD_DATE;
  +    else
  +     return BAD_DATE;
   
       if (ds.tm_mday <= 0 || ds.tm_mday > 31)
  -        return BAD_DATE;
  +     return BAD_DATE;
   
       ds.tm_hour = ((timstr[0] - '0') * 10) + (timstr[1] - '0');
  -    ds.tm_min  = ((timstr[3] - '0') * 10) + (timstr[4] - '0');
  -    ds.tm_sec  = ((timstr[6] - '0') * 10) + (timstr[7] - '0');
  +    ds.tm_min = ((timstr[3] - '0') * 10) + (timstr[4] - '0');
  +    ds.tm_sec = ((timstr[6] - '0') * 10) + (timstr[7] - '0');
   
       if ((ds.tm_hour > 23) || (ds.tm_min > 59) || (ds.tm_sec > 61))
  -        return BAD_DATE;
  +     return BAD_DATE;
   
       mint = (monstr[0] << 16) | (monstr[1] << 8) | monstr[2];
  -    for (mon=0; mon < 12; mon++)
  -        if (mint == months[mon])
  -            break;
  +    for (mon = 0; mon < 12; mon++)
  +     if (mint == months[mon])
  +         break;
       if (mon == 12)
  -        return BAD_DATE;
  -    
  +     return BAD_DATE;
  +
       if ((ds.tm_mday == 31) && (mon == 3 || mon == 5 || mon == 8 || mon == 
10))
  -        return BAD_DATE;
  +     return BAD_DATE;
   
       /* February gets special check for leapyear */
   
  -    if ((mon == 1) && ((ds.tm_mday > 29) ||
  -         ((ds.tm_mday == 29) && ((ds.tm_year & 3) ||
  -           (((ds.tm_year % 100) == 0) && (((ds.tm_year % 400) != 100)))))))
  -        return BAD_DATE;
  +    if ((mon == 1) &&
  +     ((ds.tm_mday > 29)
  +      || ((ds.tm_mday == 29)
  +          && ((ds.tm_year & 3)
  +              || (((ds.tm_year % 100) == 0)
  +                  && (((ds.tm_year % 400) != 100)))))))
  +     return BAD_DATE;
   
       ds.tm_mon = mon;
   
       return tm2sec(&ds);
   }
  -
  
  
  
  1.5       +3 -3      apachen/src/main/util_date.h
  
  Index: util_date.h
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_date.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- util_date.h       1997/07/19 20:16:15     1.4
  +++ util_date.h       1997/09/14 22:18:58     1.5
  @@ -62,6 +62,6 @@
   
   #define BAD_DATE (time_t)0
   
  -API_EXPORT(int) checkmask (const char *data, const char *mask);
  -time_t tm2sec (const struct tm *t);
  -API_EXPORT(time_t) parseHTTPdate (const char *date);
  +API_EXPORT(int) checkmask(const char *data, const char *mask);
  +time_t tm2sec(const struct tm *t);
  +API_EXPORT(time_t) parseHTTPdate(const char *date);
  
  
  
  1.10      +16 -17    apachen/src/main/util_md5.c
  
  Index: util_md5.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_md5.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- util_md5.c        1997/09/02 16:12:09     1.9
  +++ util_md5.c        1997/09/14 22:18:59     1.10
  @@ -82,23 +82,23 @@
   #include "httpd.h"
   #include "util_md5.h"
   
  -API_EXPORT(char *) ap_md5 (pool *p, unsigned char *string)
  +API_EXPORT(char *) ap_md5(pool *p, unsigned char *string)
   {
       AP_MD5_CTX my_md5;
       unsigned char hash[16];
       char *r, result[33];
       int i;
  -     
  +
       /*
        * Take the MD5 hash of the string argument.
        */
   
       MD5Init(&my_md5);
  -    MD5Update(&my_md5, string, strlen((const char *)string));
  +    MD5Update(&my_md5, string, strlen((const char *) string));
       MD5Final(hash, &my_md5);
   
  -    for (i=0, r=result; i<16; i++, r+=2)
  -        sprintf(r, "%02x", hash[i]);
  +    for (i = 0, r = result; i < 16; i++, r += 2)
  +     sprintf(r, "%02x", hash[i]);
       *r = '\0';
   
       return pstrdup(p, result);
  @@ -147,26 +147,26 @@
    */
   
   static char basis_64[] =
  -   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  +"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
   
  -API_EXPORT(char *) ap_md5contextTo64(pool *a, AP_MD5_CTX *context)
  +API_EXPORT(char *) ap_md5contextTo64(pool *a, AP_MD5_CTX * context)
   {
       unsigned char digest[18];
       char *encodedDigest;
       int i;
       char *p;
   
  -    encodedDigest = (char *)pcalloc(a, 25 * sizeof(char));
  +    encodedDigest = (char *) pcalloc(a, 25 * sizeof(char));
   
       MD5Final(digest, context);
  -    digest[sizeof(digest)-1] = digest[sizeof(digest)-2] = 0;
  +    digest[sizeof(digest) - 1] = digest[sizeof(digest) - 2] = 0;
   
       p = encodedDigest;
  -    for (i=0; i < sizeof(digest); i+=3) {
  -        *p++ = basis_64[digest[i]>>2];
  -        *p++ = basis_64[((digest[i] & 0x3)<<4) | ((int)(digest[i+1] & 
0xF0)>>4)];
  -        *p++ = basis_64[((digest[i+1] & 0xF)<<2) | ((int)(digest[i+2] & 
0xC0)>>6)];
  -        *p++ = basis_64[digest[i+2] & 0x3F];
  +    for (i = 0; i < sizeof(digest); i += 3) {
  +     *p++ = basis_64[digest[i] >> 2];
  +     *p++ = basis_64[((digest[i] & 0x3) << 4) | ((int) (digest[i + 1] & 
0xF0) >> 4)];
  +     *p++ = basis_64[((digest[i + 1] & 0xF) << 2) | ((int) (digest[i + 2] & 
0xC0) >> 6)];
  +     *p++ = basis_64[digest[i + 2] & 0x3F];
       }
       *p-- = '\0';
       *p-- = '=';
  @@ -183,10 +183,9 @@
   
       MD5Init(&context);
       while ((nbytes = fread(buf, 1, sizeof(buf), infile))) {
  -        length += nbytes;
  -        MD5Update(&context, buf, nbytes);
  +     length += nbytes;
  +     MD5Update(&context, buf, nbytes);
       }
       rewind(infile);
       return ap_md5contextTo64(p, &context);
   }
  -
  
  
  
  1.8       +1 -2      apachen/src/main/util_md5.h
  
  Index: util_md5.h
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_md5.h,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- util_md5.h        1997/09/02 16:12:10     1.7
  +++ util_md5.h        1997/09/14 22:18:59     1.8
  @@ -53,6 +53,5 @@
   #include "md5.h"
   
   API_EXPORT(char *) ap_md5(pool *a, unsigned char *string);
  -API_EXPORT(char *) ap_md5contextTo64(pool *p, AP_MD5_CTX *context);
  +API_EXPORT(char *) ap_md5contextTo64(pool *p, AP_MD5_CTX * context);
   API_EXPORT(char *) ap_md5digest(pool *p, FILE *infile);
  -
  
  
  
  1.73      +430 -395  apachen/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_script.c,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- util_script.c     1997/09/13 12:15:39     1.72
  +++ util_script.c     1997/09/14 22:18:59     1.73
  @@ -58,7 +58,7 @@
   #include "http_log.h"
   #include "http_protocol.h"
   #include "http_core.h"               /* For document_root.  Sigh... */
  -#include "http_request.h"       /* for sub_req_lookup_uri() */
  +#include "http_request.h"    /* for sub_req_lookup_uri() */
   #include "util_script.h"
   #include "util_date.h"               /* For parseHTTPdate() */
   
  @@ -68,7 +68,7 @@
    * in one place (if only to avoid creating inter-module dependancies
    * where there don't have to be).
    */
  - 
  +
   #define MALFORMED_MESSAGE "malformed header from script. Bad header="
   #define MALFORMED_HEADER_LENGTH_TO_SHOW 30
   
  @@ -81,7 +81,7 @@
    * "+" is the separator between keyword arguments.
    */
   static char **create_argv(pool *p, char *path, char *user, char *group,
  -                          char *av0, const char *args)
  +                       char *av0, const char *args)
   {
       int x, numwords;
       char **av;
  @@ -91,26 +91,27 @@
       /* count the number of keywords */
   
       for (x = 0, numwords = 1; args[x]; x++)
  -        if (args[x] == '+') ++numwords;
  +     if (args[x] == '+')
  +         ++numwords;
   
       if (numwords > APACHE_ARG_MAX - 5) {
  -        numwords = APACHE_ARG_MAX - 5; /* Truncate args to prevent overrun */
  +     numwords = APACHE_ARG_MAX - 5;  /* Truncate args to prevent overrun */
       }
  -    av = (char **)palloc(p, (numwords + 5) * sizeof(char *));
  +    av = (char **) palloc(p, (numwords + 5) * sizeof(char *));
   
       if (path)
  -        av[idx++] = path;
  +     av[idx++] = path;
       if (user)
  -        av[idx++] = user;
  +     av[idx++] = user;
       if (group)
  -        av[idx++] = group;
  +     av[idx++] = group;
   
       av[idx++] = av0;
   
       for (x = 1; x <= numwords; x++) {
  -        w = getword_nulls(p, &args, '+');
  -        unescape_url(w);
  -        av[idx++] = escape_shell_cmd(p, w);
  +     w = getword_nulls(p, &args, '+');
  +     unescape_url(w);
  +     av[idx++] = escape_shell_cmd(p, w);
       }
       av[idx] = NULL;
       return av;
  @@ -119,30 +120,34 @@
   
   static char *http2env(pool *a, char *w)
   {
  -    char *res = pstrcat (a, "HTTP_", w, NULL);
  +    char *res = pstrcat(a, "HTTP_", w, NULL);
       char *cp = res;
  -  
  +
       while (*++cp)
  -      if (*cp == '-') *cp = '_';
  -      else *cp = toupper(*cp);
  +     if (*cp == '-')
  +         *cp = '_';
  +     else
  +         *cp = toupper(*cp);
   
       return res;
   }
   
   API_EXPORT(char **) create_environment(pool *p, table *t)
   {
  -    array_header *env_arr = table_elts (t);
  -    table_entry *elts = (table_entry *)env_arr->elts;
  -    char **env = (char **)palloc (p, (env_arr->nelts + 2) *sizeof (char *));
  +    array_header *env_arr = table_elts(t);
  +    table_entry *elts = (table_entry *) env_arr->elts;
  +    char **env = (char **) palloc(p, (env_arr->nelts + 2) * sizeof(char *));
       int i, j;
       char *tz;
   
       j = 0;
       tz = getenv("TZ");
  -    if (tz!= NULL) env[j++] = pstrcat(p, "TZ=", tz, NULL);
  +    if (tz != NULL)
  +     env[j++] = pstrcat(p, "TZ=", tz, NULL);
       for (i = 0; i < env_arr->nelts; ++i) {
  -        if (!elts[i].key) continue;
  -     env[j++] = pstrcat (p, elts[i].key, "=", elts[i].val, NULL);
  +     if (!elts[i].key)
  +         continue;
  +     env[j++] = pstrcat(p, elts[i].key, "=", elts[i].val, NULL);
       }
   
       env[j] = NULL;
  @@ -155,65 +160,71 @@
       server_rec *s = r->server;
       conn_rec *c = r->connection;
       const char *rem_logname;
  -    
  -    char port[40],*env_path;
  -    
  -    array_header *hdrs_arr = table_elts (r->headers_in);
  -    table_entry *hdrs = (table_entry *)hdrs_arr->elts;
  +
  +    char port[40], *env_path;
  +
  +    array_header *hdrs_arr = table_elts(r->headers_in);
  +    table_entry *hdrs = (table_entry *) hdrs_arr->elts;
       int i;
  -    
  +
       /* First, add environment vars from headers... this is as per
        * CGI specs, though other sorts of scripting interfaces see
        * the same vars...
        */
  -    
  +
       for (i = 0; i < hdrs_arr->nelts; ++i) {
  -        if (!hdrs[i].key) continue;
  +     if (!hdrs[i].key)
  +         continue;
   
        /* A few headers are special cased --- Authorization to prevent
         * rogue scripts from capturing passwords; content-type and -length
         * for no particular reason.
         */
  -     
  -     if (!strcasecmp (hdrs[i].key, "Content-type")) 
  -         table_set (e, "CONTENT_TYPE", hdrs[i].val);
  -     else if (!strcasecmp (hdrs[i].key, "Content-length"))
  -         table_set (e, "CONTENT_LENGTH", hdrs[i].val);
  -     else if (!strcasecmp (hdrs[i].key, "Authorization"))
  +
  +     if (!strcasecmp(hdrs[i].key, "Content-type"))
  +         table_set(e, "CONTENT_TYPE", hdrs[i].val);
  +     else if (!strcasecmp(hdrs[i].key, "Content-length"))
  +         table_set(e, "CONTENT_LENGTH", hdrs[i].val);
  +     else if (!strcasecmp(hdrs[i].key, "Authorization"))
            continue;
        else
  -         table_set (e, http2env (r->pool, hdrs[i].key), hdrs[i].val);
  +         table_set(e, http2env(r->pool, hdrs[i].key), hdrs[i].val);
       }
  -    
  +
       ap_snprintf(port, sizeof(port), "%u", s->port);
   
  -    if(!(env_path = getenv("PATH")))
  -        env_path=DEFAULT_PATH;
  -    
  -    table_set (e, "PATH", env_path);
  -    table_set (e, "SERVER_SOFTWARE", SERVER_VERSION);
  -    table_set (e, "SERVER_NAME", s->server_hostname);
  -    table_set (e, "SERVER_PORT", port);
  -    table_set (e, "REMOTE_HOST",
  -            get_remote_host(c, r->per_dir_config, REMOTE_NAME));
  -    table_set (e, "REMOTE_ADDR", c->remote_ip);
  -    table_set (e, "DOCUMENT_ROOT", document_root(r)); /* Apache */
  -    table_set (e, "SERVER_ADMIN", s->server_admin); /* Apache */
  -    table_set (e, "SCRIPT_FILENAME", r->filename); /* Apache */
  -    
  +    if (!(env_path = getenv("PATH")))
  +     env_path = DEFAULT_PATH;
  +
  +    table_set(e, "PATH", env_path);
  +    table_set(e, "SERVER_SOFTWARE", SERVER_VERSION);
  +    table_set(e, "SERVER_NAME", s->server_hostname);
  +    table_set(e, "SERVER_PORT", port);
  +    table_set(e, "REMOTE_HOST",
  +           get_remote_host(c, r->per_dir_config, REMOTE_NAME));
  +    table_set(e, "REMOTE_ADDR", c->remote_ip);
  +    table_set(e, "DOCUMENT_ROOT", document_root(r)); /* Apache */
  +    table_set(e, "SERVER_ADMIN", s->server_admin);   /* Apache */
  +    table_set(e, "SCRIPT_FILENAME", r->filename);    /* Apache */
  +
       ap_snprintf(port, sizeof(port), "%d", ntohs(c->remote_addr.sin_port));
  -    table_set (e, "REMOTE_PORT", port);            /* Apache */
  +    table_set(e, "REMOTE_PORT", port);       /* Apache */
   
  -    if (c->user) table_set(e, "REMOTE_USER", c->user);
  -    if (c->auth_type) table_set(e, "AUTH_TYPE", c->auth_type);
  +    if (c->user)
  +     table_set(e, "REMOTE_USER", c->user);
  +    if (c->auth_type)
  +     table_set(e, "AUTH_TYPE", c->auth_type);
       rem_logname = get_remote_logname(r);
  -    if (rem_logname) table_set(e, "REMOTE_IDENT", rem_logname);
  -    
  +    if (rem_logname)
  +     table_set(e, "REMOTE_IDENT", rem_logname);
  +
       /* Apache custom error responses. If we have redirected set two new vars 
*/
  -    
  +
       if (r->prev) {
  -        if (r->prev->args) table_set(e,"REDIRECT_QUERY_STRING", 
r->prev->args);
  -     if (r->prev->uri) table_set (e, "REDIRECT_URL", r->prev->uri);
  +     if (r->prev->args)
  +         table_set(e, "REDIRECT_QUERY_STRING", r->prev->args);
  +     if (r->prev->uri)
  +         table_set(e, "REDIRECT_URL", r->prev->uri);
       }
   }
   
  @@ -222,7 +233,7 @@
    * and find as much of the two that match as possible.
    */
   
  -API_EXPORT(int) find_path_info (char *uri, char *path_info)
  +API_EXPORT(int) find_path_info(char *uri, char *path_info)
   {
       int lu = strlen(uri);
       int lp = strlen(path_info);
  @@ -230,7 +241,7 @@
       while (lu-- && lp-- && uri[lu] == path_info[lp]);
   
       if (lu == -1)
  -     lu=0;
  +     lu = 0;
   
       while (uri[lu] != '\0' && uri[lu] != '/')
        lu++;
  @@ -246,16 +257,19 @@
       char *first, *last;
   
       if (r->the_request == NULL)
  -        return (char *)pcalloc(r->pool, 1);
  +     return (char *) pcalloc(r->pool, 1);
   
  -    first = r->the_request;                      /* use the request-line */
  +    first = r->the_request;  /* use the request-line */
   
  -    while (*first && !isspace(*first)) ++first;  /* skip over the method */
  -    while (isspace(*first)) ++first;             /*   and the space(s)   */
  +    while (*first && !isspace(*first))
  +     ++first;                /* skip over the method */
  +    while (isspace(*first))
  +     ++first;                /*   and the space(s)   */
   
       last = first;
  -    while (*last && !isspace(*last)) ++last;     /* end at next whitespace */
  -    
  +    while (*last && !isspace(*last))
  +     ++last;                 /* end at next whitespace */
  +
       return pstrndup(r->pool, first, last - first);
   }
   
  @@ -263,61 +277,63 @@
   {
       table *e = r->subprocess_env;
   
  -    table_set (e, "GATEWAY_INTERFACE","CGI/1.1");
  -    table_set (e, "SERVER_PROTOCOL", r->protocol);
  -    table_set (e, "REQUEST_METHOD", r->method);
  -    table_set (e, "QUERY_STRING", r->args ? r->args : "");
  -    table_set (e, "REQUEST_URI", original_uri(r));
  +    table_set(e, "GATEWAY_INTERFACE", "CGI/1.1");
  +    table_set(e, "SERVER_PROTOCOL", r->protocol);
  +    table_set(e, "REQUEST_METHOD", r->method);
  +    table_set(e, "QUERY_STRING", r->args ? r->args : "");
  +    table_set(e, "REQUEST_URI", original_uri(r));
   
       /* Note that the code below special-cases scripts run from includes,
        * because it "knows" that the sub_request has been hacked to have the
        * args and path_info of the original request, and not any that may have
        * come with the script URI in the include command.  Ugh.
        */
  -    
  -    if (!strcmp (r->protocol, "INCLUDED")) {
  -        table_set (e, "SCRIPT_NAME", r->uri);
  +
  +    if (!strcmp(r->protocol, "INCLUDED")) {
  +     table_set(e, "SCRIPT_NAME", r->uri);
        if (r->path_info && *r->path_info)
  -         table_set (e, "PATH_INFO", r->path_info);
  -    } else if (!r->path_info || !*r->path_info) {
  -        table_set (e, "SCRIPT_NAME", r->uri);
  -    } else {
  -     int path_info_start = find_path_info (r->uri, r->path_info);
  +         table_set(e, "PATH_INFO", r->path_info);
  +    }
  +    else if (!r->path_info || !*r->path_info) {
  +     table_set(e, "SCRIPT_NAME", r->uri);
  +    }
  +    else {
  +     int path_info_start = find_path_info(r->uri, r->path_info);
   
  -     table_set (e, "SCRIPT_NAME", pstrndup(r->pool, r->uri,
  -                                           path_info_start));
  +     table_set(e, "SCRIPT_NAME", pstrndup(r->pool, r->uri,
  +                                          path_info_start));
   
  -     table_set (e, "PATH_INFO", r->path_info);
  +     table_set(e, "PATH_INFO", r->path_info);
       }
  -     
  +
       if (r->path_info && r->path_info[0]) {
        /*
  -      * To get PATH_TRANSLATED, treat PATH_INFO as a URI path.
  +      * To get PATH_TRANSLATED, treat PATH_INFO as a URI path.
         * Need to re-escape it for this, since the entire URI was
         * un-escaped before we determined where the PATH_INFO began.
  -      */
  -     request_rec *pa_req = sub_req_lookup_uri(
  -                                 escape_uri(r->pool, r->path_info), r);
  -      
  +      */
  +     request_rec *pa_req = sub_req_lookup_uri(escape_uri(r->pool, 
r->path_info),
  +                                              r);
  +
        /* Don't bother destroying pa_req --- it's only created in
         * child processes which are about to jettison their address
         * space anyway.  BTW, we concatenate filename and path_info
         * from the sub_request to be compatible in case the PATH_INFO
         * is pointing to an object which doesn't exist.
         */
  -     
  +
        if (pa_req->filename) {
   #ifdef WIN32
            char buffer[HUGE_STRING_LEN];
   #endif
  -         char *pt = pstrcat (r->pool, pa_req->filename, pa_req->path_info,
  -                             NULL);
  +         char *pt = pstrcat(r->pool, pa_req->filename, pa_req->path_info,
  +                            NULL);
   #ifdef WIN32
            /* We need to make this a real Windows path name */
            GetFullPathName(pt, HUGE_STRING_LEN, buffer, NULL);
  -         table_set (e, "PATH_TRANSLATED", pstrdup(r->pool, buffer));
  +         table_set(e, "PATH_TRANSLATED", pstrdup(r->pool, buffer));
   #else
  -         table_set (e, "PATH_TRANSLATED", pt);
  +         table_set(e, "PATH_TRANSLATED", pt);
   #endif
        }
       }
  @@ -325,36 +341,39 @@
   
   
   static int scan_script_header_err_core(request_rec *r, char *buffer,
  -    int (*getsfunc)(char *, int, void *), void *getsfunc_data)
  +              int (*getsfunc) (char *, int, void *), void *getsfunc_data)
   {
       char x[MAX_STRING_LEN];
       char *w, *l;
       int p;
       int cgi_status = HTTP_OK;
   
  -    if (buffer) *buffer = '\0';
  +    if (buffer)
  +     *buffer = '\0';
       w = buffer ? buffer : x;
   
  -    hard_timeout ("read script header", r);
  -    
  -    while(1) {
  +    hard_timeout("read script header", r);
   
  -     if ((*getsfunc)(w, MAX_STRING_LEN-1, getsfunc_data) == 0) {
  -         kill_timeout (r);
  +    while (1) {
  +
  +     if ((*getsfunc) (w, MAX_STRING_LEN - 1, getsfunc_data) == 0) {
  +         kill_timeout(r);
            aplog_error(APLOG_MARK, APLOG_ERR, r->server,
                        "Premature end of script headers: %s", r->filename);
            return SERVER_ERROR;
  -        }
  +     }
   
        /* Delete terminal (CR?)LF */
  -     
  +
        p = strlen(w);
  -     if (p > 0 && w[p-1] == '\n') {
  -         if (p > 1 && w[p-2] == '\015') w[p-2] = '\0';
  -         else w[p-1] = '\0';
  +     if (p > 0 && w[p - 1] == '\n') {
  +         if (p > 1 && w[p - 2] == '\015')
  +             w[p - 2] = '\0';
  +         else
  +             w[p - 1] = '\0';
        }
   
  -        /*
  +     /*
         * If we've finished reading the headers, check to make sure any
         * HTTP/1.1 conditions are met.  If so, we're done; normal processing
         * will handle the script's output.  If not, just return the error.
  @@ -366,156 +385,160 @@
         * However, we don't have the information to do that, so we have to
         * leave it to an upper layer.
         */
  -        if (w[0] == '\0') {
  +     if (w[0] == '\0') {
            int cond_status = OK;
   
  -         kill_timeout (r);
  +         kill_timeout(r);
            if ((cgi_status == HTTP_OK) && (r->method_number == M_GET)) {
                cond_status = meets_conditions(r);
            }
            return cond_status;
        }
  -                                   
  +
        /* if we see a bogus header don't ignore it. Shout and scream */
  -     
  -        if (!(l = strchr(w,':'))) {
  -         char malformed[(sizeof 
MALFORMED_MESSAGE)+1+MALFORMED_HEADER_LENGTH_TO_SHOW];
  -            strcpy(malformed, MALFORMED_MESSAGE);
  -            strncat(malformed, w, MALFORMED_HEADER_LENGTH_TO_SHOW);
  +
  +     if (!(l = strchr(w, ':'))) {
  +         char malformed[(sizeof MALFORMED_MESSAGE) + 1 + 
MALFORMED_HEADER_LENGTH_TO_SHOW];
  +         strcpy(malformed, MALFORMED_MESSAGE);
  +         strncat(malformed, w, MALFORMED_HEADER_LENGTH_TO_SHOW);
   
            if (!buffer)
  -           /* Soak up all the script output --- may save an outright kill */
  -           while ((*getsfunc)(w, MAX_STRING_LEN-1, getsfunc_data))
  -             continue;
  -         
  -         kill_timeout (r);
  +             /* Soak up all the script output --- may save an outright kill 
*/
  +             while ((*getsfunc) (w, MAX_STRING_LEN - 1, getsfunc_data))
  +                 continue;
  +
  +         kill_timeout(r);
            aplog_error(APLOG_MARK, APLOG_ERR, r->server,
                        "%s: %s", malformed, r->filename);
            return SERVER_ERROR;
  -        }
  +     }
   
  -        *l++ = '\0';
  -     while (*l && isspace (*l)) ++l;
  -     
  -        if(!strcasecmp(w,"Content-type")) {
  +     *l++ = '\0';
  +     while (*l && isspace(*l))
  +         ++l;
  +
  +     if (!strcasecmp(w, "Content-type")) {
   
            /* Nuke trailing whitespace */
  -         
  +
            char *endp = l + strlen(l) - 1;
  -         while (endp > l && isspace(*endp)) *endp-- = '\0';
  -         
  -         r->content_type = pstrdup (r->pool, l);
  -     }
  -        else if(!strcasecmp(w,"Status")) {
  -            sscanf(l, "%d", &r->status);
  -            r->status_line = pstrdup(r->pool, l);
  -        }
  -        else if(!strcasecmp(w,"Location")) {
  -         table_set (r->headers_out, w, l);
  -        }   
  -        else if(!strcasecmp(w,"Content-Length")) {
  -         table_set (r->headers_out, w, l);
  -        }   
  -        else if(!strcasecmp(w,"Transfer-Encoding")) {
  -         table_set (r->headers_out, w, l);
  -        }   
  -/*
  - * If the script gave us a Last-Modified header, we can't just pass it on
  - * blindly because of restrictions on future values.
  - */
  -        else if (!strcasecmp(w, "Last-Modified")) {
  +         while (endp > l && isspace(*endp))
  +             *endp-- = '\0';
  +
  +         r->content_type = pstrdup(r->pool, l);
  +     }
  +     else if (!strcasecmp(w, "Status")) {
  +         sscanf(l, "%d", &r->status);
  +         r->status_line = pstrdup(r->pool, l);
  +     }
  +     else if (!strcasecmp(w, "Location")) {
  +         table_set(r->headers_out, w, l);
  +     }
  +     else if (!strcasecmp(w, "Content-Length")) {
  +         table_set(r->headers_out, w, l);
  +     }
  +     else if (!strcasecmp(w, "Transfer-Encoding")) {
  +         table_set(r->headers_out, w, l);
  +     }
  +     /*
  +      * If the script gave us a Last-Modified header, we can't just
  +      * pass it on blindly because of restrictions on future values.
  +      */
  +     else if (!strcasecmp(w, "Last-Modified")) {
            time_t mtime = parseHTTPdate(l);
   
            update_mtime(r, mtime);
            set_last_modified(r);
  -        }   
  -/*
  - * If the script returned a specific status, that's what we'll use - 
otherwise
  - * we assume 200 OK.
  - */
  -        else if (!strcasecmp(w, "Status")) {
  -         table_set (r->headers_out, w, l);
  +     }
  +     /*
  +      * If the script returned a specific status, that's what
  +      * we'll use - otherwise we assume 200 OK.
  +      */
  +     else if (!strcasecmp(w, "Status")) {
  +         table_set(r->headers_out, w, l);
            cgi_status = atoi(l);
  -        }   
  +     }
   
  -/* The HTTP specification says that it is legal to merge duplicate
  - * headers into one.  Some browsers that support Cookies don't like
  - * merged headers and prefer that each Set-Cookie header is sent
  - * separately.  Lets humour those browsers.
  - */
  -     else if(!strcasecmp(w, "Set-Cookie")) {
  +     /* The HTTP specification says that it is legal to merge duplicate
  +      * headers into one.  Some browsers that support Cookies don't like
  +      * merged headers and prefer that each Set-Cookie header is sent
  +      * separately.  Lets humour those browsers.
  +      */
  +     else if (!strcasecmp(w, "Set-Cookie")) {
            table_add(r->err_headers_out, w, l);
        }
  -        else {
  -         table_merge (r->err_headers_out, w, l);
  -        }
  +     else {
  +         table_merge(r->err_headers_out, w, l);
  +     }
       }
   }
   
  -static int getsfunc_FILE (char *buf, int len, void *f)
  +static int getsfunc_FILE(char *buf, int len, void *f)
   {
  -    return fgets (buf, len, (FILE *)f) != NULL;
  +    return fgets(buf, len, (FILE *) f) != NULL;
   }
   
   API_EXPORT(int) scan_script_header_err(request_rec *r, FILE *f, char *buffer)
   {
  -    return scan_script_header_err_core (r, buffer, getsfunc_FILE, f);
  +    return scan_script_header_err_core(r, buffer, getsfunc_FILE, f);
   }
   
  -static int getsfunc_BUFF (char *w, int len, void *fb)
  +static int getsfunc_BUFF(char *w, int len, void *fb)
   {
  -    return bgets (w, len, (BUFF *)fb) > 0;
  +    return bgets(w, len, (BUFF *) fb) > 0;
   }
   
   API_EXPORT(int) scan_script_header_err_buff(request_rec *r, BUFF *fb,
  -    char *buffer)
  +                                         char *buffer)
   {
  -    return scan_script_header_err_core (r, buffer, getsfunc_BUFF, fb);
  +    return scan_script_header_err_core(r, buffer, getsfunc_BUFF, fb);
   }
   
   
  -API_EXPORT(void) send_size(size_t size, request_rec *r) {
  +API_EXPORT(void) send_size(size_t size, request_rec *r)
  +{
       char ss[20];
   
  -    if(size == -1) 
  -        strcpy(ss, "    -");
  -    else if(!size) 
  -        strcpy(ss, "   0k");
  -    else if(size < 1024) 
  -        strcpy(ss, "   1k");
  -    else if(size < 1048576)
  -        ap_snprintf(ss, sizeof(ss), "%4dk", (size + 512) / 1024);
  -    else if(size < 103809024)
  +    if (size == -1)
  +     strcpy(ss, "    -");
  +    else if (!size)
  +     strcpy(ss, "   0k");
  +    else if (size < 1024)
  +     strcpy(ss, "   1k");
  +    else if (size < 1048576)
  +     ap_snprintf(ss, sizeof(ss), "%4dk", (size + 512) / 1024);
  +    else if (size < 103809024)
        ap_snprintf(ss, sizeof(ss), "%4.1fM", size / 1048576.0);
       else
  -        ap_snprintf(ss, sizeof(ss), "%4dM", (size + 524288) / 1048576);
  +     ap_snprintf(ss, sizeof(ss), "%4dM", (size + 524288) / 1048576);
       rputs(ss, r);
   }
   
   #if defined(__EMX__) || defined(WIN32)
   static char **create_argv_cmd(pool *p, char *av0, const char *args, char 
*path)
   {
  -    register int x,n;
  +    register int x, n;
       char **av;
       char *w;
   
  -    for(x=0,n=2;args[x];x++)
  -        if(args[x] == '+') ++n;
  +    for (x = 0, n = 2; args[x]; x++)
  +     if (args[x] == '+')
  +         ++n;
   
       /* Add extra strings to array. */
       n = n + 2;
   
  -    av = (char **)palloc(p, (n+1)*sizeof(char *));
  +    av = (char **) palloc(p, (n + 1) * sizeof(char *));
       av[0] = av0;
   
       /* Now insert the extra strings we made room for above. */
       av[1] = strdup("/C");
       av[2] = strdup(path);
   
  -    for(x=(1+2);x<n;x++) {
  -        w = getword(p, &args, '+');
  -        unescape_url(w);
  -        av[x] = escape_shell_cmd(p, w);
  +    for (x = (1 + 2); x < n; x++) {
  +     w = getword(p, &args, '+');
  +     unescape_url(w);
  +     av[x] = escape_shell_cmd(p, w);
       }
       av[n] = NULL;
       return av;
  @@ -523,14 +546,14 @@
   #endif
   
   
  -API_EXPORT(int) call_exec (request_rec *r, char *argv0, char **env, int 
shellcmd) 
  +API_EXPORT(int) call_exec(request_rec *r, char *argv0, char **env, int 
shellcmd)
   {
       int pid = 0;
   #if defined(RLIMIT_CPU)  || defined(RLIMIT_NPROC) || \
       defined(RLIMIT_DATA) || defined(RLIMIT_VMEM)
   
       core_dir_config *conf =
  -      (core_dir_config *)get_module_config(r->per_dir_config, &core_module);
  +    (core_dir_config *) get_module_config(r->per_dir_config, &core_module);
   
   #endif
   
  @@ -542,280 +565,292 @@
   
   #ifdef RLIMIT_CPU
       if (conf->limit_cpu != NULL)
  -     if ((setrlimit (RLIMIT_CPU, conf->limit_cpu)) != 0)
  +     if ((setrlimit(RLIMIT_CPU, conf->limit_cpu)) != 0)
            aplog_error(APLOG_MARK, APLOG_ERR, r->server,
                        "setrlimit: failed to set CPU usage limit");
   #endif
   #ifdef RLIMIT_NPROC
       if (conf->limit_nproc != NULL)
  -     if ((setrlimit (RLIMIT_NPROC, conf->limit_nproc)) != 0)
  +     if ((setrlimit(RLIMIT_NPROC, conf->limit_nproc)) != 0)
            aplog_error(APLOG_MARK, APLOG_ERR, r->server,
                        "setrlimit: failed to set process limit");
   #endif
   #ifdef RLIMIT_DATA
       if (conf->limit_mem != NULL)
  -     if ((setrlimit (RLIMIT_DATA, conf->limit_mem)) != 0)
  +     if ((setrlimit(RLIMIT_DATA, conf->limit_mem)) != 0)
            aplog_error(APLOG_MARK, APLOG_ERR, r->server,
                        "setrlimit: failed to set memory usage limit");
   #endif
   #ifdef RLIMIT_VMEM
       if (conf->limit_mem != NULL)
  -     if ((setrlimit (RLIMIT_VMEM, conf->limit_mem)) != 0)
  +     if ((setrlimit(RLIMIT_VMEM, conf->limit_mem)) != 0)
            aplog_error(APLOG_MARK, APLOG_ERR, r->server,
                        "setrlimit: failed to set memory usage limit");
   #endif
  -    
  -#ifdef __EMX__    
  +
  +#ifdef __EMX__
       {
  -        /* Additions by Alec Kloss, to allow exec'ing of scripts under OS/2 
*/
  -        int is_script;
  -        char interpreter[2048]; /* hope this is large enough for the 
interpreter path */
  -        FILE * program;
  -        program = fopen (r->filename, "r");
  -        if (!program) {
  -            char err_string[HUGE_STRING_LEN];
  -            ap_snprintf(err_string, sizeof(err_string),      "open of %s 
failed", r->filename);
  -         
  -            /* write(2, err_string, strlen(err_string)); */
  -            /* exit(0); */
  -            aplog_error(APLOG_MARK, APLOG_ERR, r->server, "fopen: %s", 
err_string);
  -            return(pid);
  -        }
  -        fgets(interpreter, sizeof(interpreter), program);
  -        fclose(program);
  -        if (!strncmp (interpreter, "#!", 2)) {
  -            is_script = 1;
  -            interpreter[strlen(interpreter)-1] = '\0';
  -        }
  +     /* Additions by Alec Kloss, to allow exec'ing of scripts under OS/2 */
  +     int is_script;
  +     char interpreter[2048]; /* hope this is large enough for the 
interpreter path */
  +     FILE *program;
  +     program = fopen(r->filename, "r");
  +     if (!program) {
  +         char err_string[HUGE_STRING_LEN];
  +         ap_snprintf(err_string, sizeof(err_string), "open of %s failed", 
r->filename);
  +
  +         /* write(2, err_string, strlen(err_string)); */
  +         /* exit(0); */
  +         aplog_error(APLOG_MARK, APLOG_ERR, r->server, "fopen: %s", 
err_string);
  +         return (pid);
  +     }
  +     fgets(interpreter, sizeof(interpreter), program);
  +     fclose(program);
  +     if (!strncmp(interpreter, "#!", 2)) {
  +         is_script = 1;
  +         interpreter[strlen(interpreter) - 1] = '\0';
  +     }
        else {
  -            is_script = 0;
  -        }
  +         is_script = 0;
  +     }
   
  -    if ((!r->args) || (!r->args[0]) || (ind(r->args,'=') >= 0)) {
  -     int emxloop;
  -     char *emxtemp;
  -
  -     /* For OS/2 place the variables in the current
  -        enviornment then it will be inherited. This way
  -        the program will also get all of OS/2's other SETs. */
  -     for (emxloop=0; ((emxtemp = env[emxloop]) != NULL); emxloop++)
  -         putenv(emxtemp);
  -                
  -    /* Additions by Alec Kloss, to allow exec'ing of scripts under OS/2 */
  -    if (is_script) {
  -        /* here's the stuff to run the interpreter */
  -        execl (interpreter+2, interpreter+2, r->filename, NULL);
  -    } else
  -
  -     if (strstr(strupr(r->filename), ".CMD") > 0) {
  -         /* Special case to allow use of REXX commands as scripts. */
  -         os2pathname(r->filename);
  -         execl("CMD.EXE", "CMD.EXE", "/C", r->filename, NULL);
  +     if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0)) {
  +         int emxloop;
  +         char *emxtemp;
  +
  +         /* For OS/2 place the variables in the current
  +          * enviornment then it will be inherited. This way
  +          * the program will also get all of OS/2's other SETs.
  +          */
  +         for (emxloop = 0; ((emxtemp = env[emxloop]) != NULL); emxloop++)
  +             putenv(emxtemp);
  +
  +         /* Additions by Alec Kloss, to allow exec'ing of scripts under OS/2 
*/
  +         if (is_script) {
  +             /* here's the stuff to run the interpreter */
  +             execl(interpreter + 2, interpreter + 2, r->filename, NULL);
  +         }
  +         else if (strstr(strupr(r->filename), ".CMD") > 0) {
  +             /* Special case to allow use of REXX commands as scripts. */
  +             os2pathname(r->filename);
  +             execl("CMD.EXE", "CMD.EXE", "/C", r->filename, NULL);
  +         }
  +         else {
  +             execl(r->filename, argv0, NULL);
  +         }
        }
        else {
  -         execl(r->filename, argv0, NULL);
  -     }
  -    }
  -    else {
  -     int emxloop;
  -     char *emxtemp;
  -            
  -     /* For OS/2 place the variables in the current
  -        environment so that they will be inherited. This way
  -        the program will also get all of OS/2's other SETs. */
  -     for (emxloop=0; ((emxtemp = env[emxloop]) != NULL); emxloop++)
  -         putenv(emxtemp);
  -                
  -     if (strstr(strupr(r->filename), ".CMD") > 0) {
  -         /* Special case to allow use of REXX commands as scripts. */
  -         os2pathname(r->filename);
  -         execv("CMD.EXE", create_argv_cmd(r->pool, argv0, r->args, 
r->filename));
  +         int emxloop;
  +         char *emxtemp;
  +
  +         /* For OS/2 place the variables in the current
  +          * environment so that they will be inherited. This way
  +          * the program will also get all of OS/2's other SETs.
  +          */
  +         for (emxloop = 0; ((emxtemp = env[emxloop]) != NULL); emxloop++)
  +             putenv(emxtemp);
  +
  +         if (strstr(strupr(r->filename), ".CMD") > 0) {
  +             /* Special case to allow use of REXX commands as scripts. */
  +             os2pathname(r->filename);
  +             execv("CMD.EXE", create_argv_cmd(r->pool, argv0, r->args, 
r->filename));
  +         }
  +         else
  +             execv(r->filename,
  +                 create_argv(r->pool, NULL, NULL, NULL, argv0, r->args));
        }
  -     else
  -         execv(r->filename,
  -               create_argv(r->pool, NULL, NULL, NULL, argv0, r->args));
  -    }
  -    return(pid);
  +     return (pid);
       }
   #elif defined(WIN32)
       {
  -        /* Adapted from work by Alec Kloss, to allow exec'ing of scripts 
under OS/2 */
  -        int is_script = 0;
  -        int is_binary = 0;
  -        char interpreter[2048]; /* hope this is large enough for the 
interpreter path */
  -        FILE * program;
  -        int i, sz;
  -        char *dot;
  -        char *exename;
  -        int is_exe = 0;
  -
  -        interpreter[0] = 0;
  -
  -        exename = strrchr(r->filename, '/');
  -        if(!exename)
  -            exename = strrchr(r->filename, '\\');
  -        if(!exename)
  -            exename = r->filename;
  -        else
  -            exename++;
  -        dot = strrchr(exename, '.');
  -        if(dot)
  -        {
  -            if(!strcasecmp(dot, ".BAT") ||
  -                !strcasecmp(dot, ".EXE") ||
  -                !strcasecmp(dot, ".COM"))
  -                is_exe = 1;
  -        }
  -     
  -        if (!is_exe) {
  -            program = fopen (r->filename, "rb");
  -            if (!program) {
  -                char err_string[HUGE_STRING_LEN];
  -                ap_snprintf(err_string, sizeof(err_string),
  +     /* Adapted from work by Alec Kloss, to allow exec'ing of scripts under 
OS/2 */
  +     int is_script = 0;
  +     int is_binary = 0;
  +     char interpreter[2048]; /* hope this is large enough for the 
interpreter path */
  +     FILE *program;
  +     int i, sz;
  +     char *dot;
  +     char *exename;
  +     int is_exe = 0;
  +
  +     interpreter[0] = 0;
  +
  +     exename = strrchr(r->filename, '/');
  +     if (!exename)
  +         exename = strrchr(r->filename, '\\');
  +     if (!exename)
  +         exename = r->filename;
  +     else
  +         exename++;
  +     dot = strrchr(exename, '.');
  +     if (dot) {
  +         if (!strcasecmp(dot, ".BAT") ||
  +             !strcasecmp(dot, ".EXE") ||
  +             !strcasecmp(dot, ".COM"))
  +             is_exe = 1;
  +     }
  +
  +     if (!is_exe) {
  +         program = fopen(r->filename, "rb");
  +         if (!program) {
  +             char err_string[HUGE_STRING_LEN];
  +             ap_snprintf(err_string, sizeof(err_string),
                            "open of %s failed", r->filename);
  -                /* write(2, err_string, strlen(err_string)); */
  -                /* exit(0); */
  -                aplog_error(APLOG_MARK, APLOG_ERR, r->server, "fopen: %s", 
err_string);
  -                return(pid);
  -            }
  -            sz = fread(interpreter, 1, sizeof(interpreter)-1, program);
  -            if (sz < 0) {
  -                char err_string[HUGE_STRING_LEN];
  -                ap_snprintf(err_string, sizeof(err_string),
  +             /* write(2, err_string, strlen(err_string)); */
  +             /* exit(0); */
  +             aplog_error(APLOG_MARK, APLOG_ERR, r->server, "fopen: %s", 
err_string);
  +             return (pid);
  +         }
  +         sz = fread(interpreter, 1, sizeof(interpreter) - 1, program);
  +         if (sz < 0) {
  +             char err_string[HUGE_STRING_LEN];
  +             ap_snprintf(err_string, sizeof(err_string),
                            "open of %s failed", r->filename);
  -                aplog_error(APLOG_MARK, APLOG_ERR, r->server, "fread: %s", 
err_string);
  -                fclose(program);
  -                return(pid);
  -            }
  -            interpreter[sz] = 0;
  -            fclose (program);
  -            if (!strncmp (interpreter, "#!", 2)) {
  -                is_script = 1;
  -                for(i=2; i<sizeof(interpreter); i++)
  -                {
  -                    if((interpreter[i] == '\r') ||
  -                            (interpreter[i] == '\n'))
  -                        break;
  -                }
  -                interpreter[i] = 0;
  -            } else {
  -                /*
  -                 * check and see how many control chars. On
  -                 * that basis, I will classify it as a text
  -                 * or binary file
  -                 */
  -                int ctrl = 0;
  -
  -                for(i=0; i<sz; i++)
  -                {
  -                    static char *spec = "\r\n\t";
  -                    if(iscntrl(interpreter[i]) && !strchr(spec, 
interpreter[i]))
  -                        ctrl++;
  -                }
  -                if(ctrl > sz/10)
  -                    is_binary = 1;
  -                else
  -                    is_binary = 0;
  -                
  -            }
  -        }
  -
  -        if ((!r->args) || (!r->args[0]) || (ind(r->args,'=') >= 0)) {
  -            if (is_exe || is_binary) {
  -                pid = spawnle(_P_NOWAIT, r->filename, r->filename, NULL, 
env);
  -            } else if(is_script) {
  -             pid = spawnle(_P_NOWAIT, interpreter+2, interpreter+2, 
r->filename, NULL, env);
  -            } else {             
  -                pid = spawnle(_P_NOWAIT, "CMD.EXE", "CMD.EXE", "/C", 
r->filename, NULL, env);
  -            }
  -        }
  -        else {
  -            if (is_exe || is_binary) {
  -                pid = spawnve(_P_NOWAIT, r->filename, create_argv(r->pool, 
argv0, NULL, NULL, r->args, (void *)NULL), env);
  -            } else if(is_script) {
  -             ap_assert(0);
  -                pid = spawnve(_P_NOWAIT, interpreter+2, create_argv(r->pool, 
interpreter+2, NULL, NULL, r->filename, r->args), env);
  -            } else {  
  -                pid = spawnve(_P_NOWAIT, "CMD.EXE", create_argv_cmd(r->pool, 
argv0, r->args, r->filename), env);
  -            }
  -        }
  -        return(pid);
  +             aplog_error(APLOG_MARK, APLOG_ERR, r->server, "fread: %s", 
err_string);
  +             fclose(program);
  +             return (pid);
  +         }
  +         interpreter[sz] = 0;
  +         fclose(program);
  +         if (!strncmp(interpreter, "#!", 2)) {
  +             is_script = 1;
  +             for (i = 2; i < sizeof(interpreter); i++) {
  +                 if ((interpreter[i] == '\r') ||
  +                     (interpreter[i] == '\n'))
  +                     break;
  +             }
  +             interpreter[i] = 0;
  +         }
  +         else {
  +             /*
  +              * check and see how many control chars. On
  +              * that basis, I will classify it as a text
  +              * or binary file
  +              */
  +             int ctrl = 0;
  +
  +             for (i = 0; i < sz; i++) {
  +                 static char *spec = "\r\n\t";
  +                 if (iscntrl(interpreter[i]) && !strchr(spec, 
interpreter[i]))
  +                     ctrl++;
  +             }
  +             if (ctrl > sz / 10)
  +                 is_binary = 1;
  +             else
  +                 is_binary = 0;
  +
  +         }
  +     }
  +
  +     if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0)) {
  +         if (is_exe || is_binary) {
  +             pid = spawnle(_P_NOWAIT, r->filename, r->filename, NULL, env);
  +         }
  +         else if (is_script) {
  +             pid = spawnle(_P_NOWAIT, interpreter + 2, interpreter + 2,
  +                           r->filename, NULL, env);
  +         }
  +         else {
  +             pid = spawnle(_P_NOWAIT, "CMD.EXE", "CMD.EXE", "/C",
  +                           r->filename, NULL, env);
  +         }
  +     }
  +     else {
  +         if (is_exe || is_binary) {
  +             pid = spawnve(_P_NOWAIT, r->filename,
  +                           create_argv(r->pool, argv0, NULL, NULL, r->args,
  +                                       (void *) NULL), env);
  +         }
  +         else if (is_script) {
  +             ap_assert(0);
  +             pid = spawnve(_P_NOWAIT, interpreter + 2,
  +                           create_argv(r->pool, interpreter + 2, NULL, NULL,
  +                                       r->filename, r->args), env);
  +         }
  +         else {
  +             pid = spawnve(_P_NOWAIT, "CMD.EXE",
  +                           create_argv_cmd(r->pool, argv0, r->args,
  +                                           r->filename), env);
  +         }
  +     }
  +     return (pid);
       }
   #else
  -    if ( suexec_enabled &&
  -      ((r->server->server_uid != user_id) ||
  -       (r->server->server_gid != group_id) ||
  -       (!strncmp("/~",r->uri,2))) ) {
  +    if (suexec_enabled &&
  +     ((r->server->server_uid != user_id) ||
  +      (r->server->server_gid != group_id) ||
  +      (!strncmp("/~", r->uri, 2)))) {
   
        char *execuser, *grpname;
        struct passwd *pw;
        struct group *gr;
   
  -     if (!strncmp("/~",r->uri,2)) {
  +     if (!strncmp("/~", r->uri, 2)) {
            gid_t user_gid;
            char *username = pstrdup(r->pool, r->uri + 2);
            int pos = ind(username, '/');
   
  -         if (pos >= 0) username[pos] = '\0';
  +         if (pos >= 0)
  +             username[pos] = '\0';
   
            if ((pw = getpwnam(username)) == NULL) {
  -             aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  +             aplog_error(APLOG_MARK, APLOG_ERR, r->server,
                            "getpwnam: invalid username %s", username);
  -             return(pid);
  +             return (pid);
            }
            execuser = pstrcat(r->pool, "~", pw->pw_name, NULL);
            user_gid = pw->pw_gid;
   
            if ((gr = getgrgid(user_gid)) == NULL) {
  -             if ((grpname = palloc (r->pool, 16)) == NULL) 
  -                 return(pid);
  -             else
  -                 ap_snprintf(grpname, 16, "%d", user_gid);
  +             if ((grpname = palloc(r->pool, 16)) == NULL)
  +                      return (pid);
  +             else
  +                 ap_snprintf(grpname, 16, "%d", user_gid);
            }
            else
  -             grpname = gr->gr_name;
  +             grpname = gr->gr_name;
        }
        else {
  -         if ((pw = getpwuid (r->server->server_uid)) == NULL) {
  +         if ((pw = getpwuid(r->server->server_uid)) == NULL) {
                aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  -                         "getpwuid: invalid userid %d", 
r->server->server_uid);
  -             return(pid);
  +                   "getpwuid: invalid userid %d", r->server->server_uid);
  +             return (pid);
            }
            execuser = pstrdup(r->pool, pw->pw_name);
   
  -         if ((gr = getgrgid (r->server->server_gid)) == NULL) {
  +         if ((gr = getgrgid(r->server->server_gid)) == NULL) {
                aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  -                         "getgrgid: invalid groupid %d", 
r->server->server_gid);
  -             return(pid);
  +                  "getgrgid: invalid groupid %d", r->server->server_gid);
  +             return (pid);
            }
            grpname = gr->gr_name;
        }
  -  
  -     if (shellcmd)
  +
  +     if (shellcmd)
            execle(SUEXEC_BIN, SUEXEC_BIN, execuser, grpname, argv0, NULL, env);
   
  -     else if((!r->args) || (!r->args[0]) || (ind(r->args,'=') >= 0))
  +     else if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0))
            execle(SUEXEC_BIN, SUEXEC_BIN, execuser, grpname, argv0, NULL, env);
   
  -     else {
  -         execve(SUEXEC_BIN, 
  +     else {
  +         execve(SUEXEC_BIN,
                   create_argv(r->pool, SUEXEC_BIN, execuser, grpname,
  -                            argv0, r->args),
  -                env);
  +                            argv0, r->args),
  +                env);
        }
       }
       else {
  -     if (shellcmd) 
  +     if (shellcmd)
            execle(SHELL_PATH, SHELL_PATH, "-c", argv0, NULL, env);
  -     
  -     else if((!r->args) || (!r->args[0]) || (ind(r->args,'=') >= 0))
  +
  +     else if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0))
            execle(r->filename, argv0, NULL, env);
   
        else
            execve(r->filename,
  -                create_argv(r->pool, NULL, NULL, NULL, argv0, r->args),
  -                env);
  +                create_argv(r->pool, NULL, NULL, NULL, argv0, r->args),
  +                env);
       }
  -    return(pid);
  +    return (pid);
   #endif
   }
  
  
  
  1.23      +1 -2      apachen/src/main/util_script.h
  
  Index: util_script.h
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_script.h,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- util_script.h     1997/07/24 04:24:00     1.22
  +++ util_script.h     1997/09/14 22:18:59     1.23
  @@ -66,5 +66,4 @@
   API_EXPORT(int) scan_script_header_err(request_rec *r, FILE *f, char 
*buffer);
   API_EXPORT(int) scan_script_header_err_buff(request_rec *r, BUFF *f, char 
*buffer);
   API_EXPORT(void) send_size(size_t size, request_rec *r);
  -API_EXPORT(int) call_exec (request_rec *r, char *argv0, char **env, int 
shellcmd);
  -
  +API_EXPORT(int) call_exec(request_rec *r, char *argv0, char **env, int 
shellcmd);
  
  
  
  1.9       +23 -28    apachen/src/main/util_snprintf.c
  
  Index: util_snprintf.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_snprintf.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- util_snprintf.c   1997/07/21 12:27:16     1.8
  +++ util_snprintf.c   1997/09/14 22:19:00     1.9
  @@ -67,9 +67,9 @@
   
   #ifdef HAVE_CVT
   
  -# define ap_ecvt ecvt
  -# define ap_fcvt fcvt
  -# define ap_gcvt gcvt
  +#define ap_ecvt ecvt
  +#define ap_fcvt fcvt
  +#define ap_gcvt gcvt
   
   #else
   
  @@ -87,8 +87,7 @@
   
   #define      NDIG    80
   
  -static char *
  -     ap_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag)
  +static char *ap_cvt(double arg, int ndigits, int *decpt, int *sign, int 
eflag)
   {
       register int r2;
       double fi, fj;
  @@ -162,14 +161,12 @@
       return (buf);
   }
   
  -static char *
  -     ap_ecvt(double arg, int ndigits, int *decpt, int *sign)
  +static char *ap_ecvt(double arg, int ndigits, int *decpt, int *sign)
   {
       return (ap_cvt(arg, ndigits, decpt, sign, 1));
   }
   
  -static char *
  -     ap_fcvt(double arg, int ndigits, int *decpt, int *sign)
  +static char *ap_fcvt(double arg, int ndigits, int *decpt, int *sign)
   {
       return (ap_cvt(arg, ndigits, decpt, sign, 0));
   }
  @@ -179,8 +176,7 @@
    * minimal length string
    */
   
  -static char *
  -     ap_gcvt(double number, int ndigit, char *buf)
  +static char *ap_gcvt(double number, int ndigit, char *buf)
   {
       int sign, decpt;
       register char *p1, *p2;
  @@ -250,9 +246,9 @@
   #define INT_NULL             ((int *)0)
   #define WIDE_INT             long
   
  -typedef WIDE_INT             wide_int;
  -typedef unsigned WIDE_INT    u_wide_int;
  -typedef int                  bool_int;
  +typedef WIDE_INT wide_int;
  +typedef unsigned WIDE_INT u_wide_int;
  +typedef int bool_int;
   
   #define S_NULL                       "(null)"
   #define S_NULL_LEN           6
  @@ -352,9 +348,9 @@
    * which is a pointer to the END of the buffer + 1 (i.e. if the buffer
    * is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
    */
  -static char *
  -     conv_10(register wide_int num, register bool_int is_unsigned,
  -       register bool_int * is_negative, char *buf_end, register int *len)
  +static char *conv_10(register wide_int num, register bool_int is_unsigned,
  +                  register bool_int *is_negative, char *buf_end,
  +                  register int *len)
   {
       register char *p = buf_end;
       register u_wide_int magnitude;
  @@ -378,7 +374,7 @@
        if (*is_negative) {
            wide_int t = num + 1;
   
  -         magnitude = ((u_wide_int) - t) + 1;
  +         magnitude = ((u_wide_int) -t) + 1;
        }
        else
            magnitude = (u_wide_int) num;
  @@ -390,7 +386,7 @@
       do {
        register u_wide_int new_magnitude = magnitude / 10;
   
  -     *--p = (char)(magnitude - new_magnitude * 10 + '0');
  +     *--p = (char) (magnitude - new_magnitude * 10 + '0');
        magnitude = new_magnitude;
       }
       while (magnitude);
  @@ -409,7 +405,7 @@
    */
   static char *
        conv_fp(register char format, register double num,
  -boolean_e add_dp, int precision, bool_int * is_negative, char *buf, int *len)
  +boolean_e add_dp, int precision, bool_int *is_negative, char *buf, int *len)
   {
       register char *s = buf;
       register char *p;
  @@ -500,9 +496,8 @@
    * which is a pointer to the END of the buffer + 1 (i.e. if the buffer
    * is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
    */
  -static char *
  -     conv_p2(register u_wide_int num, register int nbits,
  -          char format, char *buf_end, register int *len)
  +static char *conv_p2(register u_wide_int num, register int nbits,
  +                  char format, char *buf_end, register int *len)
   {
       register int mask = (1 << nbits) - 1;
       register char *p = buf_end;
  @@ -524,8 +519,8 @@
   /*
    * Do format conversion placing the output in buffer
    */
  -static int format_converter(register buffy * odp, const char *fmt,
  -                           va_list ap)
  +static int format_converter(register buffy *odp, const char *fmt,
  +                         va_list ap)
   {
       register char *sp;
       register char *bep;
  @@ -828,8 +823,8 @@
                ui_num = (u_wide_int) va_arg(ap, char *);
   
                if (sizeof(char *) <= sizeof(u_wide_int))
  -                      s = conv_p2(ui_num, 4, 'x',
  -                                  &num_buf[NUM_BUF_SIZE], &s_len);
  +                            s = conv_p2(ui_num, 4, 'x',
  +                                        &num_buf[NUM_BUF_SIZE], &s_len);
                else {
                    s = "%p";
                    s_len = 2;
  @@ -947,4 +942,4 @@
       return (cc);
   }
   
  -#endif       /* HAVE_SNPRINTF */
  +#endif /* HAVE_SNPRINTF */
  
  
  

Reply via email to