6 static char ** argvToAnsi( wchar_t ** wargv, int argc )
\r
8 char ** argv = malloc( sizeof( *argv ) * argc );
\r
9 for ( int i = 0; i != argc; ++i ) {
\r
10 int sz = WideCharToMultiByte( CP_ACP, WC_COMPOSITECHECK | WC_SEPCHARS,
\r
11 wargv[i], -1, NULL, 0, NULL, NULL );
\r
12 if(!(argv[i] = malloc(sz))) {
\r
13 fputs("Error in C runtime initialization: "
\r
14 "unable to allocate buffer for argument", stderr);
\r
18 int rv = WideCharToMultiByte( CP_ACP, WC_COMPOSITECHECK | WC_SEPCHARS,
\r
19 wargv[i], -1, argv[i], sz, NULL, NULL );
\r
22 fputs("Error in C runtime initialization: "
\r
23 "size mismatch during character set conversion", stderr);
\r
30 static wchar_t * cl;
\r
31 static wchar_t ** wargv;
\r
32 static char ** argv;
\r
34 static void freeArgs( void )
\r
36 for(int i = 0; i != argc; i++) {
\r
43 extern int main( int argc, char ** argv, char ** envp );
\r
44 _PDCLIB_noreturn void mainCRTStartup( void )
\r
46 stdin->handle = GetStdHandle(STD_INPUT_HANDLE);
\r
47 stdout->handle = GetStdHandle(STD_OUTPUT_HANDLE);
\r
48 stderr->handle = GetStdHandle(STD_ERROR_HANDLE);
\r
50 cl = GetCommandLineW();
\r
51 wargv = CommandLineToArgvW(cl, &argc);
\r
52 argv = argvToAnsi(wargv, argc);
\r
55 int exitStatus = main(argc, argv, NULL);
\r