I just applied this patch to the Apache_20_branch and the code applies,
compiles, and runs cleanly (only tested on linux RH 7.3).  I'm puttingthis
up for a vote to be applied from cvs head to the 2.0 branch.  twothings
still need to be test, the compile on Win32 and the compile on Netware.
they should compile fine, but a test is always a Good Thing.

I've attached a cvs diff from the 2.0 branch.
Here are the HEAD CVS revisions where the changes took place

configure.in (rev 1.260)
build/build-modules-c.awk (rev 1.9)
os/win32/modules.c (rev 1.17)
os/netware/modules.c (rev 1.9)
server/core.c (rev 1.280)
include/http_config.h (rev 1.110)
modules/mappers/mod_so.c (rev 1.57)
modules/mappers/mod_so.h (rev 1.1  New File)

--
Edward Rudd <[EMAIL PROTECTED]>
Website http://www.outoforder.cc/
? build-prefork
Index: configure.in
===================================================================
RCS file: /home/cvspublic/httpd-2.0/configure.in,v
retrieving revision 1.232.2.14
diff -u -3 -p -r1.232.2.14 configure.in
--- configure.in        18 Mar 2004 07:36:52 -0000      1.232.2.14
+++ configure.in        21 Jun 2004 19:30:54 -0000
@@ -135,7 +135,7 @@ if test "$abs_builddir" != "$abs_srcdir"
   APR_ADDTO(INCLUDES, [-I\$(srcdir) -I\$(top_builddir)/server/mpm/\$(MPM_SUBDIR_NAME) 
-I\$(top_builddir)/include])
 fi
 
-APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/os/\$(OS_DIR) 
-I\$(top_srcdir)/server/mpm/\$(MPM_SUBDIR_NAME) -I\$(top_srcdir)/modules/http 
-I\$(top_srcdir)/modules/filters -I\$(top_srcdir)/modules/proxy 
-I\$(top_srcdir)/include -I\$(top_srcdir)/modules/generators])
+APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/os/\$(OS_DIR) 
-I\$(top_srcdir)/server/mpm/\$(MPM_SUBDIR_NAME) -I\$(top_srcdir)/modules/http 
-I\$(top_srcdir)/modules/filters -I\$(top_srcdir)/modules/proxy 
-I\$(top_srcdir)/include -I\$(top_srcdir)/modules/generators 
-I\$(top_srcdir)/modules/mappers])
 
 echo $ac_n "${nl}Applying OS-specific hints for httpd ...${nl}"
 
Index: libhttpd.dsp
===================================================================
RCS file: /home/cvspublic/httpd-2.0/libhttpd.dsp,v
retrieving revision 1.51.2.10
diff -u -3 -p -r1.51.2.10 libhttpd.dsp
--- libhttpd.dsp        8 Mar 2004 17:40:34 -0000       1.51.2.10
+++ libhttpd.dsp        21 Jun 2004 19:30:54 -0000
@@ -241,6 +241,35 @@ InputPath=.\modules\dav\main\mod_dav.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\modules\mappers\mod_so.h
+
+!IF  "$(CFG)" == "libhttpd - Win32 Release"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build - Creating include/mod_so.h
+InputPath=.\modules\mappers\mod_so.h
+
+".\include\mod_so.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+       type .\modules\mappers\mod_so.h > .\include\mod_so.h
+
+# End Custom Build
+
+!ELSEIF  "$(CFG)" == "libhttpd - Win32 Debug"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build - Creating include/mod_so.h
+InputPath=.\modules\mappers\mod_so.h
+
+".\include\mod_so.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+       type .\modules\mappers\mod_so.h > .\include\mod_so.h
+
+# End Custom Build
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
 SOURCE=.\modules\filters\mod_include.h
 
 !IF  "$(CFG)" == "libhttpd - Win32 Release"
