From: jsing Date: Mon, 15 Aug 2016 16:12:34 +0000 (+0000) Subject: Move server_match() from parse.y to server.c; use env instead of conf, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ceaea836206778292e338db7c3f47b4c385f2381;p=openbsd Move server_match() from parse.y to server.c; use env instead of conf, which is actually the same thing (cluebat from reyk@). --- diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index cbe5dcb8bd2..595cce9caee 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.105 2016/08/15 13:48:24 jsing Exp $ */ +/* $OpenBSD: httpd.h,v 1.106 2016/08/15 16:12:34 jsing Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -561,6 +561,8 @@ struct server_config * serverconfig_byid(uint32_t); int server_foreach(int (*)(struct server *, struct server_config *, void *), void *); +struct server * + server_match(struct server *, int); SPLAY_PROTOTYPE(client_tree, client, clt_nodes, server_client_cmp); diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y index f7433f3fa41..6900bc68161 100644 --- a/usr.sbin/httpd/parse.y +++ b/usr.sbin/httpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.79 2016/08/15 13:48:24 jsing Exp $ */ +/* $OpenBSD: parse.y,v 1.80 2016/08/15 16:12:34 jsing Exp $ */ /* * Copyright (c) 2007 - 2015 Reyk Floeter @@ -107,7 +107,6 @@ int host_if(const char *, struct addresslist *, int host(const char *, struct addresslist *, int, struct portrange *, const char *, int); void host_free(struct addresslist *); -struct server *server_match(struct server *, int); struct server *server_inherit(struct server *, struct server_config *, struct server_config *); int getservice(char *); @@ -1991,33 +1990,6 @@ host_free(struct addresslist *al) } } -struct server * -server_match(struct server *s2, int match_name) -{ - struct server *s1; - - /* Attempt to find matching server. */ - TAILQ_FOREACH(s1, conf->sc_servers, srv_entry) { - if ((s1->srv_conf.flags & SRVFLAG_LOCATION) != 0) - continue; - if (match_name) { - if (strcmp(s1->srv_conf.name, s2->srv_conf.name) != 0) - continue; - } - if (s1->srv_conf.port != s2->srv_conf.port) - continue; - if (sockaddr_cmp( - (struct sockaddr *)&s1->srv_conf.ss, - (struct sockaddr *)&s2->srv_conf.ss, - s1->srv_conf.prefixlen) != 0) - continue; - - return (s1); - } - - return (NULL); -} - struct server * server_inherit(struct server *src, struct server_config *alias, struct server_config *addr) diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index d584deca484..849b92a6bba 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.87 2016/08/15 14:14:55 jsing Exp $ */ +/* $OpenBSD: server.c,v 1.88 2016/08/15 16:12:34 jsing Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -418,6 +418,33 @@ server_foreach(int (*srv_cb)(struct server *, return (0); } +struct server * +server_match(struct server *s2, int match_name) +{ + struct server *s1; + + /* Attempt to find matching server. */ + TAILQ_FOREACH(s1, env->sc_servers, srv_entry) { + if ((s1->srv_conf.flags & SRVFLAG_LOCATION) != 0) + continue; + if (match_name) { + if (strcmp(s1->srv_conf.name, s2->srv_conf.name) != 0) + continue; + } + if (s1->srv_conf.port != s2->srv_conf.port) + continue; + if (sockaddr_cmp( + (struct sockaddr *)&s1->srv_conf.ss, + (struct sockaddr *)&s2->srv_conf.ss, + s1->srv_conf.prefixlen) != 0) + continue; + + return (s1); + } + + return (NULL); +} + int server_socket_af(struct sockaddr_storage *ss, in_port_t port) {