1 #include "auto_qmail.h"
12 void resources() { _exit(111); }
14 int safewrite(fd,buf,len) int fd; char *buf; int len;
17 r = write(fd,buf,len);
21 int saferead(fd,buf,len) int fd; char *buf; int len;
30 substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
32 substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof ssoutbuf);
34 unsigned long bytesleft = 100;
39 if (!bytesleft--) _exit(100);
40 substdio_get(&ssin,ch,1);
43 unsigned long getlen()
45 unsigned long len = 0;
50 if (ch == ':') return len;
51 if (len > 200000000) resources();
52 len = 10 * len + (ch - '0');
60 if (ch != ',') _exit(100);
72 remotehost = env_get("TCPREMOTEHOST");
73 if (!remotehost) remotehost = "unknown";
74 remoteinfo = env_get("TCPREMOTEINFO");
75 remoteip = env_get("TCPREMOTEIP");
76 if (!remoteip) remoteip = "unknown";
77 local = env_get("TCPLOCALHOST");
78 if (!local) local = env_get("TCPLOCALIP");
79 if (!local) local = "unknown";
81 received(&qq,"QMQP",local,remoteip,remotehost,remoteinfo,(char *) 0);
85 char strnum[FMT_ULONG];
94 for (i = 0;i < len;++i) getbyte(buf);
100 for (i = 0;i < len;++i) getbyte(buf + i);
103 return byte_chr(buf,len,'\0') == len;
116 sig_alarmcatch(resources);
119 bytesleft = getlen();
123 if (chdir(auto_qmail) == -1) resources();
124 if (qmail_open(&qq) == -1) resources();
128 while (len > 0) { /* XXX: could speed this up */
131 qmail_put(&qq,&ch,1);
154 result = qmail_close(&qq);
157 len = fmt_str(buf,"Kok ");
158 len += fmt_ulong(buf + len,(unsigned long) now());
159 len += fmt_str(buf + len," qp ");
160 len += fmt_ulong(buf + len,qp);
166 result = "Dsorry, I can't accept addresses like that (#5.1.3)";
168 substdio_put(&ssout,strnum,fmt_ulong(strnum,(unsigned long) str_len(result)));
169 substdio_puts(&ssout,":");
170 substdio_puts(&ssout,result);
171 substdio_puts(&ssout,",");
172 substdio_flush(&ssout);