Use getpagesize() instead of VIRTUAL_GetPageSize().
[wine.git] / misc / main.c
blobc6d4e00662e4a16704d782390961da8c5a126e20
1 /*
2 * Main function.
4 * Copyright 1994 Alexandre Julliard
5 */
7 #include "config.h"
9 #include <locale.h>
10 #include <ctype.h>
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <string.h>
14 #include <unistd.h>
16 #include "windef.h"
17 #include "winbase.h"
18 #include "ntddk.h"
19 #include "winnls.h"
20 #include "winerror.h"
22 #include "winsock.h"
23 #include "heap.h"
24 #include "msdos.h"
25 #include "options.h"
26 #include "debugtools.h"
27 #include "module.h"
28 #include "tweak.h"
30 DECLARE_DEBUG_CHANNEL(file);
33 #if 0
34 /***********************************************************************
35 * MAIN_ParseDebugOptions
37 * Turns specific debug messages on or off, according to "options".
39 void MAIN_ParseDebugOptions( const char *arg )
41 /* defined in relay32/relay386.c */
42 extern char **debug_relay_includelist;
43 extern char **debug_relay_excludelist;
44 /* defined in relay32/snoop.c */
45 extern char **debug_snoop_includelist;
46 extern char **debug_snoop_excludelist;
48 int i;
49 int l, cls;
51 char *options = strdup(arg);
53 l = strlen(options);
54 if (l<2) goto error;
56 if (options[l-1]=='\n') options[l-1]='\0';
59 if ((*options!='+')&&(*options!='-')){
60 int j;
62 for(j=0; j<DEBUG_CLASS_COUNT; j++)
63 if(!strncasecmp(options, debug_cl_name[j], strlen(debug_cl_name[j])))
64 break;
65 if(j==DEBUG_CLASS_COUNT)
66 goto error;
67 options += strlen(debug_cl_name[j]);
68 if ((*options!='+')&&(*options!='-'))
69 goto error;
70 cls = j;
72 else
73 cls = -1; /* all classes */
75 if (strchr(options,','))
76 l=strchr(options,',')-options;
77 else
78 l=strlen(options);
80 if (!strncasecmp(options+1,"all",l-1))
82 int i, j;
83 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
84 for(j=0; j<DEBUG_CLASS_COUNT; j++)
85 if(cls == -1 || cls == j)
86 __SET_DEBUGGING( j, debug_channels[i], (*options=='+') );
88 else if (!strncasecmp(options+1, "relay=", 6) ||
89 !strncasecmp(options+1, "snoop=", 6))
91 int i, j;
92 char *s, *s2, ***output, c;
94 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
95 if (!strncasecmp( debug_channels[i] + 1, options + 1, 5))
97 for(j=0; j<DEBUG_CLASS_COUNT; j++)
98 if(cls == -1 || cls == j)
99 __SET_DEBUGGING( j, debug_channels[i], 1 );
100 break;
102 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
103 if (i==DEBUG_CHANNEL_COUNT)
104 goto error;
105 output = (*options == '+') ?
106 ((*(options+1) == 'r') ?
107 &debug_relay_includelist :
108 &debug_snoop_includelist) :
109 ((*(options+1) == 'r') ?
110 &debug_relay_excludelist :
111 &debug_snoop_excludelist);
112 s = options + 7;
113 /* if there are n ':', there are n+1 modules, and we need n+2 slots
114 * last one being for the sentinel (NULL) */
115 i = 2;
116 while((s = strchr(s, ':'))) i++, s++;
117 *output = malloc(sizeof(char **) * i);
118 i = 0;
119 s = options + 7;
120 while((s2 = strchr(s, ':'))) {
121 c = *s2;
122 *s2 = '\0';
123 *((*output)+i) = _strupr(strdup(s));
124 *s2 = c;
125 s = s2 + 1;
126 i++;
128 c = *(options + l);
129 *(options + l) = '\0';
130 *((*output)+i) = _strupr(strdup(s));
131 *(options + l) = c;
132 *((*output)+i+1) = NULL;
134 else
136 int i, j;
137 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
138 if (!strncasecmp( debug_channels[i] + 1, options + 1, l - 1) && !debug_channels[i][l])
140 for(j=0; j<DEBUG_CLASS_COUNT; j++)
141 if(cls == -1 || cls == j)
142 __SET_DEBUGGING( j, debug_channels[i], (*options=='+') );
143 break;
145 if (i==DEBUG_CHANNEL_COUNT)
146 goto error;
148 options+=l;
150 while((*options==',')&&(*(++options)));
152 if (!*options) return;
154 error:
155 MESSAGE("%s: Syntax: --debugmsg [class]+xxx,... or "
156 "--debugmsg [class]-xxx,...\n",argv0);
157 MESSAGE("Example: --debugmsg +all,warn-heap\n"
158 " turn on all messages except warning heap messages\n");
159 MESSAGE("Special case: --debugmsg +relay=DLL:DLL.###:FuncName\n"
160 " turn on --debugmsg +relay only as specified\n"
161 "Special case: --debugmsg -relay=DLL:DLL.###:FuncName\n"
162 " turn on --debugmsg +relay except as specified\n"
163 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
165 MESSAGE("Available message classes:\n");
166 for(i=0;i<DEBUG_CLASS_COUNT;i++)
167 MESSAGE( "%-9s", debug_cl_name[i]);
168 MESSAGE("\n\n");
170 MESSAGE("Available message types:\n");
171 MESSAGE("%-9s ","all");
172 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
173 MESSAGE("%-9s%c",debug_channels[i] + 1,
174 (((i+2)%8==0)?'\n':' '));
175 MESSAGE("\n\n");
176 ExitProcess(1);
178 #endif
180 /***********************************************************************
181 * Beep (KERNEL32.11)
183 BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur )
185 static char beep = '\a';
186 /* dwFreq and dwDur are ignored by Win95 */
187 if (isatty(2)) write( 2, &beep, 1 );
188 return TRUE;
192 /***********************************************************************
193 * FileCDR (KERNEL.130)
195 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
197 FIXME_(file)("(0x%8x): stub\n", (int) x);
198 return (FARPROC16)TRUE;
201 /***********************************************************************
202 * GetTickCount (USER.13) (KERNEL32.299)
204 * Returns the number of milliseconds, modulo 2^32, since the start
205 * of the wineserver.
207 DWORD WINAPI GetTickCount(void)
209 struct timeval t;
210 gettimeofday( &t, NULL );
211 return ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - server_startticks;