summaryrefslogtreecommitdiffstats
path: root/newfield.c
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2013-02-04 00:08:53 +0100
committermanuel <manuel@mausz.at>2013-02-04 00:08:53 +0100
commit69aec538b456402170dc723af417ba5c05389c32 (patch)
treee6f34c543f17c6392447ea337b2e2868212424d1 /newfield.c
downloadqmail-69aec538b456402170dc723af417ba5c05389c32.tar.gz
qmail-69aec538b456402170dc723af417ba5c05389c32.tar.bz2
qmail-69aec538b456402170dc723af417ba5c05389c32.zip
qmail 1.03 import
Diffstat (limited to 'newfield.c')
-rw-r--r--newfield.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/newfield.c b/newfield.c
new file mode 100644
index 0000000..78d6bb8
--- /dev/null
+++ b/newfield.c
@@ -0,0 +1,68 @@
1#include "fmt.h"
2#include "datetime.h"
3#include "stralloc.h"
4#include "date822fmt.h"
5#include "newfield.h"
6
7/* "Date: 26 Sep 1995 04:46:53 -0000\n" */
8stralloc newfield_date = {0};
9/* "Message-ID: <19950926044653.12345.qmail@silverton.berkeley.edu>\n" */
10stralloc newfield_msgid = {0};
11
12static unsigned int datefmt(s,when)
13char *s;
14datetime_sec when;
15{
16 unsigned int i;
17 unsigned int len;
18 struct datetime dt;
19 datetime_tai(&dt,when);
20 len = 0;
21 i = fmt_str(s,"Date: "); len += i; if (s) s += i;
22 i = date822fmt(s,&dt); len += i; if (s) s += i;
23 return len;
24}
25
26static unsigned int msgidfmt(s,idhost,idhostlen,when)
27char *s;
28char *idhost;
29int idhostlen;
30datetime_sec when;
31{
32 unsigned int i;
33 unsigned int len;
34 struct datetime dt;
35 datetime_tai(&dt,when);
36 len = 0;
37 i = fmt_str(s,"Message-ID: <"); len += i; if (s) s += i;
38 i = fmt_uint(s,dt.year + 1900); len += i; if (s) s += i;
39 i = fmt_uint0(s,dt.mon + 1,2); len += i; if (s) s += i;
40 i = fmt_uint0(s,dt.mday,2); len += i; if (s) s += i;
41 i = fmt_uint0(s,dt.hour,2); len += i; if (s) s += i;
42 i = fmt_uint0(s,dt.min,2); len += i; if (s) s += i;
43 i = fmt_uint0(s,dt.sec,2); len += i; if (s) s += i;
44 i = fmt_str(s,"."); len += i; if (s) s += i;
45 i = fmt_uint(s,getpid()); len += i; if (s) s += i;
46 i = fmt_str(s,".qmail@"); len += i; if (s) s += i;
47 i = fmt_strn(s,idhost,idhostlen); len += i; if (s) s += i;
48 i = fmt_str(s,">\n"); len += i; if (s) s += i;
49 return len;
50}
51
52int newfield_datemake(when)
53datetime_sec when;
54{
55 if (!stralloc_ready(&newfield_date,datefmt(FMT_LEN,when))) return 0;
56 newfield_date.len = datefmt(newfield_date.s,when);
57 return 1;
58}
59
60int newfield_msgidmake(idhost,idhostlen,when)
61char *idhost;
62int idhostlen;
63datetime_sec when;
64{
65 if (!stralloc_ready(&newfield_msgid,msgidfmt(FMT_LEN,idhost,idhostlen,when))) return 0;
66 newfield_msgid.len = msgidfmt(newfield_msgid.s,idhost,idhostlen,when);
67 return 1;
68}