Codebase list kbd / 3f263e1
Fix warnings from -Wincompatible-pointer-types Signed-off-by: Oleg Bulatov <oleg@bulatov.me> Oleg Bulatov 4 years ago
18 changed file(s) with 78 addition(s) and 78 deletion(s). Raw diff Collapse all Expand all
160160 }
161161
162162 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)
164164 {
165165 int i;
166166 struct stat st;
199199 }
200200
201201 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)
203203 {
204204 /* Does d_name start right? */
205205 char *p = name;
241241 }
242242
243243 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)
245245 {
246246 char errbuf[200];
247247 char *ff, *fdir, *path;
372372 }
373373
374374 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)
376376 {
377377 int rc, i;
378378
3636 struct kbdfile *kbdfile_open(struct kbdfile_ctx *ctx, const char *filename);
3737 void kbdfile_close(struct kbdfile *fp);
3838
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);
4040
4141 char *kbdfile_get_pathname(struct kbdfile *fp);
4242 int kbdfile_set_pathname(struct kbdfile *fp, const char *pathname);
9797 * and afterwards use only "loadkeys /fullpath/mykeymap", where no
9898 * lookups are required.
9999 */
100 static char *include_dirpath0[] = {
101 (char *) "",
100 static const char *const include_dirpath0[] = {
101 "",
102102 NULL
103103 };
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/",
108108 NULL
109109 };
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/",
114114 NULL
115115 };
116116
117 static char *include_suffixes[] = {
118 (char *) "",
119 (char *) ".inc",
117 static const char *const include_suffixes[] = {
118 "",
119 ".inc",
120120 NULL
121121 };
122122
123123 static int
124124 find_incl_file_near_fn(struct lk_ctx *ctx, char *s, char *fn, struct kbdfile *fp)
125125 {
126 char *include_dirpath2[] = { NULL, NULL, NULL, NULL };
126 const char *include_dirpath2[] = { NULL, NULL, NULL, NULL };
127127 char *t, *te, *t1 = NULL, *t2 = NULL;
128128 size_t len;
129129 int rc = 1;
223223
224224 if ((ev = getenv("LOADKEYS_INCLUDE_PATH")) != NULL) {
225225 /* try user-specified path */
226 char *user_dir[2] = { NULL, NULL };
226 const char *user_dir[2] = { NULL, NULL };
227227 while (ev) {
228228 int rc;
229229 char *t = strchr(ev, ':');
2323 #include "paths.h"
2424 #include "keymap.h"
2525
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 "/",
3030 NULL
3131 };
32 static char *suffixes[] = {
33 (char *) "",
34 (char *) ".kmap",
35 (char *) ".map",
32 static const char *const suffixes[] = {
33 "",
34 ".kmap",
35 ".map",
3636 NULL
3737 };
3838
9292 };
9393 int options = 0;
9494
95 char **dirpath;
96 char *dirpath2[] = { NULL, NULL };
95 const char *const *dirpath;
96 const char *dirpath2[] = { NULL, NULL };
9797
9898 struct lk_ctx *ctx;
9999 lk_flags flags = 0;
221221 nomem();
222222
223223 /* first read default map - search starts in . */
224 if (kbdfile_find((char *) DEFMAP, dirpath, suffixes, fp)) {
224 if (kbdfile_find(DEFMAP, dirpath, suffixes, fp)) {
225225 fprintf(stderr, _("Cannot find %s\n"), DEFMAP);
226226 exit(EXIT_FAILURE);
227227 }
2929 extern char *progname;
3030 extern int force;
3131
32 static char *unidirpath[] = {
33 (char *) "",
34 (char *) DATADIR "/" UNIMAPDIR "/",
32 static const char *const unidirpath[] = {
33 "",
34 DATADIR "/" UNIMAPDIR "/",
3535 NULL
3636 };
37 static char *unisuffixes[] = {
38 (char *) "",
39 (char *) ".uni",
40 (char *) ".sfm",
37 static const char *const unisuffixes[] = {
38 "",
39 ".uni",
40 ".sfm",
4141 NULL
4242 };
4343
278278 if ((fp = kbdfile_new(NULL)) == NULL)
279279 nomem();
280280
281 if (kbdfile_find((char *) tblname, unidirpath, unisuffixes, fp)) {
281 if (kbdfile_find(tblname, unidirpath, unisuffixes, fp)) {
282282 perror(tblname);
283283 exit(EX_NOINPUT);
284284 }
2727 static int ctoi(char *);
2828
2929 /* 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 "/",
3333 NULL
3434 };
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",
4040 NULL
4141 };
4242
101101 static void vga_set_cursor(int, int);
102102 static void vga_set_verticaldisplayend_lowbyte(int);
103103
104 char *dirpath[] = {
105 (char *) "",
106 (char *) DATADIR "/" VIDEOMODEDIR "/",
104 const char *const dirpath[] = {
105 "",
106 DATADIR "/" VIDEOMODEDIR "/",
107107 NULL
108108 };
109 char *suffixes[] = {
110 (char *) "",
109 char const *const suffixes[] = {
110 "",
111111 NULL
112112 };
113113
5252 int double_size = 0;
5353
5454 /* 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 "/",
5858 NULL
5959 };
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",
6666 NULL
6767 };
6868 /* 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 "/",
7272 NULL
7373 };
74 char *partfontsuffixes[] = {
75 (char *) "",
74 char const *const partfontsuffixes[] = {
75 "",
7676 NULL
7777 };
7878
226226 if (!ifilct && !mfil && !ufil &&
227227 !Ofil && !ofil && !omfil && !oufil && !restore)
228228 /* reset to some default */
229 ifiles[ifilct++] = (char *) "";
229 ifiles[ifilct++] = "";
230230
231231 if (Ofil)
232232 saveoldfontplusunicodemap(fd, Ofil);
608608
609609 /* instructions to combine fonts? */
610610 {
611 char *combineheader = (char *) "# combine partial fonts\n";
611 const char *combineheader = "# combine partial fonts\n";
612612 size_t chlth = strlen(combineheader);
613613 char *p, *q;
614614 if (inputlth >= chlth && !strncmp(inbuf, combineheader, chlth)) {
2121
2222 int rc = 0;
2323
24 rc = kbdfile_find((char *)"test0", (char **) dirpath, (char **) suffixes, fp);
24 rc = kbdfile_find("test0", dirpath, suffixes, fp);
2525
2626 if (rc != 0)
2727 kbd_error(EXIT_FAILURE, 0, "unable to find file");
1818
1919 const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwertz/test2";
2020
21 int rc = kbdfile_find((char *)"test2", (char **) dirpath, (char **) suffixes, fp);
21 int rc = kbdfile_find("test2", dirpath, suffixes, fp);
2222
2323 if (rc != 0)
2424 kbd_error(EXIT_FAILURE, 0, "unable to find file");
1919
2020 const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwertz/test2.map";
2121
22 int rc = kbdfile_find((char *)"test2", (char **) dirpath, (char **) suffixes, fp);
22 int rc = kbdfile_find("test2", dirpath, suffixes, fp);
2323
2424 if (rc != 0)
2525 kbd_error(EXIT_FAILURE, 0, "unable to find file");
1818
1919 const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwertz/test2.kmap";
2020
21 int rc = kbdfile_find((char *)"test2", (char **) dirpath, (char **) suffixes, fp);
21 int rc = kbdfile_find("test2", dirpath, suffixes, fp);
2222
2323 if (rc != 0)
2424 kbd_error(EXIT_FAILURE, 0, "unable to find file");
1919
2020 const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwertz/test2.map";
2121
22 int rc = kbdfile_find((char *)"test2", (char **) dirpath, (char **) suffixes, fp);
22 int rc = kbdfile_find("test2", dirpath, suffixes, fp);
2323
2424 if (rc != 0)
2525 kbd_error(EXIT_FAILURE, 0, "unable to find file");
1919
2020 const char *expect = DATADIR "/data/findfile/test_0/keymaps/i386/qwerty/test3.map";
2121
22 int rc = kbdfile_find((char *)"test3", (char **) dirpath, (char **) suffixes, fp);
22 int rc = kbdfile_find("test3", dirpath, suffixes, fp);
2323
2424 if (rc != 0)
2525 kbd_error(EXIT_FAILURE, 0, "unable to find file");
2020
2121 int rc = 0;
2222
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);
2424
2525 if (rc != 0)
2626 kbd_error(EXIT_FAILURE, 0, "unable to find file");
2121
2222 int rc = 0;
2323
24 rc = kbdfile_find((char *)"i386/qwerty/test3", (char **) dirpath, (char **) suffixes, fp);
24 rc = kbdfile_find("i386/qwerty/test3", dirpath, suffixes, fp);
2525
2626 if (rc != 0)
2727 kbd_error(EXIT_FAILURE, 0, "unable to find file");
2121
2222 int rc = 0;
2323
24 rc = kbdfile_find((char *)"qwerty/test3", (char **) dirpath, (char **) suffixes, fp);
24 rc = kbdfile_find("qwerty/test3", dirpath, suffixes, fp);
2525
2626 if (rc != 0)
2727 kbd_error(EXIT_FAILURE, 0, "unable to find file");
2121
2222 int rc = 0;
2323
24 rc = kbdfile_find((char *)"simple-1.psf.gz", (char **) dirpath, (char **) suffixes, fp);
24 rc = kbdfile_find("simple-1.psf.gz", dirpath, suffixes, fp);
2525
2626 if (rc != 0)
2727 kbd_error(EXIT_FAILURE, 0, "unable to find file");