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 result.
46 * @param file A list of XkbFiles, each denoting one type (e.g.
47 * XkmKeyNamesIdx, etc.)
50 CompileKeymap(XkbFile * file, XkbFileInfo * result, 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, XkbMessage));
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, XkbMessage),
92 XkbConfigText(mainType, XkbMessage));
93 ACTION("All sections after the first ignored\n");
96 else if ((1 << file->type) & (~legal))
98 ERROR2("Cannot define %s in a %s file\n",
99 XkbConfigText(file->type, XkbMessage),
100 XkbConfigText(mainType, XkbMessage));
106 case XkmSemanticsFile:
109 WSGO2("Illegal %s configuration in a %s file\n",
110 XkbConfigText(file->type, XkbMessage),
111 XkbConfigText(mainType, XkbMessage));
115 case XkmKeyNamesIndex:
116 sections[KEYCODES] = file;
119 sections[TYPES] = file;
121 case XkmSymbolsIndex:
122 sections[SYMBOLS] = file;
124 case XkmCompatMapIndex:
125 sections[COMPAT] = file;
127 case XkmGeometryIndex:
128 case XkmGeometryFile:
129 sections[GEOMETRY] = file;
131 case XkmVirtualModsIndex:
132 case XkmIndicatorsIndex:
133 WSGO1("Found an isolated %s section\n",
134 XkbConfigText(file->type, XkbMessage));
137 WSGO1("Unknown file type %d\n", file->type);
141 have |= (1 << file->type);
142 file = (XkbFile *) file->common.next;
144 /* compile the sections we have in the file one-by-one, or fail. */
147 if (ok && (sections[KEYCODES] != NULL))
148 ok = CompileKeycodes(sections[KEYCODES], result, MergeOverride);
149 if (ok && (sections[GEOMETRY] != NULL))
150 ok = CompileGeometry(sections[GEOMETRY], result, MergeOverride);
151 if (ok && (sections[TYPES] != NULL))
152 ok = CompileKeyTypes(sections[TYPES], result, MergeOverride);
153 if (ok && (sections[COMPAT] != NULL))
154 ok = CompileCompatMap(sections[COMPAT], result, MergeOverride,
156 if (ok && (sections[SYMBOLS] != NULL))
157 ok = CompileSymbols(sections[SYMBOLS], result, MergeOverride);
161 result->defined = have;
162 if (required & (~have))
166 missing = required & (~have);
167 for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
171 ERROR2("Missing %s section in a %s file\n",
172 XkbConfigText(i, XkbMessage),
173 XkbConfigText(mainType, XkbMessage));
177 ACTION1("Description of %s not compiled\n",
178 XkbConfigText(mainType, XkbMessage));
181 ok = BindIndicators(result, True, unbound, NULL);