Mercurial > emacs
annotate oldXMenu/XLookAssoc.c @ 75303:528bac1f7b32
*** empty log message ***
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 20 Jan 2007 15:43:48 +0000 |
parents | ce127a46b1ca |
children | 3d45362f1d38 6588c6259dfb |
rev | line source |
---|---|
25858 | 1 /* Copyright Massachusetts Institute of Technology 1985 */ |
74548 | 2 /* Copyright (C) 2001, 2002, 2003, 2004, 2005, |
68640
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65000
diff
changeset
|
3 2006 Free Software Foundation, Inc. */ |
25858 | 4 |
5 /* | |
6 Permission to use, copy, modify, distribute, and sell this software and its | |
7 documentation for any purpose is hereby granted without fee, provided that | |
8 the above copyright notice appear in all copies and that both that | |
9 copyright notice and this permission notice appear in supporting | |
10 documentation, and that the name of M.I.T. not be used in advertising or | |
11 publicity pertaining to distribution of the software without specific, | |
12 written prior permission. M.I.T. makes no representations about the | |
13 suitability of this software for any purpose. It is provided "as is" | |
14 without express or implied warranty. | |
15 */ | |
16 | |
17 #include <X11/Xlib.h> | |
18 #include <X11/Xresource.h> | |
19 #include "X10.h" | |
20 | |
21 #ifndef NULL | |
22 #define NULL 0 | |
23 #endif | |
24 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
25 /* |
25858 | 26 * XLookUpAssoc - Retrieve the data stored in an XAssocTable by its XId. |
27 * If an appropriately matching XId can be found in the table the routine will | |
28 * return apointer to the data associated with it. If the XId can not be found | |
29 * in the table the routine will return a NULL pointer. All XId's are relative | |
30 * to the currently active Display. | |
31 */ | |
32 caddr_t XLookUpAssoc(dpy, table, x_id) | |
33 register Display *dpy; | |
34 register XAssocTable *table; /* XAssocTable to search in. */ | |
35 register XID x_id; /* XId to search for. */ | |
36 { | |
37 int hash; | |
38 register XAssoc *bucket; | |
39 register XAssoc *Entry; | |
40 | |
41 /* Hash the XId to get the bucket number. */ | |
42 hash = x_id & (table->size - 1); | |
43 /* Look up the bucket to get the entries in that bucket. */ | |
44 bucket = &table->buckets[hash]; | |
45 /* Get the first entry in the bucket. */ | |
46 Entry = bucket->next; | |
47 | |
48 /* Scan through the entries in the bucket for the right XId. */ | |
49 for (; Entry != bucket; Entry = Entry->next) { | |
50 if (Entry->x_id == x_id) { | |
51 /* We have the right XId. */ | |
52 if (Entry->display == dpy) { | |
53 /* We have the right display. */ | |
54 /* We have the right entry! */ | |
55 return(Entry->data); | |
56 } | |
57 /* Oops, identical XId's on different displays! */ | |
58 continue; | |
59 } | |
60 if (Entry->x_id > x_id) { | |
61 /* We have gone past where it should be. */ | |
62 /* It is apparently not in the table. */ | |
63 return(NULL); | |
64 } | |
65 } | |
66 /* It is apparently not in the table. */ | |
67 return(NULL); | |
68 } | |
69 | |
52401 | 70 /* arch-tag: d5075d0c-4b71-467d-b33c-3f5c4c4afcf2 |
71 (do not change this comment) */ |