brian       96/12/11 16:36:12

  Modified:    src       mod_rewrite.c mod_rewrite.h
  Log:
  Submitted by: [EMAIL PROTECTED]
  
  bring mod_rewrite up to 2.3.9:
  
    Patchlevel 8 (961211):
  
        o Incorporated the "const" changes of the Apache Group to 2.3.5
          into this release. But in a way to be backward compatible to Apache
          1.1.1.
  
        o Made gmtoff usage again workable in both 1.1.1 and 1.2
          because the function was changed in Apache 1.2.
  
        o Incorporated a patch to make mod_rewrite useable under Apache SSL,
          i.e. with https:// URLs..
          [Thanks to Michael Smith <[EMAIL PROTECTED]>]
  
        o Added a check whether the proxy module is
          compiled in or not. If not then [P] is forbidden.  This is not 100%
          safe, because it can still be turned off (ProxyRequests off) and then
          [P] can lead to a core dump. But there is no trivial way to check if
          the ProxyRequest is turned on or off. But the current variant of the
          check is useful for people who use [P] but have no proxy module
          even compiled in.
  
        o Added some warning to the documentation that ProxyRequests must be
          "on" when the [P] flag gets used.
          [Thanks to Philip Peake <[EMAIL PROTECTED]> for hint]
  
        o Fixed the installation description in the docs.
  
        o Fixed a recently removed "#" char in mod_rewrite.h
  
    Patchlevel 9:
  
  The recently introduced proxy check code was syntactically correct but not
  semantically. Hmmm.. lead to a core dump under 1.2b2. Thanks to Mark J. Cox
  <[EMAIL PROTECTED]> for the hint.
  
  Revision  Changes    Path
  1.10      +163 -27   apache/src/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_rewrite.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -C3 -r1.9 -r1.10
  *** mod_rewrite.c     1996/12/09 22:39:19     1.9
  --- mod_rewrite.c     1996/12/12 00:36:09     1.10
  ***************
  *** 61,67 ****
    **  |_| |_| |_|\___/ \__,_|___|_|  \___| \_/\_/ |_|  |_|\__\___|
    **                       |_____|
    **
  ! **  URL Rewriting Module, Version 2.3.5 (09-10-1996)
    **
    **  This module uses a rule-based rewriting engine (based on a
    **  regular-expression parser) to rewrite requested URLs on the fly. 
  --- 61,67 ----
    **  |_| |_| |_|\___/ \__,_|___|_|  \___| \_/\_/ |_|  |_|\__\___|
    **                       |_____|
    **
  ! **  URL Rewriting Module, Version 2.3.9 (11-12-1996)
    **
    **  This module uses a rule-based rewriting engine (based on a
    **  regular-expression parser) to rewrite requested URLs on the fly. 
  ***************
  *** 87,93 ****
    **  Written for The Apache Group by
    **      Ralf S. Engelschall
    **      [EMAIL PROTECTED]
  ! **      http://www.engelschall.com/~rse
    */
    
    
  --- 87,93 ----
    **  Written for The Apache Group by
    **      Ralf S. Engelschall
    **      [EMAIL PROTECTED]
  ! **      http://www.engelschall.com/
    */
    
    
  ***************
  *** 97,102 ****
  --- 97,103 ----
    #include <string.h>
    #include <stdarg.h>
    #include <time.h>
  + #include <signal.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <netinet/in.h>
  ***************
  *** 111,119 ****
        /* now our own stuff ... */
    #include "mod_rewrite.h"
    
  - 
     
    
    /*
    ** +-------------------------------------------------------+
    ** |                                                       |
  --- 112,120 ----
        /* now our own stuff ... */
    #include "mod_rewrite.h"
    
     
    
  + 
    /*
    ** +-------------------------------------------------------+
    ** |                                                       |
  ***************
  *** 216,224 ****
       NULL                         /* [#8] log a transaction */
    };
    
  !     /* the common cache */
    cache *cachep;
    
        /* the txt mapfile parsing stuff */
    #define MAPFILE_PATTERN "^([^ ]+) +([^ ]+).*$"
    #ifdef HAS_APACHE_REGEX_LIB
  --- 217,228 ----
       NULL                         /* [#8] log a transaction */
    };
    
  !     /* the cache */
    cache *cachep;
    
  +     /* whether proxy module is available or not */
  + static int proxy_available;
  + 
        /* the txt mapfile parsing stuff */
    #define MAPFILE_PATTERN "^([^ ]+) +([^ ]+).*$"
    #ifdef HAS_APACHE_REGEX_LIB
  ***************
  *** 349,355 ****
    **
    */
    
  ! static const char *cmd_rewriteengine(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, int flag)
    {
        rewrite_server_conf *sconf;
    
  --- 353,359 ----
    **
    */
    
  ! static _const char *cmd_rewriteengine(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, int flag)
    {
        rewrite_server_conf *sconf;
    
  ***************
  *** 362,371 ****
        return NULL;
    }
    
  ! static const char *cmd_rewriteoptions(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *option)
    {
        rewrite_server_conf *sconf;
  !     char *err;
    
        sconf = (rewrite_server_conf 
*)get_module_config(cmd->server->module_config, &rewrite_module);
        if (cmd->path == NULL) /* is server command */
  --- 366,375 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewriteoptions(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *option)
    {
        rewrite_server_conf *sconf;
  !     _const char *err;
    
        sconf = (rewrite_server_conf 
*)get_module_config(cmd->server->module_config, &rewrite_module);
        if (cmd->path == NULL) /* is server command */
  ***************
  *** 376,382 ****
        return err;
    }
    
  ! static char *cmd_rewriteoptions_setoption(pool *p, int *options, char *name)
    {
        if (strcasecmp(name, "inherit") == 0)
            *options |= OPTION_INHERIT;
  --- 380,386 ----
        return err;
    }
    
  ! static _const char *cmd_rewriteoptions_setoption(pool *p, int *options, 
char *name)
    {
        if (strcasecmp(name, "inherit") == 0)
            *options |= OPTION_INHERIT;
  ***************
  *** 385,391 ****
        return NULL;
    }
    
  ! static const char *cmd_rewritelog(cmd_parms *cmd, void *dconf, char *a1)
    {
        rewrite_server_conf *sconf;
    
  --- 389,395 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewritelog(cmd_parms *cmd, void *dconf, char *a1)
    {
        rewrite_server_conf *sconf;
    
  ***************
  *** 395,401 ****
        return NULL;
    }
    
  ! static const char *cmd_rewriteloglevel(cmd_parms *cmd, void *dconf, char 
*a1)
    {
        rewrite_server_conf *sconf;
    
  --- 399,405 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewriteloglevel(cmd_parms *cmd, void *dconf, char 
*a1)
    {
        rewrite_server_conf *sconf;
    
  ***************
  *** 405,411 ****
        return NULL;
    }
    
  ! static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, char *a1, 
char *a2)
    {
        rewrite_server_conf *sconf;
        rewritemap_entry *new;
  --- 409,415 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, char *a1, 
char *a2)
    {
        rewrite_server_conf *sconf;
        rewritemap_entry *new;
  ***************
  *** 449,455 ****
        return NULL;
    }
    
  ! static const char *cmd_rewritebase(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *a1)
    {
        if (cmd->path == NULL || dconf == NULL)
            return "RewriteBase: only valid in per-directory config files";
  --- 453,459 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewritebase(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *a1)
    {
        if (cmd->path == NULL || dconf == NULL)
            return "RewriteBase: only valid in per-directory config files";
  ***************
  *** 463,469 ****
        return NULL;
    }
    
  ! static const char *cmd_rewritecond(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *str)
    {
        rewrite_server_conf *sconf;
        rewritecond_entry *new;
  --- 467,473 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewritecond(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *str)
    {
        rewrite_server_conf *sconf;
        rewritecond_entry *new;
  ***************
  *** 477,483 ****
        char *a2;
        char *a3;
        char *cp;
  !     char *err;
        int rc;
    
        sconf = (rewrite_server_conf 
*)get_module_config(cmd->server->module_config, &rewrite_module);
  --- 481,487 ----
        char *a2;
        char *a3;
        char *cp;
  !     _const char *err;
        int rc;
    
        sconf = (rewrite_server_conf 
*)get_module_config(cmd->server->module_config, &rewrite_module);
  ***************
  *** 535,541 ****
        return NULL;
    }
    
  ! static char *cmd_rewritecond_parseflagfield(pool *p, rewritecond_entry 
*cfg, char *str)
    {
        char *cp;
        char *cp1;
  --- 539,545 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewritecond_parseflagfield(pool *p, 
rewritecond_entry *cfg, char *str)
    {
        char *cp;
        char *cp1;
  ***************
  *** 543,549 ****
        char *cp3;
        char *key;
        char *val;
  !     char *err;
    
        if (str[0] != '[' || str[strlen(str)-1] != ']')
            return pstrdup(p, "RewriteCond: bad flag delimiters");
  --- 547,553 ----
        char *cp3;
        char *key;
        char *val;
  !     _const char *err;
    
        if (str[0] != '[' || str[strlen(str)-1] != ']')
            return pstrdup(p, "RewriteCond: bad flag delimiters");
  ***************
  *** 581,587 ****
        return NULL;
    }
    
  ! static char *cmd_rewritecond_setflag(pool *p, rewritecond_entry *cfg, char 
*key, char *val)
    {
        if (   strcasecmp(key, "nocase") == 0
            || strcasecmp(key, "NC") == 0    ) {
  --- 585,591 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewritecond_setflag(pool *p, rewritecond_entry 
*cfg, char *key, char *val)
    {
        if (   strcasecmp(key, "nocase") == 0
            || strcasecmp(key, "NC") == 0    ) {
  ***************
  *** 597,603 ****
        return NULL;
    }
    
  ! const char *cmd_rewriterule(cmd_parms *cmd, rewrite_perdir_conf *dconf, 
char *str)
    {
        rewrite_server_conf *sconf;
        rewriterule_entry *new;
  --- 601,608 ----
        return NULL;
    }
    
  ! /* NON static */
  ! _const char *cmd_rewriterule(cmd_parms *cmd, rewrite_perdir_conf *dconf, 
char *str)
    {
        rewrite_server_conf *sconf;
        rewriterule_entry *new;
  ***************
  *** 611,617 ****
        char *a2;
        char *a3;
        char *cp;
  !     char *err;
    
        sconf = (rewrite_server_conf 
*)get_module_config(cmd->server->module_config, &rewrite_module);
    
  --- 616,622 ----
        char *a2;
        char *a3;
        char *cp;
  !     _const char *err;
    
        sconf = (rewrite_server_conf 
*)get_module_config(cmd->server->module_config, &rewrite_module);
    
  ***************
  *** 676,682 ****
        return NULL;
    }
    
  ! static char *cmd_rewriterule_parseflagfield(pool *p, rewriterule_entry 
*cfg, char *str)
    {
        char *cp;
        char *cp1;
  --- 681,687 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewriterule_parseflagfield(pool *p, 
rewriterule_entry *cfg, char *str)
    {
        char *cp;
        char *cp1;
  ***************
  *** 684,690 ****
        char *cp3;
        char *key;
        char *val;
  !     char *err;
    
        if (str[0] != '[' || str[strlen(str)-1] != ']')
            return pstrdup(p, "RewriteRule: bad flag delimiters");
  --- 689,695 ----
        char *cp3;
        char *key;
        char *val;
  !     _const char *err;
    
        if (str[0] != '[' || str[strlen(str)-1] != ']')
            return pstrdup(p, "RewriteRule: bad flag delimiters");
  ***************
  *** 722,728 ****
        return NULL;
    }
    
  ! static char *cmd_rewriterule_setflag(pool *p, rewriterule_entry *cfg, char 
*key, char *val)
    {
        if (   strcasecmp(key, "redirect") == 0
            || strcasecmp(key, "R") == 0       ) {
  --- 727,733 ----
        return NULL;
    }
    
  ! static _const char *cmd_rewriterule_setflag(pool *p, rewriterule_entry 
*cfg, char *key, char *val)
    {
        if (   strcasecmp(key, "redirect") == 0
            || strcasecmp(key, "R") == 0       ) {
  ***************
  *** 792,797 ****
  --- 797,804 ----
        /* create the lookup cache */
        cachep = init_cache(p);
    
  +     /* check if proxy module is available */
  +     proxy_available = is_proxy_available(s);
    
        /* precompile a static pattern 
           for the txt mapfile parsing */
  ***************
  *** 873,879 ****
    
        /* add the canonical URI of this URL */
        thisserver = r->server->server_hostname;
  !     if (r->server->port == 80) 
            thisport = "";
        else {
            sprintf(buf, ":%d", r->server->port);
  --- 880,891 ----
    
        /* add the canonical URI of this URL */
        thisserver = r->server->server_hostname;
  ! #ifdef APACHE_SSL
  !     if (((!r->connection->client->ssl) && (r->server->port == 80)) ||
  !          ((r->connection->client->ssl) && (r->server->port == 443)))
  ! #else
  !     if (r->server->port == 80)
  ! #endif 
            thisport = "";
        else {
            sprintf(buf, ":%d", r->server->port);
  ***************
  *** 882,888 ****
  --- 894,904 ----
        thisurl = table_get(r->subprocess_env, ENVVAR_SCRIPT_URL);
    
        /* set the variable */
  + #ifdef APACHE_SSL
  +     var = pstrcat(r->pool, http_method(r), "://", thisserver, thisport, 
thisurl, NULL);
  + #else
        var = pstrcat(r->pool, "http://";, thisserver, thisport, thisurl, NULL);
  + #endif
        table_set(r->subprocess_env, ENVVAR_SCRIPT_URI, pstrdup(r->pool, var));
    
    
  ***************
  *** 902,907 ****
  --- 918,928 ----
                strncmp(r->filename, "proxy:", 6) == 0) {
                /* it should be go on as an internal proxy request */
    
  +             /* check if the proxy module is enabled, so
  +                we can actually use it! */
  +             if (!proxy_available)
  +                 return FORBIDDEN; 
  + 
                /* make sure the QUERY_STRING and
                   PATH_INFO parts get incorporated */
                r->filename = pstrcat(r->pool, r->filename, 
  ***************
  *** 917,927 ****
  --- 938,961 ----
                rewritelog(r, 1, "go-ahead with proxy request %s [OK]", 
r->filename);
                return OK; 
            }
  + #ifdef APACHE_SSL
  +         else if (  (!r->connection->client->ssl &&
  +                     strlen(r->filename) > 7     &&
  +                     strncmp(r->filename, "http://";, 7) == 0)
  +                 || (r->connection->client->ssl  &&
  +                     strlen(r->filename) > 8     &&
  +                     strncmp(r->filename, "https://";, 8) == 0) ) {
  + #else
            else if (strlen(r->filename) > 7 &&
                     strncmp(r->filename, "http://";, 7) == 0) {
  + #endif
                /* it was finally rewritten to a remote path */
    
  + #ifdef APACHE_SSL
  +             for (cp = r->filename+strlen(http_method(r))+3; *cp != '/' && 
*cp != '\0'; cp++)
  + #else
                for (cp = r->filename+7; *cp != '/' && *cp != '\0'; cp++)
  + #endif
                    ;
                if (*cp != '\0') {
                    rewritelog(r, 1, "escaping %s for redirect", r->filename);
  ***************
  *** 1113,1127 ****
  --- 1147,1174 ----
                rewritelog(r, 1, "[per-dir %s] go-ahead with proxy request %s 
[OK]", dconf->directory, r->filename);
                return OK; 
            }
  + #ifdef APACHE_SSL
  +         else if (  (!r->connection->client->ssl &&
  +                     strlen(r->filename) > 7     &&
  +                     strncmp(r->filename, "http://";, 7) == 0)
  +                 || (r->connection->client->ssl  &&
  +                     strlen(r->filename) > 8     &&
  +                     strncmp(r->filename, "https://";, 8) == 0) ) {
  + #else
            else if (strlen(r->filename) > 7 &&
                     strncmp(r->filename, "http://";, 7) == 0) {
  + #endif
                /* it was finally rewritten to a remote path */
    
                /* because we are in a per-dir context
                   first try to replace the directory with its base-URL
                   if there is a base-URL available */
                if (dconf->baseurl != NULL) {
  + #ifdef APACHE_SSL
  +                 if ((cp = strchr(r->filename+strlen(http_method(r))+3, 
'/')) != NULL) {
  + #else
                    if ((cp = strchr(r->filename+7, '/')) != NULL) {
  + #endif
                        rewritelog(r, 2, "[per-dir %s] trying to replace prefix 
%s with %s", dconf->directory, dconf->directory, dconf->baseurl);
                        cp2 = subst_prefix_path(r, cp, dconf->directory, 
dconf->baseurl);
                        if (strcmp(cp2, cp) != 0) {
  ***************
  *** 1132,1138 ****
  --- 1179,1189 ----
                }
    
                /* now prepare the redirect... */
  + #ifdef APACHE_SSL
  +             for (cp = r->filename+strlen(http_method(r))+3; *cp != '/' && 
*cp != '\0'; cp++)
  + #else
                for (cp = r->filename+7; *cp != '/' && *cp != '\0'; cp++)
  + #endif
                    ;
                if (*cp != '\0') {
                    rewritelog(r, 1, "[per-dir %s] escaping %s for redirect", 
dconf->directory, r->filename);
  ***************
  *** 1440,1446 ****
  --- 1491,1504 ----
            }
    
            /* if this is a implicit redirect in a per-dir rule */
  + #ifdef APACHE_SSL
  +         if (perdir != NULL && (  (!r->connection->client->ssl &&
  +                                   strncmp(output, "http://";, 7) == 0)
  +                               || (r->connection->client->ssl &&
  +                                   strncmp(output, "https://";, 8) == 0) )) { 
  + #else
            if (perdir != NULL && strncmp(output, "http://";, 7) == 0) {
  + #endif
                if (p->flags & RULEFLAG_NOTMATCH) {
                    strcpy(newuri, output);
                    expand_variables_inbuffer(r, newuri);                /* 
expand %{...} */
  ***************
  *** 1509,1523 ****
  --- 1567,1601 ----
            /* if we are forced to do a explicit redirect by [R] flag
               finally prefix the new URI with http://<ourname> explicitly */
            if (flags & RULEFLAG_FORCEREDIRECT) {
  + #ifdef APACHE_SSL
  +            if ( (!r->connection->client->ssl &&
  +                  strncmp(r->filename, "http://";, 7) != 0) ||
  +                 (r->connection->client->ssl &&
  +                  strncmp(r->filename, "https://";, 8) != 0)) {
  + #else
                if (strncmp(r->filename, "http://";, 7) != 0) {
  + #endif
  + #ifdef APACHE_SSL
  +                 if ((!r->connection->client->ssl && r->server->port == 80) 
||
  +                     ( r->connection->client->ssl && r->server->port == 443) 
 )
  + #else
                    if (r->server->port == 80)
  + #endif
                        strcpy(port, "");
                    else 
                        sprintf(port, ":%d", r->server->port);
                    if (r->filename[0] == '/')
  + #ifdef APACHE_SSL
  +                     sprintf(newuri, "%s://%s%s%s", http_method(r), 
r->server->server_hostname, port, r->filename);
  + #else
                        sprintf(newuri, "http://%s%s%s";, 
r->server->server_hostname, port, r->filename);
  + #endif
                    else
  + #ifdef APACHE_SSL
  +                     sprintf(newuri, "%s://%s%s/%s", http_method(r), 
r->server->server_hostname, port, r->filename);
  + #else
                        sprintf(newuri, "http://%s%s/%s";, 
r->server->server_hostname, port, r->filename);
  + #endif
                    if (perdir == NULL) 
                        rewritelog(r, 2, "prepare forced redirect %s -> %s", 
r->filename, newuri);
                    else
  ***************
  *** 1648,1660 ****
  --- 1726,1749 ----
        static char buf[MAX_STRING_LEN];
        static char olduri[MAX_STRING_LEN];
    
  + #ifdef APACHE_SSL
  +     if (   (!r->connection->client->ssl &&
  +             strncmp(r->filename, "http://";, 7) == 0)
  +         || (r->connection->client->ssl &&
  +             strncmp(r->filename, "https://";, 8) == 0)) {
  + #else
        if (strncmp(r->filename, "http://";, 7) == 0) {
  + #endif
            /* there was really a rewrite to a remote path */
    
            strcpy(olduri, r->filename); /* save for logging */
    
            /* cut the hostname and port out of the URI */
  + #ifdef APACHE_SSL
  +         strcpy(buf, r->filename+strlen(http_method(r))+3);
  + #else
            strcpy(buf, r->filename+7);
  + #endif
            hostp = buf;
            for (cp = hostp; *cp != '\0' && *cp != '/' && *cp != ':'; cp++)
                ;
  ***************
  *** 2079,2085 ****
        exit(1);
    }
    
  ! static void rewritelog(request_rec *r, int level, char *text, ...)
    {
        rewrite_server_conf *conf;
        conn_rec *connect;
  --- 2168,2174 ----
        exit(1);
    }
    
  ! static void rewritelog(request_rec *r, int level, const char *text, ...)
    {
        rewrite_server_conf *conf;
        conn_rec *connect;
  ***************
  *** 2134,2140 ****
  --- 2223,2233 ----
    
    static char *current_logtime(request_rec *r)
    {
  + #ifdef IS_APACHE_12
        int timz;
  + #else
  +     long timz;
  + #endif
        struct tm *t;
        static char tstr[MAX_STRING_LEN];
        char sign;
  ***************
  *** 2146,2152 ****
  --- 2239,2249 ----
    
        strftime(tstr, MAX_STRING_LEN,"[%d/%b/%Y:%H:%M:%S ",t);
    
  + #ifdef IS_APACHE_12
        sprintf(tstr + strlen(tstr), "%c%.2d%.2d]", sign, timz/60, timz%60);
  + #else
  +     sprintf(tstr + strlen(tstr), "%c%02ld%02ld]", sign, timz/3600, 
timz%3600);
  + #endif
    
        return pstrdup(r->pool, tstr);
    }
  ***************
  *** 2243,2249 ****
        strcpy(input, str);
        output[0] = '\0';
        expanded = 0;
  !     for (cp = input; cp < output+MAX_STRING_LEN; ) {
            if ((cp2 = strstr(cp, "%{")) != NULL) {
                if ((cp3 = strstr(cp2, "}")) != NULL) {
                    *cp2 = '\0';
  --- 2340,2346 ----
        strcpy(input, str);
        output[0] = '\0';
        expanded = 0;
  !     for (cp = input; cp < input+MAX_STRING_LEN; ) {
            if ((cp2 = strstr(cp, "%{")) != NULL) {
                if ((cp3 = strstr(cp2, "}")) != NULL) {
                    *cp2 = '\0';
  ***************
  *** 2407,2413 ****
            return pstrdup(r->pool, result);
    }
     
  ! static char *lookup_header(request_rec *r, char *name)
    {
        array_header *hdrs_arr;
        table_entry *hdrs;
  --- 2504,2510 ----
            return pstrdup(r->pool, result);
    }
     
  ! static char *lookup_header(request_rec *r, const char *name)
    {
        array_header *hdrs_arr;
        table_entry *hdrs;
  ***************
  *** 2711,2717 ****
        char **cppHNLtest;
        char *ourhostname;
        char *ourhostip;
  !     const char *names;
        char *name;
        int i, j;
    
  --- 2808,2814 ----
        char **cppHNLtest;
        char *ourhostname;
        char *ourhostip;
  !     _const char *names;
        char *name;
        int i, j;
    
  ***************
  *** 2825,2830 ****
  --- 2922,2966 ----
        cppHNL[i] = NULL;
        return cppHNL;
    }
  + 
  + 
  + /*
  + **
  + **  check if proxy module is available
  + **  i.e. if it is compiled in and turned on
  + **
  + */
  + 
  + #ifdef IS_APACHE_12
  + int is_proxy_available(server_rec *s)
  + {
  +     extern module *preloaded_modules[];
  +     command_rec *c;
  +     int n;
  +     
  +     for (n = 0; preloaded_modules[n] != NULL; n++) {
  +         for (c = preloaded_modules[n]->cmds; c && c->name; ++c) {
  +             if (strcmp(c->name, "ProxyRequests") == 0) {
  +                 return 1;
  +             }
  +         }
  +     }
  +     return 0;
  + }
  + #else
  + int is_proxy_available(server_rec *s)
  + {
  +     extern char *module_names[];
  +     int n;
  +     
  +     for (n = 0; module_names[n] != NULL; n++) {
  +         if (strcmp(module_names[n], "proxy_module") == 0) {
  +             return 1;
  +         }
  +     }
  +     return 0;
  + }
  + #endif
    
    
    /*EOF*/
  
  
  
  1.12      +36 -26    apache/src/mod_rewrite.h
  
  Index: mod_rewrite.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_rewrite.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -C3 -r1.11 -r1.12
  *** mod_rewrite.h     1996/12/09 22:39:20     1.11
  --- mod_rewrite.h     1996/12/12 00:36:11     1.12
  ***************
  *** 64,70 ****
    **  |_| |_| |_|\___/ \__,_|___|_|  \___| \_/\_/ |_|  |_|\__\___|
    **                       |_____|
    **
  ! **  URL Rewriting Module, Version 2.3.5 (09-10-1996)
    **
    **  This module uses a rule-based rewriting engine (based on a
    **  regular-expression parser) to rewrite requested URLs on the fly. 
  --- 64,70 ----
    **  |_| |_| |_|\___/ \__,_|___|_|  \___| \_/\_/ |_|  |_|\__\___|
    **                       |_____|
    **
  ! **  URL Rewriting Module, Version 2.3.9 (11-12-1996)
    **
    **  This module uses a rule-based rewriting engine (based on a
    **  regular-expression parser) to rewrite requested URLs on the fly. 
  ***************
  *** 90,96 ****
    **  Written for The Apache Group by
    **      Ralf S. Engelschall
    **      [EMAIL PROTECTED]
  ! **      http://www.engelschall.com/~rse
    */
    
    
  --- 90,96 ----
    **  Written for The Apache Group by
    **      Ralf S. Engelschall
    **      [EMAIL PROTECTED]
  ! **      http://www.engelschall.com/
    */
    
    
  ***************
  *** 103,108 ****
  --- 103,119 ----
    #endif
    
    
  +     /* The const problem:
  +        The Apache Group changed some essential prototypes
  +        to have an additional "const" qualifier. To be backward
  +        compatible with Apache 1.1.1 we use a special define */
  + #ifdef IS_APACHE_12
  + #define _const const
  + #else
  + #define _const  
  + #endif
  + 
  + 
        /* The RegExp support:
           For Apache 1.1.1 we provide our own Spencer V8 library,
           for Apache 1.2 and higher there is a Spencer POSIX library
  ***************
  *** 278,287 ****
    **
    */
    
  -     /* static config */
  - extern module rewrite_module;
  - extern cache *cachep;
  - 
        /* config structure handling */
    static void *config_server_create(pool *p, server_rec *s);
    static void *config_server_merge (pool *p, void *basev, void *overridesv);
  --- 289,294 ----
  ***************
  *** 289,310 ****
    static void *config_perdir_merge (pool *p, void *basev, void *overridesv);
    
        /* config directive handling */
  ! static const char *cmd_rewriteengine  (cmd_parms *cmd, rewrite_perdir_conf 
*dconf, int flag);
  ! static const char *cmd_rewriteoptions (cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *option);
  ! static char *cmd_rewriteoptions_setoption(pool *p, int *options, char 
*name);
  ! static const char *cmd_rewritelog     (cmd_parms *cmd, void *dconf, char 
*a1);
  ! static const char *cmd_rewriteloglevel(cmd_parms *cmd, void *dconf, char 
*a1);
  ! static const char *cmd_rewritemap     (cmd_parms *cmd, void *dconf, char 
*a1, char *a2);
  ! 
  ! static const char *cmd_rewritebase(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *a1);
  ! 
  ! static const char *cmd_rewritecond    (cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *str);
  ! static char *cmd_rewritecond_parseflagfield(pool *p, rewritecond_entry 
*new, char *str);
  ! static char *cmd_rewritecond_setflag       (pool *p, rewritecond_entry 
*cfg, char *key, char *val);
  ! 
  ! extern const char *cmd_rewriterule    (cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *str);
  ! static char *cmd_rewriterule_parseflagfield(pool *p, rewriterule_entry 
*new, char *str);
  ! static char *cmd_rewriterule_setflag       (pool *p, rewriterule_entry 
*cfg, char *key, char *val);
    
        /* initialisation */
    static void init_module(server_rec *s, pool *p);
  --- 296,317 ----
    static void *config_perdir_merge (pool *p, void *basev, void *overridesv);
    
        /* config directive handling */
  ! static _const char *cmd_rewriteengine  (cmd_parms *cmd, rewrite_perdir_conf 
*dconf, int flag);
  ! static _const char *cmd_rewriteoptions (cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *option);
  ! static _const char *cmd_rewriteoptions_setoption(pool *p, int *options, 
char *name);
  ! static _const char *cmd_rewritelog     (cmd_parms *cmd, void *dconf, char 
*a1);
  ! static _const char *cmd_rewriteloglevel(cmd_parms *cmd, void *dconf, char 
*a1);
  ! static _const char *cmd_rewritemap     (cmd_parms *cmd, void *dconf, char 
*a1, char *a2);
  ! 
  ! static _const char *cmd_rewritebase(cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *a1);
  ! 
  ! static _const char *cmd_rewritecond    (cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *str);
  ! static _const char *cmd_rewritecond_parseflagfield(pool *p, 
rewritecond_entry *new, char *str);
  ! static _const char *cmd_rewritecond_setflag       (pool *p, 
rewritecond_entry *cfg, char *key, char *val);
  ! 
  ! extern _const char *cmd_rewriterule    (cmd_parms *cmd, rewrite_perdir_conf 
*dconf, char *str);
  ! static _const char *cmd_rewriterule_parseflagfield(pool *p, 
rewriterule_entry *new, char *str);
  ! static _const char *cmd_rewriterule_setflag       (pool *p, 
rewriterule_entry *cfg, char *key, char *val);
    
        /* initialisation */
    static void init_module(server_rec *s, pool *p);
  ***************
  *** 337,343 ****
        /* rewriting logfile support */
    static void  open_rewritelog(server_rec *s, pool *p);
    static void  rewritelog_child(void *cmd);
  ! static void  rewritelog(request_rec *r, int level, char *text, ...);
    static char *current_logtime(request_rec *r);
    
        /* program map support */
  --- 344,350 ----
        /* rewriting logfile support */
    static void  open_rewritelog(server_rec *s, pool *p);
    static void  rewritelog_child(void *cmd);
  ! static void  rewritelog(request_rec *r, int level, const char *text, ...);
    static char *current_logtime(request_rec *r);
    
        /* program map support */
  ***************
  *** 348,359 ****
    static void  expand_variables_inbuffer(request_rec *r, char *buf);
    static char *expand_variables(request_rec *r, char *str);
    static char *lookup_variable(request_rec *r, char *var);
  ! static char *lookup_header(request_rec *r, char *name);
    
        /* caching functions */
    static cache      *init_cache(pool *p);
  ! static char       *get_cache_string(cache *c, char *res, int mode, time_t 
time, char *key);
  ! static void        set_cache_string(cache *c, char *res, int mode, time_t 
time, char *key, char *value);
    static cacheentry *retrieve_cache_string(cache *c, char *res, char *key);
    static void        store_cache_string(cache *c, char *res, cacheentry *ce);
    
  --- 355,366 ----
    static void  expand_variables_inbuffer(request_rec *r, char *buf);
    static char *expand_variables(request_rec *r, char *str);
    static char *lookup_variable(request_rec *r, char *var);
  ! static char *lookup_header(request_rec *r, const char *name);
    
        /* caching functions */
    static cache      *init_cache(pool *p);
  ! static char       *get_cache_string(cache *c, char *res, int mode, time_t 
mtime, char *key);
  ! static void        set_cache_string(cache *c, char *res, int mode, time_t 
mtime, char *key, char *value);
    static cacheentry *retrieve_cache_string(cache *c, char *res, char *key);
    static void        store_cache_string(cache *c, char *res, cacheentry *ce);
    
  ***************
  *** 366,371 ****
  --- 373,381 ----
    static int    is_this_our_host(request_rec *r, char *testhost);
    static int    isaddr(char *host);
    static char **resolv_ipaddr_list(request_rec *r, char *name);
  + 
  +     /* Proxy Module check */
  + static int is_proxy_available(server_rec *s);
    
    #endif /* _MOD_REWRITE_H */
    
  
  
  

Reply via email to