nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

received.c (1602B)


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