1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
|
/* $XConsortium: xkbmisc.c /main/7 1996/12/27 20:53:10 kaleb $ */
/************************************************************
Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
#include <stdio.h>
#include <ctype.h>
#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
#endif
#define XK_CYRILLIC
#include <X11/Xos.h>
#include <X11/Xfuncs.h>
#ifndef XKB_IN_SERVER
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBgeom.h>
#include "XKMformat.h"
#include "XKBfileInt.h"
#else
#include "X.h"
#define NEED_EVENTS
#include <X11/keysym.h>
#include "Xproto.h"
#include "misc.h"
#include "inputstr.h"
#include "dix.h"
#include "XKBstr.h"
#define XKBSRV_NEED_FILE_FUNCS 1
#include "XKBsrv.h"
#include <X11/extensions/XKBgeom.h>
#endif
unsigned
#if NeedFunctionPrototypes
_XkbKSCheckCase(KeySym ks)
#else
_XkbKSCheckCase(ks)
KeySym ks;
#endif
{
unsigned set,rtrn;
unsigned char ch;
set= (ks & (~0xff));
ch= (char)(ks&0xff);
rtrn= 0;
switch (set) {
case 0: /* latin 1 */
if (((ch>=XK_A)&&(ch<=XK_Z))||
((ch>=XK_Agrave)&&(ch<=XK_THORN)&&(ch!=XK_multiply))) {
rtrn|= _XkbKSUpper;
}
if (((ch>=XK_a)&&(ch<=XK_z))||
((ch>=XK_agrave)&&(ch<=XK_ydiaeresis))) {
rtrn|= _XkbKSLower;
}
break;
}
return rtrn;
}
/***===================================================================***/
int
#if NeedFunctionPrototypes
_XkbStrCaseCmp(char *str1,char *str2)
#else
_XkbStrCaseCmp(str1,str2)
char * str1;
char * str2;
#endif
{
char buf1[512],buf2[512];
char c, *s;
register int n;
for (n=0, s = buf1; c = *str1++; n++) {
if (isupper(c))
c = tolower(c);
if (n>510)
break;
*s++ = c;
}
*s = '\0';
for (n=0, s = buf2; c = *str2++; n++) {
if (isupper(c))
c = tolower(c);
if (n>510)
break;
*s++ = c;
}
*s = '\0';
return (strcmp(buf1, buf2));
}
/***===================================================================***/
Bool
#if NeedFunctionPrototypes
XkbLookupGroupAndLevel( XkbDescPtr xkb,
int key,
int * mods_inout,
int * grp_inout,
int * lvl_rtrn)
#else
XkbLookupGroupAndLevel(xkb,key,mods_inout,grp_inout,lvl_rtrn)
XkbDescPtr xkb;
int key;
int * mods_inout;
int * grp_inout;
int * lvl_rtrn;
#endif
{
int nG,eG;
if ((!xkb)||(!XkbKeycodeInRange(xkb,key))||(!grp_inout))
return False;
nG= XkbKeyNumGroups(xkb,key);
eG= *grp_inout;
if ( nG==0 ) {
*grp_inout= 0;
if (lvl_rtrn!=NULL)
*lvl_rtrn= 0;
return False;
}
else if ( nG==1 ) {
eG= 0;
}
else if ( eG>=nG ) {
unsigned gI= XkbKeyGroupInfo(xkb,key);
switch (XkbOutOfRangeGroupAction(gI)) {
default:
eG %= nG;
break;
case XkbClampIntoRange:
eG = nG-1;
break;
case XkbRedirectIntoRange:
eG = XkbOutOfRangeGroupNumber(gI);
if (eG>=nG)
eG= 0;
break;
}
}
*grp_inout= eG;
if (mods_inout!=NULL) {
XkbKeyTypePtr type;
int preserve;
type = XkbKeyKeyType(xkb,key,eG);
if (lvl_rtrn!=NULL)
*lvl_rtrn= 0;
preserve= 0;
if (type->map) { /* find the shift level */
register int i;
register XkbKTMapEntryPtr entry;
for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
if ((entry->active)&&
(((*mods_inout)&type->mods.mask)==entry->mods.mask)){
if (lvl_rtrn!=NULL)
*lvl_rtrn= entry->level;
if (type->preserve)
preserve= type->preserve[i].mask;
break;
}
}
}
(*mods_inout)&= ~(type->mods.mask&(~preserve));
}
return True;
}
/***===================================================================***/
static Bool
#if NeedFunctionPrototypes
XkbWriteSectionFromName(FILE *file,char *sectionName,char *name)
#else
XkbWriteSectionFromName(file,sectionName,name)
FILE * file;
char * sectionName;
char * name;
#endif
{
fprintf(file," xkb_%-20s { include \"%s\" };\n",sectionName,name);
return True;
}
#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%')))
#define COMPLETE(n) ((n)&&(!NEED_DESC(n)))
/* ARGSUSED */
static void
#if NeedFunctionPrototypes
_AddIncl( FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
int index,
void * priv)
#else
_AddIncl(file,result,topLevel,showImplicit,index,priv)
FILE * file;
XkbFileInfo * result;
Bool topLevel;
Bool showImplicit;
int index;
void * priv;
#endif
{
if ((priv)&&(strcmp(priv,"%")!=0))
fprintf(file," include \"%s\"\n",(char *)priv);
return;
}
Bool
#if NeedFunctionPrototypes
XkbWriteXKBKeymapForNames( FILE * file,
XkbComponentNamesPtr names,
Display * dpy,
XkbDescPtr xkb,
unsigned want,
unsigned need)
#else
XkbWriteXKBKeymapForNames(file,names,dpy,xkb,want,need)
FILE * file;
XkbComponentNamesPtr names;
Display * dpy;
XkbDescPtr xkb;
unsigned want;
unsigned need;
#endif
{
char * name,*tmp;
unsigned complete;
XkbNamesPtr old_names;
int multi_section;
unsigned wantNames,wantConfig,wantDflts;
XkbFileInfo finfo;
bzero(&finfo,sizeof(XkbFileInfo));
complete= 0;
if ((name=names->keymap)==NULL) name= "default";
if (COMPLETE(names->keycodes)) complete|= XkmKeyNamesMask;
if (COMPLETE(names->types)) complete|= XkmTypesMask;
if (COMPLETE(names->compat)) complete|= XkmCompatMapMask;
if (COMPLETE(names->symbols)) complete|= XkmSymbolsMask;
if (COMPLETE(names->geometry)) complete|= XkmGeometryMask;
want|= (complete|need);
if (want&XkmSymbolsMask)
want|= XkmKeyNamesMask|XkmTypesMask;
if (want==0)
return False;
if (xkb!=NULL) {
old_names= xkb->names;
finfo.type= 0;
finfo.defined= 0;
finfo.xkb= xkb;
if (!XkbDetermineFileType(&finfo,XkbXKBFile,NULL))
return False;
}
else old_names= NULL;
wantConfig= want&(~complete);
if (xkb!=NULL) {
if (wantConfig&XkmTypesMask) {
if ((!xkb->map) || (xkb->map->num_types<XkbNumRequiredTypes))
wantConfig&= ~XkmTypesMask;
}
if (wantConfig&XkmCompatMapMask) {
if ((!xkb->compat) || (xkb->compat->num_si<1))
wantConfig&= ~XkmCompatMapMask;
}
if (wantConfig&XkmSymbolsMask) {
if ((!xkb->map) || (!xkb->map->key_sym_map))
wantConfig&= ~XkmSymbolsMask;
}
if (wantConfig&XkmIndicatorsMask) {
if (!xkb->indicators)
wantConfig&= ~XkmIndicatorsMask;
}
if (wantConfig&XkmKeyNamesMask) {
if ((!xkb->names)||(!xkb->names->keys))
wantConfig&= ~XkmKeyNamesMask;
}
if ((wantConfig&XkmGeometryMask)&&(!xkb->geom))
wantConfig&= ~XkmGeometryMask;
}
else {
wantConfig= 0;
}
complete|= wantConfig;
wantDflts= 0;
wantNames= want&(~complete);
if ((xkb!=NULL) && (old_names!=NULL)) {
if (wantNames&XkmTypesMask) {
if (old_names->types!=None) {
tmp= XkbAtomGetString(dpy,old_names->types);
names->types= _XkbDupString(tmp);
}
else {
wantDflts|= XkmTypesMask;
}
complete|= XkmTypesMask;
}
if (wantNames&XkmCompatMapMask) {
if (old_names->compat!=None) {
tmp= XkbAtomGetString(dpy,old_names->compat);
names->compat= _XkbDupString(tmp);
}
else wantDflts|= XkmCompatMapMask;
complete|= XkmCompatMapMask;
}
if (wantNames&XkmSymbolsMask) {
if (old_names->symbols==None)
return False;
tmp= XkbAtomGetString(dpy,old_names->symbols);
names->symbols= _XkbDupString(tmp);
complete|= XkmSymbolsMask;
}
if (wantNames&XkmKeyNamesMask) {
if (old_names->keycodes!=None) {
tmp= XkbAtomGetString(dpy,old_names->keycodes);
names->keycodes= _XkbDupString(tmp);
}
else wantDflts|= XkmKeyNamesMask;
complete|= XkmKeyNamesMask;
}
if (wantNames&XkmGeometryMask) {
if (old_names->geometry==None)
return False;
tmp= XkbAtomGetString(dpy,old_names->geometry);
names->geometry= _XkbDupString(tmp);
complete|= XkmGeometryMask;
wantNames&= ~XkmGeometryMask;
}
}
if (complete&XkmCompatMapMask)
complete|= XkmIndicatorsMask|XkmVirtualModsMask;
else if (complete&(XkmSymbolsMask|XkmTypesMask))
complete|= XkmVirtualModsMask;
if (need & (~complete))
return False;
if ((complete&XkmSymbolsMask)&&((XkmKeyNamesMask|XkmTypesMask)&(~complete)))
return False;
multi_section= 1;
if (((complete&XkmKeymapRequired)==XkmKeymapRequired)&&
((complete&(~XkmKeymapLegal))==0)) {
fprintf(file,"xkb_keymap \"%s\" {\n",name);
}
else if (((complete&XkmSemanticsRequired)==XkmSemanticsRequired)&&
((complete&(~XkmSemanticsLegal))==0)) {
fprintf(file,"xkb_semantics \"%s\" {\n",name);
}
else if (((complete&XkmLayoutRequired)==XkmLayoutRequired)&&
((complete&(~XkmLayoutLegal))==0)) {
fprintf(file,"xkb_layout \"%s\" {\n",name);
}
else if (XkmSingleSection(complete&(~XkmVirtualModsMask))) {
multi_section= 0;
}
else {
return False;
}
wantNames= complete&(~(wantConfig|wantDflts));
name= names->keycodes;
if (wantConfig&XkmKeyNamesMask)
XkbWriteXKBKeycodes(file,&finfo,False,False,_AddIncl,name);
else if (wantDflts&XkmKeyNamesMask)
fprintf(stderr,"Default symbols not implemented yet!\n");
else if (wantNames&XkmKeyNamesMask)
XkbWriteSectionFromName(file,"keycodes",name);
name= names->types;
if (wantConfig&XkmTypesMask)
XkbWriteXKBKeyTypes(file,&finfo,False,False,_AddIncl,name);
else if (wantDflts&XkmTypesMask)
fprintf(stderr,"Default types not implemented yet!\n");
else if (wantNames&XkmTypesMask)
XkbWriteSectionFromName(file,"types",name);
name= names->compat;
if (wantConfig&XkmCompatMapMask)
XkbWriteXKBCompatMap(file,&finfo,False,False,_AddIncl,name);
else if (wantDflts&XkmCompatMapMask)
fprintf(stderr,"Default interps not implemented yet!\n");
else if (wantNames&XkmCompatMapMask)
XkbWriteSectionFromName(file,"compatibility",name);
name= names->symbols;
if (wantConfig&XkmSymbolsMask)
XkbWriteXKBSymbols(file,&finfo,False,False,_AddIncl,name);
else if (wantNames&XkmSymbolsMask)
XkbWriteSectionFromName(file,"symbols",name);
name= names->geometry;
if (wantConfig&XkmGeometryMask)
XkbWriteXKBGeometry(file,&finfo,False,False,_AddIncl,name);
else if (wantNames&XkmGeometryMask)
XkbWriteSectionFromName(file,"geometry",name);
if (multi_section)
fprintf(file,"};\n");
return True;
}
/***====================================================================***/
/*ARGSUSED*/
Status
#if NeedFunctionPrototypes
XkbMergeFile(XkbDescPtr xkb,XkbFileInfo finfo)
#else
XkbMergeFile(xkb,finfo)
XkbDescPtr xkb;
XkbFileInfo *finfo;
#endif
{
return BadImplementation;
}
/***====================================================================***/
int
#if NeedFunctionPrototypes
XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases)
#else
XkbFindKeycodeByName(xkb,name,use_aliases)
XkbDescPtr xkb;
char * name;
Bool use_aliases;
#endif
{
register int i;
if ((!xkb)||(!xkb->names)||(!xkb->names->keys))
return 0;
for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
if (strncmp(xkb->names->keys[i].name,name,XkbKeyNameLength)==0)
return i;
}
if (!use_aliases)
return 0;
if (xkb->geom && xkb->geom->key_aliases) {
XkbKeyAliasPtr a;
a= xkb->geom->key_aliases;
for (i=0;i<xkb->geom->num_key_aliases;i++,a++) {
if (strncmp(name,a->alias,XkbKeyNameLength)==0)
return XkbFindKeycodeByName(xkb,a->real,False);
}
}
if (xkb->names && xkb->names->key_aliases) {
XkbKeyAliasPtr a;
a= xkb->names->key_aliases;
for (i=0;i<xkb->names->num_key_aliases;i++,a++) {
if (strncmp(name,a->alias,XkbKeyNameLength)==0)
return XkbFindKeycodeByName(xkb,a->real,False);
}
}
return 0;
}
unsigned
#if NeedFunctionPrototypes
XkbConvertGetByNameComponents(Bool toXkm,unsigned orig)
#else
XkbConvertGetByNameComponents(toXkm,orig)
Bool toXkm;
unsigned orig;
#endif
{
unsigned rtrn;
rtrn= 0;
if (toXkm) {
if (orig&XkbGBN_TypesMask) rtrn|= XkmTypesMask;
if (orig&XkbGBN_CompatMapMask) rtrn|= XkmCompatMapMask;
if (orig&XkbGBN_SymbolsMask) rtrn|= XkmSymbolsMask;
if (orig&XkbGBN_IndicatorMapMask) rtrn|= XkmIndicatorsMask;
if (orig&XkbGBN_KeyNamesMask) rtrn|= XkmKeyNamesMask;
if (orig&XkbGBN_GeometryMask) rtrn|= XkmGeometryMask;
}
else {
if (orig&XkmTypesMask) rtrn|= XkbGBN_TypesMask;
if (orig&XkmCompatMapMask) rtrn|= XkbGBN_CompatMapMask;
if (orig&XkmSymbolsMask) rtrn|= XkbGBN_SymbolsMask;
if (orig&XkmIndicatorsMask) rtrn|= XkbGBN_IndicatorMapMask;
if (orig&XkmKeyNamesMask) rtrn|= XkbGBN_KeyNamesMask;
if (orig&XkmGeometryMask) rtrn|= XkbGBN_GeometryMask;
if (orig!=0) rtrn|= XkbGBN_OtherNamesMask;
}
return rtrn;
}
unsigned
#if NeedFunctionPrototypes
XkbConvertXkbComponents(Bool toXkm,unsigned orig)
#else
XkbConvertXkbComponents(toXkm,orig)
Bool toXkm;
unsigned orig;
#endif
{
unsigned rtrn;
rtrn= 0;
if (toXkm) {
if (orig&XkbClientMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask;
if (orig&XkbServerMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask;
if (orig&XkbCompatMapMask) rtrn|= XkmCompatMapMask;
if (orig&XkbIndicatorMapMask) rtrn|= XkmIndicatorsMask;
if (orig&XkbNamesMask) rtrn|= XkmKeyNamesMask;
if (orig&XkbGeometryMask) rtrn|= XkmGeometryMask;
}
else {
if (orig!=0) rtrn|= XkbNamesMask;
if (orig&XkmTypesMask) rtrn|= XkbClientMapMask;
if (orig&XkmCompatMapMask)
rtrn|= XkbCompatMapMask|XkbIndicatorMapMask;
if (orig&XkmSymbolsMask) rtrn|=XkbClientMapMask|XkbServerMapMask;
if (orig&XkmIndicatorsMask) rtrn|= XkbIndicatorMapMask;
if (orig&XkmKeyNamesMask)
rtrn|= XkbNamesMask|XkbIndicatorMapMask;
if (orig&XkmGeometryMask) rtrn|= XkbGeometryMask;
}
return rtrn;
}
Bool
#if NeedFunctionPrototypes
XkbDetermineFileType(XkbFileInfoPtr finfo,int format,int *opts_missing)
#else
XkbDetermineFileType(finfo,format,opts_missing)
XkbFileInfoPtr finfo;
int format;
int * opts_missing;
#endif
{
unsigned present;
XkbDescPtr xkb;
if ((!finfo)||(!finfo->xkb))
return False;
if (opts_missing)
*opts_missing= 0;
xkb= finfo->xkb;
present= 0;
if ((xkb->names)&&(xkb->names->keys)) present|= XkmKeyNamesMask;
if ((xkb->map)&&(xkb->map->types)) present|= XkmTypesMask;
if (xkb->compat) present|= XkmCompatMapMask;
if ((xkb->map)&&(xkb->map->num_syms>1)) present|= XkmSymbolsMask;
if (xkb->indicators) present|= XkmIndicatorsMask;
if (xkb->geom) present|= XkmGeometryMask;
if (!present)
return False;
else switch (present) {
case XkmKeyNamesMask:
finfo->type= XkmKeyNamesIndex;
finfo->defined= present;
return True;
case XkmTypesMask:
finfo->type= XkmTypesIndex;
finfo->defined= present;
return True;
case XkmCompatMapMask:
finfo->type= XkmCompatMapIndex;
finfo->defined= present;
return True;
case XkmSymbolsMask:
if (format!=XkbXKMFile) {
finfo->type= XkmSymbolsIndex;
finfo->defined= present;
return True;
}
break;
case XkmGeometryMask:
finfo->type= XkmGeometryIndex;
finfo->defined= present;
return True;
}
if ((present&(~XkmSemanticsLegal))==0) {
if ((XkmSemanticsRequired&present)==XkmSemanticsRequired) {
if (opts_missing)
*opts_missing= XkmSemanticsOptional&(~present);
finfo->type= XkmSemanticsFile;
finfo->defined= present;
return True;
}
}
else if ((present&(~XkmLayoutLegal))==0) {
if ((XkmLayoutRequired&present)==XkmLayoutRequired) {
if (opts_missing)
*opts_missing= XkmLayoutOptional&(~present);
finfo->type= XkmLayoutFile;
finfo->defined= present;
return True;
}
}
else if ((present&(~XkmKeymapLegal))==0) {
if ((XkmKeymapRequired&present)==XkmKeymapRequired) {
if (opts_missing)
*opts_missing= XkmKeymapOptional&(~present);
finfo->type= XkmKeymapFile;
finfo->defined= present;
return True;
}
}
return False;
}
/* all latin-1 alphanumerics, plus parens, slash, minus, underscore and */
/* wildcards */
static unsigned char componentSpecLegal[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x83,
0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff
};
void
#if NeedFunctionPrototypes
XkbEnsureSafeMapName(char *name)
#else
XkbEnsureSafeMapName(name)
char *name;
#endif
{
if (name==NULL)
return;
while (*name!='\0') {
if ((componentSpecLegal[(*name)/8]&(1<<((*name)%8)))==0)
*name= '_';
name++;
}
return;
}
/***====================================================================***/
#define UNMATCHABLE(c) (((c)=='(')||((c)==')')||((c)=='/'))
Bool
#if NeedFunctionPrototypes
XkbNameMatchesPattern(char *name,char *ptrn)
#else
XkbNameMatchesPattern(name,ptrn)
char * name;
char * ptrn;
#endif
{
while (ptrn[0]!='\0') {
if (name[0]=='\0') {
if (ptrn[0]=='*') {
ptrn++;
continue;
}
return False;
}
if (ptrn[0]=='?') {
if (UNMATCHABLE(name[0]))
return False;
}
else if (ptrn[0]=='*') {
if ((!UNMATCHABLE(name[0]))&&XkbNameMatchesPattern(name+1,ptrn))
return True;
return XkbNameMatchesPattern(name,ptrn+1);
}
else if (ptrn[0]!=name[0])
return False;
name++;
ptrn++;
}
/* if we get here, the pattern is exhausted (-:just like me:-) */
return (name[0]=='\0');
}
|