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-recipients.c | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/qmail-recipients.c')
-rw-r--r-- | src/qmail-recipients.c | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/src/qmail-recipients.c b/src/qmail-recipients.c index 058994a..4fb2fb8 100644 --- a/src/qmail-recipients.c +++ b/src/qmail-recipients.c @@ -1,26 +1,28 @@ -#include <unistd.h> #include <sys/stat.h> -#include "logmsg.h" -#include "stralloc.h" +#include <unistd.h> + #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 "case.h" +#include "stralloc.h" + #include "auto_qmail.h" -#include "cdbmake.h" #define WHO "qmail-recipients" -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 users/recipients"); + logmsg(WHO, 111, ERROR, "unable to read users/recipients"); } void die_write() { - logmsg(WHO,111,ERROR,"unable to write to users/recipients.tmp"); + logmsg(WHO, 111, ERROR, "unable to write to users/recipients.tmp"); } char inbuf[1024]; @@ -31,36 +33,43 @@ int fdtemp; struct cdb_make cdb; stralloc line = {0}; -stralloc key = {0}; +stralloc key = {0}; int match; int main() { umask(033); - if (chdir(auto_qmail) == -1) - logmsg(WHO,110,ERROR,B("unable to chdir to: ",auto_qmail)); + if (chdir(auto_qmail) == -1) logmsg(WHO, 110, ERROR, B("unable to chdir to: ", auto_qmail)); fd = open_read("users/recipients"); if (fd == -1) die_read(); - buffer_init(&b,read,fd,inbuf,sizeof(inbuf)); + buffer_init(&b, read, fd, inbuf, sizeof(inbuf)); fdtemp = open_trunc("users/recipients.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 (;;) { - stralloc_copys(&key,":"); - if (getln(&b,&line,&match,'\n') != 0) die_read(); + stralloc_copys(&key, ":"); + if (getln(&b, &line, &match, '\n') != 0) die_read(); 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[0] != '#' && stralloc_cat(&key,&line)) { - case_lowerb(key.s,key.len); - if (cdb_make_add(&cdb,key.s,key.len,"",0) == -1) - die_write(); + 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] != '#' && stralloc_cat(&key, &line)) { + case_lowerb(key.s, key.len); + if (cdb_make_add(&cdb, key.s, key.len, "", 0) == -1) die_write(); } break; } @@ -70,8 +79,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("users/recipients.tmp","users/recipients.cdb") == -1) - logmsg(WHO,111,ERROR,"unable to move users/recipients.tmp to users/recipients.cdb"); + if (rename("users/recipients.tmp", "users/recipients.cdb") == -1) + logmsg(WHO, 111, ERROR, "unable to move users/recipients.tmp to users/recipients.cdb"); _exit(0); } |