4 * Copyright 1994 Alexandre Julliard
15 #ifdef MALLOC_DEBUGGING
29 #include "debugtools.h"
33 DECLARE_DEBUG_CHANNEL(file);
37 /***********************************************************************
38 * MAIN_ParseDebugOptions
40 * Turns specific debug messages on or off, according to "options".
42 void MAIN_ParseDebugOptions( const char *arg )
44 /* defined in relay32/relay386.c */
45 extern char **debug_relay_includelist;
46 extern char **debug_relay_excludelist;
47 /* defined in relay32/snoop.c */
48 extern char **debug_snoop_includelist;
49 extern char **debug_snoop_excludelist;
54 char *options = strdup(arg);
59 if (options[l-1]=='\n') options[l-1]='\0';
62 if ((*options!='+')&&(*options!='-')){
65 for(j=0; j<DEBUG_CLASS_COUNT; j++)
66 if(!strncasecmp(options, debug_cl_name[j], strlen(debug_cl_name[j])))
68 if(j==DEBUG_CLASS_COUNT)
70 options += strlen(debug_cl_name[j]);
71 if ((*options!='+')&&(*options!='-'))
76 cls = -1; /* all classes */
78 if (strchr(options,','))
79 l=strchr(options,',')-options;
83 if (!strncasecmp(options+1,"all",l-1))
86 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
87 for(j=0; j<DEBUG_CLASS_COUNT; j++)
88 if(cls == -1 || cls == j)
89 __SET_DEBUGGING( j, debug_channels[i], (*options=='+') );
91 else if (!strncasecmp(options+1, "relay=", 6) ||
92 !strncasecmp(options+1, "snoop=", 6))
95 char *s, *s2, ***output, c;
97 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
98 if (!strncasecmp( debug_channels[i] + 1, options + 1, 5))
100 for(j=0; j<DEBUG_CLASS_COUNT; j++)
101 if(cls == -1 || cls == j)
102 __SET_DEBUGGING( j, debug_channels[i], 1 );
105 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
106 if (i==DEBUG_CHANNEL_COUNT)
108 output = (*options == '+') ?
109 ((*(options+1) == 'r') ?
110 &debug_relay_includelist :
111 &debug_snoop_includelist) :
112 ((*(options+1) == 'r') ?
113 &debug_relay_excludelist :
114 &debug_snoop_excludelist);
116 /* if there are n ':', there are n+1 modules, and we need n+2 slots
117 * last one being for the sentinel (NULL) */
119 while((s = strchr(s, ':'))) i++, s++;
120 *output = malloc(sizeof(char **) * i);
123 while((s2 = strchr(s, ':'))) {
126 *((*output)+i) = _strupr(strdup(s));
132 *(options + l) = '\0';
133 *((*output)+i) = _strupr(strdup(s));
135 *((*output)+i+1) = NULL;
140 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
141 if (!strncasecmp( debug_channels[i] + 1, options + 1, l - 1) && !debug_channels[i][l])
143 for(j=0; j<DEBUG_CLASS_COUNT; j++)
144 if(cls == -1 || cls == j)
145 __SET_DEBUGGING( j, debug_channels[i], (*options=='+') );
148 if (i==DEBUG_CHANNEL_COUNT)
153 while((*options==',')&&(*(++options)));
155 if (!*options) return;
158 MESSAGE("%s: Syntax: --debugmsg [class]+xxx,... or "
159 "-debugmsg [class]-xxx,...\n",argv0);
160 MESSAGE("Example: --debugmsg +all,warn-heap\n"
161 " turn on all messages except warning heap messages\n");
162 MESSAGE("Special case: --debugmsg +relay=DLL:DLL.###:FuncName\n"
163 " turn on -debugmsg +relay only as specified\n"
164 "Special case: --debugmsg -relay=DLL:DLL.###:FuncName\n"
165 " turn on --debugmsg +relay except as specified\n"
166 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
168 MESSAGE("Available message classes:\n");
169 for(i=0;i<DEBUG_CLASS_COUNT;i++)
170 MESSAGE( "%-9s", debug_cl_name[i]);
173 MESSAGE("Available message types:\n");
174 MESSAGE("%-9s ","all");
175 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
176 MESSAGE("%-9s%c",debug_channels[i] + 1,
177 (((i+2)%8==0)?'\n':' '));
183 /***********************************************************************
186 * Wine initialisation
188 void MAIN_WineInit(void)
190 #ifdef MALLOC_DEBUGGING
194 if (!(trace = getenv("MALLOC_TRACE")))
196 MESSAGE( "MALLOC_TRACE not set. No trace generated\n" );
200 MESSAGE( "malloc trace goes to %s\n", trace );
207 setlocale(LC_CTYPE,"");
210 /***********************************************************************
213 BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur )
215 static char beep = '\a';
216 /* dwFreq and dwDur are ignored by Win95 */
217 if (isatty(2)) write( 2, &beep, 1 );
222 /***********************************************************************
223 * FileCDR (KERNEL.130)
225 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
227 FIXME_(file)("(0x%8x): stub\n", (int) x);
228 return (FARPROC16)TRUE;
231 /***********************************************************************
232 * GetTickCount (USER.13) (KERNEL32.299)
234 * Returns the number of milliseconds, modulo 2^32, since the start
237 DWORD WINAPI GetTickCount(void)
240 gettimeofday( &t, NULL );
241 return ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - server_startticks;