Mercurial > emacs
annotate oldXMenu/XLookAssoc.c @ 76170:365a8de87f1f
Add GPL for FSF copyright. Adjust FSF copyright years based on
changelogs.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 27 Feb 2007 02:56:08 +0000 |
parents | 995b45abe69d |
children | fec5e03aaf59 dd7c098af727 |
rev | line source |
---|---|
25858 | 1 /* Copyright Massachusetts Institute of Technology 1985 */ |
74548 | 2 /* Copyright (C) 2001, 2002, 2003, 2004, 2005, |
75348 | 3 2006, 2007 Free Software Foundation, Inc. */ |
25858 | 4 |
76133
995b45abe69d
Remove license text in favour of including copyright.h, as was done in
Glenn Morris <rgm@gnu.org>
parents:
75348
diff
changeset
|
5 #include "copyright.h" |
995b45abe69d
Remove license text in favour of including copyright.h, as was done in
Glenn Morris <rgm@gnu.org>
parents:
75348
diff
changeset
|
6 |
25858 | 7 |
8 #include <X11/Xlib.h> | |
9 #include <X11/Xresource.h> | |
10 #include "X10.h" | |
11 | |
12 #ifndef NULL | |
13 #define NULL 0 | |
14 #endif | |
15 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
16 /* |
25858 | 17 * XLookUpAssoc - Retrieve the data stored in an XAssocTable by its XId. |
18 * If an appropriately matching XId can be found in the table the routine will | |
19 * return apointer to the data associated with it. If the XId can not be found | |
20 * in the table the routine will return a NULL pointer. All XId's are relative | |
21 * to the currently active Display. | |
22 */ | |
23 caddr_t XLookUpAssoc(dpy, table, x_id) | |
24 register Display *dpy; | |
25 register XAssocTable *table; /* XAssocTable to search in. */ | |
26 register XID x_id; /* XId to search for. */ | |
27 { | |
28 int hash; | |
29 register XAssoc *bucket; | |
30 register XAssoc *Entry; | |
31 | |
32 /* Hash the XId to get the bucket number. */ | |
33 hash = x_id & (table->size - 1); | |
34 /* Look up the bucket to get the entries in that bucket. */ | |
35 bucket = &table->buckets[hash]; | |
36 /* Get the first entry in the bucket. */ | |
37 Entry = bucket->next; | |
38 | |
39 /* Scan through the entries in the bucket for the right XId. */ | |
40 for (; Entry != bucket; Entry = Entry->next) { | |
41 if (Entry->x_id == x_id) { | |
42 /* We have the right XId. */ | |
43 if (Entry->display == dpy) { | |
44 /* We have the right display. */ | |
45 /* We have the right entry! */ | |
46 return(Entry->data); | |
47 } | |
48 /* Oops, identical XId's on different displays! */ | |
49 continue; | |
50 } | |
51 if (Entry->x_id > x_id) { | |
52 /* We have gone past where it should be. */ | |
53 /* It is apparently not in the table. */ | |
54 return(NULL); | |
55 } | |
56 } | |
57 /* It is apparently not in the table. */ | |
58 return(NULL); | |
59 } | |
60 | |
52401 | 61 /* arch-tag: d5075d0c-4b71-467d-b33c-3f5c4c4afcf2 |
62 (do not change this comment) */ |