s/qmail 4.2.29a
Next generation secure email transport
Loading...
Searching...
No Matches
auto-str.c
Go to the documentation of this file.
1#include <unistd.h>
2#include "buffer.h"
3#include "exit.h"
4
5char inbuf[BUFFER_SMALL];
6buffer b = BUFFER_INIT(write,1,inbuf,sizeof(inbuf));
7
8void out(char *s)
9{
10 if (buffer_puts(&b,s) == -1) _exit(111);
11}
12
13int main(int argc, char **argv)
14{
15 char *name;
16 char *value;
17 unsigned char ch;
18 char octal[4];
19
20 name = argv[1];
21 if (!name) _exit(100);
22 value = argv[2];
23 if (!value) _exit(100);
24
25 out("char ");
26 out(name);
27 out("[] = \"\\\n");
28
29 while ((ch = *value++)) {
30 out("\\");
31 octal[3] = 0;
32 octal[2] = '0' + (ch & 7); ch >>= 3;
33 octal[1] = '0' + (ch & 7); ch >>= 3;
34 octal[0] = '0' + (ch & 7);
35 out(octal);
36 }
37
38 out("\\\n\";\n");
39 if (buffer_flush(&b) == -1) _exit(111);
40 _exit(0);
41}
buffer b
Definition: auto-str.c:6
char inbuf[BUFFER_SMALL]
Definition: auto-str.c:5
int main()
Definition: chkshsgr.c:6
stralloc out
Definition: dnscname.c:12
void _exit()
void write()