8 #include "auto_qmail.h"
10 static char *binqqargs[2] = { "/usr/sbin/qmail-queue", 0 } ;
18 if (pipe(pim) == -1) return -1;
19 if (pipe(pie) == -1) { close(pim[0]); close(pim[1]); return -1; }
21 switch(qq->pid = vfork()) {
23 close(pim[0]); close(pim[1]);
24 close(pie[0]); close(pie[1]);
29 if (fd_move(0,pim[0]) == -1) _exit(120);
30 if (fd_move(1,pie[0]) == -1) _exit(120);
31 if (chdir(auto_qmail) == -1) _exit(61);
32 execv(*binqqargs,binqqargs);
36 qq->fdm = pim[1]; close(pim[0]);
37 qq->fde = pie[1]; close(pie[0]);
38 substdio_fdbuf(&qq->ss,write,qq->fdm,qq->buf,sizeof(qq->buf));
43 unsigned long qmail_qp(qq) struct qmail *qq;
48 void qmail_fail(qq) struct qmail *qq;
53 void qmail_put(qq,s,len) struct qmail *qq; char *s; int len;
55 if (!qq->flagerr) if (substdio_put(&qq->ss,s,len) == -1) qq->flagerr = 1;
58 void qmail_puts(qq,s) struct qmail *qq; char *s;
60 if (!qq->flagerr) if (substdio_puts(&qq->ss,s) == -1) qq->flagerr = 1;
63 void qmail_from(qq,s) struct qmail *qq; char *s;
65 if (substdio_flush(&qq->ss) == -1) qq->flagerr = 1;
67 substdio_fdbuf(&qq->ss,write,qq->fde,qq->buf,sizeof(qq->buf));
73 void qmail_to(qq,s) struct qmail *qq; char *s;
87 if (!qq->flagerr) if (substdio_flush(&qq->ss) == -1) qq->flagerr = 1;
90 if (wait_pid(&wstat,qq->pid) != qq->pid)
91 return "Zqq waitpid surprise (#4.3.0)";
92 if (wait_crashed(wstat))
93 return "Zqq crashed (#4.3.0)";
94 exitcode = wait_exitcode(wstat);
97 case 115: /* compatibility */
98 case 11: return "Denvelope address too long for qq (#5.1.3)";
99 case 31: return "Dmail server permanently rejected message (#5.3.0)";
100 case 51: return "Zqq out of memory (#4.3.0)";
101 case 52: return "Zqq timeout (#4.3.0)";
102 case 53: return "Zqq write error or disk full (#4.3.0)";
103 case 0: if (!qq->flagerr) return ""; /* fall through */
104 case 54: return "Zqq read error (#4.3.0)";
105 case 55: return "Zqq unable to read configuration (#4.3.0)";
106 case 56: return "Zqq trouble making network connection (#4.3.0)";
107 case 61: return "Zqq trouble in home directory (#4.3.0)";
112 case 62: return "Zqq trouble creating files in queue (#4.3.0)";
113 case 71: return "Zmail server temporarily rejected message (#4.3.0)";
114 case 72: return "Zconnection to mail server timed out (#4.4.1)";
115 case 73: return "Zconnection to mail server rejected (#4.4.1)";
116 case 74: return "Zcommunication with mail server failed (#4.4.2)";
117 case 91: /* fall through */
118 case 81: return "Zqq internal bug (#4.3.0)";
119 case 120: return "Zunable to exec qq (#4.3.0)";
121 if ((exitcode >= 11) && (exitcode <= 40))
122 return "Dqq permanent problem (#5.3.0)";
123 return "Zqq temporary problem (#4.3.0)";