httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chia-liang Kao <cl...@cirx.org>
Subject [PATCH] Pre-constructed server alias list
Date Thu, 12 Feb 1998 00:41:48 GMT
	Here's a patch for making ServerAlias pre-constructs when
	reading config files. Also avoid some is_matchexp called,
	by seperating server alias entry with and without wildcards.

	Also for PR#1531, this enables multiple ServerAlias.

	Btw, as I use indent to make the sources I modified for 
	the `Apache Style', lots of the source code in core, vhost
	are re-indented. Someone should indent all source files
	for the styling.

Index: include/httpd.h
===================================================================
RCS file: /cvs/apache-1.3/src/include/httpd.h,v
retrieving revision 1.184
diff -u -r1.184 httpd.h
--- httpd.h	1998/02/09 13:25:42	1.184
+++ httpd.h	1998/02/12 00:13:24
@@ -754,7 +754,8 @@
     char *path;			/* Pathname for ServerPath */
     int pathlen;		/* Length of path */
 
-    char *names;		/* Wildcarded names for ServerAlias servers */
+    array_header *names;	/* Normal names for ServerAlias servers */
+    array_header *wild_names;	/* Wildcarded names for ServerAlias servers */
 
     uid_t server_uid;		/* effective user id when calling exec wrapper */
     gid_t server_gid;		/* effective group id when calling exec wrapper */
Index: main/http_config.c
===================================================================
RCS file: /cvs/apache-1.3/src/main/http_config.c,v
retrieving revision 1.96
diff -u -r1.96 http_config.c
--- http_config.c	1998/02/06 18:19:56	1.96
+++ http_config.c	1998/02/12 00:13:29
@@ -1175,7 +1175,8 @@
     s->next = NULL;
 
     s->is_virtual = 1;
-    s->names = NULL;
+    s->names = make_array(p, 4, sizeof(char **));
+    s->wild_names = make_array(p, 4, sizeof(char **));
 
     s->module_config = create_empty_config(p);
     s->lookup_defaults = create_per_dir_config(p);
@@ -1284,6 +1285,7 @@
     /* NOT virtual host; don't match any real network interface */
     s->addrs->host_addr.s_addr = htonl(INADDR_ANY);
     s->addrs->host_port = 0;	/* matches any port */
+    s->names = s->wild_names = NULL;
 
     s->module_config = create_server_config(p, s);
     s->lookup_defaults = create_default_per_dir_config(p);
Index: main/http_core.c
===================================================================
RCS file: /cvs/apache-1.3/src/main/http_core.c,v
retrieving revision 1.157
diff -u -r1.157 http_core.c
--- http_core.c	1998/02/08 23:15:34	1.157
+++ http_core.c	1998/02/12 00:13:35
@@ -1195,6 +1195,21 @@
     return errmsg;
 }
 
+const char *set_server_alias(cmd_parms *cmd, void *dummy, const char *arg)
+{
+    if (!cmd->server->names)
+	return "ServerAlias only used in <VirtualHost>";
+    while (*arg) {
+	char **item, *name = getword_conf(cmd->pool, &arg);
+	if (is_matchexp(name))
+	    item = (char **) push_array(cmd->server->wild_names);
+	else
+	    item = (char **) push_array(cmd->server->names);
+	*item = name;
+    }
+    return NULL;
+}
+
 const char *add_module_command (cmd_parms *cmd, void *dummy, char *arg)
 {
     const char *err = check_cmd_context(cmd, GLOBAL_ONLY);
@@ -1840,9 +1855,8 @@
 { "ResourceConfig", set_server_string_slot,
   (void *)XtOffsetOf (server_rec, srm_confname), RSRC_CONF, TAKE1,
   "The filename of the resource config file" },
-{ "ServerAlias", set_server_string_slot,
-   (void *)XtOffsetOf (server_rec, names), RSRC_CONF, RAW_ARGS,
-   "A name or names alternately used to access the server" },
+{ "ServerAlias", set_server_alias, NULL, RSRC_CONF, RAW_ARGS,
+  "A name or names alternately used to access the server" },
 { "ServerPath", set_serverpath, NULL, RSRC_CONF, TAKE1,
   "The pathname the server can be reached at" },
 { "Timeout", set_timeout, NULL, RSRC_CONF, TAKE1, "Timeout duration (sec)"},
Index: http_vhost.c
===================================================================
RCS file: /cvs/apache-1.3/src/main/http_vhost.c,v
retrieving revision 1.6
diff -u -r1.6 http_vhost.c
--- http_vhost.c	1998/02/01 21:19:30	1.6
+++ http_vhost.c	1998/02/12 00:29:55
@@ -638,7 +638,8 @@
      */
 
     for (src = r->connection->vhost_lookup_data; src; src = src->next) {
-        const char *names;
+	int i;
+	array_header *names;
         server_addr_rec *sar;
 
 	/* We only consider addresses on the name_chain which have a matching
@@ -670,17 +671,24 @@
         }
 
         /* search all the aliases from ServerAlias directive */
-        names = s->names;
-        if (names) {
-            while (*names) {
-                char *name = getword_conf(r->pool, &names);
-
-                if ((is_matchexp(name) && !strcasecmp_match(host, name)) ||
-                    (!strcasecmp(host, name))) {
+	names = s->names;
+	if (names) {
+	    char **name = (char **) names->elts;
+	    for (i = 0; i < names->nelts; ++i) {
+		if(!name[i]) continue;
+		if (!strcasecmp(host, name[i]))
 		    goto found;
-                }
-            }
-        }
+	    }
+	}
+	names = s->wild_names;
+	if (names) {
+	    char **name = (char **) names->elts;
+	    for (i = 0; i < names->nelts; ++i) {
+		if(!name[i]) continue;
+		if (!strcasecmp_match(host, name[i]))
+		    goto found;
+	    }
+	}
     }
     return;
 
-- 
Chia-liang Kao  /  clkao@cirx.org
Panther Tech Co. , Taichung, Taiwan
http://www.pamud.net/~clkao
`白爛濤濤我不怕' -- IOI 97

Mime
View raw message