Index: build/build-modules-c.awk
===================================================================
RCS file: /home/cvspublic/httpd-2.0/build/build-modules-c.awk,v
retrieving revision 1.5.2.2
diff -u -3 -p -r1.5.2.2 build-modules-c.awk
--- build/build-modules-c.awk   9 Feb 2004 20:59:44 -0000       1.5.2.2
+++ build/build-modules-c.awk   21 Jun 2004 19:30:54 -0000
@@ -32,6 +32,7 @@ END {
     print ""
     print "#include \"ap_config.h\""
     print "#include \"httpd.h\""
+    print "#define CORE_PRIVATE"
     print "#include \"http_config.h\""
     print ""
     for (i = 0; i < pn; ++i) {
@@ -50,6 +51,17 @@ END {
         printf "  &%s_module,\n", modules[i]
     }
     print "  NULL"
+    print "};"
+    print ""
+    print "/*"
+    print " *  We need the symbols as strings for <IfModule> containers"
+    print " */"
+    print ""
+    print "ap_module_symbol_t ap_prelinked_module_symbols[] = {"
+    for (i = 0; i < n; ++i) {
+        printf ("  {\"%s_module\", &%s_module},\n", modules[i], modules[i])
+    }
+    print "  {NULL, NULL}"
     print "};"
     print ""
     print "/*"
Index: include/http_config.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/include/http_config.h,v
retrieving revision 1.97.2.5
diff -u -3 -p -r1.97.2.5 http_config.h
--- include/http_config.h       9 Feb 2004 20:54:33 -0000       1.97.2.5
+++ include/http_config.h       21 Jun 2004 19:30:58 -0000
@@ -713,6 +713,14 @@ AP_DECLARE(const char *) ap_check_cmd_co
 #ifdef CORE_PRIVATE
 
 /**
+ * This structure is used to assign symbol names to module pointers
+ */
+typedef struct {
+    const char *name;
+    module *modp;
+} ap_module_symbol_t;
+
+/**
  * The topmost module in the list
  * @defvar module *ap_top_module
  */
@@ -723,6 +731,11 @@ AP_DECLARE_DATA extern module *ap_top_mo
  * @defvar module *ap_prelinked_modules[]
  */
 AP_DECLARE_DATA extern module *ap_prelinked_modules[];
+/**
+ * Array of all statically linked modulenames (symbols)
+ * @defvar ap_module_symbol_t ap_prelinked_modulenames[]
+ */
+AP_DECLARE_DATA extern ap_module_symbol_t ap_prelinked_module_symbols[];
 /**
  * Array of all preloaded modules
  * @defvar module *ap_preloaded_modules[]
Index: modules/mappers/mod_so.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/mappers/mod_so.c,v
retrieving revision 1.50.2.4
diff -u -3 -p -r1.50.2.4 mod_so.c
--- modules/mappers/mod_so.c    9 Feb 2004 20:53:18 -0000       1.50.2.4
+++ modules/mappers/mod_so.c    21 Jun 2004 19:30:58 -0000
@@ -94,6 +94,8 @@
 #include "http_log.h"
 #include "ap_config.h"
 
+#include "mod_so.h"
+
 module AP_MODULE_DECLARE_DATA so_module;
 
 
@@ -102,11 +104,6 @@ module AP_MODULE_DECLARE_DATA so_module;
  * loaded modules and the corresponding module name.
  */
 
-typedef struct moduleinfo {
-    const char *name;
-    module *modp;
-} moduleinfo;
-
 typedef struct so_server_conf {
     apr_array_header_t *loaded_modules;
 } so_server_conf;
@@ -117,7 +114,7 @@ static void *so_sconf_create(apr_pool_t 
 
     soc = (so_server_conf *)apr_pcalloc(p, sizeof(so_server_conf));
     soc->loaded_modules = apr_array_make(p, DYNAMIC_MODULE_LIMIT, 
-                                     sizeof(moduleinfo));
+                                     sizeof(ap_module_symbol_t));
 
     return (void *)soc;
 }
@@ -131,7 +128,7 @@ static void *so_sconf_create(apr_pool_t 
 
 static apr_status_t unload_module(void *data)
 {
-    moduleinfo *modi = (moduleinfo*)data;
+    ap_module_symbol_t *modi = (ap_module_symbol_t*)data;
 
     /* only unload if module information is still existing */
     if (modi->modp == NULL)
@@ -159,8 +156,8 @@ static const char *load_module(cmd_parms
     module *modp;
     const char *szModuleFile = ap_server_root_relative(cmd->pool, filename);
     so_server_conf *sconf;
-    moduleinfo *modi;
-    moduleinfo *modie;
+    ap_module_symbol_t *modi;
+    ap_module_symbol_t *modie;
     int i;
 
     /* we need to setup this value for dummy to make sure that we don't try
@@ -181,7 +178,7 @@ static const char *load_module(cmd_parms
      */
     sconf = (so_server_conf *)ap_get_module_config(cmd->server->module_config, 
                                                &so_module);
-    modie = (moduleinfo *)sconf->loaded_modules->elts;
+    modie = (ap_module_symbol_t *)sconf->loaded_modules->elts;
     for (i = 0; i < sconf->loaded_modules->nelts; i++) {
         modi = &modie[i];
         if (modi->name != NULL && strcmp(modi->name, modname) == 0) {
@@ -326,6 +323,26 @@ static const char *load_file(cmd_parms *
     return NULL;
 }
 
+static module *ap_find_loaded_module_symbol(server_rec *s, const char *modname)
+{
+    so_server_conf *sconf;
+    ap_module_symbol_t *modi;
+    ap_module_symbol_t *modie;
+    int i;
+
+    sconf = (so_server_conf *)ap_get_module_config(s->module_config, 
+                                                   &so_module);
+    modie = (ap_module_symbol_t *)sconf->loaded_modules->elts;
+
+    for (i = 0; i < sconf->loaded_modules->nelts; i++) {
+        modi = &modie[i];
+        if (modi->name != NULL && strcmp(modi->name, modname) == 0) {
+            return modi->modp;
+        }
+    }
+    return NULL;
+}
+
 #else /* not NO_DLOPEN */
 
 static const char *load_file(cmd_parms *cmd, void *dummy, const char *filename)
@@ -345,6 +362,13 @@ static const char *load_module(cmd_parms
 
 #endif /* NO_DLOPEN */
 
+static void register_hooks(apr_pool_t *p)
+{
+#ifndef NO_DLOPEN
+    APR_REGISTER_OPTIONAL_FN(ap_find_loaded_module_symbol);
+#endif
+}
+
 static const command_rec so_cmds[] = {
     AP_INIT_TAKE2("LoadModule", load_module, NULL, RSRC_CONF | EXEC_ON_READ,
       "a module name and the name of a shared object file to load it from"),
@@ -360,5 +384,5 @@ module AP_MODULE_DECLARE_DATA so_module 
    so_sconf_create,            /* server config */
    NULL,                           /* merge server config */
    so_cmds,                        /* command apr_table_t */
-   NULL                                    /* register hooks */
+   register_hooks          /* register hooks */
 };
Index: modules/mappers/mod_so.h
===================================================================
RCS file: modules/mappers/mod_so.h
diff -N modules/mappers/mod_so.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ modules/mappers/mod_so.h    21 Jun 2004 19:30:58 -0000
@@ -0,0 +1,27 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MOD_SO_H
+#define MOD_SO_H 1
+
+#include "apr_optional.h"
+#include "httpd.h"
+
+/* optional function declaration */
+APR_DECLARE_OPTIONAL_FN(module *, ap_find_loaded_module_symbol,
+                        (server_rec *s, const char *modname));
+
+#endif /* MOD_SO_H */
+
Index: os/netware/modules.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/os/netware/modules.c,v
retrieving revision 1.5.2.3
diff -u -3 -p -r1.5.2.3 modules.c
--- os/netware/modules.c        9 Feb 2004 20:59:45 -0000       1.5.2.3
+++ os/netware/modules.c        21 Jun 2004 19:30:59 -0000
@@ -71,6 +71,32 @@ module *ap_prelinked_modules[] = {
   NULL
 };
 
+ap_module_symbol_t ap_prelinked_module_symbols[] = {
+  {"core_module", &core_module},
+  {"mpm_netware_module", &mpm_netware_module},
+  {"http_module", &http_module},
+  {"so_module", &so_module},
+  {"mime_module", &mime_module},
+  {"access_module", &access_module},
+  {"auth_module", &auth_module},
+  {"negotiation_module", &negotiation_module},
+  {"include_module", &include_module},
+  {"autoindex_module", &autoindex_module},
+  {"dir_module", &dir_module},
+  {"cgi_module", &cgi_module},
+  {"userdir_module", &userdir_module},
+  {"alias_module", &alias_module},
+  {"env_module", &env_module},
+  {"log_config_module", &log_config_module},
+  {"asis_module", &asis_module},
+  {"imap_module", &imap_module},
+  {"actions_module", &actions_module},
+  {"setenvif_module", &setenvif_module},
+  {"nwssl_module", &nwssl_module},
+  {"netware_module", &netware_module},
+  {NULL, NULL}
+};
+
 module *ap_preloaded_modules[] = {
   &core_module,
   &mpm_netware_module,
Index: os/win32/modules.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/os/win32/modules.c,v
retrieving revision 1.13.2.2
diff -u -3 -p -r1.13.2.2 modules.c
--- os/win32/modules.c  9 Feb 2004 20:59:45 -0000       1.13.2.2
+++ os/win32/modules.c  21 Jun 2004 19:30:59 -0000
@@ -37,6 +37,15 @@ AP_DECLARE_DATA module *ap_prelinked_mod
   NULL
 };
 
+ap_module_symbol_t ap_prelinked_module_symbols[] = {
+  {"core_module", &core_module},
+  {"win32_module", &win32_module},
+  {"mpm_winnt_module", &mpm_winnt_module},
+  {"http_module", &http_module},
+  {"so_module", &so_module},
+  {NULL, NULL}
+};
+
 AP_DECLARE_DATA module *ap_preloaded_modules[] = {
   &core_module,
   &win32_module,
Index: server/core.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/core.c,v
retrieving revision 1.225.2.22
diff -u -3 -p -r1.225.2.22 core.c
--- server/core.c       6 Jun 2004 13:23:26 -0000       1.225.2.22
+++ server/core.c       21 Jun 2004 19:31:04 -0000
@@ -49,6 +49,8 @@
 #include "mod_proxy.h"
 #include "ap_listen.h"
 
+#include "mod_so.h" /* for ap_find_loaded_module_symbol */
+
 /* LimitRequestBody handling */
 #define AP_LIMIT_REQ_BODY_UNSET         ((apr_off_t) -1)
 #define AP_DEFAULT_LIMIT_REQ_BODY       ((apr_off_t) 0)
@@ -1853,6 +1855,28 @@ static const char *start_ifmod(cmd_parms
     }
 
     found = ap_find_linked_module(arg);
+
+    /* search prelinked stuff */
+    if (!found) {
+        ap_module_symbol_t *current = ap_prelinked_module_symbols;
+
+        for (; current->name; ++current) {
+            if (!strcmp(current->name, arg)) {
+                found = current->modp;
+                break;
+            }
+        }
+    }
+
+    /* search dynamic stuff */
+    if (!found) {
+        APR_OPTIONAL_FN_TYPE(ap_find_loaded_module_symbol) *check_symbol =
+            APR_RETRIEVE_OPTIONAL_FN(ap_find_loaded_module_symbol);
+
+        if (check_symbol) {
+            found = check_symbol(cmd->server, arg);
+        }
+    }
 
     if ((!not && found) || (not && !found)) {
         ap_directive_t *parent = NULL;

Reply via email to