diff options
Diffstat (limited to 'sqmail-4.3.07/src/qmail-newmrh.c')
-rw-r--r-- | sqmail-4.3.07/src/qmail-newmrh.c | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/sqmail-4.3.07/src/qmail-newmrh.c b/sqmail-4.3.07/src/qmail-newmrh.c deleted file mode 100644 index 4a74698..0000000 --- a/sqmail-4.3.07/src/qmail-newmrh.c +++ /dev/null @@ -1,75 +0,0 @@ -#include <unistd.h> -#include <sys/stat.h> -#include <stdio.h> // rename -#include "logmsg.h" -#include "stralloc.h" -#include "buffer.h" -#include "getln.h" -#include "exit.h" -#include "open.h" -#include "auto_qmail.h" -#include "cdbmake.h" -#include "case.h" - -#define WHO "qmail-newmrh" - -int rename(const char *,const char *); // stdio.h - -void die_read() -{ - logmsg(WHO,111,ERROR,"unable to read control/morercpthosts"); -} -void die_write() -{ - logmsg(WHO,111,ERROR,"unable to write to control/morercpthosts.tmp"); -} - -char inbuf[1024]; -buffer bi; - -int fd; -int fdtemp; - -struct cdb_make cdb; -stralloc line = {0}; -int match; - -int main() -{ - umask(033); - 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)); - - fdtemp = open_trunc("control/morercpthosts.tmp"); - if (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); - 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] != '#') - if (cdb_make_add(&cdb,line.s,line.len,"",0) == -1) - die_write(); - break; - } - if (!match) break; - } - - 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"); - - _exit(0); -} |