]> granicus.if.org Git - apache/commitdiff
Nobody objected:
authorAndré Malo <nd@apache.org>
Fri, 4 Jun 2004 22:40:47 +0000 (22:40 +0000)
committerAndré Malo <nd@apache.org>
Fri, 4 Jun 2004 22:40:47 +0000 (22:40 +0000)
<IfModule> now takes the module identifier in addition to the
filename.

CAUTION: this commit breaks the build on netware. It still needs
to be adjusted. (but I don't have any netware knowledge...)
Also, developers need to re-run buildconf on unices.

PR: 29003
Submitted by: Edward Rudd <eddie omegaware.com>, Andr� Malo

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@103849 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
build/build-modules-c.awk
configure.in
include/ap_mmn.h
include/http_config.h
libhttpd.dsp
modules/mappers/mod_so.c
modules/mappers/mod_so.h [new file with mode: 0644]
os/netware/modules.c
os/win32/modules.c
server/core.c

diff --git a/CHANGES b/CHANGES
index 2c2c1e84f28336ef274e269fc46f17203735bb81..f496baf29f97cc053319ef521cdb7f118b7e931d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) <IfModule> now recognizes the module identifier in addition to the
+     file name. PR 29003.  [Edward Rudd <eddie omegaware.com>, André Malo]
+
   *) mod_ssl: Add "SSLUserName" directive to set r->user based on a
      chosen SSL environment variable.  PR 20957. 
      [Martin v. Loewis <martin v.loewis.de>]
index 27ebbde1e6a73c92ad11b5d8337f0d28b0b3c22a..fda31c28604ec0c751e4ed9e340e5951682396e3 100644 (file)
@@ -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) {
@@ -53,6 +54,17 @@ END {
     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 "/*"
     print " *  Modules which initially form the"
     print " *  list of available modules on startup,"
     print " *  i.e. these are the modules which are"
index 68bc23bb0e7bf5ebc2c6f0e620403a02304da876..ee7a975bac3f3a43931f5959446701c53c2af988 100644 (file)
@@ -134,7 +134,7 @@ if test "$abs_builddir" != "$abs_srcdir"; then
   APR_ADDTO(INCLUDES, [-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 3c94f4e4119f3f8a6614128f800ecb7defb9b1b5..d724fe7ef6f60ac275fd8add393ba485d77f405d 100644 (file)
@@ -83,6 +83,7 @@
  * 20040425 (2.1.0-dev) removed ap_add_named_module API
  *                      changed ap_add_module, ap_add_loaded_module,
  *                      ap_setup_prelinked_modules, ap_process_resource_config
+ * 20040425.1 (2.1.0-dev) Added ap_module_symbol_t and ap_prelinked_module_symbols
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
@@ -90,7 +91,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20040425
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index b0cda6304249fb2f62c9cd4a60abf16848ac8b96..31b6dd6502878522e458b396ec4d66761f71e2a2 100644 (file)
@@ -704,6 +704,14 @@ AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
 
 #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
@@ -715,6 +723,11 @@ AP_DECLARE_DATA extern module *ap_top_module;
  * @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 cc21ffa22d82d22b0e1d51842dd1d6ebb7cb425b..4def46c08edc636aa71d2c8efc1128fe469fce98 100644 (file)
@@ -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 578b170a05803311e527d1a9bb85c6f8c791efdc..9088d7f9ff3853d5575e151cf23c0e0757dfd219 100644 (file)
@@ -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 *p, server_rec *s)
 
     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 *p, server_rec *s)
 
 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 *cmd, void *dummy,
     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;
     const char *error;
 
@@ -182,7 +179,7 @@ static const char *load_module(cmd_parms *cmd, void *dummy,
      */
     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) {
@@ -330,6 +327,26 @@ static const char *load_file(cmd_parms *cmd, void *dummy, const char *filename)
     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)
@@ -349,6 +366,13 @@ static const char *load_module(cmd_parms *cmd, void *dummy,
 
 #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"),
@@ -364,5 +388,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 */
 };
diff --git a/modules/mappers/mod_so.h b/modules/mappers/mod_so.h
new file mode 100644 (file)
index 0000000..514ba6c
--- /dev/null
@@ -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 7d3b791738e95f69ceed29b3c9a114311ddb2e6d..0115cc8f4e1456f6d30fe38429cc7593431fc514 100644 (file)
@@ -69,6 +69,31 @@ 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},
+  {"authz_host_module", &authz_host_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 49cb856c6fb4e0b12d7304e0b46328d7a231c118..447f9cd886a7841a6ff41aa4f4f14dec160c4ef2 100644 (file)
@@ -37,6 +37,15 @@ AP_DECLARE_DATA module *ap_prelinked_modules[] = {
   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 3475c0f347beac5bf3f32577617de6116f13fb4b..35eb37efb57eac3675eea31dc945453564c4eeea 100644 (file)
@@ -48,6 +48,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)
@@ -1896,6 +1898,28 @@ static const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg)
 
     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;
         ap_directive_t *current = NULL;