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 ********************************************************/
34 #include "indicators.h"
41 #define MAX_SECTIONS 5
43 static XkbFile *sections[MAX_SECTIONS];
46 * Compile the given file and store the output in xkb.
47 * @param file A list of XkbFiles, each denoting one type (e.g.
48 * XkmKeyNamesIdx, etc.)
51 CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
55 unsigned required, legal;
58 LEDInfo *unbound = NULL;
60 bzero(sections, MAX_SECTIONS * sizeof(XkbFile *));
61 mainType = file->type;
62 mainName = file->name;
65 case XkmSemanticsFile:
66 required = XkmSemanticsRequired;
67 legal = XkmSemanticsLegal;
69 case XkmLayoutFile: /* standard type if setxkbmap -print */
70 required = XkmLayoutRequired;
71 legal = XkmKeymapLegal;
74 required = XkmKeymapRequired;
75 legal = XkmKeymapLegal;
78 ERROR("Cannot compile %s alone into an XKM file\n",
79 XkbcConfigText(mainType));
84 file = (XkbFile *) file->defs;
85 /* Check for duplicate entries in the input file */
86 while ((file) && (ok))
88 file->topName = mainName;
89 if ((have & (1 << file->type)) != 0)
91 ERROR("More than one %s section in a %s file\n",
92 XkbcConfigText(file->type), XkbcConfigText(mainType));
93 ACTION("All sections after the first ignored\n");
96 else if ((1 << file->type) & (~legal))
98 ERROR("Cannot define %s in a %s file\n",
99 XkbcConfigText(file->type), XkbcConfigText(mainType));
105 case XkmSemanticsFile:
108 WSGO("Illegal %s configuration in a %s file\n",
109 XkbcConfigText(file->type), XkbcConfigText(mainType));
113 case XkmKeyNamesIndex:
114 sections[KEYCODES] = file;
117 sections[TYPES] = file;
119 case XkmSymbolsIndex:
120 sections[SYMBOLS] = file;
122 case XkmCompatMapIndex:
123 sections[COMPAT] = file;
125 case XkmGeometryIndex:
126 case XkmGeometryFile:
127 sections[GEOMETRY] = file;
129 case XkmVirtualModsIndex:
130 case XkmIndicatorsIndex:
131 WSGO("Found an isolated %s section\n",
132 XkbcConfigText(file->type));
135 WSGO("Unknown file type %d\n", file->type);
139 have |= (1 << file->type);
140 file = (XkbFile *) file->common.next;
142 /* compile the sections we have in the file one-by-one, or fail. */
145 if (ok && (sections[KEYCODES] != NULL))
146 ok = CompileKeycodes(sections[KEYCODES], xkb, MergeOverride);
147 if (ok && (sections[GEOMETRY] != NULL))
148 ok = CompileGeometry(sections[GEOMETRY], xkb, MergeOverride);
149 if (ok && (sections[TYPES] != NULL))
150 ok = CompileKeyTypes(sections[TYPES], xkb, MergeOverride);
151 if (ok && (sections[COMPAT] != NULL))
152 ok = CompileCompatMap(sections[COMPAT], xkb, MergeOverride,
154 if (ok && (sections[SYMBOLS] != NULL))
155 ok = CompileSymbols(sections[SYMBOLS], xkb, MergeOverride);
160 if (required & (~have))
164 missing = required & (~have);
165 for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
169 ERROR("Missing %s section in a %s file\n",
170 XkbcConfigText(i), XkbcConfigText(mainType));
174 ACTION("Description of %s not compiled\n",
175 XkbcConfigText(mainType));
178 ok = BindIndicators(xkb, True, unbound, NULL);