summaryrefslogtreecommitdiff
path: root/src/qmail-send.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmail-send.c')
-rw-r--r--src/qmail-send.c67
1 files changed, 42 insertions, 25 deletions
diff --git a/src/qmail-send.c b/src/qmail-send.c
index 5305d95..31aa60e 100644
--- a/src/qmail-send.c
+++ b/src/qmail-send.c
@@ -71,11 +71,13 @@ void sigterm()
{
flagexitasap = 1;
}
+
int flagrunasap = 0;
void sigalrm()
{
flagrunasap = 1;
}
+
int flagreadasap = 0;
void sighup()
{
@@ -118,26 +120,32 @@ 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_foop(unsigned long id)
{
fn.len = fmtqfn(fn.s, "foop/", id, 0);
}
+
void fnmake_split(unsigned long id)
{
fn.len = fmtqfn(fn.s, "", id, 1);
}
+
void fnmake2_bounce(unsigned long id)
{
fn2.len = fmtqfn(fn2.s, "bounce/", id, 0);
}
+
void fnmake_chanaddr(unsigned long id, int c)
{
fn.len = fmtqfn(fn.s, chanaddr[c], id, 1);
@@ -153,7 +161,7 @@ void senderadd(stralloc *sa, char *sender, char *recip)
int k;
i = str_len(sender);
- if (i >= 4)
+ if (i >= 4) {
if (str_equal(sender + i - 4, "-@[]")) {
j = byte_rchr(sender, i - 4, '@');
k = str_rchr(recip, '@');
@@ -168,6 +176,7 @@ void senderadd(stralloc *sa, char *sender, char *recip)
return;
}
}
+ }
while (!stralloc_cats(sa, sender)) nomem();
}
@@ -256,21 +265,23 @@ void comm_selprep(int *nfds, fd_set *wfds)
{
int c;
- for (c = 0; c < CHANNELS; ++c)
- if (flagspawnalive[c])
+ for (c = 0; c < CHANNELS; ++c) {
+ if (flagspawnalive[c]) {
if (comm_buf[c].s && comm_buf[c].len) {
FD_SET(chanfdout[c], wfds);
if (*nfds <= chanfdout[c]) *nfds = chanfdout[c] + 1;
}
+ }
+ }
}
void comm_do(fd_set *wfds)
{
int c;
- for (c = 0; c < CHANNELS; ++c)
- if (flagspawnalive[c])
- if (comm_buf[c].s && comm_buf[c].len)
+ for (c = 0; c < CHANNELS; ++c) {
+ if (flagspawnalive[c]) {
+ if (comm_buf[c].s && comm_buf[c].len) {
if (FD_ISSET(chanfdout[c], wfds)) {
int w;
int len;
@@ -287,6 +298,9 @@ void comm_do(fd_set *wfds)
if (comm_pos[c] == len) comm_buf[c].len = 0;
}
}
+ }
+ }
+ }
}
@@ -432,7 +446,7 @@ void pqfinish()
struct prioq_elt pe;
time_t ut[2]; /* XXX: more portable than utimbuf, but still worrisome */
- for (c = 0; c < CHANNELS; ++c)
+ for (c = 0; c < CHANNELS; ++c) {
while (prioq_min(&pqchan[c], &pe)) {
prioq_delmin(&pqchan[c]);
fnmake_chanaddr(pe.id, c);
@@ -440,6 +454,7 @@ void pqfinish()
if (utime(fn.s, ut) == -1)
log3s("warning: unable to utime ", fn.s, "; message will be retried too soon\n");
}
+ }
}
void pqrun()
@@ -555,8 +570,8 @@ char *stripvdomprepend(char *recip)
domain = recip + i + 1;
domainlen = str_len(domain);
- for (i = 0; i <= domainlen; ++i)
- if ((i == 0) || (i == domainlen) || (domain[i] == '.'))
+ for (i = 0; i <= domainlen; ++i) {
+ if ((i == 0) || (i == domainlen) || (domain[i] == '.')) {
if ((prepend = constmap(&mapvdoms, domain + i, domainlen - i))) {
if (!*prepend) break;
i = str_len(prepend);
@@ -564,6 +579,8 @@ char *stripvdomprepend(char *recip)
if (recip[i] != '-') break;
return recip + i + 1;
}
+ }
+ }
return recip;
}
@@ -610,8 +627,9 @@ void addbounce(unsigned long id, char *recip, char *report)
if (w <= 0) {
log1s("alert: unable to append to bounce message; HELP! sleeping...\n");
sleep(10);
- } else
+ } else {
pos += w;
+ }
}
close(fd);
}
@@ -637,11 +655,10 @@ int injectbounce(unsigned long id)
if (!getinfo(&sender, &birth, id)) return 0; /* XXX: print warning */
/* owner-@host-@[] -> owner-@host */
- if (sender.len >= 5)
- if (str_equal(sender.s + sender.len - 5, "-@[]")) {
- sender.len -= 4;
- sender.s[sender.len - 1] = 0;
- }
+ if (sender.len >= 5 && str_equal(sender.s + sender.len - 5, "-@[]")) {
+ sender.len -= 4;
+ sender.s[sender.len - 1] = 0;
+ }
fnmake2_bounce(id);
fnmake_mess(id);
@@ -652,11 +669,11 @@ int injectbounce(unsigned long id)
return 0;
}
- if (str_equal(sender.s, "#@[]"))
+ if (str_equal(sender.s, "#@[]")) {
log3s("triple bounce: discarding ", fn2.s, "\n");
- else if (!*sender.s && *doublebounceto.s == '@')
+ } else if (!*sender.s && *doublebounceto.s == '@') {
log3s("double bounce: discarding ", fn2.s, "\n");
- else {
+ } else {
if (qmail_open(&qqt) == -1) {
log1s("warning: unable to start qmail-queue, will try later\n");
return 0;
@@ -701,9 +718,9 @@ I tried to deliver a bounce message to this address, but the bounce bounced!\n\
");
fd = open_read(fn2.s);
- if (fd == -1)
+ if (fd == -1) {
qmail_fail(&qqt);
- else {
+ } else {
buffer_init(&bi, read, fd, inbuf, sizeof(inbuf));
while ((r = buffer_get(&bi, buf, sizeof(buf))) > 0) qmail_put(&qqt, buf, r);
@@ -721,9 +738,9 @@ I tried to deliver a bounce message to this address, but the bounce bounced!\n\
qmail_puts(&qqt, ">\n");
fd = open_read(fn.s);
- if (fd == -1)
+ if (fd == -1) {
qmail_fail(&qqt);
- else {
+ } else {
if (bouncemaxbytes) {
bytestogo = bouncemaxbytes;
bytestoget = (bytestogo < sizeof(buf)) ? bytestogo : sizeof(buf);
@@ -926,9 +943,9 @@ void del_dochan(int c)
if (!ch && (dline[c].len > 1)) {
delnum = (unsigned int)(unsigned char)dline[c].s[0];
- if ((delnum < 0) || (delnum >= concurrency[c]) || !d[c][delnum].used)
+ if ((delnum < 0) || (delnum >= concurrency[c]) || !d[c][delnum].used) {
log1s("warning: internal error: delivery report out of range\n");
- else {
+ } else {
strnum3[fmt_ulong(strnum3, d[c][delnum].delid)] = 0;
if (dline[c].s[1] == 'Z')
if (jo[d[c][delnum].j].flagdying) {
@@ -1122,11 +1139,11 @@ void pass_dochan(int c)
}
switch (line.s[0]) {
+ case 'D': break;
case 'T':
++jo[pass[c].j].numtodo;
del_start(pass[c].j, pass[c].mpos, line.s + 1);
break;
- case 'D': break;
default:
fnmake_chanaddr(pass[c].id, c);
log3s("warning: unknown record type in ", fn.s, "!\n");