]> granicus.if.org Git - apache/commitdiff
Add ap_os_proc_filepath and clean up the win32/os.h file structure.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Mon, 1 Jul 2002 17:48:47 +0000 (17:48 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Mon, 1 Jul 2002 17:48:47 +0000 (17:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95927 13f79535-47bb-0310-9956-ffa450edef68

os/win32/os.h
os/win32/util_win32.c

index 2a8f9945b5c3e6a6e00b3b5e10754afd04c17696..c6f6200f002bce0bb8f558522f2b6ab466b0b381 100644 (file)
  * University of Illinois, Urbana-Champaign.
  */
 
-#ifndef APACHE_OS_H
-#define APACHE_OS_H
-/* 
- * Compile the server including all the Windows NT 4.0 header files by 
- * default. We still want the server to run on Win95/98 so use 
- * runtime checks before calling NT specific functions to verify we are 
- * really running on an NT system.
- *
- * Delegate windows include to the apr.h header, if USER or GDI declarations
+#ifdef WIN32
+
+#ifndef AP_OS_H
+#define AP_OS_H
+/* Delegate windows include to the apr.h header, if USER or GDI declarations
  * are required (for a window rather than console application), include
  * windows.h prior to any other Apache header files.
  */
-
-#ifndef ap_os_h
-#define ap_os_h
-#endif
+#include "apr_pools.h"
 
 #include <io.h>
 #include <fcntl.h>
 
 #include <stddef.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* BIG RED WARNING: exit() is mapped to allow us to capture the exit
  * status.  This header must only be included from modules linked into
  * the ApacheCore.dll - since it's a horrible behavior to exit() from
@@ -100,4 +97,11 @@ AP_DECLARE_DATA extern int real_exit_code;
 #define exit(status) ((exit)((real_exit_code==2) ? (real_exit_code = (status)) \
                                                  : ((real_exit_code = 0), (status))))
 
-#endif   /* ! ap_os_h */
+AP_DECLARE(apr_status_t) ap_os_proc_filepath(char **binpath, apr_pool_t *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* ndef AP_OS_H */
+#endif  /* def WIN32 */
index dc15980bcbbb3b070a0b9fa95373141acf2d53b6..0dfce99ffb3d126a9dc49a44b16ff2a7b5fd20ae 100644 (file)
 #include "httpd.h"
 #include "http_log.h"
 #include "apr_strings.h"
+#include "arch/win32/fileio.h"
+#include "arch/win32/misc.h"
 
 #include <stdarg.h>
 #include <time.h>
 #include <stdlib.h>
 
 
+AP_DECLARE(apr_status_t) ap_os_proc_filepath(char **binpath, apr_pool_t *p)
+{
+    apr_wchar_t wbinpath[APR_PATH_MAX];
+
+#if APR_HAS_UNICODE_FS
+    IF_WIN_OS_IS_UNICODE 
+    {
+        apr_size_t binlen;
+        apr_size_t wbinlen;
+        apr_status_t rv;
+        if (!GetModuleFileNameW(NULL, wbinpath, sizeof(wbinpath) 
+                                              / sizeof(apr_wchar_t))) {
+            return apr_get_os_error();
+        }
+        wbinlen = wcslen(wbinpath) + 1;
+        binlen = (wbinlen - 1) * 3 + 1;
+        *binpath = apr_palloc(p, binlen);
+        rv = apr_conv_ucs2_to_utf8(wbinpath, &wbinlen, *binpath, &binlen);
+        if (rv != APR_SUCCESS)
+            return rv;
+        else if (wbinlen)
+            return APR_ENAMETOOLONG;
+    }
+#endif /* APR_HAS_UNICODE_FS */
+#if APR_HAS_ANSI_FS
+    ELSE_WIN_OS_IS_ANSI
+    {
+        /* share the same scratch buffer */
+        char *pathbuf = (char*) wbinpath;
+        if (!GetModuleFileName(NULL, pathbuf, sizeof(wbinpath))) {
+            return apr_get_os_error();
+        }
+        *binpath = apr_pstrdup(p, pathbuf);
+    }
+#endif
+    return APR_SUCCESS;
+}
+
+
 AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
     const request_rec *r,
     apr_proc_t *newproc, const char *progname,