Revision 12350,
1.4 KB
checked in by ghudson, 26 years ago
(diff) |
Some RCS ID cleanup: delete $Log$ and replace other RCS keywords with $Id$.
|
Line | |
---|
1 | /* |
---|
2 | * $Id: registerCB.c,v 1.2 1999-01-22 23:17:09 ghudson Exp $ |
---|
3 | * |
---|
4 | * Copyright 1990, 1991 by the Massachusetts Institute of Technology. |
---|
5 | * |
---|
6 | * For copying and distribution information, please see the file |
---|
7 | * <mit-copyright.h>. |
---|
8 | * |
---|
9 | */ |
---|
10 | |
---|
11 | #if (!defined(lint)) && (!defined(SABER)) |
---|
12 | static char rcsid[] = |
---|
13 | "$Id: registerCB.c,v 1.2 1999-01-22 23:17:09 ghudson Exp $"; |
---|
14 | #endif |
---|
15 | |
---|
16 | #include "mit-copyright.h" |
---|
17 | #include <stdio.h> |
---|
18 | #include <X11/Xlib.h> |
---|
19 | #include <X11/Xresource.h> |
---|
20 | #include "Jets.h" |
---|
21 | #include "hash.h" |
---|
22 | |
---|
23 | static struct hash *h = NULL; |
---|
24 | |
---|
25 | |
---|
26 | void XjRegisterCallback(w, name) |
---|
27 | XjCallbackProc w; |
---|
28 | char *name; |
---|
29 | { |
---|
30 | XrmQuark quark; |
---|
31 | |
---|
32 | quark = XrmStringToQuark(name); |
---|
33 | |
---|
34 | if ( h == NULL ) |
---|
35 | h = create_hash(HASHSIZE); |
---|
36 | |
---|
37 | if (hash_store(h, quark, (caddr_t)w) == 1) /* if a callback already */ |
---|
38 | { /* exists by that name, */ |
---|
39 | char errtext[100]; /* give a warning */ |
---|
40 | |
---|
41 | sprintf(errtext, |
---|
42 | "XjRegisterCallbacks: duplicate procedure registration: %s", |
---|
43 | name); |
---|
44 | XjWarning(errtext); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | XjCallbackProc XjGetCallback(string) |
---|
50 | char *string; |
---|
51 | { |
---|
52 | XrmQuark quark; |
---|
53 | XjCallbackProc w; |
---|
54 | |
---|
55 | if (h == NULL) |
---|
56 | return NULL; |
---|
57 | |
---|
58 | quark = XrmStringToQuark(string); |
---|
59 | |
---|
60 | w = (XjCallbackProc)(hash_lookup(h, quark)); |
---|
61 | return(w); |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | void XjRegisterCallbacks(c, num) |
---|
66 | XjCallbackRec c[]; |
---|
67 | int num; |
---|
68 | { |
---|
69 | int i; |
---|
70 | |
---|
71 | for (i = 0; i < num; i++) |
---|
72 | XjRegisterCallback(c[i].proc, c[i].name); |
---|
73 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.