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
30 extern int main( int argc
, char *argv
[] );
32 static char **build_argv( const char *src
, int *ret_argc
)
34 char **argv
, *arg
, *dst
;
35 int argc
, in_quotes
= 0, bcount
= 0, len
= strlen(src
) + 1;
38 argv
= HeapAlloc( GetProcessHeap(), 0, argc
* sizeof(*argv
) + len
);
39 arg
= dst
= (char *)(argv
+ argc
);
43 if ((*src
== ' ' || *src
== '\t') && !in_quotes
)
45 /* skip the remaining spaces */
46 while (*src
== ' ' || *src
== '\t') src
++;
48 /* close the argument and copy it */
51 /* start with a new argument */
55 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.
69 if (in_quotes
&& *src
== '"') *dst
++ = *src
++;
70 else in_quotes
= !in_quotes
;
74 /* Preceded by an odd number of '\', this is half that
75 * number of '\' followed by a '"'
77 dst
-= bcount
/ 2 + 1;
82 else /* a regular character */
95 DWORD WINAPI DECLSPEC_HIDDEN
__wine_spec_exe_entry( PEB
*peb
)
98 char **argv
= build_argv( GetCommandLineA(), &argc
);
100 ExitProcess( main( argc
, argv
));