int main(int argc, char **argv) { umask(033); if (argc != 3) strerr_die1sys(111,"qmail-cdb: usage: qmail-cdb rules.cdb rules.tmp"); substdio_fdbuf(&ssin,subread,0,inbuf,sizeof inbuf); fdtemp = open_trunc(argv[2]); if (fdtemp == -1) die_write(argv[2]); if (cdb_make_start(&cdbm,fdtemp) == -1) die_write(argv[2]); for (;;) { if (getln(&ssin,&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(&cdbm,line.s,line.len,"",0) == -1) die_write(argv[2]); break; } if (!match) break; } if (cdb_make_finish(&cdbm) == -1) die_write(argv[2]); if (fsync(fdtemp) == -1) die_write(argv[2]); if (close(fdtemp) == -1) die_write(argv[2]); /* NFS stupidity */ if (rename(argv[2],argv[1]) == -1) strerr_die5sys(111, FATAL, "unable to move ", argv[2], " to ", argv[1]); return 0; }
void fatal2(char *m0, char *m1) { strerr_die5sys(111, FATAL, m0, ": ", m1, ": "); }
void drop2(char *m0, char *m1) { strerr_die5sys(111, DROP, m0, ": ", m1, ": "); }
static void fatalm(char *m0) { strerr_die5sys(111, NAME, id, FATAL, m0, ": "); }