~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/3rdparty/qmon/Xmt310/Xmt/CallbackCvt.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Motif Tools Library, Version 3.1
 
3
 * $Id$
 
4
 * 
 
5
 * Written by David Flanagan.
 
6
 * Copyright (c) 1992-2001 by David Flanagan.
 
7
 * All Rights Reserved.  See the file COPYRIGHT for details.
 
8
 * This is open source software.  See the file LICENSE for details.
 
9
 * There is no warranty for this software.  See NO_WARRANTY for details.
 
10
 *
 
11
 * $Log$
 
12
 * Revision 1.1.1.1  2001/07/18 11:06:01  root
 
13
 * Initial checkin.
 
14
 *
 
15
 * Revision 1.1  2001/06/12 15:00:21  andre
 
16
 * AA-2001-06-12-0: replaced Xmt212 by Xmt310
 
17
 *                  (http://sourceforge.net/projects/motiftools) with
 
18
 *                  our xmt212 patches applied
 
19
 *
 
20
 *
 
21
 */
 
22
 
 
23
#include <Xmt/Xmt.h>
 
24
#include <Xmt/ProceduresP.h>
 
25
#include <Xmt/Symbols.h>
 
26
#include <Xmt/ConvertersP.h>
 
27
#include <Xmt/Util.h>
 
28
#include <Xmt/Lexer.h>
 
29
#include <Xmt/QuarksP.h>
 
30
 
 
31
typedef struct {
 
32
    String procedure_name;
 
33
    XmtProcedureInfo *procedure;
 
34
    String argument_strings[XmtMAX_PROCEDURE_ARGS];
 
35
    XtPointer arguments[XmtMAX_PROCEDURE_ARGS];
 
36
    XmtSymbol symbols[XmtMAX_PROCEDURE_ARGS];
 
37
    Boolean error;
 
38
} CallInfo;
 
39
    
 
40
 
 
41
typedef struct {
 
42
    CallInfo *calls;
 
43
    int num_calls;
 
44
} Callback;
 
45
 
 
46
typedef void (*XmtProcedure0)(
 
47
#if NeedFunctionPrototypes
 
48
                              void
 
49
#endif
 
50
                              );
 
51
typedef void (*XmtProcedure1)(
 
52
#if NeedFunctionPrototypes
 
53
                                   XtPointer
 
54
#endif
 
55
                              );
 
56
typedef void (*XmtProcedure2)(
 
57
#if NeedFunctionPrototypes
 
58
                                   XtPointer, XtPointer
 
59
#endif
 
60
                              );
 
61
typedef void (*XmtProcedure3)(
 
62
#if NeedFunctionPrototypes
 
63
                                   XtPointer, XtPointer, XtPointer
 
64
#endif
 
65
                              );
 
66
typedef void (*XmtProcedure4)(
 
67
#if NeedFunctionPrototypes
 
68
                                   XtPointer, XtPointer, 
 
69
                                   XtPointer, XtPointer
 
70
#endif
 
71
                              );
 
72
typedef void (*XmtProcedure5)(
 
73
#if NeedFunctionPrototypes
 
74
                                   XtPointer, XtPointer, XtPointer,
 
75
                                   XtPointer, XtPointer
 
76
#endif
 
77
                              );
 
78
typedef void (*XmtProcedure6)(
 
79
#if NeedFunctionPrototypes
 
80
                                   XtPointer, XtPointer, XtPointer,
 
81
                                   XtPointer, XtPointer, XtPointer
 
82
#endif
 
83
                              );
 
84
typedef void (*XmtProcedure7)(
 
85
#if NeedFunctionPrototypes
 
86
                                   XtPointer, XtPointer, XtPointer,
 
87
                                   XtPointer, XtPointer, XtPointer,
 
88
                                   XtPointer
 
89
#endif
 
90
                              );
 
91
typedef void (*XmtProcedure8)(
 
92
#if NeedFunctionPrototypes
 
93
                                   XtPointer, XtPointer, XtPointer,
 
94
                                   XtPointer, XtPointer, XtPointer,
 
95
                                   XtPointer, XtPointer
 
96
#endif
 
97
                              );
 
98
 
 
99
#if NeedFunctionPrototypes
 
100
static void ExpectedWarning(String s)
 
101
#else
 
102
static void ExpectedWarning(s)
 
103
String s;
 
104
#endif
 
105
{
 
106
    XmtWarningMsg("XmtConvertStringToCallback", "expected",
 
107
                  "%s expected.",
 
108
                  s);
 
109
}
 
110
 
 
111
#if NeedFunctionPrototypes
 
112
static Boolean ParseCall(XmtLexer l, CallInfo *ci)
 
113
#else
 
114
static Boolean ParseCall(l, ci)
 
115
XmtLexer l;
 
116
CallInfo *ci;
 
117
#endif
 
118
{
 
119
    XmtLexerToken tok;
 
120
    Cardinal num_args;
 
121
    int i;
 
122
 
 
123
    ci->procedure_name = NULL;
 
124
    ci->procedure = NULL;
 
125
    for(i=0; i < XmtMAX_PROCEDURE_ARGS; i++) {
 
126
        ci->argument_strings[i] = NULL;
 
127
        ci->arguments[i] = NULL;
 
128
        ci->symbols[i] = NULL;
 
129
    }
 
130
    ci->error = False;
 
131
 
 
132
    tok = XmtLexerGetToken(l);
 
133
    if (tok != XmtLexerIdent) {
 
134
        ExpectedWarning("procedure name");
 
135
        goto error;
 
136
    }
 
137
 
 
138
    ci->procedure_name = XmtLexerStrValue(l);
 
139
    XmtLexerConsumeToken(l);
 
140
 
 
141
    if (XmtLexerGetToken(l) != XmtLexerLParen) {
 
142
        ExpectedWarning("'('");
 
143
        goto error;
 
144
    }
 
145
 
 
146
    XmtLexerGetArgList(l,ci->argument_strings,XmtMAX_PROCEDURE_ARGS,&num_args);
 
147
    return True;
 
148
    
 
149
 error:
 
150
    /* free any strings allocated so far.  XtFree is okay with NULL */
 
151
    XtFree(ci->procedure_name);
 
152
    ci->procedure_name = NULL;
 
153
    for(i=0; i < XmtMAX_PROCEDURE_ARGS; i++) {
 
154
        XtFree(ci->argument_strings[i]);
 
155
        ci->argument_strings[i] = NULL;
 
156
    }
 
157
    return False;
 
158
}
 
159
    
 
160
 
 
161
#if NeedFunctionPrototypes
 
162
static Callback *StringToCallback(String str)
 
163
#else
 
164
static Callback *StringToCallback(str)
 
165
String str;
 
166
#endif
 
167
{
 
168
    static XmtLexer l = NULL;
 
169
    XmtLexerToken tok;
 
170
    int num, max;
 
171
    CallInfo *calls;
 
172
    Callback *cb;
 
173
    Boolean stat;
 
174
 
 
175
    if (l == NULL)
 
176
        l = XmtLexerCreate((String *)NULL, 0);
 
177
 
 
178
    XmtLexerInit(l, str);
 
179
 
 
180
    num = max = 0;
 
181
    calls = NULL;
 
182
 
 
183
    while(XmtLexerGetToken(l) != XmtLexerEndOfString) {
 
184
        if (num == max) {
 
185
            if (max == 0) max = 4; else max *= 2;
 
186
            calls = (CallInfo*)XtRealloc((char*)calls, sizeof(CallInfo) * max);
 
187
        }
 
188
        /* parse a single procedure call */
 
189
        stat = ParseCall(l, &calls[num]);
 
190
        if (stat) num++;
 
191
        else { /* on error read 'till next semicolon */
 
192
            while(1) {
 
193
                tok = XmtLexerGetToken(l);
 
194
                if ((tok == XmtLexerSemicolon) ||
 
195
                    (tok == XmtLexerEndOfString)) break;
 
196
                XmtLexerConsumeToken(l);
 
197
            }
 
198
        }
 
199
            
 
200
        /* and discard any semicolons */
 
201
        while (XmtLexerGetToken(l) == XmtLexerSemicolon)
 
202
            XmtLexerConsumeToken(l);
 
203
    }
 
204
 
 
205
    if (num == 0) { /* if empty string or errors */
 
206
        XtFree((char *)calls);
 
207
        cb = NULL;
 
208
    }
 
209
    else {
 
210
        calls = (CallInfo *)XtRealloc((char *)calls, sizeof(CallInfo)*num);
 
211
        cb = XtNew(Callback);
 
212
        cb->calls = calls;
 
213
        cb->num_calls = num;
 
214
    }
 
215
    return cb;
 
216
}
 
217
 
 
218
 
 
219
#if NeedFunctionPrototypes
 
220
static void DestroyCallback(Callback *cb)
 
221
#else
 
222
static void DestroyCallback(cb)
 
223
Callback *cb;
 
224
#endif
 
225
{
 
226
    int i,j;
 
227
    CallInfo *info;
 
228
 
 
229
    for(i=0; i < cb->num_calls; i++) {
 
230
        info = &cb->calls[i];
 
231
        XtFree(info->procedure_name);
 
232
        for(j=0; j < XmtMAX_PROCEDURE_ARGS; j++)
 
233
            XtFree(info->argument_strings[j]);
 
234
    }
 
235
    XtFree((char *) cb->calls);
 
236
    XtFree((char *)cb);
 
237
}
 
238
 
 
239
#if NeedFunctionPrototypes
 
240
static void ConvertArg(Widget w, CallInfo *call, int i, int j)
 
241
#else
 
242
static void ConvertArg(w, call, i, j)
 
243
Widget w;
 
244
CallInfo *call;
 
245
int i;
 
246
int j;
 
247
#endif
 
248
{
 
249
    XrmValue from, to;
 
250
    Boolean stat;
 
251
    XmtProcedureInfo *proc = call->procedure;
 
252
    
 
253
    /*
 
254
     * if the argument is a symbol name, bind it,
 
255
     * check the type, and remember the symbol
 
256
     */
 
257
    if (call->argument_strings[j][0] == '$') {
 
258
        call->symbols[i] = XmtLookupSymbol(&call->argument_strings[j][1]);
 
259
        
 
260
        if (!call->symbols[i]) {
 
261
            XmtWarningMsg("XmtCallCallbacks", "symbol",
 
262
                          "argument %d of procedure %s.\n\tSymbol '%s' is undefined.",
 
263
                          j, call->procedure_name,
 
264
                          call->argument_strings[j]);
 
265
        }
 
266
        else {
 
267
            /*
 
268
             * check symbol type.
 
269
             * A buffer symbol will match a string argument.
 
270
             */
 
271
            XrmQuark symtype = XmtSymbolTypeQuark(call->symbols[i]);
 
272
            XrmQuark argtype = (XrmQuark) proc->argument_types[i];
 
273
            if ((symtype != argtype) &&
 
274
                !((symtype == XmtQBuffer) && (argtype == XmtQString))) {
 
275
                XmtWarningMsg("XmtCallCallbacks", "symbolType",
 
276
                              "type mismatch:\n\targument %d of procedure %s.\n\tSymbol '%s' is not of type %s",
 
277
                              j, call->procedure_name,
 
278
                              XmtSymbolName(call->symbols[i]),
 
279
                              XrmQuarkToString((XrmQuark)
 
280
                                               proc->argument_types[i]));
 
281
                call->symbols[i] = NULL;
 
282
            }
 
283
        }
 
284
        if (!call->symbols[i]) call->error = True;
 
285
    }
 
286
    else {
 
287
        /*
 
288
         * if it is not a symbol, then if it is a string constant, we're done.
 
289
         * otherwise, we've got to convert our string to the appropriate type.
 
290
         */
 
291
        if ((XrmQuark)proc->argument_types[i] == XmtQString) {
 
292
            call->arguments[i] = (XtPointer)call->argument_strings[j];
 
293
        }
 
294
        else {
 
295
            from.addr = (XPointer) call->argument_strings[j];
 
296
            from.size = strlen(from.addr)+1;
 
297
            to.addr = (XPointer) NULL;
 
298
            /* XtConvertAndStore() will ensure that converted
 
299
             * values are freed when the widget w is destroyed.
 
300
             */
 
301
            stat = XtConvertAndStore(w, XtRString, &from,
 
302
                           XrmQuarkToString((XrmQuark)proc->argument_types[i]),
 
303
                                     &to);
 
304
            
 
305
            if (!stat) {
 
306
                XmtWarningMsg("XmtCallCallbacks", "typeMismatch",
 
307
                              "type mismatch: \n\targument %d of procedure %s.\n\tCan't convert \"%s\" to type %s",
 
308
                              j, call->procedure_name,
 
309
                              call->argument_strings[i],
 
310
                              XrmQuarkToString((XrmQuark)
 
311
                                               proc->argument_types[i]));
 
312
                call->error = True;
 
313
            }
 
314
            else {
 
315
                /* XXX
 
316
                 * This code isn't as portable as it should be, but it
 
317
                 * does seem to work on 32-bit architectures, and 64-bit Alpha.
 
318
                 * I don't know if there are any architectures that have
 
319
                 * calling conventions unlike those assumed here.
 
320
                 *
 
321
                 * All functions registered with the callback converter
 
322
                 * must expect arguments of the same size as XtPointer.
 
323
                 * This means that chars and shorts must be "widened"
 
324
                 * to longs.  Also, arguments of type double are not
 
325
                 * supported
 
326
                 */
 
327
                switch(to.size) {
 
328
                case 1:
 
329
                    call->arguments[i] = (XtPointer)(long)*(char *)to.addr;
 
330
                    break;
 
331
                case 2:
 
332
                    /* XXX signed vs. unsigned??? */
 
333
                    call->arguments[i] = (XtPointer)(long)*(short *)to.addr;
 
334
                    break;
 
335
                case 4:
 
336
                    call->arguments[i] = (XtPointer)(long)*(int *)to.addr;
 
337
                    break;
 
338
                default:
 
339
                    call->arguments[i] = (XtPointer)*(long *)to.addr;
 
340
                }
 
341
            }
 
342
        }
 
343
    }
 
344
}
 
345
 
 
346
 
 
347
#if NeedFunctionPrototypes
 
348
static void XmtCallCallback(Widget w, XtPointer tag, XtPointer data)
 
349
#else
 
350
static void XmtCallCallback(w, tag, data)
 
351
Widget w;
 
352
XtPointer tag;
 
353
XtPointer data;
 
354
#endif
 
355
{
 
356
    Callback *cb = (Callback *) tag;
 
357
    CallInfo *call;
 
358
    XmtProcedureInfo *proc;
 
359
    Boolean firsttime;
 
360
    int n;
 
361
    int i, j;
 
362
 
 
363
    for(n=0; n < cb->num_calls; n++) {
 
364
        call = &cb->calls[n];
 
365
 
 
366
        if (call->error) {
 
367
            XmtWarningMsg("XmtCallCallback", "badCall",
 
368
                          "not calling %s() because of previous errors.",
 
369
                          call->procedure_name);
 
370
            continue;
 
371
        }
 
372
 
 
373
        /* if this is the 1st time, figure out the procedure info */
 
374
        /* also set a flag for use below */
 
375
        if (call->procedure == NULL) {
 
376
            firsttime = True;
 
377
            call->procedure = XmtLookupProcedure(call->procedure_name);
 
378
            if (call->procedure == NULL) {
 
379
                XmtWarningMsg("XmtCallCallback", "unknown",
 
380
                              "unknown procedure %s",
 
381
                              call->procedure_name);
 
382
                continue;
 
383
            }
 
384
        }
 
385
        else firsttime = False;
 
386
 
 
387
        proc = call->procedure;
 
388
 
 
389
        /* if this is the first time, check the # of arguments */
 
390
        if (firsttime) {
 
391
            for(i=0;
 
392
                (i < XmtMAX_PROCEDURE_ARGS) && (call->argument_strings[i]);
 
393
                i++);
 
394
 
 
395
            if (i != proc->expected_args) {
 
396
                XmtWarningMsg("XmtCallCallback", "wrongNum",
 
397
                              "procedure %s expects %d arguments.",
 
398
                              call->procedure_name, proc->expected_args);
 
399
                call->error = True;
 
400
                continue;
 
401
            }
 
402
        }
 
403
 
 
404
        /* build up the array of arguments */
 
405
        i = j = 0;
 
406
        while((i < XmtMAX_PROCEDURE_ARGS) &&
 
407
              (proc->argument_types[i] != (String)NULLQUARK)) {
 
408
            if ((XrmQuark)proc->argument_types[i] == _XmtQCallbackWidget)
 
409
                call->arguments[i] = (XtPointer) w;
 
410
            else if ((XrmQuark)proc->argument_types[i] == _XmtQCallbackData)
 
411
                call->arguments[i] = data;
 
412
            else if((XrmQuark)proc->argument_types[i]==_XmtQCallbackAppContext)
 
413
                call->arguments[i] =(XtPointer)XtWidgetToApplicationContext(w);
 
414
            else if ((XrmQuark)proc->argument_types[i] == _XmtQCallbackWindow)
 
415
                call->arguments[i] = (XtPointer) XtWindow(w);
 
416
            else if ((XrmQuark)proc->argument_types[i] == _XmtQCallbackDisplay)
 
417
                call->arguments[i] = (XtPointer) XtDisplay(w);
 
418
            else if ((XrmQuark)proc->argument_types[i] == _XmtQCallbackUnused)
 
419
                call->arguments[i] = NULL;
 
420
            else {
 
421
                /*
 
422
                 * if this is the first time this CallInfo has been called,
 
423
                 * we've got to convert the argument string to the expected
 
424
                 * type, or to a symbol of the expected type.  If the argument
 
425
                 * is a constant, then we can use it for all subsequent calls.
 
426
                 * if the argument is a symbol, we save the bound symbol,
 
427
                 * and look up its value for each subsequent call.
 
428
                 * Note we convert argument_string[j] to argument[i].
 
429
                 */
 
430
                if (firsttime) {
 
431
                    ConvertArg(w, call, i, j);
 
432
                }
 
433
                /*
 
434
                 * if the arg is a symbol, get its value.
 
435
                 * Otherwise, its a constant, already converted, so do nothing.
 
436
                 */
 
437
                if (call->symbols[i]) {
 
438
                    XmtSymbolGetValue(call->symbols[i],
 
439
                                      (XtArgVal *)&call->arguments[i]);
 
440
                }
 
441
                j++;
 
442
            }
 
443
            if (call->error) break;
 
444
            i++;
 
445
        }
 
446
 
 
447
        if (call->error) continue;
 
448
        
 
449
        /*
 
450
         * Call the function.
 
451
         * If you change XmtMAX_PROCEDURE_ARGS, change this code too.
 
452
         * Note that all functions declared this way must expect
 
453
         * all their arguments to be the same size as XtPointer.
 
454
         * On most (all?) architectures it is safe to pass extra arguments
 
455
         * to functions, so we could just do case 8: here in all cases.
 
456
         * But this is a little cleaner when using a debugger, for example.
 
457
         */
 
458
        switch(i) {  /* number of arguments*/
 
459
        case 0:
 
460
            (*((XmtProcedure0)proc->function))();
 
461
            break;
 
462
        case 1:
 
463
            (*((XmtProcedure1)proc->function))(call->arguments[0]);
 
464
            break;
 
465
        case 2:
 
466
            (*((XmtProcedure2)proc->function))
 
467
                (call->arguments[0], call->arguments[1]);
 
468
            break;
 
469
        case 3:
 
470
            (*((XmtProcedure3)proc->function))
 
471
                (call->arguments[0], call->arguments[1],
 
472
                 call->arguments[2]);
 
473
            break;
 
474
        case 4:
 
475
            (*((XmtProcedure4)proc->function))
 
476
                (call->arguments[0], call->arguments[1],
 
477
                 call->arguments[2], call->arguments[3]);
 
478
            break;
 
479
        case 5:
 
480
            (*((XmtProcedure5)proc->function))
 
481
                (call->arguments[0], call->arguments[1],
 
482
                 call->arguments[2], call->arguments[3],
 
483
                 call->arguments[4]);
 
484
            break;
 
485
        case 6:
 
486
            (*((XmtProcedure6)proc->function))
 
487
                (call->arguments[0], call->arguments[1],
 
488
                 call->arguments[2], call->arguments[3],
 
489
                 call->arguments[4], call->arguments[5]);
 
490
            break;
 
491
        case 7:
 
492
            (*((XmtProcedure7)proc->function))
 
493
                (call->arguments[0], call->arguments[1],
 
494
                 call->arguments[2], call->arguments[3],
 
495
                 call->arguments[4], call->arguments[5],
 
496
                 call->arguments[6]);
 
497
            break;
 
498
        case 8:
 
499
            (*((XmtProcedure8)proc->function))
 
500
                (call->arguments[0], call->arguments[1],
 
501
                 call->arguments[2], call->arguments[3],
 
502
                 call->arguments[4], call->arguments[5],
 
503
                 call->arguments[6], call->arguments[7]);
 
504
            break;
 
505
        }
 
506
 
 
507
    }
 
508
}
 
509
 
 
510
 
 
511
/* ARGSUSED */
 
512
#if NeedFunctionPrototypes
 
513
Boolean XmtConvertStringToCallback(Display *dpy,
 
514
                                   XrmValue *args, Cardinal *num_args,
 
515
                                   XrmValue *from, XrmValue *to,
 
516
                                   XtPointer *converter_data)
 
517
#else
 
518
Boolean XmtConvertStringToCallback(dpy, args, num_args, from, to,
 
519
                                   converter_data)
 
520
Display *dpy;
 
521
XrmValue *args;
 
522
Cardinal *num_args;
 
523
XrmValue *from;
 
524
XrmValue *to;
 
525
XtPointer *converter_data;
 
526
#endif
 
527
{
 
528
    Callback *callback;
 
529
    XtCallbackList list;
 
530
 
 
531
    callback = StringToCallback((char *)from->addr);
 
532
 
 
533
    if (callback == NULL) { /* error, couldn't convert */
 
534
        /* XXX print the string here, and mark where the error occured. */
 
535
        return False;
 
536
    }
 
537
    else {
 
538
        list = (XtCallbackList)XtCalloc(sizeof(XtCallbackRec), 2);
 
539
        list[0].callback = (XtCallbackProc) XmtCallCallback;
 
540
        list[0].closure = (XtPointer) callback;
 
541
        done(XtCallbackList, list);
 
542
    }
 
543
}
 
544
 
 
545
/* ARGSUSED */
 
546
#if NeedFunctionPrototypes
 
547
static void XmtDestroyCallback(XtAppContext app, XrmValue *to,
 
548
                               XtPointer converter_data,
 
549
                               XrmValue *args, Cardinal *num_args)
 
550
#else
 
551
static void XmtDestroyCallback(app, to, converter_data, args, num_args)
 
552
XtAppContext app;
 
553
XrmValue *to;
 
554
XtPointer converter_data;
 
555
XrmValue *args;
 
556
Cardinal *num_args;
 
557
#endif
 
558
{
 
559
    XtCallbackList list = *(XtCallbackList *)to->addr;
 
560
 
 
561
    DestroyCallback((Callback *)list[0].closure);
 
562
    XtFree((char *)list);
 
563
}
 
564
 
 
565
#if NeedFunctionPrototypes
 
566
void XmtRegisterCallbackConverter(void)
 
567
#else
 
568
void XmtRegisterCallbackConverter()
 
569
#endif
 
570
{
 
571
    static Boolean registered = False;
 
572
 
 
573
    if (!registered) {
 
574
        registered = True;
 
575
        /*
 
576
         * Note that the results of this converter cannot be cached, because
 
577
         * the callback arguments need to be converted in the context of
 
578
         * their particular widget and thus cannot be shared.  It doesn't
 
579
         * make much sense, however, to have lots of widgets with the same
 
580
         * callbacks and arguments, however, so this is no great loss.
 
581
         */
 
582
        XtSetTypeConverter(XtRString, XtRCallback,
 
583
                           XmtConvertStringToCallback, NULL, 0,
 
584
                           XtCacheNone | XtCacheRefCount,
 
585
                           XmtDestroyCallback);
 
586
 
 
587
        /* ensure that the quarks we need will exist when the
 
588
         * converter is called
 
589
         */
 
590
        _XmtInitQuarks();
 
591
 
 
592
        /*
 
593
         * we also register the converter in variables declared in
 
594
         * GlobalsI.h so that it can be looked up by the automatic
 
595
         * widget creation routines.  We don't want those routines to
 
596
         * reference these directly because then they would be linked
 
597
         * together.
 
598
         */
 
599
        _XmtCallbackConverter = XmtConvertStringToCallback;
 
600
    }
 
601
}
 
602
 
 
603
#if NeedFunctionPrototypes
 
604
Boolean XmtCallbackCheckList(XtCallbackList list, XmtProcedure proc)
 
605
#else
 
606
Boolean XmtCallbackCheckList(list, proc)
 
607
XtCallbackList list;
 
608
XmtProcedure proc;
 
609
#endif
 
610
{
 
611
    Callback *cb;
 
612
    int i;
 
613
    
 
614
    /* for each item in the callback list */
 
615
    for(; list->callback != NULL; list++) {
 
616
        /* if the procedures match exactly */
 
617
        if (list->callback == (XtCallbackProc) proc) return True;
 
618
        /* else if it is the result of the converter */
 
619
        else if (list->callback == (XtCallbackProc) XmtCallCallback) {
 
620
            /* the client data is a list of calls */
 
621
            cb = (Callback *) list->closure;
 
622
            for (i=0; i < cb->num_calls; i++) {
 
623
                /* if the callback has been called once and already converted*/
 
624
                if (cb->calls[i].procedure) {
 
625
                    if (cb->calls[i].procedure->function == proc) return True;
 
626
                }
 
627
                /* otherwise, we've got to look up procedures by name */
 
628
                else {
 
629
                    XmtProcedureInfo *procedure;
 
630
                    procedure =XmtLookupProcedure(cb->calls[i].procedure_name);
 
631
                    if (procedure && procedure->function == proc) return True;
 
632
                }
 
633
            }
 
634
        }
 
635
    }
 
636
    return False;
 
637
}
 
638