mess822x 1.23
mess822x
Loading...
Searching...
No Matches
auto-str.c
Go to the documentation of this file.
1#include <unistd.h>
2#include "buffer.h"
3#include "readwrite.h"
4#include "exit.h"
5
6char outbuf[256];
7buffer bo = BUFFER_INIT(write,1,outbuf,sizeof(outbuf));
8
9static void spit(char *s)
10{
11 if (buffer_puts(&bo,s) == -1) _exit(111);
12}
13
14int main(int argc,char **argv)
15{
16 char *name;
17 char *value;
18 unsigned char ch;
19 char octal[4];
20
21 name = argv[1];
22 if (!name) _exit(100);
23 value = argv[2];
24 if (!value) _exit(100);
25
26 spit("char ");
27 spit(name);
28 spit("[] = \"\\\n");
29
30 while ((ch = *value++)) {
31 spit("\\");
32 octal[3] = 0;
33 octal[2] = '0' + (ch & 7); ch >>= 3;
34 octal[1] = '0' + (ch & 7); ch >>= 3;
35 octal[0] = '0' + (ch & 7);
36 spit(octal);
37 }
38
39 spit("\\\n\";\n");
40 if (buffer_flush(&bo) == -1) _exit(111);
41 _exit(0);
42}
int main()
Definition: 822print.c:351
char name[11]
Definition: 822mimeparts.c:52
stralloc value
Definition: 822field.c:17
char outbuf[256]
Definition: auto-str.c:6
buffer bo
Definition: auto-str.c:7