4 * Copyright 1994 Alexandre Julliard
26 #include "debugtools.h"
30 DECLARE_DEBUG_CHANNEL(file
);
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
;
51 char *options
= strdup(arg
);
56 if (options
[l
-1]=='\n') options
[l
-1]='\0';
59 if ((*options
!='+')&&(*options
!='-')){
62 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
63 if(!strncasecmp(options
, debug_cl_name
[j
], strlen(debug_cl_name
[j
])))
65 if(j
==DEBUG_CLASS_COUNT
)
67 options
+= strlen(debug_cl_name
[j
]);
68 if ((*options
!='+')&&(*options
!='-'))
73 cls
= -1; /* all classes */
75 if (strchr(options
,','))
76 l
=strchr(options
,',')-options
;
80 if (!strncasecmp(options
+1,"all",l
-1))
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))
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 );
102 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
103 if (i
==DEBUG_CHANNEL_COUNT
)
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
);
113 /* if there are n ':', there are n+1 modules, and we need n+2 slots
114 * last one being for the sentinel (NULL) */
116 while((s
= strchr(s
, ':'))) i
++, s
++;
117 *output
= malloc(sizeof(char **) * i
);
120 while((s2
= strchr(s
, ':'))) {
123 *((*output
)+i
) = _strupr(strdup(s
));
129 *(options
+ l
) = '\0';
130 *((*output
)+i
) = _strupr(strdup(s
));
132 *((*output
)+i
+1) = NULL
;
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
=='+') );
145 if (i
==DEBUG_CHANNEL_COUNT
)
150 while((*options
==',')&&(*(++options
)));
152 if (!*options
) return;
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
]);
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':' '));
180 /***********************************************************************
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 );
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
207 DWORD WINAPI
GetTickCount(void)
210 gettimeofday( &t
, NULL
);
211 return ((t
.tv_sec
* 1000) + (t
.tv_usec
/ 1000)) - server_startticks
;