Move server_match() from parse.y to server.c; use env instead of conf,
authorjsing <jsing@openbsd.org>
Mon, 15 Aug 2016 16:12:34 +0000 (16:12 +0000)
committerjsing <jsing@openbsd.org>
Mon, 15 Aug 2016 16:12:34 +0000 (16:12 +0000)
which is actually the same thing (cluebat from reyk@).

usr.sbin/httpd/httpd.h
usr.sbin/httpd/parse.y
usr.sbin/httpd/server.c

index cbe5dcb..595cce9 100644 (file)
@@ -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 <reyk@openbsd.org>
@@ -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);
 
index f7433f3..6900bc6 100644 (file)
@@ -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 <reyk@openbsd.org>
@@ -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)
index d584dec..849b92a 100644 (file)
@@ -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 <reyk@openbsd.org>
@@ -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)
 {