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/qmail-newmrh.c | 56 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'src/qmail-newmrh.c') diff --git a/src/qmail-newmrh.c b/src/qmail-newmrh.c index 4a74698..20945a4 100644 --- a/src/qmail-newmrh.c +++ b/src/qmail-newmrh.c @@ -1,27 +1,30 @@ -#include #include -#include // rename -#include "logmsg.h" -#include "stralloc.h" +#include + +#include // rename + #include "buffer.h" -#include "getln.h" +#include "case.h" +#include "cdbmake.h" #include "exit.h" +#include "getln.h" +#include "logmsg.h" #include "open.h" +#include "stralloc.h" + #include "auto_qmail.h" -#include "cdbmake.h" -#include "case.h" #define WHO "qmail-newmrh" -int rename(const char *,const char *); // stdio.h +int rename(const char *, const char *); // stdio.h void die_read() { - logmsg(WHO,111,ERROR,"unable to read control/morercpthosts"); + logmsg(WHO, 111, ERROR, "unable to read control/morercpthosts"); } void die_write() { - logmsg(WHO,111,ERROR,"unable to write to control/morercpthosts.tmp"); + logmsg(WHO, 111, ERROR, "unable to write to control/morercpthosts.tmp"); } char inbuf[1024]; @@ -37,29 +40,36 @@ int match; int main() { umask(033); - if (chdir(auto_qmail) == -1) - logmsg(WHO,111,ERROR,B("unable to chdir to: ",auto_qmail)); + if (chdir(auto_qmail) == -1) logmsg(WHO, 111, ERROR, B("unable to chdir to: ", auto_qmail)); fd = open_read("control/morercpthosts"); if (fd == -1) die_read(); - buffer_init(&bi,read,fd,inbuf,sizeof(inbuf)); + buffer_init(&bi, read, fd, inbuf, sizeof(inbuf)); fdtemp = open_trunc("control/morercpthosts.tmp"); if (fdtemp == -1) die_write(); - if (cdb_make_start(&cdb,fdtemp) == -1) die_write(); + if (cdb_make_start(&cdb, fdtemp) == -1) die_write(); for (;;) { - if (getln(&bi,&line,&match,'\n') != 0) die_read(); - case_lowerb(line.s,line.len); + if (getln(&bi, &line, &match, '\n') != 0) die_read(); + case_lowerb(line.s, line.len); while (line.len) { - if (line.s[line.len - 1] == ' ') { --line.len; continue; } - if (line.s[line.len - 1] == '\n') { --line.len; continue; } - if (line.s[line.len - 1] == '\t') { --line.len; continue; } + if (line.s[line.len - 1] == ' ') { + --line.len; + continue; + } + if (line.s[line.len - 1] == '\n') { + --line.len; + continue; + } + if (line.s[line.len - 1] == '\t') { + --line.len; + continue; + } if (line.s[0] != '#') - if (cdb_make_add(&cdb,line.s,line.len,"",0) == -1) - die_write(); + if (cdb_make_add(&cdb, line.s, line.len, "", 0) == -1) die_write(); break; } if (!match) break; @@ -68,8 +78,8 @@ int main() if (cdb_make_finish(&cdb) == -1) die_write(); if (fsync(fdtemp) == -1) die_write(); if (close(fdtemp) == -1) die_write(); /* NFS stupidity */ - if (rename("control/morercpthosts.tmp","control/morercpthosts.cdb") == -1) - logmsg(WHO,111,ERROR,"unable to move control/morercpthosts.tmp to control/morercpthosts.cdb"); + if (rename("control/morercpthosts.tmp", "control/morercpthosts.cdb") == -1) + logmsg(WHO, 111, ERROR, "unable to move control/morercpthosts.tmp to control/morercpthosts.cdb"); _exit(0); } -- cgit v1.2.3