diff options
| author | manuel <manuel@mausz.at> | 2013-02-04 00:08:53 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-02-04 00:08:53 +0100 |
| commit | 69aec538b456402170dc723af417ba5c05389c32 (patch) | |
| tree | e6f34c543f17c6392447ea337b2e2868212424d1 /received.c | |
| download | qmail-69aec538b456402170dc723af417ba5c05389c32.tar.gz qmail-69aec538b456402170dc723af417ba5c05389c32.tar.bz2 qmail-69aec538b456402170dc723af417ba5c05389c32.zip | |
qmail 1.03 import
Diffstat (limited to 'received.c')
| -rw-r--r-- | received.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/received.c b/received.c new file mode 100644 index 0000000..07706d5 --- /dev/null +++ b/received.c | |||
| @@ -0,0 +1,71 @@ | |||
| 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 | } | ||
