httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Neulinger <nn...@umr.edu>
Subject Re: heres a patch for mod_alias.c - does the per dir redirect correctly
Date Thu, 04 Jul 1996 18:53:21 GMT
>Looks good. Just about what I was going to do; just a couple notes:
>
>1) I wouldn't allocate 20 table entries in create_alias_dir_config().
>   Most people aren't going to use it, and it'll just take up memory.
>   Just allocate 1 or 2. (remember, the Apache code will add more if
>   it needs it)
Yeah, makes sense, I just copied the other one... done.

>2) You only need to check each type of redirect once; only check the
done.

>Otherwise, looks good. I'd make the changes myself, but I don't trust
>me anymore. So if you wouldn't mind... :)
Changes made and attached...

Updated mod_alias.c in incoming as mod_alias.c.1

I'm not really part of the group, so someone else will have to do any
actual code changes...


---------------------
*** mod_alias.c.sv      Thu Jul  4 11:06:53 1996
--- mod_alias.c Thu Jul  4 13:47:52 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, 2, 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,204 ****
  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;

--- 231,237 ----
  int translate_alias_redir(request_rec *r)
  {
      void *sconf = r->server->module_config;
!     alias_server_conf *serverconf =
          (alias_server_conf *)get_module_config(sconf, &alias_module);
      char *ret;

***************
*** 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;
      }
--- 243,254 ----
  #endif
          return BAD_REQUEST;

!     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;
      }
***************
*** 225,239 ****

  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;
      }

--- 258,272 ----

  int fixup_redir(request_rec *r)
  {
!     void *dconf = r->per_dir_config;
!     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;
      }

***************
*** 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 */
--- 276,283 ----
  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