winex11: Create a global vulkan instance for xrandr.
[wine.git] / dlls / winecrt0 / exe_entry.c
blobdef7b57c38d5b4aae27da40be85e293f622722ed
1 /*
2 * Default entry point for an 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 /* this is actually part of a static lib linked into a .exe.so module, not a real Unix library */
26 #undef WINE_UNIX_LIB
28 #include <stdarg.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winternl.h"
33 extern int main( int argc, char *argv[] );
34 extern void __wine_init_so_dll(void);
36 static char **build_argv( const char *src, int *ret_argc )
38 char **argv, *arg, *dst;
39 int argc, in_quotes = 0, bcount = 0, len = strlen(src) + 1;
41 argc = 2 + len / 2;
42 argv = HeapAlloc( GetProcessHeap(), 0, argc * sizeof(*argv) + len );
43 arg = dst = (char *)(argv + argc);
44 argc = 0;
45 while (*src)
47 if ((*src == ' ' || *src == '\t') && !in_quotes)
49 /* skip the remaining spaces */
50 while (*src == ' ' || *src == '\t') src++;
51 if (!*src) break;
52 /* close the argument and copy it */
53 *dst++ = 0;
54 argv[argc++] = arg;
55 /* start with a new argument */
56 arg = dst;
57 bcount = 0;
59 else if (*src == '\\')
61 *dst++ = *src++;
62 bcount++;
64 else if (*src == '"')
66 if ((bcount & 1) == 0)
68 /* Preceded by an even number of '\', this is half that
69 * number of '\', plus a '"' which we discard.
71 dst -= bcount / 2;
72 src++;
73 if (in_quotes && *src == '"') *dst++ = *src++;
74 else in_quotes = !in_quotes;
76 else
78 /* Preceded by an odd number of '\', this is half that
79 * number of '\' followed by a '"'
81 dst -= bcount / 2 + 1;
82 *dst++ = *src++;
84 bcount = 0;
86 else /* a regular character */
88 *dst++ = *src++;
89 bcount = 0;
92 *dst = 0;
93 argv[argc++] = arg;
94 argv[argc] = NULL;
95 *ret_argc = argc;
96 return argv;
99 DWORD WINAPI __wine_spec_exe_entry( PEB *peb )
101 int argc;
102 char **argv = build_argv( GetCommandLineA(), &argc );
104 __wine_init_so_dll();
105 ExitProcess( main( argc, argv ));