ezmlmx
0.68
ezmlmx
Loading...
Searching...
No Matches
ezmlmx-0.68
src
author.c
Go to the documentation of this file.
1
#define WHO "author"
2
18
19
unsigned
int
author_name
(
char
**sout,
char
*s,
unsigned
int
l)
20
{
21
int
squote = 0;
22
int
dquote = 0;
23
int
level = 0;
24
int
flagdone;
25
unsigned
int
len
;
26
char
ch;
27
char
*cpfirst,*
cp
;
28
char
*cpcomlast = 0;
29
char
*cpquotlast = 0;
30
char
*cpquot = 0;
31
char
*cpcom = 0;
32
char
*cplt = 0;
33
34
if
(!s || !l) {
/* Yuck - pass the buck */
35
*sout = s;
36
return
0;
37
}
38
cp
= s;
len
= l;
39
40
while
(
len
--) {
41
ch = *(
cp
++);
42
if
(squote) {
43
squote = 0;
44
continue
;
45
}
46
if
(ch ==
'\\'
) {
47
squote = 1;
48
continue
;
49
}
50
if
(ch ==
'"'
) {
/* "name" <address@host> */
51
if
(dquote) {
52
cpquotlast =
cp
- 2;
53
break
;
54
}
else
{
55
cpquot =
cp
;
56
dquote = 1;
57
}
58
continue
;
59
}
else
if
(dquote)
continue
;
60
if
(ch ==
'('
) {
61
if
(!level) cpcom =
cp
;
62
level++;
63
}
else
if
(ch ==
')'
) {
64
level--;
65
if
(!level)
66
cpcomlast =
cp
- 2;
/* address@host (name) */
67
}
else
if
(!level) {
68
if
(ch ==
'<'
) {
/* name <address@host> */
69
cplt =
cp
- 2;
70
break
;
71
}
else
if
(ch ==
';'
)
break
;
/* address@host ;garbage */
72
}
73
}
74
if
(cplt) {
/* non-comment '<' */
75
cp
= cplt;
76
cpfirst = s;
77
}
else
if
(cpquot && cpquotlast >= cpquot) {
78
cpfirst = cpquot;
79
cp
= cpquotlast;
80
}
else
if
(cpcom && cpcomlast >= cpcom) {
81
cpfirst = cpcom;
82
cp
= cpcomlast;
83
}
else
{
84
cp
= s + l - 1;
85
cpfirst = s;
86
}
87
flagdone = 0;
88
for
(;;) {
/* e.g. LWSP <user@host> */
89
while
(cpfirst <=
cp
&& (*cpfirst ==
' '
|| *cpfirst ==
'\t'
|| *cpfirst ==
'<'
))
90
cpfirst++;
91
while
(
cp
>= cpfirst && (*
cp
==
' '
|| *
cp
==
'\t'
|| *
cp
==
'\n'
|| *
cp
==
'>'
))
92
cp
--;
93
if
(
cp
>= cpfirst || flagdone)
break
;
94
cp
= s + l - 1;
95
cpfirst = s;
96
flagdone = 1;
97
}
98
99
*sout = cpfirst;
100
len
=
cp
- cpfirst + 1;
101
102
while
(cpfirst <=
cp
) {
103
if
(*cpfirst ==
'@'
) *cpfirst =
'.'
;
104
cpfirst++;
105
}
106
return
len
;
107
}
author_name
unsigned int author_name(char **sout, char *s, unsigned int l)
Definition
author.c:19
cp
const char * cp
Definition
ezmlm-cron.c:76
len
unsigned int len
Definition
ezmlm-cron.c:68
Generated on
for ezmlmx by
1.14.0