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"
37 * Compile the given file and store the output in xkb.
38 * @param file A list of XkbFiles, each denoting one type (e.g.
39 * XkmKeyNamesIdx, etc.)
42 CompileKeymap(XkbFile *file, unsigned merge)
46 unsigned required, legal;
49 LEDInfo *unbound = NULL;
50 struct xkb_desc *xkb = XkbcAllocKeyboard();
61 memset(§ions, 0, sizeof(sections));
62 mainType = file->type;
63 mainName = file->name;
66 case XkmSemanticsFile:
67 required = XkmSemanticsRequired;
68 legal = XkmSemanticsLegal;
70 case XkmLayoutFile: /* standard type if setxkbmap -print */
71 required = XkmLayoutRequired;
72 legal = XkmKeymapLegal;
75 required = XkmKeyNamesIndex | XkmTypesIndex | XkmSymbolsIndex | \
76 XkmCompatMapIndex | XkmVirtualModsIndex;
77 legal = XkmKeymapLegal;
80 ERROR("Cannot compile %s alone into an XKM file\n",
81 XkbcConfigText(mainType));
86 /* Check for duplicate entries in the input file */
87 for (file = (XkbFile *) file->defs; file; file = (XkbFile *) file->common.next)
89 if (file->topName != mainName) {
91 file->topName = strdup(mainName);
94 if ((have & (1 << file->type)) != 0)
96 ERROR("More than one %s section in a %s file\n",
97 XkbcConfigText(file->type), XkbcConfigText(mainType));
98 ACTION("All sections after the first ignored\n");
101 else if ((1 << file->type) & (~legal))
103 ERROR("Cannot define %s in a %s file\n",
104 XkbcConfigText(file->type), XkbcConfigText(mainType));
110 case XkmKeyNamesIndex:
111 sections.keycodes = file;
114 sections.types = file;
116 case XkmSymbolsIndex:
117 sections.symbols = file;
119 case XkmCompatMapIndex:
120 sections.compat = file;
122 case XkmGeometryIndex:
124 case XkmVirtualModsIndex:
125 case XkmIndicatorsIndex:
126 WSGO("Found an isolated %s section\n", XkbcConfigText(file->type));
130 WSGO("Unknown file type %d\n", file->type);
133 case XkmSemanticsFile:
136 WSGO("Illegal %s configuration in a %s file\n",
137 XkbcConfigText(file->type), XkbcConfigText(mainType));
142 have |= (1 << file->type);
145 if (required & (~have))
149 missing = required & (~have);
150 for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
154 ERROR("Required section %s missing from keymap\n", XkbcConfigText(i));
161 /* compile the sections we have in the file one-by-one, or fail. */
162 if (sections.keycodes != NULL &&
163 !CompileKeycodes(sections.keycodes, xkb, MergeOverride))
165 ERROR("Failed to compile keycodes\n");
168 if (sections.types != NULL &&
169 !CompileKeyTypes(sections.types, xkb, MergeOverride))
171 ERROR("Failed to compile key types\n");
174 if (sections.compat != NULL &&
175 !CompileCompatMap(sections.compat, xkb, MergeOverride, &unbound))
177 ERROR("Failed to compile compat map\n");
180 if (sections.symbols != NULL &&
181 !CompileSymbols(sections.symbols, xkb, MergeOverride))
183 ERROR("Failed to compile symbols\n");
189 ok = BindIndicators(xkb, True, unbound, NULL);
196 ACTION("Failed to compile keymap\n");
198 xkb_free_keymap(xkb);