4 * Copyright 1994 Alexandre Julliard
15 #ifdef MALLOC_DEBUGGING
29 #include "debugtools.h"
30 #include "debugdefs.h"
35 /***********************************************************************
36 * MAIN_ParseDebugOptions
38 * Turns specific debug messages on or off, according to "options".
40 void MAIN_ParseDebugOptions( const char *arg
)
42 /* defined in relay32/relay386.c */
43 extern char **debug_relay_includelist
;
44 extern char **debug_relay_excludelist
;
45 /* defined in relay32/snoop.c */
46 extern char **debug_snoop_includelist
;
47 extern char **debug_snoop_excludelist
;
52 char *options
= strdup(arg
);
57 if (options
[l
-1]=='\n') options
[l
-1]='\0';
60 if ((*options
!='+')&&(*options
!='-')){
63 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
64 if(!strncasecmp(options
, debug_cl_name
[j
], strlen(debug_cl_name
[j
])))
66 if(j
==DEBUG_CLASS_COUNT
)
68 options
+= strlen(debug_cl_name
[j
]);
69 if ((*options
!='+')&&(*options
!='-'))
74 cls
= -1; /* all classes */
76 if (strchr(options
,','))
77 l
=strchr(options
,',')-options
;
81 if (!strncasecmp(options
+1,"all",l
-1))
84 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
85 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
86 if(cls
== -1 || cls
== j
)
87 __SET_DEBUGGING( j
, debug_channels
[i
], (*options
=='+') );
89 else if (!strncasecmp(options
+1, "relay=", 6) ||
90 !strncasecmp(options
+1, "snoop=", 6))
93 char *s
, *s2
, ***output
, c
;
95 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
96 if (!strncasecmp( debug_channels
[i
] + 1, options
+ 1, 5))
98 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
99 if(cls
== -1 || cls
== j
)
100 __SET_DEBUGGING( j
, debug_channels
[i
], 1 );
103 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
104 if (i
==DEBUG_CHANNEL_COUNT
)
106 output
= (*options
== '+') ?
107 ((*(options
+1) == 'r') ?
108 &debug_relay_includelist
:
109 &debug_snoop_includelist
) :
110 ((*(options
+1) == 'r') ?
111 &debug_relay_excludelist
:
112 &debug_snoop_excludelist
);
114 /* if there are n ':', there are n+1 modules, and we need n+2 slots
115 * last one being for the sentinel (NULL) */
117 while((s
= strchr(s
, ':'))) i
++, s
++;
118 *output
= malloc(sizeof(char **) * i
);
121 while((s2
= strchr(s
, ':'))) {
124 *((*output
)+i
) = _strupr(strdup(s
));
130 *(options
+ l
) = '\0';
131 *((*output
)+i
) = _strupr(strdup(s
));
133 *((*output
)+i
+1) = NULL
;
138 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
139 if (!strncasecmp( debug_channels
[i
] + 1, options
+ 1, l
- 1) && !debug_channels
[i
][l
])
141 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
142 if(cls
== -1 || cls
== j
)
143 __SET_DEBUGGING( j
, debug_channels
[i
], (*options
=='+') );
146 if (i
==DEBUG_CHANNEL_COUNT
)
151 while((*options
==',')&&(*(++options
)));
153 if (!*options
) return;
156 MESSAGE("%s: Syntax: --debugmsg [class]+xxx,... or "
157 "-debugmsg [class]-xxx,...\n",argv0
);
158 MESSAGE("Example: --debugmsg +all,warn-heap\n"
159 " turn on all messages except warning heap messages\n");
160 MESSAGE("Special case: --debugmsg +relay=DLL:DLL.###:FuncName\n"
161 " turn on -debugmsg +relay only as specified\n"
162 "Special case: --debugmsg -relay=DLL:DLL.###:FuncName\n"
163 " turn on --debugmsg +relay except as specified\n"
164 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
166 MESSAGE("Available message classes:\n");
167 for(i
=0;i
<DEBUG_CLASS_COUNT
;i
++)
168 MESSAGE( "%-9s", debug_cl_name
[i
]);
171 MESSAGE("Available message types:\n");
172 MESSAGE("%-9s ","all");
173 for(i
=0;i
<DEBUG_CHANNEL_COUNT
;i
++)
174 MESSAGE("%-9s%c",debug_channels
[i
] + 1,
175 (((i
+2)%8==0)?'\n':' '));
180 /***********************************************************************
183 * Wine initialisation
185 void MAIN_WineInit(void)
187 #ifdef MALLOC_DEBUGGING
191 if (!(trace
= getenv("MALLOC_TRACE")))
193 MESSAGE( "MALLOC_TRACE not set. No trace generated\n" );
197 MESSAGE( "malloc trace goes to %s\n", trace
);
204 setlocale(LC_CTYPE
,"");
207 /***********************************************************************
210 BOOL WINAPI
Beep( DWORD dwFreq
, DWORD dwDur
)
212 static char beep
= '\a';
213 /* dwFreq and dwDur are ignored by Win95 */
214 if (isatty(2)) write( 2, &beep
, 1 );
219 /***********************************************************************
220 * FileCDR (KERNEL.130)
222 FARPROC16 WINAPI
FileCDR16(FARPROC16 x
)
224 FIXME_(file
)("(0x%8x): stub\n", (int) x
);
225 return (FARPROC16
)TRUE
;
228 /***********************************************************************
229 * GetTickCount (USER.13) (KERNEL32.299)
231 * Returns the number of milliseconds, modulo 2^32, since the start
234 DWORD WINAPI
GetTickCount(void)
237 gettimeofday( &t
, NULL
);
238 return ((t
.tv_sec
* 1000) + (t
.tv_usec
/ 1000)) - server_startticks
;