Made nt-related types compatible, throw out wine-specific types.
[wine] / library / winestub.c
1 /* Sample winestub.c file for compiling programs with libwine.so. */
2
3 #include <string.h>
4 #include "windows.h"
5 #include "xmalloc.h"
6
7 extern int PASCAL WinMain(HINSTANCE32,HINSTANCE32,LPSTR,int);
8
9 /* external declaration here because we don't want to depend on Wine headers */
10 #ifdef __cplusplus
11 extern "C" HINSTANCE32 MAIN_WinelibInit( int *argc, char *argv[] );
12 #else
13 extern HINSTANCE32 MAIN_WinelibInit( int *argc, char *argv[] );
14 #endif
15
16 /* Most Windows C/C++ compilers use something like this to */
17 /* access argc and argv globally: */
18 int _ARGC;
19 char **_ARGV;
20
21 int main( int argc, char *argv [] )
22 {
23   HINSTANCE32 hInstance;
24   LPSTR lpszCmdParam;
25   int i, len = 0;
26   _ARGC = argc;
27   _ARGV = (char **)argv;
28
29   if (!(hInstance = MAIN_WinelibInit( &argc, argv ))) return 0;
30
31   /* Alloc szCmdParam */
32   for (i = 1; i < argc; i++) len += strlen(argv[i]) + 1;
33   lpszCmdParam = (LPSTR) xmalloc(len + 1);
34   /* Concatenate arguments */
35   if (argc > 1) strcpy(lpszCmdParam, argv[1]);
36   else lpszCmdParam[0] = '\0';
37   for (i = 2; i < argc; i++) strcat(strcat(lpszCmdParam, " "), argv[i]);
38
39   return WinMain (hInstance,    /* hInstance */
40                   0,            /* hPrevInstance */
41                   lpszCmdParam, /* lpszCmdParam */
42                   SW_NORMAL);   /* nCmdShow */
43 }