File: received.c

package info (click to toggle)
qmail 1.03-14
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 2,648 kB
  • ctags: 1,885
  • sloc: ansic: 14,818; makefile: 2,198; sh: 605; perl: 537
file content (71 lines) | stat: -rw-r--r-- 1,545 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "fmt.h"
#include "qmail.h"
#include "now.h"
#include "datetime.h"
#include "date822fmt.h"
#include "received.h"

static int issafe(ch) char ch;
{
  if (ch == '.') return 1;
  if (ch == '@') return 1;
  if (ch == '%') return 1;
  if (ch == '+') return 1;
  if (ch == '/') return 1;
  if (ch == '=') return 1;
  if (ch == ':') return 1;
  if (ch == '-') return 1;
  if ((ch >= 'a') && (ch <= 'z')) return 1;
  if ((ch >= 'A') && (ch <= 'Z')) return 1;
  if ((ch >= '0') && (ch <= '9')) return 1;
  return 0;
}

void safeput(qqt,s)
struct qmail *qqt;
char *s;
{
  char ch;
  while (ch = *s++) {
    if (!issafe(ch)) ch = '?';
    qmail_put(qqt,&ch,1);
  }
}

static char buf[DATE822FMT];

/* "Received: from relay1.uu.net (HELO uunet.uu.net) (7@192.48.96.5)\n" */
/* "  by silverton.berkeley.edu with SMTP; 26 Sep 1995 04:46:54 -0000\n" */

void received(qqt,protocol,local,remoteip,remotehost,remoteinfo,helo)
struct qmail *qqt;
char *protocol;
char *local;
char *remoteip;
char *remotehost;
char *remoteinfo;
char *helo;
{
  struct datetime dt;

  qmail_puts(qqt,"Received: from ");
  safeput(qqt,remotehost);
  if (helo) {
    qmail_puts(qqt," (HELO ");
    safeput(qqt,helo);
    qmail_puts(qqt,")");
  }
  qmail_puts(qqt," (");
  if (remoteinfo) {
    safeput(qqt,remoteinfo);
    qmail_puts(qqt,"@");
  }
  safeput(qqt,remoteip);
  qmail_puts(qqt,")\n  by ");
  safeput(qqt,local);
  qmail_puts(qqt," with ");
  qmail_puts(qqt,protocol);
  qmail_puts(qqt,"; ");
  datetime_tai(&dt,now());
  qmail_put(qqt,buf,date822fmt(buf,&dt));
}