#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
#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;
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");
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"
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 *
/* 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 */
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;
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;
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,
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++)
{
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);
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;
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
}
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 */
.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,
.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,
.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,
.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,
.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,
.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,
.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,
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++)
{