httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Neulinger <nn...@umr.edu>
Subject heres a patch for mod_alias.c - does the per dir redirect correctly
Date Thu, 04 Jul 1996 16:46:05 GMT

Seems to work ok for me... Someone else might want to take a look over it
though...

Please let me know if the diff is the correct format...

I also uploaded the fixed mod_alias.c to incoming on ftp.apache.org as
mod_alias.c

-- Nathan

-------------------------------------

*** mod_alias.c.sv      Thu Jul  4 11:06:53 1996
--- mod_alias.c Thu Jul  4 11:45:27 1996
***************
*** 74,79 ****
--- 74,83 ----
      array_header *redirects;
  } alias_server_conf;

+ typedef struct {
+     array_header *redirects;
+ } alias_dir_conf;
+
  module alias_module;

  void *create_alias_config (pool *p, server_rec *s)
***************
*** 86,91 ****
--- 90,104 ----
      return a;
  }

+ void *create_alias_dir_config (pool *p, char *d)
+ {
+     alias_dir_conf *a =
+       (alias_dir_conf *)pcalloc (p, sizeof(alias_dir_conf));
+
+     a->redirects = make_array (p, 20, sizeof(alias_entry));
+     return a;
+ }
+
  void *merge_alias_config (pool *p, void *basev, void *overridesv)
  {
      alias_server_conf *a =
***************
*** 98,103 ****
--- 111,127 ----
      return a;
  }

+ void *merge_alias_dir_config (pool *p, void *basev, void *overridesv)
+ {
+     alias_dir_conf *a =
+       (alias_dir_conf *)pcalloc (p, sizeof(alias_dir_conf));
+     alias_dir_conf *base = (alias_dir_conf *)basev,
+       *overrides = (alias_dir_conf *)overridesv;
+
+     a->redirects = append_arrays (p, overrides->redirects, base->redirects);
+     return a;
+ }
+
  char *add_alias(cmd_parms *cmd, void *dummy, char *f, char *r)
  {
      server_rec *s = cmd->server;
***************
*** 111,125 ****
      return NULL;
  }

! char *add_redirect(cmd_parms *cmd, void *dummy, char *f, char *url)
  {
      server_rec *s = cmd->server;
!     alias_server_conf *conf =
          (alias_server_conf
*)get_module_config(s->module_config,&alias_module);
-     alias_entry *new = push_array (conf->redirects);

      if (!is_url (url)) return "Redirect to non-URL";
!
      new->fake = f; new->real = url;
      return NULL;
  }
--- 135,158 ----
      return NULL;
  }

! char *add_redirect(cmd_parms *cmd, alias_dir_conf *dirconf, char *f, char
*url)
  {
+     alias_entry *new;
      server_rec *s = cmd->server;
!     alias_server_conf *serverconf =
          (alias_server_conf
*)get_module_config(s->module_config,&alias_module);

      if (!is_url (url)) return "Redirect to non-URL";
!
!     if ( cmd->path )
!     {
!         new = push_array (dirconf->redirects);
!     }
!     else
!     {
!         new = push_array (serverconf->redirects);
!     }
!
      new->fake = f; new->real = url;
      return NULL;
  }
***************
*** 198,205 ****
  int translate_alias_redir(request_rec *r)
  {
      void *sconf = r->server->module_config;
!     alias_server_conf *conf =
          (alias_server_conf *)get_module_config(sconf, &alias_module);
      char *ret;

  #ifdef __EMX__
--- 231,241 ----
  int translate_alias_redir(request_rec *r)
  {
      void *sconf = r->server->module_config;
!     void *dconf = r->per_dir_config;
!     alias_server_conf *serverconf =
          (alias_server_conf *)get_module_config(sconf, &alias_module);
+     alias_dir_conf *dirconf =
+         (alias_dir_conf *)get_module_config(dconf, &alias_module);
      char *ret;

  #ifdef __EMX__
***************
*** 210,221 ****
  #endif
          return BAD_REQUEST;

!     if ((ret = try_alias_list (r, conf->redirects, 1)) != NULL) {
!         table_set (r->headers_out, "Location", ret);
          return REDIRECT;
      }

!     if ((ret = try_alias_list (r, conf->aliases, 0)) != NULL) {
          r->filename = ret;
          return OK;
      }
--- 246,262 ----
  #endif
          return BAD_REQUEST;

!     if ((ret = try_alias_list (r, dirconf->redirects, 1)) != NULL) {
!         table_set (r->headers_out, "Location", ret);
          return REDIRECT;
      }
+
+     if ((ret = try_alias_list (r, serverconf->redirects, 1)) != NULL) {
+         table_set (r->headers_out, "Location", ret);
+         return REDIRECT;
+     }

!     if ((ret = try_alias_list (r, serverconf->aliases, 0)) != NULL) {
          r->filename = ret;
          return OK;
      }
***************
*** 226,238 ****
  int fixup_redir(request_rec *r)
  {
      void *sconf = r->server->module_config;
!     alias_server_conf *conf =
          (alias_server_conf *)get_module_config(sconf, &alias_module);
      char *ret;

      /* It may have changed since last time, so try again */

!     if ((ret = try_alias_list (r, conf->redirects, 1)) != NULL) {
          table_set (r->headers_out, "Location", ret);
          return REDIRECT;
      }
--- 267,287 ----
  int fixup_redir(request_rec *r)
  {
      void *sconf = r->server->module_config;
!     void *dconf = r->per_dir_config;
!     alias_server_conf *serverconf =
          (alias_server_conf *)get_module_config(sconf, &alias_module);
+     alias_dir_conf *dirconf =
+         (alias_dir_conf *)get_module_config(dconf, &alias_module);
      char *ret;

      /* It may have changed since last time, so try again */

!     if ((ret = try_alias_list (r, dirconf->redirects, 1)) != NULL) {
!         table_set (r->headers_out, "Location", ret);
!         return REDIRECT;
!     }
!
!     if ((ret = try_alias_list (r, serverconf->redirects, 1)) != NULL) {
          table_set (r->headers_out, "Location", ret);
          return REDIRECT;
      }
***************
*** 243,250 ****
  module alias_module = {
     STANDARD_MODULE_STUFF,
     NULL,                      /* initializer */
!    NULL,                      /* dir config creater */
!    NULL,                      /* dir merger --- default is to override */
     create_alias_config,               /* server config */
     merge_alias_config,                /* merge server configs */
     alias_cmds,                        /* command table */
--- 292,299 ----
  module alias_module = {
     STANDARD_MODULE_STUFF,
     NULL,                      /* initializer */
!    create_alias_dir_config,   /* dir config creater */
!    merge_alias_dir_config,    /* dir merger --- default is to override */
     create_alias_config,               /* server config */
     merge_alias_config,                /* merge server configs */
     alias_cmds,                        /* command table */

------------------------------------------------------------
Nathan Neulinger                  Univ. of Missouri - Rolla
EMail: nneul@umr.edu                  Computing Services
WWW: http://www.umr.edu/~nneul      SysAdmin: rollanet.org



Mime
View raw message