2 * Copyright © 2018 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
32 #include "xkbcommon/xkbcommon.h"
34 static bool print = false;
39 printf("Usage: %s [--print] [--rules <rules>] [--layout <layout>] [--variant <variant>] [--options <option>]\n",
41 printf("This tool tests the compilation from RMLVO to a keymap.\n");
42 printf("--print print the resulting keymap\n");
46 parse_options(int argc, char **argv, struct xkb_rule_names *names)
56 static struct option opts[] = {
57 {"help", no_argument, 0, 'h'},
58 {"print", no_argument, 0, OPT_PRINT},
59 {"rules", required_argument, 0, OPT_RULES},
60 {"model", required_argument, 0, OPT_MODEL},
61 {"layout", required_argument, 0, OPT_LAYOUT},
62 {"variant", required_argument, 0, OPT_VARIANT},
63 {"options", required_argument, 0, OPT_OPTION},
70 c = getopt_long(argc, argv, "h", opts, &option_index);
82 names->rules = optarg;
85 names->model = optarg;
88 names->layout = optarg;
91 names->variant = optarg;
94 names->options = optarg;
107 main(int argc, char **argv)
109 struct xkb_context *ctx;
110 struct xkb_keymap *keymap;
111 struct xkb_rule_names names = {
125 if (!parse_options(argc, argv, &names))
128 ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
131 keymap = xkb_keymap_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS);
132 rc = (keymap == NULL);
134 if (rc == 0 && print)
135 printf("%s\n", xkb_keymap_get_as_string(keymap,
136 XKB_KEYMAP_FORMAT_TEXT_V1));
138 xkb_keymap_unref(keymap);
139 xkb_context_unref(ctx);