mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / winecrt0 / exe_wentry.c
bloba4c1a0897fbc8bc78f339c0c3eff966c92de1700
1 /*
2 * Default entry point for a Unicode exe
4 * Copyright 2005 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #if 0
22 #pragma makedep unix
23 #endif
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winternl.h"
30 extern int wmain( int argc, WCHAR *argv[] );
32 static WCHAR **build_argv( const WCHAR *src, int *ret_argc )
34 WCHAR **argv, *arg, *dst;
35 int argc, in_quotes = 0, bcount = 0, len = lstrlenW(src) + 1;
37 argc = 2 + len / 2;
38 argv = HeapAlloc( GetProcessHeap(), 0, argc * sizeof(*argv) + len * sizeof(WCHAR) );
39 arg = dst = (WCHAR *)(argv + argc);
40 argc = 0;
41 while (*src)
43 if ((*src == ' ' || *src == '\t') && !in_quotes)
45 /* skip the remaining spaces */
46 while (*src == ' ' || *src == '\t') src++;
47 if (!*src) break;
48 /* close the argument and copy it */
49 *dst++ = 0;
50 argv[argc++] = arg;
51 /* start with a new argument */
52 arg = dst;
53 bcount = 0;
55 else if (*src == '\\')
57 *dst++ = *src++;
58 bcount++;
60 else if (*src == '"')
62 if ((bcount & 1) == 0)
64 /* Preceded by an even number of '\', this is half that
65 * number of '\', plus a '"' which we discard.
67 dst -= bcount / 2;
68 src++;
69 if (in_quotes && *src == '"') *dst++ = *src++;
70 else in_quotes = !in_quotes;
72 else
74 /* Preceded by an odd number of '\', this is half that
75 * number of '\' followed by a '"'
77 dst -= bcount / 2 + 1;
78 *dst++ = *src++;
80 bcount = 0;
82 else /* a regular character */
84 *dst++ = *src++;
85 bcount = 0;
88 *dst = 0;
89 argv[argc++] = arg;
90 argv[argc] = NULL;
91 *ret_argc = argc;
92 return argv;
95 DWORD WINAPI DECLSPEC_HIDDEN __wine_spec_exe_wentry( PEB *peb )
97 int argc;
98 WCHAR **argv = build_argv( GetCommandLineW(), &argc );
100 ExitProcess( wmain( argc, argv ));