|
1 #include "fmt.h" |
|
2 #include "qmail.h" |
|
3 #include "now.h" |
|
4 #include "datetime.h" |
|
5 #include "date822fmt.h" |
|
6 #include "received.h" |
|
7 |
|
8 static int issafe(ch) char ch; |
|
9 { |
|
10 if (ch == '.') return 1; |
|
11 if (ch == '@') return 1; |
|
12 if (ch == '%') return 1; |
|
13 if (ch == '+') return 1; |
|
14 if (ch == '/') return 1; |
|
15 if (ch == '=') return 1; |
|
16 if (ch == ':') return 1; |
|
17 if (ch == '-') return 1; |
|
18 if ((ch >= 'a') && (ch <= 'z')) return 1; |
|
19 if ((ch >= 'A') && (ch <= 'Z')) return 1; |
|
20 if ((ch >= '0') && (ch <= '9')) return 1; |
|
21 return 0; |
|
22 } |
|
23 |
|
24 void safeput(qqt,s) |
|
25 struct qmail *qqt; |
|
26 char *s; |
|
27 { |
|
28 char ch; |
|
29 while (ch = *s++) { |
|
30 if (!issafe(ch)) ch = '?'; |
|
31 qmail_put(qqt,&ch,1); |
|
32 } |
|
33 } |
|
34 |
|
35 static char buf[DATE822FMT]; |
|
36 |
|
37 /* "Received: from relay1.uu.net (HELO uunet.uu.net) (7@192.48.96.5)\n" */ |
|
38 /* " by silverton.berkeley.edu with SMTP; 26 Sep 1995 04:46:54 -0000\n" */ |
|
39 |
|
40 void received(qqt,protocol,local,remoteip,remotehost,remoteinfo,helo) |
|
41 struct qmail *qqt; |
|
42 char *protocol; |
|
43 char *local; |
|
44 char *remoteip; |
|
45 char *remotehost; |
|
46 char *remoteinfo; |
|
47 char *helo; |
|
48 { |
|
49 struct datetime dt; |
|
50 |
|
51 qmail_puts(qqt,"Received: from "); |
|
52 safeput(qqt,remotehost); |
|
53 if (helo) { |
|
54 qmail_puts(qqt," (HELO "); |
|
55 safeput(qqt,helo); |
|
56 qmail_puts(qqt,")"); |
|
57 } |
|
58 qmail_puts(qqt," ("); |
|
59 if (remoteinfo) { |
|
60 safeput(qqt,remoteinfo); |
|
61 qmail_puts(qqt,"@"); |
|
62 } |
|
63 safeput(qqt,remoteip); |
|
64 qmail_puts(qqt,")\n by "); |
|
65 safeput(qqt,local); |
|
66 qmail_puts(qqt," with "); |
|
67 qmail_puts(qqt,protocol); |
|
68 qmail_puts(qqt,"; "); |
|
69 datetime_tai(&dt,now()); |
|
70 qmail_put(qqt,buf,date822fmt(buf,&dt)); |
|
71 } |