20 logmsg(
WHO,111,FATAL,
"out of memory");
23static void putspaces(
int len)
25 while (len-- > 0) buffer_put(buffer_1,
" ",1);
28static void putformat(
char *buf,
unsigned int len)
33 buffer_put(buffer_1,
"_\010",2);
36 buffer_put(buffer_1,buf,1);
37 buffer_put(buffer_1,
"\010",1);
40 buffer_put(buffer_1,buf++,1);
45static void format(stralloc *
out,
char *buf,
int len,
char *pre,
char *style1,
char *style2)
50 if (!stralloc_copys(
out,pre)) nomem();
54 if (ch ==
'\n') ch = 0;
55 if (ch ==
'\t') ch =
' ';
56 if ((ch >= 32) && (ch <= 126)) {
57 if (!stralloc_append(
out,style1)) nomem();
58 if (!stralloc_append(
out,&ch)) nomem();
62 if (!stralloc_cats(
out,style2)) nomem();
63 if (!stralloc_append(
out,
"\\")) nomem();
64 ch2 =
'0' + (ch >> 6);
65 if (!stralloc_cats(
out,style2)) nomem();
66 if (!stralloc_append(
out,&ch2)) nomem();
67 ch2 =
'0' + (7 & (ch >> 3));
68 if (!stralloc_cats(
out,style2)) nomem();
69 if (!stralloc_append(
out,&ch2)) nomem();
71 if (!stralloc_cats(
out,style2)) nomem();
72 if (!stralloc_append(
out,&ch2)) nomem();
89 i = byte_rchr(
leftline.s + pos,73 * 2,
' ') / 2;
92 buffer_puts(buffer_1,
"\n");
97 buffer_puts(buffer_1,
"\n");
100static void doleftright()
115 while (leftxlen + rightxlen > 76) {
117 if (i > leftxlen) i = leftxlen;
119 if (j > rightxlen) j = rightxlen;
120 if (i + j > 76) j = 76 - i;
122 putformat(
leftline.s + leftxpos,i * 2);
123 putspaces(78 - i - j);
124 putformat(
rightline.s + rightxpos,j * 2);
125 buffer_put(buffer_1,
"\n",1);
132 putformat(
leftline.s + leftxpos,leftxlen * 2);
133 putspaces(78 - leftxlen - rightxlen);
134 putformat(
rightline.s + rightxpos,rightxlen * 2);
135 buffer_put(buffer_1,
"\n",1);
138static void putvalue(stralloc *
a,
char *pre)
143 if (j && (
a->s[j - 1] ==
'\n')) --j;
150static void putfields(stralloc *
a)
155 for (j = i = 0; j <
a->len; ++j)
156 if (
a->s[j] ==
'\n') {
157 format(&
leftline,
a->s + i,j - i,
"",
"=",
"_");
163static void putaddr(stralloc *
a,
char *pre,
char *post,
char *style)
171 for (j = i = 0; j <
a->len; ++j)
173 if (
a->s[i] ==
'(') {
175 format(&
leftline,
a->s + comment,str_len(
a->s + comment),pre,
"_",
"=");
180 else if (
a->s[i] ==
'+') {
184 format(&
leftline,
a->s + comment,str_len(
a->s + comment),pre,
"_",
"=");
187 format(&
rightline,addr,str_len(addr),post,style,
"_");
195 format(&
leftline,
a->s + comment,str_len(
a->s + comment),pre,
"_",
"=");
203 unsigned char secpack[TAI_PACK];
210 if (j && (text->s[j - 1] ==
'\n')) --j;
211 format(&
leftline,text->s,j,
"=D=a=t=e=:",
"=",
"_");
231 local.date.year = tm->tm_year + 1900;
232 local.date.month = tm->tm_mon + 1;
233 local.date.day = tm->tm_mday;
234 local.hour = tm->tm_hour;
235 local.minute = tm->tm_min;
236 local.second = tm->tm_sec;
238 if (!stralloc_ready(&
tmp,
caltime_fmt((
char *) 0,&local))) nomem();
275, {
"subject", 0, 0, &
subject, 0, 0, 0 }
276, {
"to", 0, 0, 0, &
to, 0, 0 }
277, {
"cc", 0, 0, 0, &
cc, 0, 0 }
278, {
"bcc", 0, 0, 0, &
bcc, 0, 0 }
279, {
"apparently-to", 0, 0, 0, &
bcc, 0, 0 }
280, {
"notice-requested-upon-delivery-to", 0, 0, 0, &
nrudt, 0, 0 }
281, {
"from", 0, 0, 0, &
from, 0, 0 }
282, {
"sender", 0, 0, 0, &
sender, 0, 0 }
283, {
"reply-to", 0, 0, 0, &
replyto, 0, 0 }
285, {
"mail-followup-to", 0, 0, 0, &
followupto, 0, 0 }
286, {
"message-id", 0, 0, 0, &
mid, 0, 0 }
287, {
"references", 0, 0, 0, &
refs, 0, 0 }
288, {
"in-reply-to", 0, &
threading, 0, 0, 0, 0 }
289, {
"return-path", 0, 0, 0, &
returnpath, 0, 0 }
290, {
"received:", 0, &
envelope, 0, 0, 0, 0 }
291, {
"received-spf", 0, 0, &
spf, 0 , 0, 0 }
292, {
"dkim", 0, 0, &
dkim, 0 , 0, 0 }
293, {
"x-authentication-results", 0, 0, &
qdkim, 0 , 0, 0 }
294, {
"arc-", 0, 0, &
dkim, 0, 0, 0 }
295, {
"delivered-to", 0, &
envelope, 0, 0, 0, 0 }
296, {
"errors-to", 0, &
envelope, 0, 0, 0, 0 }
297, {
"resent-sender", 0, &
envelope, 0, 0, 0 }
298, {
"resent-from", 0, &
envelope, 0, 0, 0, 0 }
299, {
"resent-reply-to", 0, &
envelope, 0, 0, 0, 0 }
300, {
"resent-to", 0, &
envelope, 0, 0, 0, 0 }
301, {
"resent-cc", 0, &
envelope, 0, 0, 0, 0 }
302, {
"resent-bcc", 0, &
envelope, 0, 0, 0, 0 }
303, {
"resent-date", 0, &
envelope, 0, 0, 0, 0 }
304, {
"resent-message-id", 0, &
envelope, 0, 0, 0, 0 }
305, { 0, 0, &
misc, 0, 0, 0, 0 }
308static void finishheader()
312 putvalue(&
subject,
"=S=u=b=j=e=c=t=:");
313 putaddr(&
from,
"=F=r=o=m=:= ",
"",
"+");
317 putaddr(&
returnpath,
"=R=e=t=u=r=n=-=P=a=t=h=:= ",
"=r=e=t=u=r=n= ",
"+");
320 putaddr(&
refs,
"=R=e=f=:= ",
"",
"_");
321 putaddr(&
mid,
"=M=e=s=s=a=g=e=-=I=D=:= ",
"",
"_");
323 buffer_puts(buffer_1,
"------------------------------------------------------------------------------\n");
325 putaddr(&
to,
"=T=o=:= ",
"",
"+");
326 putaddr(&
cc,
"=C=c=:= ",
"",
"+");
327 putaddr(&
bcc,
"=B=c=c=:= ",
"",
"+");
328 putaddr(&
nrudt,
"=N=o=t=i=c=e=-=R=e=q=u=e=s=t=e=d=-=U=p=o=n=-=D=e=l=i=v=e=r=y=-=T=o=:= ",
"",
"+");
330 buffer_puts(buffer_1,
"------------------------------------------------------------------------------\n");
332 putaddr(&
sender,
"=S=e=n=d=e=r=:= ",
"=s=e=n=d=e=r= ",
"+");
333 putaddr(&
replyto,
"=R=e=p=l=y=-=T=o=:= ",
"=r=e=p=l=y= =t=o= ",
"+");
334 putaddr(&
mailreplyto,
"=M=a=i=l=-=R=e=p=l=y=-=T=o=:= ",
"=r=e=p=l=y= =t=o= ",
"+");
335 putaddr(&
followupto,
"=M=a=i=l=-=F=o=l=l=o=w=u=p=-=T=o=:= ",
"=f=o=l=l=o=w= =u=p= =t=o= ",
"+");
337 buffer_puts(buffer_1,
"------------------------------------------------------------------------------\n");
339 putvalue(&
spf,
"=S=P=F=-=V=a=l=i=d=a=t=i=o=n=:=");
341 putvalue(&
qdkim,
"=D=K=I=M=-=V=e=r=i=f=i=c=a=t=i=o=n=:=");
343 buffer_puts(buffer_1,
"------------------------------------------------------------------------------\n");
356 logmsg(
WHO,111,FATAL,
"unable to init leapsecs: ");
360 if (getln(buffer_0,&
line,&
match,
'\n') == -1)
361 logmsg(
WHO,111,FATAL,
"unable to read input: ");
368 buffer_put(buffer_1,
line.s,
line.len);
376 buffer_flush(buffer_1);
unsigned char secpack[TAI_PACK]
unsigned int caltime_fmt(char *s, struct caltime *ct)
int mess822_line(mess822_header *, stralloc *)
int mess822_end(mess822_header *)
int mess822_ok(stralloc *)
int mess822_begin(mess822_header *, mess822_action *)
void caltime_tai(struct caltime *ct, struct tai *t)