summaryrefslogtreecommitdiff
path: root/src/forward.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/forward.c')
-rw-r--r--src/forward.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/src/forward.c b/src/forward.c
index 7cc8e53..e8c7eb0 100644
--- a/src/forward.c
+++ b/src/forward.c
@@ -1,28 +1,33 @@
#include <unistd.h>
-#include "sig.h"
-#include "exit.h"
-#include "env.h"
-#include "qmail.h"
-#include "logmsg.h"
+
#include "buffer.h"
+#include "env.h"
+#include "exit.h"
#include "fmt.h"
+#include "logmsg.h"
+#include "sig.h"
+
+#include "qmail.h"
#define WHO "forward"
-void die_nomem() { logmsg(WHO,111,FATAL,"out of memory"); }
+void die_nomem()
+{
+ logmsg(WHO, 111, FATAL, "out of memory");
+}
struct qmail qqt;
ssize_t mywrite(int fd, char *buf, int len)
{
- qmail_put(&qqt,buf,len);
+ qmail_put(&qqt, buf, len);
return len;
}
char inbuf[BUFFER_INSIZE];
-buffer bi = BUFFER_INIT(read,0,inbuf,sizeof(inbuf));
+buffer bi = BUFFER_INIT(read, 0, inbuf, sizeof(inbuf));
char outbuf[1];
-buffer bo = BUFFER_INIT(mywrite,-1,outbuf,sizeof(outbuf));
+buffer bo = BUFFER_INIT(mywrite, -1, outbuf, sizeof(outbuf));
char num[FMT_ULONG];
@@ -31,28 +36,24 @@ int main(int argc, char **argv)
char *sender;
char *dtline;
char *qqx;
-
+
sig_pipeignore();
-
+
sender = env_get("NEWSENDER");
- if (!sender)
- logmsg(WHO,100,FATAL,"NEWSENDER not set");
+ if (!sender) logmsg(WHO, 100, FATAL, "NEWSENDER not set");
dtline = env_get("DTLINE");
- if (!dtline)
- logmsg(WHO,100,FATAL,"DTLINE not set");
-
- if (qmail_open(&qqt) == -1)
- logmsg(WHO,111,FATAL,"unable to fork: ");
- qmail_puts(&qqt,dtline);
- if (buffer_copy(&bo,&bi) != 0)
- logmsg(WHO,111,FATAL,"unable to read message: ");
+ if (!dtline) logmsg(WHO, 100, FATAL, "DTLINE not set");
+
+ if (qmail_open(&qqt) == -1) logmsg(WHO, 111, FATAL, "unable to fork: ");
+ qmail_puts(&qqt, dtline);
+ if (buffer_copy(&bo, &bi) != 0) logmsg(WHO, 111, FATAL, "unable to read message: ");
buffer_flush(&bo);
- num[fmt_ulong(num,qmail_qp(&qqt))] = 0;
-
- qmail_from(&qqt,sender);
- while (*++argv) qmail_to(&qqt,*argv);
+ num[fmt_ulong(num, qmail_qp(&qqt))] = 0;
+
+ qmail_from(&qqt, sender);
+ while (*++argv) qmail_to(&qqt, *argv);
qqx = qmail_close(&qqt);
- if (*qqx) logmsg(WHO,*qqx == 'D' ? 100 : 111,FATAL,qqx + 1);
- logmsg(WHO,0,LOG,B("qp ",num));
+ if (*qqx) logmsg(WHO, *qqx == 'D' ? 100 : 111, FATAL, qqx + 1);
+ logmsg(WHO, 0, LOG, B("qp ", num));
}