You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Alexei Kosut <ak...@organic.com> on 1997/07/07 22:48:00 UTC

Another add_module() patch

Here's another patch to add_module(). It includes the patch I submitted
earlier today, but only for convenience; it addresses a different problem.

The name structure in a module is used to store the modules "name", for
various purposes. It's listed in lists (e.g. httpd -l or mod_info), used
for directives like <IfModule>, etc... We use __FILE__ to get this
information. Most compilers seem to return the filename (as I assume the
ANSI spec on the C preprocessor says - though I don't know), e.g.
"mod_cgi.c". However, I've discovered that Microsoft Visual C++ (version
5.0, at least) puts the entire filename in there, e.g.
"C:\Apache\src\mod_cgi.c". Obviously, this doesn't work nearly as well,
and could be very confusing if the user has downloaded a binary release,
and has never even heard of a C:\Apache\src directory.

So this patch includes, in addition to fixing the dynamic module
problem addressed in my last email, some code that should strip the
module's name down to the last path segment, which should be the string we
want.

Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.55
diff -u -r1.55 http_config.c
--- http_config.c	1997/06/30 21:18:11	1.55
+++ http_config.c	1997/07/07 20:42:25
@@ -83,8 +83,6 @@
  * of modules which control just about all of the server operation.
  */
 
-/* num_modules is the number of currently active modules.  */
-static int num_modules = 0;    
 /* total_modules is the number of modules linked in.  */
 static int total_modules = 0;
 module *top_module = NULL;
@@ -470,8 +468,17 @@
 	top_module = m;
     }
     if (m->module_index == -1) {
-	m->module_index = num_modules++;
+	m->module_index = total_modules++;
     }
+
+    /* Some C compilers put a complete path into __FILE__, but we want
+     * only the filename (e.g. mod_includes.c). So check for path
+     * components (Unix and DOS), and remove them.
+     */
+
+    if (strrchr(m->name, '/')) m->name = strrchr(m->name, '/');
+    if (strrchr(m->name, '\\')) m->name = strrchr(m->name, '\\');
+
     /** XXX: this will be slow if there's lots of add_modules */
     build_method_shortcuts ();
 }
@@ -539,8 +546,6 @@
 	*m = NULL;
 	m = next_m;
     }
-
-    num_modules = 0;
 
     /* This is required; so we add it always.  */
     add_named_module ("http_core.c");


-- Alexei Kosut <ak...@organic.com>