1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
/* $Xorg: Error.c,v 1.4 2000/08/17 19:46:11 cpqbld Exp $ */
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or Sun not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* $XFree86: xc/lib/Xt/Error.c,v 3.11 2001/04/01 14:00:02 tsi Exp $ */
/*
Copyright 1987, 1988, 1998 The Open Group
All Rights Reserved.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
#include "IntrinsicI.h"
#include <stdio.h>
#include <stdlib.h>
/* The error handlers in the application context aren't used since we can't
come up with a uniform way of using them. If you can, define
GLOBALERRORS to be FALSE (or 0). */
#ifndef GLOBALERRORS
#define GLOBALERRORS 1
#endif
static void InitErrorHandling();
#if GLOBALERRORS
static XrmDatabase errorDB = NULL;
static Boolean error_inited = FALSE;
void _XtDefaultErrorMsg(), _XtDefaultWarningMsg(),
_XtDefaultError(), _XtDefaultWarning();
static XtErrorMsgHandler errorMsgHandler = _XtDefaultErrorMsg;
static XtErrorMsgHandler warningMsgHandler = _XtDefaultWarningMsg;
static XtErrorHandler errorHandler = _XtDefaultError;
static XtErrorHandler warningHandler = _XtDefaultWarning;
#endif /* GLOBALERRORS */
XrmDatabase *XtGetErrorDatabase()
{
XrmDatabase* retval;
#if GLOBALERRORS
LOCK_PROCESS;
retval = &errorDB;
UNLOCK_PROCESS;
#else
retval = XtAppGetErrorDatabase(_XtDefaultAppContext());
#endif /* GLOBALERRORS */
return retval;
}
XrmDatabase *XtAppGetErrorDatabase(app)
XtAppContext app;
{
XrmDatabase* retval;
#if GLOBALERRORS
LOCK_PROCESS;
retval = &errorDB;
UNLOCK_PROCESS;
#else
LOCK_APP(app);
retval= &app->errorDB;
UNLOCK_APP(app);
#endif /* GLOBALERRORS */
return retval;
}
#if NeedFunctionPrototypes
void XtGetErrorDatabaseText(
register _Xconst char* name,
register _Xconst char* type,
register _Xconst char* class,
_Xconst char* defaultp,
String buffer,
int nbytes
)
#else
void XtGetErrorDatabaseText(name,type,class,defaultp, buffer, nbytes)
register String name, type, class;
String defaultp;
String buffer;
int nbytes;
#endif
{
#if GLOBALERRORS
XtAppGetErrorDatabaseText(NULL,
name,type,class,defaultp, buffer, nbytes, NULL);
#else
XtAppGetErrorDatabaseText(_XtDefaultAppContext(),
name,type,class,defaultp, buffer, nbytes, NULL);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
void XtAppGetErrorDatabaseText(
XtAppContext app,
register _Xconst char* name,
register _Xconst char* type,
register _Xconst char* class,
_Xconst char* defaultp,
String buffer,
int nbytes,
XrmDatabase db
)
#else
void XtAppGetErrorDatabaseText(app, name,type,class,defaultp,
buffer, nbytes, db)
XtAppContext app;
register String name, type, class;
String defaultp;
String buffer;
int nbytes;
XrmDatabase db;
#endif
{
String str_class;
String type_str;
XrmValue result;
char *str_name = NULL;
char *temp = NULL;
#if GLOBALERRORS
LOCK_PROCESS;
if (error_inited == FALSE) {
InitErrorHandling (&errorDB);
error_inited = TRUE;
}
#else
LOCK_APP(app);
if (app->error_inited == FALSE) {
InitErrorHandling (&app->errorDB);
app->error_inited = TRUE;
}
#endif /* GLOBALERRORS */
if (!(str_name = ALLOCATE_LOCAL(strlen(name) + strlen(type) + 2)))
_XtAllocError(NULL);
(void) sprintf(str_name, "%s.%s", name, type);
/* XrmGetResource requires the name and class to be fully qualified
* and to have the same number of components. */
str_class = (char *)class;
if (! strchr(class, '.')) {
if (!(temp = ALLOCATE_LOCAL(2 * strlen(class) + 2)))
_XtAllocError(NULL);
(void) sprintf(temp, "%s.%s", class, class);
str_class = temp;
}
if (db == NULL) {
#if GLOBALERRORS
(void) XrmGetResource(errorDB, str_name, str_class, &type_str,
&result);
#else
(void) XrmGetResource(app->errorDB, str_name, str_class, &type_str,
&result);
#endif /* GLOBALERRORS */
} else (void) XrmGetResource(db, str_name, str_class, &type_str, &result);
if (result.addr) {
(void) strncpy (buffer, result.addr, nbytes);
if (result.size > nbytes) buffer[nbytes-1] = 0;
} else {
int len = strlen(defaultp);
if (len >= nbytes) len = nbytes-1;
(void) memmove(buffer, defaultp, len);
buffer[len] = '\0';
}
if (str_name)
DEALLOCATE_LOCAL(str_name);
if (temp)
DEALLOCATE_LOCAL(temp);
#if GLOBALERRORS
UNLOCK_PROCESS;
#else
UNLOCK_APP(app);
#endif
}
static void InitErrorHandling (db)
XrmDatabase *db;
{
XrmDatabase errordb;
errordb = XrmGetFileDatabase(ERRORDB);
XrmMergeDatabases(errordb, db);
}
static void DefaultMsg (name,type,class,defaultp,params,num_params,error,fn)
String name,type,class,defaultp;
String* params;
Cardinal* num_params;
Bool error;
void (*fn)(String);
{
#define BIGBUF 1024
#ifdef notyet /* older versions don't, might want to wait until more do */
#if defined(__linux__) || defined(CSRG_BASED) /* everyone else needs to get with the program */
#define USE_SNPRINTF
#endif
#endif
char buffer[BIGBUF];
char* message;
XtGetErrorDatabaseText(name,type,class,defaultp, buffer, BIGBUF);
/*need better solution here, perhaps use lower level printf primitives? */
if (params == NULL || num_params == NULL || *num_params == 0)
(*fn)(buffer);
#ifndef WIN32 /* and OS/2 */
else if ((getuid () != geteuid ()) || getuid() == 0) {
if ((error && errorHandler == _XtDefaultError) ||
(!error && warningHandler == _XtDefaultWarning)) {
/*
* if it's just going to go to stderr anyway, then we'll
* fprintf to stderr ourselves and skip the insecure sprintf.
*/
int i = *num_params;
String par[10];
if (i > 10) i = 10;
(void) memmove((char*)par, (char*)params, i * sizeof(String) );
bzero( &par[i], (10-i) * sizeof(String) );
(void) fprintf (stderr, "%s%s",
error ? XTERROR_PREFIX : XTWARNING_PREFIX,
error ? "Error: " : "Warning: ");
(void) fprintf (stderr, buffer,
par[0], par[1], par[2], par[3], par[4],
par[5], par[6], par[7], par[8], par[9]);
(void) fprintf (stderr, "%c", '\n');
if (i != *num_params)
(*fn) ( "Some arguments in previous message were lost" );
else if (error) exit (1);
} else {
/*
* can't tell what it might do, so we'll play it safe
*/
XtWarning ("\
This program is an suid-root program or is being run by the root user.\n\
The full text of the error or warning message cannot be safely formatted\n\
in this environment. You may get a more descriptive message by running the\n\
program as a non-root user or by removing the suid bit on the executable.");
(*fn)(buffer); /* if *fn is an ErrorHandler it should exit */
}
}
#endif
else {
/*
* If you have snprintf the worst thing that could happen is you'd
* lose some information. Without snprintf you're probably going to
* scramble your heap and perhaps SEGV -- sooner or later.
* If it hurts when you go like this then don't go like this! :-)
*/
int i = *num_params;
String par[10];
if (i > 10) i = 10;
(void) memmove((char*)par, (char*)params, i * sizeof(String) );
bzero( &par[i], (10-i) * sizeof(String) );
if (i != *num_params)
XtWarning( "Some arguments in following message were lost" );
/*
* resist any temptation you might have to make `message' a
* local buffer on the stack. Doing so is a security hole
* in programs executing as root. Error and Warning
* messages shouldn't be called frequently enough for this
* to be a performance issue.
*/
if ((message = __XtMalloc (BIGBUF))) {
#ifndef USE_SNPRINTF
message[BIGBUF-1] = 0;
(void) sprintf (message, buffer,
#else
(void) snprintf (message, BIGBUF, buffer,
#endif
par[0], par[1], par[2], par[3], par[4],
par[5], par[6], par[7], par[8], par[9]);
#ifndef USE_SNPRINTF
if (message[BIGBUF-1] != '\0')
XtWarning ("Possible heap corruption in Xt{Error,Warning}MsgHandler");
#endif
(*fn)(message);
XtFree(message);
} else {
XtWarning ("Memory allocation failed, arguments in the following message were lost");
(*fn)(buffer);
}
}
}
void _XtDefaultErrorMsg (name,type,class,defaultp,params,num_params)
String name,type,class,defaultp;
String* params;
Cardinal* num_params;
{
DefaultMsg (name,type,class,defaultp,params,num_params,True,XtError);
}
void _XtDefaultWarningMsg (name,type,class,defaultp,params,num_params)
String name,type,class,defaultp;
String* params;
Cardinal* num_params;
{
DefaultMsg (name,type,class,defaultp,params,num_params,False,XtWarning);
}
#if NeedFunctionPrototypes
void XtErrorMsg(
_Xconst char* name,
_Xconst char* type,
_Xconst char* class,
_Xconst char* defaultp,
String* params,
Cardinal* num_params
)
#else
void XtErrorMsg(name,type,class,defaultp,params,num_params)
String name,type,class,defaultp;
String* params;
Cardinal* num_params;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
(*errorMsgHandler)((String)name,(String)type,(String)class,
(String)defaultp,params,num_params);
UNLOCK_PROCESS;
#else
XtAppErrorMsg(_XtDefaultAppContext(),name,type,class,
defaultp,params,num_params);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
void XtAppErrorMsg(
XtAppContext app,
_Xconst char* name,
_Xconst char* type,
_Xconst char* class,
_Xconst char* defaultp,
String* params,
Cardinal* num_params
)
#else
void XtAppErrorMsg(app, name,type,class,defaultp,params,num_params)
XtAppContext app;
String name,type,class,defaultp;
String* params;
Cardinal* num_params;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
(*errorMsgHandler)((String)name,(String)type,(String)class,
(String)defaultp,params,num_params);
UNLOCK_PROCESS;
#else
LOCK_APP(app);
(*app->errorMsgHandler)(name,type,class,defaultp,params,num_params);
UNLOCK_APP(app);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
void XtWarningMsg(
_Xconst char* name,
_Xconst char* type,
_Xconst char* class,
_Xconst char* defaultp,
String* params,
Cardinal* num_params
)
#else
void XtWarningMsg(name,type,class,defaultp,params,num_params)
String name,type,class,defaultp;
String* params;
Cardinal* num_params;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
(*warningMsgHandler)((String)name,(String)type,(String)class,
(String)defaultp,params,num_params);
UNLOCK_PROCESS;
#else
XtAppWarningMsg(_XtDefaultAppContext(),name,type,class,
defaultp,params,num_params);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
void XtAppWarningMsg(
XtAppContext app,
_Xconst char* name,
_Xconst char* type,
_Xconst char* class,
_Xconst char* defaultp,
String* params,
Cardinal* num_params
)
#else
void XtAppWarningMsg(app,name,type,class,defaultp,params,num_params)
XtAppContext app;
String name,type,class,defaultp;
String* params;
Cardinal* num_params;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
(*warningMsgHandler)((String)name,(String)type,(String)class,
(String)defaultp,params,num_params);
UNLOCK_PROCESS;
#else
LOCK_APP(app);
(*app->warningMsgHandler)(name,type,class,defaultp,params,num_params);
UNLOCK_APP(app);
#endif /* GLOBALERRORS */
}
void XtSetErrorMsgHandler(handler)
XtErrorMsgHandler handler;
{
#if GLOBALERRORS
LOCK_PROCESS;
if (handler != NULL) errorMsgHandler = handler;
else errorMsgHandler = _XtDefaultErrorMsg;
UNLOCK_PROCESS;
#else
XtAppSetErrorMsgHandler(_XtDefaultAppContext(), handler);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
XtErrorMsgHandler XtAppSetErrorMsgHandler(
XtAppContext app,
XtErrorMsgHandler handler)
#else
XtErrorMsgHandler XtAppSetErrorMsgHandler(app,handler)
XtAppContext app;
XtErrorMsgHandler handler;
#endif
{
XtErrorMsgHandler old;
#if GLOBALERRORS
LOCK_PROCESS;
old = errorMsgHandler;
if (handler != NULL) errorMsgHandler = handler;
else errorMsgHandler = _XtDefaultErrorMsg;
UNLOCK_PROCESS;
#else
LOCK_APP(app);
old = app->errorMsgHandler;
if (handler != NULL) app->errorMsgHandler = handler;
else app->errorMsgHandler = _XtDefaultErrorMsg;
UNLOCK_APP(app);
#endif /* GLOBALERRORS */
return old;
}
void XtSetWarningMsgHandler(handler)
XtErrorMsgHandler handler;
{
#if GLOBALERRORS
LOCK_PROCESS;
if (handler != NULL) warningMsgHandler = handler;
else warningMsgHandler = _XtDefaultWarningMsg;
UNLOCK_PROCESS;
#else
XtAppSetWarningMsgHandler(_XtDefaultAppContext(),handler);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
XtErrorMsgHandler XtAppSetWarningMsgHandler(
XtAppContext app,
XtErrorMsgHandler handler)
#else
XtErrorMsgHandler XtAppSetWarningMsgHandler(app,handler)
XtAppContext app;
XtErrorMsgHandler handler;
#endif
{
XtErrorMsgHandler old;
#if GLOBALERRORS
LOCK_PROCESS;
old = warningMsgHandler;
if (handler != NULL) warningMsgHandler = handler;
else warningMsgHandler = _XtDefaultWarningMsg;
UNLOCK_PROCESS;
#else
LOCK_APP(app);
old = app->warningMsgHandler;
if (handler != NULL) app->warningMsgHandler = handler;
else app->warningMsgHandler = _XtDefaultWarningMsg;
UNLOCK_APP(app);
#endif /* GLOBALERRORS */
return old;
}
void _XtDefaultError(message)
String message;
{
if (message && *message)
(void)fprintf(stderr, "%sError: %s\n", XTERROR_PREFIX, message);
exit(1);
}
void _XtDefaultWarning(message)
String message;
{
if (message && *message)
(void)fprintf(stderr, "%sWarning: %s\n", XTWARNING_PREFIX, message);
return;
}
#if NeedFunctionPrototypes
void XtError(
_Xconst char* message
)
#else
void XtError(message)
String message;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
(*errorHandler)((String)message);
UNLOCK_PROCESS;
#else
XtAppError(_XtDefaultAppContext(),message);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
void XtAppError(
XtAppContext app,
_Xconst char* message
)
#else
void XtAppError(app,message)
XtAppContext app;
String message;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
(*errorHandler)((String)message);
UNLOCK_PROCESS;
#else
LOCK_APP(app);
(*app->errorHandler)(message);
UNLOCK_APP(app);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
void XtWarning(
_Xconst char* message
)
#else
void XtWarning(message)
String message;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
(*warningHandler)((String)message);
UNLOCK_PROCESS;
#else
XtAppWarning(_XtDefaultAppContext(),message);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
void XtAppWarning(
XtAppContext app,
_Xconst char* message
)
#else
void XtAppWarning(app,message)
XtAppContext app;
String message;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
(*warningHandler)((String)message);
UNLOCK_PROCESS;
#else
LOCK_APP(app);
(*app->warningHandler)(message);
UNLOCK_APP(app);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
void XtSetErrorHandler(XtErrorHandler handler)
#else
void XtSetErrorHandler(handler)
XtErrorHandler handler;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
if (handler != NULL) errorHandler = handler;
else errorHandler = _XtDefaultError;
UNLOCK_PROCESS;
#else
XtAppSetErrorHandler(_XtDefaultAppContext(),handler);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
XtErrorHandler XtAppSetErrorHandler(
XtAppContext app,
XtErrorHandler handler)
#else
XtErrorHandler XtAppSetErrorHandler(app,handler)
XtAppContext app;
XtErrorHandler handler;
#endif
{
XtErrorHandler old;
#if GLOBALERRORS
LOCK_PROCESS;
old = errorHandler;
if (handler != NULL) errorHandler = handler;
else errorHandler = _XtDefaultError;
UNLOCK_PROCESS;
#else
LOCK_APP(app);
old = app->errorHandler;
if (handler != NULL) app->errorHandler = handler;
else app->errorHandler = _XtDefaultError;
UNLOCK_APP(app);
#endif /* GLOBALERRORS */
return old;
}
#if NeedFunctionPrototypes
void XtSetWarningHandler(XtErrorHandler handler)
#else
void XtSetWarningHandler(handler)
XtErrorHandler handler;
#endif
{
#if GLOBALERRORS
LOCK_PROCESS;
if (handler != NULL) warningHandler = handler;
else warningHandler = _XtDefaultWarning;
UNLOCK_PROCESS;
#else
XtAppSetWarningHandler(_XtDefaultAppContext(),handler);
#endif /* GLOBALERRORS */
}
#if NeedFunctionPrototypes
XtErrorHandler XtAppSetWarningHandler(
XtAppContext app,
XtErrorHandler handler)
#else
XtErrorHandler XtAppSetWarningHandler(app,handler)
XtAppContext app;
XtErrorHandler handler;
#endif
{
XtErrorHandler old;
#if GLOBALERRORS
LOCK_PROCESS;
old = warningHandler;
if (handler != NULL) warningHandler = handler;
else warningHandler = _XtDefaultWarning;
UNLOCK_PROCESS;
#else
LOCK_APP(app);
old = app->warningHandler;
if (handler != NULL) app->warningHandler = handler;
else app->warningHandler = _XtDefaultWarning;
UNLOCK_APP(app);
#endif /* GLOBALERRORS */
return old;
}
void _XtSetDefaultErrorHandlers(errMsg, warnMsg, err, warn)
XtErrorMsgHandler *errMsg, *warnMsg;
XtErrorHandler *err, *warn;
{
#ifndef GLOBALERRORS
LOCK_PROCESS;
*errMsg = _XtDefaultErrorMsg;
*warnMsg = _XtDefaultWarningMsg;
*err = _XtDefaultError;
*warn = _XtDefaultWarning;
UNLOCK_PROCESS;
#endif /* GLOBALERRORS */
}
|