7#define WHO "printmaillist"
11 logmsg(
WHO,100,FATAL,
"bad database format");
15 logmsg(
WHO,111,FATAL,
"out of memory");
18static void getch(
char *ch)
21 r = buffer_get(buffer_0small,ch,1);
23 logmsg(
WHO,111,FATAL,
"unable to read input");
28static void out(
char *ch)
30 if (buffer_put(buffer_1small,ch,1) == -1)
31 logmsg(
WHO,111,FATAL,
"unable to write output");
34static void printbuf(
char *
buf)
40static void printsafe(
char *
buf,
int len)
46 if ((ch <= 32) || (ch ==
',') || (ch ==
':') || (ch ==
';') || (ch ==
'\\') || (ch ==
'#'))
68 for (i = 0; i < 4; ++i)
70 eod = cdb_unpack(
buf);
72 for (i = 4; i < 2048; ++i)
77 if (eod - pos < 8) badformat();
79 for (i = 0; i < 8; ++i) getch(
buf + i);
80 klen = cdb_unpack(
buf);
84 if (eod - pos < klen) badformat();
89 if (!stralloc_append(&
key,&ch))
nomem();
92 if (eod - pos <
dlen) badformat();
101 if (!
key.len) badformat();
102 if (
key.s[0] ==
'?') {
103 printsafe(
key.s + 1,
key.len - 1);
108 else if (
key.s[0] ==
':') {
109 printsafe(
key.s + 1,
key.len - 1);
115 if ((
data.s[i] ==
'.') || (
data.s[i] ==
'/')) {
117 printsafe(
data.s + i,
j - i);
120 else if ((
data.s[i] ==
'|') || (
data.s[i] ==
'!')) {
122 printsafe(
data.s + i,
j - i);
125 else if ((
data.s[i] ==
'&') && (
j - i < 900)) {
127 printsafe(
data.s + i,
j - i);
133 if (i !=
j) badformat();
139 if (buffer_flush(buffer_1small) == -1)
140 logmsg(
WHO,111,FATAL,
"unable to write output");
int stralloc_copys(stralloc *, char const *)