Initialize the kbdfile context internally if necessary
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Alexey Gladkov
4 years ago
11 | 11 | 1. Find a git server that can be reached from anywhere in internet anonymously. |
12 | 12 | Github is for example a popular choice. |
13 | 13 | |
14 | 2. Create your own util-linux contributor repository, and push a upstream clone | |
14 | 2. Create your own kbd contributor repository, and push a upstream clone | |
15 | 15 | to there. |
16 | 16 | |
17 | 17 | 3. In these instructions the upstream remote repository is called 'origin' and |
26 | 26 | |
27 | 27 | struct kbdfile { |
28 | 28 | struct kbdfile_ctx *ctx; |
29 | int flags; | |
29 | 30 | FILE *fd; |
30 | int pipe; | |
31 | 31 | char pathname[MAXPATHLEN]; |
32 | 32 | }; |
33 | ||
34 | #define KBDFILE_CTX_INITIALIZED 0x01 | |
35 | #define KBDFILE_PIPE 0x02 | |
33 | 36 | |
34 | 37 | #define kbdfile_log_cond(ctx, level, arg...) \ |
35 | 38 | do { \ |
36 | 36 | |
37 | 37 | fp->ctx = ctx; |
38 | 38 | |
39 | if (!fp->ctx) { | |
40 | fp->ctx = kbdfile_context_new(); | |
41 | if (!fp->ctx) | |
42 | return NULL; | |
43 | fp->flags |= KBDFILE_CTX_INITIALIZED; | |
44 | } | |
45 | ||
39 | 46 | return fp; |
40 | 47 | } |
41 | 48 | |
44 | 51 | { |
45 | 52 | if (!fp) |
46 | 53 | return; |
54 | if (fp->flags & KBDFILE_CTX_INITIALIZED) | |
55 | kbdfile_context_free(fp->ctx); | |
47 | 56 | kbdfile_close(fp); |
48 | 57 | free(fp); |
49 | 58 | } |
83 | 92 | { |
84 | 93 | if (!fp || !fp->fd) |
85 | 94 | return; |
86 | if (fp->pipe) | |
95 | if (fp->flags & KBDFILE_PIPE) | |
87 | 96 | pclose(fp->fd); |
88 | 97 | else |
89 | 98 | fclose(fp->fd); |
102 | 111 | |
103 | 112 | sprintf(pipe_cmd, "%s %s", dc->cmd, fp->pathname); |
104 | 113 | |
105 | fp->fd = popen(pipe_cmd, "r"); | |
106 | fp->pipe = 1; | |
114 | fp->fd = popen(pipe_cmd, "r"); | |
115 | fp->flags |= KBDFILE_PIPE; | |
107 | 116 | |
108 | 117 | free(pipe_cmd); |
109 | 118 | |
137 | 146 | } |
138 | 147 | } |
139 | 148 | |
140 | fp->pipe = 0; | |
149 | fp->flags &= ~KBDFILE_PIPE; | |
141 | 150 | |
142 | 151 | if ((fp->fd = fopen(fp->pathname, "r")) == NULL) { |
143 | 152 | char buf[200]; |
151 | 160 | } |
152 | 161 | |
153 | 162 | static int |
154 | findfile_by_fullname(const char *fnam, const char *const *suffixes, struct kbdfile *fp) | |
163 | findfile_by_fullname(const char *fnam, char **suffixes, struct kbdfile *fp) | |
155 | 164 | { |
156 | 165 | int i; |
157 | 166 | struct stat st; |
158 | 167 | struct decompressor *dc; |
159 | 168 | size_t fnam_len, sp_len; |
160 | 169 | |
161 | fp->pipe = 0; | |
170 | fp->flags &= ~KBDFILE_PIPE; | |
162 | 171 | fnam_len = strlen(fnam); |
163 | 172 | |
164 | 173 | for (i = 0; suffixes[i]; i++) { |
190 | 199 | } |
191 | 200 | |
192 | 201 | static int |
193 | filecmp(const char *fname, char *name, const char *const *suf, unsigned int *index, struct decompressor **d) | |
202 | filecmp(const char *fname, char *name, char **suf, unsigned int *index, struct decompressor **d) | |
194 | 203 | { |
195 | 204 | /* Does d_name start right? */ |
196 | 205 | char *p = name; |
232 | 241 | } |
233 | 242 | |
234 | 243 | static int |
235 | findfile_in_dir(const char *fnam, const char *dir, const int recdepth, const char *const *suf, struct kbdfile *fp) | |
244 | findfile_in_dir(const char *fnam, const char *dir, const int recdepth, char **suf, struct kbdfile *fp) | |
236 | 245 | { |
237 | 246 | char errbuf[200]; |
238 | 247 | char *ff, *fdir, *path; |
239 | 248 | int rc = 1, secondpass = 0; |
240 | 249 | size_t dir_len; |
241 | 250 | |
242 | fp->fd = NULL; | |
243 | fp->pipe = 0; | |
251 | fp->fd = NULL; | |
252 | fp->flags &= ~KBDFILE_PIPE; | |
244 | 253 | |
245 | 254 | dir_len = strlen(dir); |
246 | 255 | |
334 | 343 | snprintf(fp->pathname, sizeof(fp->pathname), "%s/%s%s%s", dir, fnam, suf[index], (dc ? dc->ext : "")); |
335 | 344 | |
336 | 345 | if (!dc) { |
337 | fp->pipe = 0; | |
346 | fp->flags &= ~KBDFILE_PIPE; | |
338 | 347 | fp->fd = fopen(fp->pathname, "r"); |
339 | 348 | |
340 | 349 | if (!(fp->fd)) { |
370 | 379 | } |
371 | 380 | |
372 | 381 | int |
373 | kbdfile_find(char *fnam, const char *const *dirpath, const char *const *suffixes, struct kbdfile *fp) | |
382 | kbdfile_find(char *fnam, char **dirpath, char **suffixes, struct kbdfile *fp) | |
374 | 383 | { |
375 | 384 | int rc, i; |
376 | 385 | |
379 | 388 | return -1; |
380 | 389 | } |
381 | 390 | |
382 | fp->pipe = 0; | |
391 | fp->flags &= ~KBDFILE_PIPE; | |
383 | 392 | |
384 | 393 | /* Try explicitly given name first */ |
385 | 394 | strncpy(fp->pathname, fnam, sizeof(fp->pathname)); |
433 | 442 | struct kbdfile * |
434 | 443 | kbdfile_open(struct kbdfile_ctx *ctx, const char *filename) |
435 | 444 | { |
436 | struct kbdfile *fp = calloc(1, sizeof(struct kbdfile)); | |
445 | struct kbdfile *fp = kbdfile_new(ctx); | |
437 | 446 | |
438 | 447 | if (!fp) |
439 | 448 | return NULL; |
440 | 449 | |
441 | fp->ctx = ctx; | |
442 | strncpy(fp->pathname, filename, sizeof(fp->pathname)); | |
450 | kbdfile_set_pathname(fp, filename); | |
443 | 451 | |
444 | 452 | if (maybe_pipe_open(fp) < 0) { |
445 | 453 | kbdfile_free(fp); |
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, const char *const *dirpath, const char *const *suffixes, struct kbdfile *fp); | |
39 | int kbdfile_find(char *fnam, char **dirpath, char **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); |
96 | 96 | char *console = NULL; |
97 | 97 | char *ev; |
98 | 98 | struct kbdfile *fp; |
99 | struct kbdfile_ctx *kbdfile_ctx; | |
100 | 99 | |
101 | 100 | set_progname(argv[0]); |
102 | 101 | setuplocale(); |
106 | 105 | exit(EXIT_FAILURE); |
107 | 106 | } |
108 | 107 | |
109 | if ((kbdfile_ctx = kbdfile_context_new()) == NULL) | |
110 | nomem(); | |
111 | ||
112 | if ((fp = kbdfile_new(kbdfile_ctx)) == NULL) | |
108 | if ((fp = kbdfile_new(NULL)) == NULL) | |
113 | 109 | nomem(); |
114 | 110 | |
115 | 111 | while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { |
256 | 252 | fail: |
257 | 253 | lk_free(ctx); |
258 | 254 | kbdfile_free(fp); |
259 | kbdfile_context_free(kbdfile_ctx); | |
260 | 255 | |
261 | 256 | if (fd >= 0) |
262 | 257 | close(fd); |
265 | 265 | char buffer[65536]; |
266 | 266 | char *p; |
267 | 267 | struct kbdfile *fp; |
268 | struct kbdfile_ctx *kbdfile_ctx; | |
269 | ||
270 | if ((kbdfile_ctx = kbdfile_context_new()) == NULL) | |
271 | nomem(); | |
272 | ||
273 | if ((fp = kbdfile_new(kbdfile_ctx)) == NULL) | |
268 | ||
269 | if ((fp = kbdfile_new(NULL)) == NULL) | |
274 | 270 | nomem(); |
275 | 271 | |
276 | 272 | if (kbdfile_find((char *) tblname, unidirpath, unisuffixes, fp)) { |
292 | 288 | } |
293 | 289 | |
294 | 290 | kbdfile_free(fp); |
295 | kbdfile_context_free(kbdfile_ctx); | |
296 | 291 | |
297 | 292 | if (listct == 0 && !force) { |
298 | 293 | fprintf(stderr, |
127 | 127 | int u = 0; |
128 | 128 | int lineno = 0; |
129 | 129 | struct kbdfile *fp; |
130 | struct kbdfile_ctx *kbdfile_ctx; | |
131 | ||
132 | if ((kbdfile_ctx = kbdfile_context_new()) == NULL) | |
133 | nomem(); | |
134 | ||
135 | if ((fp = kbdfile_new(kbdfile_ctx)) == NULL) | |
130 | ||
131 | if ((fp = kbdfile_new(NULL)) == NULL) | |
136 | 132 | nomem(); |
137 | 133 | |
138 | 134 | if (kbdfile_find(mfil, mapdirpath, mapsuffixes, fp)) { |
181 | 177 | } |
182 | 178 | } |
183 | 179 | kbdfile_free(fp); |
184 | kbdfile_context_free(kbdfile_ctx); | |
185 | 180 | return u; |
186 | 181 | } |
187 | 182 |
114 | 114 | char tty[12], cmd[80], infile[1024]; |
115 | 115 | const char *defaultfont; |
116 | 116 | struct kbdfile *fp; |
117 | struct kbdfile_ctx *kbdfile_ctx; | |
118 | 117 | |
119 | 118 | set_progname(argv[0]); |
120 | 119 | setuplocale(); |
148 | 147 | usage(); |
149 | 148 | } |
150 | 149 | |
151 | if ((kbdfile_ctx = kbdfile_context_new()) == NULL) | |
152 | nomem(); | |
153 | ||
154 | if ((fp = kbdfile_new(kbdfile_ctx)) == NULL) | |
150 | if ((fp = kbdfile_new(NULL)) == NULL) | |
155 | 151 | nomem(); |
156 | 152 | |
157 | 153 | if (mode == MODE_RESTORETEXTMODE) { |
277 | 273 | } |
278 | 274 | |
279 | 275 | kbdfile_free(fp); |
280 | kbdfile_context_free(kbdfile_ctx); | |
281 | 276 | |
282 | 277 | /* |
283 | 278 | * for i in /dev/tty[0-9] /dev/tty[0-9][0-9] |
396 | 396 | struct unicode_list *uclistheads; |
397 | 397 | int i; |
398 | 398 | struct kbdfile *fp; |
399 | struct kbdfile_ctx *kbdfile_ctx; | |
400 | ||
401 | 399 | |
402 | 400 | if (ifilct == 1) { |
403 | 401 | loadnewfont(fd, ifiles[0], iunit, hwunit, no_m, no_u); |
404 | 402 | return; |
405 | 403 | } |
406 | 404 | |
407 | if ((kbdfile_ctx = kbdfile_context_new()) == NULL) | |
408 | nomem(); | |
409 | ||
410 | if ((fp = kbdfile_new(kbdfile_ctx)) == NULL) | |
405 | if ((fp = kbdfile_new(NULL)) == NULL) | |
411 | 406 | nomem(); |
412 | 407 | |
413 | 408 | /* several fonts that must be merged */ |
437 | 432 | "must be psf fonts - %s isn't\n"), |
438 | 433 | kbdfile_get_pathname(fp)); |
439 | 434 | kbdfile_free(fp); |
440 | kbdfile_context_free(kbdfile_ctx); | |
441 | 435 | exit(EX_DATAERR); |
442 | 436 | } |
443 | 437 | |
444 | 438 | kbdfile_free(fp); // avoid zombies, jw@suse.de (#88501) |
445 | kbdfile_context_free(kbdfile_ctx); | |
446 | 439 | |
447 | 440 | bytewidth = (width + 7) / 8; |
448 | 441 | height = fontbuflth / (bytewidth * fontsize); |
484 | 477 | loadnewfont(int fd, char *ifil, int iunit, int hwunit, int no_m, int no_u) |
485 | 478 | { |
486 | 479 | struct kbdfile *fp; |
487 | struct kbdfile_ctx *kbdfile_ctx; | |
488 | 480 | |
489 | 481 | char defname[20]; |
490 | 482 | int height, width, bytewidth, def = 0; |
492 | 484 | int inputlth, fontbuflth, fontsize, offset; |
493 | 485 | struct unicode_list *uclistheads; |
494 | 486 | |
495 | ||
496 | if ((kbdfile_ctx = kbdfile_context_new()) == NULL) | |
497 | nomem(); | |
498 | ||
499 | if ((fp = kbdfile_new(kbdfile_ctx)) == NULL) | |
487 | if ((fp = kbdfile_new(NULL)) == NULL) | |
500 | 488 | nomem(); |
501 | 489 | |
502 | 490 | if (!*ifil) { |
540 | 528 | &width, &fontsize, 0, |
541 | 529 | no_u ? NULL : &uclistheads) == 0) { |
542 | 530 | kbdfile_free(fp); |
543 | kbdfile_context_free(kbdfile_ctx); | |
544 | 531 | |
545 | 532 | /* we've got a psf font */ |
546 | 533 | bytewidth = (width + 7) / 8; |
557 | 544 | return; |
558 | 545 | } |
559 | 546 | kbdfile_free(fp); // avoid zombies, jw@suse.de (#88501) |
560 | kbdfile_context_free(kbdfile_ctx); | |
561 | 547 | |
562 | 548 | /* instructions to combine fonts? */ |
563 | 549 | { |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | ||
19 | 14 | kbdfile_free(fp); |
20 | kbdfile_context_free(ctx); | |
21 | ||
22 | 15 | return EXIT_SUCCESS; |
23 | 16 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
32 | 28 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
33 | 29 | |
34 | 30 | kbdfile_free(fp); |
35 | kbdfile_context_free(ctx); | |
36 | 31 | |
37 | 32 | return EXIT_SUCCESS; |
38 | 33 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
30 | 26 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
31 | 27 | |
32 | 28 | kbdfile_free(fp); |
33 | kbdfile_context_free(ctx); | |
34 | 29 | |
35 | 30 | return EXIT_SUCCESS; |
36 | 31 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
29 | 25 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
30 | 26 | |
31 | 27 | kbdfile_free(fp); |
32 | kbdfile_context_free(ctx); | |
33 | 28 | |
34 | 29 | return EXIT_SUCCESS; |
35 | 30 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
30 | 26 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
31 | 27 | |
32 | 28 | kbdfile_free(fp); |
33 | kbdfile_context_free(ctx); | |
34 | 29 | |
35 | 30 | return EXIT_SUCCESS; |
36 | 31 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
30 | 26 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
31 | 27 | |
32 | 28 | kbdfile_free(fp); |
33 | kbdfile_context_free(ctx); | |
34 | 29 | |
35 | 30 | return EXIT_SUCCESS; |
36 | 31 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
30 | 26 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
31 | 27 | |
32 | 28 | kbdfile_free(fp); |
33 | kbdfile_context_free(ctx); | |
34 | 29 | |
35 | 30 | return EXIT_SUCCESS; |
36 | 31 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
32 | 28 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
33 | 29 | |
34 | 30 | kbdfile_free(fp); |
35 | kbdfile_context_free(ctx); | |
36 | 31 | |
37 | 32 | return EXIT_SUCCESS; |
38 | 33 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_open(ctx, DATADIR "/findfile/test_0/keymaps/i386/qwerty/test0.map"); | |
11 | struct kbdfile *fp = kbdfile_open(NULL, DATADIR "/findfile/test_0/keymaps/i386/qwerty/test0.map"); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
21 | 17 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
22 | 18 | |
23 | 19 | kbdfile_free(fp); |
24 | kbdfile_context_free(ctx); | |
25 | 20 | |
26 | 21 | return EXIT_SUCCESS; |
27 | 22 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_open(ctx, DATADIR "/findfile/test_0/keymaps/i386/qwerty/test0"); | |
11 | struct kbdfile *fp = kbdfile_open(NULL, DATADIR "/findfile/test_0/keymaps/i386/qwerty/test0"); | |
16 | 12 | if (fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unexpected kbdfile"); |
18 | 14 | |
19 | 15 | kbdfile_free(fp); |
20 | kbdfile_context_free(ctx); | |
21 | 16 | |
22 | 17 | return EXIT_SUCCESS; |
23 | 18 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
32 | 28 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
33 | 29 | |
34 | 30 | kbdfile_free(fp); |
35 | kbdfile_context_free(ctx); | |
36 | 31 | |
37 | 32 | return EXIT_SUCCESS; |
38 | 33 | } |
8 | 8 | int |
9 | 9 | main(void) |
10 | 10 | { |
11 | struct kbdfile_ctx *ctx = kbdfile_context_new(); | |
12 | if (!ctx) | |
13 | error(EXIT_FAILURE, 0, "unable to create context"); | |
14 | ||
15 | struct kbdfile *fp = kbdfile_new(ctx); | |
11 | struct kbdfile *fp = kbdfile_new(NULL); | |
16 | 12 | if (!fp) |
17 | 13 | error(EXIT_FAILURE, 0, "unable to create kbdfile"); |
18 | 14 | |
32 | 28 | error(EXIT_FAILURE, 0, "unexpected file: %s (expected %s)", kbdfile_get_pathname(fp), expect); |
33 | 29 | |
34 | 30 | kbdfile_free(fp); |
35 | kbdfile_context_free(ctx); | |
36 | 31 | |
37 | 32 | return EXIT_SUCCESS; |
38 | 33 | } |