]>
diplodocus.org Git - nmh/blob - h/addrsbr.h
3 * addrsbr.h -- definitions for the address parsing system
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 */
16 * The email structure used by nmh to define an email address
20 struct mailname
*m_next
; /* Linked list linkage; available for */
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) */
36 * See notes for auxformat() below.
39 #define adrformat(m) auxformat ((m), 1)
44 void mnfree(struct mailname
*);
45 int ismymbox(struct mailname
*);
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.
54 * header - Pointer to the start of an email header.
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
63 char *getname(const char *header
);
66 * Format an email address given a struct mailname.
68 * This function takes a pointer to a struct mailname and returns a pointer
69 * to a static buffer holding the resulting email address.
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.
76 * mp - Pointer to mailname structure
77 * extras - If true, include the personal name and/or note in the
78 * address. Otherwise, omit it.
81 char *auxformat(struct mailname
*mp
, int extras
);
84 * Parse an email address into it's components.
86 * Used in conjunction with getname() to parse a complete email header.
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
94 * dftype - If dfhost is given, use dftype as the email address type
95 * if no host is in the email address.
96 * wanthost - One of AD_HOST or AD_NHST. If AD_HOST, look up the
97 * "official name" of the host. Well, that's what the
98 * documentation says, at least ... support for that
99 * functionality was removed when hostable support was
100 * removed and the address parser was converted by default
101 * to always being in DUMB mode. So nowadays this only
102 * affects where error messages are put if there is no
103 * host part (set it to AD_HOST if you want error messages
104 * to appear on standard error).
105 * eresult - Any error string returned by the address parser. String
106 * must contain sufficient room for the error message.
107 * (BUFSIZ is used in general by the code). Can be NULL.
109 * A pointer to an allocated struct mailname corresponding to the email
110 * address is returned.
112 struct mailname
*getm(char *str
, char *dfhost
, int dftype
,
113 int wanthost
, char *eresult
);