]> diplodocus.org Git - nmh/blob - h/addrsbr.h
mhlsbr.c: Don't strchr(3) non-string NUL-less buffer.
[nmh] / h / addrsbr.h
1 /* addrsbr.h -- definitions for the address parsing system
2 */
3
4 #define UUCPHOST (-1)
5 #define LOCALHOST 0
6 #define NETHOST 1
7 #define BADHOST 2
8
9 /*
10 * The email structure used by nmh to define an email address
11 */
12
13 struct mailname {
14 struct mailname *m_next; /* Linked list linkage; available for */
15 /* application use */
16 char *m_text; /* Full unparsed text of email address */
17 char *m_pers; /* display-name in RFC 5322 parlance */
18 char *m_mbox; /* local-part in RFC 5322 parlance */
19 char *m_host; /* domain in RFC 5322 parlance */
20 char *m_path; /* Host routing; should not be used */
21 int m_type; /* UUCPHOST, LOCALHOST, NETHOST, or BADHOST */
22 char m_nohost; /* True if no host part available */
23 char m_bcc; /* Used by post to keep track of bcc's */
24 int m_ingrp; /* True if email address is in a group */
25 char *m_gname; /* display-name of group */
26 char *m_note; /* Note (post-address comment) */
27 };
28
29 /*
30 * See notes for auxformat() below.
31 */
32
33 #define adrformat(m) auxformat ((m), 1)
34
35 /*
36 * prototypes
37 */
38 void mnfree(struct mailname *);
39 bool ismymbox(struct mailname *);
40
41 /*
42 * Enable Email Address Internationalization, which requires
43 * support of 8-bit addresses.
44 */
45 void enable_eai(void);
46
47 /*
48 * Parse an address header, and return a sequence of email addresses.
49 * This function is the main entry point into the nmh address parser.
50 * It is used in conjunction with getm() to parse an email header.
51 *
52 * Arguments include:
53 *
54 * header - Pointer to the start of an email header.
55 *
56 * On the first call, header is copied and saved internally. Each email
57 * address in the header is returned on the first and subsequent calls
58 * to getname(). When there are no more email addresses available in
59 * the header, NULL is returned and the parser's internal state is
60 * reset.
61 */
62
63 char *getname(const char *header);
64
65 /*
66 * Format an email address given a struct mailname.
67 *
68 * This function takes a pointer to a struct mailname and returns a pointer
69 * to a static buffer holding the resulting email address.
70 *
71 * It is worth noting that group names are NOT handled, so if you want to
72 * do something with groups you need to handle it externally to this function.
73 *
74 * Arguments include:
75 *
76 * mp - Pointer to mailname structure
77 * extras - If true, include the personal name and/or note in the
78 * address. Otherwise, omit it.
79 */
80
81 char *auxformat(struct mailname *mp, int extras);
82
83 /*
84 * Parse an email address into it's components.
85 *
86 * Used in conjunction with getname() to parse a complete email header.
87 *
88 * Arguments include:
89 *
90 * str - Email address being parsed.
91 * dfhost - A default host to append to the email address if
92 * one is not included. If NULL, use nmh's idea of
93 * localhost().
94 * dftype - If dfhost is given, use dftype as the email address type
95 * if no host is in the email address.
96 * eresult - A buffer containing an error message returned by the
97 * address parser. May be NULL.
98 * eresultsize - The size of the buffer passed in eresult.
99 *
100 * A pointer to an allocated struct mailname corresponding to the email
101 * address is returned.
102 *
103 * This function used to have an argument called 'wanthost' which would
104 * control whether or not it would canonicalize hostnames in email
105 * addresses. This functionality was removed for nmh 1.5, and eventually
106 * all of the code that used this argument was garbage collected.
107 */
108 struct mailname *getm(char *str, char *dfhost, int dftype, char *eresult,
109 size_t eresultsize);