diff options
author | William A. Rowe Jr <wrowe@apache.org> | 2002-01-30 06:42:55 +0000 |
---|---|---|
committer | William A. Rowe Jr <wrowe@apache.org> | 2002-01-30 06:42:55 +0000 |
commit | 11d2f3fc6d4513628d54cb94130bee94b4c363f0 (patch) | |
tree | 82300cf185942b09258e091d1cf1b0dc5866c423 /misc | |
parent | 2643c050ef8d2b68f7f31137db62f317ce473d1d (diff) | |
download | apr-11d2f3fc6d4513628d54cb94130bee94b4c363f0.tar.gz |
Introduce apr_app_main() for global consumption.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@62872 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc')
-rw-r--r-- | misc/unix/start.c | 18 | ||||
-rw-r--r-- | misc/win32/apr_app.c | 16 |
2 files changed, 28 insertions, 6 deletions
diff --git a/misc/unix/start.c b/misc/unix/start.c index bb8b05c1d..b0d8f9932 100644 --- a/misc/unix/start.c +++ b/misc/unix/start.c @@ -63,6 +63,20 @@ #include "internal_time.h" +#ifndef WIN32 +APR_DECLARE(apr_status_t) apr_app_main(int *argc, char ***argv, char ***env) +{ + /* An absolute noop. At present, only Win32 requires this stub, but it's + * required in order to move command arguments passed through the service + * control manager into the process, and it's required to fix the char* + * data passed in from local/wide codepage into utf-8, our internal fmt. + * + * Win32 declares it's implementation in misc/win32/apr_app.c + */ + return APR_SUCCESS; +} +#endif + static int initialized = 0; APR_DECLARE(apr_status_t) apr_initialize(void) @@ -108,7 +122,7 @@ APR_DECLARE(apr_status_t) apr_initialize(void) } #endif -#if defined WIN32 || defined(NETWARE) +#if defined(NETWARE) || defined(WIN32) iVersionRequested = MAKEWORD(WSAHighByte, WSALowByte); err = WSAStartup((WORD) iVersionRequested, &wsaData); if (err) { @@ -134,7 +148,7 @@ APR_DECLARE_NONSTD(void) apr_terminate(void) } apr_pool_terminate(); -#if defined(NETWARE) +#if defined(NETWARE) || defined(WIN32) WSACleanup(); #endif } diff --git a/misc/win32/apr_app.c b/misc/win32/apr_app.c index f7d29a4ef..1c691af59 100644 --- a/misc/win32/apr_app.c +++ b/misc/win32/apr_app.c @@ -143,6 +143,8 @@ static int wastrtoastr(char ***retarr, wchar_t **arr, int args) #ifdef APR_APP +/* This symbol is _private_, although it must be exported. + */ extern int APR_DECLARE_DATA apr_app_init_complete; extern int main(int argc, char **argv, char **env); @@ -181,6 +183,8 @@ int wmain(int argc, wchar_t **wargv, wchar_t **wenv) #else +/* This symbol is _private_, although it must be exported. + */ int APR_DECLARE_DATA apr_app_init_complete = 0; static int warrsztoastr(char ***retarr, wchar_t *arrsz, int args) @@ -260,11 +264,15 @@ APR_DECLARE(apr_status_t) apr_app_main(int *argc, char ***argv, char ***env) } sysstr = GetEnvironmentStringsW(); - dupenv = warrsztoastr(env, sysstr, -1); + dupenv = warrsztoastr(&_environ, sysstr, -1); - _environ = _malloc_dbg((dupenv + 1) * sizeof (char *), - _CRT_BLOCK, __FILE__, __LINE__ ); - memcpy(_environ, env, (dupenv + 1) * sizeof (char *)); + if (env) { + env = _malloc_dbg((dupenv + 1) * sizeof (char *), + _CRT_BLOCK, __FILE__, __LINE__ ); + memcpy(*env, _environ, (dupenv + 1) * sizeof (char *)); + } + else { + } /* MSVCRT will attempt to maintain the wide environment calls * on _putenv(), which is bogus if we've passed a non-ascii |