Fix warnings from -Wincompatible-pointer-types
Signed-off-by: Oleg Bulatov <oleg@bulatov.me>
Oleg Bulatov
4 years ago
160 | 160 | } |
161 | 161 | |
162 | 162 | static int |
163 | findfile_by_fullname(const char *fnam, char **suffixes, struct kbdfile *fp) | |
163 | findfile_by_fullname(const char *fnam, const char *const *suffixes, struct kbdfile *fp) | |
164 | 164 | { |
165 | 165 | int i; |
166 | 166 | struct stat st; |
199 | 199 | } |
200 | 200 | |
201 | 201 | static int |
202 | filecmp(const char *fname, char *name, char **suf, unsigned int *index, struct decompressor **d) | |
202 | filecmp(const char *fname, const char *name, const char *const *suf, unsigned int *index, struct decompressor **d) | |
203 | 203 | { |
204 | 204 | /* Does d_name start right? */ |
205 | 205 | char *p = name; |
241 | 241 | } |
242 | 242 | |
243 | 243 | static int |
244 | findfile_in_dir(const char *fnam, const char *dir, const int recdepth, char **suf, struct kbdfile *fp) | |
244 | findfile_in_dir(const char *fnam, const char *dir, const int recdepth, const char *const *suf, struct kbdfile *fp) | |
245 | 245 | { |
246 | 246 | char errbuf[200]; |
247 | 247 | char *ff, *fdir, *path; |
372 | 372 | } |
373 | 373 | |
374 | 374 | int |
375 | kbdfile_find(char *fnam, char **dirpath, char **suffixes, struct kbdfile *fp) | |
375 | kbdfile_find(const char *fnam, const char *const *dirpath, const char *const *suffixes, struct kbdfile *fp) | |
376 | 376 | { |
377 | 377 | int rc, i; |
378 | 378 |
36 | 36 | struct kbdfile *kbdfile_open(struct kbdfile_ctx *ctx, const char *filename); |
37 | 37 | void kbdfile_close(struct kbdfile *fp); |
38 | 38 | |
39 | int kbdfile_find(char *fnam, char **dirpath, char **suffixes, struct kbdfile *fp); | |
39 | int kbdfile_find(const char *fnam, const char *const *dirpath, const char *const *suffixes, struct kbdfile *fp); | |
40 | 40 | |
41 | 41 | char *kbdfile_get_pathname(struct kbdfile *fp); |
42 | 42 | int kbdfile_set_pathname(struct kbdfile *fp, const char *pathname); |
97 | 97 | * and afterwards use only "loadkeys /fullpath/mykeymap", where no |
98 | 98 | * lookups are required. |
99 | 99 | */ |
100 | static char *include_dirpath0[] = { | |
101 | (char *) "", | |
100 | static const char *const include_dirpath0[] = { | |
101 | "", | |
102 | 102 | NULL |
103 | 103 | }; |
104 | static char *include_dirpath1[] = { | |
105 | (char *) "", | |
106 | (char *) "../include/", | |
107 | (char *) "../../include/", | |
104 | static const char *const include_dirpath1[] = { | |
105 | "", | |
106 | "../include/", | |
107 | "../../include/", | |
108 | 108 | NULL |
109 | 109 | }; |
110 | static char *include_dirpath3[] = { | |
111 | (char *) DATADIR "/" KEYMAPDIR "/include/", | |
112 | (char *) DATADIR "/" KEYMAPDIR "/i386/include/", | |
113 | (char *) DATADIR "/" KEYMAPDIR "/mac/include/", | |
110 | static const char *const include_dirpath3[] = { | |
111 | DATADIR "/" KEYMAPDIR "/include/", | |
112 | DATADIR "/" KEYMAPDIR "/i386/include/", | |
113 | DATADIR "/" KEYMAPDIR "/mac/include/", | |
114 | 114 | NULL |
115 | 115 | }; |
116 | 116 | |
117 | static char *include_suffixes[] = { | |
118 | (char *) "", | |
119 | (char *) ".inc", | |
117 | static const char *const include_suffixes[] = { | |
118 | "", | |
119 | ".inc", | |
120 | 120 | NULL |
121 | 121 | }; |
122 | 122 | |
123 | 123 | static int |
124 | 124 | find_incl_file_near_fn(struct lk_ctx *ctx, char *s, char *fn, struct kbdfile *fp) |
125 | 125 | { |
126 | char *include_dirpath2[] = { NULL, NULL, NULL, NULL }; | |
126 | const char *include_dirpath2[] = { NULL, NULL, NULL, NULL }; | |
127 | 127 | char *t, *te, *t1 = NULL, *t2 = NULL; |
128 | 128 | size_t len; |
129 | 129 | int rc = 1; |
223 | 223 | |
224 | 224 | if ((ev = getenv("LOADKEYS_INCLUDE_PATH")) != NULL) { |
225 | 225 | /* try user-specified path */ |
226 | char *user_dir[2] = { NULL, NULL }; | |
226 | const char *user_dir[2] = { NULL, NULL }; | |
227 | 227 | while (ev) { |
228 | 228 | int rc; |
229 | 229 | char *t = strchr(ev, ':'); |
23 | 23 | #include "paths.h" |
24 | 24 | #include "keymap.h" |
25 | 25 | |
26 | static char *dirpath1[] = { | |
27 | (char *) "", | |
28 | (char *) DATADIR "/" KEYMAPDIR "/**", | |
29 | (char *) KERNDIR "/", | |
26 | static const char *const dirpath1[] = { | |
27 | "", | |
28 | DATADIR "/" KEYMAPDIR "/**", | |
29 | KERNDIR "/", | |
30 | 30 | NULL |
31 | 31 | }; |
32 | static char *suffixes[] = { | |
33 | (char *) "", | |
34 | (char *) ".kmap", | |
35 | (char *) ".map", | |
32 | static const char *const suffixes[] = { | |
33 | "", | |
34 | ".kmap", | |
35 | ".map", | |
36 | 36 | NULL |
37 | 37 | }; |
38 | 38 | |
92 | 92 | }; |
93 | 93 | int options = 0; |
94 | 94 | |
95 | char **dirpath; | |
96 | char *dirpath2[] = { NULL, NULL }; | |
95 | const char *const *dirpath; | |
96 | const char *dirpath2[] = { NULL, NULL }; | |
97 | 97 | |
98 | 98 | struct lk_ctx *ctx; |
99 | 99 | lk_flags flags = 0; |
221 | 221 | nomem(); |
222 | 222 | |
223 | 223 | /* first read default map - search starts in . */ |
224 | if (kbdfile_find((char *) DEFMAP, dirpath, suffixes, fp)) { | |
224 | if (kbdfile_find(DEFMAP, dirpath, suffixes, fp)) { | |
225 | 225 | fprintf(stderr, _("Cannot find %s\n"), DEFMAP); |
226 | 226 | exit(EXIT_FAILURE); |
227 | 227 | } |
29 | 29 | extern char *progname; |
30 | 30 | extern int force; |
31 | 31 | |
32 | static char *unidirpath[] = { | |
33 | (char *) "", | |
34 | (char *) DATADIR "/" UNIMAPDIR "/", | |
32 | static const char *const unidirpath[] = { | |
33 | "", | |
34 | DATADIR "/" UNIMAPDIR "/", | |
35 | 35 | NULL |
36 | 36 | }; |
37 | static char *unisuffixes[] = { | |
38 | (char *) "", | |
39 | (char *) ".uni", | |
40 | (char *) ".sfm", | |
37 | static const char *const unisuffixes[] = { | |
38 | "", | |
39 | ".uni", | |
40 | ".sfm", | |
41 | 41 | NULL |
42 | 42 | }; |
43 | 43 | |
278 | 278 | if ((fp = kbdfile_new(NULL)) == NULL) |
279 | 279 | nomem(); |
280 | 280 | |
281 | if (kbdfile_find((char *) tblname, unidirpath, unisuffixes, fp)) { | |
281 | if (kbdfile_find(tblname, unidirpath, unisuffixes, fp)) { | |
282 | 282 | perror(tblname); |
283 | 283 | exit(EX_NOINPUT); |
284 | 284 | } |
27 | 27 | static int ctoi(char *); |
28 | 28 | |
29 | 29 | /* search for the map file in these directories (with trailing /) */ |
30 | static char *mapdirpath[] = { | |
31 | (char *) "", | |
32 | (char *) DATADIR "/" TRANSDIR "/", | |
30 | static const char *const mapdirpath[] = { | |
31 | "", | |
32 | DATADIR "/" TRANSDIR "/", | |
33 | 33 | NULL |
34 | 34 | }; |
35 | static char *mapsuffixes[] = { | |
36 | (char *) "", | |
37 | (char *) ".trans", | |
38 | (char *) "_to_uni.trans", | |
39 | (char *) ".acm", | |
35 | static const char *const mapsuffixes[] = { | |
36 | "", | |
37 | ".trans", | |
38 | "_to_uni.trans", | |
39 | ".acm", | |
40 | 40 | NULL |
41 | 41 | }; |
42 | 42 |
101 | 101 | static void vga_set_cursor(int, int); |
102 | 102 | static void vga_set_verticaldisplayend_lowbyte(int); |
103 | 103 | |
104 | char *dirpath[] = { | |
105 | (char *) "", | |
106 | (char *) DATADIR "/" VIDEOMODEDIR "/", | |
104 | const char *const dirpath[] = { | |
105 | "", | |
106 | DATADIR "/" VIDEOMODEDIR "/", | |
107 | 107 | NULL |
108 | 108 | }; |
109 | char *suffixes[] = { | |
110 | (char *) "", | |
109 | char const *const suffixes[] = { | |
110 | "", | |
111 | 111 | NULL |
112 | 112 | }; |
113 | 113 |
52 | 52 | int double_size = 0; |
53 | 53 | |
54 | 54 | /* search for the font in these directories (with trailing /) */ |
55 | char *fontdirpath[] = { | |
56 | (char *) "", | |
57 | (char *) DATADIR "/" FONTDIR "/", | |
55 | const char *const fontdirpath[] = { | |
56 | "", | |
57 | DATADIR "/" FONTDIR "/", | |
58 | 58 | NULL |
59 | 59 | }; |
60 | char *fontsuffixes[] = { | |
61 | (char *) "", | |
62 | (char *) ".psfu", | |
63 | (char *) ".psf", | |
64 | (char *) ".cp", | |
65 | (char *) ".fnt", | |
60 | char const *const fontsuffixes[] = { | |
61 | "", | |
62 | ".psfu", | |
63 | ".psf", | |
64 | ".cp", | |
65 | ".fnt", | |
66 | 66 | NULL |
67 | 67 | }; |
68 | 68 | /* hide partial fonts a bit - loading a single one is a bad idea */ |
69 | char *partfontdirpath[] = { | |
70 | (char *) "", | |
71 | (char *) DATADIR "/" FONTDIR "/" PARTIALDIR "/", | |
69 | const char *const partfontdirpath[] = { | |
70 | "", | |
71 | DATADIR "/" FONTDIR "/" PARTIALDIR "/", | |
72 | 72 | NULL |
73 | 73 | }; |
74 | char *partfontsuffixes[] = { | |
75 | (char *) "", | |
74 | char const *const partfontsuffixes[] = { | |
75 | "", | |
76 | 76 | NULL |
77 | 77 | }; |
78 | 78 | |
226 | 226 | if (!ifilct && !mfil && !ufil && |
227 | 227 | !Ofil && !ofil && !omfil && !oufil && !restore) |
228 | 228 | /* reset to some default */ |
229 | ifiles[ifilct++] = (char *) ""; | |
229 | ifiles[ifilct++] = ""; | |
230 | 230 | |
231 | 231 | if (Ofil) |
232 | 232 | saveoldfontplusunicodemap(fd, Ofil); |
608 | 608 | |
609 | 609 | /* instructions to combine fonts? */ |
610 | 610 | { |
611 | char *combineheader = (char *) "# combine partial fonts\n"; | |
611 | const char *combineheader = "# combine partial fonts\n"; | |
612 | 612 | size_t chlth = strlen(combineheader); |
613 | 613 | char *p, *q; |
614 | 614 | if (inputlth >= chlth && !strncmp(inbuf, combineheader, chlth)) { |
21 | 21 | |
22 | 22 | int rc = 0; |
23 | 23 | |
24 | rc = kbdfile_find((char *)"test0", (char **) dirpath, (char **) suffixes, fp); | |
24 | rc = kbdfile_find("test0", dirpath, suffixes, fp); | |
25 | 25 | |
26 | 26 | if (rc != 0) |
27 | 27 | kbd_error(EXIT_FAILURE, 0, "unable to find file"); |
18 | 18 | |
19 | 19 | const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwertz/test2"; |
20 | 20 | |
21 | int rc = kbdfile_find((char *)"test2", (char **) dirpath, (char **) suffixes, fp); | |
21 | int rc = kbdfile_find("test2", dirpath, suffixes, fp); | |
22 | 22 | |
23 | 23 | if (rc != 0) |
24 | 24 | kbd_error(EXIT_FAILURE, 0, "unable to find file"); |
19 | 19 | |
20 | 20 | const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwertz/test2.map"; |
21 | 21 | |
22 | int rc = kbdfile_find((char *)"test2", (char **) dirpath, (char **) suffixes, fp); | |
22 | int rc = kbdfile_find("test2", dirpath, suffixes, fp); | |
23 | 23 | |
24 | 24 | if (rc != 0) |
25 | 25 | kbd_error(EXIT_FAILURE, 0, "unable to find file"); |
18 | 18 | |
19 | 19 | const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwertz/test2.kmap"; |
20 | 20 | |
21 | int rc = kbdfile_find((char *)"test2", (char **) dirpath, (char **) suffixes, fp); | |
21 | int rc = kbdfile_find("test2", dirpath, suffixes, fp); | |
22 | 22 | |
23 | 23 | if (rc != 0) |
24 | 24 | kbd_error(EXIT_FAILURE, 0, "unable to find file"); |
19 | 19 | |
20 | 20 | const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwertz/test2.map"; |
21 | 21 | |
22 | int rc = kbdfile_find((char *)"test2", (char **) dirpath, (char **) suffixes, fp); | |
22 | int rc = kbdfile_find("test2", dirpath, suffixes, fp); | |
23 | 23 | |
24 | 24 | if (rc != 0) |
25 | 25 | kbd_error(EXIT_FAILURE, 0, "unable to find file"); |
19 | 19 | |
20 | 20 | const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwerty/test3.map"; |
21 | 21 | |
22 | int rc = kbdfile_find((char *)"test3", (char **) dirpath, (char **) suffixes, fp); | |
22 | int rc = kbdfile_find("test3", dirpath, suffixes, fp); | |
23 | 23 | |
24 | 24 | if (rc != 0) |
25 | 25 | kbd_error(EXIT_FAILURE, 0, "unable to find file"); |
20 | 20 | |
21 | 21 | int rc = 0; |
22 | 22 | |
23 | rc = kbdfile_find((char *)(DATADIR "/data/findfile/test_0/keymaps/i386/qwerty/test0"), (char **) dirpath, (char **) suffixes, fp); | |
23 | rc = kbdfile_find(DATADIR "/data/findfile/test_0/keymaps/i386/qwerty/test0", dirpath, suffixes, fp); | |
24 | 24 | |
25 | 25 | if (rc != 0) |
26 | 26 | kbd_error(EXIT_FAILURE, 0, "unable to find file"); |
21 | 21 | |
22 | 22 | int rc = 0; |
23 | 23 | |
24 | rc = kbdfile_find((char *)"i386/qwerty/test3", (char **) dirpath, (char **) suffixes, fp); | |
24 | rc = kbdfile_find("i386/qwerty/test3", dirpath, suffixes, fp); | |
25 | 25 | |
26 | 26 | if (rc != 0) |
27 | 27 | kbd_error(EXIT_FAILURE, 0, "unable to find file"); |
21 | 21 | |
22 | 22 | int rc = 0; |
23 | 23 | |
24 | rc = kbdfile_find((char *)"qwerty/test3", (char **) dirpath, (char **) suffixes, fp); | |
24 | rc = kbdfile_find("qwerty/test3", dirpath, suffixes, fp); | |
25 | 25 | |
26 | 26 | if (rc != 0) |
27 | 27 | kbd_error(EXIT_FAILURE, 0, "unable to find file"); |