src/xkbcomp/parseutils.h \
src/xkbcomp/path.c \
src/xkbcomp/path.h \
+ src/xkbcomp/rules.c \
+ src/xkbcomp/rules.h \
src/xkbcomp/scanner.l \
src/xkbcomp/symbols.c \
src/xkbcomp/vmod.c \
src/keysym.c \
src/map.c \
src/misc.c \
- src/rules.c \
- src/rules.h \
src/state.c \
src/text.c \
src/text.h \
+++ /dev/null
-/*
-Copyright 2009 Dan Nicholson
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the names of the authors or their
-institutions shall not be used in advertising or otherwise to promote the
-sale, use or other dealings in this Software without prior written
-authorization from the authors.
-*/
-
-#ifndef RULES_H
-#define RULES_H
-
-#include <stdio.h>
-
-#include "xkb-priv.h"
-
-/* From filecommon */
-
-typedef struct _XkbRF_VarDefs {
- const char * model;
- const char * layout;
- const char * variant;
- const char * options;
-} XkbRF_VarDefsRec,*XkbRF_VarDefsPtr;
-
-typedef struct _XkbRF_VarDesc {
- char * name;
- char * desc;
-} XkbRF_VarDescRec, *XkbRF_VarDescPtr;
-
-typedef struct _XkbRF_DescribeVars {
- size_t sz_desc;
- size_t num_desc;
- XkbRF_VarDescPtr desc;
-} XkbRF_DescribeVarsRec,*XkbRF_DescribeVarsPtr;
-
-typedef struct _XkbRF_Rule {
- int number;
- int layout_num;
- int variant_num;
- char * model;
- char * layout;
- char * variant;
- char * option;
- /* yields */
- char * keycodes;
- char * symbols;
- char * types;
- char * compat;
- char * keymap;
- unsigned flags;
-} XkbRF_RuleRec,*XkbRF_RulePtr;
-
-typedef struct _XkbRF_Group {
- int number;
- char * name;
- char * words;
-} XkbRF_GroupRec, *XkbRF_GroupPtr;
-
-#define XkbRF_PendingMatch (1L<<1)
-#define XkbRF_Option (1L<<2)
-#define XkbRF_Append (1L<<3)
-#define XkbRF_Normal (1L<<4)
-#define XkbRF_Invalid (1L<<5)
-
-typedef struct _XkbRF_Rules {
- XkbRF_DescribeVarsRec models;
- XkbRF_DescribeVarsRec layouts;
- XkbRF_DescribeVarsRec variants;
- XkbRF_DescribeVarsRec options;
-
- size_t sz_rules;
- size_t num_rules;
- XkbRF_RulePtr rules;
- size_t sz_groups;
- size_t num_groups;
- XkbRF_GroupPtr groups;
-} XkbRF_RulesRec, *XkbRF_RulesPtr;
-
-extern bool
-XkbcRF_GetComponents(XkbRF_RulesPtr rules, XkbRF_VarDefsPtr defs,
- struct xkb_component_names * names);
-
-extern bool
-XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
-
-extern void
-XkbcRF_Free(XkbRF_RulesPtr rules);
-
-#endif /* RULES_H */
"keycodes", "symbols", "types", "compat", "geometry", "keymap"
};
+typedef struct {
+ const char *model;
+ const char *layout;
+ const char *variant;
+ const char *options;
+} XkbRF_VarDefsRec, *XkbRF_VarDefsPtr;
+
typedef struct _RemapSpec {
int number;
size_t num_remap;
char * options;
} XkbRF_MultiDefsRec, *XkbRF_MultiDefsPtr;
+typedef struct _XkbRF_VarDesc {
+ char * name;
+ char * desc;
+} XkbRF_VarDescRec, *XkbRF_VarDescPtr;
+
+typedef struct _XkbRF_DescribeVars {
+ size_t sz_desc;
+ size_t num_desc;
+ XkbRF_VarDescPtr desc;
+} XkbRF_DescribeVarsRec,*XkbRF_DescribeVarsPtr;
+
+typedef struct _XkbRF_Group {
+ int number;
+ char * name;
+ char * words;
+} XkbRF_GroupRec, *XkbRF_GroupPtr;
+
+#define XkbRF_PendingMatch (1L<<1)
+#define XkbRF_Option (1L<<2)
+#define XkbRF_Append (1L<<3)
+#define XkbRF_Normal (1L<<4)
+#define XkbRF_Invalid (1L<<5)
+
+typedef struct _XkbRF_Rule {
+ int number;
+ int layout_num;
+ int variant_num;
+ char * model;
+ char * layout;
+ char * variant;
+ char * option;
+ /* yields */
+ char * keycodes;
+ char * symbols;
+ char * types;
+ char * compat;
+ char * keymap;
+ unsigned flags;
+} XkbRF_RuleRec,*XkbRF_RulePtr;
+
+typedef struct XkbRF_Rules {
+ XkbRF_DescribeVarsRec models;
+ XkbRF_DescribeVarsRec layouts;
+ XkbRF_DescribeVarsRec variants;
+ XkbRF_DescribeVarsRec options;
+
+ size_t sz_rules;
+ size_t num_rules;
+ XkbRF_RulePtr rules;
+ size_t sz_groups;
+ size_t num_groups;
+ XkbRF_GroupPtr groups;
+} XkbRF_RulesRec, *XkbRF_RulesPtr;
+
#define NDX_BUFF_SIZE 4
/***====================================================================***/
}
static bool
-MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
+MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, const XkbRF_VarDefsPtr defs)
{
memset(mdefs, 0, sizeof(XkbRF_MultiDefsRec));
mdefs->model = defs->model;
/***====================================================================***/
-bool
-XkbcRF_GetComponents( XkbRF_RulesPtr rules,
- XkbRF_VarDefsPtr defs,
- struct xkb_component_names * names)
+static bool
+XkbcRF_GetComponents(struct XkbRF_Rules *rules, const XkbRF_VarDefsPtr defs,
+ struct xkb_component_names *names)
{
XkbRF_MultiDefsRec mdefs;
return &rules->groups[rules->num_groups++];
}
-bool
-XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules)
+static XkbRF_RulesPtr
+XkbcRF_LoadRules(FILE *file)
{
InputLine line;
RemapSpec remap;
XkbRF_RuleRec trule,*rule;
XkbRF_GroupRec tgroup,*group;
+ XkbRF_RulesPtr rules;
+
+ rules = calloc(1, sizeof(*rules));
+ if (!rules)
+ return NULL;
- if (!(rules && file))
- return false;
memset(&remap, 0, sizeof(RemapSpec));
memset(&tgroup, 0, sizeof(XkbRF_GroupRec));
InitInputLine(&line);
line.num_line= 0;
}
FreeInputLine(&line);
- return true;
+ return rules;
}
static void
var->desc= NULL;
}
-void
+static void
XkbcRF_Free(XkbRF_RulesPtr rules)
{
int i;
free(rules);
}
+
+struct xkb_component_names *
+xkb_components_from_rules(struct xkb_context *ctx,
+ const struct xkb_rule_names *rmlvo)
+{
+ int i;
+ FILE *rulesFile;
+ char *rulesPath;
+ XkbRF_RulesPtr loaded;
+ struct xkb_component_names *names = NULL;
+ XkbRF_VarDefsRec defs = {
+ .model = rmlvo->model,
+ .layout = rmlvo->layout,
+ .variant = rmlvo->variant,
+ .options = rmlvo->options,
+ };
+
+ rulesFile = XkbFindFileInPath(ctx, rmlvo->rules, XkmRulesFile,
+ &rulesPath);
+ if (!rulesFile) {
+ ERROR("could not find \"%s\" rules in XKB path\n", rmlvo->rules);
+ ERROR("%d include paths searched:\n",
+ xkb_context_num_include_paths(ctx));
+ for (i = 0; i < xkb_context_num_include_paths(ctx); i++)
+ ERROR("\t%s\n", xkb_context_include_path_get(ctx, i));
+ return NULL;
+ }
+
+ loaded = XkbcRF_LoadRules(rulesFile);
+ if (!loaded) {
+ ERROR("failed to load XKB rules \"%s\"\n", rulesPath);
+ goto unwind_file;
+ }
+
+ names = calloc(1, sizeof(*names));
+ if (!names) {
+ ERROR("failed to allocate XKB components\n");
+ goto unwind_file;
+ }
+
+ if (!XkbcRF_GetComponents(loaded, &defs, names)) {
+ free(names->keymap);
+ free(names->keycodes);
+ free(names->types);
+ free(names->compat);
+ free(names->symbols);
+ free(names);
+ names = NULL;
+ ERROR("no components returned from XKB rules \"%s\"\n", rulesPath);
+ }
+
+unwind_file:
+ XkbcRF_Free(loaded);
+ if (rulesFile)
+ fclose(rulesFile);
+ free(rulesPath);
+ return names;
+}
--- /dev/null
+/*
+Copyright 2009 Dan Nicholson
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the authors or their
+institutions shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization from the authors.
+*/
+
+#ifndef RULES_H
+#define RULES_H
+
+#include "xkbcomp-priv.h"
+
+struct xkb_component_names *
+xkb_components_from_rules(struct xkb_context *ctx,
+ const struct xkb_rule_names *rmlvo);
+
+#endif /* RULES_H */
#include "xkbcomp-priv.h"
#include "rules.h"
#include "parseutils.h"
-#include "path.h"
/* Global warning level */
unsigned int warningLevel = 0;
&keycodes->common, 0);
}
-static struct xkb_component_names *
-XkbComponentsFromRules(struct xkb_context *ctx,
- const char *rules,
- const XkbRF_VarDefsPtr defs)
-{
- FILE *rulesFile = NULL;
- char *rulesPath = NULL;
- XkbRF_RulesPtr loaded = NULL;
- struct xkb_component_names * names = NULL;
- int i;
-
- rulesFile = XkbFindFileInPath(ctx, rules, XkmRulesFile, &rulesPath);
- if (!rulesFile) {
- ERROR("could not find \"%s\" rules in XKB path\n", rules);
- ERROR("%d include paths searched:\n",
- xkb_context_num_include_paths(ctx));
- for (i = 0; i < xkb_context_num_include_paths(ctx); i++)
- ERROR("\t%s\n", xkb_context_include_path_get(ctx, i));
- return NULL;
- }
-
- if (!(loaded = uTypedCalloc(1, XkbRF_RulesRec))) {
- ERROR("failed to allocate XKB rules\n");
- goto unwind_file;
- }
-
- if (!XkbcRF_LoadRules(rulesFile, loaded)) {
- ERROR("failed to load XKB rules \"%s\"\n", rulesPath);
- goto unwind_file;
- }
-
- if (!(names = uTypedCalloc(1, struct xkb_component_names))) {
- ERROR("failed to allocate XKB components\n");
- goto unwind_file;
- }
-
- if (!XkbcRF_GetComponents(loaded, defs, names)) {
- free(names->keymap);
- free(names->keycodes);
- free(names->types);
- free(names->compat);
- free(names->symbols);
- free(names);
- names = NULL;
- ERROR("no components returned from XKB rules \"%s\"\n", rulesPath);
- }
-
-unwind_file:
- XkbcRF_Free(loaded);
- if (rulesFile)
- fclose(rulesFile);
- free(rulesPath);
- return names;
-}
-
_X_EXPORT struct xkb_keymap *
xkb_map_new_from_names(struct xkb_context *ctx,
const struct xkb_rule_names *rmlvo,
enum xkb_map_compile_flags flags)
{
- XkbRF_VarDefsRec defs;
- struct xkb_component_names *names;
+ struct xkb_component_names *kkctgs;
struct xkb_keymap *keymap;
if (!rmlvo || ISEMPTY(rmlvo->rules) || ISEMPTY(rmlvo->layout)) {
return NULL;
}
- defs.model = rmlvo->model;
- defs.layout = rmlvo->layout;
- defs.variant = rmlvo->variant;
- defs.options = rmlvo->options;
-
- names = XkbComponentsFromRules(ctx, rmlvo->rules, &defs);
- if (!names) {
+ kkctgs = xkb_components_from_rules(ctx, rmlvo);
+ if (!kkctgs) {
ERROR("failed to generate XKB components from rules \"%s\"\n",
rmlvo->rules);
return NULL;
}
- keymap = xkb_map_new_from_kccgst(ctx, names, 0);
+ keymap = xkb_map_new_from_kccgst(ctx, kkctgs, 0);
- free(names->keymap);
- free(names->keycodes);
- free(names->types);
- free(names->compat);
- free(names->symbols);
- free(names);
+ free(kkctgs->keymap);
+ free(kkctgs->keycodes);
+ free(kkctgs->types);
+ free(kkctgs->compat);
+ free(kkctgs->symbols);
+ free(kkctgs);
return keymap;
}