thetaphi                Fri May 30 09:15:04 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/sapi/nsapi    nsapi.c 
  Log:
  virtual() now works under windows, too
  
Index: php4/sapi/nsapi/nsapi.c
diff -u php4/sapi/nsapi/nsapi.c:1.28.2.10 php4/sapi/nsapi/nsapi.c:1.28.2.11
--- php4/sapi/nsapi/nsapi.c:1.28.2.10   Thu May 29 17:05:06 2003
+++ php4/sapi/nsapi/nsapi.c     Fri May 30 09:15:04 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: nsapi.c,v 1.28.2.10 2003/05/29 21:05:06 thetaphi Exp $ */
+/* $Id: nsapi.c,v 1.28.2.11 2003/05/30 13:15:04 thetaphi Exp $ */
 
 /*
  * PHP includes
@@ -211,10 +211,11 @@
 /* newer servers hide this functions from the programmer so redefine the functions 
dynamically
    thanks to Chris Elving from Sun for the function declarations */
 
-int (*nsapi_servact_uri2path)(Session *sn, Request *rq) = NULL;
-int (*nsapi_servact_pathchecks)(Session *sn, Request *rq) = NULL;
-int (*nsapi_servact_fileinfo)(Session *sn, Request *rq) = NULL;
-int (*nsapi_servact_service)(Session *sn, Request *rq) = NULL;
+typedef int (*nsapi_servact_prototype)(Session *sn, Request *rq);
+nsapi_servact_prototype nsapi_servact_uri2path = NULL;
+nsapi_servact_prototype nsapi_servact_pathchecks = NULL;
+nsapi_servact_prototype nsapi_servact_fileinfo = NULL;
+nsapi_servact_prototype nsapi_servact_service = NULL;
 
 /* {{{ php_nsapi_init_dynamic_symbols
  */
@@ -226,12 +227,28 @@
        nsapi_servact_pathchecks = &servact_pathchecks;
        nsapi_servact_fileinfo = &servact_fileinfo;
        nsapi_servact_service = &servact_service;
-#elif !defined(PHP_WIN32)
+#else
        /* find address of internal NSAPI functions */
-       *(void **)(&nsapi_servact_uri2path) = DL_FETCH_SYMBOL(RTLD_DEFAULT, 
"INTservact_uri2path");
-       *(void **)(&nsapi_servact_pathchecks) = DL_FETCH_SYMBOL(RTLD_DEFAULT, 
"INTservact_pathchecks");
-       *(void **)(&nsapi_servact_fileinfo) = DL_FETCH_SYMBOL(RTLD_DEFAULT, 
"INTservact_fileinfo");
-       *(void **)(&nsapi_servact_service) = DL_FETCH_SYMBOL(RTLD_DEFAULT, 
"INTservact_service");
+#ifdef PHP_WIN32
+       register int i;
+       char module_name[11];
+       DL_HANDLE module = NULL;
+       /* find a LOADED dll module named "ns-httpdX0", where X is version
+        * currently there are server-dlls in version 2, 3 and 4 in use */
+       for (i=4; i>=2; i--) {
+               sprintf(module_name, "ns-httpd%d0", i);
+               if (module = GetModuleHandle(module_name)) {
+                       break;
+               }
+       }
+       if (!module) return;
+#else
+       DL_HANDLE module = RTLD_DEFAULT;
+#endif
+       nsapi_servact_uri2path = (nsapi_servact_prototype)DL_FETCH_SYMBOL(module, 
"INTservact_uri2path");
+       nsapi_servact_pathchecks = (nsapi_servact_prototype)DL_FETCH_SYMBOL(module, 
"INTservact_pathchecks");
+       nsapi_servact_fileinfo = (nsapi_servact_prototype)DL_FETCH_SYMBOL(module, 
"INTservact_fileinfo");
+       nsapi_servact_service = (nsapi_servact_prototype)DL_FETCH_SYMBOL(module, 
"INTservact_service");
        if (!(nsapi_servact_uri2path && nsapi_servact_pathchecks && 
nsapi_servact_fileinfo && nsapi_servact_service)) {
                /* not found - could be cause they are undocumented */
                nsapi_servact_uri2path = NULL;
@@ -787,9 +804,9 @@
 
        nsapi_free(SG(request_info).query_string);
        nsapi_free(SG(request_info).request_uri);
-       nsapi_free(SG(request_info).request_method);
+       nsapi_free((void*)(SG(request_info).request_method));
        nsapi_free(SG(request_info).path_translated);
-       nsapi_free(SG(request_info).content_type);
+       nsapi_free((void*)(SG(request_info).content_type));
 
        FREE(request_context);
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to