Modify a dependancy for install a keymap file e-tizen-data to xkb-data
[platform/upstream/libxkbcommon.git] / tools / tools-common.h
1 /*
2  * Copyright © 2012 Intel Corporation
3  *
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:
10  *
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
13  * Software.
14  *
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.
22  *
23  * Author: Daniel Stone <daniel@fooishbar.org>
24  */
25
26 #pragma once
27
28 #include "config.h"
29
30 #include <assert.h>
31
32 /* Don't use compat names in internal code. */
33 #define _XKBCOMMON_COMPAT_H
34 #include "xkbcommon/xkbcommon.h"
35 #include "xkbcommon/xkbcommon-compose.h"
36
37 #define ARRAY_SIZE(arr) ((sizeof(arr) / sizeof(*(arr))))
38
39 /* Fields that are printed in the interactive tools. */
40 enum print_state_fields {
41 #ifdef ENABLE_PRIVATE_APIS
42     PRINT_MODMAPS = (1u << 1),
43 #endif
44     PRINT_LAYOUT = (1u << 2),
45     PRINT_UNICODE = (1u << 3),
46     PRINT_ALL_FIELDS = ((PRINT_UNICODE << 1) - 1),
47     /*
48      * Fields that can be hidden with the option --short.
49      * NOTE: If this value is modified, remember to update the documentation of
50      *       the --short option in the corresponding tools.
51      */
52     PRINT_VERBOSE_FIELDS = (PRINT_LAYOUT | PRINT_UNICODE)
53 };
54 typedef uint32_t print_state_fields_mask_t;
55
56 #ifdef ENABLE_PRIVATE_APIS
57 void
58 print_keymap_modmaps(struct xkb_keymap *keymap);
59 void
60 print_keys_modmaps(struct xkb_keymap *keymap);
61 #endif
62
63 void
64 tools_print_keycode_state(struct xkb_state *state,
65                           struct xkb_compose_state *compose_state,
66                           xkb_keycode_t keycode,
67                           enum xkb_consumed_mode consumed_mode,
68                           print_state_fields_mask_t fields);
69
70 void
71 tools_print_state_changes(enum xkb_state_component changed);
72
73 void
74 tools_disable_stdin_echo(void);
75
76 void
77 tools_enable_stdin_echo(void);
78
79 int
80 tools_exec_command(const char *prefix, int argc, char **argv);
81
82 #ifdef _WIN32
83 #define setenv(varname, value, overwrite) _putenv_s((varname), (value))
84 #define unsetenv(varname) _putenv_s(varname, "")
85 #endif