Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 32111 invoked by uid 500); 30 Jan 2002 06:42:56 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 32100 invoked from network); 30 Jan 2002 06:42:56 -0000 Date: 30 Jan 2002 06:42:55 -0000 Message-ID: <20020130064255.5153.qmail@icarus.apache.org> From: wrowe@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/misc/win32 apr_app.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N wrowe 02/01/29 22:42:55 Modified: include apr_general.h misc/unix start.c misc/win32 apr_app.c Log: Introduce apr_app_main() for global consumption. Revision Changes Path 1.63 +10 -0 apr/include/apr_general.h Index: apr_general.h =================================================================== RCS file: /home/cvs/apr/include/apr_general.h,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- apr_general.h 11 Dec 2001 19:40:50 -0000 1.62 +++ apr_general.h 30 Jan 2002 06:42:54 -0000 1.63 @@ -185,6 +185,16 @@ */ APR_DECLARE(void) apr_terminate2(void); +/** + * Set up an application with normalized argc, argv (and optionally env) in + * order to deal with platform-specific oddities, such as Win32 services, + * code pages and signals. + * @remark An APR program should invoke apr_app_main immediately following + * apr_initialize, so it behaves properly as a service on Win32 with respect + * to its Unicode (utf-8) code page, services and signals. + */ +APR_DECLARE(apr_status_t) apr_app_main(int *argc, char ***argv, char ***env); + /** @} */ /** 1.60 +16 -2 apr/misc/unix/start.c Index: start.c =================================================================== RCS file: /home/cvs/apr/misc/unix/start.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- start.c 13 Jan 2002 02:12:25 -0000 1.59 +++ start.c 30 Jan 2002 06:42:55 -0000 1.60 @@ -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 @@ } #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_pool_terminate(); -#if defined(NETWARE) +#if defined(NETWARE) || defined(WIN32) WSACleanup(); #endif } 1.9 +12 -4 apr/misc/win32/apr_app.c Index: apr_app.c =================================================================== RCS file: /home/cvs/apr/misc/win32/apr_app.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- apr_app.c 30 Jan 2002 05:26:43 -0000 1.8 +++ apr_app.c 30 Jan 2002 06:42:55 -0000 1.9 @@ -143,6 +143,8 @@ #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 @@ #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 @@ } 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