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