From: William A. Rowe Jr Date: Mon, 1 Jul 2002 17:48:47 +0000 (+0000) Subject: Add ap_os_proc_filepath and clean up the win32/os.h file structure. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a9f463503822c2999a706eeac746c76dd630915e;p=apache Add ap_os_proc_filepath and clean up the win32/os.h file structure. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95927 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/os/win32/os.h b/os/win32/os.h index 2a8f9945b5..c6f6200f00 100644 --- a/os/win32/os.h +++ b/os/win32/os.h @@ -56,22 +56,15 @@ * 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 #include @@ -87,6 +80,10 @@ #include +#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 */ diff --git a/os/win32/util_win32.c b/os/win32/util_win32.c index dc15980bcb..0dfce99ffb 100644 --- a/os/win32/util_win32.c +++ b/os/win32/util_win32.c @@ -59,12 +59,53 @@ #include "httpd.h" #include "http_log.h" #include "apr_strings.h" +#include "arch/win32/fileio.h" +#include "arch/win32/misc.h" #include #include #include +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,