s/qmail 4.2.29a
Next generation secure email transport
Loading...
Searching...
No Matches
printmaillist.c
Go to the documentation of this file.
1#include <unistd.h>
2#include "buffer.h"
3#include "logmsg.h"
4#include "stralloc.h"
5#include "getln.h"
6#include "str.h"
7
8#define WHO "printmaillist"
9
11{
12 logmsg(WHO,100,FATAL,"bad mailing list format");
13}
14
15stralloc line = {0};
17
18int main()
19{
20 for (;;) {
21 if (getln(buffer_1small,&line,&match,'\0') == -1)
22 logmsg(WHO,111,FATAL,"unable to read input: ");
23 if (!match) {
24 if (line.len)
25 badformat();
26 if (buffer_flush(buffer_1small) == -1)
27 logmsg(WHO,111,FATAL,"unable to write output: ");
28 _exit(0);
29 }
30
31 if (line.s[str_chr(line.s,'\n')]) badformat();
32 if (line.s[line.len - 1] == ' ') badformat();
33 if (line.s[line.len - 1] == '\t') badformat();
34
35 if ((line.s[0] == '.') || (line.s[0] == '/')) {
36 if (buffer_puts(buffer_1small,line.s) == -1)
37 logmsg(WHO,111,FATAL,"unable to write output: ");
38 if (buffer_puts(buffer_1small,"\n") == -1)
39 logmsg(WHO,111,FATAL,"unable to write output: ");
40 continue;
41 }
42 if (line.s[0] == '&') {
43 if (line.len > 900) badformat();
44 if (buffer_puts(buffer_1small,line.s) == -1)
45 logmsg(WHO,111,FATAL,"unable to write output: ");
46 if (buffer_puts(buffer_1small,"\n") == -1)
47 logmsg(WHO,111,FATAL,"unable to write output: ");
48 continue;
49 }
50
51 badformat();
52 }
53}
void _exit()
void badformat()
Definition: printmaillist.c:10
stralloc line
Definition: printmaillist.c:15
int match
Definition: printmaillist.c:16
#define WHO
Definition: printmaillist.c:8
int main()
Definition: printmaillist.c:18