diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
commit | a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch) | |
tree | b88cc7a8457658d67e0321718556ac807f6bccf3 /src/qmail-newmrh.c | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/qmail-newmrh.c')
-rw-r--r-- | src/qmail-newmrh.c | 56 |
1 files changed, 33 insertions, 23 deletions
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 <unistd.h> #include <sys/stat.h> -#include <stdio.h> // rename -#include "logmsg.h" -#include "stralloc.h" +#include <unistd.h> + +#include <stdio.h> // 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); } |