38 |
HANDLE input_available = NULL; |
HANDLE input_available = NULL; |
39 |
HANDLE interrupt_handle = NULL; |
HANDLE interrupt_handle = NULL; |
40 |
|
|
41 |
void |
void |
42 |
init_crit () |
init_crit () |
43 |
{ |
{ |
44 |
InitializeCriticalSection (&critsect); |
InitializeCriticalSection (&critsect); |
56 |
interrupt_handle = CreateEvent (NULL, TRUE, FALSE, NULL); |
interrupt_handle = CreateEvent (NULL, TRUE, FALSE, NULL); |
57 |
} |
} |
58 |
|
|
59 |
void |
void |
60 |
delete_crit () |
delete_crit () |
61 |
{ |
{ |
62 |
DeleteCriticalSection (&critsect); |
DeleteCriticalSection (&critsect); |
160 |
int_msg *lpTail = NULL; |
int_msg *lpTail = NULL; |
161 |
int nQueue = 0; |
int nQueue = 0; |
162 |
|
|
163 |
BOOL |
BOOL |
164 |
get_next_msg (lpmsg, bWait) |
get_next_msg (lpmsg, bWait) |
165 |
W32Msg * lpmsg; |
W32Msg * lpmsg; |
166 |
BOOL bWait; |
BOOL bWait; |
167 |
{ |
{ |
168 |
BOOL bRet = FALSE; |
BOOL bRet = FALSE; |
169 |
|
|
170 |
enter_crit (); |
enter_crit (); |
171 |
|
|
172 |
/* The while loop takes care of multiple sets */ |
/* The while loop takes care of multiple sets */ |
173 |
|
|
174 |
while (!nQueue && bWait) |
while (!nQueue && bWait) |
175 |
{ |
{ |
176 |
leave_crit (); |
leave_crit (); |
177 |
WaitForSingleObject (input_available, INFINITE); |
WaitForSingleObject (input_available, INFINITE); |
178 |
enter_crit (); |
enter_crit (); |
179 |
} |
} |
180 |
|
|
181 |
if (nQueue) |
if (nQueue) |
182 |
{ |
{ |
183 |
bcopy (&(lpHead->w32msg), lpmsg, sizeof (W32Msg)); |
bcopy (&(lpHead->w32msg), lpmsg, sizeof (W32Msg)); |
184 |
|
|
185 |
{ |
{ |
186 |
int_msg * lpCur = lpHead; |
int_msg * lpCur = lpHead; |
187 |
|
|
188 |
lpHead = lpHead->lpNext; |
lpHead = lpHead->lpNext; |
189 |
|
|
190 |
myfree (lpCur); |
myfree (lpCur); |
191 |
} |
} |
192 |
|
|
197 |
|
|
198 |
if (nQueue == 0) |
if (nQueue == 0) |
199 |
ResetEvent (input_available); |
ResetEvent (input_available); |
200 |
|
|
201 |
leave_crit (); |
leave_crit (); |
202 |
|
|
203 |
return (bRet); |
return (bRet); |
204 |
} |
} |
205 |
|
|
206 |
BOOL |
BOOL |
207 |
post_msg (lpmsg) |
post_msg (lpmsg) |
208 |
W32Msg * lpmsg; |
W32Msg * lpmsg; |
209 |
{ |
{ |
221 |
{ |
{ |
222 |
lpTail->lpNext = lpNew; |
lpTail->lpNext = lpNew; |
223 |
} |
} |
224 |
else |
else |
225 |
{ |
{ |
226 |
lpHead = lpNew; |
lpHead = lpNew; |
227 |
} |
} |
228 |
|
|
229 |
lpTail = lpNew; |
lpTail = lpNew; |
230 |
SetEvent (input_available); |
SetEvent (input_available); |
231 |
|
|
232 |
leave_crit (); |
leave_crit (); |
233 |
|
|
234 |
return (TRUE); |
return (TRUE); |
277 |
* It returns a bitmask that indicates which of the four values |
* It returns a bitmask that indicates which of the four values |
278 |
* were actually found in the string. For each value found, |
* were actually found in the string. For each value found, |
279 |
* the corresponding argument is updated; for each value |
* the corresponding argument is updated; for each value |
280 |
* not found, the corresponding argument is left unchanged. |
* not found, the corresponding argument is left unchanged. |
281 |
*/ |
*/ |
282 |
|
|
283 |
static int |
static int |
287 |
{ |
{ |
288 |
register int Result = 0; |
register int Result = 0; |
289 |
int Sign = 1; |
int Sign = 1; |
290 |
|
|
291 |
if (*string == '+') |
if (*string == '+') |
292 |
string++; |
string++; |
293 |
else if (*string == '-') |
else if (*string == '-') |
306 |
return (-Result); |
return (-Result); |
307 |
} |
} |
308 |
|
|
309 |
int |
int |
310 |
XParseGeometry (string, x, y, width, height) |
XParseGeometry (string, x, y, width, height) |
311 |
char *string; |
char *string; |
312 |
int *x, *y; |
int *x, *y; |
317 |
unsigned int tempWidth, tempHeight; |
unsigned int tempWidth, tempHeight; |
318 |
int tempX, tempY; |
int tempX, tempY; |
319 |
char *nextCharacter; |
char *nextCharacter; |
320 |
|
|
321 |
if ((string == NULL) || (*string == '\0')) return (mask); |
if ((string == NULL) || (*string == '\0')) return (mask); |
322 |
if (*string == '=') |
if (*string == '=') |
323 |
string++; /* ignore possible '=' at beg of geometry spec */ |
string++; /* ignore possible '=' at beg of geometry spec */ |
324 |
|
|
325 |
strind = (char *)string; |
strind = (char *)string; |
326 |
if (*strind != '+' && *strind != '-' && *strind != 'x') |
if (*strind != '+' && *strind != '-' && *strind != 'x') |
327 |
{ |
{ |
328 |
tempWidth = read_integer (strind, &nextCharacter); |
tempWidth = read_integer (strind, &nextCharacter); |
329 |
if (strind == nextCharacter) |
if (strind == nextCharacter) |
330 |
return (0); |
return (0); |
331 |
strind = nextCharacter; |
strind = nextCharacter; |
332 |
mask |= WidthValue; |
mask |= WidthValue; |
333 |
} |
} |
334 |
|
|
335 |
if (*strind == 'x' || *strind == 'X') |
if (*strind == 'x' || *strind == 'X') |
336 |
{ |
{ |
337 |
strind++; |
strind++; |
338 |
tempHeight = read_integer (strind, &nextCharacter); |
tempHeight = read_integer (strind, &nextCharacter); |
339 |
if (strind == nextCharacter) |
if (strind == nextCharacter) |
341 |
strind = nextCharacter; |
strind = nextCharacter; |
342 |
mask |= HeightValue; |
mask |= HeightValue; |
343 |
} |
} |
344 |
|
|
345 |
if ((*strind == '+') || (*strind == '-')) |
if ((*strind == '+') || (*strind == '-')) |
346 |
{ |
{ |
347 |
if (*strind == '-') |
if (*strind == '-') |
348 |
{ |
{ |
349 |
strind++; |
strind++; |
350 |
tempX = -read_integer (strind, &nextCharacter); |
tempX = -read_integer (strind, &nextCharacter); |
355 |
|
|
356 |
} |
} |
357 |
else |
else |
358 |
{ |
{ |
359 |
strind++; |
strind++; |
360 |
tempX = read_integer (strind, &nextCharacter); |
tempX = read_integer (strind, &nextCharacter); |
361 |
if (strind == nextCharacter) |
if (strind == nextCharacter) |
363 |
strind = nextCharacter; |
strind = nextCharacter; |
364 |
} |
} |
365 |
mask |= XValue; |
mask |= XValue; |
366 |
if ((*strind == '+') || (*strind == '-')) |
if ((*strind == '+') || (*strind == '-')) |
367 |
{ |
{ |
368 |
if (*strind == '-') |
if (*strind == '-') |
369 |
{ |
{ |
370 |
strind++; |
strind++; |
371 |
tempY = -read_integer (strind, &nextCharacter); |
tempY = -read_integer (strind, &nextCharacter); |
386 |
mask |= YValue; |
mask |= YValue; |
387 |
} |
} |
388 |
} |
} |
389 |
|
|
390 |
/* If strind isn't at the end of the string the it's an invalid |
/* If strind isn't at the end of the string the it's an invalid |
391 |
geometry specification. */ |
geometry specification. */ |
392 |
|
|
393 |
if (*strind != '\0') return (0); |
if (*strind != '\0') return (0); |
394 |
|
|
395 |
if (mask & XValue) |
if (mask & XValue) |
396 |
*x = tempX; |
*x = tempX; |
397 |
if (mask & YValue) |
if (mask & YValue) |