tidying
authorJeremy Harris <jgh146exb@wizmail.org>
Wed, 14 Aug 2024 10:11:47 +0000 (11:11 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Wed, 14 Aug 2024 10:17:13 +0000 (11:17 +0100)
12 files changed:
src/src/drtables.c
src/src/globals.h
src/src/readconf.c
src/src/route.c
src/src/routers/accept.c
src/src/routers/dnslookup.c
src/src/routers/ipliteral.c
src/src/routers/iplookup.c
src/src/routers/manualroute.c
src/src/routers/queryprogram.c
src/src/routers/redirect.c
src/src/transport.c

index 0f64728b467ed89a1d296e857961f8629795bcb1..b514090966b7f2843dbf9ae14052ad9c9af83d5e 100644 (file)
@@ -230,31 +230,6 @@ exim binary. */
 
 #include "routers/rf_functions.h"
 
-/*XXX delete */
-#ifdef ROUTER_DNSLOOKUP
-# include "routers/dnslookup.h"
-#endif
-
-#ifdef ROUTER_MANUALROUTE
-# include "routers/manualroute.h"
-#endif
-
-#ifdef ROUTER_IPLITERAL
-# include "routers/ipliteral.h"
-#endif
-
-#ifdef ROUTER_IPLOOKUP
-# include "routers/iplookup.h"
-#endif
-
-#ifdef ROUTER_QUERYPROGRAM
-# include "routers/queryprogram.h"
-#endif
-
-#ifdef ROUTER_REDIRECT
-# include "routers/redirect.h"
-#endif
-
 #ifdef TRANSPORT_APPENDFILE
 # include "transports/appendfile.h"
 #endif
@@ -280,14 +255,7 @@ exim binary. */
 #endif
 
 
-router_info * routers_available_newlist = NULL;
-
-/* Now set up the structures, terminated by an entry with a null name. */
-
-router_info routers_available_oldarray[] = {
-  { .drinfo = { .driver_name = US"" }}
-};
-
+router_info * routers_available = NULL;
 
 
 transport_info * transports_available_newlist = NULL;
@@ -397,8 +365,6 @@ gstring *
 auth_show_supported(gstring * g)
 {
 g = string_cat(g, US"Authenticators:");
-/*XXX these run off the static list as we want them before the conf is read */
-/*XXX Could possibly check for dyn flag + file presence */
 for (auth_info * ai = auths_available_oldarray; ai->drinfo.driver_name[0]; ai++)
                g = string_fmt_append(g, " %s", ai->drinfo.driver_name);
 return string_cat(g, US"\n");
@@ -407,15 +373,6 @@ return string_cat(g, US"\n");
 gstring *
 route_show_supported(gstring * g)
 {
-#ifdef old
-g = string_cat(g, US"Routers:");
-/*XXX these run off the static list as we want them before the conf is read */
-/*XXX lookup_show_supported is in exim.c and just works off the #defines, with hardoded strings */
-for (router_info * rr = routers_available_oldarray; rr->drinfo.driver_name[0]; rr++)
-               g = string_fmt_append(g, " %s", rr->drinfo.driver_name);
-return string_cat(g, US"\n");
-#else
-
 uschar * b = US""              /* static-build router names */
 #if defined(ROUTER_ACCEPT) && ROUTER_ACCEPT!=2
   " accept"
@@ -467,7 +424,6 @@ uschar * d = US""           /* dynamic-module router names */
 if (*b) g = string_fmt_append(g, "Routers (built-in):%s\n", b);
 if (*d) g = string_fmt_append(g, "Routers (dynamic): %s\n", d);
 return g;
-#endif /*!old*/
 }
 
 gstring *
index 817c940ed4ade46ee1bde56e4f75596115946e57..6bca06c00999ade79137a7f6f424fbf5a7527bf9 100644 (file)
@@ -947,8 +947,7 @@ extern int     rfc1413_query_timeout;  /* Timeout on RFC 1413 calls */
 /* extern BOOL    rfc821_domains;  */       /* If set, syntax is 821, not 822 => being abolished */
 extern uid_t   root_gid;               /* The gid for root */
 extern uid_t   root_uid;               /* The uid for root */
-extern router_info routers_available_oldarray[];/* Vector of available routers */
-extern router_info *routers_available_newlist;
+extern router_info *routers_available; /* List of available router drivers */
 extern router_instance *routers;       /* Chain of instantiated routers */
 extern router_instance router_defaults;/* Default values */
 extern const uschar *router_name;      /* Name of router last started */
index da94071b506447ab940269fb3b50b2c4ed381691..57788afc39c28b561dbf5cdb7978e623a75df8fc 100644 (file)
@@ -3734,39 +3734,6 @@ static driver_info *
 init_driver(driver_instance * d, driver_info ** info_anchor,
   int size_of_info, const uschar * class)
 {
-/*XXX if dynamic, the _info entry will not be here yet.
-
-For lookups it does it by pulling the info entry out of the dlopen()d
-file (for dynamic) or direct from the lookup .o file (for static).
-It builds a linked-list with those two classes,
-then an array sorted by (? name) and discards the list.
-The array is the _info list.
-
-We'd rather not have to do two passes over the config file(s) section.
-With the number of drivers I see no point in sorting,
-so we could stick with a one-pass build of an _info linked-list.
-This does mean converting any code using the current array.
-
-DONE:
-Rename the array to old.  For now, walk it once and build a linked-list.
-Find and convert all the uses,
-
-Move all the element defns to driver code files.
-Change the init/build to scan them.
-
-Move the scan to the place-of-use reading the config,
-only load if not already on linked-list.
-
-Add the build-dynamic wrapper,
-and scan from dlopen if marked dynamic.
-*/
-
-#ifdef old
-/*XXX walk the old array */
-for (driver_info * di= *info_anchor; di->driver_name[0] != 0;
-     di= (driver_info *)((US di) + size_of_info))
-#endif
-
 driver_info * di;
 int len;
 DIR * dd;
@@ -3822,7 +3789,10 @@ else
     for(driver_magics * dmp = dm; dmp < dm + nelem(dm); dmp++)
       if(Ustrcmp(dmp->class, class) == 0 && dmp->magic == di->dyn_magic)
        {
+       int old_pool = store_pool;
+       store_pool = POOL_PERM;
        add_driver_info(info_anchor, di, size_of_info);
+       store_pool = old_pool;
        DEBUG(D_any) debug_printf("Loaded %s %s\n", d->driver_name, class);
        closedir(dd);
        goto found;
@@ -3898,7 +3868,7 @@ Returns:                     nothing
 void
 readconf_driver_init(
   driver_instance ** anchor,
-  driver_info ** info_anchor,  /*XXX now list not array, static only so far */
+  driver_info ** info_anchor,
   int size_of_info,
   void * instance_default,
   int  instance_size,
@@ -4359,9 +4329,6 @@ auths_init(void)
 int nauths = 0;
 #endif
 
-/*XXX temp loop just copying the old array to build the new list.
-Will replace with haul from either static build file or dyn module
-done by readconf_driver_init() */
 for (auth_info * tblent = auths_available_oldarray;
     *tblent->drinfo.driver_name; tblent++)
   {
index b733d1a522445fa7cdd4156d518ae3ceccbde16a..07f0a6b20d9635e23f58d474398be9f011e2a420 100644 (file)
@@ -159,10 +159,7 @@ uschar buf[64];
 
 options_from_list(optionlist_routers, nelem(optionlist_routers), US"ROUTERS", NULL);
 
-#ifdef old
-for (router_info * ri = routers_available; ri->drinfo.driver_name[0]; ri++)
-#endif
-for (driver_info * di = (driver_info *)routers_available_newlist; di; di = di->next)
+for (driver_info * di = (driver_info *)routers_available; di; di = di->next)
   {
   spf(buf, sizeof(buf), US"_DRIVER_ROUTER_%T", di->driver_name);
   builtin_macro_create(buf);
@@ -231,29 +228,10 @@ void
 route_init(void)
 {
 
-#ifdef old
-/*XXX temp loop just copying the old array to build the new list. */
-for (router_info * tblent = routers_available_oldarray;
-    *tblent->drinfo.driver_name; tblent++)
-  {
-  driver_info * listent = store_get(sizeof(router_info), tblent);
-  memcpy(listent, tblent, sizeof(router_info));
-  listent->next = (driver_info *)routers_available_newlist;
-  routers_available_newlist = (router_info *)listent;
-  }
-#else
-
-/*XXX
-Will replace with ifdeffed explicit calls in drtab.c just building list
-(2 lists?) of names for -bV (DONE),
-plut ifdeffed repeated code here adding static-build modules to list (DONE)
-plus code in readconf.c for dlopen()s just before per-driver init api call.
-*/
-
 int old_pool = store_pool;
 store_pool = POOL_PERM;
   {
-  driver_info ** anchor = (driver_info **) &routers_available_newlist;
+  driver_info ** anchor = (driver_info **) &routers_available;
   extern router_info accept_router_info;
   extern router_info dnslookup_router_info;
   extern router_info ipliteral_router_info;
@@ -262,10 +240,9 @@ store_pool = POOL_PERM;
   extern router_info redirect_router_info;
   extern router_info queryprogram_router_info;
 
-  /*XXX this adds only the statics.  We can't get the dynamics as they
-  are not linked.  Until dlopen(), when we can use dlsym().  So the discovery
-  is by the file exitence, via the filename pattern. */
-  /*XXX TODO: move the info structs to individual driver files */
+  /* Add the router drivers that are built for static linkage to the
+  list of availables. */
+
 #if defined(ROUTER_ACCEPT) && ROUTER_ACCEPT!=2
   add_driver_info(anchor, &accept_router_info.drinfo, sizeof(router_info));
 #endif
@@ -290,11 +267,13 @@ store_pool = POOL_PERM;
   }
 store_pool = old_pool;
 
-#endif /*!old*/
 
-/*XXX this does the config file "routers" section reading */
+/* Read the config file "routers" section, creating a routers instance list.
+For any yet-undiscovered driver, check for a loadable module and add it to
+those available. */
+
 readconf_driver_init((driver_instance **)&routers,     /* chain anchor */
-  (driver_info **)&routers_available_newlist,   /* available drivers */
+  (driver_info **)&routers_available, /* available drivers */
   sizeof(router_info),                /* size of info blocks */
   &router_defaults,                   /* default values for generic options */
   sizeof(router_instance),            /* size of instance block */
index 353d1762c69f3c505c4f1134ef837bcbe03d18df..5b247131f5d02a90ba6c6f51c957af3a6b2cb3ab 100644 (file)
@@ -156,7 +156,7 @@ router_info accept_router_info =
   .options_len =       sizeof(accept_router_options_block),
   .init =              accept_router_init,
 # ifdef DYNLOOKUP
-  .dyn_magic =         ROUTER_MAGIC,           /*XXX*/
+  .dyn_magic =         ROUTER_MAGIC,
 # endif
   },
 .code =                accept_router_entry,
index 90ea0f6131059142091e4cc195db499a7943c367..1520cc376930c656bced6ce468af6c8f115812cd 100644 (file)
@@ -492,7 +492,7 @@ router_info dnslookup_router_info =
   .options_len =       sizeof(dnslookup_router_options_block),
   .init =              dnslookup_router_init,
 # ifdef DYNLOOKUP
-  .dyn_magic =         ROUTER_MAGIC,           /*XXX*/
+  .dyn_magic =         ROUTER_MAGIC,
 # endif
   },
 .code =                        dnslookup_router_entry,
index a5ef20d32530c8c88d1a02aafbcb663bca377f39..54a776e9ad7eb0a04c51d695012976c42e630872 100644 (file)
@@ -217,7 +217,7 @@ router_info ipliteral_router_info =
   .options_len =       sizeof(ipliteral_router_options_block),
   .init =              ipliteral_router_init,
 # ifdef DYNLOOKUP
-  .dyn_magic =         ROUTER_MAGIC,           /*XXX*/
+  .dyn_magic =         ROUTER_MAGIC,
 # endif
   },
 .code =                        ipliteral_router_entry,
index 24362fa8873430991a9e74a6bf62e7238ec2bb1b..464112bc0ce8ed12705035037829cd1a327a5df0 100644 (file)
@@ -433,7 +433,7 @@ router_info iplookup_router_info =
   .options_len =       sizeof(iplookup_router_options_block),
   .init =              iplookup_router_init,
 # ifdef DYNLOOKUP
-  .dyn_magic =         ROUTER_MAGIC,           /*XXX*/
+  .dyn_magic =         ROUTER_MAGIC,
 # endif
   },
 .code =                        iplookup_router_entry,
index 095a3af16585fac8c564b3fef42921f4f0bb7487..c24ae0e2c025df76174337f6d9cdbd2e99fd1a1c 100644 (file)
@@ -512,7 +512,7 @@ router_info manualroute_router_info =
   .options_len =       sizeof(manualroute_router_options_block),
   .init =              manualroute_router_init,
 # ifdef DYNLOOKUP
-  .dyn_magic =         ROUTER_MAGIC,           /*XXX*/
+  .dyn_magic =         ROUTER_MAGIC,
 # endif
   },
 .code =                        manualroute_router_entry,
index 606124e7ed336245736fd87bae49c2ce7b2e4c5d..9433759125c383e641bc7117bebb678c6bd5d554 100644 (file)
@@ -550,7 +550,7 @@ router_info queryprogram_router_info =
   .options_len =      sizeof(queryprogram_router_options_block),
   .init =             queryprogram_router_init,
 # ifdef DYNLOOKUP
-  .dyn_magic =       ROUTER_MAGIC,           /*XXX*/
+  .dyn_magic =       ROUTER_MAGIC,
 # endif
   },
 .code =               queryprogram_router_entry,
index 50b180372bb7b8f5eb19fd767c0a5e724b66ab45..86278d818806823e460248f8d6732fefc0fa1ac8 100644 (file)
@@ -804,7 +804,7 @@ router_info redirect_router_info =
   .options_len =       sizeof(redirect_router_options_block),
   .init =              redirect_router_init,
 # ifdef DYNLOOKUP
-  .dyn_magic =         ROUTER_MAGIC,           /*XXX*/
+  .dyn_magic =         ROUTER_MAGIC,
 # endif
   },
 .code =                        redirect_router_entry,
index 7e47cf1da56697e380d7c7363186e63ae3bd2209..e42625ce82e6b0051132e3cb01f9c3a18b5f6f97 100644 (file)
@@ -146,9 +146,6 @@ the work. */
 void
 transport_init(void)
 {
-/*XXX temp loop just copying the old array to build the new list.
-Will replace with haul from either static build file or dyn module
-done by readconf_driver_init() */
 for (transport_info * tblent = transports_available_oldarray;
     *tblent->drinfo.driver_name; tblent++)
   {