comparison winmain.c @ 1802:aedf5903db0a

Add DW_FCF_TEXTURED window style; relevant only for Mac port. Remove NSTexturedBackgroundWindowMask from style in dw_window_new. Add Copyright notice to winmain.c.
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 27 Sep 2012 05:09:10 +0000
parents 32b5fba0b00a
children 05dd5189099f
comparison
equal deleted inserted replaced
1801:889f8d47761c 1802:aedf5903db0a
1 /* Dynamic Windows stub file to allow Win32 applications 1 /* Dynamic Windows stub file to allow Win32 applications
2 * to use the main() entry point instead of WinMain(). 2 * to use the main() entry point instead of WinMain().
3 *
4 * (C) 2000-2012 Brian Smith <brian@dbsoft.org>
3 */ 5 */
4 6
5 #include <windows.h> 7 #include <windows.h>
6 #include <stdlib.h> 8 #include <stdlib.h>
7 #include <string.h> 9 #include <string.h>
12 void Win32_Set_Instance(HINSTANCE hInstance); 14 void Win32_Set_Instance(HINSTANCE hInstance);
13 #endif 15 #endif
14 16
15 char **_convertargs(int *count, char *start, HINSTANCE DWInstance) 17 char **_convertargs(int *count, char *start, HINSTANCE DWInstance)
16 { 18 {
17 char *tmp, *argstart, **argv; 19 char *tmp, *argstart, **argv;
18 int loc = 0, inquotes = 0; 20 int loc = 0, inquotes = 0;
19 21
20 (*count) = 1; 22 (*count) = 1;
21 23
22 tmp = start; 24 tmp = start;
23 25
24 /* Count the number of entries */ 26 /* Count the number of entries */
25 if(*start) 27 if(*start)
26 { 28 {
27 (*count)++; 29 (*count)++;
28 30
29 while(*tmp) 31 while(*tmp)
30 { 32 {
31 if(*tmp == '"' && inquotes) 33 if(*tmp == '"' && inquotes)
32 inquotes = 0; 34 inquotes = 0;
33 else if(*tmp == '"' && !inquotes) 35 else if(*tmp == '"' && !inquotes)
34 inquotes = 1; 36 inquotes = 1;
35 else if(*tmp == ' ' && !inquotes) 37 else if(*tmp == ' ' && !inquotes)
36 { 38 {
37 /* Push past any white space */ 39 /* Push past any white space */
38 while(*(tmp+1) == ' ') 40 while(*(tmp+1) == ' ')
39 tmp++; 41 tmp++;
40 /* If we aren't at the end of the command 42 /* If we aren't at the end of the command
41 * line increment the count. 43 * line increment the count.
42 */ 44 */
43 if(*(tmp+1)) 45 if(*(tmp+1))
44 (*count)++; 46 (*count)++;
45 } 47 }
46 tmp++; 48 tmp++;
47 } 49 }
48 } 50 }
49 51
50 argv = (char **)malloc(sizeof(char *) * ((*count)+1)); 52 argv = (char **)malloc(sizeof(char *) * ((*count)+1));
51 argv[0] = malloc(260); 53 argv[0] = malloc(260);
52 GetModuleFileNameA(DWInstance, argv[0], 260); 54 GetModuleFileNameA(DWInstance, argv[0], 260);
53 55
54 argstart = tmp = start; 56 argstart = tmp = start;
55 57
56 if(*start) 58 if(*start)
57 { 59 {
58 loc = 1; 60 loc = 1;
59 61
60 while(*tmp) 62 while(*tmp)
61 { 63 {
62 if(*tmp == '"' && inquotes) 64 if(*tmp == '"' && inquotes)
63 { 65 {
64 *tmp = 0; 66 *tmp = 0;
65 inquotes = 0; 67 inquotes = 0;
66 } 68 }
67 else if(*tmp == '"' && !inquotes) 69 else if(*tmp == '"' && !inquotes)
68 { 70 {
69 argstart = tmp+1; 71 argstart = tmp+1;
70 inquotes = 1; 72 inquotes = 1;
71 } 73 }
72 else if(*tmp == ' ' && !inquotes) 74 else if(*tmp == ' ' && !inquotes)
73 { 75 {
74 *tmp = 0; 76 *tmp = 0;
75 argv[loc] = strdup(argstart); 77 argv[loc] = strdup(argstart);
76 78
77 /* Push past any white space */ 79 /* Push past any white space */
78 while(*(tmp+1) == ' ') 80 while(*(tmp+1) == ' ')
79 tmp++; 81 tmp++;
80 82
81 /* Move the start pointer */ 83 /* Move the start pointer */
82 argstart = tmp+1; 84 argstart = tmp+1;
83 85
84 /* If we aren't at the end of the command 86 /* If we aren't at the end of the command
85 * line increment the count. 87 * line increment the count.
86 */ 88 */
87 if(*(tmp+1)) 89 if(*(tmp+1))
88 loc++; 90 loc++;
89 } 91 }
90 tmp++; 92 tmp++;
91 } 93 }
92 if(*argstart) 94 if(*argstart)
93 argv[loc] = strdup(argstart); 95 argv[loc] = strdup(argstart);
94 } 96 }
95 argv[loc+1] = NULL; 97 argv[loc+1] = NULL;
96 return argv; 98 return argv;
97 } 99 }
98 100
99 /* Ok this is a really big hack but what the hell ;) */ 101 /* Ok this is a really big hack but what the hell ;) */
100 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 102 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
101 { 103 {
102 char **argv; 104 char **argv;
103 int argc; 105 int argc;
104 106
105 #ifndef NODW 107 #ifndef NODW
106 Win32_Set_Instance(hInstance); 108 Win32_Set_Instance(hInstance);
107 #endif 109 #endif
108 110
109 argv = _convertargs(&argc, lpCmdLine, hInstance); 111 argv = _convertargs(&argc, lpCmdLine, hInstance);
110 112
111 return main(argc, argv); 113 return main(argc, argv);
112 } 114 }