Remove all non-public API from XKBcommon.h header
[platform/upstream/libxkbcommon.git] / test / xkey.c
1 #include "xkbmisc.h"
2 #include "X11/extensions/XKBcommon.h"
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
6
7 static void print_keysym(const char *s)
8 {
9     KeySym ks = XkbcStringToKeysym(s);
10     if (ks == NoSymbol)
11         printf("NoSymbol\n");
12     else
13         printf("0x%lX\n", ks);
14 }
15
16 static void print_string(KeySym ks)
17 {
18     char *s = XkbcKeysymToString(ks);
19     printf("%s\n", s ? s : "NULL");
20 }
21
22 int main(int argc, char *argv[])
23 {
24     int mode;
25     KeySym sym;
26
27     if (argc < 3) {
28         fprintf(stderr, "error: not enough arguments\n");
29         exit(EXIT_FAILURE);
30     }
31
32     if (strcmp(argv[1], "-k") == 0) {
33         mode = 0;
34         sym = strtoul(argv[2], NULL, 16);
35     }
36     else if (strcmp(argv[1], "-s") == 0)
37         mode = 1;
38     else {
39         fprintf(stderr, "error: unrecognized argument \"%s\"\n", argv[1]);
40         exit(EXIT_FAILURE);
41     }
42
43     if (mode == 0)
44         print_string(sym);
45     else
46         print_keysym(argv[2]);
47
48     return 0;
49 }