1ecce36beSmrg/* C code produced by gperf version 3.0.3 */
2ecce36beSmrg/* Command-line: gperf --output-file atoms.c atoms.gperf  */
3ecce36beSmrg/* Computed positions: -k'3,6,9,$' */
4ecce36beSmrg
5ecce36beSmrg#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
6ecce36beSmrg      && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
7ecce36beSmrg      && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
8ecce36beSmrg      && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
9ecce36beSmrg      && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
10ecce36beSmrg      && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
11ecce36beSmrg      && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
12ecce36beSmrg      && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
13ecce36beSmrg      && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
14ecce36beSmrg      && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
15ecce36beSmrg      && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
16ecce36beSmrg      && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
17ecce36beSmrg      && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
18ecce36beSmrg      && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
19ecce36beSmrg      && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
20ecce36beSmrg      && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
21ecce36beSmrg      && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
22ecce36beSmrg      && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
23ecce36beSmrg      && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
24ecce36beSmrg      && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
25ecce36beSmrg      && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
26ecce36beSmrg      && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
27ecce36beSmrg      && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
28ecce36beSmrg/* The character set is not based on ISO-646.  */
29ecce36beSmrgerror "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
30ecce36beSmrg#endif
31ecce36beSmrg
32ecce36beSmrg#line 1 "atoms.gperf"
33ecce36beSmrg
34ecce36beSmrg
35ecce36beSmrg/* Rely on vasprintf (GNU extension) instead of vsnprintf if
36ecce36beSmrg   possible... */
37ecce36beSmrg#ifdef HAVE_VASPRINTF
38ecce36beSmrg#define _GNU_SOURCE
39ecce36beSmrg#include <stdio.h>
40ecce36beSmrg#endif
41ecce36beSmrg
42ecce36beSmrg#include <xcb/xcb.h>
43ecce36beSmrg#include <stdlib.h>
44ecce36beSmrg#include <stdarg.h>
45ecce36beSmrg#include "xcb_atom.h"
46ecce36beSmrg
47ecce36beSmrgconst xcb_atom_t PRIMARY = 1;
48ecce36beSmrgconst xcb_atom_t SECONDARY = 2;
49ecce36beSmrgconst xcb_atom_t ARC = 3;
50ecce36beSmrgconst xcb_atom_t ATOM = 4;
51ecce36beSmrgconst xcb_atom_t BITMAP = 5;
52ecce36beSmrgconst xcb_atom_t CARDINAL = 6;
53ecce36beSmrgconst xcb_atom_t COLORMAP = 7;
54ecce36beSmrgconst xcb_atom_t CURSOR = 8;
55ecce36beSmrgconst xcb_atom_t CUT_BUFFER0 = 9;
56ecce36beSmrgconst xcb_atom_t CUT_BUFFER1 = 10;
57ecce36beSmrgconst xcb_atom_t CUT_BUFFER2 = 11;
58ecce36beSmrgconst xcb_atom_t CUT_BUFFER3 = 12;
59ecce36beSmrgconst xcb_atom_t CUT_BUFFER4 = 13;
60ecce36beSmrgconst xcb_atom_t CUT_BUFFER5 = 14;
61ecce36beSmrgconst xcb_atom_t CUT_BUFFER6 = 15;
62ecce36beSmrgconst xcb_atom_t CUT_BUFFER7 = 16;
63ecce36beSmrgconst xcb_atom_t DRAWABLE = 17;
64ecce36beSmrgconst xcb_atom_t FONT = 18;
65ecce36beSmrgconst xcb_atom_t INTEGER = 19;
66ecce36beSmrgconst xcb_atom_t PIXMAP = 20;
67ecce36beSmrgconst xcb_atom_t POINT = 21;
68ecce36beSmrgconst xcb_atom_t RECTANGLE = 22;
69ecce36beSmrgconst xcb_atom_t RESOURCE_MANAGER = 23;
70ecce36beSmrgconst xcb_atom_t RGB_COLOR_MAP = 24;
71ecce36beSmrgconst xcb_atom_t RGB_BEST_MAP = 25;
72ecce36beSmrgconst xcb_atom_t RGB_BLUE_MAP = 26;
73ecce36beSmrgconst xcb_atom_t RGB_DEFAULT_MAP = 27;
74ecce36beSmrgconst xcb_atom_t RGB_GRAY_MAP = 28;
75ecce36beSmrgconst xcb_atom_t RGB_GREEN_MAP = 29;
76ecce36beSmrgconst xcb_atom_t RGB_RED_MAP = 30;
77ecce36beSmrgconst xcb_atom_t STRING = 31;
78ecce36beSmrgconst xcb_atom_t VISUALID = 32;
79ecce36beSmrgconst xcb_atom_t WINDOW = 33;
80ecce36beSmrgconst xcb_atom_t WM_COMMAND = 34;
81ecce36beSmrgconst xcb_atom_t WM_HINTS = 35;
82ecce36beSmrgconst xcb_atom_t WM_CLIENT_MACHINE = 36;
83ecce36beSmrgconst xcb_atom_t WM_ICON_NAME = 37;
84ecce36beSmrgconst xcb_atom_t WM_ICON_SIZE = 38;
85ecce36beSmrgconst xcb_atom_t WM_NAME = 39;
86ecce36beSmrgconst xcb_atom_t WM_NORMAL_HINTS = 40;
87ecce36beSmrgconst xcb_atom_t WM_SIZE_HINTS = 41;
88ecce36beSmrgconst xcb_atom_t WM_ZOOM_HINTS = 42;
89ecce36beSmrgconst xcb_atom_t MIN_SPACE = 43;
90ecce36beSmrgconst xcb_atom_t NORM_SPACE = 44;
91ecce36beSmrgconst xcb_atom_t MAX_SPACE = 45;
92ecce36beSmrgconst xcb_atom_t END_SPACE = 46;
93ecce36beSmrgconst xcb_atom_t SUPERSCRIPT_X = 47;
94ecce36beSmrgconst xcb_atom_t SUPERSCRIPT_Y = 48;
95ecce36beSmrgconst xcb_atom_t SUBSCRIPT_X = 49;
96ecce36beSmrgconst xcb_atom_t SUBSCRIPT_Y = 50;
97ecce36beSmrgconst xcb_atom_t UNDERLINE_POSITION = 51;
98ecce36beSmrgconst xcb_atom_t UNDERLINE_THICKNESS = 52;
99ecce36beSmrgconst xcb_atom_t STRIKEOUT_ASCENT = 53;
100ecce36beSmrgconst xcb_atom_t STRIKEOUT_DESCENT = 54;
101ecce36beSmrgconst xcb_atom_t ITALIC_ANGLE = 55;
102ecce36beSmrgconst xcb_atom_t X_HEIGHT = 56;
103ecce36beSmrgconst xcb_atom_t QUAD_WIDTH = 57;
104ecce36beSmrgconst xcb_atom_t WEIGHT = 58;
105ecce36beSmrgconst xcb_atom_t POINT_SIZE = 59;
106ecce36beSmrgconst xcb_atom_t RESOLUTION = 60;
107ecce36beSmrgconst xcb_atom_t COPYRIGHT = 61;
108ecce36beSmrgconst xcb_atom_t NOTICE = 62;
109ecce36beSmrgconst xcb_atom_t FONT_NAME = 63;
110ecce36beSmrgconst xcb_atom_t FAMILY_NAME = 64;
111ecce36beSmrgconst xcb_atom_t FULL_NAME = 65;
112ecce36beSmrgconst xcb_atom_t CAP_HEIGHT = 66;
113ecce36beSmrgconst xcb_atom_t WM_CLASS = 67;
114ecce36beSmrgconst xcb_atom_t WM_TRANSIENT_FOR = 68;
115ecce36beSmrg#line 93 "atoms.gperf"
116ecce36beSmrgstruct atom_map { int name; xcb_atom_t value; };
117ecce36beSmrg#include <string.h>
118ecce36beSmrg/* maximum key range = 146, duplicates = 0 */
119ecce36beSmrg
120ecce36beSmrg#ifdef __GNUC__
121ecce36beSmrg__inline
122ecce36beSmrg#else
123ecce36beSmrg#ifdef __cplusplus
124ecce36beSmrginline
125ecce36beSmrg#endif
126ecce36beSmrg#endif
127ecce36beSmrgstatic unsigned int
128ecce36beSmrghash (str, len)
129ecce36beSmrg     register const char *str;
130ecce36beSmrg     register unsigned int len;
131ecce36beSmrg{
132ecce36beSmrg  static const unsigned char asso_values[] =
133ecce36beSmrg    {
134ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
135ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
136ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
137ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
138ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150,  75,  70,
139ecce36beSmrg       65,  60,  40,  35,  20,   5, 150, 150, 150, 150,
140ecce36beSmrg      150, 150, 150, 150, 150,  35,   0,  45,  15,   0,
141ecce36beSmrg      150,  50,   0,   5, 150, 150,  15,  35,   0,  40,
142ecce36beSmrg        5, 150,  10,  15,   0,  25, 150,  20,  70,  40,
143ecce36beSmrg       55, 150, 150, 150, 150,  15, 150, 150, 150, 150,
144ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
145ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
146ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
147ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
148ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
149ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
150ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
151ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
152ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
153ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
154ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
155ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
156ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
157ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
158ecce36beSmrg      150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
159ecce36beSmrg      150, 150, 150, 150, 150, 150
160ecce36beSmrg    };
161ecce36beSmrg  register int hval = len;
162ecce36beSmrg
163ecce36beSmrg  switch (hval)
164ecce36beSmrg    {
165ecce36beSmrg      default:
166ecce36beSmrg        hval += asso_values[(unsigned char)str[8]];
167ecce36beSmrg      /*FALLTHROUGH*/
168ecce36beSmrg      case 8:
169ecce36beSmrg      case 7:
170ecce36beSmrg      case 6:
171ecce36beSmrg        hval += asso_values[(unsigned char)str[5]];
172ecce36beSmrg      /*FALLTHROUGH*/
173ecce36beSmrg      case 5:
174ecce36beSmrg      case 4:
175ecce36beSmrg      case 3:
176ecce36beSmrg        hval += asso_values[(unsigned char)str[2]];
177ecce36beSmrg        break;
178ecce36beSmrg    }
179ecce36beSmrg  return hval + asso_values[(unsigned char)str[len - 1]];
180ecce36beSmrg}
181ecce36beSmrg
182ecce36beSmrgstruct stringpool_t
183ecce36beSmrg  {
184ecce36beSmrg    char stringpool_str4[sizeof("FONT")];
185ecce36beSmrg    char stringpool_str6[sizeof("NOTICE")];
186ecce36beSmrg    char stringpool_str9[sizeof("FONT_NAME")];
187ecce36beSmrg    char stringpool_str10[sizeof("POINT")];
188ecce36beSmrg    char stringpool_str11[sizeof("WEIGHT")];
189ecce36beSmrg    char stringpool_str14[sizeof("MIN_SPACE")];
190ecce36beSmrg    char stringpool_str15[sizeof("CAP_HEIGHT")];
191ecce36beSmrg    char stringpool_str16[sizeof("BITMAP")];
192ecce36beSmrg    char stringpool_str17[sizeof("INTEGER")];
193ecce36beSmrg    char stringpool_str19[sizeof("COPYRIGHT")];
194ecce36beSmrg    char stringpool_str24[sizeof("FULL_NAME")];
195ecce36beSmrg    char stringpool_str26[sizeof("STRIKEOUT_ASCENT")];
196ecce36beSmrg    char stringpool_str27[sizeof("STRIKEOUT_DESCENT")];
197ecce36beSmrg    char stringpool_str28[sizeof("RGB_GREEN_MAP")];
198ecce36beSmrg    char stringpool_str29[sizeof("END_SPACE")];
199ecce36beSmrg    char stringpool_str32[sizeof("RGB_BEST_MAP")];
200ecce36beSmrg    char stringpool_str33[sizeof("CARDINAL")];
201ecce36beSmrg    char stringpool_str36[sizeof("CURSOR")];
202ecce36beSmrg    char stringpool_str37[sizeof("WM_CLIENT_MACHINE")];
203ecce36beSmrg    char stringpool_str38[sizeof("WM_HINTS")];
204ecce36beSmrg    char stringpool_str41[sizeof("CUT_BUFFER7")];
205ecce36beSmrg    char stringpool_str42[sizeof("RGB_GRAY_MAP")];
206ecce36beSmrg    char stringpool_str43[sizeof("DRAWABLE")];
207ecce36beSmrg    char stringpool_str45[sizeof("RGB_DEFAULT_MAP")];
208ecce36beSmrg    char stringpool_str46[sizeof("WINDOW")];
209ecce36beSmrg    char stringpool_str47[sizeof("RGB_BLUE_MAP")];
210ecce36beSmrg    char stringpool_str48[sizeof("UNDERLINE_POSITION")];
211ecce36beSmrg    char stringpool_str51[sizeof("RGB_RED_MAP")];
212ecce36beSmrg    char stringpool_str53[sizeof("VISUALID")];
213ecce36beSmrg    char stringpool_str54[sizeof("RECTANGLE")];
214ecce36beSmrg    char stringpool_str56[sizeof("CUT_BUFFER6")];
215ecce36beSmrg    char stringpool_str57[sizeof("WM_NAME")];
216ecce36beSmrg    char stringpool_str58[sizeof("X_HEIGHT")];
217ecce36beSmrg    char stringpool_str61[sizeof("SUBSCRIPT_Y")];
218ecce36beSmrg    char stringpool_str62[sizeof("PRIMARY")];
219ecce36beSmrg    char stringpool_str63[sizeof("COLORMAP")];
220ecce36beSmrg    char stringpool_str64[sizeof("UNDERLINE_THICKNESS")];
221ecce36beSmrg    char stringpool_str65[sizeof("QUAD_WIDTH")];
222ecce36beSmrg    char stringpool_str66[sizeof("RESOURCE_MANAGER")];
223ecce36beSmrg    char stringpool_str67[sizeof("WM_ICON_NAME")];
224ecce36beSmrg    char stringpool_str68[sizeof("RGB_COLOR_MAP")];
225ecce36beSmrg    char stringpool_str70[sizeof("WM_NORMAL_HINTS")];
226ecce36beSmrg    char stringpool_str71[sizeof("CUT_BUFFER5")];
227ecce36beSmrg    char stringpool_str73[sizeof("WM_CLASS")];
228ecce36beSmrg    char stringpool_str75[sizeof("WM_COMMAND")];
229ecce36beSmrg    char stringpool_str76[sizeof("CUT_BUFFER4")];
230ecce36beSmrg    char stringpool_str78[sizeof("SUPERSCRIPT_Y")];
231ecce36beSmrg    char stringpool_str79[sizeof("ATOM")];
232ecce36beSmrg    char stringpool_str80[sizeof("NORM_SPACE")];
233ecce36beSmrg    char stringpool_str81[sizeof("WM_TRANSIENT_FOR")];
234ecce36beSmrg    char stringpool_str82[sizeof("WM_ICON_SIZE")];
235ecce36beSmrg    char stringpool_str83[sizeof("WM_ZOOM_HINTS")];
236ecce36beSmrg    char stringpool_str84[sizeof("MAX_SPACE")];
237ecce36beSmrg    char stringpool_str85[sizeof("POINT_SIZE")];
238ecce36beSmrg    char stringpool_str86[sizeof("PIXMAP")];
239ecce36beSmrg    char stringpool_str90[sizeof("RESOLUTION")];
240ecce36beSmrg    char stringpool_str91[sizeof("SUBSCRIPT_X")];
241ecce36beSmrg    char stringpool_str92[sizeof("ITALIC_ANGLE")];
242ecce36beSmrg    char stringpool_str93[sizeof("ARC")];
243ecce36beSmrg    char stringpool_str96[sizeof("CUT_BUFFER3")];
244ecce36beSmrg    char stringpool_str98[sizeof("WM_SIZE_HINTS")];
245ecce36beSmrg    char stringpool_str101[sizeof("CUT_BUFFER2")];
246ecce36beSmrg    char stringpool_str106[sizeof("CUT_BUFFER1")];
247ecce36beSmrg    char stringpool_str108[sizeof("SUPERSCRIPT_X")];
248ecce36beSmrg    char stringpool_str111[sizeof("CUT_BUFFER0")];
249ecce36beSmrg    char stringpool_str116[sizeof("STRING")];
250ecce36beSmrg    char stringpool_str121[sizeof("FAMILY_NAME")];
251ecce36beSmrg    char stringpool_str149[sizeof("SECONDARY")];
252ecce36beSmrg  };
253ecce36beSmrgstatic const struct stringpool_t stringpool_contents =
254ecce36beSmrg  {
255ecce36beSmrg    "FONT",
256ecce36beSmrg    "NOTICE",
257ecce36beSmrg    "FONT_NAME",
258ecce36beSmrg    "POINT",
259ecce36beSmrg    "WEIGHT",
260ecce36beSmrg    "MIN_SPACE",
261ecce36beSmrg    "CAP_HEIGHT",
262ecce36beSmrg    "BITMAP",
263ecce36beSmrg    "INTEGER",
264ecce36beSmrg    "COPYRIGHT",
265ecce36beSmrg    "FULL_NAME",
266ecce36beSmrg    "STRIKEOUT_ASCENT",
267ecce36beSmrg    "STRIKEOUT_DESCENT",
268ecce36beSmrg    "RGB_GREEN_MAP",
269ecce36beSmrg    "END_SPACE",
270ecce36beSmrg    "RGB_BEST_MAP",
271ecce36beSmrg    "CARDINAL",
272ecce36beSmrg    "CURSOR",
273ecce36beSmrg    "WM_CLIENT_MACHINE",
274ecce36beSmrg    "WM_HINTS",
275ecce36beSmrg    "CUT_BUFFER7",
276ecce36beSmrg    "RGB_GRAY_MAP",
277ecce36beSmrg    "DRAWABLE",
278ecce36beSmrg    "RGB_DEFAULT_MAP",
279ecce36beSmrg    "WINDOW",
280ecce36beSmrg    "RGB_BLUE_MAP",
281ecce36beSmrg    "UNDERLINE_POSITION",
282ecce36beSmrg    "RGB_RED_MAP",
283ecce36beSmrg    "VISUALID",
284ecce36beSmrg    "RECTANGLE",
285ecce36beSmrg    "CUT_BUFFER6",
286ecce36beSmrg    "WM_NAME",
287ecce36beSmrg    "X_HEIGHT",
288ecce36beSmrg    "SUBSCRIPT_Y",
289ecce36beSmrg    "PRIMARY",
290ecce36beSmrg    "COLORMAP",
291ecce36beSmrg    "UNDERLINE_THICKNESS",
292ecce36beSmrg    "QUAD_WIDTH",
293ecce36beSmrg    "RESOURCE_MANAGER",
294ecce36beSmrg    "WM_ICON_NAME",
295ecce36beSmrg    "RGB_COLOR_MAP",
296ecce36beSmrg    "WM_NORMAL_HINTS",
297ecce36beSmrg    "CUT_BUFFER5",
298ecce36beSmrg    "WM_CLASS",
299ecce36beSmrg    "WM_COMMAND",
300ecce36beSmrg    "CUT_BUFFER4",
301ecce36beSmrg    "SUPERSCRIPT_Y",
302ecce36beSmrg    "ATOM",
303ecce36beSmrg    "NORM_SPACE",
304ecce36beSmrg    "WM_TRANSIENT_FOR",
305ecce36beSmrg    "WM_ICON_SIZE",
306ecce36beSmrg    "WM_ZOOM_HINTS",
307ecce36beSmrg    "MAX_SPACE",
308ecce36beSmrg    "POINT_SIZE",
309ecce36beSmrg    "PIXMAP",
310ecce36beSmrg    "RESOLUTION",
311ecce36beSmrg    "SUBSCRIPT_X",
312ecce36beSmrg    "ITALIC_ANGLE",
313ecce36beSmrg    "ARC",
314ecce36beSmrg    "CUT_BUFFER3",
315ecce36beSmrg    "WM_SIZE_HINTS",
316ecce36beSmrg    "CUT_BUFFER2",
317ecce36beSmrg    "CUT_BUFFER1",
318ecce36beSmrg    "SUPERSCRIPT_X",
319ecce36beSmrg    "CUT_BUFFER0",
320ecce36beSmrg    "STRING",
321ecce36beSmrg    "FAMILY_NAME",
322ecce36beSmrg    "SECONDARY"
323ecce36beSmrg  };
324ecce36beSmrg#define stringpool ((const char *) &stringpool_contents)
3252fd93fedSapbstatic
326ecce36beSmrg#ifdef __GNUC__
327ecce36beSmrg__inline
328ecce36beSmrg#ifdef __GNUC_STDC_INLINE__
329ecce36beSmrg__attribute__ ((__gnu_inline__))
330ecce36beSmrg#endif
331ecce36beSmrg#endif
332ecce36beSmrgconst struct atom_map *
333ecce36beSmrgin_word_set (str, len)
334ecce36beSmrg     register const char *str;
335ecce36beSmrg     register unsigned int len;
336ecce36beSmrg{
337ecce36beSmrg  enum
338ecce36beSmrg    {
339ecce36beSmrg      TOTAL_KEYWORDS = 68,
340ecce36beSmrg      MIN_WORD_LENGTH = 3,
341ecce36beSmrg      MAX_WORD_LENGTH = 19,
342ecce36beSmrg      MIN_HASH_VALUE = 4,
343ecce36beSmrg      MAX_HASH_VALUE = 149
344ecce36beSmrg    };
345ecce36beSmrg
346ecce36beSmrg  static const struct atom_map wordlist[] =
347ecce36beSmrg    {
348ecce36beSmrg      {-1}, {-1}, {-1}, {-1},
349ecce36beSmrg#line 112 "atoms.gperf"
350ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str4,18},
351ecce36beSmrg      {-1},
352ecce36beSmrg#line 156 "atoms.gperf"
353ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str6,62},
354ecce36beSmrg      {-1}, {-1},
355ecce36beSmrg#line 157 "atoms.gperf"
356ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str9,63},
357ecce36beSmrg#line 115 "atoms.gperf"
358ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str10,21},
359ecce36beSmrg#line 152 "atoms.gperf"
360ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str11,58},
361ecce36beSmrg      {-1}, {-1},
362ecce36beSmrg#line 137 "atoms.gperf"
363ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str14,43},
364ecce36beSmrg#line 160 "atoms.gperf"
365ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str15,66},
366ecce36beSmrg#line 99 "atoms.gperf"
367ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str16,5},
368ecce36beSmrg#line 113 "atoms.gperf"
369ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str17,19},
370ecce36beSmrg      {-1},
371ecce36beSmrg#line 155 "atoms.gperf"
372ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str19,61},
373ecce36beSmrg      {-1}, {-1}, {-1}, {-1},
374ecce36beSmrg#line 159 "atoms.gperf"
375ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str24,65},
376ecce36beSmrg      {-1},
377ecce36beSmrg#line 147 "atoms.gperf"
378ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str26,53},
379ecce36beSmrg#line 148 "atoms.gperf"
380ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str27,54},
381ecce36beSmrg#line 123 "atoms.gperf"
382ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str28,29},
383ecce36beSmrg#line 140 "atoms.gperf"
384ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str29,46},
385ecce36beSmrg      {-1}, {-1},
386ecce36beSmrg#line 119 "atoms.gperf"
387ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str32,25},
388ecce36beSmrg#line 100 "atoms.gperf"
389ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str33,6},
390ecce36beSmrg      {-1}, {-1},
391ecce36beSmrg#line 102 "atoms.gperf"
392ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str36,8},
393ecce36beSmrg#line 130 "atoms.gperf"
394ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str37,36},
395ecce36beSmrg#line 129 "atoms.gperf"
396ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str38,35},
397ecce36beSmrg      {-1}, {-1},
398ecce36beSmrg#line 110 "atoms.gperf"
399ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str41,16},
400ecce36beSmrg#line 122 "atoms.gperf"
401ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str42,28},
402ecce36beSmrg#line 111 "atoms.gperf"
403ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str43,17},
404ecce36beSmrg      {-1},
405ecce36beSmrg#line 121 "atoms.gperf"
406ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str45,27},
407ecce36beSmrg#line 127 "atoms.gperf"
408ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str46,33},
409ecce36beSmrg#line 120 "atoms.gperf"
410ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str47,26},
411ecce36beSmrg#line 145 "atoms.gperf"
412ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str48,51},
413ecce36beSmrg      {-1}, {-1},
414ecce36beSmrg#line 124 "atoms.gperf"
415ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str51,30},
416ecce36beSmrg      {-1},
417ecce36beSmrg#line 126 "atoms.gperf"
418ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str53,32},
419ecce36beSmrg#line 116 "atoms.gperf"
420ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str54,22},
421ecce36beSmrg      {-1},
422ecce36beSmrg#line 109 "atoms.gperf"
423ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str56,15},
424ecce36beSmrg#line 133 "atoms.gperf"
425ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str57,39},
426ecce36beSmrg#line 150 "atoms.gperf"
427ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str58,56},
428ecce36beSmrg      {-1}, {-1},
429ecce36beSmrg#line 144 "atoms.gperf"
430ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str61,50},
431ecce36beSmrg#line 95 "atoms.gperf"
432ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str62,1},
433ecce36beSmrg#line 101 "atoms.gperf"
434ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str63,7},
435ecce36beSmrg#line 146 "atoms.gperf"
436ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str64,52},
437ecce36beSmrg#line 151 "atoms.gperf"
438ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str65,57},
439ecce36beSmrg#line 117 "atoms.gperf"
440ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str66,23},
441ecce36beSmrg#line 131 "atoms.gperf"
442ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str67,37},
443ecce36beSmrg#line 118 "atoms.gperf"
444ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str68,24},
445ecce36beSmrg      {-1},
446ecce36beSmrg#line 134 "atoms.gperf"
447ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str70,40},
448ecce36beSmrg#line 108 "atoms.gperf"
449ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str71,14},
450ecce36beSmrg      {-1},
451ecce36beSmrg#line 161 "atoms.gperf"
452ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str73,67},
453ecce36beSmrg      {-1},
454ecce36beSmrg#line 128 "atoms.gperf"
455ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str75,34},
456ecce36beSmrg#line 107 "atoms.gperf"
457ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str76,13},
458ecce36beSmrg      {-1},
459ecce36beSmrg#line 142 "atoms.gperf"
460ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str78,48},
461ecce36beSmrg#line 98 "atoms.gperf"
462ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str79,4},
463ecce36beSmrg#line 138 "atoms.gperf"
464ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str80,44},
465ecce36beSmrg#line 162 "atoms.gperf"
466ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str81,68},
467ecce36beSmrg#line 132 "atoms.gperf"
468ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str82,38},
469ecce36beSmrg#line 136 "atoms.gperf"
470ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str83,42},
471ecce36beSmrg#line 139 "atoms.gperf"
472ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str84,45},
473ecce36beSmrg#line 153 "atoms.gperf"
474ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str85,59},
475ecce36beSmrg#line 114 "atoms.gperf"
476ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str86,20},
477ecce36beSmrg      {-1}, {-1}, {-1},
478ecce36beSmrg#line 154 "atoms.gperf"
479ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str90,60},
480ecce36beSmrg#line 143 "atoms.gperf"
481ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str91,49},
482ecce36beSmrg#line 149 "atoms.gperf"
483ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str92,55},
484ecce36beSmrg#line 97 "atoms.gperf"
485ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str93,3},
486ecce36beSmrg      {-1}, {-1},
487ecce36beSmrg#line 106 "atoms.gperf"
488ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str96,12},
489ecce36beSmrg      {-1},
490ecce36beSmrg#line 135 "atoms.gperf"
491ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str98,41},
492ecce36beSmrg      {-1}, {-1},
493ecce36beSmrg#line 105 "atoms.gperf"
494ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str101,11},
495ecce36beSmrg      {-1}, {-1}, {-1}, {-1},
496ecce36beSmrg#line 104 "atoms.gperf"
497ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str106,10},
498ecce36beSmrg      {-1},
499ecce36beSmrg#line 141 "atoms.gperf"
500ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str108,47},
501ecce36beSmrg      {-1}, {-1},
502ecce36beSmrg#line 103 "atoms.gperf"
503ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str111,9},
504ecce36beSmrg      {-1}, {-1}, {-1}, {-1},
505ecce36beSmrg#line 125 "atoms.gperf"
506ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str116,31},
507ecce36beSmrg      {-1}, {-1}, {-1}, {-1},
508ecce36beSmrg#line 158 "atoms.gperf"
509ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str121,64},
510ecce36beSmrg      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
511ecce36beSmrg      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
512ecce36beSmrg      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
513ecce36beSmrg#line 96 "atoms.gperf"
514ecce36beSmrg      {(int)(long)&((struct stringpool_t *)0)->stringpool_str149,2}
515ecce36beSmrg    };
516ecce36beSmrg
517ecce36beSmrg  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
518ecce36beSmrg    {
519ecce36beSmrg      register int key = hash (str, len);
520ecce36beSmrg
521ecce36beSmrg      if (key <= MAX_HASH_VALUE && key >= 0)
522ecce36beSmrg        {
523ecce36beSmrg          register int o = wordlist[key].name;
524ecce36beSmrg          if (o >= 0)
525ecce36beSmrg            {
526ecce36beSmrg              register const char *s = o + stringpool;
527ecce36beSmrg
528ecce36beSmrg              if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
529ecce36beSmrg                return &wordlist[key];
530ecce36beSmrg            }
531ecce36beSmrg        }
532ecce36beSmrg    }
533ecce36beSmrg  return 0;
534ecce36beSmrg}
535ecce36beSmrg#line 163 "atoms.gperf"
536ecce36beSmrg
537ecce36beSmrg
538ecce36beSmrgstatic const char atom_names[] =
539ecce36beSmrg	"PRIMARY\0"
540ecce36beSmrg	"SECONDARY\0"
541ecce36beSmrg	"ARC\0"
542ecce36beSmrg	"ATOM\0"
543ecce36beSmrg	"BITMAP\0"
544ecce36beSmrg	"CARDINAL\0"
545ecce36beSmrg	"COLORMAP\0"
546ecce36beSmrg	"CURSOR\0"
547ecce36beSmrg	"CUT_BUFFER0\0"
548ecce36beSmrg	"CUT_BUFFER1\0"
549ecce36beSmrg	"CUT_BUFFER2\0"
550ecce36beSmrg	"CUT_BUFFER3\0"
551ecce36beSmrg	"CUT_BUFFER4\0"
552ecce36beSmrg	"CUT_BUFFER5\0"
553ecce36beSmrg	"CUT_BUFFER6\0"
554ecce36beSmrg	"CUT_BUFFER7\0"
555ecce36beSmrg	"DRAWABLE\0"
556ecce36beSmrg	"FONT\0"
557ecce36beSmrg	"INTEGER\0"
558ecce36beSmrg	"PIXMAP\0"
559ecce36beSmrg	"POINT\0"
560ecce36beSmrg	"RECTANGLE\0"
561ecce36beSmrg	"RESOURCE_MANAGER\0"
562ecce36beSmrg	"RGB_COLOR_MAP\0"
563ecce36beSmrg	"RGB_BEST_MAP\0"
564ecce36beSmrg	"RGB_BLUE_MAP\0"
565ecce36beSmrg	"RGB_DEFAULT_MAP\0"
566ecce36beSmrg	"RGB_GRAY_MAP\0"
567ecce36beSmrg	"RGB_GREEN_MAP\0"
568ecce36beSmrg	"RGB_RED_MAP\0"
569ecce36beSmrg	"STRING\0"
570ecce36beSmrg	"VISUALID\0"
571ecce36beSmrg	"WINDOW\0"
572ecce36beSmrg	"WM_COMMAND\0"
573ecce36beSmrg	"WM_HINTS\0"
574ecce36beSmrg	"WM_CLIENT_MACHINE\0"
575ecce36beSmrg	"WM_ICON_NAME\0"
576ecce36beSmrg	"WM_ICON_SIZE\0"
577ecce36beSmrg	"WM_NAME\0"
578ecce36beSmrg	"WM_NORMAL_HINTS\0"
579ecce36beSmrg	"WM_SIZE_HINTS\0"
580ecce36beSmrg	"WM_ZOOM_HINTS\0"
581ecce36beSmrg	"MIN_SPACE\0"
582ecce36beSmrg	"NORM_SPACE\0"
583ecce36beSmrg	"MAX_SPACE\0"
584ecce36beSmrg	"END_SPACE\0"
585ecce36beSmrg	"SUPERSCRIPT_X\0"
586ecce36beSmrg	"SUPERSCRIPT_Y\0"
587ecce36beSmrg	"SUBSCRIPT_X\0"
588ecce36beSmrg	"SUBSCRIPT_Y\0"
589ecce36beSmrg	"UNDERLINE_POSITION\0"
590ecce36beSmrg	"UNDERLINE_THICKNESS\0"
591ecce36beSmrg	"STRIKEOUT_ASCENT\0"
592ecce36beSmrg	"STRIKEOUT_DESCENT\0"
593ecce36beSmrg	"ITALIC_ANGLE\0"
594ecce36beSmrg	"X_HEIGHT\0"
595ecce36beSmrg	"QUAD_WIDTH\0"
596ecce36beSmrg	"WEIGHT\0"
597ecce36beSmrg	"POINT_SIZE\0"
598ecce36beSmrg	"RESOLUTION\0"
599ecce36beSmrg	"COPYRIGHT\0"
600ecce36beSmrg	"NOTICE\0"
601ecce36beSmrg	"FONT_NAME\0"
602ecce36beSmrg	"FAMILY_NAME\0"
603ecce36beSmrg	"FULL_NAME\0"
604ecce36beSmrg	"CAP_HEIGHT\0"
605ecce36beSmrg	"WM_CLASS\0"
606ecce36beSmrg	"WM_TRANSIENT_FOR\0"
607ecce36beSmrg;
608ecce36beSmrg
609ecce36beSmrgstatic const uint16_t atom_name_offsets[] = {
610ecce36beSmrg	0,
611ecce36beSmrg	8,
612ecce36beSmrg	18,
613ecce36beSmrg	22,
614ecce36beSmrg	27,
615ecce36beSmrg	34,
616ecce36beSmrg	43,
617ecce36beSmrg	52,
618ecce36beSmrg	59,
619ecce36beSmrg	71,
620ecce36beSmrg	83,
621ecce36beSmrg	95,
622ecce36beSmrg	107,
623ecce36beSmrg	119,
624ecce36beSmrg	131,
625ecce36beSmrg	143,
626ecce36beSmrg	155,
627ecce36beSmrg	164,
628ecce36beSmrg	169,
629ecce36beSmrg	177,
630ecce36beSmrg	184,
631ecce36beSmrg	190,
632ecce36beSmrg	200,
633ecce36beSmrg	217,
634ecce36beSmrg	231,
635ecce36beSmrg	244,
636ecce36beSmrg	257,
637ecce36beSmrg	273,
638ecce36beSmrg	286,
639ecce36beSmrg	300,
640ecce36beSmrg	312,
641ecce36beSmrg	319,
642ecce36beSmrg	328,
643ecce36beSmrg	335,
644ecce36beSmrg	346,
645ecce36beSmrg	355,
646ecce36beSmrg	373,
647ecce36beSmrg	386,
648ecce36beSmrg	399,
649ecce36beSmrg	407,
650ecce36beSmrg	423,
651ecce36beSmrg	437,
652ecce36beSmrg	451,
653ecce36beSmrg	461,
654ecce36beSmrg	472,
655ecce36beSmrg	482,
656ecce36beSmrg	492,
657ecce36beSmrg	506,
658ecce36beSmrg	520,
659ecce36beSmrg	532,
660ecce36beSmrg	544,
661ecce36beSmrg	563,
662ecce36beSmrg	583,
663ecce36beSmrg	600,
664ecce36beSmrg	618,
665ecce36beSmrg	631,
666ecce36beSmrg	640,
667ecce36beSmrg	651,
668ecce36beSmrg	658,
669ecce36beSmrg	669,
670ecce36beSmrg	680,
671ecce36beSmrg	690,
672ecce36beSmrg	697,
673ecce36beSmrg	707,
674ecce36beSmrg	719,
675ecce36beSmrg	729,
676ecce36beSmrg	740,
677ecce36beSmrg	749,
678ecce36beSmrg};
679ecce36beSmrg
680ecce36beSmrgxcb_atom_t xcb_atom_get(xcb_connection_t *connection, const char *atom_name)
681ecce36beSmrg{
682ecce36beSmrg	if(atom_name == NULL)
683ecce36beSmrg		return XCB_NONE;
684ecce36beSmrg	xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection,
685ecce36beSmrg		xcb_intern_atom(connection, 0, strlen(atom_name), atom_name), NULL);
686ecce36beSmrg	if(!reply)
687ecce36beSmrg		return XCB_NONE;
688ecce36beSmrg	xcb_atom_t atom = reply->atom;
689ecce36beSmrg	free(reply);
690ecce36beSmrg	return atom;
691ecce36beSmrg}
692ecce36beSmrg
693ecce36beSmrgxcb_atom_t xcb_atom_get_predefined(uint16_t name_len, const char *name)
694ecce36beSmrg{
695ecce36beSmrg	const struct atom_map *value = in_word_set(name, name_len);
696ecce36beSmrg	xcb_atom_t ret = XCB_NONE;
697ecce36beSmrg	if(value)
698ecce36beSmrg		ret = value->value;
699ecce36beSmrg	return ret;
700ecce36beSmrg}
701ecce36beSmrg
702ecce36beSmrgxcb_atom_fast_cookie_t xcb_atom_get_fast(xcb_connection_t *c, uint8_t only_if_exists, uint16_t name_len, const char *name)
703ecce36beSmrg{
704ecce36beSmrg	xcb_atom_fast_cookie_t cookie;
705ecce36beSmrg
706ecce36beSmrg	if((cookie.u.atom = xcb_atom_get_predefined(name_len, name)) != XCB_NONE)
707ecce36beSmrg	{
708ecce36beSmrg		cookie.tag = TAG_VALUE;
709ecce36beSmrg		return cookie;
710ecce36beSmrg	}
711ecce36beSmrg
712ecce36beSmrg	cookie.tag = TAG_COOKIE;
713ecce36beSmrg	cookie.u.cookie = xcb_intern_atom(c, only_if_exists, name_len, name);
714ecce36beSmrg	return cookie;
715ecce36beSmrg}
716ecce36beSmrg
717ecce36beSmrgxcb_atom_t xcb_atom_get_fast_reply(xcb_connection_t *c, xcb_atom_fast_cookie_t cookie, xcb_generic_error_t **e)
718ecce36beSmrg{
719ecce36beSmrg	switch(cookie.tag)
720ecce36beSmrg	{
721ecce36beSmrg		xcb_intern_atom_reply_t *reply;
722ecce36beSmrg	case TAG_VALUE:
723ecce36beSmrg		if(e)
724ecce36beSmrg			*e = 0;
725ecce36beSmrg		break;
726ecce36beSmrg	case TAG_COOKIE:
727ecce36beSmrg		reply = xcb_intern_atom_reply(c, cookie.u.cookie, e);
728ecce36beSmrg		if(reply)
729ecce36beSmrg		{
730ecce36beSmrg			cookie.u.atom = reply->atom;
731ecce36beSmrg			free(reply);
732ecce36beSmrg		}
733ecce36beSmrg		else
734ecce36beSmrg			cookie.u.atom = XCB_NONE;
735ecce36beSmrg		break;
736ecce36beSmrg	}
737ecce36beSmrg	return cookie.u.atom;
738ecce36beSmrg}
739ecce36beSmrg
740ecce36beSmrgconst char *xcb_atom_get_name_predefined(xcb_atom_t atom)
741ecce36beSmrg{
742ecce36beSmrg	if(atom <= 0 || atom > (sizeof(atom_name_offsets) / sizeof(*atom_name_offsets)))
743ecce36beSmrg		return 0;
744ecce36beSmrg	return atom_names + atom_name_offsets[atom - 1];
745ecce36beSmrg}
746ecce36beSmrg
747ecce36beSmrgint xcb_atom_get_name(xcb_connection_t *c, xcb_atom_t atom, const char **namep, int *lengthp)
748ecce36beSmrg{
749ecce36beSmrg	static char buf[100];
750ecce36beSmrg	const char *name = xcb_atom_get_name_predefined(atom);
751ecce36beSmrg	int namelen;
752ecce36beSmrg	xcb_get_atom_name_cookie_t atomc;
753ecce36beSmrg	xcb_get_atom_name_reply_t *atomr;
754ecce36beSmrg	if(name)
755ecce36beSmrg	{
756ecce36beSmrg		*namep = name;
757ecce36beSmrg		*lengthp = strlen(name);
758ecce36beSmrg		return 1;
759ecce36beSmrg	}
760ecce36beSmrg	atomc = xcb_get_atom_name(c, atom);
761ecce36beSmrg	atomr = xcb_get_atom_name_reply(c, atomc, 0);
762ecce36beSmrg	if(!atomr)
763ecce36beSmrg		return 0;
764ecce36beSmrg	namelen = xcb_get_atom_name_name_length(atomr);
765ecce36beSmrg	if(namelen > sizeof(buf))
766ecce36beSmrg		namelen = sizeof(buf);
767ecce36beSmrg	*lengthp = namelen;
768ecce36beSmrg	memcpy(buf, xcb_get_atom_name_name(atomr), namelen);
769ecce36beSmrg	*namep = buf;
770ecce36beSmrg	free(atomr);
771ecce36beSmrg	return 1;
772ecce36beSmrg}
773ecce36beSmrg
774ecce36beSmrgstatic char *makename(const char *fmt, ...)
775ecce36beSmrg{
776ecce36beSmrg	char *ret;
777ecce36beSmrg	int n;
778ecce36beSmrg	va_list ap;
779ecce36beSmrg
780ecce36beSmrg#ifndef HAVE_VASPRINTF
781ecce36beSmrg	char *np;
782ecce36beSmrg	int size = 64;
783ecce36beSmrg
784ecce36beSmrg	/* First allocate 'size' bytes, should be enough usually */
785ecce36beSmrg	if((ret = malloc(size)) == NULL)
786ecce36beSmrg		return NULL;
787ecce36beSmrg
788ecce36beSmrg	while(1)
789ecce36beSmrg	{
790ecce36beSmrg		va_start(ap, fmt);
791ecce36beSmrg		n = vsnprintf(ret, size, fmt, ap);
792ecce36beSmrg		va_end(ap);
793ecce36beSmrg
794ecce36beSmrg		if(n < 0)
795ecce36beSmrg			return NULL;
796ecce36beSmrg
797ecce36beSmrg		if(n < size)
798ecce36beSmrg			return ret;
799ecce36beSmrg
800ecce36beSmrg		size = n + 1;
801ecce36beSmrg		if((np = realloc(ret, size)) == NULL)
802ecce36beSmrg		{
803ecce36beSmrg			free(ret);
804ecce36beSmrg			return NULL;
805ecce36beSmrg		}
806ecce36beSmrg
807ecce36beSmrg		ret = np;
808ecce36beSmrg	}
809ecce36beSmrg#else
810ecce36beSmrg	va_start(ap, fmt);
811ecce36beSmrg	n = vasprintf(&ret, fmt, ap);
812ecce36beSmrg	va_end(ap);
813ecce36beSmrg
814ecce36beSmrg	if(n < 0)
815ecce36beSmrg		return NULL;
816ecce36beSmrg
817ecce36beSmrg	return ret;
818ecce36beSmrg#endif
819ecce36beSmrg}
820ecce36beSmrg
821ecce36beSmrgchar *xcb_atom_name_by_screen(const char *base, uint8_t screen)
822ecce36beSmrg{
823ecce36beSmrg	return makename("%s_S%u", base, screen);
824ecce36beSmrg}
825ecce36beSmrg
826ecce36beSmrgchar *xcb_atom_name_by_resource(const char *base, uint32_t resource)
827ecce36beSmrg{
828ecce36beSmrg	return makename("%s_R%08X", base, resource);
829ecce36beSmrg}
830ecce36beSmrg
831ecce36beSmrgchar *xcb_atom_name_unique(const char *base, uint32_t id)
832ecce36beSmrg{
833ecce36beSmrg	if(base)
834ecce36beSmrg		return makename("%s_U%lu", base, id);
835ecce36beSmrg	else
836ecce36beSmrg		return makename("U%lu", id);
837ecce36beSmrg}
838