]> diplodocus.org Git - nmh/blob - h/addrsbr.h
More work on address portion of RFC 2047 encoder.
[nmh] / h / addrsbr.h
1
2 /*
3 * addrsbr.h -- definitions for the address parsing system
4 */
5
6 #define AD_HOST 1 /* getm(): lookup official hostname */
7 #define AD_NHST 0 /* getm(): do not lookup official name */
8 #define AD_NAME AD_NHST /* AD_HOST is TOO slow */
9
10 #define UUCPHOST (-1)
11 #define LOCALHOST 0
12 #define NETHOST 1
13 #define BADHOST 2
14
15 /*
16 * The email structure used by nmh to define an email address
17 */
18
19 struct mailname {
20 struct mailname *m_next; /* Linked list linkage; available for */
21 /* application use */
22 char *m_text; /* Full unparsed text of email address */
23 char *m_pers; /* display-name in RFC 5322 parlance */
24 char *m_mbox; /* local-part in RFC 5322 parlance */
25 char *m_host; /* domain in RFC 5322 parlance */
26 char *m_path; /* Host routing; should not be used */
27 int m_type; /* UUCPHOST, LOCALHOST, NETHOST, or BADHOST */
28 char m_nohost; /* True if no host part available */
29 char m_bcc; /* Used by post to keep track of bcc's */
30 int m_ingrp; /* True if email address is in a group */
31 char *m_gname; /* display-name of group */
32 char *m_note; /* Note (post-address comment) */
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 * Parse an address header, and return a sequence of email addresses.
45 * This function is the main entry point into the nmh address parser.
46 * It is used in conjunction with getm() to parse an email header.
47 *
48 * Arguments include:
49 *
50 * header - Pointer to the start of an email header.
51 *
52 * On the first call, header is copied and saved internally. Each email
53 * address in the header is returned on the first and subsequent calls
54 * to getname(). When there are no more email addresses available in
55 * the header, NULL is returned and the parser's internal state is
56 * reset.
57 */
58
59 char *getname(const char *header);
60 char *getlocaladdr(void);
61 char *auxformat(struct mailname *, int);
62
63 /*
64 * Parse an email address into it's components.
65 *
66 * Used in conjunction with getname() to parse a complete email header.
67 *
68 * Arguments include:
69 *
70 * str - Email address being parsed.
71 * dfhost - A default host to append to the email address if
72 * one is not included. If NULL, use nmh's idea of
73 * localhost().
74 * dftype - If dfhost is given, use dftype as the email address type
75 * if no host is in the email address.
76 * wanthost - One of AD_HOST or AD_NHST. If AD_HOST, look up the
77 * "official name" of the host. Well, that's what the
78 * documentation says, at least ... support for that
79 * functionality was removed when hostable support was
80 * removed and the address parser was converted by default
81 * to always being in DUMB mode. So nowadays this only
82 * affects where error messages are put if there is no
83 * host part (set it to AD_HOST if you want error messages
84 * to appear on standard error).
85 * eresult - Any error string returned by the address parser. String
86 * must contain sufficient room for the error message.
87 * (BUFSIZ is used in general by the code). Can be NULL.
88 *
89 * A pointer to an allocated struct mailname corresponding to the email
90 * address is returned.
91 */
92 struct mailname *getm(char *str, char *dfhost, int dftype,
93 int wanthost, char *eresult);