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