2 ** $Id: rfc822.h,v 1.24 2006/04/11 02:24:59 mrsam Exp $
8 ** Copyright 1998 - 2006 Double Precision, Inc.
9 ** See COPYING for distribution information.
13 #include "../rfc822/config.h" /* VPATH build */
23 ** The text string we want to parse is first tokenized into an array of
24 ** struct rfc822token records. 'ptr' points into the original text
25 ** string, and 'len' has how many characters from 'ptr' belongs to this
30 struct rfc822token
*next
; /* Unused by librfc822, for use by
38 '<', '>', '@', ',', ';', ':', '.', '[', ']', '%', '!', '=', '?', '/' - RFC atoms.
42 #define rfc822_is_atom(p) ( (p) == 0 || (p) == '"' || (p) == '(' )
44 const char *ptr
; /* Pointer to value for the token. */
45 int len
; /* Length of token value */
49 ** After the struct rfc822token array is built, it is used to create
50 ** the rfc822addr array, which is the array of addresses (plus
51 ** syntactical fluff) extracted from those text strings. Each rfc822addr
52 ** record has several possible interpretation:
54 ** tokens is NULL - syntactical fluff, look in name/nname for tokens
55 ** representing the syntactical fluff ( which is semicolons
58 ** tokens is not NULL - actual address. The tokens representing the actual
59 ** address is in tokens/ntokens. If there are comments in
60 ** the address that are possible "real name" for the address
61 ** they are saved in name/nname (name may be null if there
63 ** If nname is 1, and name points to a comment token,
64 ** the address was specified in old-style format. Otherwise
65 ** the address was specified in new-style route-addr format.
67 ** The tokens and name pointers are set to point to the original rfc822token
72 struct rfc822token
*tokens
;
73 struct rfc822token
*name
;
76 /***************************************************************************
80 ***************************************************************************/
83 struct rfc822token
*tokens
;
87 struct rfc822t
*rfc822t_alloc(const char *p
,
88 void (*err_func
)(const char *, int)); /* Parse addresses */
90 struct rfc822t
*rfc822t_alloc_new(const char *p
,
91 void (*err_func
)(const char *, int, void *), void *);
94 void rfc822t_free(struct rfc822t
*); /* Free rfc822 structure */
96 void rfc822tok_print(const struct rfc822token
*, void (*)(char, void *), void *);
97 /* Print the tokens */
99 /***************************************************************************
103 ***************************************************************************/
106 struct rfc822addr
*addrs
;
110 struct rfc822a
*rfc822a_alloc(struct rfc822t
*);
111 void rfc822a_free(struct rfc822a
*); /* Free rfc822 structure */
113 void rfc822_deladdr(struct rfc822a
*, int);
115 /* rfc822_print "unparses" the rfc822 structure. Each rfc822addr is "printed"
116 (via the attached function). NOTE: instead of separating addresses by
117 commas, the print_separator function is called.
120 void rfc822_print(const struct rfc822a
*a
,
121 void (*print_func
)(char, void *),
122 void (*print_separator
)(const char *, void *), void *);
124 /* rfc822_print_common is an internal function */
126 void rfc822_print_common(const struct rfc822a
*a
,
127 char *(*decode_func
)(const char *, const char *),
129 void (*print_func
)(char, void *),
130 void (*print_separator
)(const char *, void *), void *);
132 /* Another unparser, except that only the raw addresses are extracted,
133 and each address is followed by a newline character */
135 void rfc822_addrlist(const struct rfc822a
*, void (*print_func
)(char, void *),
138 /* Now, just the comments. If comments not given, the address. */
139 void rfc822_namelist(const struct rfc822a
*, void (*print_func
)(char, void *),
142 /* Unparse an individual name/addr from a list of addresses. If the given
143 index points to some syntactical fluff, this is a noop */
145 void rfc822_prname(const struct rfc822a
*, int, void (*)(char, void *), void *);
146 void rfc822_praddr(const struct rfc822a
*, int, void (*)(char, void *), void *);
148 /* Like rfc822_prname, except that we'll also print the legacy format
149 ** of a list designation.
152 void rfc822_prname_orlist(const struct rfc822a
*, int,
153 void (*)(char, void *), void *);
155 /* Extra functions */
157 char *rfc822_gettok(const struct rfc822token
*);
158 char *rfc822_getaddr(const struct rfc822a
*, int);
159 char *rfc822_getname(const struct rfc822a
*, int);
160 char *rfc822_getname_orlist(const struct rfc822a
*, int);
161 char *rfc822_getaddrs(const struct rfc822a
*);
162 char *rfc822_getaddrs_wrap(const struct rfc822a
*, int);
164 void rfc822_mkdate_buf(time_t, char *);
165 const char *rfc822_mkdate(time_t);
166 time_t rfc822_parsedt(const char *);
168 #define CORESUBJ_RE 1
169 #define CORESUBJ_FWD 2
171 char *rfc822_coresubj(const char *, int *);
172 char *rfc822_coresubj_nouc(const char *, int *);
173 char *rfc822_coresubj_keepblobs(const char *s
);