File: | xkbtext.c |
Location: | line 670, column 20 |
Description: | Null pointer argument in call to string length function |
1 | /************************************************************ | |||
2 | Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. | |||
3 | ||||
4 | Permission to use, copy, modify, and distribute this | |||
5 | software and its documentation for any purpose and without | |||
6 | fee is hereby granted, provided that the above copyright | |||
7 | notice appear in all copies and that both that copyright | |||
8 | notice and this permission notice appear in supporting | |||
9 | documentation, and that the name of Silicon Graphics not be | |||
10 | used in advertising or publicity pertaining to distribution | |||
11 | of the software without specific prior written permission. | |||
12 | Silicon Graphics makes no representation about the suitability | |||
13 | of this software for any purpose. It is provided "as is" | |||
14 | without any express or implied warranty. | |||
15 | ||||
16 | SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS | |||
17 | SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |||
18 | AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON | |||
19 | GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL | |||
20 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |||
21 | DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE | |||
22 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | |||
23 | THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
24 | ||||
25 | ********************************************************/ | |||
26 | ||||
27 | #ifdef HAVE_DIX_CONFIG_H | |||
28 | #include <dix-config.h> | |||
29 | #elif defined(HAVE_CONFIG_H1) | |||
30 | #include <config.h> | |||
31 | #endif | |||
32 | ||||
33 | #include <stdio.h> | |||
34 | #include <ctype.h> | |||
35 | #include <stdlib.h> | |||
36 | ||||
37 | #include <X11/Xos.h> | |||
38 | ||||
39 | ||||
40 | #include <X11/Xlib.h> | |||
41 | #include <X11/XKBlib.h> | |||
42 | #include <X11/extensions/XKBgeom.h> | |||
43 | ||||
44 | #include "XKMformat.h" | |||
45 | #include "XKBfileInt.h" | |||
46 | ||||
47 | ||||
48 | /***====================================================================***/ | |||
49 | ||||
50 | #define BUFFER_SIZE512 512 | |||
51 | ||||
52 | static char textBuffer[BUFFER_SIZE512]; | |||
53 | static int tbNext = 0; | |||
54 | ||||
55 | static char * | |||
56 | tbGetBuffer(unsigned size) | |||
57 | { | |||
58 | char *rtrn; | |||
59 | ||||
60 | if (size >= BUFFER_SIZE512) | |||
61 | return NULL((void*)0); | |||
62 | if ((BUFFER_SIZE512 - tbNext) <= size) | |||
63 | tbNext = 0; | |||
64 | rtrn = &textBuffer[tbNext]; | |||
65 | tbNext += size; | |||
66 | return rtrn; | |||
67 | } | |||
68 | ||||
69 | /***====================================================================***/ | |||
70 | ||||
71 | char * | |||
72 | XkbAtomText(Display *dpy, Atom atm, unsigned format) | |||
73 | { | |||
74 | char *rtrn, *tmp; | |||
75 | ||||
76 | tmp = XkbAtomGetString(dpy, atm); | |||
77 | if (tmp != NULL((void*)0)) { | |||
78 | int len; | |||
79 | ||||
80 | len = strlen(tmp) + 1; | |||
81 | if (len > BUFFER_SIZE512) | |||
82 | len = BUFFER_SIZE512 - 2; | |||
83 | rtrn = tbGetBuffer(len); | |||
84 | strncpy(rtrn, tmp, len)__builtin___strncpy_chk (rtrn, tmp, len, __builtin_object_size (rtrn, 2 > 1 ? 1 : 0)); | |||
85 | rtrn[len] = '\0'; | |||
86 | _XkbFree(tmp)free(tmp); | |||
87 | } | |||
88 | else { | |||
89 | rtrn = tbGetBuffer(1); | |||
90 | rtrn[0] = '\0'; | |||
91 | } | |||
92 | if (format == XkbCFile1) { | |||
93 | for (tmp = rtrn; *tmp != '\0'; tmp++) { | |||
94 | if ((tmp == rtrn) && (!isalpha(*tmp))) | |||
95 | *tmp = '_'; | |||
96 | else if (!isalnum(*tmp)) | |||
97 | *tmp = '_'; | |||
98 | } | |||
99 | } | |||
100 | return XkbStringText(rtrn, format); | |||
101 | } | |||
102 | ||||
103 | /***====================================================================***/ | |||
104 | ||||
105 | char * | |||
106 | XkbVModIndexText(Display *dpy, XkbDescPtr xkb, unsigned ndx, unsigned format) | |||
107 | { | |||
108 | register int len; | |||
109 | register Atom *vmodNames; | |||
110 | char *rtrn, *tmp; | |||
111 | ||||
112 | if (xkb && xkb->names) | |||
113 | vmodNames = xkb->names->vmods; | |||
114 | else | |||
115 | vmodNames = NULL((void*)0); | |||
116 | ||||
117 | tmp = NULL((void*)0); | |||
118 | if (ndx >= XkbNumVirtualMods16) | |||
119 | tmp = strdup("illegal"); | |||
120 | else if (vmodNames && (vmodNames[ndx] != None0L)) | |||
121 | tmp = XkbAtomGetString(dpy, vmodNames[ndx]); | |||
122 | if (tmp == NULL((void*)0)) { | |||
123 | tmp = (char *) _XkbAlloc(20 * sizeof(char))malloc((20 * sizeof(char))); | |||
124 | snprintf(tmp, 20, "%d", ndx)__builtin___snprintf_chk (tmp, 20, 0, __builtin_object_size ( tmp, 2 > 1 ? 1 : 0), "%d", ndx); | |||
125 | } | |||
126 | ||||
127 | len = strlen(tmp) + 1; | |||
128 | if (format == XkbCFile1) | |||
129 | len += 4; | |||
130 | if (len >= BUFFER_SIZE512) | |||
131 | len = BUFFER_SIZE512 - 1; | |||
132 | rtrn = tbGetBuffer(len); | |||
133 | if (format == XkbCFile1) { | |||
134 | snprintf(rtrn, len, "vmod_%s", tmp)__builtin___snprintf_chk (rtrn, len, 0, __builtin_object_size (rtrn, 2 > 1 ? 1 : 0), "vmod_%s", tmp); | |||
135 | } | |||
136 | else | |||
137 | strncpy(rtrn, tmp, len)__builtin___strncpy_chk (rtrn, tmp, len, __builtin_object_size (rtrn, 2 > 1 ? 1 : 0)); | |||
138 | _XkbFree(tmp)free(tmp); | |||
139 | return rtrn; | |||
140 | } | |||
141 | ||||
142 | char * | |||
143 | XkbVModMaskText(Display * dpy, | |||
144 | XkbDescPtr xkb, | |||
145 | unsigned modMask, | |||
146 | unsigned mask, | |||
147 | unsigned format) | |||
148 | { | |||
149 | register int i, bit; | |||
150 | int len; | |||
151 | char *mm, *rtrn; | |||
152 | char *str, buf[BUFFER_SIZE512]; | |||
153 | ||||
154 | if ((modMask == 0) && (mask == 0)) { | |||
155 | const int rtrnsize = 5; | |||
156 | rtrn = tbGetBuffer(rtrnsize); | |||
157 | if (format == XkbCFile1) | |||
158 | snprintf(rtrn, rtrnsize, "0")__builtin___snprintf_chk (rtrn, rtrnsize, 0, __builtin_object_size (rtrn, 2 > 1 ? 1 : 0), "0"); | |||
159 | else | |||
160 | snprintf(rtrn, rtrnsize, "none")__builtin___snprintf_chk (rtrn, rtrnsize, 0, __builtin_object_size (rtrn, 2 > 1 ? 1 : 0), "none"); | |||
161 | return rtrn; | |||
162 | } | |||
163 | if (modMask != 0) | |||
164 | mm = XkbModMaskText(modMask, format); | |||
165 | else | |||
166 | mm = NULL((void*)0); | |||
167 | ||||
168 | str = buf; | |||
169 | buf[0] = '\0'; | |||
170 | if (mask) { | |||
171 | char *tmp; | |||
172 | ||||
173 | for (i = 0, bit = 1; i < XkbNumVirtualMods16; i++, bit <<= 1) { | |||
174 | if (mask & bit) { | |||
175 | tmp = XkbVModIndexText(dpy, xkb, i, format); | |||
176 | len = strlen(tmp) + 1 + (str == buf ? 0 : 1); | |||
177 | if (format == XkbCFile1) | |||
178 | len += 4; | |||
179 | if ((str - (buf + len)) <= BUFFER_SIZE512) { | |||
180 | if (str != buf) { | |||
181 | if (format == XkbCFile1) | |||
182 | *str++ = '|'; | |||
183 | else | |||
184 | *str++ = '+'; | |||
185 | len--; | |||
186 | } | |||
187 | } | |||
188 | if (format == XkbCFile1) | |||
189 | sprintf(str, "%sMask", tmp)__builtin___sprintf_chk (str, 0, __builtin_object_size (str, 2 > 1 ? 1 : 0), "%sMask", tmp); | |||
190 | else | |||
191 | strcpy(str, tmp)__builtin___strcpy_chk (str, tmp, __builtin_object_size (str, 2 > 1 ? 1 : 0)); | |||
192 | str = &str[len - 1]; | |||
193 | } | |||
194 | } | |||
195 | str = buf; | |||
196 | } | |||
197 | else | |||
198 | str = NULL((void*)0); | |||
199 | if (mm) | |||
200 | len = strlen(mm); | |||
201 | else | |||
202 | len = 0; | |||
203 | if (str) | |||
204 | len += strlen(str) + (mm == NULL((void*)0) ? 0 : 1); | |||
205 | if (len >= BUFFER_SIZE512) | |||
206 | len = BUFFER_SIZE512 - 1; | |||
207 | rtrn = tbGetBuffer(len + 1); | |||
208 | rtrn[0] = '\0'; | |||
209 | ||||
210 | if (mm != NULL((void*)0)) { | |||
211 | i = strlen(mm); | |||
212 | if (i > len) | |||
213 | i = len; | |||
214 | strcpy(rtrn, mm)__builtin___strcpy_chk (rtrn, mm, __builtin_object_size (rtrn , 2 > 1 ? 1 : 0)); | |||
215 | } | |||
216 | else { | |||
217 | i = 0; | |||
218 | } | |||
219 | if (str != NULL((void*)0)) { | |||
220 | if (mm != NULL((void*)0)) { | |||
221 | if (format == XkbCFile1) | |||
222 | strcat(rtrn, "|")__builtin___strcat_chk (rtrn, "|", __builtin_object_size (rtrn , 2 > 1 ? 1 : 0)); | |||
223 | else | |||
224 | strcat(rtrn, "+")__builtin___strcat_chk (rtrn, "+", __builtin_object_size (rtrn , 2 > 1 ? 1 : 0)); | |||
225 | } | |||
226 | strncat(rtrn, str, len - i)__builtin___strncat_chk (rtrn, str, len - i, __builtin_object_size (rtrn, 2 > 1 ? 1 : 0)); | |||
227 | } | |||
228 | rtrn[len] = '\0'; | |||
229 | return rtrn; | |||
230 | } | |||
231 | ||||
232 | static const char *modNames[XkbNumModifiers8] = { | |||
233 | "Shift", "Lock", "Control", "Mod1", "Mod2", "Mod3", "Mod4", "Mod5" | |||
234 | }; | |||
235 | ||||
236 | char * | |||
237 | XkbModIndexText(unsigned ndx, unsigned format) | |||
238 | { | |||
239 | char *rtrn; | |||
240 | char buf[100]; | |||
241 | ||||
242 | if (format == XkbCFile1) { | |||
243 | if (ndx < XkbNumModifiers8) | |||
244 | snprintf(buf, sizeof(buf), "%sMapIndex", modNames[ndx])__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%sMapIndex", modNames[ndx]); | |||
245 | else if (ndx == XkbNoModifier0xff) | |||
246 | snprintf(buf, sizeof(buf), "XkbNoModifier")__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "XkbNoModifier"); | |||
247 | else | |||
248 | snprintf(buf, sizeof(buf), "0x%02x", ndx)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "0x%02x", ndx); | |||
249 | } | |||
250 | else { | |||
251 | if (ndx < XkbNumModifiers8) | |||
252 | strcpy(buf, modNames[ndx])__builtin___strcpy_chk (buf, modNames[ndx], __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
253 | else if (ndx == XkbNoModifier0xff) | |||
254 | strcpy(buf, "none")__builtin___strcpy_chk (buf, "none", __builtin_object_size (buf , 2 > 1 ? 1 : 0)); | |||
255 | else | |||
256 | snprintf(buf, sizeof(buf), "ILLEGAL_%02x", ndx)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "ILLEGAL_%02x", ndx); | |||
257 | } | |||
258 | rtrn = tbGetBuffer(strlen(buf) + 1); | |||
259 | strcpy(rtrn, buf)__builtin___strcpy_chk (rtrn, buf, __builtin_object_size (rtrn , 2 > 1 ? 1 : 0)); | |||
260 | return rtrn; | |||
261 | } | |||
262 | ||||
263 | char * | |||
264 | XkbModMaskText(unsigned mask, unsigned format) | |||
265 | { | |||
266 | register int i, bit; | |||
267 | char buf[64], *rtrn; | |||
268 | ||||
269 | if ((mask & 0xff) == 0xff) { | |||
270 | if (format == XkbCFile1) | |||
271 | strcpy(buf, "0xff")__builtin___strcpy_chk (buf, "0xff", __builtin_object_size (buf , 2 > 1 ? 1 : 0)); | |||
272 | else | |||
273 | strcpy(buf, "all")__builtin___strcpy_chk (buf, "all", __builtin_object_size (buf , 2 > 1 ? 1 : 0)); | |||
274 | } | |||
275 | else if ((mask & 0xff) == 0) { | |||
276 | if (format == XkbCFile1) | |||
277 | strcpy(buf, "0")__builtin___strcpy_chk (buf, "0", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
278 | else | |||
279 | strcpy(buf, "none")__builtin___strcpy_chk (buf, "none", __builtin_object_size (buf , 2 > 1 ? 1 : 0)); | |||
280 | } | |||
281 | else { | |||
282 | char *str = buf; | |||
283 | ||||
284 | buf[0] = '\0'; | |||
285 | for (i = 0, bit = 1; i < XkbNumModifiers8; i++, bit <<= 1) { | |||
286 | if (mask & bit) { | |||
287 | if (str != buf) { | |||
288 | if (format == XkbCFile1) | |||
289 | *str++ = '|'; | |||
290 | else | |||
291 | *str++ = '+'; | |||
292 | } | |||
293 | strcpy(str, modNames[i])__builtin___strcpy_chk (str, modNames[i], __builtin_object_size (str, 2 > 1 ? 1 : 0)); | |||
294 | str = &str[strlen(str)]; | |||
295 | if (format == XkbCFile1) { | |||
296 | strcpy(str, "Mask")__builtin___strcpy_chk (str, "Mask", __builtin_object_size (str , 2 > 1 ? 1 : 0)); | |||
297 | str += 4; | |||
298 | } | |||
299 | } | |||
300 | } | |||
301 | } | |||
302 | rtrn = tbGetBuffer(strlen(buf) + 1); | |||
303 | strcpy(rtrn, buf)__builtin___strcpy_chk (rtrn, buf, __builtin_object_size (rtrn , 2 > 1 ? 1 : 0)); | |||
304 | return rtrn; | |||
305 | } | |||
306 | ||||
307 | /***====================================================================***/ | |||
308 | ||||
309 | /*ARGSUSED*/ | |||
310 | char * | |||
311 | XkbConfigText(unsigned config, unsigned format) | |||
312 | { | |||
313 | static char *buf; | |||
314 | const int bufsize = 32; | |||
315 | ||||
316 | buf = tbGetBuffer(bufsize); | |||
317 | switch (config) { | |||
318 | case XkmSemanticsFile20: | |||
319 | strcpy(buf, "Semantics")__builtin___strcpy_chk (buf, "Semantics", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
320 | break; | |||
321 | case XkmLayoutFile21: | |||
322 | strcpy(buf, "Layout")__builtin___strcpy_chk (buf, "Layout", __builtin_object_size ( buf, 2 > 1 ? 1 : 0)); | |||
323 | break; | |||
324 | case XkmKeymapFile22: | |||
325 | strcpy(buf, "Keymap")__builtin___strcpy_chk (buf, "Keymap", __builtin_object_size ( buf, 2 > 1 ? 1 : 0)); | |||
326 | break; | |||
327 | case XkmGeometryFile23: | |||
328 | case XkmGeometryIndex5: | |||
329 | strcpy(buf, "Geometry")__builtin___strcpy_chk (buf, "Geometry", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
330 | break; | |||
331 | case XkmTypesIndex0: | |||
332 | strcpy(buf, "Types")__builtin___strcpy_chk (buf, "Types", __builtin_object_size ( buf, 2 > 1 ? 1 : 0)); | |||
333 | break; | |||
334 | case XkmCompatMapIndex1: | |||
335 | strcpy(buf, "CompatMap")__builtin___strcpy_chk (buf, "CompatMap", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
336 | break; | |||
337 | case XkmSymbolsIndex2: | |||
338 | strcpy(buf, "Symbols")__builtin___strcpy_chk (buf, "Symbols", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
339 | break; | |||
340 | case XkmIndicatorsIndex3: | |||
341 | strcpy(buf, "Indicators")__builtin___strcpy_chk (buf, "Indicators", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
342 | break; | |||
343 | case XkmKeyNamesIndex4: | |||
344 | strcpy(buf, "KeyNames")__builtin___strcpy_chk (buf, "KeyNames", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
345 | break; | |||
346 | case XkmVirtualModsIndex6: | |||
347 | strcpy(buf, "VirtualMods")__builtin___strcpy_chk (buf, "VirtualMods", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
348 | break; | |||
349 | default: | |||
350 | snprintf(buf, bufsize, "unknown(%d)", config)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "unknown(%d)", config); | |||
351 | break; | |||
352 | } | |||
353 | return buf; | |||
354 | } | |||
355 | ||||
356 | /***====================================================================***/ | |||
357 | ||||
358 | char * | |||
359 | XkbKeysymText(KeySym sym, unsigned format) | |||
360 | { | |||
361 | static char buf[32], *rtrn; | |||
362 | ||||
363 | if (sym == NoSymbol0L) | |||
364 | strcpy(rtrn = buf, "NoSymbol")__builtin___strcpy_chk (rtrn = buf, "NoSymbol", __builtin_object_size (rtrn = buf, 2 > 1 ? 1 : 0)); | |||
365 | else if ((rtrn = XKeysymToString(sym)) == NULL((void*)0)) { | |||
366 | snprintf(buf, sizeof(buf), "0x%lx", (long) sym)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "0x%lx", (long) sym); | |||
367 | rtrn = buf; | |||
368 | } | |||
369 | else if (format == XkbCFile1) { | |||
370 | snprintf(buf, sizeof(buf), "XK_%s", rtrn)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "XK_%s", rtrn); | |||
371 | rtrn = buf; | |||
372 | } | |||
373 | return rtrn; | |||
374 | } | |||
375 | ||||
376 | char * | |||
377 | XkbKeyNameText(char *name, unsigned format) | |||
378 | { | |||
379 | char *buf; | |||
380 | ||||
381 | if (format == XkbCFile1) { | |||
382 | buf = tbGetBuffer(5); | |||
383 | memcpy(buf, name, 4)__builtin___memcpy_chk (buf, name, 4, __builtin_object_size ( buf, 0)); | |||
384 | buf[4] = '\0'; | |||
385 | } | |||
386 | else { | |||
387 | int len; | |||
388 | ||||
389 | buf = tbGetBuffer(7); | |||
390 | buf[0] = '<'; | |||
391 | memcpy(&buf[1], name, 4)__builtin___memcpy_chk (&buf[1], name, 4, __builtin_object_size (&buf[1], 0)); | |||
392 | buf[5] = '\0'; | |||
393 | len = strlen(buf); | |||
394 | buf[len++] = '>'; | |||
395 | buf[len] = '\0'; | |||
396 | } | |||
397 | return buf; | |||
398 | } | |||
399 | ||||
400 | /***====================================================================***/ | |||
401 | ||||
402 | static char *siMatchText[5] = { | |||
403 | "NoneOf", "AnyOfOrNone", "AnyOf", "AllOf", "Exactly" | |||
404 | }; | |||
405 | ||||
406 | char * | |||
407 | XkbSIMatchText(unsigned type, unsigned format) | |||
408 | { | |||
409 | static char buf[40]; | |||
410 | ||||
411 | char *rtrn; | |||
412 | ||||
413 | switch (type & XkbSI_OpMask(0x7f)) { | |||
414 | case XkbSI_NoneOf(0): rtrn = siMatchText[0]; break; | |||
415 | case XkbSI_AnyOfOrNone(1): rtrn = siMatchText[1]; break; | |||
416 | case XkbSI_AnyOf(2): rtrn = siMatchText[2]; break; | |||
417 | case XkbSI_AllOf(3): rtrn = siMatchText[3]; break; | |||
418 | case XkbSI_Exactly(4): rtrn = siMatchText[4]; break; | |||
419 | default: | |||
420 | snprintf(buf, sizeof(buf), "0x%x", type & XkbSI_OpMask)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "0x%x", type & (0x7f)); | |||
421 | return buf; | |||
422 | } | |||
423 | if (format == XkbCFile1) { | |||
424 | if (type & XkbSI_LevelOneOnly(0x80)) | |||
425 | snprintf(buf, sizeof(buf), "XkbSI_LevelOneOnly|XkbSI_%s", rtrn)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "XkbSI_LevelOneOnly|XkbSI_%s", rtrn ); | |||
426 | else | |||
427 | snprintf(buf, sizeof(buf), "XkbSI_%s", rtrn)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "XkbSI_%s", rtrn); | |||
428 | rtrn = buf; | |||
429 | } | |||
430 | return rtrn; | |||
431 | } | |||
432 | ||||
433 | /***====================================================================***/ | |||
434 | ||||
435 | static const char *imWhichNames[] = { | |||
436 | "base", | |||
437 | "latched", | |||
438 | "locked", | |||
439 | "effective", | |||
440 | "compat" | |||
441 | }; | |||
442 | ||||
443 | char * | |||
444 | XkbIMWhichStateMaskText(unsigned use_which, unsigned format) | |||
445 | { | |||
446 | int len, bufsize; | |||
447 | unsigned i, bit, tmp; | |||
448 | char *buf; | |||
449 | ||||
450 | if (use_which == 0) { | |||
451 | buf = tbGetBuffer(2); | |||
452 | strcpy(buf, "0")__builtin___strcpy_chk (buf, "0", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
453 | return buf; | |||
454 | } | |||
455 | tmp = use_which & XkbIM_UseAnyMods(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4)); | |||
456 | for (len = i = 0, bit = 1; tmp != 0; i++, bit <<= 1) { | |||
457 | if (tmp & bit) { | |||
458 | tmp &= ~bit; | |||
459 | len += strlen(imWhichNames[i]) + 1; | |||
460 | if (format == XkbCFile1) | |||
461 | len += 9; | |||
462 | } | |||
463 | } | |||
464 | bufsize = len + 1; | |||
465 | buf = tbGetBuffer(bufsize); | |||
466 | tmp = use_which & XkbIM_UseAnyMods(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4)); | |||
467 | for (len = i = 0, bit = 1; tmp != 0; i++, bit <<= 1) { | |||
468 | if (tmp & bit) { | |||
469 | tmp &= ~bit; | |||
470 | if (format == XkbCFile1) { | |||
471 | if (len != 0) | |||
472 | buf[len++] = '|'; | |||
473 | snprintf(&buf[len], bufsize - len,__builtin___snprintf_chk (&buf[len], bufsize - len, 0, __builtin_object_size (&buf[len], 2 > 1 ? 1 : 0), "XkbIM_Use%s", imWhichNames [i]) | |||
474 | "XkbIM_Use%s", imWhichNames[i])__builtin___snprintf_chk (&buf[len], bufsize - len, 0, __builtin_object_size (&buf[len], 2 > 1 ? 1 : 0), "XkbIM_Use%s", imWhichNames [i]); | |||
475 | buf[len + 9] = toupper(buf[len + 9]); | |||
476 | } | |||
477 | else { | |||
478 | if (len != 0) | |||
479 | buf[len++] = '+'; | |||
480 | snprintf(&buf[len], bufsize - len,__builtin___snprintf_chk (&buf[len], bufsize - len, 0, __builtin_object_size (&buf[len], 2 > 1 ? 1 : 0), "%s", imWhichNames[i]) | |||
481 | "%s", imWhichNames[i])__builtin___snprintf_chk (&buf[len], bufsize - len, 0, __builtin_object_size (&buf[len], 2 > 1 ? 1 : 0), "%s", imWhichNames[i]); | |||
482 | } | |||
483 | len += strlen(&buf[len]); | |||
484 | } | |||
485 | } | |||
486 | return buf; | |||
487 | } | |||
488 | ||||
489 | char * | |||
490 | XkbAccessXDetailText(unsigned state, unsigned format) | |||
491 | { | |||
492 | char *buf; | |||
493 | const char *prefix; | |||
494 | const int bufsize = 32; | |||
495 | ||||
496 | buf = tbGetBuffer(bufsize); | |||
497 | if (format == XkbMessage3) | |||
498 | prefix = ""; | |||
499 | else | |||
500 | prefix = "XkbAXN_"; | |||
501 | switch (state) { | |||
502 | case XkbAXN_SKPress0: | |||
503 | snprintf(buf, bufsize, "%sSKPress", prefix)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%sSKPress", prefix); | |||
504 | break; | |||
505 | case XkbAXN_SKAccept1: | |||
506 | snprintf(buf, bufsize, "%sSKAccept", prefix)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%sSKAccept", prefix); | |||
507 | break; | |||
508 | case XkbAXN_SKRelease3: | |||
509 | snprintf(buf, bufsize, "%sSKRelease", prefix)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%sSKRelease", prefix); | |||
510 | break; | |||
511 | case XkbAXN_SKReject2: | |||
512 | snprintf(buf, bufsize, "%sSKReject", prefix)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%sSKReject", prefix); | |||
513 | break; | |||
514 | case XkbAXN_BKAccept4: | |||
515 | snprintf(buf, bufsize, "%sBKAccept", prefix)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%sBKAccept", prefix); | |||
516 | break; | |||
517 | case XkbAXN_BKReject5: | |||
518 | snprintf(buf, bufsize, "%sBKReject", prefix)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%sBKReject", prefix); | |||
519 | break; | |||
520 | case XkbAXN_AXKWarning6: | |||
521 | snprintf(buf, bufsize, "%sAXKWarning", prefix)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%sAXKWarning", prefix); | |||
522 | break; | |||
523 | default: | |||
524 | snprintf(buf, bufsize, "ILLEGAL")__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "ILLEGAL"); | |||
525 | break; | |||
526 | } | |||
527 | return buf; | |||
528 | } | |||
529 | ||||
530 | static const char *nknNames[] = { | |||
531 | "keycodes", "geometry", "deviceID" | |||
532 | }; | |||
533 | #define NUM_NKN(sizeof(nknNames)/sizeof(char *)) (sizeof(nknNames)/sizeof(char *)) | |||
534 | ||||
535 | char * | |||
536 | XkbNKNDetailMaskText(unsigned detail, unsigned format) | |||
537 | { | |||
538 | char *buf; | |||
539 | const char *prefix, *suffix; | |||
540 | register int i; | |||
541 | register unsigned bit; | |||
542 | int len, plen, slen; | |||
543 | ||||
544 | if ((detail & XkbAllNewKeyboardEventsMask(0x7)) == 0) { | |||
545 | const char *tmp = ""; | |||
546 | ||||
547 | if (format == XkbCFile1) | |||
548 | tmp = "0"; | |||
549 | else if (format == XkbMessage3) | |||
550 | tmp = "none"; | |||
551 | buf = tbGetBuffer(strlen(tmp) + 1); | |||
552 | strcpy(buf, tmp)__builtin___strcpy_chk (buf, tmp, __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
553 | return buf; | |||
554 | } | |||
555 | else if ((detail & XkbAllNewKeyboardEventsMask(0x7)) == | |||
556 | XkbAllNewKeyboardEventsMask(0x7)) { | |||
557 | const char *tmp; | |||
558 | ||||
559 | if (format == XkbCFile1) | |||
560 | tmp = "XkbAllNewKeyboardEventsMask"; | |||
561 | else | |||
562 | tmp = "all"; | |||
563 | buf = tbGetBuffer(strlen(tmp) + 1); | |||
564 | strcpy(buf, tmp)__builtin___strcpy_chk (buf, tmp, __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
565 | return buf; | |||
566 | } | |||
567 | if (format == XkbMessage3) { | |||
568 | prefix = ""; | |||
569 | suffix = ""; | |||
570 | slen = plen = 0; | |||
571 | } | |||
572 | else { | |||
573 | prefix = "XkbNKN_"; | |||
574 | plen = 7; | |||
575 | if (format == XkbCFile1) | |||
576 | suffix = "Mask"; | |||
577 | else | |||
578 | suffix = ""; | |||
579 | slen = strlen(suffix); | |||
580 | } | |||
581 | for (len = 0, i = 0, bit = 1; i < NUM_NKN(sizeof(nknNames)/sizeof(char *)); i++, bit <<= 1) { | |||
582 | if (detail & bit) { | |||
583 | if (len != 0) | |||
584 | len += 1; /* room for '+' or '|' */ | |||
585 | len += plen + slen + strlen(nknNames[i]); | |||
586 | } | |||
587 | } | |||
588 | buf = tbGetBuffer(len + 1); | |||
589 | buf[0] = '\0'; | |||
590 | for (len = 0, i = 0, bit = 1; i < NUM_NKN(sizeof(nknNames)/sizeof(char *)); i++, bit <<= 1) { | |||
591 | if (detail & bit) { | |||
592 | if (len != 0) { | |||
593 | if (format == XkbCFile1) | |||
594 | buf[len++] = '|'; | |||
595 | else | |||
596 | buf[len++] = '+'; | |||
597 | } | |||
598 | if (plen) { | |||
599 | strcpy(&buf[len], prefix)__builtin___strcpy_chk (&buf[len], prefix, __builtin_object_size (&buf[len], 2 > 1 ? 1 : 0)); | |||
600 | len += plen; | |||
601 | } | |||
602 | strcpy(&buf[len], nknNames[i])__builtin___strcpy_chk (&buf[len], nknNames[i], __builtin_object_size (&buf[len], 2 > 1 ? 1 : 0)); | |||
603 | len += strlen(nknNames[i]); | |||
604 | if (slen) { | |||
605 | strcpy(&buf[len], suffix)__builtin___strcpy_chk (&buf[len], suffix, __builtin_object_size (&buf[len], 2 > 1 ? 1 : 0)); | |||
606 | len += slen; | |||
607 | } | |||
608 | } | |||
609 | } | |||
610 | buf[len++] = '\0'; | |||
611 | return buf; | |||
612 | } | |||
613 | ||||
614 | static const char *ctrlNames[] = { | |||
615 | "repeatKeys", | |||
616 | "slowKeys", | |||
617 | "bounceKeys", | |||
618 | "stickyKeys", | |||
619 | "mouseKeys", | |||
620 | "mouseKeysAccel", | |||
621 | "accessXKeys", | |||
622 | "accessXTimeout", | |||
623 | "accessXFeedback", | |||
624 | "audibleBell", | |||
625 | "overlay1", | |||
626 | "overlay2", | |||
627 | "ignoreGroupLock" | |||
628 | }; | |||
629 | ||||
630 | char * | |||
631 | XkbControlsMaskText(unsigned ctrls, unsigned format) | |||
632 | { | |||
633 | int len; | |||
634 | unsigned i, bit, tmp; | |||
635 | char *buf; | |||
636 | ||||
637 | if (ctrls == 0) { | |||
| ||||
638 | buf = tbGetBuffer(5); | |||
639 | if (format == XkbCFile1) | |||
640 | strcpy(buf, "0")__builtin___strcpy_chk (buf, "0", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
641 | else | |||
642 | strcpy(buf, "none")__builtin___strcpy_chk (buf, "none", __builtin_object_size (buf , 2 > 1 ? 1 : 0)); | |||
643 | return buf; | |||
644 | } | |||
645 | tmp = ctrls & XkbAllBooleanCtrlsMask(0x00001FFF); | |||
646 | for (len = i = 0, bit = 1; tmp != 0; i++, bit <<= 1) { | |||
647 | if (tmp & bit) { | |||
648 | tmp &= ~bit; | |||
649 | len += strlen(ctrlNames[i]) + 1; | |||
650 | if (format == XkbCFile1) | |||
651 | len += 7; | |||
652 | } | |||
653 | } | |||
654 | buf = tbGetBuffer(len + 1); | |||
655 | tmp = ctrls & XkbAllBooleanCtrlsMask(0x00001FFF); | |||
656 | for (len = i = 0, bit = 1; tmp != 0; i++, bit <<= 1) { | |||
657 | if (tmp & bit) { | |||
658 | tmp &= ~bit; | |||
659 | if (format == XkbCFile1) { | |||
660 | if (len != 0) | |||
661 | buf[len++] = '|'; | |||
662 | sprintf(&buf[len], "Xkb%sMask", ctrlNames[i])__builtin___sprintf_chk (&buf[len], 0, __builtin_object_size (&buf[len], 2 > 1 ? 1 : 0), "Xkb%sMask", ctrlNames[i] ); | |||
663 | buf[len + 3] = toupper(buf[len + 3]); | |||
664 | } | |||
665 | else { | |||
666 | if (len != 0) | |||
667 | buf[len++] = '+'; | |||
668 | sprintf(&buf[len], "%s", ctrlNames[i])__builtin___sprintf_chk (&buf[len], 0, __builtin_object_size (&buf[len], 2 > 1 ? 1 : 0), "%s", ctrlNames[i]); | |||
669 | } | |||
670 | len += strlen(&buf[len]); | |||
| ||||
671 | } | |||
672 | } | |||
673 | return buf; | |||
674 | } | |||
675 | ||||
676 | /***====================================================================***/ | |||
677 | ||||
678 | char * | |||
679 | XkbStringText(char *str, unsigned format) | |||
680 | { | |||
681 | char *buf; | |||
682 | register char *in, *out; | |||
683 | int len; | |||
684 | Boolint ok; | |||
685 | ||||
686 | if (str == NULL((void*)0)) { | |||
687 | buf = tbGetBuffer(2); | |||
688 | buf[0] = '\0'; | |||
689 | return buf; | |||
690 | } | |||
691 | else if (format == XkbXKMFile0) | |||
692 | return str; | |||
693 | for (ok = True1, len = 0, in = str; *in != '\0'; in++, len++) { | |||
694 | if (!isprint(*in)) { | |||
695 | ok = False0; | |||
696 | switch (*in) { | |||
697 | case '\n': | |||
698 | case '\t': | |||
699 | case '\v': | |||
700 | case '\b': | |||
701 | case '\r': | |||
702 | case '\f': | |||
703 | len++; | |||
704 | break; | |||
705 | default: | |||
706 | len += 4; | |||
707 | break; | |||
708 | } | |||
709 | } | |||
710 | } | |||
711 | if (ok) | |||
712 | return str; | |||
713 | buf = tbGetBuffer(len + 1); | |||
714 | for (in = str, out = buf; *in != '\0'; in++) { | |||
715 | if (isprint(*in)) | |||
716 | *out++ = *in; | |||
717 | else { | |||
718 | *out++ = '\\'; | |||
719 | if (*in == '\n') | |||
720 | *out++ = 'n'; | |||
721 | else if (*in == '\t') | |||
722 | *out++ = 't'; | |||
723 | else if (*in == '\v') | |||
724 | *out++ = 'v'; | |||
725 | else if (*in == '\b') | |||
726 | *out++ = 'b'; | |||
727 | else if (*in == '\r') | |||
728 | *out++ = 'r'; | |||
729 | else if (*in == '\f') | |||
730 | *out++ = 'f'; | |||
731 | else if ((*in == '\033') && (format == XkbXKMFile0)) { | |||
732 | *out++ = 'e'; | |||
733 | } | |||
734 | else { | |||
735 | *out++ = '0'; | |||
736 | sprintf(out, "%o", *in)__builtin___sprintf_chk (out, 0, __builtin_object_size (out, 2 > 1 ? 1 : 0), "%o", *in); | |||
737 | while (*out != '\0') | |||
738 | out++; | |||
739 | } | |||
740 | } | |||
741 | } | |||
742 | *out++ = '\0'; | |||
743 | return buf; | |||
744 | } | |||
745 | ||||
746 | /***====================================================================***/ | |||
747 | ||||
748 | char * | |||
749 | XkbGeomFPText(int val, unsigned format) | |||
750 | { | |||
751 | int whole, frac; | |||
752 | char *buf; | |||
753 | const int bufsize = 12; | |||
754 | ||||
755 | buf = tbGetBuffer(bufsize); | |||
756 | if (format == XkbCFile1) { | |||
757 | snprintf(buf, bufsize, "%d", val)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%d", val); | |||
758 | } | |||
759 | else { | |||
760 | whole = val / XkbGeomPtsPerMM10; | |||
761 | frac = val % XkbGeomPtsPerMM10; | |||
762 | if (frac != 0) | |||
763 | snprintf(buf, bufsize, "%d.%d", whole, frac)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%d.%d", whole, frac); | |||
764 | else | |||
765 | snprintf(buf, bufsize, "%d", whole)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%d", whole); | |||
766 | } | |||
767 | return buf; | |||
768 | } | |||
769 | ||||
770 | char * | |||
771 | XkbDoodadTypeText(unsigned type, unsigned format) | |||
772 | { | |||
773 | char *buf; | |||
774 | ||||
775 | if (format == XkbCFile1) { | |||
776 | const int bufsize = 24; | |||
777 | buf = tbGetBuffer(bufsize); | |||
778 | if (type == XkbOutlineDoodad1) | |||
779 | strcpy(buf, "XkbOutlineDoodad")__builtin___strcpy_chk (buf, "XkbOutlineDoodad", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
780 | else if (type == XkbSolidDoodad2) | |||
781 | strcpy(buf, "XkbSolidDoodad")__builtin___strcpy_chk (buf, "XkbSolidDoodad", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
782 | else if (type == XkbTextDoodad3) | |||
783 | strcpy(buf, "XkbTextDoodad")__builtin___strcpy_chk (buf, "XkbTextDoodad", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
784 | else if (type == XkbIndicatorDoodad4) | |||
785 | strcpy(buf, "XkbIndicatorDoodad")__builtin___strcpy_chk (buf, "XkbIndicatorDoodad", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
786 | else if (type == XkbLogoDoodad5) | |||
787 | strcpy(buf, "XkbLogoDoodad")__builtin___strcpy_chk (buf, "XkbLogoDoodad", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
788 | else | |||
789 | snprintf(buf, bufsize, "UnknownDoodad%d", type)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "UnknownDoodad%d", type); | |||
790 | } | |||
791 | else { | |||
792 | const int bufsize = 12; | |||
793 | buf = tbGetBuffer(bufsize); | |||
794 | if (type == XkbOutlineDoodad1) | |||
795 | strcpy(buf, "outline")__builtin___strcpy_chk (buf, "outline", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
796 | else if (type == XkbSolidDoodad2) | |||
797 | strcpy(buf, "solid")__builtin___strcpy_chk (buf, "solid", __builtin_object_size ( buf, 2 > 1 ? 1 : 0)); | |||
798 | else if (type == XkbTextDoodad3) | |||
799 | strcpy(buf, "text")__builtin___strcpy_chk (buf, "text", __builtin_object_size (buf , 2 > 1 ? 1 : 0)); | |||
800 | else if (type == XkbIndicatorDoodad4) | |||
801 | strcpy(buf, "indicator")__builtin___strcpy_chk (buf, "indicator", __builtin_object_size (buf, 2 > 1 ? 1 : 0)); | |||
802 | else if (type == XkbLogoDoodad5) | |||
803 | strcpy(buf, "logo")__builtin___strcpy_chk (buf, "logo", __builtin_object_size (buf , 2 > 1 ? 1 : 0)); | |||
804 | else | |||
805 | snprintf(buf, bufsize, "unknown%d", type)__builtin___snprintf_chk (buf, bufsize, 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "unknown%d", type); | |||
806 | } | |||
807 | return buf; | |||
808 | } | |||
809 | ||||
810 | static char *actionTypeNames[XkbSA_NumActions(0x14 +1)] = { | |||
811 | "NoAction", | |||
812 | "SetMods", "LatchMods", "LockMods", | |||
813 | "SetGroup", "LatchGroup", "LockGroup", | |||
814 | "MovePtr", | |||
815 | "PtrBtn", "LockPtrBtn", | |||
816 | "SetPtrDflt", | |||
817 | "ISOLock", | |||
818 | "Terminate", "SwitchScreen", | |||
819 | "SetControls", "LockControls", | |||
820 | "ActionMessage", | |||
821 | "RedirectKey", | |||
822 | "DeviceBtn", "LockDeviceBtn" | |||
823 | }; | |||
824 | ||||
825 | char * | |||
826 | XkbActionTypeText(unsigned type, unsigned format) | |||
827 | { | |||
828 | static char buf[32]; | |||
829 | char *rtrn; | |||
830 | ||||
831 | if (type <= XkbSA_LastAction0x14) { | |||
832 | rtrn = actionTypeNames[type]; | |||
833 | if (format == XkbCFile1) { | |||
834 | snprintf(buf, sizeof(buf), "XkbSA_%s", rtrn)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "XkbSA_%s", rtrn); | |||
835 | return buf; | |||
836 | } | |||
837 | return rtrn; | |||
838 | } | |||
839 | snprintf(buf, sizeof(buf), "Private")__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "Private"); | |||
840 | return buf; | |||
841 | } | |||
842 | ||||
843 | /***====================================================================***/ | |||
844 | ||||
845 | static int | |||
846 | TryCopyStr(char *to, const char *from, int *pLeft) | |||
847 | { | |||
848 | register int len; | |||
849 | ||||
850 | if (*pLeft > 0) { | |||
851 | len = strlen(from); | |||
852 | if (len < ((*pLeft) - 3)) { | |||
853 | strcat(to, from)__builtin___strcat_chk (to, from, __builtin_object_size (to, 2 > 1 ? 1 : 0)); | |||
854 | *pLeft -= len; | |||
855 | return True1; | |||
856 | } | |||
857 | } | |||
858 | *pLeft = -1; | |||
859 | return False0; | |||
860 | } | |||
861 | ||||
862 | /*ARGSUSED*/ | |||
863 | static Boolint | |||
864 | CopyNoActionArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
865 | char *buf, int *sz) | |||
866 | { | |||
867 | return True1; | |||
868 | } | |||
869 | ||||
870 | static Boolint | |||
871 | CopyModActionArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
872 | char *buf, int *sz) | |||
873 | { | |||
874 | XkbModAction *act; | |||
875 | unsigned tmp; | |||
876 | ||||
877 | act = &action->mods; | |||
878 | tmp = XkbModActionVMods(act)((short)(((act)->vmods1<<8)|((act)->vmods2))); | |||
879 | TryCopyStr(buf, "modifiers=", sz); | |||
880 | if (act->flags & XkbSA_UseModMapMods(1L << 2)) | |||
881 | TryCopyStr(buf, "modMapMods", sz); | |||
882 | else if (act->real_mods || tmp) { | |||
883 | TryCopyStr(buf, | |||
884 | XkbVModMaskText(dpy, xkb, act->real_mods, tmp, XkbXKBFile2), | |||
885 | sz); | |||
886 | } | |||
887 | else | |||
888 | TryCopyStr(buf, "none", sz); | |||
889 | if (act->type == XkbSA_LockMods0x03) { | |||
890 | switch (act->flags & (XkbSA_LockNoUnlock(1L << 1) | XkbSA_LockNoLock(1L << 0))) { | |||
891 | case XkbSA_LockNoLock(1L << 0): | |||
892 | TryCopyStr(buf, ",affect=unlock", sz); | |||
893 | break; | |||
894 | case XkbSA_LockNoUnlock(1L << 1): | |||
895 | TryCopyStr(buf, ",affect=lock", sz); | |||
896 | break; | |||
897 | case XkbSA_LockNoUnlock(1L << 1)|XkbSA_LockNoLock(1L << 0): | |||
898 | TryCopyStr(buf, ",affect=neither", sz); | |||
899 | break; | |||
900 | default: | |||
901 | break; | |||
902 | } | |||
903 | return True1; | |||
904 | } | |||
905 | if (act->flags & XkbSA_ClearLocks(1L << 0)) | |||
906 | TryCopyStr(buf, ",clearLocks", sz); | |||
907 | if (act->flags & XkbSA_LatchToLock(1L << 1)) | |||
908 | TryCopyStr(buf, ",latchToLock", sz); | |||
909 | return True1; | |||
910 | } | |||
911 | ||||
912 | /*ARGSUSED*/ | |||
913 | static Boolint | |||
914 | CopyGroupActionArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
915 | char *buf, int *sz) | |||
916 | { | |||
917 | XkbGroupAction *act; | |||
918 | char tbuf[32]; | |||
919 | ||||
920 | act = &action->group; | |||
921 | TryCopyStr(buf, "group=", sz); | |||
922 | if (act->flags & XkbSA_GroupAbsolute(1L << 2)) | |||
923 | snprintf(tbuf, sizeof(tbuf), "%d", XkbSAGroup(act) + 1)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%d", ((((act)->group_XXX)& 0x80?(int)(((act)->group_XXX)|(~0xff)):(int)(((act)->group_XXX )&0x7f))) + 1); | |||
924 | else if (XkbSAGroup(act)((((act)->group_XXX)&0x80?(int)(((act)->group_XXX)| (~0xff)):(int)(((act)->group_XXX)&0x7f))) < 0) | |||
925 | snprintf(tbuf, sizeof(tbuf), "%d", XkbSAGroup(act))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%d", ((((act)->group_XXX)& 0x80?(int)(((act)->group_XXX)|(~0xff)):(int)(((act)->group_XXX )&0x7f)))); | |||
926 | else | |||
927 | snprintf(tbuf, sizeof(tbuf), "+%d", XkbSAGroup(act))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "+%d", ((((act)->group_XXX)& 0x80?(int)(((act)->group_XXX)|(~0xff)):(int)(((act)->group_XXX )&0x7f)))); | |||
928 | TryCopyStr(buf, tbuf, sz); | |||
929 | if (act->type == XkbSA_LockGroup0x06) | |||
930 | return True1; | |||
931 | if (act->flags & XkbSA_ClearLocks(1L << 0)) | |||
932 | TryCopyStr(buf, ",clearLocks", sz); | |||
933 | if (act->flags & XkbSA_LatchToLock(1L << 1)) | |||
934 | TryCopyStr(buf, ",latchToLock", sz); | |||
935 | return True1; | |||
936 | } | |||
937 | ||||
938 | /*ARGSUSED*/ | |||
939 | static Boolint | |||
940 | CopyMovePtrArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
941 | char *buf, int *sz) | |||
942 | { | |||
943 | XkbPtrAction *act; | |||
944 | int x, y; | |||
945 | char tbuf[32]; | |||
946 | ||||
947 | act = &action->ptr; | |||
948 | x = XkbPtrActionX(act)(((short)((((act)->high_XXX)<<8)|((act)->low_XXX) ))); | |||
949 | y = XkbPtrActionY(act)(((short)((((act)->high_YYY)<<8)|((act)->low_YYY) ))); | |||
950 | if ((act->flags & XkbSA_MoveAbsoluteX(1L << 1)) || (x < 0)) | |||
951 | snprintf(tbuf, sizeof(tbuf), "x=%d", x)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "x=%d", x); | |||
952 | else | |||
953 | snprintf(tbuf, sizeof(tbuf), "x=+%d", x)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "x=+%d", x); | |||
954 | TryCopyStr(buf, tbuf, sz); | |||
955 | ||||
956 | if ((act->flags & XkbSA_MoveAbsoluteY(1L << 2)) || (y < 0)) | |||
957 | snprintf(tbuf, sizeof(tbuf), ",y=%d", y)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",y=%d", y); | |||
958 | else | |||
959 | snprintf(tbuf, sizeof(tbuf), ",y=+%d", y)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",y=+%d", y); | |||
960 | TryCopyStr(buf, tbuf, sz); | |||
961 | if (act->flags & XkbSA_NoAcceleration(1L << 0)) | |||
962 | TryCopyStr(buf, ",!accel", sz); | |||
963 | return True1; | |||
964 | } | |||
965 | ||||
966 | /*ARGSUSED*/ | |||
967 | static Boolint | |||
968 | CopyPtrBtnArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
969 | char *buf, int *sz) | |||
970 | { | |||
971 | XkbPtrBtnAction *act; | |||
972 | char tbuf[32]; | |||
973 | ||||
974 | act = &action->btn; | |||
975 | TryCopyStr(buf, "button=", sz); | |||
976 | if ((act->button > 0) && (act->button < 6)) { | |||
977 | snprintf(tbuf, sizeof(tbuf), "%d", act->button)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%d", act->button); | |||
978 | TryCopyStr(buf, tbuf, sz); | |||
979 | } | |||
980 | else | |||
981 | TryCopyStr(buf, "default", sz); | |||
982 | if (act->count > 0) { | |||
983 | snprintf(tbuf, sizeof(tbuf), ",count=%d", act->count)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",count=%d", act->count); | |||
984 | TryCopyStr(buf, tbuf, sz); | |||
985 | } | |||
986 | if (action->type == XkbSA_LockPtrBtn0x09) { | |||
987 | switch (act->flags & (XkbSA_LockNoUnlock(1L << 1) | XkbSA_LockNoLock(1L << 0))) { | |||
988 | case XkbSA_LockNoLock(1L << 0): | |||
989 | snprintf(tbuf, sizeof(tbuf), ",affect=unlock")__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",affect=unlock"); | |||
990 | break; | |||
991 | case XkbSA_LockNoUnlock(1L << 1): | |||
992 | snprintf(tbuf, sizeof(tbuf), ",affect=lock")__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",affect=lock"); | |||
993 | break; | |||
994 | case XkbSA_LockNoUnlock(1L << 1) | XkbSA_LockNoLock(1L << 0): | |||
995 | snprintf(tbuf, sizeof(tbuf), ",affect=neither")__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",affect=neither"); | |||
996 | break; | |||
997 | default: | |||
998 | snprintf(tbuf, sizeof(tbuf), ",affect=both")__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",affect=both"); | |||
999 | break; | |||
1000 | } | |||
1001 | TryCopyStr(buf, tbuf, sz); | |||
1002 | } | |||
1003 | return True1; | |||
1004 | } | |||
1005 | ||||
1006 | /*ARGSUSED*/ | |||
1007 | static Boolint | |||
1008 | CopySetPtrDfltArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
1009 | char *buf, int *sz) | |||
1010 | { | |||
1011 | XkbPtrDfltAction *act; | |||
1012 | char tbuf[32]; | |||
1013 | ||||
1014 | act = &action->dflt; | |||
1015 | if (act->affect == XkbSA_AffectDfltBtn1) { | |||
1016 | TryCopyStr(buf, "affect=button,button=", sz); | |||
1017 | if ((act->flags & XkbSA_DfltBtnAbsolute(1L << 2)) || | |||
1018 | (XkbSAPtrDfltValue(act)((((act)->valueXXX)&0x80?(int)(((act)->valueXXX)|(~ 0xff)):(int)(((act)->valueXXX)&0x7f))) < 0)) | |||
1019 | snprintf(tbuf, sizeof(tbuf), "%d", XkbSAPtrDfltValue(act))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%d", ((((act)->valueXXX)&0x80 ?(int)(((act)->valueXXX)|(~0xff)):(int)(((act)->valueXXX )&0x7f)))); | |||
1020 | else | |||
1021 | snprintf(tbuf, sizeof(tbuf), "+%d", XkbSAPtrDfltValue(act))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "+%d", ((((act)->valueXXX)& 0x80?(int)(((act)->valueXXX)|(~0xff)):(int)(((act)->valueXXX )&0x7f)))); | |||
1022 | TryCopyStr(buf, tbuf, sz); | |||
1023 | } | |||
1024 | return True1; | |||
1025 | } | |||
1026 | ||||
1027 | static Boolint | |||
1028 | CopyISOLockArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
1029 | char *buf, int *sz) | |||
1030 | { | |||
1031 | XkbISOAction *act; | |||
1032 | char tbuf[64]; | |||
1033 | ||||
1034 | act = &action->iso; | |||
1035 | if (act->flags & XkbSA_ISODfltIsGroup(1L << 7)) { | |||
1036 | TryCopyStr(tbuf, "group=", sz); | |||
1037 | if (act->flags & XkbSA_GroupAbsolute(1L << 2)) | |||
1038 | snprintf(tbuf, sizeof(tbuf), "%d", XkbSAGroup(act) + 1)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%d", ((((act)->group_XXX)& 0x80?(int)(((act)->group_XXX)|(~0xff)):(int)(((act)->group_XXX )&0x7f))) + 1); | |||
1039 | else if (XkbSAGroup(act)((((act)->group_XXX)&0x80?(int)(((act)->group_XXX)| (~0xff)):(int)(((act)->group_XXX)&0x7f))) < 0) | |||
1040 | snprintf(tbuf, sizeof(tbuf), "%d", XkbSAGroup(act))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%d", ((((act)->group_XXX)& 0x80?(int)(((act)->group_XXX)|(~0xff)):(int)(((act)->group_XXX )&0x7f)))); | |||
1041 | else | |||
1042 | snprintf(tbuf, sizeof(tbuf), "+%d", XkbSAGroup(act))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "+%d", ((((act)->group_XXX)& 0x80?(int)(((act)->group_XXX)|(~0xff)):(int)(((act)->group_XXX )&0x7f)))); | |||
1043 | TryCopyStr(buf, tbuf, sz); | |||
1044 | } | |||
1045 | else { | |||
1046 | unsigned tmp; | |||
1047 | ||||
1048 | tmp = XkbModActionVMods(act)((short)(((act)->vmods1<<8)|((act)->vmods2))); | |||
1049 | TryCopyStr(buf, "modifiers=", sz); | |||
1050 | if (act->flags & XkbSA_UseModMapMods(1L << 2)) | |||
1051 | TryCopyStr(buf, "modMapMods", sz); | |||
1052 | else if (act->real_mods || tmp) { | |||
1053 | if (act->real_mods) { | |||
1054 | TryCopyStr(buf, XkbModMaskText(act->real_mods, XkbXKBFile2), sz); | |||
1055 | if (tmp) | |||
1056 | TryCopyStr(buf, "+", sz); | |||
1057 | } | |||
1058 | if (tmp) | |||
1059 | TryCopyStr(buf, XkbVModMaskText(dpy, xkb, 0, tmp, XkbXKBFile2), | |||
1060 | sz); | |||
1061 | } | |||
1062 | else | |||
1063 | TryCopyStr(buf, "none", sz); | |||
1064 | } | |||
1065 | TryCopyStr(buf, ",affect=", sz); | |||
1066 | if ((act->affect & XkbSA_ISOAffectMask(0x78)) == 0) { | |||
1067 | TryCopyStr(buf, "all", sz); | |||
1068 | } | |||
1069 | else if ((act->affect & XkbSA_ISOAffectMask(0x78)) == XkbSA_ISOAffectMask(0x78)) { | |||
1070 | TryCopyStr(buf, "none", sz); | |||
1071 | } | |||
1072 | else { | |||
1073 | int nOut = 0; | |||
1074 | ||||
1075 | if ((act->affect & XkbSA_ISONoAffectMods(1L << 6)) == 0) { | |||
1076 | TryCopyStr(buf, "mods", sz); | |||
1077 | nOut++; | |||
1078 | } | |||
1079 | if ((act->affect & XkbSA_ISONoAffectGroup(1L << 5)) == 0) { | |||
1080 | snprintf(tbuf, sizeof(tbuf), "%sgroups", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sgroups", (nOut > 0 ? "+" : "" )); | |||
1081 | TryCopyStr(buf, tbuf, sz); | |||
1082 | nOut++; | |||
1083 | } | |||
1084 | if ((act->affect & XkbSA_ISONoAffectPtr(1L << 4)) == 0) { | |||
1085 | snprintf(tbuf, sizeof(tbuf), "%spointer", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%spointer", (nOut > 0 ? "+" : "" )); | |||
1086 | TryCopyStr(buf, tbuf, sz); | |||
1087 | nOut++; | |||
1088 | } | |||
1089 | if ((act->affect & XkbSA_ISONoAffectCtrls(1L << 3)) == 0) { | |||
1090 | snprintf(tbuf, sizeof(tbuf), "%scontrols", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%scontrols", (nOut > 0 ? "+" : "")); | |||
1091 | TryCopyStr(buf, tbuf, sz); | |||
1092 | nOut++; | |||
1093 | } | |||
1094 | } | |||
1095 | switch (act->flags & (XkbSA_LockNoUnlock(1L << 1) | XkbSA_LockNoLock(1L << 0))) { | |||
1096 | case XkbSA_LockNoLock(1L << 0): | |||
1097 | TryCopyStr(buf, "+unlock", sz); | |||
1098 | break; | |||
1099 | case XkbSA_LockNoUnlock(1L << 1): | |||
1100 | TryCopyStr(buf, "+lock", sz); | |||
1101 | break; | |||
1102 | case XkbSA_LockNoUnlock(1L << 1) | XkbSA_LockNoLock(1L << 0): | |||
1103 | TryCopyStr(buf, "+neither", sz); | |||
1104 | break; | |||
1105 | default: ; | |||
1106 | } | |||
1107 | return True1; | |||
1108 | } | |||
1109 | ||||
1110 | /*ARGSUSED*/ | |||
1111 | static Boolint | |||
1112 | CopySwitchScreenArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
1113 | char *buf, int *sz) | |||
1114 | { | |||
1115 | XkbSwitchScreenAction *act; | |||
1116 | char tbuf[32]; | |||
1117 | ||||
1118 | act = &action->screen; | |||
1119 | if ((act->flags & XkbSA_SwitchAbsolute(1L << 2)) || (XkbSAScreen(act)((((act)->screenXXX)&0x80?(int)(((act)->screenXXX)| (~0xff)):(int)(((act)->screenXXX)&0x7f))) < 0)) | |||
1120 | snprintf(tbuf, sizeof(tbuf), "screen=%d", XkbSAScreen(act))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "screen=%d", ((((act)->screenXXX )&0x80?(int)(((act)->screenXXX)|(~0xff)):(int)(((act)-> screenXXX)&0x7f)))); | |||
1121 | else | |||
1122 | snprintf(tbuf, sizeof(tbuf), "screen=+%d", XkbSAScreen(act))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "screen=+%d", ((((act)->screenXXX )&0x80?(int)(((act)->screenXXX)|(~0xff)):(int)(((act)-> screenXXX)&0x7f)))); | |||
1123 | TryCopyStr(buf, tbuf, sz); | |||
1124 | if (act->flags & XkbSA_SwitchApplication(1L << 0)) | |||
1125 | TryCopyStr(buf, ",!same", sz); | |||
1126 | else | |||
1127 | TryCopyStr(buf, ",same", sz); | |||
1128 | return True1; | |||
1129 | } | |||
1130 | ||||
1131 | /*ARGSUSED*/ | |||
1132 | static Boolint | |||
1133 | CopySetLockControlsArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
1134 | char *buf, int *sz) | |||
1135 | { | |||
1136 | XkbCtrlsAction *act; | |||
1137 | unsigned tmp; | |||
1138 | char tbuf[32]; | |||
1139 | ||||
1140 | act = &action->ctrls; | |||
1141 | tmp = XkbActionCtrls(act)((((unsigned int)(act)->ctrls3)<<24)| (((unsigned int )(act)->ctrls2)<<16)| (((unsigned int)(act)->ctrls1 )<<8)| ((unsigned int)((act)->ctrls0))); | |||
1142 | TryCopyStr(buf, "controls=", sz); | |||
1143 | if (tmp == 0) | |||
1144 | TryCopyStr(buf, "none", sz); | |||
1145 | else if ((tmp & XkbAllBooleanCtrlsMask(0x00001FFF)) == XkbAllBooleanCtrlsMask(0x00001FFF)) | |||
1146 | TryCopyStr(buf, "all", sz); | |||
1147 | else { | |||
1148 | int nOut = 0; | |||
1149 | ||||
1150 | if (tmp & XkbRepeatKeysMask(1L << 0)) { | |||
1151 | snprintf(tbuf, sizeof(tbuf), "%sRepeatKeys", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sRepeatKeys", (nOut > 0 ? "+" : "")); | |||
1152 | TryCopyStr(buf, tbuf, sz); | |||
1153 | nOut++; | |||
1154 | } | |||
1155 | if (tmp & XkbSlowKeysMask(1L << 1)) { | |||
1156 | snprintf(tbuf, sizeof(tbuf), "%sSlowKeys", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sSlowKeys", (nOut > 0 ? "+" : "")); | |||
1157 | TryCopyStr(buf, tbuf, sz); | |||
1158 | nOut++; | |||
1159 | } | |||
1160 | if (tmp & XkbBounceKeysMask(1L << 2)) { | |||
1161 | snprintf(tbuf, sizeof(tbuf), "%sBounceKeys", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sBounceKeys", (nOut > 0 ? "+" : "")); | |||
1162 | TryCopyStr(buf, tbuf, sz); | |||
1163 | nOut++; | |||
1164 | } | |||
1165 | if (tmp & XkbStickyKeysMask(1L << 3)) { | |||
1166 | snprintf(tbuf, sizeof(tbuf), "%sStickyKeys", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sStickyKeys", (nOut > 0 ? "+" : "")); | |||
1167 | TryCopyStr(buf, tbuf, sz); | |||
1168 | nOut++; | |||
1169 | } | |||
1170 | if (tmp & XkbMouseKeysMask(1L << 4)) { | |||
1171 | snprintf(tbuf, sizeof(tbuf), "%sMouseKeys", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sMouseKeys", (nOut > 0 ? "+" : "")); | |||
1172 | TryCopyStr(buf, tbuf, sz); | |||
1173 | nOut++; | |||
1174 | } | |||
1175 | if (tmp & XkbMouseKeysAccelMask(1L << 5)) { | |||
1176 | snprintf(tbuf, sizeof(tbuf), "%sMouseKeysAccel", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sMouseKeysAccel", (nOut > 0 ? "+" : "")); | |||
1177 | TryCopyStr(buf, tbuf, sz); | |||
1178 | nOut++; | |||
1179 | } | |||
1180 | if (tmp & XkbAccessXKeysMask(1L << 6)) { | |||
1181 | snprintf(tbuf, sizeof(tbuf), "%sAccessXKeys", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sAccessXKeys", (nOut > 0 ? "+" : "")); | |||
1182 | TryCopyStr(buf, tbuf, sz); | |||
1183 | nOut++; | |||
1184 | } | |||
1185 | if (tmp & XkbAccessXTimeoutMask(1L << 7)) { | |||
1186 | snprintf(tbuf, sizeof(tbuf), "%sAccessXTimeout", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sAccessXTimeout", (nOut > 0 ? "+" : "")); | |||
1187 | TryCopyStr(buf, tbuf, sz); | |||
1188 | nOut++; | |||
1189 | } | |||
1190 | if (tmp & XkbAccessXFeedbackMask(1L << 8)) { | |||
1191 | snprintf(tbuf, sizeof(tbuf), "%sAccessXFeedback", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sAccessXFeedback", (nOut > 0 ? "+" : "")); | |||
1192 | TryCopyStr(buf, tbuf, sz); | |||
1193 | nOut++; | |||
1194 | } | |||
1195 | if (tmp & XkbAudibleBellMask(1L << 9)) { | |||
1196 | snprintf(tbuf, sizeof(tbuf), "%sAudibleBell", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sAudibleBell", (nOut > 0 ? "+" : "")); | |||
1197 | TryCopyStr(buf, tbuf, sz); | |||
1198 | nOut++; | |||
1199 | } | |||
1200 | if (tmp & XkbOverlay1Mask(1L << 10)) { | |||
1201 | snprintf(tbuf, sizeof(tbuf), "%sOverlay1", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sOverlay1", (nOut > 0 ? "+" : "")); | |||
1202 | TryCopyStr(buf, tbuf, sz); | |||
1203 | nOut++; | |||
1204 | } | |||
1205 | if (tmp & XkbOverlay2Mask(1L << 11)) { | |||
1206 | snprintf(tbuf, sizeof(tbuf), "%sOverlay2", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sOverlay2", (nOut > 0 ? "+" : "")); | |||
1207 | TryCopyStr(buf, tbuf, sz); | |||
1208 | nOut++; | |||
1209 | } | |||
1210 | if (tmp & XkbIgnoreGroupLockMask(1L << 12)) { | |||
1211 | snprintf(tbuf, sizeof(tbuf), "%sIgnoreGroupLock", (nOut > 0 ? "+" : ""))__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%sIgnoreGroupLock", (nOut > 0 ? "+" : "")); | |||
1212 | TryCopyStr(buf, tbuf, sz); | |||
1213 | nOut++; | |||
1214 | } | |||
1215 | } | |||
1216 | if (action->type == XkbSA_LockControls0x0f) { | |||
1217 | switch (act->flags & (XkbSA_LockNoUnlock(1L << 1) | XkbSA_LockNoLock(1L << 0))) { | |||
1218 | case XkbSA_LockNoLock(1L << 0): | |||
1219 | TryCopyStr(buf, ",affect=unlock", sz); | |||
1220 | break; | |||
1221 | case XkbSA_LockNoUnlock(1L << 1): | |||
1222 | TryCopyStr(buf, ",affect=lock", sz); | |||
1223 | break; | |||
1224 | case XkbSA_LockNoUnlock(1L << 1) | XkbSA_LockNoLock(1L << 0): | |||
1225 | TryCopyStr(buf, ",affect=neither", sz); | |||
1226 | break; | |||
1227 | default: ; | |||
1228 | } | |||
1229 | } | |||
1230 | return True1; | |||
1231 | } | |||
1232 | ||||
1233 | /*ARGSUSED*/ | |||
1234 | static Boolint | |||
1235 | CopyActionMessageArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
1236 | char *buf, int *sz) | |||
1237 | { | |||
1238 | XkbMessageAction *act; | |||
1239 | unsigned all; | |||
1240 | char tbuf[32]; | |||
1241 | ||||
1242 | act = &action->msg; | |||
1243 | all = XkbSA_MessageOnPress(1L << 0) | XkbSA_MessageOnRelease(1L << 1); | |||
1244 | TryCopyStr(buf, "report=", sz); | |||
1245 | if ((act->flags & all) == 0) | |||
1246 | TryCopyStr(buf, "none", sz); | |||
1247 | else if ((act->flags & all) == all) | |||
1248 | TryCopyStr(buf, "all", sz); | |||
1249 | else if (act->flags & XkbSA_MessageOnPress(1L << 0)) | |||
1250 | TryCopyStr(buf, "KeyPress", sz); | |||
1251 | else | |||
1252 | TryCopyStr(buf, "KeyRelease", sz); | |||
1253 | snprintf(tbuf, sizeof(tbuf), ",data[0]=0x%02x", act->message[0])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[0]=0x%02x", act->message [0]); | |||
1254 | TryCopyStr(buf, tbuf, sz); | |||
1255 | snprintf(tbuf, sizeof(tbuf), ",data[1]=0x%02x", act->message[1])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[1]=0x%02x", act->message [1]); | |||
1256 | TryCopyStr(buf, tbuf, sz); | |||
1257 | snprintf(tbuf, sizeof(tbuf), ",data[2]=0x%02x", act->message[2])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[2]=0x%02x", act->message [2]); | |||
1258 | TryCopyStr(buf, tbuf, sz); | |||
1259 | snprintf(tbuf, sizeof(tbuf), ",data[3]=0x%02x", act->message[3])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[3]=0x%02x", act->message [3]); | |||
1260 | TryCopyStr(buf, tbuf, sz); | |||
1261 | snprintf(tbuf, sizeof(tbuf), ",data[4]=0x%02x", act->message[4])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[4]=0x%02x", act->message [4]); | |||
1262 | TryCopyStr(buf, tbuf, sz); | |||
1263 | snprintf(tbuf, sizeof(tbuf), ",data[5]=0x%02x", act->message[5])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[5]=0x%02x", act->message [5]); | |||
1264 | TryCopyStr(buf, tbuf, sz); | |||
1265 | if (act->flags & XkbSA_MessageGenKeyEvent(1L << 2)) | |||
1266 | TryCopyStr(buf, ",genKeyEvent", sz); | |||
1267 | return True1; | |||
1268 | } | |||
1269 | ||||
1270 | static Boolint | |||
1271 | CopyRedirectKeyArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
1272 | char *buf, int *sz) | |||
1273 | { | |||
1274 | XkbRedirectKeyAction *act; | |||
1275 | char tbuf[32], *tmp; | |||
1276 | unsigned kc; | |||
1277 | unsigned vmods, vmods_mask; | |||
1278 | ||||
1279 | act = &action->redirect; | |||
1280 | kc = act->new_key; | |||
1281 | vmods = XkbSARedirectVMods(act)((((unsigned int)(act)->vmods1)<<8)| ((unsigned int) (act)->vmods0)); | |||
1282 | vmods_mask = XkbSARedirectVModsMask(act)((((unsigned int)(act)->vmods_mask1)<<8)| ((unsigned int)(act)->vmods_mask0)); | |||
1283 | if (xkb && xkb->names && xkb->names->keys && (kc <= xkb->max_key_code) && | |||
1284 | (xkb->names->keys[kc].name[0] != '\0')) { | |||
1285 | char *kn; | |||
1286 | ||||
1287 | kn = XkbKeyNameText(xkb->names->keys[kc].name, XkbXKBFile2); | |||
1288 | snprintf(tbuf, sizeof(tbuf), "key=%s", kn)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "key=%s", kn); | |||
1289 | } | |||
1290 | else | |||
1291 | snprintf(tbuf, sizeof(tbuf), "key=%d", kc)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "key=%d", kc); | |||
1292 | TryCopyStr(buf, tbuf, sz); | |||
1293 | if ((act->mods_mask == 0) && (vmods_mask == 0)) | |||
1294 | return True1; | |||
1295 | if ((act->mods_mask == XkbAllModifiersMask0xff) && | |||
1296 | (vmods_mask == XkbAllVirtualModsMask0xffff)) { | |||
1297 | tmp = XkbVModMaskText(dpy, xkb, act->mods, vmods, XkbXKBFile2); | |||
1298 | TryCopyStr(buf, ",mods=", sz); | |||
1299 | TryCopyStr(buf, tmp, sz); | |||
1300 | } | |||
1301 | else { | |||
1302 | if ((act->mods_mask & act->mods) || (vmods_mask & vmods)) { | |||
1303 | tmp = XkbVModMaskText(dpy, xkb, act->mods_mask & act->mods, | |||
1304 | vmods_mask & vmods, XkbXKBFile2); | |||
1305 | TryCopyStr(buf, ",mods= ", sz); | |||
1306 | TryCopyStr(buf, tmp, sz); | |||
1307 | } | |||
1308 | if ((act->mods_mask & (~act->mods)) || (vmods_mask & (~vmods))) { | |||
1309 | tmp = XkbVModMaskText(dpy, xkb, act->mods_mask & (~act->mods), | |||
1310 | vmods_mask & (~vmods), XkbXKBFile2); | |||
1311 | TryCopyStr(buf, ",clearMods= ", sz); | |||
1312 | TryCopyStr(buf, tmp, sz); | |||
1313 | } | |||
1314 | } | |||
1315 | return True1; | |||
1316 | } | |||
1317 | ||||
1318 | /*ARGSUSED*/ | |||
1319 | static Boolint | |||
1320 | CopyDeviceBtnArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
1321 | char *buf, int *sz) | |||
1322 | { | |||
1323 | XkbDeviceBtnAction *act; | |||
1324 | char tbuf[32]; | |||
1325 | ||||
1326 | act = &action->devbtn; | |||
1327 | snprintf(tbuf, sizeof(tbuf), "device= %d", act->device)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "device= %d", act->device); | |||
1328 | TryCopyStr(buf, tbuf, sz); | |||
1329 | TryCopyStr(buf, ",button=", sz); | |||
1330 | snprintf(tbuf, sizeof(tbuf), "%d", act->button)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%d", act->button); | |||
1331 | TryCopyStr(buf, tbuf, sz); | |||
1332 | if (act->count > 0) { | |||
1333 | snprintf(tbuf, sizeof(tbuf), ",count=%d", act->count)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",count=%d", act->count); | |||
1334 | TryCopyStr(buf, tbuf, sz); | |||
1335 | } | |||
1336 | if (action->type == XkbSA_LockDeviceBtn0x13) { | |||
1337 | switch (act->flags & (XkbSA_LockNoUnlock(1L << 1) | XkbSA_LockNoLock(1L << 0))) { | |||
1338 | case XkbSA_LockNoLock(1L << 0): | |||
1339 | snprintf(tbuf, sizeof(tbuf), ",affect=unlock")__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",affect=unlock"); | |||
1340 | break; | |||
1341 | case XkbSA_LockNoUnlock(1L << 1): | |||
1342 | snprintf(tbuf, sizeof(tbuf), ",affect=lock")__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",affect=lock"); | |||
1343 | break; | |||
1344 | case XkbSA_LockNoUnlock(1L << 1) | XkbSA_LockNoLock(1L << 0): | |||
1345 | snprintf(tbuf, sizeof(tbuf), ",affect=neither")__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",affect=neither"); | |||
1346 | break; | |||
1347 | default: | |||
1348 | snprintf(tbuf, sizeof(tbuf), ",affect=both")__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",affect=both"); | |||
1349 | break; | |||
1350 | } | |||
1351 | TryCopyStr(buf, tbuf, sz); | |||
1352 | } | |||
1353 | return True1; | |||
1354 | } | |||
1355 | ||||
1356 | /*ARGSUSED*/ | |||
1357 | static Boolint | |||
1358 | CopyOtherArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action, | |||
1359 | char *buf, int *sz) | |||
1360 | { | |||
1361 | XkbAnyAction *act; | |||
1362 | char tbuf[32]; | |||
1363 | ||||
1364 | act = &action->any; | |||
1365 | snprintf(tbuf, sizeof(tbuf), "type=0x%02x", act->type)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "type=0x%02x", act->type); | |||
1366 | TryCopyStr(buf, tbuf, sz); | |||
1367 | snprintf(tbuf, sizeof(tbuf), ",data[0]=0x%02x", act->data[0])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[0]=0x%02x", act->data[0] ); | |||
1368 | TryCopyStr(buf, tbuf, sz); | |||
1369 | snprintf(tbuf, sizeof(tbuf), ",data[1]=0x%02x", act->data[1])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[1]=0x%02x", act->data[1] ); | |||
1370 | TryCopyStr(buf, tbuf, sz); | |||
1371 | snprintf(tbuf, sizeof(tbuf), ",data[2]=0x%02x", act->data[2])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[2]=0x%02x", act->data[2] ); | |||
1372 | TryCopyStr(buf, tbuf, sz); | |||
1373 | snprintf(tbuf, sizeof(tbuf), ",data[3]=0x%02x", act->data[3])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[3]=0x%02x", act->data[3] ); | |||
1374 | TryCopyStr(buf, tbuf, sz); | |||
1375 | snprintf(tbuf, sizeof(tbuf), ",data[4]=0x%02x", act->data[4])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[4]=0x%02x", act->data[4] ); | |||
1376 | TryCopyStr(buf, tbuf, sz); | |||
1377 | snprintf(tbuf, sizeof(tbuf), ",data[5]=0x%02x", act->data[5])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[5]=0x%02x", act->data[5] ); | |||
1378 | TryCopyStr(buf, tbuf, sz); | |||
1379 | snprintf(tbuf, sizeof(tbuf), ",data[6]=0x%02x", act->data[6])__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), ",data[6]=0x%02x", act->data[6] ); | |||
1380 | TryCopyStr(buf, tbuf, sz); | |||
1381 | return True1; | |||
1382 | } | |||
1383 | ||||
1384 | typedef Boolint (*actionCopy) (Display * /* dpy */ , | |||
1385 | XkbDescPtr /* xkb */ , | |||
1386 | XkbAction * /* action */ , | |||
1387 | char * /* buf */ , | |||
1388 | int * /* sz */ | |||
1389 | ); | |||
1390 | ||||
1391 | static actionCopy copyActionArgs[XkbSA_NumActions(0x14 +1)] = { | |||
1392 | CopyNoActionArgs /* NoAction */ , | |||
1393 | CopyModActionArgs /* SetMods */ , | |||
1394 | CopyModActionArgs /* LatchMods */ , | |||
1395 | CopyModActionArgs /* LockMods */ , | |||
1396 | CopyGroupActionArgs /* SetGroup */ , | |||
1397 | CopyGroupActionArgs /* LatchGroup */ , | |||
1398 | CopyGroupActionArgs /* LockGroup */ , | |||
1399 | CopyMovePtrArgs /* MovePtr */ , | |||
1400 | CopyPtrBtnArgs /* PtrBtn */ , | |||
1401 | CopyPtrBtnArgs /* LockPtrBtn */ , | |||
1402 | CopySetPtrDfltArgs /* SetPtrDflt */ , | |||
1403 | CopyISOLockArgs /* ISOLock */ , | |||
1404 | CopyNoActionArgs /* Terminate */ , | |||
1405 | CopySwitchScreenArgs /* SwitchScreen */ , | |||
1406 | CopySetLockControlsArgs /* SetControls */ , | |||
1407 | CopySetLockControlsArgs /* LockControls */ , | |||
1408 | CopyActionMessageArgs /* ActionMessage */ , | |||
1409 | CopyRedirectKeyArgs /* RedirectKey */ , | |||
1410 | CopyDeviceBtnArgs /* DeviceBtn */ , | |||
1411 | CopyDeviceBtnArgs /* LockDeviceBtn */ | |||
1412 | }; | |||
1413 | ||||
1414 | #define ACTION_SZ256 256 | |||
1415 | ||||
1416 | char * | |||
1417 | XkbActionText(Display *dpy, XkbDescPtr xkb, XkbAction *action, unsigned format) | |||
1418 | { | |||
1419 | char buf[ACTION_SZ256], *tmp; | |||
1420 | int sz; | |||
1421 | ||||
1422 | if (format == XkbCFile1) { | |||
1423 | snprintf(buf, sizeof(buf),__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }" , XkbActionTypeText(action->type, 1), action->any.data[ 0], action->any.data[1], action->any.data[2], action-> any.data[3], action->any.data[4], action->any.data[5], action ->any.data[6]) | |||
1424 | "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }",__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }" , XkbActionTypeText(action->type, 1), action->any.data[ 0], action->any.data[1], action->any.data[2], action-> any.data[3], action->any.data[4], action->any.data[5], action ->any.data[6]) | |||
1425 | XkbActionTypeText(action->type, XkbCFile),__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }" , XkbActionTypeText(action->type, 1), action->any.data[ 0], action->any.data[1], action->any.data[2], action-> any.data[3], action->any.data[4], action->any.data[5], action ->any.data[6]) | |||
1426 | action->any.data[0], action->any.data[1], action->any.data[2],__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }" , XkbActionTypeText(action->type, 1), action->any.data[ 0], action->any.data[1], action->any.data[2], action-> any.data[3], action->any.data[4], action->any.data[5], action ->any.data[6]) | |||
1427 | action->any.data[3], action->any.data[4], action->any.data[5],__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }" , XkbActionTypeText(action->type, 1), action->any.data[ 0], action->any.data[1], action->any.data[2], action-> any.data[3], action->any.data[4], action->any.data[5], action ->any.data[6]) | |||
1428 | action->any.data[6])__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }" , XkbActionTypeText(action->type, 1), action->any.data[ 0], action->any.data[1], action->any.data[2], action-> any.data[3], action->any.data[4], action->any.data[5], action ->any.data[6]); | |||
1429 | } | |||
1430 | else { | |||
1431 | snprintf(buf, sizeof(buf),__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%s(", XkbActionTypeText(action-> type, 2)) | |||
1432 | "%s(", XkbActionTypeText(action->type, XkbXKBFile))__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "%s(", XkbActionTypeText(action-> type, 2)); | |||
1433 | sz = ACTION_SZ256 - strlen(buf) + 2; /* room for close paren and NULL */ | |||
1434 | if (action->type < (unsigned) XkbSA_NumActions(0x14 +1)) | |||
1435 | (*copyActionArgs[action->type]) (dpy, xkb, action, buf, &sz); | |||
1436 | else | |||
1437 | CopyOtherArgs(dpy, xkb, action, buf, &sz); | |||
1438 | TryCopyStr(buf, ")", &sz); | |||
1439 | } | |||
1440 | tmp = tbGetBuffer(strlen(buf) + 1); | |||
1441 | if (tmp != NULL((void*)0)) | |||
1442 | strcpy(tmp, buf)__builtin___strcpy_chk (tmp, buf, __builtin_object_size (tmp, 2 > 1 ? 1 : 0)); | |||
1443 | return tmp; | |||
1444 | } | |||
1445 | ||||
1446 | char * | |||
1447 | XkbBehaviorText(XkbDescPtr xkb, XkbBehavior * behavior, unsigned format) | |||
1448 | { | |||
1449 | char buf[256], *tmp; | |||
1450 | ||||
1451 | if (format == XkbCFile1) { | |||
1452 | if (behavior->type == XkbKB_Default0x00) | |||
1453 | snprintf(buf, sizeof(buf), "{ 0, 0 }")__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "{ 0, 0 }"); | |||
1454 | else | |||
1455 | snprintf(buf, sizeof(buf), "{ %3d, 0x%02x }", behavior->type, behavior->data)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "{ %3d, 0x%02x }", behavior->type , behavior->data); | |||
1456 | } | |||
1457 | else { | |||
1458 | unsigned type, permanent; | |||
1459 | ||||
1460 | type = behavior->type & XkbKB_OpMask0x7f; | |||
1461 | permanent = ((behavior->type & XkbKB_Permanent0x80) != 0); | |||
1462 | ||||
1463 | if (type == XkbKB_Lock0x01) { | |||
1464 | snprintf(buf, sizeof(buf), "lock= %s", (permanent ? "Permanent" : "True"))__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "lock= %s", (permanent ? "Permanent" : "True")); | |||
1465 | } | |||
1466 | else if (type == XkbKB_RadioGroup0x02) { | |||
1467 | int g; | |||
1468 | char *tmp; | |||
1469 | size_t tmpsize; | |||
1470 | ||||
1471 | g = ((behavior->data) & (~XkbKB_RGAllowNone0x80)) + 1; | |||
1472 | if (XkbKB_RGAllowNone0x80 & behavior->data) { | |||
1473 | snprintf(buf, sizeof(buf), "allowNone,")__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "allowNone,"); | |||
1474 | tmp = &buf[strlen(buf)]; | |||
1475 | } | |||
1476 | else | |||
1477 | tmp = buf; | |||
1478 | tmpsize = sizeof(buf) - (tmp - buf); | |||
1479 | if (permanent) | |||
1480 | snprintf(tmp, tmpsize, "permanentRadioGroup= %d", g)__builtin___snprintf_chk (tmp, tmpsize, 0, __builtin_object_size (tmp, 2 > 1 ? 1 : 0), "permanentRadioGroup= %d", g); | |||
1481 | else | |||
1482 | snprintf(tmp, tmpsize, "radioGroup= %d", g)__builtin___snprintf_chk (tmp, tmpsize, 0, __builtin_object_size (tmp, 2 > 1 ? 1 : 0), "radioGroup= %d", g); | |||
1483 | } | |||
1484 | else if ((type == XkbKB_Overlay10x03) || (type == XkbKB_Overlay20x04)) { | |||
1485 | int ndx, kc; | |||
1486 | char *kn; | |||
1487 | ||||
1488 | ndx = ((type == XkbKB_Overlay10x03) ? 1 : 2); | |||
1489 | kc = behavior->data; | |||
1490 | if ((xkb) && (xkb->names) && (xkb->names->keys)) | |||
1491 | kn = XkbKeyNameText(xkb->names->keys[kc].name, XkbXKBFile2); | |||
1492 | else { | |||
1493 | static char tbuf[8]; | |||
1494 | ||||
1495 | snprintf(tbuf, sizeof(tbuf), "%d", kc)__builtin___snprintf_chk (tbuf, sizeof(tbuf), 0, __builtin_object_size (tbuf, 2 > 1 ? 1 : 0), "%d", kc); | |||
1496 | kn = tbuf; | |||
1497 | } | |||
1498 | if (permanent) | |||
1499 | snprintf(buf, sizeof(buf), "permanentOverlay%d= %s", ndx, kn)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "permanentOverlay%d= %s", ndx, kn); | |||
1500 | else | |||
1501 | snprintf(buf, sizeof(buf), "overlay%d= %s", ndx, kn)__builtin___snprintf_chk (buf, sizeof(buf), 0, __builtin_object_size (buf, 2 > 1 ? 1 : 0), "overlay%d= %s", ndx, kn); | |||
1502 | } | |||
1503 | } | |||
1504 | tmp = tbGetBuffer(strlen(buf) + 1); | |||
1505 | if (tmp != NULL((void*)0)) | |||
1506 | strcpy(tmp, buf)__builtin___strcpy_chk (tmp, buf, __builtin_object_size (tmp, 2 > 1 ? 1 : 0)); | |||
1507 | return tmp; | |||
1508 | } | |||
1509 | ||||
1510 | /***====================================================================***/ | |||
1511 | ||||
1512 | char * | |||
1513 | XkbIndentText(unsigned size) | |||
1514 | { | |||
1515 | static char buf[32]; | |||
1516 | register int i; | |||
1517 | ||||
1518 | if (size > 31) | |||
1519 | size = 31; | |||
1520 | ||||
1521 | for (i = 0; i < size; i++) { | |||
1522 | buf[i] = ' '; | |||
1523 | } | |||
1524 | buf[size] = '\0'; | |||
1525 | return buf; | |||
1526 | } | |||
1527 | ||||
1528 | ||||
1529 | /***====================================================================***/ | |||
1530 | ||||
1531 | #define PIXEL_MAX65535 65535 | |||
1532 | ||||
1533 | Boolint | |||
1534 | XkbLookupCanonicalRGBColor(char *def, XColor *color) | |||
1535 | { | |||
1536 | int tmp; | |||
1537 | ||||
1538 | if (_XkbStrCaseEqual(def, "black")(strcasecmp(def,"black")==0)) { | |||
1539 | color->red = color->green = color->blue = 0; | |||
1540 | return True1; | |||
1541 | } | |||
1542 | else if (_XkbStrCaseEqual(def, "white")(strcasecmp(def,"white")==0)) { | |||
1543 | color->red = color->green = color->blue = PIXEL_MAX65535; | |||
1544 | return True1; | |||
1545 | } | |||
1546 | else if ((sscanf(def, "grey%d", &tmp) == 1) || | |||
1547 | (sscanf(def, "gray%d", &tmp) == 1) || | |||
1548 | (sscanf(def, "Grey%d", &tmp) == 1) || | |||
1549 | (sscanf(def, "Gray%d", &tmp) == 1)) { | |||
1550 | if ((tmp > 0) && (tmp <= 100)) { | |||
1551 | tmp = (PIXEL_MAX65535 * tmp) / 100; | |||
1552 | color->red = color->green = color->blue = tmp; | |||
1553 | return True1; | |||
1554 | } | |||
1555 | } | |||
1556 | else if ((tmp = (_XkbStrCaseEqual(def, "red")(strcasecmp(def,"red")==0) * 100)) || | |||
1557 | (sscanf(def, "red%d", &tmp) == 1)) { | |||
1558 | if ((tmp > 0) && (tmp <= 100)) { | |||
1559 | tmp = (PIXEL_MAX65535 * tmp) / 100; | |||
1560 | color->red = tmp; | |||
1561 | color->green = color->blue = 0; | |||
1562 | return True1; | |||
1563 | } | |||
1564 | } | |||
1565 | else if ((tmp = (_XkbStrCaseEqual(def, "green")(strcasecmp(def,"green")==0) * 100)) || | |||
1566 | (sscanf(def, "green%d", &tmp) == 1)) { | |||
1567 | if ((tmp > 0) && (tmp <= 100)) { | |||
1568 | tmp = (PIXEL_MAX65535 * tmp) / 100; | |||
1569 | color->green = tmp; | |||
1570 | color->red = color->blue = 0; | |||
1571 | return True1; | |||
1572 | } | |||
1573 | } | |||
1574 | else if ((tmp = (_XkbStrCaseEqual(def, "blue")(strcasecmp(def,"blue")==0) * 100)) || | |||
1575 | (sscanf(def, "blue%d", &tmp) == 1)) { | |||
1576 | if ((tmp > 0) && (tmp <= 100)) { | |||
1577 | tmp = (PIXEL_MAX65535 * tmp) / 100; | |||
1578 | color->blue = tmp; | |||
1579 | color->red = color->green = 0; | |||
1580 | return True1; | |||
1581 | } | |||
1582 | } | |||
1583 | else if ((tmp = (_XkbStrCaseEqual(def, "magenta")(strcasecmp(def,"magenta")==0) * 100)) || | |||
1584 | (sscanf(def, "magenta%d", &tmp) == 1)) { | |||
1585 | if ((tmp > 0) && (tmp <= 100)) { | |||
1586 | tmp = (PIXEL_MAX65535 * tmp) / 100; | |||
1587 | color->green = 0; | |||
1588 | color->red = color->blue = tmp; | |||
1589 | return True1; | |||
1590 | } | |||
1591 | } | |||
1592 | else if ((tmp = (_XkbStrCaseEqual(def, "cyan")(strcasecmp(def,"cyan")==0) * 100)) || | |||
1593 | (sscanf(def, "cyan%d", &tmp) == 1)) { | |||
1594 | if ((tmp > 0) && (tmp <= 100)) { | |||
1595 | tmp = (PIXEL_MAX65535 * tmp) / 100; | |||
1596 | color->red = 0; | |||
1597 | color->green = color->blue = tmp; | |||
1598 | return True1; | |||
1599 | } | |||
1600 | } | |||
1601 | else if ((tmp = (_XkbStrCaseEqual(def, "yellow")(strcasecmp(def,"yellow")==0) * 100)) || | |||
1602 | (sscanf(def, "yellow%d", &tmp) == 1)) { | |||
1603 | if ((tmp > 0) && (tmp <= 100)) { | |||
1604 | tmp = (PIXEL_MAX65535 * tmp) / 100; | |||
1605 | color->blue = 0; | |||
1606 | color->red = color->green = tmp; | |||
1607 | return True1; | |||
1608 | } | |||
1609 | } | |||
1610 | return False0; | |||
1611 | } | |||
1612 |