s/qmail
4.3.20
Next generation secure email transport
Loading...
Searching...
No Matches
4.3
sqmail-4.3.20
src
headerbody.c
Go to the documentation of this file.
1
#include "stralloc.h"
2
#include "buffer.h"
3
#include "getln.h"
4
#include "
hfield.h
"
5
#include "
headerbody.h
"
6
7
static
int
getsa(buffer *
b
,stralloc *
sa
,
int
*
match
)
8
{
9
if
(!*
match
)
return
0;
10
if
(getln(
b
,
sa
,
match
,
'\n'
) == -1)
return
-1;
11
if
(*
match
)
return
1;
12
if
(!
sa
->len)
return
0;
13
if
(!stralloc_append(
sa
,
"\n"
))
return
-1;
14
15
return
1;
16
}
17
18
static
stralloc line = {0};
19
static
stralloc nextline = {0};
20
21
int
headerbody
(buffer *
b
,
void
(*dohf)(),
void
(*hdone)(),
void
(*dobl)())
22
{
23
int
match
;
24
int
flaglineok;
25
match
= 1;
26
flaglineok = 0;
27
28
for
(;;) {
29
switch
(getsa(
b
,&nextline,&
match
)) {
30
case
-1:
31
return
-1;
32
case
0:
33
if
(flaglineok) dohf(&line);
34
hdone();
35
/* no message body; could insert blank line here */
36
return
0;
37
}
38
39
if
(flaglineok) {
40
if
((nextline.s[0] ==
' '
) || (nextline.s[0] ==
'\t'
)) {
41
if
(!stralloc_cat(&line,&nextline))
return
-1;
42
continue
;
43
}
44
dohf(&line);
45
}
46
47
if
(nextline.len == 1) {
48
hdone();
49
dobl(&nextline);
50
break
;
51
}
52
53
if
(stralloc_starts(&nextline,
"From "
)) {
54
if
(!
stralloc_copys
(&line,
"MBOX-Line: "
))
return
-1;
55
if
(!stralloc_cat(&line,&nextline))
return
-1;
56
}
else
if
(
hfield_valid
(nextline.s,nextline.len)) {
57
if
(!stralloc_copy(&line,&nextline))
return
-1;
58
}
else
{
59
hdone();
60
if
(!
stralloc_copys
(&line,
"\n"
))
return
-1;
61
dobl(&line);
62
dobl(&nextline);
63
break
;
64
}
65
flaglineok = 1;
66
}
67
68
for
(;;)
69
switch
(getsa(
b
,&nextline,&
match
)) {
70
case
-1:
return
-1;
71
case
0:
return
0;
72
case
1: dobl(&nextline);
73
}
74
}
b
buffer b
Definition:
auto-gid.c:10
stralloc_copys
int stralloc_copys(stralloc *, char const *)
sa
stralloc sa
Definition:
dnscname.c:11
headerbody
int headerbody(buffer *b, void(*dohf)(), void(*hdone)(), void(*dobl)())
Definition:
headerbody.c:21
headerbody.h
hfield_valid
int hfield_valid(char *s, int len)
Definition:
hfield.c:69
hfield.h
match
int match
Definition:
matchup.c:196
Generated on Thu Jan 16 2025 17:42:04 for s/qmail by
1.9.6