]> granicus.if.org Git - php/commitdiff
Added apache_get_version() & apache_get_modules() to Apache 1.X & Apache
authorIlia Alshanetsky <iliaa@php.net>
Fri, 27 Dec 2002 22:47:06 +0000 (22:47 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 27 Dec 2002 22:47:06 +0000 (22:47 +0000)
Hooks sapis.
Made the module listing in Apache 2 not show the '.c' portion, to be
consistent with Apache 1.X.

sapi/apache/php_apache.c
sapi/apache2filter/php_functions.c
sapi/apache_hooks/php_apache.c

index 1d64f2e53e820448e17c0afcbd6e580211ad9249..17d455e773c07948a83afc2f3527e337e3159028 100644 (file)
@@ -35,6 +35,7 @@ php_apache_info_struct php_apache_info;
 #define SECTION(name)  PUTS("<h2>" name "</h2>\n")
 
 extern module *top_module;
+extern module **ap_loaded_modules;
 
 PHP_FUNCTION(virtual);
 PHP_FUNCTION(apache_request_headers);
@@ -44,6 +45,8 @@ PHP_FUNCTION(apache_note);
 PHP_FUNCTION(apache_lookup_uri);
 PHP_FUNCTION(apache_child_terminate);
 PHP_FUNCTION(apache_setenv);
+PHP_FUNCTION(apache_get_version);
+PHP_FUNCTION(apache_get_modules);
 
 PHP_MINFO_FUNCTION(apache);
 
@@ -55,6 +58,8 @@ function_entry apache_functions[] = {
        PHP_FE(apache_child_terminate,                                  NULL)
        PHP_FE(apache_setenv,                                                   NULL)
        PHP_FE(apache_response_headers,                                 NULL)
+       PHP_FE(apache_get_version,                                      NULL)
+       PHP_FE(apache_get_modules,                                      NULL)
        PHP_FALIAS(getallheaders, apache_request_headers, NULL)
        {NULL, NULL, NULL}
 };
@@ -498,6 +503,34 @@ PHP_FUNCTION(apache_exec_uri)
 }
 #endif
 
+/* {{{ proto string apache_get_version(void)
+   Fetch Apache version */
+PHP_FUNCTION(apache_get_version)
+{
+       RETURN_STRING(SERVER_VERSION, 1);
+}
+/* }}} */
+
+/* {{{ proto array apache_get_modules(void)
+   Get a list of loaded Apache modules */
+PHP_FUNCTION(apache_get_modules)
+{
+       int n;
+       char *p;
+       
+       array_init(return_value);
+       
+       for (n = 0; ap_loaded_modules[n]; ++n) {
+               char *s = (char *) ap_loaded_modules[n]->name;
+               if ((p = strchr(s, '.'))) {
+                       add_next_index_stringl(return_value, s, (p - s), 1);
+               } else {
+                       add_next_index_string(return_value, s, 1);
+               }       
+       }
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
index 4959fb91c719ad53a62f108056eee70afb176eeb..a87e38e5f05e6dab7cc9f48e5490a76b43c9bbf3 100644 (file)
@@ -314,11 +314,17 @@ PHP_FUNCTION(apache_get_version)
 PHP_FUNCTION(apache_get_modules)
 {
        int n;
+       char *p;
        
        array_init(return_value);
        
        for (n = 0; ap_loaded_modules[n]; ++n) {
-               add_next_index_string(return_value, (char *) ap_loaded_modules[n]->name, 1);
+               char *s = (char *) ap_loaded_modules[n]->name;
+               if ((p = strchr(s, '.'))) {
+                       add_next_index_stringl(return_value, s, (p - s), 1);
+               } else {
+                       add_next_index_string(return_value, s, 1);
+               }
        }
 }
 /* }}} */
@@ -328,9 +334,15 @@ PHP_MINFO_FUNCTION(apache)
        char *apv = php_apache_get_version();
        smart_str tmp1 = {0};
        int n;
+       char *p;
        
        for (n = 0; ap_loaded_modules[n]; ++n) {
-               smart_str_appends(&tmp1, ap_loaded_modules[n]->name);
+               char *s = (char *) ap_loaded_modules[n]->name;
+               if ((p = strchr(s, '.'))) {
+                       smart_str_appendl(&tmp1, s, (p - s));
+               } else {
+                       smart_str_appends(&tmp1, s);
+               }
                smart_str_appendc(&tmp1, ' ');
        }
             
@@ -338,7 +350,7 @@ PHP_MINFO_FUNCTION(apache)
        if (apv && *apv) {
                php_info_print_table_row(2, "Apache Version", apv);
        }
-       php_info_print_table_row(2, "Loaded Apache Modules", tmp1.c);
+       php_info_print_table_row(2, "Loaded Modules", tmp1.c);
        smart_str_free(&tmp1);
        php_info_print_table_end();
 }
index e8006e2f0d5659910dc597c25e47d161ff7ff1c5..e8cd54d53b6a41cee6ad3c66ab1653c7d166e699 100644 (file)
@@ -40,6 +40,7 @@ php_apache_info_struct php_apache_info;
 #define offsetof(s_type,field) ((size_t)&(((s_type*)0)->field))
 
 extern module *top_module;
+extern module **ap_loaded_modules;
 static int le_apachereq;
 static zend_class_entry *apacherequest_class_entry;
 
@@ -53,6 +54,8 @@ PHP_FUNCTION(apache_note);
 PHP_FUNCTION(apache_lookup_uri);
 PHP_FUNCTION(apache_child_terminate);
 PHP_FUNCTION(apache_setenv);
+PHP_FUNCTION(apache_get_version);
+PHP_FUNCTION(apache_get_modules);
 
 PHP_MINFO_FUNCTION(apache);
 
@@ -65,6 +68,8 @@ function_entry apache_functions[] = {
        PHP_FE(apache_child_terminate,                                  NULL)
        PHP_FE(apache_setenv,                                                   NULL)
        PHP_FE(apache_response_headers,                                 NULL)
+       PHP_FE(apache_get_version,                                      NULL)
+       PHP_FE(apache_get_modules,                                      NULL)
        PHP_FALIAS(getallheaders, apache_request_headers, NULL)
        {NULL, NULL, NULL}
 };
@@ -1907,6 +1912,34 @@ PHP_FUNCTION(apache_exec_uri)
 }
 #endif
 
+/* {{{ proto string apache_get_version(void)
+   Fetch Apache version */
+PHP_FUNCTION(apache_get_version)
+{
+       RETURN_STRING(SERVER_VERSION, 1);
+}
+/* }}} */
+
+/* {{{ proto array apache_get_modules(void)
+   Get a list of loaded Apache modules */
+PHP_FUNCTION(apache_get_modules)
+{
+       int n;
+       char *p;
+       
+       array_init(return_value);
+       
+       for (n = 0; ap_loaded_modules[n]; ++n) {
+               char *s = (char *) ap_loaded_modules[n]->name;
+               if ((p = strchr(s, '.'))) {
+                       add_next_index_stringl(return_value, s, (p - s), 1);
+               } else {
+                       add_next_index_string(return_value, s, 1);
+               }       
+       }
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4