1 /*
2 * Table initialization for X11 protocol
3 *
4 * James Peterson, 1988
5 *
6 * Copyright (C) 1988 MCC
7 *
8 * Permission to use, copy, modify, distribute, and sell this software and its
9 * documentation for any purpose is hereby granted without fee, provided that
10 * the above copyright notice appear in all copies and that both that
11 * copyright notice and this permission notice appear in supporting
12 * documentation, and that the name of MCC not be used in
13 * advertising or publicity pertaining to distribution of the software without
14 * specific, written prior permission. MCC makes no
15 * representations about the suitability of this software for any purpose. It
16 * is provided "as is" without express or implied warranty.
17 *
18 * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
20 * EVENT SHALL MCC BE LIABLE FOR ANY SPECIAL, INDIRECT OR
21 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
22 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
23 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24 * PERFORMANCE OF THIS SOFTWARE.
25 *
26 */
27 /*
28 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
29 *
30 * Permission is hereby granted, free of charge, to any person obtaining a
31 * copy of this software and associated documentation files (the "Software"),
32 * to deal in the Software without restriction, including without limitation
33 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
34 * and/or sell copies of the Software, and to permit persons to whom the
35 * Software is furnished to do so, subject to the following conditions:
36 *
37 * The above copyright notice and this permission notice (including the next
38 * paragraph) shall be included in all copies or substantial portions of the
39 * Software.
40 *
41 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
44 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
46 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
47 * DEALINGS IN THE SOFTWARE.
48 *
49 */
50
51 #include "scope.h"
52 #include "x11.h"
53
54 #include <sys/types.h>
55 #include <sys/socket.h>
56 #include <netinet/in.h>
57 #include <arpa/inet.h>
58
59 static void InitBuiltInTypes(void);
60 static void InitEnumeratedTypes(void);
61 static void InitSetTypes(void);
62 static void InitRecordTypes(void);
63 static void InitValuesTypes(void);
64
65 static int PrintCHAR2B(const unsigned char *buf);
66 static int PrintPOINT(const unsigned char *buf);
67 static int PrintRECTANGLE(const unsigned char *buf);
68 static int PrintARC(const unsigned char *buf);
69 static int PrintHOST(const unsigned char *buf);
70 static int PrintTIMECOORD(const unsigned char *buf);
71 static int PrintFONTPROP(const unsigned char *buf);
72 static int PrintCHARINFO(const unsigned char *buf);
73 static int PrintSEGMENT(const unsigned char *buf);
74 static int PrintCOLORITEM(const unsigned char *buf);
75 static int PrintRGB(const unsigned char *buf);
76 static int PrintFORMAT(const unsigned char *buf);
77 static int PrintSCREEN(const unsigned char *buf);
78 static int PrintDEPTH(const unsigned char *buf);
79 static int PrintVISUALTYPE(const unsigned char *buf);
80
81 /*
82 To initialize for the X11 protocol, we need to create data structures
83 describing the data types used by X11.
84 */
85
86 /*
87 There are about 100-128 data types for X11. This start with the simple
88 INT8, INT16, INT32 (byte, short, long), and the CARD8, CARD16, CARD32
89 (unsigned) and extend to records like RGB (a resource id, 3 color
90 values and a bitmask to select a subset of the 3 color values). Each
91 data type has an assigned type index. The type index identifies the
92 type (with a #define in x11.h) and is used to access an entry in an
93 array of type descriptors (TD). Each type descriptor has the type name,
94 the kind of type, and a procedure to print an object of that type.
95 The print procedure for a type <foo> is named Print<foo>. The kind of
96 type is
97
98 BUILTIN: one of the primitive types.
99 ENUMERATED: value should be one of a small set of values. This type
100 needs a list of allowed values (and their print names).
101 SET: value is a bitmask of a small set of values. Each value
102 is a one-bit mask (and its print name).
103 RECORD: value is a record of fields of other types.
104
105 The Type Descriptor array allows us to print a value if we know its type
106 (index) and the bytes in memory that are its value.
107 */
108
109 void
InitializeX11(void)110 InitializeX11(void)
111 {
112 CS = calloc(MaxFD, sizeof(struct ConnState));
113 if (CS == NULL)
114 panic("unable to allocate ConnState table");
115 InitReplyQ();
116
117 InitBuiltInTypes();
118 InitEnumeratedTypes();
119 InitSetTypes();
120 InitValuesTypes();
121 InitRecordTypes();
122 }
123
124 #define HASH_SIZE 997
125
126 ValuePtr buckets[HASH_SIZE];
127
128 #define HASH(key) ((key) % HASH_SIZE)
129
130 ValuePtr
GetValueRec(uint32_t key)131 GetValueRec(uint32_t key)
132 {
133 ValuePtr *bucket, value;
134
135 bucket = &buckets[HASH(key)];
136 for (value = *bucket; value; value = value->next) {
137 if (value->key == key)
138 return value;
139 }
140 return NULL;
141 }
142
143 void
CreateValueRec(uint32_t key,int size,const uint32_t * def)144 CreateValueRec(uint32_t key, int size, const uint32_t *def)
145 {
146 ValuePtr *bucket, value;
147 int i;
148
149 bucket = &buckets[HASH(key)];
150 value = malloc(sizeof(ValueRec) + (size * sizeof(uint32_t)));
151 if (!value)
152 return;
153 value->values = (uint32_t *) (value + 1);
154 for (i = 0; i < size; i++)
155 value->values[i] = ILong((const unsigned char *) (def + i));
156 value->size = size;
157 value->key = key;
158 value->next = *bucket;
159 *bucket = value;
160 }
161
162 void
DeleteValueRec(uint32_t key)163 DeleteValueRec(uint32_t key)
164 {
165 ValuePtr *bucket, value;
166
167 for (bucket = &buckets[HASH(key)]; (value = *bucket) != NULL;
168 bucket = &value->next) {
169 if (value->key == key) {
170 *bucket = value->next;
171 free(value);
172 return;
173 }
174 }
175 }
176
177 void
SetValueRec(uint32_t key,const unsigned char * control,short clength,short ctype,const unsigned char * values)178 SetValueRec(uint32_t key,
179 const unsigned char *control,
180 short clength, short ctype, const unsigned char *values)
181 {
182 uint32_t cmask;
183 struct ValueListEntry *p;
184 ValuePtr value;
185 int i;
186
187 value = GetValueRec(key);
188 if (!value)
189 return;
190 /* first get the control mask */
191 if (clength == 1)
192 cmask = IByte(control);
193 else if (clength == 2)
194 cmask = IShort(control);
195 else
196 cmask = ILong(control);
197
198 /* now if it is zero, ignore and return */
199 if (cmask == 0)
200 return;
201 /* there are bits in the controlling bitmask, figure out which */
202 /* the ctype is a set type, so this code is similar to PrintSET */
203 for (p = TD[ctype].ValueList, i = 0; p != NULL; p = p->Next, i++) {
204 if ((p->Value & cmask) != 0) {
205 memcpy(&value->values[i], values, sizeof(uint32_t));
206 values += 4;
207 }
208 }
209 }
210
211 /* ************************************************************ */
212 /* */
213 /* */
214 /* ************************************************************ */
215
216 /* define the various types */
217
218 TYPE
DefineType(short typeid,short class,const char * name,int (* printproc)(const unsigned char *))219 DefineType(short typeid,
220 short class,
221 const char *name, int (*printproc) (const unsigned char *))
222 {
223 TD[typeid].Name = name;
224 TD[typeid].Type = class;
225 TD[typeid].ValueList = NULL;
226 TD[typeid].PrintProc = printproc;
227 return (&TD[typeid]);
228 }
229
230 /* ************************************************************ */
231 /* define an Enumerated Value (or a Set Value) */
232
233 void
DefineEValue(TYPE type,long value,const char * name)234 DefineEValue(TYPE type, long value, const char *name)
235 {
236 struct ValueListEntry *p;
237
238 /* define the new value */
239 p = malloc(sizeof(struct ValueListEntry));
240 if (p == NULL)
241 panic("Can't allocate memory for Enum ValueListEntry");
242 p->Name = name;
243 p->Value = value;
244
245 /* add an new value to the list. */
246 if (type->ValueList == NULL || type->ValueList->Value > p->Value) {
247 p->Next = type->ValueList;
248 type->ValueList = p;
249 }
250 else {
251 /* keep the list sorted, smallest to largest */
252 struct ValueListEntry *q = type->ValueList;
253
254 while (q->Next != NULL && q->Next->Value < p->Value)
255 q = q->Next;
256 p->Next = q->Next;
257 q->Next = p;
258 }
259 }
260
261 long
GetEValue(short typeid,const char * name)262 GetEValue(short typeid, const char *name)
263 {
264 TYPE p;
265 struct ValueListEntry *v;
266
267 if (typeid < 0 || MaxTypes <= typeid)
268 return -1;
269 p = &TD[typeid];
270 if (!p)
271 return -2;
272 for (v = p->ValueList; v; v = v->Next)
273 if (!strcmp(name, v->Name))
274 return v->Value;
275 return -3;
276 }
277
278 /* ************************************************************ */
279 /* a Values list is like an enumerated Value, but has a type and length
280 in addition to a value and name. It is used to print a Values List */
281
282 /* A Values List is a bitmask (like a set), but if the bit is set on, then
283 we have an associated value. We need to know the length and type of the
284 associated value for each bit */
285
286 void
DefineValues(TYPE type,long value,short length,short ctype,const char * name)287 DefineValues(TYPE type, long value, short length, short ctype, const char *name)
288 {
289 struct ValueListEntry *p;
290
291 p = malloc(sizeof(struct ValueListEntry));
292 if (p == NULL)
293 panic("Can't allocate memory for ValueListEntry");
294 p->Name = name;
295 p->Type = ctype;
296 p->Length = length;
297 p->Value = value;
298
299 /* add an new value to the list. */
300 if (type->ValueList == NULL || type->ValueList->Value > p->Value) {
301 p->Next = type->ValueList;
302 type->ValueList = p;
303 }
304 else {
305 /* keep the list sorted, smallest to largest */
306 struct ValueListEntry *q = type->ValueList;
307
308 while (q->Next != NULL && q->Next->Value < p->Value)
309 q = q->Next;
310 p->Next = q->Next;
311 q->Next = p;
312 }
313 }
314
315
316
317 /* ************************************************************ */
318 /* Atoms are defined as a builtin type for the core protocol defined
319 atoms, with atoms passed via InternAtom & GetAtomName added as
320 additional enumerated type values */
321 #define NumberofAtoms 68
322
323 static const char *const AtomTable[NumberofAtoms + 1] = {
324 "NONE", "PRIMARY", "SECONDARY", "ARC", "ATOM", "BITMAP", "CARDINAL",
325 "COLORMAP", "CURSOR", "CUT_BUFFER0", "CUT_BUFFER1", "CUT_BUFFER2",
326 "CUT_BUFFER3", "CUT_BUFFER4", "CUT_BUFFER5", "CUT_BUFFER6",
327 "CUT_BUFFER7", "DRAWABLE", "FONT", "INTEGER", "PIXMAP", "POINT",
328 "RECTANGLE", "RESOURCE_MANAGER", "RGB_COLOR_MAP", "RGB_BEST_MAP",
329 "RGB_BLUE_MAP", "RGB_DEFAULT_MAP", "RGB_GRAY_MAP", "RGB_GREEN_MAP",
330 "RGB_RED_MAP", "STRING", "VISUALID", "WINDOW", "WM_COMMAND",
331 "WM_HINTS", "WM_CLIENT_MACHINE", "WM_ICON_NAME", "WM_ICON_SIZE",
332 "WM_NAME", "WM_NORMAL_HINTS", "WM_SIZE_HINTS", "WM_ZOOM_HINTS",
333 "MIN_SPACE", "NORM_SPACE", "MAX_SPACE", "END_SPACE", "SUPERSCRIPT_X",
334 "SUPERSCRIPT_Y", "SUBSCRIPT_X", "SUBSCRIPT_Y", "UNDERLINE_POSITION",
335 "UNDERLINE_THICKNESS", "STRIKEOUT_ASCENT", "STRIKEOUT_DESCENT",
336 "ITALIC_ANGLE", "X_HEIGHT", "QUAD_WIDTH", "WEIGHT", "POINT_SIZE",
337 "RESOLUTION", "COPYRIGHT", "NOTICE", "FONT_NAME", "FAMILY_NAME",
338 "FULL_NAME", "CAP_HEIGHT", "WM_CLASS", "WM_TRANSIENT_FOR"
339 };
340
341 const char *
FindAtomName(uint32_t atom)342 FindAtomName(uint32_t atom)
343 {
344 struct ValueListEntry *p;
345
346 if (atom <= NumberofAtoms)
347 return AtomTable[atom];
348
349 for (p = TD[ATOM].ValueList; p != NULL; p = p->Next) {
350 if (p->Value == atom)
351 return p->Name;
352 }
353
354 return NULL;
355 }
356
357 void
DefineAtom(uint32_t atom,const char * name)358 DefineAtom(uint32_t atom, const char *name)
359 {
360 if ((atom == 0) || (name == NULL))
361 return;
362
363 if (FindAtomName(atom) == NULL)
364 DefineEValue(&TD[ATOM], atom, strdup(name));
365 }
366
367
368 /* ************************************************************ */
369
370 static void
InitBuiltInTypes(void)371 InitBuiltInTypes(void)
372 {
373 (void) DefineType(INT8, BUILTIN, "INT8", PrintINT8);
374 (void) DefineType(INT16, BUILTIN, "INT16", PrintINT16);
375 (void) DefineType(INT32, BUILTIN, "INT32", PrintINT32);
376 (void) DefineType(CARD8, BUILTIN, "CARD8", PrintCARD8);
377 (void) DefineType(CARD16, BUILTIN, "CARD16", PrintCARD16);
378 (void) DefineType(CARD32, BUILTIN, "CARD32", PrintCARD32);
379 (void) DefineType(BYTE, BUILTIN, "BYTE", PrintBYTE);
380 (void) DefineType(CHAR8, BUILTIN, "CHAR8", PrintCHAR8);
381 (void) DefineType(STRING16, BUILTIN, "STRING16", PrintSTRING16);
382 (void) DefineType(STR, BUILTIN, "STR", PrintSTR);
383 (void) DefineType(WINDOW, BUILTIN, "WINDOW", PrintWINDOW);
384 (void) DefineType(WINDOWD, BUILTIN, "WINDOWD", PrintWINDOWD);
385 (void) DefineType(WINDOWNR, BUILTIN, "WINDOWNR", PrintWINDOWNR);
386 (void) DefineType(PIXMAP, BUILTIN, "PIXMAP", PrintPIXMAP);
387 (void) DefineType(PIXMAPNPR, BUILTIN, "PIXMAPNPR", PrintPIXMAPNPR);
388 (void) DefineType(PIXMAPC, BUILTIN, "PIXMAPC", PrintPIXMAPC);
389 (void) DefineType(CURSOR, BUILTIN, "CURSOR", PrintCURSOR);
390 (void) DefineType(FONT, BUILTIN, "FONT", PrintFONT);
391 (void) DefineType(GCONTEXT, BUILTIN, "GCONTEXT", PrintGCONTEXT);
392 (void) DefineType(COLORMAP, BUILTIN, "COLORMAP", PrintCOLORMAP);
393 (void) DefineType(COLORMAPC, BUILTIN, "COLORMAPC", PrintCOLORMAPC);
394 (void) DefineType(DRAWABLE, BUILTIN, "DRAWABLE", PrintDRAWABLE);
395 (void) DefineType(FONTABLE, BUILTIN, "FONTABLE", PrintFONTABLE);
396 (void) DefineType(ATOM, BUILTIN, "ATOM", PrintATOM);
397 (void) DefineType(ATOMT, BUILTIN, "ATOMT", PrintATOMT);
398 (void) DefineType(VISUALID, BUILTIN, "VISUALID", PrintVISUALID);
399 (void) DefineType(VISUALIDC, BUILTIN, "VISUALIDC", PrintVISUALIDC);
400 (void) DefineType(TIMESTAMP, BUILTIN, "TIMESTAMP", PrintTIMESTAMP);
401 (void) DefineType(RESOURCEID, BUILTIN, "RESOURCEID", PrintRESOURCEID);
402 (void) DefineType(KEYSYM, BUILTIN, "KEYSYM", PrintKEYSYM);
403 (void) DefineType(KEYCODE, BUILTIN, "KEYCODE", PrintKEYCODE);
404 (void) DefineType(KEYCODEA, BUILTIN, "KEYCODEA", PrintKEYCODEA);
405 (void) DefineType(BUTTON, BUILTIN, "BUTTON", PrintBUTTON);
406 (void) DefineType(BUTTONA, BUILTIN, "BUTTONA", PrintBUTTONA);
407 (void) DefineType(EVENTFORM, BUILTIN, "EVENTFORM", PrintEVENTFORM);
408 }
409
410 /* ************************************************************ */
411 /* */
412 /* */
413 /* ************************************************************ */
414
415 static void
InitEnumeratedTypes(void)416 InitEnumeratedTypes(void)
417 {
418 TYPE p;
419
420 p = DefineType(REQUEST, ENUMERATED, "REQUEST",
421 (PrintProcType) PrintENUMERATED);
422 DefineEValue(p, 1L, "CreateWindow");
423 DefineEValue(p, 2L, "ChangeWindowAttributes");
424 DefineEValue(p, 3L, "GetWindowAttributes");
425 DefineEValue(p, 4L, "DestroyWindow");
426 DefineEValue(p, 5L, "DestroySubwindows");
427 DefineEValue(p, 6L, "ChangeSaveSet");
428 DefineEValue(p, 7L, "ReparentWindow");
429 DefineEValue(p, 8L, "MapWindow");
430 DefineEValue(p, 9L, "MapSubwindows");
431 DefineEValue(p, 10L, "UnmapWindow");
432 DefineEValue(p, 11L, "UnmapSubwindows");
433 DefineEValue(p, 12L, "ConfigureWindow");
434 DefineEValue(p, 13L, "CirculateWindow");
435 DefineEValue(p, 14L, "GetGeometry");
436 DefineEValue(p, 15L, "QueryTree");
437 DefineEValue(p, 16L, "InternAtom");
438 DefineEValue(p, 17L, "GetAtomName");
439 DefineEValue(p, 18L, "ChangeProperty");
440 DefineEValue(p, 19L, "DeleteProperty");
441 DefineEValue(p, 20L, "GetProperty");
442 DefineEValue(p, 21L, "ListProperties");
443 DefineEValue(p, 22L, "SetSelectionOwner");
444 DefineEValue(p, 23L, "GetSelectionOwner");
445 DefineEValue(p, 24L, "ConvertSelection");
446 DefineEValue(p, 25L, "SendEvent");
447 DefineEValue(p, 26L, "GrabPointer");
448 DefineEValue(p, 27L, "UngrabPointer");
449 DefineEValue(p, 28L, "GrabButton");
450 DefineEValue(p, 29L, "UngrabButton");
451 DefineEValue(p, 30L, "ChangeActivePointerGrab");
452 DefineEValue(p, 31L, "GrabKeyboard");
453 DefineEValue(p, 32L, "UngrabKeyboard");
454 DefineEValue(p, 33L, "GrabKey");
455 DefineEValue(p, 34L, "UngrabKey");
456 DefineEValue(p, 35L, "AllowEvents");
457 DefineEValue(p, 36L, "GrabServer");
458 DefineEValue(p, 37L, "UngrabServer");
459 DefineEValue(p, 38L, "QueryPointer");
460 DefineEValue(p, 39L, "GetMotionEvents");
461 DefineEValue(p, 40L, "TranslateCoordinates");
462 DefineEValue(p, 41L, "WarpPointer");
463 DefineEValue(p, 42L, "SetInputFocus");
464 DefineEValue(p, 43L, "GetInputFocus");
465 DefineEValue(p, 44L, "QueryKeymap");
466 DefineEValue(p, 45L, "OpenFont");
467 DefineEValue(p, 46L, "CloseFont");
468 DefineEValue(p, 47L, "QueryFont");
469 DefineEValue(p, 48L, "QueryTextExtents");
470 DefineEValue(p, 49L, "ListFonts");
471 DefineEValue(p, 50L, "ListFontsWithInfo");
472 DefineEValue(p, 51L, "SetFontPath");
473 DefineEValue(p, 52L, "GetFontPath");
474 DefineEValue(p, 53L, "CreatePixmap");
475 DefineEValue(p, 54L, "FreePixmap");
476 DefineEValue(p, 55L, "CreateGC");
477 DefineEValue(p, 56L, "ChangeGC");
478 DefineEValue(p, 57L, "CopyGC");
479 DefineEValue(p, 58L, "SetDashes");
480 DefineEValue(p, 59L, "SetClipRectangles");
481 DefineEValue(p, 60L, "FreeGC");
482 DefineEValue(p, 61L, "ClearArea");
483 DefineEValue(p, 62L, "CopyArea");
484 DefineEValue(p, 63L, "CopyPlane");
485 DefineEValue(p, 64L, "PolyPoint");
486 DefineEValue(p, 65L, "PolyLine");
487 DefineEValue(p, 66L, "PolySegment");
488 DefineEValue(p, 67L, "PolyRectangle");
489 DefineEValue(p, 68L, "PolyArc");
490 DefineEValue(p, 69L, "FillPoly");
491 DefineEValue(p, 70L, "PolyFillRectangle");
492 DefineEValue(p, 71L, "PolyFillArc");
493 DefineEValue(p, 72L, "PutImage");
494 DefineEValue(p, 73L, "GetImage");
495 DefineEValue(p, 74L, "PolyText8");
496 DefineEValue(p, 75L, "PolyText16");
497 DefineEValue(p, 76L, "ImageText8");
498 DefineEValue(p, 77L, "ImageText16");
499 DefineEValue(p, 78L, "CreateColormap");
500 DefineEValue(p, 79L, "FreeColormap");
501 DefineEValue(p, 80L, "CopyColormapAndFree");
502 DefineEValue(p, 81L, "InstallColormap");
503 DefineEValue(p, 82L, "UninstallColormap");
504 DefineEValue(p, 83L, "ListInstalledColormaps");
505 DefineEValue(p, 84L, "AllocColor");
506 DefineEValue(p, 85L, "AllocNamedColor");
507 DefineEValue(p, 86L, "AllocColorCells");
508 DefineEValue(p, 87L, "AllocColorPlanes");
509 DefineEValue(p, 88L, "FreeColors");
510 DefineEValue(p, 89L, "StoreColors");
511 DefineEValue(p, 90L, "StoreNamedColor");
512 DefineEValue(p, 91L, "QueryColors");
513 DefineEValue(p, 92L, "LookupColor");
514 DefineEValue(p, 93L, "CreateCursor");
515 DefineEValue(p, 94L, "CreateGlyphCursor");
516 DefineEValue(p, 95L, "FreeCursor");
517 DefineEValue(p, 96L, "RecolorCursor");
518 DefineEValue(p, 97L, "QueryBestSize");
519 DefineEValue(p, 98L, "QueryExtension");
520 DefineEValue(p, 99L, "ListExtensions");
521 DefineEValue(p, 100L, "ChangeKeyboardMapping");
522 DefineEValue(p, 101L, "GetKeyboardMapping");
523 DefineEValue(p, 102L, "ChangeKeyboardControl");
524 DefineEValue(p, 103L, "GetKeyboardControl");
525 DefineEValue(p, 104L, "Bell");
526 DefineEValue(p, 105L, "ChangePointerControl");
527 DefineEValue(p, 106L, "GetPointerControl");
528 DefineEValue(p, 107L, "SetScreenSaver");
529 DefineEValue(p, 108L, "GetScreenSaver");
530 DefineEValue(p, 109L, "ChangeHosts");
531 DefineEValue(p, 110L, "ListHosts");
532 DefineEValue(p, 111L, "SetAccessControl");
533 DefineEValue(p, 112L, "SetCloseDownMode");
534 DefineEValue(p, 113L, "KillClient");
535 DefineEValue(p, 114L, "RotateProperties");
536 DefineEValue(p, 115L, "ForceScreenSaver");
537 DefineEValue(p, 116L, "SetPointerMapping");
538 DefineEValue(p, 117L, "GetPointerMapping");
539 DefineEValue(p, 118L, "SetModifierMapping");
540 DefineEValue(p, 119L, "GetModifierMapping");
541 DefineEValue(p, 127L, "NoOperation");
542
543 p = DefineType(REPLY, ENUMERATED, "REPLY", (PrintProcType) PrintENUMERATED);
544 DefineEValue(p, 3L, "GetWindowAttributes");
545 DefineEValue(p, 14L, "GetGeometry");
546 DefineEValue(p, 15L, "QueryTree");
547 DefineEValue(p, 16L, "InternAtom");
548 DefineEValue(p, 17L, "GetAtomName");
549 DefineEValue(p, 20L, "GetProperty");
550 DefineEValue(p, 21L, "ListProperties");
551 DefineEValue(p, 23L, "GetSelectionOwner");
552 DefineEValue(p, 26L, "GrabPointer");
553 DefineEValue(p, 31L, "GrabKeyboard");
554 DefineEValue(p, 38L, "QueryPointer");
555 DefineEValue(p, 39L, "GetMotionEvents");
556 DefineEValue(p, 40L, "TranslateCoordinates");
557 DefineEValue(p, 43L, "GetInputFocus");
558 DefineEValue(p, 44L, "QueryKeymap");
559 DefineEValue(p, 47L, "QueryFont");
560 DefineEValue(p, 48L, "QueryTextExtents");
561 DefineEValue(p, 49L, "ListFonts");
562 DefineEValue(p, 50L, "ListFontsWithInfo");
563 DefineEValue(p, 52L, "GetFontPath");
564 DefineEValue(p, 73L, "GetImage");
565 DefineEValue(p, 83L, "ListInstalledColormaps");
566 DefineEValue(p, 84L, "AllocColor");
567 DefineEValue(p, 85L, "AllocNamedColor");
568 DefineEValue(p, 86L, "AllocColorCells");
569 DefineEValue(p, 87L, "AllocColorPlanes");
570 DefineEValue(p, 91L, "QueryColors");
571 DefineEValue(p, 92L, "LookupColor");
572 DefineEValue(p, 97L, "QueryBestSize");
573 DefineEValue(p, 98L, "QueryExtension");
574 DefineEValue(p, 99L, "ListExtensions");
575 DefineEValue(p, 101L, "GetKeyboardMapping");
576 DefineEValue(p, 103L, "GetKeyboardControl");
577 DefineEValue(p, 106L, "GetPointerControl");
578 DefineEValue(p, 108L, "GetScreenSaver");
579 DefineEValue(p, 110L, "ListHosts");
580 DefineEValue(p, 116L, "SetPointerMapping");
581 DefineEValue(p, 117L, "GetPointerMapping");
582 DefineEValue(p, 118L, "SetModifierMapping");
583 DefineEValue(p, 119L, "GetModifierMapping");
584
585 p = DefineType(ERROR, ENUMERATED, "ERROR", (PrintProcType) PrintENUMERATED);
586 DefineEValue(p, 1L, "Request");
587 DefineEValue(p, 2L, "Value");
588 DefineEValue(p, 3L, "Window");
589 DefineEValue(p, 4L, "Pixmap");
590 DefineEValue(p, 5L, "Atom");
591 DefineEValue(p, 6L, "Cursor");
592 DefineEValue(p, 7L, "Font");
593 DefineEValue(p, 8L, "Match");
594 DefineEValue(p, 9L, "Drawable");
595 DefineEValue(p, 10L, "Access");
596 DefineEValue(p, 11L, "Alloc");
597 DefineEValue(p, 12L, "Colormap");
598 DefineEValue(p, 13L, "GContext");
599 DefineEValue(p, 14L, "IDChoice");
600 DefineEValue(p, 15L, "Name");
601 DefineEValue(p, 16L, "Length");
602 DefineEValue(p, 17L, "Implementation");
603
604 p = DefineType(EVENT, BUILTIN, "EVENT", (PrintProcType) PrintEVENT);
605 DefineEValue(p, 2L, "KeyPress");
606 DefineEValue(p, 3L, "KeyRelease");
607 DefineEValue(p, 4L, "ButtonPress");
608 DefineEValue(p, 5L, "ButtonRelease");
609 DefineEValue(p, 6L, "MotionNotify");
610 DefineEValue(p, 7L, "EnterNotify");
611 DefineEValue(p, 8L, "LeaveNotify");
612 DefineEValue(p, 9L, "FocusIn");
613 DefineEValue(p, 10L, "FocusOut");
614 DefineEValue(p, 11L, "KeymapNotify");
615 DefineEValue(p, 12L, "Expose");
616 DefineEValue(p, 13L, "GraphicsExposure");
617 DefineEValue(p, 14L, "NoExposure");
618 DefineEValue(p, 15L, "VisibilityNotify");
619 DefineEValue(p, 16L, "CreateNotify");
620 DefineEValue(p, 17L, "DestroyNotify");
621 DefineEValue(p, 18L, "UnmapNotify");
622 DefineEValue(p, 19L, "MapNotify");
623 DefineEValue(p, 20L, "MapRequest");
624 DefineEValue(p, 21L, "ReparentNotify");
625 DefineEValue(p, 22L, "ConfigureNotify");
626 DefineEValue(p, 23L, "ConfigureRequest");
627 DefineEValue(p, 24L, "GravityNotify");
628 DefineEValue(p, 25L, "ResizeRequest");
629 DefineEValue(p, 26L, "CirculateNotify");
630 DefineEValue(p, 27L, "CirculateRequest");
631 DefineEValue(p, 28L, "PropertyNotify");
632 DefineEValue(p, 29L, "SelectionClear");
633 DefineEValue(p, 30L, "SelectionRequest");
634 DefineEValue(p, 31L, "SelectionNotify");
635 DefineEValue(p, 32L, "ColormapNotify");
636 DefineEValue(p, 33L, "ClientMessage");
637 DefineEValue(p, 34L, "MappingNotify");
638 DefineEValue(p, 35L, "GenericEvent");
639
640 p = DefineType(BITGRAVITY, ENUMERATED, "BITGRAVITY",
641 (PrintProcType) PrintENUMERATED);
642 DefineEValue(p, 0L, "Forget");
643 DefineEValue(p, 1L, "NorthWest");
644 DefineEValue(p, 2L, "North");
645 DefineEValue(p, 3L, "NorthEast");
646 DefineEValue(p, 4L, "West");
647 DefineEValue(p, 5L, "Center");
648 DefineEValue(p, 6L, "East");
649 DefineEValue(p, 7L, "SouthWest");
650 DefineEValue(p, 8L, "South");
651 DefineEValue(p, 9L, "SouthEast");
652 DefineEValue(p, 10L, "Static");
653
654 p = DefineType(WINGRAVITY, ENUMERATED, "WINGRAVITY",
655 (PrintProcType) PrintENUMERATED);
656 DefineEValue(p, 0L, "Unmap");
657 DefineEValue(p, 1L, "NorthWest");
658 DefineEValue(p, 2L, "North");
659 DefineEValue(p, 3L, "NorthEast");
660 DefineEValue(p, 4L, "West");
661 DefineEValue(p, 5L, "Center");
662 DefineEValue(p, 6L, "East");
663 DefineEValue(p, 7L, "SouthWest");
664 DefineEValue(p, 8L, "South");
665 DefineEValue(p, 9L, "SouthEast");
666 DefineEValue(p, 10L, "Static");
667
668 p = DefineType(BOOL, ENUMERATED, "BOOL", (PrintProcType) PrintENUMERATED);
669 DefineEValue(p, 0L, "False");
670 DefineEValue(p, 1L, "True");
671
672 p = DefineType(HOSTFAMILY, ENUMERATED, "HOSTFAMILY",
673 (PrintProcType) PrintENUMERATED);
674 DefineEValue(p, 0L, "Internet");
675 DefineEValue(p, 1L, "DECnet");
676 DefineEValue(p, 2L, "Chaos");
677 DefineEValue(p, 5L, "ServerInterpreted");
678 DefineEValue(p, 6L, "InternetV6");
679 DefineEValue(p, 252L, "LocalHost");
680 DefineEValue(p, 253L, "Kerberos5");
681 DefineEValue(p, 254L, "SecureRPC");
682
683 p = DefineType(PK_MODE, ENUMERATED, "PK_MODE",
684 (PrintProcType) PrintENUMERATED);
685 DefineEValue(p, 0L, "Synchronous");
686 DefineEValue(p, 1L, "Asynchronous");
687
688 p = DefineType(NO_YES, ENUMERATED, "NO_YES",
689 (PrintProcType) PrintENUMERATED);
690 DefineEValue(p, 0L, "No");
691 DefineEValue(p, 1L, "Yes");
692 DefineEValue(p, 2L, "Default");
693
694 p = DefineType(WINDOWCLASS, ENUMERATED, "WINDOWCLASS",
695 (PrintProcType) PrintENUMERATED);
696 DefineEValue(p, 0L, "CopyFromParent");
697 DefineEValue(p, 1L, "InputOutput");
698 DefineEValue(p, 2L, "InputOnly");
699
700 p = DefineType(BACKSTORE, ENUMERATED, "BACKSTORE",
701 (PrintProcType) PrintENUMERATED);
702 DefineEValue(p, 0L, "NotUseful");
703 DefineEValue(p, 1L, "WhenMapped");
704 DefineEValue(p, 2L, "Always");
705
706 p = DefineType(MAPSTATE, ENUMERATED, "MAPSTATE",
707 (PrintProcType) PrintENUMERATED);
708 DefineEValue(p, 0L, "Unmapped");
709 DefineEValue(p, 1L, "Unviewable");
710 DefineEValue(p, 2L, "Viewable");
711
712 p = DefineType(STACKMODE, ENUMERATED, "STACKMODE",
713 (PrintProcType) PrintENUMERATED);
714 DefineEValue(p, 0L, "Above");
715 DefineEValue(p, 1L, "Below");
716 DefineEValue(p, 2L, "TopIf");
717 DefineEValue(p, 3L, "BottomIf");
718 DefineEValue(p, 4L, "Opposite");
719
720 p = DefineType(CIRMODE, ENUMERATED, "CIRMODE",
721 (PrintProcType) PrintENUMERATED);
722 DefineEValue(p, 0L, "RaiseLowest");
723 DefineEValue(p, 1L, "LowerHighest");
724
725 p = DefineType(CHANGEMODE, ENUMERATED, "CHANGEMODE",
726 (PrintProcType) PrintENUMERATED);
727 DefineEValue(p, 0L, "Replace");
728 DefineEValue(p, 1L, "Prepend");
729 DefineEValue(p, 2L, "Append");
730
731 p = DefineType(GRABSTAT, ENUMERATED, "GRABSTAT",
732 (PrintProcType) PrintENUMERATED);
733 DefineEValue(p, 0L, "Success");
734 DefineEValue(p, 1L, "AlreadyGrabbed");
735 DefineEValue(p, 2L, "InvalidTime");
736 DefineEValue(p, 3L, "NotViewable");
737 DefineEValue(p, 4L, "Frozen");
738
739 p = DefineType(EVENTMODE, ENUMERATED, "EVENTMODE",
740 (PrintProcType) PrintENUMERATED);
741 DefineEValue(p, 0L, "AsyncPointer");
742 DefineEValue(p, 1L, "SyncPointer");
743 DefineEValue(p, 2L, "ReplayPointer");
744 DefineEValue(p, 3L, "AsyncKeyboard");
745 DefineEValue(p, 4L, "SyncKeyboard");
746 DefineEValue(p, 5L, "ReplayKeyboard");
747 DefineEValue(p, 6L, "AsyncBoth");
748 DefineEValue(p, 7L, "SyncBoth");
749
750 p = DefineType(FOCUSAGENT, ENUMERATED, "FOCUSAGENT",
751 (PrintProcType) PrintENUMERATED);
752 DefineEValue(p, 0L, "None");
753 DefineEValue(p, 1L, "PointerRoot");
754 DefineEValue(p, 2L, "Parent");
755
756 p = DefineType(DIRECT, ENUMERATED, "DIRECT",
757 (PrintProcType) PrintENUMERATED);
758 DefineEValue(p, 0L, "LeftToRight");
759 DefineEValue(p, 1L, "RightToLeft");
760
761 p = DefineType(GCFUNC, ENUMERATED, "GCFUNC",
762 (PrintProcType) PrintENUMERATED);
763 DefineEValue(p, 0L, "Clear");
764 DefineEValue(p, 1L, "And");
765 DefineEValue(p, 2L, "AndReverse");
766 DefineEValue(p, 3L, "Copy");
767 DefineEValue(p, 4L, "AndInverted");
768 DefineEValue(p, 5L, "Noop");
769 DefineEValue(p, 6L, "Xor");
770 DefineEValue(p, 7L, "Or");
771 DefineEValue(p, 8L, "Nor");
772 DefineEValue(p, 9L, "Equiv");
773 DefineEValue(p, 10L, "Invert");
774 DefineEValue(p, 11L, "OrReverse");
775 DefineEValue(p, 12L, "CopyInverted");
776 DefineEValue(p, 13L, "OrInverted");
777 DefineEValue(p, 14L, "Nand");
778 DefineEValue(p, 15L, "Set");
779
780 p = DefineType(LINESTYLE, ENUMERATED, "LINESTYLE",
781 (PrintProcType) PrintENUMERATED);
782 DefineEValue(p, 0L, "Solid");
783 DefineEValue(p, 1L, "OnOffDash");
784 DefineEValue(p, 2L, "DoubleDash");
785
786 p = DefineType(CAPSTYLE, ENUMERATED, "CAPSTYLE",
787 (PrintProcType) PrintENUMERATED);
788 DefineEValue(p, 0L, "NotLast");
789 DefineEValue(p, 1L, "Butt");
790 DefineEValue(p, 2L, "Round");
791 DefineEValue(p, 3L, "Projecting");
792
793 p = DefineType(JOINSTYLE, ENUMERATED, "JOINSTYLE",
794 (PrintProcType) PrintENUMERATED);
795 DefineEValue(p, 0L, "Miter");
796 DefineEValue(p, 1L, "Round");
797 DefineEValue(p, 2L, "Bevel");
798
799 p = DefineType(FILLSTYLE, ENUMERATED, "FILLSTYLE",
800 (PrintProcType) PrintENUMERATED);
801 DefineEValue(p, 0L, "Solid");
802 DefineEValue(p, 1L, "Tiled");
803 DefineEValue(p, 2L, "Stippled");
804 DefineEValue(p, 3L, "OpaqueStippled");
805
806 p = DefineType(FILLRULE, ENUMERATED, "FILLRULE",
807 (PrintProcType) PrintENUMERATED);
808 DefineEValue(p, 0L, "EvenOdd");
809 DefineEValue(p, 1L, "Winding");
810
811 p = DefineType(SUBWINMODE, ENUMERATED, "SUBWINMODE",
812 (PrintProcType) PrintENUMERATED);
813 DefineEValue(p, 0L, "ClipByChildren");
814 DefineEValue(p, 1L, "IncludeInferiors");
815
816 p = DefineType(ARCMODE, ENUMERATED, "ARCMODE",
817 (PrintProcType) PrintENUMERATED);
818 DefineEValue(p, 0L, "Chord");
819 DefineEValue(p, 1L, "PieSlice");
820
821 p = DefineType(RECTORDER, ENUMERATED, "RECTORDER",
822 (PrintProcType) PrintENUMERATED);
823 DefineEValue(p, 0L, "UnSorted");
824 DefineEValue(p, 1L, "YSorted");
825 DefineEValue(p, 2L, "YXSorted");
826 DefineEValue(p, 3L, "YXBanded");
827
828 p = DefineType(COORMODE, ENUMERATED, "COORMODE",
829 (PrintProcType) PrintENUMERATED);
830 DefineEValue(p, 0L, "Origin");
831 DefineEValue(p, 1L, "Previous");
832
833 p = DefineType(POLYSHAPE, ENUMERATED, "POLYSHAPE",
834 (PrintProcType) PrintENUMERATED);
835 DefineEValue(p, 0L, "Complex");
836 DefineEValue(p, 1L, "Nonconvex");
837 DefineEValue(p, 2L, "Convex");
838
839 p = DefineType(IMAGEMODE, ENUMERATED, "IMAGEMODE",
840 (PrintProcType) PrintENUMERATED);
841 DefineEValue(p, 0L, "Bitmap");
842 DefineEValue(p, 1L, "XYPixmap");
843 DefineEValue(p, 2L, "ZPixmap");
844
845 p = DefineType(ALLORNONE, ENUMERATED, "ALLORNONE",
846 (PrintProcType) PrintENUMERATED);
847 DefineEValue(p, 0L, "None");
848 DefineEValue(p, 1L, "All");
849
850 p = DefineType(OBJECTCLASS, ENUMERATED, "OBJECTCLASS",
851 (PrintProcType) PrintENUMERATED);
852 DefineEValue(p, 0L, "Cursor");
853 DefineEValue(p, 1L, "Tile");
854 DefineEValue(p, 2L, "Stipple");
855
856 p = DefineType(OFF_ON, ENUMERATED, "OFF_ON",
857 (PrintProcType) PrintENUMERATED);
858 DefineEValue(p, 0L, "Off");
859 DefineEValue(p, 1L, "On");
860 DefineEValue(p, 2L, "Default");
861
862 p = DefineType(INS_DEL, ENUMERATED, "INS_DEL",
863 (PrintProcType) PrintENUMERATED);
864 DefineEValue(p, 0L, "Insert");
865 DefineEValue(p, 1L, "Delete");
866
867 p = DefineType(DIS_EN, ENUMERATED, "DIS_EN",
868 (PrintProcType) PrintENUMERATED);
869 DefineEValue(p, 0L, "Disabled");
870 DefineEValue(p, 1L, "Enabled");
871
872 p = DefineType(CLOSEMODE, ENUMERATED, "CLOSEMODE",
873 (PrintProcType) PrintENUMERATED);
874 DefineEValue(p, 0L, "Destroy");
875 DefineEValue(p, 1L, "RetainPermanent");
876 DefineEValue(p, 2L, "RetainTemporary");
877
878 p = DefineType(SAVEMODE, ENUMERATED, "SAVEMODE",
879 (PrintProcType) PrintENUMERATED);
880 DefineEValue(p, 0L, "Reset");
881 DefineEValue(p, 1L, "Activate");
882
883 p = DefineType(RSTATUS, ENUMERATED, "RSTATUS",
884 (PrintProcType) PrintENUMERATED);
885 DefineEValue(p, 0L, "Success");
886 DefineEValue(p, 1L, "Busy");
887 DefineEValue(p, 2L, "Failed");
888
889 p = DefineType(MOTIONDETAIL, ENUMERATED, "MOTIONDETAIL",
890 (PrintProcType) PrintENUMERATED);
891 DefineEValue(p, 0L, "Normal");
892 DefineEValue(p, 1L, "Hint");
893
894 p = DefineType(ENTERDETAIL, ENUMERATED, "ENTERDETAIL",
895 (PrintProcType) PrintENUMERATED);
896 DefineEValue(p, 0L, "Ancestor");
897 DefineEValue(p, 1L, "Virtual");
898 DefineEValue(p, 2L, "Inferior");
899 DefineEValue(p, 3L, "Nonlinear");
900 DefineEValue(p, 4L, "NonlinearVirtual");
901 DefineEValue(p, 5L, "Pointer");
902 DefineEValue(p, 6L, "PointerRoot");
903 DefineEValue(p, 7L, "None");
904
905 p = DefineType(BUTTONMODE, ENUMERATED, "BUTTONMODE",
906 (PrintProcType) PrintENUMERATED);
907 DefineEValue(p, 0L, "Normal");
908 DefineEValue(p, 1L, "Grab");
909 DefineEValue(p, 2L, "Ungrab");
910 DefineEValue(p, 3L, "WhileGrabbed");
911
912 p = DefineType(VISIBLE, ENUMERATED, "VISIBLE",
913 (PrintProcType) PrintENUMERATED);
914 DefineEValue(p, 0L, "Unobscured");
915 DefineEValue(p, 1L, "PartiallyObscured");
916 DefineEValue(p, 2L, "FullyObscured");
917
918 p = DefineType(CIRSTAT, ENUMERATED, "CIRSTAT",
919 (PrintProcType) PrintENUMERATED);
920 DefineEValue(p, 0L, "Top");
921 DefineEValue(p, 1L, "Bottom");
922
923 p = DefineType(PROPCHANGE, ENUMERATED, "PROPCHANGE",
924 (PrintProcType) PrintENUMERATED);
925 DefineEValue(p, 0L, "NewValue");
926 DefineEValue(p, 1L, "Deleted");
927
928 p = DefineType(CMAPCHANGE, ENUMERATED, "CMAPCHANGE",
929 (PrintProcType) PrintENUMERATED);
930 DefineEValue(p, 0L, "Uninstalled");
931 DefineEValue(p, 1L, "Installed");
932
933 p = DefineType(MAPOBJECT, ENUMERATED, "MAPOBJECT",
934 (PrintProcType) PrintENUMERATED);
935 DefineEValue(p, 0L, "Modifier");
936 DefineEValue(p, 1L, "Keyboard");
937 DefineEValue(p, 2L, "Pointer");
938
939 p = DefineType(BYTEMODE, ENUMERATED, "BYTEMODE",
940 (PrintProcType) PrintENUMERATED);
941 DefineEValue(p, 0x42L, "MSB first");
942 DefineEValue(p, 0x6CL, "LSB first");
943
944 p = DefineType(BYTEORDER, ENUMERATED, "BYTEORDER",
945 (PrintProcType) PrintENUMERATED);
946 DefineEValue(p, 0L, "LSB first");
947 DefineEValue(p, 1L, "MSB first");
948
949 p = DefineType(COLORCLASS, ENUMERATED, "COLORCLASS",
950 (PrintProcType) PrintENUMERATED);
951 DefineEValue(p, 0L, "StaticGray");
952 DefineEValue(p, 1L, "GrayScale");
953 DefineEValue(p, 2L, "StaticColor");
954 DefineEValue(p, 3L, "PseudoColor");
955 DefineEValue(p, 4L, "TrueColor");
956 DefineEValue(p, 5L, "DirectColor");
957
958 p = DefineType(EXTENSION, ENUMERATED, "EXTENSION",
959 (PrintProcType) PrintENUMERATED);
960 }
961
962 /* ************************************************************ */
963 /* */
964 /* */
965 /* ************************************************************ */
966
967 static void
InitSetTypes(void)968 InitSetTypes(void)
969 {
970 TYPE p;
971
972 p = DefineType(SETofEVENT, SET, "SETofEVENT", (PrintProcType) PrintSET);
973 DefineEValue(p, 0x00000001L, "KeyPress");
974 DefineEValue(p, 0x00000002L, "KeyRelease");
975 DefineEValue(p, 0x00000004L, "ButtonPress");
976 DefineEValue(p, 0x00000008L, "ButtonRelease");
977 DefineEValue(p, 0x00000010L, "EnterWindow");
978 DefineEValue(p, 0x00000020L, "LeaveWindow");
979 DefineEValue(p, 0x00000040L, "PointerMotion");
980 DefineEValue(p, 0x00000080L, "PointerMotionHint");
981 DefineEValue(p, 0x00000100L, "Button1Motion");
982 DefineEValue(p, 0x00000200L, "Button2Motion");
983 DefineEValue(p, 0x00000400L, "Button3Motion");
984 DefineEValue(p, 0x00000800L, "Button4Motion");
985 DefineEValue(p, 0x00001000L, "Button5Motion");
986 DefineEValue(p, 0x00002000L, "ButtonMotion");
987 DefineEValue(p, 0x00004000L, "KeymapState");
988 DefineEValue(p, 0x00008000L, "Exposure");
989 DefineEValue(p, 0x00010000L, "VisibilityChange");
990 DefineEValue(p, 0x00020000L, "StructureNotify");
991 DefineEValue(p, 0x00040000L, "ResizeRedirect");
992 DefineEValue(p, 0x00080000L, "SubstructureNotify");
993 DefineEValue(p, 0x00100000L, "SubstructureRedirect");
994 DefineEValue(p, 0x00200000L, "FocusChange");
995 DefineEValue(p, 0x00400000L, "PropertyChange");
996 DefineEValue(p, 0x00800000L, "ColormapChange");
997 DefineEValue(p, 0x01000000L, "OwnerGrabButton");
998
999 p = DefineType(SETofPOINTEREVENT, SET, "SETofPOINTEREVENT",
1000 (PrintProcType) PrintSET);
1001 DefineEValue(p, 0x00000004L, "ButtonPress");
1002 DefineEValue(p, 0x00000008L, "ButtonRelease");
1003 DefineEValue(p, 0x00000010L, "EnterWindow");
1004 DefineEValue(p, 0x00000020L, "LeaveWindow");
1005 DefineEValue(p, 0x00000040L, "PointerMotion");
1006 DefineEValue(p, 0x00000080L, "PointerMotionHint");
1007 DefineEValue(p, 0x00000100L, "Button1Motion");
1008 DefineEValue(p, 0x00000200L, "Button2Motion");
1009 DefineEValue(p, 0x00000400L, "Button3Motion");
1010 DefineEValue(p, 0x00000800L, "Button4Motion");
1011 DefineEValue(p, 0x00001000L, "Button5Motion");
1012 DefineEValue(p, 0x00002000L, "ButtonMotion");
1013 DefineEValue(p, 0x00004000L, "KeymapState");
1014
1015 p = DefineType(SETofDEVICEEVENT, SET, "SETofDEVICEEVENT",
1016 (PrintProcType) PrintSET);
1017 DefineEValue(p, 0x00000001L, "KeyPress");
1018 DefineEValue(p, 0x00000002L, "KeyRelease");
1019 DefineEValue(p, 0x00000004L, "ButtonPress");
1020 DefineEValue(p, 0x00000008L, "ButtonRelease");
1021 DefineEValue(p, 0x00000040L, "PointerMotion");
1022 DefineEValue(p, 0x00000100L, "Button1Motion");
1023 DefineEValue(p, 0x00000200L, "Button2Motion");
1024 DefineEValue(p, 0x00000400L, "Button3Motion");
1025 DefineEValue(p, 0x00000800L, "Button4Motion");
1026 DefineEValue(p, 0x00001000L, "Button5Motion");
1027 DefineEValue(p, 0x00002000L, "ButtonMotion");
1028
1029 p = DefineType(SETofKEYBUTMASK, SET, "SETofKEYBUTMASK",
1030 (PrintProcType) PrintSET);
1031 DefineEValue(p, 0x0001L, "Shift");
1032 DefineEValue(p, 0x0002L, "Lock");
1033 DefineEValue(p, 0x0004L, "Control");
1034 DefineEValue(p, 0x0008L, "Mod1");
1035 DefineEValue(p, 0x0010L, "Mod2");
1036 DefineEValue(p, 0x0020L, "Mod3");
1037 DefineEValue(p, 0x0040L, "Mod4");
1038 DefineEValue(p, 0x0080L, "Mod5");
1039 DefineEValue(p, 0x0100L, "Button1");
1040 DefineEValue(p, 0x0200L, "Button2");
1041 DefineEValue(p, 0x0400L, "Button3");
1042 DefineEValue(p, 0x0800L, "Button4");
1043 DefineEValue(p, 0x1000L, "Button5");
1044
1045 p = DefineType(SETofKEYMASK, SET, "SETofKEYMASK", (PrintProcType) PrintSET);
1046 DefineEValue(p, 0x0001L, "Shift");
1047 DefineEValue(p, 0x0002L, "Lock");
1048 DefineEValue(p, 0x0004L, "Control");
1049 DefineEValue(p, 0x0008L, "Mod1");
1050 DefineEValue(p, 0x0010L, "Mod2");
1051 DefineEValue(p, 0x0020L, "Mod3");
1052 DefineEValue(p, 0x0040L, "Mod4");
1053 DefineEValue(p, 0x0080L, "Mod5");
1054 DefineEValue(p, 0x8000L, "AnyModifier");
1055
1056 p = DefineType(COLORMASK, SET, "COLORMASK", (PrintProcType) PrintSET);
1057 DefineEValue(p, 0x01L, "do-red");
1058 DefineEValue(p, 0x02L, "do-green");
1059 DefineEValue(p, 0x04L, "do-blue");
1060
1061 p = DefineType(SCREENFOCUS, SET, "SCREENFOCUS", (PrintProcType) PrintSET);
1062 DefineEValue(p, 0x01L, "focus");
1063 DefineEValue(p, 0x02L, "same-screen");
1064 }
1065
1066
1067 /* ************************************************************ */
1068 /* */
1069 /* */
1070 /* ************************************************************ */
1071
1072 /* Print Routines for builtin record types */
1073
1074 static int
PrintCHAR2B(const unsigned char * buf)1075 PrintCHAR2B(const unsigned char *buf)
1076 {
1077 PrintField(buf, 0, 1, CARD8, "byte1");
1078 PrintField(buf, 1, 1, CARD8, "byte2");
1079 return (2);
1080 }
1081
1082 static int
PrintPOINT(const unsigned char * buf)1083 PrintPOINT(const unsigned char *buf)
1084 {
1085 PrintField(buf, 0, 2, INT16, "x");
1086 PrintField(buf, 2, 2, INT16, "y");
1087 return (4);
1088 }
1089
1090 static int
PrintRECTANGLE(const unsigned char * buf)1091 PrintRECTANGLE(const unsigned char *buf)
1092 {
1093 PrintField(buf, 0, 2, INT16, "x");
1094 PrintField(buf, 2, 2, INT16, "y");
1095 PrintField(buf, 4, 2, CARD16, "width");
1096 PrintField(buf, 6, 2, CARD16, "height");
1097 return (8);
1098 }
1099
1100 static int
PrintARC(const unsigned char * buf)1101 PrintARC(const unsigned char *buf)
1102 {
1103 PrintField(buf, 0, 2, INT16, "x");
1104 PrintField(buf, 2, 2, INT16, "y");
1105 PrintField(buf, 4, 2, CARD16, "width");
1106 PrintField(buf, 6, 2, CARD16, "height");
1107 PrintField(buf, 8, 2, INT16, "angle1");
1108 PrintField(buf, 10, 2, INT16, "angle2");
1109 return (12);
1110 }
1111
1112 static int
PrintHOST(const unsigned char * buf)1113 PrintHOST(const unsigned char *buf)
1114 {
1115 short n;
1116
1117 PrintField(buf, 0, 1, HOSTFAMILY, "family");
1118 PrintField(buf, 2, 2, DVALUE2(n), "length of address");
1119 n = IShort(&buf[2]);
1120 switch (buf[0]) {
1121 case 0:
1122 {
1123 struct in_addr ia;
1124 char *addr;
1125
1126 memcpy(&ia, &buf[4], sizeof(ia)); /* Need to get alignment right */
1127 addr = inet_ntoa(ia);
1128 PrintString8((unsigned char *) addr, strlen(addr), "address");
1129 break;
1130 }
1131 #ifdef IPv6
1132 case 6:
1133 {
1134 struct in6_addr i6a;
1135 char addr[INET6_ADDRSTRLEN];
1136
1137 memcpy(&i6a, &buf[4], sizeof(i6a)); /* Need to get alignment right */
1138 inet_ntop(AF_INET6, &i6a, addr, sizeof(addr));
1139 PrintString8((unsigned char *) addr, strlen(addr), "address");
1140 break;
1141 }
1142 #endif
1143
1144 case 5: /* ServerInterpreted */
1145 {
1146 int i;
1147
1148 for (i = 0; buf[i + 4] != 0; i++) {
1149 /* empty loop */
1150 }
1151 PrintString8(&buf[4], i, "type");
1152 PrintString8(&buf[i + 5], n - i - 1, "value");
1153 break;
1154 }
1155
1156 case 254:
1157 PrintString8(&buf[4], n, "address");
1158 break;
1159
1160 default:
1161 PrintList(&buf[4], (long) n, BYTE, "address");
1162 }
1163 return (pad((long) (4 + n)));
1164 }
1165
1166 static int
PrintTIMECOORD(const unsigned char * buf)1167 PrintTIMECOORD(const unsigned char *buf)
1168 {
1169 PrintField(buf, 0, 4, TIMESTAMP, "time");
1170 PrintField(buf, 4, 2, CARD16, "x");
1171 PrintField(buf, 6, 2, CARD16, "y");
1172 return (8);
1173 }
1174
1175 static int
PrintFONTPROP(const unsigned char * buf)1176 PrintFONTPROP(const unsigned char *buf)
1177 {
1178 PrintField(buf, 0, 4, ATOM, "name");
1179 PrintField(buf, 4, 4, INT32, "value");
1180 return (8);
1181 }
1182
1183 static int
PrintCHARINFO(const unsigned char * buf)1184 PrintCHARINFO(const unsigned char *buf)
1185 {
1186 PrintField(buf, 0, 2, INT16, "left-side-bearing");
1187 PrintField(buf, 2, 2, INT16, "right-side-bearing");
1188 PrintField(buf, 4, 2, INT16, "character-width");
1189 PrintField(buf, 6, 2, INT16, "ascent");
1190 PrintField(buf, 8, 2, INT16, "descent");
1191 PrintField(buf, 10, 2, CARD16, "attributes");
1192 return (12);
1193 }
1194
1195 static int
PrintSEGMENT(const unsigned char * buf)1196 PrintSEGMENT(const unsigned char *buf)
1197 {
1198 PrintField(buf, 0, 2, INT16, "x1");
1199 PrintField(buf, 2, 2, INT16, "y1");
1200 PrintField(buf, 4, 2, INT16, "x2");
1201 PrintField(buf, 6, 2, INT16, "y2");
1202 return (8);
1203 }
1204
1205 static int
PrintCOLORITEM(const unsigned char * buf)1206 PrintCOLORITEM(const unsigned char *buf)
1207 {
1208 PrintField(buf, 0, 4, CARD32, "pixel");
1209 PrintField(buf, 4, 2, CARD16, "red");
1210 PrintField(buf, 6, 2, CARD16, "green");
1211 PrintField(buf, 8, 2, CARD16, "blue");
1212 PrintField(buf, 10, 1, COLORMASK, "component selector");
1213 return (12);
1214 }
1215
1216 static int
PrintRGB(const unsigned char * buf)1217 PrintRGB(const unsigned char *buf)
1218 {
1219 PrintField(buf, 0, 2, CARD16, "red");
1220 PrintField(buf, 2, 2, CARD16, "green");
1221 PrintField(buf, 4, 2, CARD16, "blue");
1222 return (8);
1223 }
1224
1225 static int
PrintFORMAT(const unsigned char * buf)1226 PrintFORMAT(const unsigned char *buf)
1227 {
1228 PrintField(buf, 0, 1, CARD8, "depth");
1229 PrintField(buf, 1, 1, CARD8, "bits-per-pixel");
1230 PrintField(buf, 2, 1, CARD8, "scanline-pad");
1231 return (8);
1232 }
1233
1234 static int
PrintSCREEN(const unsigned char * buf)1235 PrintSCREEN(const unsigned char *buf)
1236 {
1237 short n; /* number of elements in List of DEPTH */
1238 long m; /* length (in bytes) of List of DEPTH */
1239
1240 PrintField(buf, 0, 4, WINDOW, "root");
1241 PrintField(buf, 4, 4, COLORMAP, "default-colormap");
1242 PrintField(buf, 8, 4, CARD32, "white-pixel");
1243 PrintField(buf, 12, 4, CARD32, "black-pixel");
1244 PrintField(buf, 16, 4, SETofEVENT, "current-input-masks");
1245 PrintField(buf, 20, 2, CARD16, "width-in-pixels");
1246 PrintField(buf, 22, 2, CARD16, "height-in-pixels");
1247 PrintField(buf, 24, 2, CARD16, "width-in-millimeters");
1248 PrintField(buf, 26, 2, CARD16, "height-in-millimeters");
1249 PrintField(buf, 28, 2, CARD16, "min-installed-maps");
1250 PrintField(buf, 30, 2, CARD16, "max-installed-maps");
1251 PrintField(buf, 32, 4, VISUALID, "root-visual");
1252 PrintField(buf, 36, 1, BACKSTORE, "backing-stores");
1253 PrintField(buf, 37, 1, BOOL, "save-unders");
1254 PrintField(buf, 38, 1, CARD8, "root-depth");
1255 PrintField(buf, 39, 1, CARD8, "number of allowed-depths");
1256 n = IByte(&buf[39]);
1257 m = PrintList(&buf[40], (long) n, DEPTH, "allowed-depths");
1258 return (40 + m);
1259 }
1260
1261 static int
PrintDEPTH(const unsigned char * buf)1262 PrintDEPTH(const unsigned char *buf)
1263 {
1264 short n; /* number of elements in List of VISUALTYPE */
1265 short m; /* length (in bytes) of List of VISUALTYPE */
1266
1267 PrintField(buf, 0, 1, CARD8, "depth");
1268 PrintField(buf, 2, 2, DVALUE2(n), "number of visuals");
1269 n = IShort(&buf[2]);
1270 m = PrintList(&buf[8], (long) n, VISUALTYPE, "visuals");
1271 return (8 + m);
1272 }
1273
1274 static int
PrintVISUALTYPE(const unsigned char * buf)1275 PrintVISUALTYPE(const unsigned char *buf)
1276 {
1277 PrintField(buf, 0, 4, VISUALID, "visual-id");
1278 PrintField(buf, 4, 1, COLORCLASS, "class");
1279 PrintField(buf, 5, 1, CARD8, "bits-per-rgb-value");
1280 PrintField(buf, 6, 2, CARD16, "colormap-entries");
1281 PrintField(buf, 8, 4, CARD32, "red-mask");
1282 PrintField(buf, 12, 4, CARD32, "green-mask");
1283 PrintField(buf, 16, 4, CARD32, "blue-mask");
1284 return (24);
1285 }
1286
1287 /* ************************************************************ */
1288
1289 static void
InitRecordTypes(void)1290 InitRecordTypes(void)
1291 {
1292 (void) DefineType(CHAR2B, RECORD, "CHAR2B", PrintCHAR2B);
1293 (void) DefineType(POINT, RECORD, "POINT", PrintPOINT);
1294 (void) DefineType(RECTANGLE, RECORD, "RECTANGLE", PrintRECTANGLE);
1295 (void) DefineType(ARC, RECORD, "ARC", PrintARC);
1296 (void) DefineType(HOST, RECORD, "HOST", PrintHOST);
1297 (void) DefineType(TIMECOORD, RECORD, "TIMECOORD", PrintTIMECOORD);
1298 (void) DefineType(FONTPROP, RECORD, "FONTPROP", PrintFONTPROP);
1299 (void) DefineType(CHARINFO, RECORD, "CHARINFO", PrintCHARINFO);
1300 (void) DefineType(SEGMENT, RECORD, "SEGMENT", PrintSEGMENT);
1301 (void) DefineType(COLORITEM, RECORD, "COLORITEM", PrintCOLORITEM);
1302 (void) DefineType(RGB, RECORD, "RGB", PrintRGB);
1303 (void) DefineType(FORMAT, RECORD, "FORMAT", PrintFORMAT);
1304 (void) DefineType(SCREEN, RECORD, "SCREEN", PrintSCREEN);
1305 (void) DefineType(DEPTH, RECORD, "DEPTH", PrintDEPTH);
1306 (void) DefineType(VISUALTYPE, RECORD, "VISUALTYPE", PrintVISUALTYPE);
1307 }
1308
1309
1310
1311 /* ************************************************************ */
1312 /* */
1313 /* */
1314 /* ************************************************************ */
1315
1316 static void
InitValuesTypes(void)1317 InitValuesTypes(void)
1318 {
1319 TYPE p;
1320
1321 p = DefineType(WINDOW_BITMASK, SET, "WINDOW_BITMASK",
1322 (PrintProcType) PrintSET);
1323
1324 DefineValues(p, 0x00000001L, 4, PIXMAPNPR, "background-pixmap");
1325 DefineValues(p, 0x00000002L, 4, CARD32, "background-pixel");
1326 DefineValues(p, 0x00000004L, 4, PIXMAPC, "border-pixmap");
1327 DefineValues(p, 0x00000008L, 4, CARD32, "border-pixel");
1328 DefineValues(p, 0x00000010L, 1, BITGRAVITY, "bit-gravity");
1329 DefineValues(p, 0x00000020L, 1, WINGRAVITY, "win-gravity");
1330 DefineValues(p, 0x00000040L, 1, BACKSTORE, "backing-store");
1331 DefineValues(p, 0x00000080L, 4, CARD32, "backing-planes");
1332 DefineValues(p, 0x00000100L, 4, CARD32, "backing-pixel");
1333 DefineValues(p, 0x00000200L, 1, BOOL, "override-redirect");
1334 DefineValues(p, 0x00000400L, 1, BOOL, "save-under");
1335 DefineValues(p, 0x00000800L, 4, SETofEVENT, "event-mask");
1336 DefineValues(p, 0x00001000L, 4, SETofDEVICEEVENT, "do-not-propagate-mask");
1337 DefineValues(p, 0x00002000L, 4, COLORMAPC, "colormap");
1338 DefineValues(p, 0x00004000L, 4, CURSOR, "cursor");
1339
1340 p = DefineType(CONFIGURE_BITMASK, SET, "CONFIGURE_BITMASK",
1341 (PrintProcType) PrintSET);
1342 DefineValues(p, 0x0001L, 2, INT16, "x");
1343 DefineValues(p, 0x0002L, 2, INT16, "y");
1344 DefineValues(p, 0x0004L, 2, CARD16, "width");
1345 DefineValues(p, 0x0008L, 2, CARD16, "height");
1346 DefineValues(p, 0x0010L, 2, CARD16, "border-width");
1347 DefineValues(p, 0x0020L, 4, WINDOW, "sibling");
1348 DefineValues(p, 0x0040L, 1, STACKMODE, "stack-mode");
1349
1350 p = DefineType(GC_BITMASK, SET, "GC_BITMASK", (PrintProcType) PrintSET);
1351 DefineValues(p, 0x00000001L, 1, GCFUNC, "function");
1352 DefineValues(p, 0x00000002L, 4, CARD32, "plane-mask");
1353 DefineValues(p, 0x00000004L, 4, CARD32, "foreground");
1354 DefineValues(p, 0x00000008L, 4, CARD32, "background");
1355 DefineValues(p, 0x00000010L, 2, CARD16, "line-width");
1356 DefineValues(p, 0x00000020L, 1, LINESTYLE, "line-style");
1357 DefineValues(p, 0x00000040L, 1, CAPSTYLE, "cap-style");
1358 DefineValues(p, 0x00000080L, 1, JOINSTYLE, "join-style");
1359 DefineValues(p, 0x00000100L, 1, FILLSTYLE, "fill-style");
1360 DefineValues(p, 0x00000200L, 1, FILLRULE, "fill-rule");
1361 DefineValues(p, 0x00000400L, 4, PIXMAP, "tile");
1362 DefineValues(p, 0x00000800L, 4, PIXMAP, "stipple");
1363 DefineValues(p, 0x00001000L, 2, INT16, "tile-stipple-x-origin");
1364 DefineValues(p, 0x00002000L, 2, INT16, "tile-stipple-y-origin");
1365 DefineValues(p, 0x00004000L, 4, FONT, "font");
1366 DefineValues(p, 0x00008000L, 1, SUBWINMODE, "subwindow-mode");
1367 DefineValues(p, 0x00010000L, 1, BOOL, "graphics-exposures");
1368 DefineValues(p, 0x00020000L, 2, INT16, "clip-x-origin");
1369 DefineValues(p, 0x00040000L, 2, INT16, "clip-y-origin");
1370 DefineValues(p, 0x00080000L, 4, PIXMAP, "clip-mask");
1371 DefineValues(p, 0x00100000L, 2, CARD16, "dash-offset");
1372 DefineValues(p, 0x00200000L, 1, CARD8, "dashes");
1373 DefineValues(p, 0x00400000L, 1, ARCMODE, "arc-mode");
1374
1375 p = DefineType(KEYBOARD_BITMASK, SET, "KEYBOARD_BITMASK",
1376 (PrintProcType) PrintSET);
1377 DefineValues(p, 0x0001L, 1, INT8, "key-click-percent");
1378 DefineValues(p, 0x0002L, 1, INT8, "bell-percent");
1379 DefineValues(p, 0x0004L, 2, INT16, "bell-pitch");
1380 DefineValues(p, 0x0008L, 2, INT16, "bell-duration");
1381 DefineValues(p, 0x0010L, 1, CARD8, "led");
1382 DefineValues(p, 0x0020L, 1, OFF_ON, "led-mode");
1383 DefineValues(p, 0x0040L, 1, KEYCODE, "key");
1384 DefineValues(p, 0x0080L, 1, OFF_ON, "auto-repeat-mode");
1385 }
1386