Bug Summary

File:xkbconfig.c
Location:line 125, column 4
Description:Value stored to 'stop' is never read

Annotated Source Code

1/************************************************************
2 Copyright (c) 1995 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/Xfuncs.h>
38
39#include <X11/Xfuncs.h>
40
41#ifndef XKB_IN_SERVER
42
43#include <X11/Xos.h>
44#include <X11/Xlib.h>
45#include <X11/keysym.h>
46#include <X11/XKBlib.h>
47#include "XKBfileInt.h"
48
49#else
50
51#include <X11/X.h>
52#include <X11/keysym.h>
53#include <X11/Xproto.h>
54#include "misc.h"
55#include "inputstr.h"
56#include "dix.h"
57#define XKBSRV_NEED_FILE_FUNCS
58#include <X11/extensions/XKBsrv.h>
59#endif
60
61#include <X11/extensions/XKBconfig.h>
62
63/***====================================================================***/
64
65#define XKBCF_MAX_STR_LEN100 100
66static char _XkbCF_rtrn[XKBCF_MAX_STR_LEN100+1];
67
68static int
69ScanIdent(FILE *file,int ch,XkbCFScanResultPtr val_rtrn)
70{
71register int i;
72char * str;
73
74 val_rtrn->str= str= _XkbCF_rtrn;
75 for (i=0;(isalpha(ch)((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int)
_ISalpha)
||isdigit(ch)((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int)
_ISdigit)
||(ch=='_'));ch=getc(file)_IO_getc (file)) {
76 if (i<XKBCF_MAX_STR_LEN100)
77 str[i++]= ch;
78 }
79 if ((ch!=EOF(-1))&&(ch!=' ')&&(ch!='\t'))
80 ungetc(ch,file);
81 str[i]= '\0';
82 return XkbCF_Ident11;
83}
84
85static int
86ScanString(FILE *file,int quote,XkbCFScanResultPtr val_rtrn)
87{
88int ch,nInBuf;
89
90 nInBuf = 0;
91 while ( ((ch=getc(file)_IO_getc (file))!=EOF(-1)) && (ch!='\n') && (ch!=quote) ) {
92 if ( ch == '\\' ) {
93 if ((ch = getc(file)_IO_getc (file))!=EOF(-1)) {
94 if ( ch=='n' ) ch = '\n';
95 else if ( ch == 't' ) ch = '\t';
96 else if ( ch == 'v' ) ch = '\v';
97 else if ( ch == 'b' ) ch = '\b';
98 else if ( ch == 'r' ) ch = '\r';
99 else if ( ch == 'f' ) ch = '\f';
100 else if ( ch == 'e' ) ch = '\033';
101 else if ( ch == '0' ) {
102 int tmp,stop;
103 ch = stop = 0;
104 if (((tmp=getc(file)_IO_getc (file))!=EOF(-1)) && (isdigit(tmp)((*__ctype_b_loc ())[(int) ((tmp))] & (unsigned short int
) _ISdigit)
) &&
105 (tmp!='8') && (tmp!='9')) {
106 ch= (ch*8)+(tmp-'0');
107 }
108 else {
109 stop= 1;
110 ungetc(tmp,file);
111 }
112 if ((!stop) && ((tmp=getc(file)_IO_getc (file))!=EOF(-1)) && (isdigit(tmp)((*__ctype_b_loc ())[(int) ((tmp))] & (unsigned short int
) _ISdigit)
) &&
113 (tmp!='8') && (tmp!='9')) {
114 ch= (ch*8)+(tmp-'0');
115 }
116 else {
117 stop= 1;
118 ungetc(tmp,file);
119 }
120 if ((!stop) && ((tmp=getc(file)_IO_getc (file))!=EOF(-1)) && (isdigit(tmp)((*__ctype_b_loc ())[(int) ((tmp))] & (unsigned short int
) _ISdigit)
) &&
121 (tmp!='8') && (tmp!='9')) {
122 ch= (ch*8)+(tmp-'0');
123 }
124 else {
125 stop= 1;
Value stored to 'stop' is never read
126 ungetc(tmp,file);
127 }
128 }
129 }
130 else return XkbCF_EOF-1;
131 }
132
133 if ( nInBuf < XKBCF_MAX_STR_LEN100-1 )
134 _XkbCF_rtrn[nInBuf++] = ch;
135 }
136 if ( ch == quote ) {
137 _XkbCF_rtrn[nInBuf++] = '\0';
138 val_rtrn->str= _XkbCF_rtrn;
139 return XkbCF_String10;
140 }
141 return XkbCF_UnterminatedString100;
142}
143
144static int
145ScanInteger(FILE *file,int ch,XkbCFScanResultPtr val_rtrn)
146{
147int i;
148
149 if (isdigit(ch)((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int)
_ISdigit)
)
150 ungetc(ch,file);
151 if (fscanf(file,"%i",&i)==1) {
152 val_rtrn->ival= i;
153 return XkbCF_Integer12;
154 }
155 return XkbCF_Unknown0;
156}
157
158int
159XkbCFScan(FILE *file,XkbCFScanResultPtr val_rtrn,XkbConfigRtrnPtr rtrn)
160{
161int ch;
162
163 do {
164 ch= getc(file)_IO_getc (file);
165 } while ((ch=='\t')||(ch==' '));
166 if (isalpha(ch)((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int)
_ISalpha)
)
167 return ScanIdent(file,ch,val_rtrn);
168 else if (isdigit(ch)((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int)
_ISdigit)
)
169 return ScanInteger(file,ch,val_rtrn);
170 else if (ch=='"')
171 return ScanString(file,ch,val_rtrn);
172 else if (ch=='\n') {
173 rtrn->line++;
174 return XkbCF_EOL1;
175 }
176 else if (ch==';')
177 return XkbCF_Semi2;
178 else if (ch=='=')
179 return XkbCF_Equals3;
180 else if (ch=='+') {
181 ch= getc(file)_IO_getc (file);
182 if (ch=='=')
183 return XkbCF_PlusEquals4;
184 if ((ch!=EOF(-1))&&(ch!=' ')&&(ch!='\t'))
185 ungetc(ch,file);
186 return XkbCF_Plus6;
187 }
188 else if (ch=='-') {
189 ch= getc(file)_IO_getc (file);
190 if (ch=='=')
191 return XkbCF_MinusEquals5;
192 if ((ch!=EOF(-1))&&(ch!=' ')&&(ch!='\t'))
193 ungetc(ch,file);
194 return XkbCF_Minus7;
195 }
196 else if (ch==EOF(-1))
197 return XkbCF_EOF-1;
198 else if ((ch=='#')||((ch=='/')&&(getc(file)_IO_getc (file)=='/'))) {
199 while ((ch!='\n')&&(ch!=EOF(-1)))
200 ch= getc(file)_IO_getc (file);
201 rtrn->line++;
202 return XkbCF_EOL1;
203 }
204 return XkbCF_Unknown0;
205}
206
207/***====================================================================***/
208
209#define _XkbCF_Illegal0 0
210#define _XkbCF_Keymap1 1
211#define _XkbCF_Keycodes2 2
212#define _XkbCF_Geometry3 3
213#define _XkbCF_PhysSymbols4 4
214#define _XkbCF_Symbols5 5
215#define _XkbCF_Types6 6
216#define _XkbCF_CompatMap7 7
217
218#define _XkbCF_RulesFile8 8
219#define _XkbCF_Model9 9
220#define _XkbCF_Layout10 10
221#define _XkbCF_Variant11 11
222#define _XkbCF_Options12 12
223
224#define _XkbCF_InitialMods13 13
225#define _XkbCF_InitialCtrls14 14
226
227#define _XkbCF_ClickVolume15 15
228#define _XkbCF_BellVolume16 16
229#define _XkbCF_BellPitch17 17
230#define _XkbCF_BellDuration18 18
231#define _XkbCF_RepeatDelay19 19
232#define _XkbCF_RepeatInterval20 20
233#define _XkbCF_SlowKeysDelay21 21
234#define _XkbCF_DebounceDelay22 22
235#define _XkbCF_MouseKeysDelay23 23
236#define _XkbCF_MouseKeysInterval24 24
237#define _XkbCF_MouseKeysTimeToMax25 25
238#define _XkbCF_MouseKeysMaxSpeed26 26
239#define _XkbCF_MouseKeysCurve27 27
240#define _XkbCF_AccessXTimeout28 28
241#define _XkbCF_AccessXTimeoutCtrlsOn29 29
242#define _XkbCF_AccessXTimeoutCtrlsOff30 30
243#define _XkbCF_AccessXTimeoutOptsOn31 31
244#define _XkbCF_AccessXTimeoutOptsOff32 32
245
246#define _XkbCF_IgnoreLockMods33 33
247#define _XkbCF_IgnoreGroupLock34 34
248#define _XkbCF_InternalMods35 35
249
250#define _XkbCF_GroupsWrap36 36
251#define _XkbCF_InitialFeedback37 37
252
253static Boolint
254AddCtrlByName(XkbConfigRtrnPtr rtrn,char *name,unsigned long *ctrls_rtrn)
255{
256 if ((_XkbStrCaseCmpstrcasecmp(name,"repeat")==0)||
257 (_XkbStrCaseCmpstrcasecmp(name,"repeatkeys")==0))
258 *ctrls_rtrn= XkbRepeatKeysMask(1L << 0);
259 else if (_XkbStrCaseCmpstrcasecmp(name,"slowkeys")==0)
260 *ctrls_rtrn= XkbSlowKeysMask(1L << 1);
261 else if (_XkbStrCaseCmpstrcasecmp(name,"bouncekeys")==0)
262 *ctrls_rtrn= XkbBounceKeysMask(1L << 2);
263 else if (_XkbStrCaseCmpstrcasecmp(name,"stickykeys")==0)
264 *ctrls_rtrn= XkbStickyKeysMask(1L << 3);
265 else if (_XkbStrCaseCmpstrcasecmp(name,"mousekeys")==0)
266 *ctrls_rtrn= XkbMouseKeysMask(1L << 4);
267 else if (_XkbStrCaseCmpstrcasecmp(name,"mousekeysaccel")==0)
268 *ctrls_rtrn= XkbMouseKeysAccelMask(1L << 5);
269 else if (_XkbStrCaseCmpstrcasecmp(name,"accessxkeys")==0)
270 *ctrls_rtrn= XkbAccessXKeysMask(1L << 6);
271 else if (_XkbStrCaseCmpstrcasecmp(name,"accessxtimeout")==0)
272 *ctrls_rtrn= XkbAccessXTimeoutMask(1L << 7);
273 else if (_XkbStrCaseCmpstrcasecmp(name,"accessxfeedback")==0)
274 *ctrls_rtrn= XkbAccessXFeedbackMask(1L << 8);
275 else if (_XkbStrCaseCmpstrcasecmp(name,"audiblebell")==0)
276 *ctrls_rtrn= XkbAudibleBellMask(1L << 9);
277 else if (_XkbStrCaseCmpstrcasecmp(name,"overlay1")==0)
278 *ctrls_rtrn= XkbOverlay1Mask(1L << 10);
279 else if (_XkbStrCaseCmpstrcasecmp(name,"overlay2")==0)
280 *ctrls_rtrn= XkbOverlay2Mask(1L << 11);
281 else if (_XkbStrCaseCmpstrcasecmp(name,"ignoregrouplock")==0)
282 *ctrls_rtrn= XkbIgnoreGroupLockMask(1L << 12);
283 else {
284 rtrn->error= XkbCF_ExpectedControl109;
285 return False0;
286 }
287 return True1;
288}
289
290static Boolint
291AddAXTimeoutOptByName( XkbConfigRtrnPtr rtrn,
292 char * name,
293 unsigned short * opts_rtrn)
294{
295 if (_XkbStrCaseCmpstrcasecmp(name,"slowkeyspress")==0)
296 *opts_rtrn= XkbAX_SKPressFBMask(1L << 0);
297 else if (_XkbStrCaseCmpstrcasecmp(name,"slowkeysaccept")==0)
298 *opts_rtrn= XkbAX_SKAcceptFBMask(1L << 1);
299 else if (_XkbStrCaseCmpstrcasecmp(name,"feature")==0)
300 *opts_rtrn= XkbAX_FeatureFBMask(1L << 2);
301 else if (_XkbStrCaseCmpstrcasecmp(name,"slowwarn")==0)
302 *opts_rtrn= XkbAX_SlowWarnFBMask(1L << 3);
303 else if (_XkbStrCaseCmpstrcasecmp(name,"indicator")==0)
304 *opts_rtrn= XkbAX_IndicatorFBMask(1L << 4);
305 else if (_XkbStrCaseCmpstrcasecmp(name,"stickykeys")==0)
306 *opts_rtrn= XkbAX_StickyKeysFBMask(1L << 5);
307 else if (_XkbStrCaseCmpstrcasecmp(name,"twokeys")==0)
308 *opts_rtrn= XkbAX_TwoKeysMask(1L << 6);
309 else if (_XkbStrCaseCmpstrcasecmp(name,"latchtolock")==0)
310 *opts_rtrn= XkbAX_LatchToLockMask(1L << 7);
311 else if (_XkbStrCaseCmpstrcasecmp(name,"slowkeysrelease")==0)
312 *opts_rtrn= XkbAX_SKReleaseFBMask(1L << 8);
313 else if (_XkbStrCaseCmpstrcasecmp(name,"slowkeysreject")==0)
314 *opts_rtrn= XkbAX_SKRejectFBMask(1L << 9);
315 else if (_XkbStrCaseCmpstrcasecmp(name,"bouncekeysreject")==0)
316 *opts_rtrn= XkbAX_BKRejectFBMask(1L << 10);
317 else if (_XkbStrCaseCmpstrcasecmp(name,"dumbbell")==0)
318 *opts_rtrn= XkbAX_DumbBellFBMask(1L << 11);
319 else {
320 rtrn->error= XkbCF_ExpectedControl109;
321 return False0;
322 }
323 return True1;
324}
325
326XkbConfigUnboundModPtr
327XkbCFAddModByName( XkbConfigRtrnPtr rtrn,
328 int what,
329 char * name,
330 Boolint merge,
331 XkbConfigUnboundModPtr last)
332{
333 if (rtrn->num_unbound_mods>=rtrn->sz_unbound_mods) {
334 rtrn->sz_unbound_mods+= 5;
335 rtrn->unbound_mods= _XkbTypedRealloc(rtrn->unbound_mods,((rtrn->unbound_mods)?(XkbConfigUnboundModRec *)realloc((rtrn
->unbound_mods),(rtrn->sz_unbound_mods)*sizeof(XkbConfigUnboundModRec
)):((XkbConfigUnboundModRec *)calloc((rtrn->sz_unbound_mods
),sizeof(XkbConfigUnboundModRec))))
336 rtrn->sz_unbound_mods,((rtrn->unbound_mods)?(XkbConfigUnboundModRec *)realloc((rtrn
->unbound_mods),(rtrn->sz_unbound_mods)*sizeof(XkbConfigUnboundModRec
)):((XkbConfigUnboundModRec *)calloc((rtrn->sz_unbound_mods
),sizeof(XkbConfigUnboundModRec))))
337 XkbConfigUnboundModRec)((rtrn->unbound_mods)?(XkbConfigUnboundModRec *)realloc((rtrn
->unbound_mods),(rtrn->sz_unbound_mods)*sizeof(XkbConfigUnboundModRec
)):((XkbConfigUnboundModRec *)calloc((rtrn->sz_unbound_mods
),sizeof(XkbConfigUnboundModRec))))
;
338 if (rtrn->unbound_mods==NULL((void*)0)) {
339 rtrn->error= XkbCF_BadAlloc101;
340 return NULL((void*)0);
341 }
342 }
343 if (last==NULL((void*)0)) {
344 last= &rtrn->unbound_mods[rtrn->num_unbound_mods++];
345 last->what= what;
346 last->mods= 0;
347 last->vmods= 0;
348 last->merge= merge;
349 last->name= NULL((void*)0);
350 }
351 if (_XkbStrCaseCmpstrcasecmp(name,"shift")==0)
352 last->mods|= ShiftMask(1<<0);
353 else if (_XkbStrCaseCmpstrcasecmp(name,"lock")==0)
354 last->mods|= LockMask(1<<1);
355 else if ((_XkbStrCaseCmpstrcasecmp(name,"control")==0)||
356 (_XkbStrCaseCmpstrcasecmp(name,"ctrl")==0))
357 last->mods|= ControlMask(1<<2);
358 else if (_XkbStrCaseCmpstrcasecmp(name,"mod1")==0)
359 last->mods|= Mod1Mask(1<<3);
360 else if (_XkbStrCaseCmpstrcasecmp(name,"mod2")==0)
361 last->mods|= Mod2Mask(1<<4);
362 else if (_XkbStrCaseCmpstrcasecmp(name,"mod3")==0)
363 last->mods|= Mod3Mask(1<<5);
364 else if (_XkbStrCaseCmpstrcasecmp(name,"mod4")==0)
365 last->mods|= Mod4Mask(1<<6);
366 else if (_XkbStrCaseCmpstrcasecmp(name,"mod5")==0)
367 last->mods|= Mod5Mask(1<<7);
368 else {
369 if (last->name!=NULL((void*)0)) {
370 last= &rtrn->unbound_mods[rtrn->num_unbound_mods++];
371 last->what= what;
372 last->mods= 0;
373 last->vmods= 0;
374 last->merge= merge;
375 last->name= NULL((void*)0);
376 }
377 last->name= _XkbDupString(name);
378 }
379 return last;
380}
381
382int
383XkbCFBindMods(XkbConfigRtrnPtr rtrn,XkbDescPtr xkb)
384{
385register int n,v;
386Atom name;
387XkbConfigUnboundModPtr mod;
388int missing;
389
390 if (rtrn->num_unbound_mods<1)
391 return 0;
392 if ((xkb==NULL((void*)0)) || (xkb->names==NULL((void*)0)))
393 return -1;
394
395 missing= 0;
396 for (n=0,mod=rtrn->unbound_mods;n<rtrn->num_unbound_mods;n++,mod++) {
397 if (mod->name!=NULL((void*)0)) {
398 name= XkbInternAtom(xkb->dpy,mod->name,True1);
399 if (name==None0L)
400 continue;
401 for (v=0;v<XkbNumVirtualMods16;v++) {
402 if (xkb->names->vmods[v]==name) {
403 mod->vmods= (1<<v);
404 _XkbFree(mod->name)free(mod->name);
405 mod->name= NULL((void*)0);
406 break;
407 }
408 }
409 if (mod->name!=NULL((void*)0))
410 missing++;
411 }
412 }
413 return missing;
414}
415
416Boolint
417XkbCFApplyMods(XkbConfigRtrnPtr rtrn,int what,XkbConfigModInfoPtr info)
418{
419register int n;
420XkbConfigUnboundModPtr mod;
421
422 if (rtrn->num_unbound_mods<1)
423 return True1;
424
425 for (n=0,mod=rtrn->unbound_mods;n<rtrn->num_unbound_mods;n++,mod++) {
426 if (mod->what!=what)
427 continue;
428 if (mod->merge==XkbCF_MergeRemove2) {
429 info->mods_clear|= mod->mods;
430 info->vmods_clear|= mod->vmods;
431 }
432 else {
433 if (mod->merge==XkbCF_MergeSet0)
434 info->replace= True1;
435 info->mods|= mod->mods;
436 info->vmods|= mod->vmods;
437 }
438 if (mod->name==NULL((void*)0)) {
439 mod->what= _XkbCF_Illegal0;
440 }
441 else {
442 mod->mods= 0;
443 mod->vmods= 0;
444 }
445 }
446 return True1;
447}
448
449/*ARGSUSED*/
450static Boolint
451DefaultParser( FILE * file,
452 XkbConfigFieldsPtr fields,
453 XkbConfigFieldPtr field,
454 XkbDescPtr xkb,
455 XkbConfigRtrnPtr rtrn)
456{
457int tok;
458XkbCFScanResultRec val;
459char ** str;
460int merge;
461unsigned long * ctrls, ctrls_mask;
462unsigned short * opts, opts_mask;
463int * pival, sign;
464int onoff;
465XkbConfigUnboundModPtr last;
466unsigned what;
467
468 tok= XkbCFScan(file,&val,rtrn);
469 str= NULL((void*)0);
470 onoff= 0;
471 pival= NULL((void*)0);
472 switch (field->field_id) {
473 case _XkbCF_RulesFile8: if (!str) str= &rtrn->rules_file;
474 case _XkbCF_Model9: if (!str) str= &rtrn->model;
475 case _XkbCF_Layout10: if (!str) str= &rtrn->layout;
476 case _XkbCF_Variant11: if (!str) str= &rtrn->variant;
477 case _XkbCF_Options12: if (!str) str= &rtrn->options;
478 case _XkbCF_Keymap1: if (!str) str= &rtrn->keymap;
479 case _XkbCF_Keycodes2: if (!str) str= &rtrn->keycodes;
480 case _XkbCF_Geometry3: if (!str) str= &rtrn->geometry;
481 case _XkbCF_PhysSymbols4:if (!str) str= &rtrn->phys_symbols;
482 case _XkbCF_Symbols5: if (!str) str= &rtrn->symbols;
483 case _XkbCF_Types6: if (!str) str= &rtrn->types;
484 case _XkbCF_CompatMap7: if (!str) str= &rtrn->compat;
485 if (tok!=XkbCF_Equals3) {
486 rtrn->error= XkbCF_MissingEquals103;
487 goto BAILOUT;
488 }
489 tok= XkbCFScan(file,&val,rtrn);
490 if ((tok!=XkbCF_String10)&&(tok!=XkbCF_Ident11)) {
491 rtrn->error= XkbCF_ExpectedString107;
492 return False0;
493 }
494 tok= XkbCFScan(file,&val,rtrn);
495 if ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_Semi2)&&(tok!=XkbCF_EOF-1)) {
496 rtrn->error= XkbCF_ExpectedEOS104;
497 return False0;
498 }
499 if (*str!=NULL((void*)0))
500 _XkbFree(*str)free(*str);
501 *str= _XkbDupString(val.str);
502 break;
503 case _XkbCF_InitialMods13:
504 case _XkbCF_IgnoreLockMods33:
505 case _XkbCF_InternalMods35:
506 what= XkbCF_InitialMods(1L<<0);
507 if (field->field_id==_XkbCF_InitialMods13)
508 rtrn->defined|= (what=XkbCF_InitialMods(1L<<0));
509 else if (field->field_id==_XkbCF_InternalMods35)
510 rtrn->defined|= (what=XkbCF_InternalMods(1L<<1));
511 else if (field->field_id==_XkbCF_IgnoreLockMods33)
512 rtrn->defined|= (what=XkbCF_IgnoreLockMods(1L<<2));
513 if (tok==XkbCF_Equals3) merge= XkbCF_MergeSet0;
514 else if (tok==XkbCF_MinusEquals5) merge= XkbCF_MergeRemove2;
515 else if (tok==XkbCF_PlusEquals4) merge= XkbCF_MergeAdd1;
516 else {
517 rtrn->error= XkbCF_MissingEquals103;
518 goto BAILOUT;
519 }
520 tok= XkbCFScan(file,&val,rtrn);
521 if ((tok==XkbCF_EOL1)||(tok==XkbCF_Semi2)||(tok==XkbCF_EOF-1)) {
522 rtrn->error= XkbCF_ExpectedModifier108;
523 return False0;
524 }
525 last= NULL((void*)0);
526 while ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_Semi2)&&(tok!=XkbCF_EOF-1)) {
527 if ((tok!=XkbCF_Ident11)&&(tok!=XkbCF_String10)) {
528 rtrn->error= XkbCF_ExpectedModifier108;
529 return False0;
530 }
531 last=XkbCFAddModByName(rtrn,what,val.str,merge,last);
532 if (last==NULL((void*)0))
533 return False0;
534 if (merge==XkbCF_MergeSet0)
535 merge= XkbCF_MergeAdd1;
536 tok= XkbCFScan(file,&val,rtrn);
537 if ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_EOF-1)&&(tok!=XkbCF_Semi2)) {
538 if (tok!=XkbCF_Plus6) {
539 rtrn->error= XkbCF_ExpectedOperator111;
540 return False0;
541 }
542 tok= XkbCFScan(file,&val,rtrn);
543 }
544 }
545 break;
546 case _XkbCF_InitialCtrls14:
547 rtrn->defined|= XkbCF_InitialCtrls(1L<<3);
548 ctrls= NULL((void*)0);
549 if (tok==XkbCF_PlusEquals4)
550 ctrls= &rtrn->initial_ctrls;
551 else if (tok==XkbCF_MinusEquals5)
552 ctrls= &rtrn->initial_ctrls_clear;
553 else if (tok==XkbCF_Equals3) {
554 ctrls= &rtrn->initial_ctrls;
555 rtrn->replace_initial_ctrls= True1;
556 *ctrls= 0;
557 }
558 else {
559 rtrn->error= XkbCF_MissingEquals103;
560 goto BAILOUT;
561 }
562 tok= XkbCFScan(file,&val,rtrn);
563 if ((tok==XkbCF_EOL1)||(tok==XkbCF_Semi2)||(tok==XkbCF_EOF-1)) {
564 rtrn->error= XkbCF_ExpectedControl109;
565 return False0;
566 }
567 while ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_Semi2)&&(tok!=XkbCF_EOF-1)) {
568 if ((tok!=XkbCF_Ident11)&&(tok!=XkbCF_String10)) {
569 rtrn->error= XkbCF_ExpectedControl109;
570 return False0;
571 }
572 if (!AddCtrlByName(rtrn,val.str,&ctrls_mask)) {
573 return False0;
574 }
575 *ctrls |= ctrls_mask;
576 tok= XkbCFScan(file,&val,rtrn);
577 if ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_EOF-1)&&(tok!=XkbCF_Semi2)) {
578 if (tok!=XkbCF_Plus6) {
579 rtrn->error= XkbCF_ExpectedOperator111;
580 return False0;
581 }
582 tok= XkbCFScan(file,&val,rtrn);
583 }
584 }
585 break;
586 case _XkbCF_AccessXTimeoutCtrlsOn29:
587 case _XkbCF_AccessXTimeoutCtrlsOff30:
588 opts= NULL((void*)0);
589 if (tok==XkbCF_MinusEquals5) {
590 ctrls= &rtrn->axt_ctrls_ignore;
591 opts= &rtrn->axt_opts_ignore;
592 }
593 else if ((tok==XkbCF_PlusEquals4)||(tok==XkbCF_Equals3)) {
594 if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOff30) {
595 ctrls= &rtrn->axt_ctrls_off;
596 opts= &rtrn->axt_opts_off;
597 if (tok==XkbCF_Equals3)
598 rtrn->replace_axt_ctrls_off= True1;
599 }
600 else {
601 ctrls= &rtrn->axt_ctrls_on;
602 opts= &rtrn->axt_opts_on;
603 if (tok==XkbCF_Equals3)
604 rtrn->replace_axt_ctrls_on= True1;
605 }
606 *ctrls= 0;
607 }
608 else {
609 rtrn->error= XkbCF_MissingEquals103;
610 goto BAILOUT;
611 }
612 tok= XkbCFScan(file,&val,rtrn);
613 if ((tok==XkbCF_EOL1)||(tok==XkbCF_Semi2)||(tok==XkbCF_EOF-1)) {
614 rtrn->error= XkbCF_ExpectedControl109;
615 return False0;
616 }
617 while ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_Semi2)&&(tok!=XkbCF_EOF-1)) {
618 if ((tok!=XkbCF_Ident11)&&(tok!=XkbCF_String10)) {
619 rtrn->error= XkbCF_ExpectedControl109;
620 return False0;
621 }
622 if (!AddCtrlByName(rtrn,val.str,&ctrls_mask)) {
623 if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask))
624 return False0;
625 *opts |= opts_mask;
626 if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOff30) {
627 rtrn->defined|= XkbCF_AccessXTimeoutOptsOff(1L<<8);
628 if (rtrn->replace_axt_ctrls_off)
629 rtrn->replace_axt_opts_off= True1;
630 }
631 else {
632 rtrn->defined|= XkbCF_AccessXTimeoutOptsOn(1L<<7);
633 if (rtrn->replace_axt_ctrls_on)
634 rtrn->replace_axt_opts_on= True1;
635 }
636 }
637 else
638 *ctrls |= ctrls_mask;
639 tok= XkbCFScan(file,&val,rtrn);
640 if ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_EOF-1)&&(tok!=XkbCF_Semi2)) {
641 if (tok!=XkbCF_Plus6) {
642 rtrn->error= XkbCF_ExpectedOperator111;
643 return False0;
644 }
645 tok= XkbCFScan(file,&val,rtrn);
646 }
647 }
648 break;
649 case _XkbCF_InitialFeedback37:
650 rtrn->defined|= XkbCF_InitialOpts(1L<<10);
651 opts= NULL((void*)0);
652 if (tok==XkbCF_PlusEquals4)
653 opts= &rtrn->initial_opts;
654 else if (tok==XkbCF_MinusEquals5)
655 opts= &rtrn->initial_opts_clear;
656 else if (tok==XkbCF_Equals3) {
657 opts= &rtrn->initial_opts;
658 rtrn->replace_initial_opts= True1;
659 *opts= 0;
660 }
661 else {
662 rtrn->error= XkbCF_MissingEquals103;
663 goto BAILOUT;
664 }
665 tok= XkbCFScan(file,&val,rtrn);
666 if ((tok==XkbCF_EOL1)||(tok==XkbCF_Semi2)||(tok==XkbCF_EOF-1)) {
667 rtrn->error= XkbCF_ExpectedAXOption110;
668 return False0;
669 }
670 while ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_Semi2)&&(tok!=XkbCF_EOF-1)) {
671 if ((tok!=XkbCF_Ident11)&&(tok!=XkbCF_String10)) {
672 rtrn->error= XkbCF_ExpectedAXOption110;
673 return False0;
674 }
675 if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask)) {
676 return False0;
677 }
678 *opts |= opts_mask;
679 tok= XkbCFScan(file,&val,rtrn);
680 if ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_EOF-1)&&(tok!=XkbCF_Semi2)) {
681 if (tok!=XkbCF_Plus6) {
682 rtrn->error= XkbCF_ExpectedOperator111;
683 return False0;
684 }
685 tok= XkbCFScan(file,&val,rtrn);
686 }
687 }
688 break;
689 case _XkbCF_AccessXTimeoutOptsOff32:
690 case _XkbCF_AccessXTimeoutOptsOn31:
691 opts= NULL((void*)0);
692 if (tok==XkbCF_MinusEquals5)
693 opts= &rtrn->axt_opts_ignore;
694 else if ((tok==XkbCF_PlusEquals4)||(tok==XkbCF_Equals3)) {
695 if (field->field_id==_XkbCF_AccessXTimeoutOptsOff32) {
696 opts= &rtrn->axt_opts_off;
697 if (tok==XkbCF_Equals3)
698 rtrn->replace_axt_opts_off= True1;
699 }
700 else {
701 opts= &rtrn->axt_opts_on;
702 if (tok==XkbCF_Equals3)
703 rtrn->replace_axt_opts_on= True1;
704 }
705 *opts = 0;
706 }
707 else {
708 rtrn->error= XkbCF_MissingEquals103;
709 goto BAILOUT;
710 }
711 tok= XkbCFScan(file,&val,rtrn);
712 if ((tok==XkbCF_EOL1)||(tok==XkbCF_Semi2)||(tok==XkbCF_EOF-1)) {
713 rtrn->error= XkbCF_ExpectedControl109;
714 return False0;
715 }
716 while ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_Semi2)&&(tok!=XkbCF_EOF-1)) {
717 if ((tok!=XkbCF_Ident11)&&(tok!=XkbCF_String10)) {
718 rtrn->error= XkbCF_ExpectedControl109;
719 return False0;
720 }
721 if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask))
722 return False0;
723 *opts |= opts_mask;
724
725 tok= XkbCFScan(file,&val,rtrn);
726 if ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_EOF-1)&&(tok!=XkbCF_Semi2)) {
727 if (tok!=XkbCF_Plus6) {
728 rtrn->error= XkbCF_ExpectedOperator111;
729 return False0;
730 }
731 tok= XkbCFScan(file,&val,rtrn);
732 }
733 }
734 break;
735 case _XkbCF_ClickVolume15:
736 if (!pival) {
737 pival= &rtrn->click_volume;
738 onoff= 100;
739 }
740 case _XkbCF_BellVolume16:
741 if (!pival) {
742 pival= &rtrn->bell_volume;
743 onoff= 100;
744 }
745 case _XkbCF_BellPitch17:
746 if (!pival)
747 pival= &rtrn->bell_pitch;
748 case _XkbCF_BellDuration18:
749 if (!pival)
750 pival= &rtrn->bell_duration;
751 case _XkbCF_RepeatDelay19:
752 if (!pival)
753 pival= &rtrn->repeat_delay;
754 case _XkbCF_RepeatInterval20:
755 if (!pival)
756 pival= &rtrn->repeat_interval;
757 case _XkbCF_SlowKeysDelay21:
758 if (!pival)
759 pival= &rtrn->slow_keys_delay;
760 case _XkbCF_DebounceDelay22:
761 if (!pival)
762 pival= &rtrn->debounce_delay;
763 case _XkbCF_MouseKeysDelay23:
764 if (!pival)
765 pival= &rtrn->mk_delay;
766 case _XkbCF_MouseKeysInterval24:
767 if (!pival)
768 pival= &rtrn->mk_interval;
769 case _XkbCF_MouseKeysTimeToMax25:
770 if (!pival)
771 pival= &rtrn->mk_time_to_max;
772 case _XkbCF_MouseKeysMaxSpeed26:
773 if (!pival)
774 pival= &rtrn->mk_max_speed;
775 case _XkbCF_MouseKeysCurve27:
776 if (!pival)
777 pival= &rtrn->mk_curve;
778 case _XkbCF_AccessXTimeout28:
779 if (!pival)
780 pival= &rtrn->ax_timeout;
781 if (tok!=XkbCF_Equals3) {
782 rtrn->error= XkbCF_MissingEquals103;
783 goto BAILOUT;
784 }
785 tok= XkbCFScan(file,&val,rtrn);
786 if (tok == XkbCF_Minus7 && field->field_id == _XkbCF_MouseKeysCurve27) {
787 /* This can be a negative value */
788 tok = XkbCFScan(file,&val,rtrn);
789 sign = -1;
790 }
791 else
792 sign = 1;
793 if (tok!=XkbCF_Integer12) {
794 Boolint ok= False0;
795 if ((onoff)&&(tok==XkbCF_Ident11)&&(val.str!=NULL((void*)0))) {
796 if (_XkbStrCaseCmpstrcasecmp(val.str,"on")) {
797 val.ival= onoff;
798 ok= True1;
799 }
800 else if (_XkbStrCaseCmpstrcasecmp(val.str,"off")) {
801 val.ival= 0;
802 ok= True1;
803 }
804 }
805 if (!ok) {
806 rtrn->error= XkbCF_ExpectedInteger106;
807 goto BAILOUT;
808 }
809 }
810 *pival= val.ival * sign;
811 if (field->field_id == _XkbCF_AccessXTimeout28)
812 rtrn->defined|=XkbCF_AccessXTimeout(1L<<4);
813 tok= XkbCFScan(file,&val,rtrn);
814 if ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_Semi2)&&(tok!=XkbCF_EOF-1)) {
815 rtrn->error= XkbCF_ExpectedEOS104;
816 return False0;
817 }
818 break;
819 case _XkbCF_GroupsWrap36:
820 if (tok!=XkbCF_Equals3) {
821 rtrn->error= XkbCF_MissingEquals103;
822 goto BAILOUT;
823 }
824 tok= XkbCFScan(file,&val,rtrn);
825 if (tok==XkbCF_Ident11) {
826 if (_XkbStrCaseCmpstrcasecmp(val.str,"wrap")==0) {
827 rtrn->groups_wrap= XkbSetGroupInfo(0,XkbWrapIntoRange,0)((((0x00))&0xc0)|(((0)&3)<<4)|((0)&0x0f));
828 }
829 else if (_XkbStrCaseCmpstrcasecmp(val.str,"clamp")==0) {
830 rtrn->groups_wrap= XkbSetGroupInfo(0,XkbClampIntoRange,0)((((0x40))&0xc0)|(((0)&3)<<4)|((0)&0x0f));
831 }
832 else {
833 rtrn->error= XkbCF_ExpectedOORGroupBehavior112;
834 return False0;
835 }
836 }
837 else if ((tok==XkbCF_Integer12)&&(XkbIsLegalGroup(val.ival-1)(((val.ival-1)>=0)&&((val.ival-1)<4)))) {
838 rtrn->groups_wrap= XkbSetGroupInfo(0,XkbRedirectIntoRange,((((0x80))&0xc0)|(((val.ival-1)&3)<<4)|((0)&
0x0f))
839 val.ival-1)((((0x80))&0xc0)|(((val.ival-1)&3)<<4)|((0)&
0x0f))
;
840 }
841 else {
842 rtrn->error= XkbCF_ExpectedOORGroupBehavior112;
843 return False0;
844 }
845 rtrn->defined|= XkbCF_GroupsWrap(1L<<9);
846 tok= XkbCFScan(file,&val,rtrn);
847 if ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_Semi2)&&(tok!=XkbCF_EOF-1)) {
848 rtrn->error= XkbCF_ExpectedEOS104;
849 return False0;
850 }
851 break;
852 default:
853 rtrn->error= XkbCF_ExpectedInteger106;
854 goto BAILOUT;
855
856 }
857 return True1;
858BAILOUT:
859 return False0;
860}
861
862static Boolint
863DefaultCleanUp(XkbConfigRtrnPtr rtrn)
864{
865 if (rtrn->keymap) _XkbFree(rtrn->keymap)free(rtrn->keymap);
866 if (rtrn->keycodes) _XkbFree(rtrn->keycodes)free(rtrn->keycodes);
867 if (rtrn->geometry) _XkbFree(rtrn->geometry)free(rtrn->geometry);
868 if (rtrn->phys_symbols) _XkbFree(rtrn->phys_symbols)free(rtrn->phys_symbols);
869 if (rtrn->symbols) _XkbFree(rtrn->symbols)free(rtrn->symbols);
870 if (rtrn->types) _XkbFree(rtrn->types)free(rtrn->types);
871 if (rtrn->compat) _XkbFree(rtrn->compat)free(rtrn->compat);
872 rtrn->keycodes= rtrn->geometry= NULL((void*)0);
873 rtrn->symbols= rtrn->phys_symbols= NULL((void*)0);
874 rtrn->types= rtrn->compat= NULL((void*)0);
875 if ((rtrn->unbound_mods!=NULL((void*)0))&&(rtrn->num_unbound_mods>0)) {
876 register int i;
877 for (i=0;i<rtrn->num_unbound_mods;i++) {
878 if (rtrn->unbound_mods[i].name!=NULL((void*)0)) {
879 _XkbFree(rtrn->unbound_mods[i].name)free(rtrn->unbound_mods[i].name);
880 rtrn->unbound_mods[i].name= NULL((void*)0);
881 }
882 }
883 _XkbFree(rtrn->unbound_mods)free(rtrn->unbound_mods);
884 rtrn->sz_unbound_mods= 0;
885 rtrn->num_unbound_mods= 0;
886 rtrn->unbound_mods= NULL((void*)0);
887 }
888 return True1;
889}
890
891static Boolint
892DefaultApplyNames(XkbConfigRtrnPtr rtrn,XkbDescPtr xkb)
893{
894char *str;
895
896 if (XkbAllocNames(xkb,XkbComponentNamesMask(0x3f),0,0)!=Success0)
897 return False0;
898 if ((str=rtrn->keycodes)!=NULL((void*)0)) {
899 xkb->names->keycodes= XkbInternAtom(xkb->dpy,str,False0);
900 _XkbFree(str)free(str);
901 rtrn->keycodes= NULL((void*)0);
902 }
903 if ((str=rtrn->geometry)!=NULL((void*)0)) {
904 xkb->names->geometry= XkbInternAtom(xkb->dpy,str,False0);
905 _XkbFree(str)free(str);
906 rtrn->geometry= NULL((void*)0);
907 }
908 if ((str=rtrn->symbols)!=NULL((void*)0)) {
909 xkb->names->symbols= XkbInternAtom(xkb->dpy,str,False0);
910 _XkbFree(str)free(str);
911 rtrn->symbols= NULL((void*)0);
912 }
913 if ((str=rtrn->phys_symbols)!=NULL((void*)0)) {
914 xkb->names->phys_symbols= XkbInternAtom(xkb->dpy,str,False0);
915 _XkbFree(str)free(str);
916 rtrn->phys_symbols= NULL((void*)0);
917 }
918 if ((str=rtrn->types)!=NULL((void*)0)) {
919 xkb->names->types= XkbInternAtom(xkb->dpy,str,False0);
920 _XkbFree(str)free(str);
921 rtrn->types= NULL((void*)0);
922 }
923 if ((str=rtrn->compat)!=NULL((void*)0)) {
924 xkb->names->compat= XkbInternAtom(xkb->dpy,str,False0);
925 _XkbFree(str)free(str);
926 rtrn->compat= NULL((void*)0);
927 }
928 return True1;
929}
930
931static Boolint
932DefaultApplyControls(XkbConfigRtrnPtr rtrn,XkbDescPtr xkb)
933{
934unsigned on,off;
935XkbControlsPtr ctrls;
936unsigned int mask;
937
938 if (XkbAllocControls(xkb,XkbAllControlsMask(0xF8001FFF))!=Success0)
939 return False0;
940 ctrls= xkb->ctrls;
941 if (rtrn->replace_initial_ctrls)
942 ctrls->enabled_ctrls= rtrn->initial_ctrls;
943 else ctrls->enabled_ctrls|= rtrn->initial_ctrls;
944 ctrls->enabled_ctrls&= ~rtrn->initial_ctrls_clear;
945 if (rtrn->internal_mods.replace) {
946 ctrls->internal.real_mods= rtrn->internal_mods.mods;
947 ctrls->internal.vmods= rtrn->internal_mods.vmods;
948 }
949 else {
950 ctrls->internal.real_mods&= ~rtrn->internal_mods.mods_clear;
951 ctrls->internal.vmods&= ~rtrn->internal_mods.vmods_clear;
952 ctrls->internal.real_mods|= rtrn->internal_mods.mods;
953 ctrls->internal.vmods|= rtrn->internal_mods.vmods;
954 }
955 mask= 0;
956 (void)XkbVirtualModsToReal(xkb,ctrls->internal.vmods,&mask);
957 ctrls->internal.mask= (ctrls->internal.real_mods|mask);
958
959 if (rtrn->ignore_lock_mods.replace) {
960 ctrls->ignore_lock.real_mods= rtrn->ignore_lock_mods.mods;
961 ctrls->ignore_lock.vmods= rtrn->ignore_lock_mods.vmods;
962 }
963 else {
964 ctrls->ignore_lock.real_mods&= ~rtrn->ignore_lock_mods.mods_clear;
965 ctrls->ignore_lock.vmods&= ~rtrn->ignore_lock_mods.vmods_clear;
966 ctrls->ignore_lock.real_mods|= rtrn->ignore_lock_mods.mods;
967 ctrls->ignore_lock.vmods|= rtrn->ignore_lock_mods.vmods;
968 }
969 mask= 0;
970 (void)XkbVirtualModsToReal(xkb,ctrls->ignore_lock.vmods,&mask);
971 ctrls->ignore_lock.mask= (ctrls->ignore_lock.real_mods|mask);
972
973 if (rtrn->repeat_delay>0)
974 ctrls->repeat_delay= rtrn->repeat_delay;
975 if (rtrn->repeat_interval>0)
976 ctrls->repeat_interval= rtrn->repeat_interval;
977 if (rtrn->slow_keys_delay>0)
978 ctrls->slow_keys_delay= rtrn->slow_keys_delay;
979 if (rtrn->debounce_delay>0)
980 ctrls->debounce_delay= rtrn->debounce_delay;
981 if (rtrn->mk_delay>0)
982 ctrls->mk_delay= rtrn->mk_delay;
983 if (rtrn->mk_interval>0)
984 ctrls->mk_interval= rtrn->mk_interval;
985 if (rtrn->mk_time_to_max>0)
986 ctrls->mk_time_to_max= rtrn->mk_time_to_max;
987 if (rtrn->mk_max_speed>0)
988 ctrls->mk_max_speed= rtrn->mk_max_speed;
989 if (rtrn->mk_curve>0)
990 ctrls->mk_curve= rtrn->mk_curve;
991 if (rtrn->defined&XkbCF_AccessXTimeout(1L<<4) && rtrn->ax_timeout > 0)
992 ctrls->ax_timeout= rtrn->ax_timeout;
993
994 /* any value set to both off and on is reset to ignore */
995 if ((off=(rtrn->axt_ctrls_on&rtrn->axt_ctrls_off))!=0)
996 rtrn->axt_ctrls_ignore|= off;
997
998 /* ignore takes priority over on and off */
999 rtrn->axt_ctrls_on&= ~rtrn->axt_ctrls_ignore;
1000 rtrn->axt_ctrls_off&= ~rtrn->axt_ctrls_ignore;
1001
1002 if (!rtrn->replace_axt_ctrls_off) {
1003 off= (ctrls->axt_ctrls_mask&(~ctrls->axt_ctrls_values));
1004 off&= ~rtrn->axt_ctrls_on;
1005 off|= rtrn->axt_ctrls_off;
1006 }
1007 else off= rtrn->axt_ctrls_off;
1008 if (!rtrn->replace_axt_ctrls_on) {
1009 on= (ctrls->axt_ctrls_mask&ctrls->axt_ctrls_values);
1010 on&= ~rtrn->axt_ctrls_off;
1011 on|= rtrn->axt_ctrls_on;
1012 }
1013 else on= rtrn->axt_ctrls_on;
1014 ctrls->axt_ctrls_mask= (on|off)&~rtrn->axt_ctrls_ignore;
1015 ctrls->axt_ctrls_values= on&~rtrn->axt_ctrls_ignore;
1016
1017 /* any value set to both off and on is reset to ignore */
1018 if ((off=(rtrn->axt_opts_on&rtrn->axt_opts_off))!=0)
1019 rtrn->axt_opts_ignore|= off;
1020
1021 /* ignore takes priority over on and off */
1022 rtrn->axt_opts_on&= ~rtrn->axt_opts_ignore;
1023 rtrn->axt_opts_off&= ~rtrn->axt_opts_ignore;
1024
1025 if (rtrn->replace_axt_opts_off) {
1026 off= (ctrls->axt_opts_mask&(~ctrls->axt_opts_values));
1027 off&= ~rtrn->axt_opts_on;
1028 off|= rtrn->axt_opts_off;
1029 }
1030 else off= rtrn->axt_opts_off;
1031 if (!rtrn->replace_axt_opts_on) {
1032 on= (ctrls->axt_opts_mask&ctrls->axt_opts_values);
1033 on&= ~rtrn->axt_opts_off;
1034 on|= rtrn->axt_opts_on;
1035 }
1036 else on= rtrn->axt_opts_on;
1037 ctrls->axt_opts_mask= (unsigned short)((on|off)&~rtrn->axt_ctrls_ignore);
1038 ctrls->axt_opts_values= (unsigned short)(on&~rtrn->axt_ctrls_ignore);
1039
1040 if (rtrn->defined&XkbCF_GroupsWrap(1L<<9)) {
1041 int n;
1042 n= XkbNumGroups(ctrls->groups_wrap)((ctrls->groups_wrap)&0x0f);
1043 rtrn->groups_wrap= XkbSetNumGroups(rtrn->groups_wrap,n)(((rtrn->groups_wrap)&0xf0)|((n)&0x0f));
1044 ctrls->groups_wrap= rtrn->groups_wrap;
1045 }
1046 return True1;
1047}
1048
1049/*ARGSUSED*/
1050static Boolint
1051DefaultFinish( XkbConfigFieldsPtr fields,
1052 XkbDescPtr xkb,
1053 XkbConfigRtrnPtr rtrn,
1054 int what)
1055{
1056 if ((what==XkbCF_Destroy3)||(what==XkbCF_CleanUp2))
1057 return DefaultCleanUp(rtrn);
1058 if (what==XkbCF_Check0) {
1059 if ((rtrn->symbols==NULL((void*)0))&&(rtrn->phys_symbols!=NULL((void*)0)))
1060 rtrn->symbols= _XkbDupString(rtrn->phys_symbols);
1061 }
1062 if ((what==XkbCF_Apply1)||(what==XkbCF_Check0)) {
1063 if (xkb && xkb->names && (rtrn->num_unbound_mods>0))
1064 XkbCFBindMods(rtrn,xkb);
1065 XkbCFApplyMods(rtrn,XkbCF_InitialMods(1L<<0),&rtrn->initial_mods);
1066 XkbCFApplyMods(rtrn,XkbCF_InternalMods(1L<<1),&rtrn->internal_mods);
1067 XkbCFApplyMods(rtrn,XkbCF_IgnoreLockMods(1L<<2),&rtrn->ignore_lock_mods);
1068 }
1069 if (what==XkbCF_Apply1) {
1070 if (xkb!=NULL((void*)0)) {
1071 DefaultApplyNames(rtrn,xkb);
1072 DefaultApplyControls(rtrn,xkb);
1073 XkbCFBindMods(rtrn,xkb);
1074 }
1075 }
1076 return True1;
1077}
1078
1079static XkbConfigFieldRec _XkbCFDfltFields[] = {
1080 { "rules", _XkbCF_RulesFile8 },
1081 { "model", _XkbCF_Model9 },
1082 { "layout", _XkbCF_Layout10 },
1083 { "variant", _XkbCF_Variant11 },
1084 { "options", _XkbCF_Options12 },
1085 { "keymap", _XkbCF_Keymap1 },
1086 { "keycodes", _XkbCF_Keycodes2 },
1087 { "geometry", _XkbCF_Geometry3 },
1088 { "realsymbols",_XkbCF_PhysSymbols4 },
1089 { "actualsymbols",_XkbCF_PhysSymbols4 },
1090 { "symbols", _XkbCF_Symbols5 },
1091 { "symbolstouse",_XkbCF_Symbols5 },
1092 { "types", _XkbCF_Types6 },
1093 { "compat", _XkbCF_CompatMap7 },
1094 { "modifiers", _XkbCF_InitialMods13 },
1095 { "controls", _XkbCF_InitialCtrls14 },
1096 { "click", _XkbCF_ClickVolume15 },
1097 { "clickvolume",_XkbCF_ClickVolume15 },
1098 { "bell", _XkbCF_BellVolume16 },
1099 { "bellvolume", _XkbCF_BellVolume16 },
1100 { "bellpitch", _XkbCF_BellPitch17 },
1101 { "bellduration",_XkbCF_BellDuration18 },
1102 { "repeatdelay",_XkbCF_RepeatDelay19 },
1103 { "repeatinterval",_XkbCF_RepeatInterval20 },
1104 { "slowkeysdelay",_XkbCF_SlowKeysDelay21 },
1105 { "debouncedelay",_XkbCF_DebounceDelay22 },
1106 { "mousekeysdelay",_XkbCF_MouseKeysDelay23 },
1107 { "mousekeysinterval",_XkbCF_MouseKeysInterval24 },
1108 { "mousekeystimetomax",_XkbCF_MouseKeysTimeToMax25 },
1109 { "mousekeysmaxspeed",_XkbCF_MouseKeysMaxSpeed26 },
1110 { "mousekeyscurve",_XkbCF_MouseKeysCurve27 },
1111 { "accessxtimeout",_XkbCF_AccessXTimeout28 },
1112 { "axtimeout",_XkbCF_AccessXTimeout28 },
1113 { "accessxtimeoutctrlson",_XkbCF_AccessXTimeoutCtrlsOn29 },
1114 { "axtctrlson", _XkbCF_AccessXTimeoutCtrlsOn29 },
1115 { "accessxtimeoutctrlsoff",_XkbCF_AccessXTimeoutCtrlsOff30 },
1116 { "axtctrlsoff",_XkbCF_AccessXTimeoutCtrlsOff30 },
1117 { "accessxtimeoutfeedbackon", _XkbCF_AccessXTimeoutOptsOn31 },
1118 { "axtfeedbackon", _XkbCF_AccessXTimeoutOptsOn31 },
1119 { "accessxtimeoutfeedbackoff", _XkbCF_AccessXTimeoutOptsOff32 },
1120 { "axtfeedbackoff", _XkbCF_AccessXTimeoutOptsOff32 },
1121 { "ignorelockmods",_XkbCF_IgnoreLockMods33 },
1122 { "ignorelockmodifiers",_XkbCF_IgnoreLockMods33 },
1123 { "ignoregrouplock",_XkbCF_IgnoreGroupLock34 },
1124 { "internalmods",_XkbCF_InternalMods35 },
1125 { "internalmodifiers",_XkbCF_InternalMods35 },
1126 { "outofrangegroups",_XkbCF_GroupsWrap36 },
1127 { "groups", _XkbCF_GroupsWrap36 },
1128 { "feedback", _XkbCF_InitialFeedback37 },
1129};
1130#define _XkbCFNumDfltFields(sizeof(_XkbCFDfltFields)/sizeof(XkbConfigFieldRec)) (sizeof(_XkbCFDfltFields)/sizeof(XkbConfigFieldRec))
1131
1132static XkbConfigFieldsRec _XkbCFDflts = {
1133 0, /* cfg_id */
1134 _XkbCFNumDfltFields(sizeof(_XkbCFDfltFields)/sizeof(XkbConfigFieldRec)), /* num_fields */
1135 _XkbCFDfltFields, /* fields */
1136 DefaultParser, /* parser */
1137 DefaultFinish, /* finish */
1138 NULL((void*)0), /* priv */
1139 NULL((void*)0) /* next */
1140};
1141
1142XkbConfigFieldsPtr XkbCFDflts= &_XkbCFDflts;
1143
1144/***====================================================================***/
1145
1146XkbConfigFieldsPtr
1147XkbCFDup(XkbConfigFieldsPtr fields)
1148{
1149XkbConfigFieldsPtr pNew;
1150
1151 pNew= _XkbTypedAlloc(XkbConfigFieldsRec)((XkbConfigFieldsRec *)malloc(sizeof(XkbConfigFieldsRec)));
1152 if (pNew!=NULL((void*)0)) {
1153 memcpy(pNew,fields,sizeof(XkbConfigFieldsRec));
1154 if ((pNew->fields!=NULL((void*)0))&&(pNew->num_fields>0)) {
1155 pNew->fields= _XkbTypedCalloc(pNew->num_fields,XkbConfigFieldRec)((XkbConfigFieldRec *)calloc((pNew->num_fields),sizeof(XkbConfigFieldRec
)))
;
1156 if (pNew->fields) {
1157 memcpy(fields->fields,pNew->fields,
1158 (pNew->num_fields*sizeof(XkbConfigFieldRec)));
1159 }
1160 else {
1161 _XkbFree(pNew)free(pNew);
1162 return NULL((void*)0);
1163 }
1164 }
1165 else {
1166 pNew->num_fields= 0;
1167 pNew->fields= NULL((void*)0);
1168 }
1169 pNew->next= NULL((void*)0);
1170 }
1171 return pNew;
1172}
1173
1174XkbConfigFieldsPtr
1175XkbCFFree(XkbConfigFieldsPtr fields,Boolint all)
1176{
1177XkbConfigFieldsPtr next;
1178
1179 next= NULL((void*)0);
1180 while (fields!=NULL((void*)0)) {
1181 next= fields->next;
1182 if (fields!=XkbCFDflts) {
1183 if (fields->fields) {
1184 _XkbFree(fields->fields)free(fields->fields);
1185 fields->fields= NULL((void*)0);
1186 fields->num_fields= 0;
1187 }
1188 _XkbFree(fields)free(fields);
1189 }
1190 fields= (all?next:NULL((void*)0));
1191 }
1192 return next;
1193}
1194
1195Boolint
1196XkbCFApplyRtrnValues( XkbConfigRtrnPtr rtrn,
1197 XkbConfigFieldsPtr fields,
1198 XkbDescPtr xkb)
1199{
1200Boolint ok;
1201
1202 if ((fields==NULL((void*)0))||(rtrn==NULL((void*)0))||(xkb==NULL((void*)0)))
1203 return False0;
1204 for (ok=True1;fields!=NULL((void*)0);fields=fields->next) {
1205 if (fields->finish!=NULL((void*)0))
1206 ok= (*fields->finish)(fields,xkb,rtrn,XkbCF_Apply1)&&ok;
1207 }
1208 return ok;
1209}
1210
1211XkbConfigRtrnPrivPtr
1212XkbCFAddPrivate( XkbConfigRtrnPtr rtrn,
1213 XkbConfigFieldsPtr fields,
1214 XPointer ptr)
1215{
1216XkbConfigRtrnPrivPtr priv;
1217
1218 if ((rtrn==NULL((void*)0))||(fields==NULL((void*)0)))
1219 return NULL((void*)0);
1220 priv= _XkbTypedAlloc(XkbConfigRtrnPrivRec)((XkbConfigRtrnPrivRec *)malloc(sizeof(XkbConfigRtrnPrivRec))
)
;
1221 if (priv!=NULL((void*)0)) {
1222 priv->cfg_id= fields->cfg_id;
1223 priv->priv= ptr;
1224 priv->next= rtrn->priv;
1225 rtrn->priv= priv;
1226 }
1227 return priv;
1228}
1229
1230void
1231XkbCFFreeRtrn( XkbConfigRtrnPtr rtrn,
1232 XkbConfigFieldsPtr fields,
1233 XkbDescPtr xkb)
1234{
1235XkbConfigRtrnPrivPtr tmp,next;
1236
1237 if ((fields==NULL((void*)0))||(rtrn==NULL((void*)0)))
1238 return;
1239 while (fields!=NULL((void*)0)) {
1240 if (fields->finish!=NULL((void*)0))
1241 (*fields->finish)(fields,xkb,rtrn,XkbCF_Destroy3);
1242 fields= fields->next;
1243 }
1244 for (tmp=rtrn->priv;tmp!=NULL((void*)0);tmp=next) {
1245 next= tmp->next;
1246 bzero((char *)tmp,sizeof(XkbConfigRtrnPrivRec))memset((char *)tmp,0,sizeof(XkbConfigRtrnPrivRec));
1247 _XkbFree(tmp)free(tmp);
1248 }
1249 bzero((char *)rtrn,sizeof(XkbConfigRtrnRec))memset((char *)rtrn,0,sizeof(XkbConfigRtrnRec));
1250 return;
1251}
1252
1253Boolint
1254XkbCFParse( FILE * file,
1255 XkbConfigFieldsPtr fields,
1256 XkbDescPtr xkb,
1257 XkbConfigRtrnPtr rtrn)
1258{
1259int tok;
1260XkbCFScanResultRec val;
1261XkbConfigFieldsPtr tmp;
1262
1263 if ((file==NULL((void*)0))||(fields==NULL((void*)0))||(rtrn==NULL((void*)0)))
1264 return False0;
1265 for (tok=0,tmp=fields;tmp!=NULL((void*)0);tmp=tmp->next,tok++) {
1266 fields->cfg_id= tok;
1267 }
1268 bzero((char *)rtrn,sizeof(XkbConfigRtrnRec))memset((char *)rtrn,0,sizeof(XkbConfigRtrnRec));
1269 rtrn->line= 1;
1270 rtrn->click_volume= -1;
1271 rtrn->bell_volume= -1;
1272 while ((tok=XkbCFScan(file,&val,rtrn))!=XkbCF_EOF-1) {
1273 if (tok==XkbCF_Ident11) {
1274 Boolint done;
1275 for (tmp=fields,done=False0;(tmp!=NULL((void*)0))&&(!done);tmp=tmp->next) {
1276 register int i;
1277 XkbConfigFieldPtr f;
1278
1279 for (i=0,f=tmp->fields;(i<tmp->num_fields)&&(!done);i++,f++) {
1280 if (_XkbStrCaseCmpstrcasecmp(val.str,f->field)!=0)
1281 continue;
1282 if ((*tmp->parser)(file,tmp,f,xkb,rtrn))
1283 done= True1;
1284 else goto BAILOUT;
1285 }
1286 }
1287 }
1288 else if ((tok!=XkbCF_EOL1)&&(tok!=XkbCF_Semi2)) {
1289 rtrn->error= XkbCF_MissingIdent102;
1290 goto BAILOUT;
1291 }
1292 }
1293 for (tmp=fields;tmp!=NULL((void*)0);tmp=tmp->next) {
1294 if ((tmp->finish)&&(!(*tmp->finish)(tmp,xkb,rtrn,XkbCF_Check0)))
1295 goto BAILOUT;
1296 }
1297 return True1;
1298BAILOUT:
1299 for (tmp=fields;tmp!=NULL((void*)0);tmp=tmp->next) {
1300 if (tmp->finish)
1301 (*tmp->finish)(tmp,xkb,rtrn,XkbCF_CleanUp2);
1302 }
1303 return False0;
1304}
1305
1306/*ARGSUSED*/
1307void
1308XkbCFReportError(FILE *file,char *name,int error,int line)
1309{
1310const char *msg;
1311
1312 switch(error) {
1313 case XkbCF_BadAlloc101:
1314 msg= "allocation failed\n"; break;
1315 case XkbCF_UnterminatedString100:
1316 msg= "unterminated string on line %d"; break;
1317 case XkbCF_MissingIdent102:
1318 msg= "expected identifier on line %d"; break;
1319 case XkbCF_MissingEquals103:
1320 msg= "expected '=' on line %d"; break;
1321 case XkbCF_ExpectedEOS104:
1322 msg= "expected ';' or newline on line %d"; break;
1323 case XkbCF_ExpectedBoolean105:
1324 msg= "expected a boolean value on line %d"; break;
1325 case XkbCF_ExpectedInteger106:
1326 msg= "expected a numeric value on line %d"; break;
1327 case XkbCF_ExpectedString107:
1328 msg= "expected a string on line %d"; break;
1329 case XkbCF_ExpectedModifier108:
1330 msg= "expected a modifier name on line %d"; break;
1331 case XkbCF_ExpectedControl109:
1332 msg= "expected a control name on line %d"; break;
1333 case XkbCF_ExpectedAXOption110:
1334 msg= "expected an AccessX option on line %d"; break;
1335 case XkbCF_ExpectedOperator111:
1336 msg= "expected '+' or '-' on line %d"; break;
1337 case XkbCF_ExpectedOORGroupBehavior112:
1338 msg= "expected wrap, clamp or group number on line %d"; break;
1339 default:
1340 msg= "unknown error on line %d"; break;
1341 }
1342#ifndef XKB_IN_SERVER
1343 fprintf(file,msg,line);
1344 if (name) fprintf(file," of %s\n",name);
1345 else fprintf(file,"\n");
1346#else
1347 ErrorF(msg,line);
1348 if (name) ErrorF(" of %s\n",name);
1349 else ErrorF("\n");
1350#endif
1351 return;
1352}