Commit | Line | Data |
6d62b57d |
1 | #include <stdio.h> |
2 | #include <stdlib.h> |
2b1d1392 |
3 | /* If it turns out that we need to make this conditional on config.sh derived |
4 | values, it might be easier just to rip out the use of strerrer(). */ |
5 | #include <string.h> |
6 | /* If a platform doesn't support errno.h, it's probably so strange that |
7 | "hello world" won't port easily to it. */ |
8 | #include <errno.h> |
6d62b57d |
9 | |
10 | static const char PL_uuemap[] |
11 | = "`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"; |
12 | |
13 | typedef unsigned char U8; |
14 | |
15 | /* This will ensure it is all zeros. */ |
16 | static char PL_uudmap[256]; |
17 | |
2b1d1392 |
18 | int main(int argc, char **argv) { |
6d62b57d |
19 | size_t i; |
20 | char *p; |
2b1d1392 |
21 | FILE *uudmap_out; |
22 | |
23 | if (argc < 2 || argv[1][0] == '\0') { |
24 | fprintf(stderr, "Usage: %s uudemap.h\n", argv[0]); |
25 | return 1; |
26 | } |
27 | |
28 | if (!(uudmap_out = fopen(argv[1], "w"))) { |
29 | fprintf(stderr, "%s: Could not open '%s': %s\n", argv[0], argv[1], |
30 | strerror(errno)); |
31 | return 1; |
32 | } |
6d62b57d |
33 | |
34 | for (i = 0; i < sizeof(PL_uuemap) - 1; ++i) |
0934c9d9 |
35 | PL_uudmap[(U8)PL_uuemap[i]] = (char)i; |
6d62b57d |
36 | /* |
37 | * Because ' ' and '`' map to the same value, |
38 | * we need to decode them both the same. |
39 | */ |
40 | PL_uudmap[(U8)' '] = 0; |
41 | |
42 | i = sizeof(PL_uudmap); |
43 | p = PL_uudmap; |
44 | |
2b1d1392 |
45 | fputs("{\n ", uudmap_out); |
6d62b57d |
46 | while (i--) { |
2b1d1392 |
47 | fprintf(uudmap_out, "%d", *p); |
6d62b57d |
48 | p++; |
49 | if (i) { |
2b1d1392 |
50 | fputs(", ", uudmap_out); |
6d62b57d |
51 | if (!(i & 15)) { |
2b1d1392 |
52 | fputs("\n ", uudmap_out); |
6d62b57d |
53 | } |
54 | } |
55 | } |
2b1d1392 |
56 | fputs("\n}\n", uudmap_out); |
57 | |
58 | if (fclose(uudmap_out)) { |
59 | fprintf(stderr, "%s: Could not close '%s': %s\n", argv[0], argv[1], |
60 | strerror(errno)); |
61 | return 1; |
62 | } |
6d62b57d |
63 | |
64 | return 0; |
65 | } |
66 | |
67 | |