Removing duplicated code. load_forwardfile() now uses create_url_spec()
authorjongfoster <jongfoster@users.sourceforge.net>
Sat, 26 May 2001 00:55:20 +0000 (00:55 +0000)
committerjongfoster <jongfoster@users.sourceforge.net>
Sat, 26 May 2001 00:55:20 +0000 (00:55 +0000)
loaders.c

index 3f481d8..bcc76c1 100644 (file)
--- a/loaders.c
+++ b/loaders.c
@@ -1,4 +1,4 @@
-const char loaders_rcs[] = "$Id: loaders.c,v 1.6 2001/05/23 12:27:33 oes Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.7 2001/05/26 00:28:36 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loaders.c,v $
@@ -35,6 +35,13 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.6 2001/05/23 12:27:33 oes Exp $";
  *
  * Revisions   :
  *    $Log: loaders.c,v $
+ *    Revision 1.7  2001/05/26 00:28:36  jongfoster
+ *    Automatic reloading of config file.
+ *    Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
+ *    Most of the global variables have been moved to a new
+ *    struct configuration_spec, accessed through csp->config->globalname
+ *    Most of the globals remaining are used by the Win32 GUI.
+ *
  *    Revision 1.6  2001/05/23 12:27:33  oes
  *
  *    Fixed ugly indentation of my last changes
@@ -1595,10 +1602,9 @@ int load_forwardfile(struct client_state *csp)
    struct forward_spec *b, *bl;
    char  buf[BUFSIZ], *p, *q, *tmp;
    char  *vec[4];
-   int port, n, reject;
+   int n, reject;
    struct file_list *fs;
    const struct gateway *gw;
-   struct url_spec url[1];
 
    if (!check_file_changed(current_forwardfile, csp->config->forwardfile, &fs))
    {
@@ -1665,9 +1671,6 @@ int load_forwardfile(struct client_state *csp)
 
       /* allocate a new node */
       if (((b = zalloc(sizeof(*b))) == NULL)
-#ifdef REGEX
-      || ((b->url->preg = zalloc(sizeof(*b->url->preg))) == NULL)
-#endif
       )
       {
          fclose(fp);
@@ -1678,77 +1681,14 @@ int load_forwardfile(struct client_state *csp)
       b->next  = bl->next;
       bl->next = b;
 
-      /* save a copy of the orignal specification */
-      if ((b->url->spec = strdup(buf)) == NULL)
-      {
-         fclose(fp);
-         goto load_forwardfile_error;
-      }
-
-      b->reject = reject;
-
-      if ((p = strchr(buf, '/')))
-      {
-         b->url->path    = strdup(p);
-         b->url->pathlen = strlen(b->url->path);
-         *p = '\0';
-      }
-      else
-      {
-         b->url->path    = NULL;
-         b->url->pathlen = 0;
-      }
-#ifdef REGEX
-      if (b->url->path)
-      {
-         int errcode;
-         char rebuf[BUFSIZ];
-
-         sprintf(rebuf, "^(%s)", b->url->path);
-
-         errcode = regcomp(b->url->preg, rebuf,
-               (REG_EXTENDED|REG_NOSUB|REG_ICASE));
-
-         if (errcode)
-         {
-            size_t errlen = regerror(errcode, b->url->preg, buf, sizeof(buf));
-
-            buf[errlen] = '\0';
-
-            log_error(LOG_LEVEL_ERROR, "error compiling %s: %s",
-                    b->url->spec, buf);
-            fclose(fp);
-            goto load_forwardfile_error;
-         }
-      }
-      else
-      {
-         freez(b->url->preg);
-      }
-#endif
-      if ((p = strchr(buf, ':')) == NULL)
-      {
-         port = 0;
-      }
-      else
-      {
-         *p++ = '\0';
-         port = atoi(p);
-      }
-
-      b->url->port = port;
-
-      if ((b->url->domain = strdup(buf)) == NULL)
-      {
-         fclose(fp);
-         goto load_forwardfile_error;
-      }
-
-      /* split domain into components */
-      *url = dsplit(b->url->domain);
-      b->url->dbuf = url->dbuf;
-      b->url->dcnt = url->dcnt;
-      b->url->dvec = url->dvec;
+      b->reject = reject;\r
+\r
+      /* Save the URL pattern */\r
+      if (create_url_spec(b->url, buf))\r
+      {\r
+         fclose(fp);\r
+         goto load_forwardfile_error;\r
+      }\r
 
       /* now parse the gateway specs */