projects
/
profile
/
ivi
/
libxkbcommon.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Create path.h for the path.c functions
[profile/ivi/libxkbcommon.git]
/
src
/
xkbcomp
/
xkbcomp.c
diff --git
a/src/xkbcomp/xkbcomp.c
b/src/xkbcomp/xkbcomp.c
index
7ff22e1
..
68e180f
100644
(file)
--- a/
src/xkbcomp/xkbcomp.c
+++ b/
src/xkbcomp/xkbcomp.c
@@
-24,14
+24,10
@@
sale, use or other dealings in this Software without prior written
authorization from the authors.
*/
authorization from the authors.
*/
-#include <limits.h>
-#include "xkbcomp.h"
-#include "xkballoc.h"
-#include "xkbrules.h"
-#include "xkbpath.h"
-#include "xkbmisc.h"
+#include "xkbcomp-priv.h"
+#include "rules.h"
#include "parseutils.h"
#include "parseutils.h"
-#include "
utils
.h"
+#include "
path
.h"
/* Global warning level */
unsigned int warningLevel = 0;
/* Global warning level */
unsigned int warningLevel = 0;
@@
-39,33
+35,38
@@
unsigned int warningLevel = 0;
#define ISEMPTY(str) (!(str) || (strlen(str) == 0))
static XkbFile *
#define ISEMPTY(str) (!(str) || (strlen(str) == 0))
static XkbFile *
-XkbKeymapFileFromComponents(const struct xkb_component_names * ktcsg)
+XkbKeymapFileFromComponents(struct xkb_context *ctx,
+ const struct xkb_component_names *ktcsg)
{
XkbFile *keycodes, *types, *compat, *symbols;
IncludeStmt *inc;
inc = IncludeCreate(ktcsg->keycodes, MergeDefault);
{
XkbFile *keycodes, *types, *compat, *symbols;
IncludeStmt *inc;
inc = IncludeCreate(ktcsg->keycodes, MergeDefault);
- keycodes = CreateXKBFile(XkmKeyNamesIndex, NULL, (ParseCommon *)inc, 0);
+ keycodes = CreateXKBFile(ctx, XkmKeyNamesIndex, NULL,
+ (ParseCommon *)inc, 0);
inc = IncludeCreate(ktcsg->types, MergeDefault);
inc = IncludeCreate(ktcsg->types, MergeDefault);
- types = CreateXKBFile(XkmTypesIndex, NULL, (ParseCommon *)inc, 0);
+ types = CreateXKBFile(ctx, XkmTypesIndex, NULL,
+ (ParseCommon *)inc, 0);
AppendStmt(&keycodes->common, &types->common);
inc = IncludeCreate(ktcsg->compat, MergeDefault);
AppendStmt(&keycodes->common, &types->common);
inc = IncludeCreate(ktcsg->compat, MergeDefault);
- compat = CreateXKBFile(XkmCompatMapIndex, NULL, (ParseCommon *)inc, 0);
+ compat = CreateXKBFile(ctx, XkmCompatMapIndex, NULL,
+ (ParseCommon *)inc, 0);
AppendStmt(&keycodes->common, &compat->common);
inc = IncludeCreate(ktcsg->symbols, MergeDefault);
AppendStmt(&keycodes->common, &compat->common);
inc = IncludeCreate(ktcsg->symbols, MergeDefault);
- symbols = CreateXKBFile(XkmSymbolsIndex, NULL, (ParseCommon *)inc, 0);
+ symbols = CreateXKBFile(ctx, XkmSymbolsIndex, NULL,
+ (ParseCommon *)inc, 0);
AppendStmt(&keycodes->common, &symbols->common);
AppendStmt(&keycodes->common, &symbols->common);
- return CreateXKBFile(XkmKeymapFile,
+ return CreateXKBFile(
ctx,
XkmKeymapFile,
ktcsg->keymap ? ktcsg->keymap : strdup(""),
&keycodes->common, 0);
}
static struct xkb_component_names *
ktcsg->keymap ? ktcsg->keymap : strdup(""),
&keycodes->common, 0);
}
static struct xkb_component_names *
-XkbComponentsFromRules(struct xkb_context *c
ontext
,
+XkbComponentsFromRules(struct xkb_context *c
tx
,
const char *rules,
const XkbRF_VarDefsPtr defs)
{
const char *rules,
const XkbRF_VarDefsPtr defs)
{
@@
-73,10
+74,15
@@
XkbComponentsFromRules(struct xkb_context *context,
char *rulesPath = NULL;
XkbRF_RulesPtr loaded = NULL;
struct xkb_component_names * names = NULL;
char *rulesPath = NULL;
XkbRF_RulesPtr loaded = NULL;
struct xkb_component_names * names = NULL;
+ int i;
- rulesFile = XkbFindFileInPath(c
ontext
, rules, XkmRulesFile, &rulesPath);
+ rulesFile = XkbFindFileInPath(c
tx
, rules, XkmRulesFile, &rulesPath);
if (!rulesFile) {
ERROR("could not find \"%s\" rules in XKB path\n", rules);
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;
}
return NULL;
}
@@
-114,13
+120,14
@@
unwind_file:
return names;
}
return names;
}
-struct xkb_keymap *
-xkb_map_new_from_names(struct xkb_context *context,
- const struct xkb_rule_names *rmlvo)
+_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;
{
XkbRF_VarDefsRec defs;
struct xkb_component_names *names;
- struct xkb_keymap *
xkb
;
+ struct xkb_keymap *
keymap
;
if (!rmlvo || ISEMPTY(rmlvo->rules) || ISEMPTY(rmlvo->layout)) {
ERROR("rules and layout required to generate XKB keymap\n");
if (!rmlvo || ISEMPTY(rmlvo->rules) || ISEMPTY(rmlvo->layout)) {
ERROR("rules and layout required to generate XKB keymap\n");
@@
-132,14
+139,14
@@
xkb_map_new_from_names(struct xkb_context *context,
defs.variant = rmlvo->variant;
defs.options = rmlvo->options;
defs.variant = rmlvo->variant;
defs.options = rmlvo->options;
- names = XkbComponentsFromRules(c
ontext
, rmlvo->rules, &defs);
+ names = XkbComponentsFromRules(c
tx
, rmlvo->rules, &defs);
if (!names) {
ERROR("failed to generate XKB components from rules \"%s\"\n",
rmlvo->rules);
return NULL;
}
if (!names) {
ERROR("failed to generate XKB components from rules \"%s\"\n",
rmlvo->rules);
return NULL;
}
-
xkb = xkb_map_new_from_kccgst(context, names
);
+
keymap = xkb_map_new_from_kccgst(ctx, names, 0
);
free(names->keymap);
free(names->keycodes);
free(names->keymap);
free(names->keycodes);
@@
-148,7
+155,7
@@
xkb_map_new_from_names(struct xkb_context *context,
free(names->symbols);
free(names);
free(names->symbols);
free(names);
- return
xkb
;
+ return
keymap
;
}
static XkbFile *
}
static XkbFile *
@@
-186,39
+193,34
@@
XkbChooseMap(XkbFile *file, const char *name)
}
static struct xkb_keymap *
}
static struct xkb_keymap *
-compile_keymap(struct xkb_context *c
ontext
, XkbFile *file)
+compile_keymap(struct xkb_context *c
tx
, XkbFile *file)
{
XkbFile *mapToUse;
{
XkbFile *mapToUse;
- struct xkb_keymap *
xkb
= NULL;
+ struct xkb_keymap *
keymap
= NULL;
/* Find map to use */
mapToUse = XkbChooseMap(file, NULL);
if (!mapToUse)
goto err;
/* Find map to use */
mapToUse = XkbChooseMap(file, NULL);
if (!mapToUse)
goto err;
- switch (mapToUse->type) {
- case XkmSemanticsFile:
- case XkmLayoutFile:
- case XkmKeymapFile:
- break;
- default:
+ if (mapToUse->type != XkmKeymapFile) {
ERROR("file type %d not handled\n", mapToUse->type);
goto err;
}
ERROR("file type %d not handled\n", mapToUse->type);
goto err;
}
-
xkb = CompileKeymap(context, mapToUse, MergeReplac
e);
- if (!
xkb
)
+
keymap = CompileKeymap(ctx, mapToUs
e);
+ if (!
keymap
)
goto err;
err:
FreeXKBFile(file);
goto err;
err:
FreeXKBFile(file);
- XkbcFreeAllAtoms();
- return xkb;
+ return keymap;
}
}
-struct xkb_keymap *
-xkb_map_new_from_kccgst(struct xkb_context *context,
- const struct xkb_component_names *kccgst)
+_X_EXPORT struct xkb_keymap *
+xkb_map_new_from_kccgst(struct xkb_context *ctx,
+ const struct xkb_component_names *kccgst,
+ enum xkb_map_compile_flags flags)
{
XkbFile *file;
{
XkbFile *file;
@@
-247,18
+249,19
@@
xkb_map_new_from_kccgst(struct xkb_context *context,
return NULL;
}
return NULL;
}
- if (!(file = XkbKeymapFileFromComponents(kccgst))) {
+ if (!(file = XkbKeymapFileFromComponents(
ctx,
kccgst))) {
ERROR("failed to generate parsed XKB file from components\n");
return NULL;
}
ERROR("failed to generate parsed XKB file from components\n");
return NULL;
}
- return compile_keymap(c
ontext
, file);
+ return compile_keymap(c
tx
, file);
}
}
-struct xkb_keymap *
-xkb_map_new_from_string(struct xkb_context *c
ontext
,
+
_X_EXPORT
struct xkb_keymap *
+xkb_map_new_from_string(struct xkb_context *c
tx
,
const char *string,
const char *string,
- enum xkb_keymap_format format)
+ enum xkb_keymap_format format,
+ enum xkb_map_compile_flags flags)
{
XkbFile *file;
{
XkbFile *file;
@@
-272,58
+275,52
@@
xkb_map_new_from_string(struct xkb_context *context,
return NULL;
}
return NULL;
}
- if (!XKBParseString(
string, "input", &file) || !file
) {
+ if (!XKBParseString(
ctx, string, "input", &file)
) {
ERROR("failed to parse input xkb file\n");
return NULL;
}
ERROR("failed to parse input xkb file\n");
return NULL;
}
- return compile_keymap(c
ontext
, file);
+ return compile_keymap(c
tx
, file);
}
}
-struct xkb_keymap *
-xkb_map_new_from_fd(struct xkb_context *context,
- int fd,
- enum xkb_keymap_format format)
+_X_EXPORT struct xkb_keymap *
+xkb_map_new_from_file(struct xkb_context *ctx,
+ FILE *file,
+ enum xkb_keymap_format format,
+ enum xkb_map_compile_flags flags)
{
{
- XkbFile *file;
- FILE *fptr;
+ XkbFile *xkb_file;
if (format != XKB_KEYMAP_FORMAT_TEXT_V1) {
ERROR("unsupported keymap format %d\n", format);
return NULL;
}
if (format != XKB_KEYMAP_FORMAT_TEXT_V1) {
ERROR("unsupported keymap format %d\n", format);
return NULL;
}
- if (
fd < 0
) {
+ if (
!file
) {
ERROR("no file specified to generate XKB keymap\n");
ERROR("no file specified to generate XKB keymap\n");
- return NULL;
- }
-
- fptr = fdopen(fd, "r");
- if (!fptr) {
- ERROR("couldn't associate fd with file pointer\n");
return NULL;
}
return NULL;
}
- if (!XKBParseFile(
fptr, "(unknown file)", &file) || !file
) {
+ if (!XKBParseFile(
ctx, file, "(unknown file)", &xkb_file)
) {
ERROR("failed to parse input xkb file\n");
ERROR("failed to parse input xkb file\n");
- return NULL;
+
return NULL;
}
}
- return compile_keymap(c
ontext,
file);
+ return compile_keymap(c
tx, xkb_
file);
}
}
-struct xkb_keymap *
-xkb_map_ref(struct xkb_keymap *
xkb
)
+
_X_EXPORT
struct xkb_keymap *
+xkb_map_ref(struct xkb_keymap *
keymap
)
{
{
-
xkb
->refcnt++;
- return
xkb
;
+
keymap
->refcnt++;
+ return
keymap
;
}
}
-void
-xkb_map_unref(struct xkb_keymap *
xkb
)
+
_X_EXPORT
void
+xkb_map_unref(struct xkb_keymap *
keymap
)
{
{
- if (--
xkb
->refcnt > 0)
+ if (--
keymap
->refcnt > 0)
return;
return;
- XkbcFreeKeyboard(
xkb
);
+ XkbcFreeKeyboard(
keymap
);
}
}