* 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
#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 */
#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,