1 /*$Id: author.c,v 1.3 1999/09/29 03:11:44 lindberg Exp $*/
4 unsigned int author_name(char **sout,char *s,unsigned int l)
5 /* s is a string that contains a from: line argument\n. We parse */
6 /* s as follows: If there is an unquoted '<' we eliminate everything after */
7 /* it else if there is a unquoted ';' we eliminate everything after it. */
8 /* Then, we eliminate LWSP and '"' from the beginning and end. Note that */
9 /* this is not strict rfc822, but all we need is a display handle that */
10 /* doesn't show the address. If in the remaining text there is a '@' we put*/
11 /* in a '.' instead. Also, there are some non-rfc822 from lines out there */
12 /* and we still want to maximize the chance of getting a handle, even if it*/
13 /* costs a little extra work.*/
28 if (!s || !l) { /* Yuck - pass the buck */
44 if (ch == '"') { /* "name" <address@host> */
53 } else if (dquote) continue;
55 if (!level) cpcom = cp;
57 } else if (ch == ')') {
60 cpcomlast = cp - 2; /* address@host (name) */
62 if (ch == '<') { /* name <address@host> */
65 } else if (ch == ';') break; /* address@host ;garbage */
68 if (cplt) { /* non-comment '<' */
71 } else if (cpquot && cpquotlast >= cpquot) {
74 } else if (cpcom && cpcomlast >= cpcom) {
82 for (;;) { /* e.g. LWSP <user@host> */
83 while (cpfirst <= cp &&
84 (*cpfirst == ' ' || *cpfirst == '\t' || *cpfirst == '<')) cpfirst++;
85 while (cp >= cpfirst &&
86 (*cp == ' ' || *cp == '\t' || *cp == '\n' || *cp == '>')) cp--;
87 if (cp >= cpfirst || flagdone)
95 len = cp - cpfirst + 1;
96 while (cpfirst <= cp) {