Commit | Line | Data |
---|---|---|
2117e02e MW |
1 | #include "substdio.h" |
2 | #include "readwrite.h" | |
3 | #include "exit.h" | |
4 | ||
5 | char buf1[256]; | |
6 | substdio ss1 = SUBSTDIO_FDBUF(write,1,buf1,sizeof(buf1)); | |
7 | ||
8 | void puts(s) | |
9 | char *s; | |
10 | { | |
11 | if (substdio_puts(&ss1,s) == -1) _exit(111); | |
12 | } | |
13 | ||
14 | void main(argc,argv) | |
15 | int argc; | |
16 | char **argv; | |
17 | { | |
18 | char *name; | |
19 | char *value; | |
20 | unsigned char ch; | |
21 | char octal[4]; | |
22 | ||
23 | name = argv[1]; | |
24 | if (!name) _exit(100); | |
25 | value = argv[2]; | |
26 | if (!value) _exit(100); | |
27 | ||
28 | puts("char "); | |
29 | puts(name); | |
30 | puts("[] = \"\\\n"); | |
31 | ||
32 | while (ch = *value++) { | |
33 | puts("\\"); | |
34 | octal[3] = 0; | |
35 | octal[2] = '0' + (ch & 7); ch >>= 3; | |
36 | octal[1] = '0' + (ch & 7); ch >>= 3; | |
37 | octal[0] = '0' + (ch & 7); | |
38 | puts(octal); | |
39 | } | |
40 | ||
41 | puts("\\\n\";\n"); | |
42 | if (substdio_flush(&ss1) == -1) _exit(111); | |
43 | _exit(0); | |
44 | } |