Take care of one BSOD in NtGdiDdCreateDirectDrawObject, it is not correct fix, it...
[reactos.git] / rosapps / sysutils / wmain.c
1 /* $Id$
2 *
3 * Entry point for programs that use wmain()
4 */
5 #include <stdio.h>
6 #include <stdarg.h>
7
8 #include <windef.h>
9 #include <winbase.h>
10
11 int wmain(int argc,wchar_t *argv[]);
12
13 wchar_t *
14 a2w( char * a, wchar_t * w )
15 {
16 wchar_t * ww = w;
17 while (*a) *w++ = (wchar_t) *a++;
18 *w = 0;
19 return ww;
20 }
21
22 wchar_t *
23 fgetws(wchar_t *buf, int bufsize, FILE *file)
24 {
25 char * abuf = GlobalAlloc(bufsize,0);
26 if (!buf)return NULL;
27 fgets(abuf,bufsize,file);
28 a2w(abuf,buf);
29 GlobalFree(abuf);
30 return buf;
31 }
32
33 int main(int argc, char *argv[])
34 {
35 wchar_t ** wargv;
36 int i;
37 int ec;
38
39 wargv = (wchar_t **) GlobalAlloc(
40 sizeof(void*) * argc,
41 0
42 );
43 for(i=0;i<argc;++i)
44 {
45 wargv[i] = (wchar_t*) GlobalAlloc(
46 sizeof(wchar_t) * (1+lstrlenA(argv[i])),
47 0
48 );
49 a2w(argv[i],wargv[i]);
50 }
51 wargv[i] = NULL;
52 ec = wmain(argc,wargv);
53 for (i=0;wargv[i];++i) GlobalFree(wargv[i]);
54 return ec;
55 }