| ---
tmail.c (1346B)
---
1 #include "common.h"
2
3 /* format of REMOTE FROM lines */
4 char *REMFROMRE =
5 "^>?From[ \t]+((\".*\")?[^\" \t]+?(\".*\")?[^\" \t]+?)[ \t]+(.+)[ \t]+remote[ \t]+from[ \t]+(.*)\n$";
6 int REMSENDERMATCH = 1;
7 int REMDATEMATCH = 4;
8 int REMSYSMATCH = 5;
9
10 /* format of LOCAL FROM lines */
11 char *FROMRE =
12 "^>?From[ \t]+((\".*\")?[^\" \t]+?(\".*\")?[^\" \t]+?)[ \t]+(.+)\n$";
13 int SENDERMATCH = 1;
14 int DATEMATCH = 4;
15
16 /* output a unix style local header */
17 int
18 print_header(Biobuf *fp, char *sender, char *date)
19 {
20 return Bprint(fp, "From %s %s\n", sender, date);
21 }
22
23 /* output a unix style remote header */
24 int
25 print_remote_header(Biobuf *fp, char *sender, char *date, char *system)
26 {
27 return Bprint(fp, "From %s %s remote from %s\n", sender, date, system);
28 }
29
30 /* parse a mailbox style header */
31 int
32 parse_header(char *line, String *sender, String *date)
33 {
34 if (!IS_HEADER(line))
35 return -1;
36 line += sizeof("From ") - 1;
37 s_restart(sender);
38 while(*line==' '||*line=='\t')
39 line++;
40 if(*line == '"'){
41 s_putc(sender, *line++);
42 while(*line && *line != '"')
43 s_putc(sender, *line++);
44 s_putc(sender, *line++);
45 } else {
46 while(*line && *line != ' ' && *line != '\t')
47 s_putc(sender, *line++);
48 }
49 s_terminate(sender);
50 s_restart(date);
51 while(*line==' '||*line=='\t')
52 line++;
53 while(*line)
54 s_putc(date, *line++);
55 s_terminate(date);
56 return 0;
57 } |