2 ** Copyright 2001 Double Precision, Inc.
3 ** See COPYING for distribution information.
10 #include "rfc822hdr.h"
12 static const char rcsid
[]="$Id: rfc822hdr.c,v 1.2 2009/11/08 18:14:47 mrsam Exp $";
15 ** Read the next mail header.
18 int rfc822hdr_read(struct rfc822hdr
*h
, FILE *f
, off_t
*pos
, off_t epos
)
27 size_t hn
=h
->hdrsize
+ 1024;
28 char *p
= h
->header
? realloc(h
->header
, hn
):
38 if (pos
&& *pos
>= epos
)
69 if (c
== '\n' || c
== '\r' ||
70 !isspace((int)(unsigned char)c
))
77 if (h
->maxsize
&& n
+ 2 > h
->maxsize
)
89 for (h
->value
=h
->header
; *h
->value
; ++h
->value
)
95 isspace((int)(unsigned char)*h
->value
))
103 void rfc822hdr_fixname(struct rfc822hdr
*h
)
107 for (p
=h
->header
; *p
; p
++)
109 *p
=tolower((int)(unsigned char)*p
);
113 void rfc822hdr_collapse(struct rfc822hdr
*h
)
117 for (p
=q
=h
->value
; *p
; )
121 while (*p
&& isspace((int)(unsigned char)*p
))
131 int rfc822hdr_is_addr(const char *hdr
)
133 return strcasecmp(hdr
, "from") == 0 ||
134 strcasecmp(hdr
, "to") == 0 ||
135 strcasecmp(hdr
, "cc") == 0 ||
136 strcasecmp(hdr
, "bcc") == 0 ||
137 strcasecmp(hdr
, "resent-from") == 0 ||
138 strcasecmp(hdr
, "resent-to") == 0 ||
139 strcasecmp(hdr
, "resent-cc") == 0 ||
140 strcasecmp(hdr
, "resent-bcc") == 0;