(ebrowse-global-prefix-key): Change to C-c C-m.
[emacs.git] / oldXMenu / XLookAssoc.c
blob7e72570e2ba3873440f5c1e4805bf990d67711cd
1 /* Copyright Massachusetts Institute of Technology 1985 */
2 /* Copyright (C) 2002, 2003, 2004, 2005,
3 2006 Free Software Foundation, Inc. */
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.
17 #include <X11/Xlib.h>
18 #include <X11/Xresource.h>
19 #include "X10.h"
21 #ifndef NULL
22 #define NULL 0
23 #endif
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.
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. */
37 int hash;
38 register XAssoc *bucket;
39 register XAssoc *Entry;
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;
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);
57 /* Oops, identical XId's on different displays! */
58 continue;
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);
66 /* It is apparently not in the table. */
67 return(NULL);
70 /* arch-tag: d5075d0c-4b71-467d-b33c-3f5c4c4afcf2
71 (do not change this comment) */