diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-09 11:44:11 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-09 11:44:11 +0200 |
commit | f1b71c9fe7dbb4886588a036399cf5ebe16b7c47 (patch) | |
tree | e07786aa479c9fb6ee3e537078470aaab5454f80 /src/printmaillist.c | |
parent | a293489ee83c8b05d845a162dc2a4de026f3775d (diff) |
removed top level directory
Diffstat (limited to 'src/printmaillist.c')
-rw-r--r-- | src/printmaillist.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/printmaillist.c b/src/printmaillist.c new file mode 100644 index 0000000..6edb3b3 --- /dev/null +++ b/src/printmaillist.c @@ -0,0 +1,53 @@ +#include <unistd.h> +#include "buffer.h" +#include "logmsg.h" +#include "stralloc.h" +#include "getln.h" +#include "str.h" + +#define WHO "printmaillist" + +void badformat() +{ + logmsg(WHO,100,FATAL,"bad mailing list format"); +} + +stralloc line = {0}; +int match; + +int main() +{ + for (;;) { + if (getln(buffer_1small,&line,&match,'\0') == -1) + logmsg(WHO,111,FATAL,"unable to read input: "); + if (!match) { + if (line.len) + badformat(); + if (buffer_flush(buffer_1small) == -1) + logmsg(WHO,111,FATAL,"unable to write output: "); + _exit(0); + } + + if (line.s[str_chr(line.s,'\n')]) badformat(); + if (line.s[line.len - 1] == ' ') badformat(); + if (line.s[line.len - 1] == '\t') badformat(); + + if ((line.s[0] == '.') || (line.s[0] == '/')) { + if (buffer_puts(buffer_1small,line.s) == -1) + logmsg(WHO,111,FATAL,"unable to write output: "); + if (buffer_puts(buffer_1small,"\n") == -1) + logmsg(WHO,111,FATAL,"unable to write output: "); + continue; + } + if (line.s[0] == '&') { + if (line.len > 900) badformat(); + if (buffer_puts(buffer_1small,line.s) == -1) + logmsg(WHO,111,FATAL,"unable to write output: "); + if (buffer_puts(buffer_1small,"\n") == -1) + logmsg(WHO,111,FATAL,"unable to write output: "); + continue; + } + + badformat(); + } +} |