diff options
Diffstat (limited to 'src/qmail-todo.c')
-rw-r--r-- | src/qmail-todo.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/qmail-todo.c b/src/qmail-todo.c index 34be551..411f514 100644 --- a/src/qmail-todo.c +++ b/src/qmail-todo.c @@ -59,6 +59,7 @@ void sighup(void) { flagreadasap = 1; } + int flagsendalive = 1; void senddied(void) { @@ -85,14 +86,17 @@ void fnmake_info(unsigned long id) { fn.len = fmtqfn(fn.s, "info/", id, 1); } + void fnmake_todo(unsigned long id) { fn.len = fmtqfn(fn.s, "todo/", id, 1); } + void fnmake_mess(unsigned long id) { fn.len = fmtqfn(fn.s, "mess/", id, 1); } + void fnmake_chanaddr(unsigned long id, int c) { fn.len = fmtqfn(fn.s, chanaddr[c], id, 1); @@ -139,8 +143,8 @@ int rewrite(char *recip) return 1; } - for (i = 0; i <= addr.len; ++i) - if (!i || (i == at + 1) || (i == addr.len) || ((i > at) && (addr.s[i] == '.'))) + for (i = 0; i <= addr.len; ++i) { + if (!i || (i == at + 1) || (i == addr.len) || ((i > at) && (addr.s[i] == '.'))) { if ((x = constmap(&mapvdoms, addr.s + i, addr.len - i))) { if (!*x) break; if (!stralloc_cats(&rwline, x)) return 0; @@ -149,6 +153,8 @@ int rewrite(char *recip) if (!stralloc_0(&rwline)) return 0; return 1; } + } + } if (!stralloc_cat(&rwline, &addr)) return 0; if (!stralloc_0(&rwline)) return 0; @@ -263,11 +269,12 @@ void comm_info(unsigned long id, unsigned long size, char *from, unsigned long p i = comm_buf.len; if (!stralloc_cats(&comm_buf, from)) goto FAIL; - for (; i < comm_buf.len; ++i) + for (; i < comm_buf.len; ++i) { if (comm_buf.s[i] == '\n') comm_buf.s[i] = '/'; else if (!issafe(comm_buf.s[i])) comm_buf.s[i] = '_'; + } if (!stralloc_cats(&comm_buf, "> qp ")) goto FAIL; strnum[fmt_ulong(strnum, pid)] = 0; @@ -307,8 +314,8 @@ void comm_selprep(int *nfds, fd_set *wfds, fd_set *rfds) void comm_do(fd_set *wfds, fd_set *rfds) { /* first write then read */ - if (flagsendalive) - if (comm_canwrite()) + if (flagsendalive) { + if (comm_canwrite()) { if (FD_ISSET(fdout, wfds)) { int w; int len; @@ -324,7 +331,9 @@ void comm_do(fd_set *wfds, fd_set *rfds) } } } - if (flagsendalive) + } + } + if (flagsendalive) { if (FD_ISSET(fdin, rfds)) { /* there are only two messages 'H' and 'X' */ char c; @@ -340,6 +349,7 @@ void comm_do(fd_set *wfds, fd_set *rfds) } } } + } } /* this file is not so long ------------------------------------------ TODO */ @@ -423,19 +433,21 @@ void todo_do(fd_set *rfds) for (c = 0; c < CHANNELS; ++c) { fnmake_chanaddr(id, c); - if (unlink(fn.s) == -1) + if (unlink(fn.s) == -1) { if (errno != ENOENT) { sendlog3("warning: qmail-todo: unable to unlink ", fn.s, " for mess\n"); goto FAIL; } + } } fnmake_info(id); - if (unlink(fn.s) == -1) + if (unlink(fn.s) == -1) { if (errno != ENOENT) { sendlog3("warning: qmail-todo: unable to unlink ", fn.s, " for info\n"); goto FAIL; } + } fdnumber = open_excl(fn.s); if (fdnumber == -1) { @@ -518,7 +530,7 @@ void todo_do(fd_set *rfds) close(fdnumber); fdnumber = -1; - for (c = 0; c < CHANNELS; ++c) + for (c = 0; c < CHANNELS; ++c) { if (fdchan[c] != -1) { fnmake_chanaddr(id, c); if (buffer_flush(&bchan[c]) == -1) { @@ -532,6 +544,7 @@ void todo_do(fd_set *rfds) close(fdchan[c]); fdchan[c] = -1; } + } fnmake_todo(id); if (buffer_putflush(&toqc, fn.s, fn.len) == -1) { @@ -613,8 +626,9 @@ void regetcontrols(void) if (r) { while (!stralloc_copy(&vdoms, &newvdoms)) nomem(); while (!constmap_init(&mapvdoms, vdoms.s, vdoms.len, 1)) nomem(); - } else + } else { while (!constmap_init(&mapvdoms, "", 0, 1)) nomem(); + } } void reread(void) @@ -692,12 +706,12 @@ int main() tv.tv_sec = wakeup - recent + SLEEP_FUZZ; tv.tv_usec = 0; - if (select(nfds, &rfds, &wfds, (fd_set *)0, &tv) == -1) + if (select(nfds, &rfds, &wfds, (fd_set *)0, &tv) == -1) { if (errno == EINTR) ; else sendlog1("warning: qmail-todo: trouble in select\n"); - else { + } else { recent = now(); todo_do(&rfds); |