From a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Wed, 3 Jul 2024 15:52:39 +0200 Subject: format files --- src/setmaillist.c | 64 ++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) (limited to 'src/setmaillist.c') diff --git a/src/setmaillist.c b/src/setmaillist.c index f7ac89b..a32e86b 100644 --- a/src/setmaillist.c +++ b/src/setmaillist.c @@ -1,19 +1,20 @@ -#include #include +#include + #include "buffer.h" -#include "logmsg.h" -#include "stralloc.h" +#include "byte.h" #include "getln.h" +#include "logmsg.h" #include "open.h" -#include "byte.h" +#include "stralloc.h" #define WHO "setmaillist" -int rename(const char *,const char *); // stdio.h +int rename(const char *, const char *); // stdio.h void usage() { - logmsg(WHO,100,USAGE,"setmaillist list.bin list.tmp"); + logmsg(WHO, 100, USAGE, "setmaillist list.bin list.tmp"); } stralloc line = {0}; @@ -27,56 +28,52 @@ buffer bo; void writeerr() { - logmsg(WHO,111,FATAL,B("unable to write to: ",fntmp)); + logmsg(WHO, 111, FATAL, B("unable to write to: ", fntmp)); } -static void out(char *s,int len) +static void out(char *s, int len) { - if (buffer_put(&bo,s,len) == -1) writeerr(); + if (buffer_put(&bo, s, len) == -1) writeerr(); } -int main(int argc,char **argv) +int main(int argc, char **argv) { umask(033); - fnbin = argv[1]; if (!fnbin) usage(); - fntmp = argv[2]; if (!fntmp) usage(); + fnbin = argv[1]; + if (!fnbin) usage(); + fntmp = argv[2]; + if (!fntmp) usage(); fd = open_trunc(fntmp); - if (fd == -1) - logmsg(WHO,111,FATAL,B("unable to create: ",fntmp)); + if (fd == -1) logmsg(WHO, 111, FATAL, B("unable to create: ", fntmp)); - buffer_init(&bo,write,fd,buf,sizeof(buf)); + buffer_init(&bo, write, fd, buf, sizeof(buf)); do { - if (getln(buffer_0small,&line,&match,'\n') == -1) - logmsg(WHO,111,FATAL,"unable to read input: "); + if (getln(buffer_0small, &line, &match, '\n') == -1) + logmsg(WHO, 111, FATAL, "unable to read input: "); while (line.len) { if (line.s[line.len - 1] != '\n') if (line.s[line.len - 1] != ' ') - if (line.s[line.len - 1] != '\t') - break; + if (line.s[line.len - 1] != '\t') break; --line.len; } - if (byte_chr(line.s,line.len,'\0') != line.len) - logmsg(WHO,111,FATAL,"NUL in input"); + if (byte_chr(line.s, line.len, '\0') != line.len) logmsg(WHO, 111, FATAL, "NUL in input"); if (line.len) if (line.s[0] != '#') { if ((line.s[0] == '.') || (line.s[0] == '/')) { - out(line.s,line.len); - out("",1); - } - else { - if (line.len > 800) - logmsg(WHO,111,FATAL,"addresses must be under 800 bytes"); - if (line.s[0] != '&') - out("&",1); - out(line.s,line.len); - out("",1); + out(line.s, line.len); + out("", 1); + } else { + if (line.len > 800) logmsg(WHO, 111, FATAL, "addresses must be under 800 bytes"); + if (line.s[0] != '&') out("&", 1); + out(line.s, line.len); + out("", 1); } } @@ -86,8 +83,7 @@ int main(int argc,char **argv) if (fsync(fd) == -1) writeerr(); if (close(fd) == -1) writeerr(); /* NFS stupidity */ - if (rename(fntmp,fnbin) == -1) - logmsg(WHO,111,FATAL,B("unable to move ",fntmp," to: ",fnbin)); - + if (rename(fntmp, fnbin) == -1) logmsg(WHO, 111, FATAL, B("unable to move ", fntmp, " to: ", fnbin)); + _exit(0); } -- cgit v1.2.3