| 1 |
/* |
| 2 |
* Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. |
| 3 |
* SPDX-License-Identifier: HPND |
| 4 |
*/ |
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include "config.h" |
| 8 |
|
| 9 |
#include "keymap.h" |
| 10 |
#include "ast.h" |
| 11 |
#include "scanner-utils.h" |
| 12 |
|
| 13 |
char * |
| 14 |
text_v1_keymap_get_as_string(struct xkb_keymap *keymap, |
| 15 |
enum xkb_keymap_format format, |
| 16 |
enum xkb_keymap_serialize_flags flags); |
| 17 |
|
| 18 |
XkbFile * |
| 19 |
XkbParseFile(struct xkb_context *ctx, FILE *file, |
| 20 |
const char *file_name, const char *map); |
| 21 |
bool |
| 22 |
XkbParseStringInit(struct xkb_context *ctx, struct scanner *scanner, |
| 23 |
const char *string, size_t len, |
| 24 |
const char *file_name, const char *map); |
| 25 |
|
| 26 |
XkbFile * |
| 27 |
XkbParseString(struct xkb_context *ctx, |
| 28 |
const char *string, size_t len, |
| 29 |
const char *file_name, const char *map); |
| 30 |
|
| 31 |
bool |
| 32 |
XkbParseStringNext(struct xkb_context *ctx, struct scanner *scanner, |
| 33 |
const char *map, XkbFile **out); |
| 34 |
|
| 35 |
void |
| 36 |
FreeXkbFile(XkbFile *file); |
| 37 |
|
| 38 |
XkbFile * |
| 39 |
XkbFileFromComponents(struct xkb_context *ctx, |
| 40 |
const struct xkb_component_names *kkctgs); |
| 41 |
|
| 42 |
bool |
| 43 |
CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap); |
| 44 |
|
| 45 |
bool |
| 46 |
CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap); |
| 47 |
|
| 48 |
bool |
| 49 |
CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap); |
| 50 |
|
| 51 |
bool |
| 52 |
CompileSymbols(XkbFile *file, struct xkb_keymap *keymap); |
| 53 |
|
| 54 |
bool |
| 55 |
CompileKeymap(XkbFile *file, struct xkb_keymap *keymap); |
| 56 |
|
| 57 |
extern const struct xkb_sym_interpret default_interpret; |
| 58 |
|
| 59 |
/***====================================================================***/ |
| 60 |
|
| 61 |
static inline bool |
| 62 |
ReportNotArray(struct xkb_context *ctx, const char *type, const char *field, |
| 63 |
const char *name) |
| 64 |
{ |
| 65 |
log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE, |
| 66 |
"The %s %s field is not an array; " |
| 67 |
"Ignoring illegal assignment in %s\n", |
| 68 |
type, field, name); |
| 69 |
return false; |
| 70 |
} |
| 71 |
|
| 72 |
static inline bool |
| 73 |
ReportShouldBeArray(struct xkb_context *ctx, const char *type, |
| 74 |
const char *field, const char *name) |
| 75 |
{ |
| 76 |
log_err(ctx, XKB_ERROR_EXPECTED_ARRAY_ENTRY, |
| 77 |
"Missing subscript for %s %s; " |
| 78 |
"Ignoring illegal assignment in %s\n", |
| 79 |
type, field, name); |
| 80 |
return false; |
| 81 |
} |
| 82 |
|
| 83 |
static inline bool |
| 84 |
ReportBadType(struct xkb_context *ctx, xkb_message_code_t code, const char *type, |
| 85 |
const char *field, const char *name, const char *wanted) |
| 86 |
{ |
| 87 |
log_err(ctx, code, |
| 88 |
"The %s %s field must be a %s; " |
| 89 |
"Ignoring illegal assignment in %s\n", |
| 90 |
type, field, wanted, name); |
| 91 |
return false; |
| 92 |
} |
| 93 |
|
| 94 |
static inline bool |
| 95 |
ReportBadField(struct xkb_context *ctx, const char *type, const char *field, |
| 96 |
const char *name) |
| 97 |
{ |
| 98 |
log_err(ctx, XKB_LOG_MESSAGE_NO_ID, |
| 99 |
"Unknown %s field \"%s\" in %s; " |
| 100 |
"Ignoring assignment to unknown field in %s\n", |
| 101 |
type, field, name, name); |
| 102 |
return false; |
| 103 |
} |
| 104 |
|
| 105 |
static inline const char* |
| 106 |
safe_map_name(XkbFile *file) |
| 107 |
{ |
| 108 |
return file->name ? file->name : "(unnamed map)"; |
| 109 |
} |