3 Copyright 1988, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
28 * This file contains routines to cache atoms, avoiding multiple
29 * server round-trips. Not so useful now that Xlib caches them.
31 * Public entry points:
33 * XmuMakeAtom creates & initializes an opaque AtomRec
34 * XmuInternAtom fetches an Atom from cache or Display
35 * XmuInternStrings fetches multiple Atoms as strings
36 * XmuGetAtomName returns name of an Atom
37 * XmuNameOfAtom returns name from an AtomPtr
43 #include <X11/Intrinsic.h>
46 typedef struct _DisplayRec {
47 struct _DisplayRec* next;
63 #define DeclareAtom(atom,text) \
64 STATIC struct _AtomRec __##atom = { text, NULL }; \
65 AtomPtr _##atom = &__##atom;
67 DeclareAtom(XA_ATOM_PAIR, "ATOM_PAIR" )
68 DeclareAtom(XA_CHARACTER_POSITION, "CHARACTER_POSITION" )
69 DeclareAtom(XA_CLASS, "CLASS" )
70 DeclareAtom(XA_CLIENT_WINDOW, "CLIENT_WINDOW" )
71 DeclareAtom(XA_CLIPBOARD, "CLIPBOARD" )
72 DeclareAtom(XA_COMPOUND_TEXT, "COMPOUND_TEXT" )
73 DeclareAtom(XA_DECNET_ADDRESS, "DECNET_ADDRESS" )
74 DeclareAtom(XA_DELETE, "DELETE" )
75 DeclareAtom(XA_FILENAME, "FILENAME" )
76 DeclareAtom(XA_HOSTNAME, "HOSTNAME" )
77 DeclareAtom(XA_IP_ADDRESS, "IP_ADDRESS" )
78 DeclareAtom(XA_LENGTH, "LENGTH" )
79 DeclareAtom(XA_LIST_LENGTH, "LIST_LENGTH" )
80 DeclareAtom(XA_NAME, "NAME" )
81 DeclareAtom(XA_NET_ADDRESS, "NET_ADDRESS" )
82 DeclareAtom(XA_NULL, "NULL" )
83 DeclareAtom(XA_OWNER_OS, "OWNER_OS" )
84 DeclareAtom(XA_SPAN, "SPAN" )
85 DeclareAtom(XA_TARGETS, "TARGETS" )
86 DeclareAtom(XA_TEXT, "TEXT" )
87 DeclareAtom(XA_TIMESTAMP, "TIMESTAMP" )
88 DeclareAtom(XA_USER, "USER" )
89 DeclareAtom(XA_UTF8_STRING, "UTF8_STRING" )
91 /******************************************************************
95 ******************************************************************/
99 XmuMakeAtom(_Xconst char *name)
101 AtomPtr ptr = XtNew(struct _AtomRec);
108 XmuNameOfAtom(AtomPtr atom_ptr)
110 return (char *) atom_ptr->name;
115 XmuInternAtom(Display *d, AtomPtr atom_ptr)
117 DisplayRec* display_rec;
118 for (display_rec = atom_ptr->head; display_rec != NULL;
119 display_rec = display_rec->next) {
120 if (display_rec->dpy == d)
121 return display_rec->atom;
123 display_rec = XtNew(DisplayRec);
124 display_rec->next = atom_ptr->head;
125 atom_ptr->head = display_rec;
126 display_rec->dpy = d;
127 display_rec->atom = XInternAtom(d, atom_ptr->name, False);
128 return display_rec->atom;
133 XmuGetAtomName(Display *d, Atom atom)
135 if (atom == 0) return (NULL);
136 return XGetAtomName(d, atom);
139 /* convert (names, count) to a list of atoms. Caller allocates list */
141 XmuInternStrings(Display *d, register String *names,
142 register Cardinal count, register Atom *atoms)
144 (void) XInternAtoms(d, (char**)names, (int)count, FALSE, atoms);