1 /************************************************************
2 Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
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.
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.
25 ********************************************************/
33 #include "indicators.h"
40 #define MAX_SECTIONS 5
42 static XkbFile *sections[MAX_SECTIONS];
45 * Compile the given file and store the output in xkb.
46 * @param file A list of XkbFiles, each denoting one type (e.g.
47 * XkmKeyNamesIdx, etc.)
50 CompileKeymap(XkbFile *file, XkbcDescPtr xkb, unsigned merge)
54 unsigned required, legal;
57 LEDInfo *unbound = NULL;
59 bzero(sections, MAX_SECTIONS * sizeof(XkbFile *));
60 mainType = file->type;
61 mainName = file->name;
64 case XkmSemanticsFile:
65 required = XkmSemanticsRequired;
66 legal = XkmSemanticsLegal;
68 case XkmLayoutFile: /* standard type if setxkbmap -print */
69 required = XkmLayoutRequired;
70 legal = XkmKeymapLegal;
73 required = XkmKeymapRequired;
74 legal = XkmKeymapLegal;
77 ERROR1("Cannot compile %s alone into an XKM file\n",
78 XkbConfigText(mainType));
83 file = (XkbFile *) file->defs;
84 /* Check for duplicate entries in the input file */
85 while ((file) && (ok))
87 file->topName = mainName;
88 if ((have & (1 << file->type)) != 0)
90 ERROR2("More than one %s section in a %s file\n",
91 XkbConfigText(file->type), XkbConfigText(mainType));
92 ACTION("All sections after the first ignored\n");
95 else if ((1 << file->type) & (~legal))
97 ERROR2("Cannot define %s in a %s file\n",
98 XkbConfigText(file->type), XkbConfigText(mainType));
104 case XkmSemanticsFile:
107 WSGO2("Illegal %s configuration in a %s file\n",
108 XkbConfigText(file->type), XkbConfigText(mainType));
112 case XkmKeyNamesIndex:
113 sections[KEYCODES] = file;
116 sections[TYPES] = file;
118 case XkmSymbolsIndex:
119 sections[SYMBOLS] = file;
121 case XkmCompatMapIndex:
122 sections[COMPAT] = file;
124 case XkmGeometryIndex:
125 case XkmGeometryFile:
126 sections[GEOMETRY] = file;
128 case XkmVirtualModsIndex:
129 case XkmIndicatorsIndex:
130 WSGO1("Found an isolated %s section\n",
131 XkbConfigText(file->type));
134 WSGO1("Unknown file type %d\n", file->type);
138 have |= (1 << file->type);
139 file = (XkbFile *) file->common.next;
141 /* compile the sections we have in the file one-by-one, or fail. */
144 if (ok && (sections[KEYCODES] != NULL))
145 ok = CompileKeycodes(sections[KEYCODES], xkb, MergeOverride);
146 if (ok && (sections[GEOMETRY] != NULL))
147 ok = CompileGeometry(sections[GEOMETRY], xkb, MergeOverride);
148 if (ok && (sections[TYPES] != NULL))
149 ok = CompileKeyTypes(sections[TYPES], xkb, MergeOverride);
150 if (ok && (sections[COMPAT] != NULL))
151 ok = CompileCompatMap(sections[COMPAT], xkb, MergeOverride,
153 if (ok && (sections[SYMBOLS] != NULL))
154 ok = CompileSymbols(sections[SYMBOLS], xkb, MergeOverride);
159 if (required & (~have))
163 missing = required & (~have);
164 for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
168 ERROR2("Missing %s section in a %s file\n",
169 XkbConfigText(i), XkbConfigText(mainType));
173 ACTION1("Description of %s not compiled\n",
174 XkbConfigText(mainType));
177 ok = BindIndicators(xkb, True, unbound, NULL);