7 #define FATAL "printmaillist: fatal: "
11 strerr_die2x(100,FATAL
,"bad database format");
15 strerr_die2x(111,FATAL
,"out of memory");
22 r
= substdio_get(subfdinsmall
,ch
,1);
24 strerr_die2sys(111,FATAL
,"unable to read input: ");
32 if (substdio_put(subfdoutsmall
,ch
,1) == -1)
33 strerr_die2x(111,FATAL
,"unable to write output: ");
43 void printsafe(buf
,len
)
51 if ((ch
<= 32) || (ch
== ',') || (ch
== ':') || (ch
== ';') || (ch
== '\\') || (ch
== '#'))
73 for (i
= 0;i
< 4;++i
) getch(buf
+ i
);
74 eod
= cdb_unpack(buf
);
76 for (i
= 4;i
< 2048;++i
) getch(&ch
);
80 if (eod
- pos
< 8) badformat();
82 for (i
= 0;i
< 8;++i
) getch(buf
+ i
);
83 klen
= cdb_unpack(buf
);
84 dlen
= cdb_unpack(buf
+ 4);
86 if (!stralloc_copys(&key
,"")) nomem();
87 if (eod
- pos
< klen
) badformat();
92 if (!stralloc_append(&key
,&ch
)) nomem();
95 if (eod
- pos
< dlen
) badformat();
97 if (!stralloc_copys(&data
,"")) nomem();
101 if (!stralloc_append(&data
,&ch
)) nomem();
104 if (!key
.len
) badformat();
105 if (key
.s
[0] == '?') {
106 printsafe(key
.s
+ 1,key
.len
- 1);
108 printsafe(data
.s
,data
.len
);
111 else if (key
.s
[0] == ':') {
112 printsafe(key
.s
+ 1,key
.len
- 1);
116 for (j
= 0;j
< data
.len
;++j
)
118 if ((data
.s
[i
] == '.') || (data
.s
[i
] == '/')) {
120 printsafe(data
.s
+ i
,j
- i
);
123 else if ((data
.s
[i
] == '|') || (data
.s
[i
] == '!')) {
125 printsafe(data
.s
+ i
,j
- i
);
128 else if ((data
.s
[i
] == '&') && (j
- i
< 900)) {
130 printsafe(data
.s
+ i
,j
- i
);
136 if (i
!= j
) badformat();
142 if (substdio_flush(subfdoutsmall
) == -1)
143 strerr_die2sys(111,FATAL
,"unable to write output: ");