X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/d1622b3fcf620fb6dbd1a8eeb46fd368e0e3d460..721927adc3f031a799eb1251c80c087cf3d27493:/h/addrsbr.h diff --git a/h/addrsbr.h b/h/addrsbr.h index 2611e5a8..a753e623 100644 --- a/h/addrsbr.h +++ b/h/addrsbr.h @@ -12,19 +12,24 @@ #define NETHOST 1 #define BADHOST 2 +/* + * The email structure used by nmh to define an email address + */ + struct mailname { - struct mailname *m_next; - char *m_text; - char *m_pers; - char *m_mbox; - char *m_host; - char *m_path; - int m_type; - char m_nohost; - char m_bcc; - int m_ingrp; - char *m_gname; - char *m_note; + struct mailname *m_next; /* Linked list linkage; available for */ + /* application use */ + char *m_text; /* Full unparsed text of email address */ + char *m_pers; /* display-name in RFC 5322 parlance */ + char *m_mbox; /* local-part in RFC 5322 parlance */ + char *m_host; /* domain in RFC 5322 parlance */ + char *m_path; /* Host routing; should not be used */ + int m_type; /* UUCPHOST, LOCALHOST, NETHOST, or BADHOST */ + char m_nohost; /* True if no host part available */ + char m_bcc; /* Used by post to keep track of bcc's */ + int m_ingrp; /* True if email address is in a group */ + char *m_gname; /* display-name of group */ + char *m_note; /* Note (post-address comment) */ }; #define adrformat(m) auxformat ((m), 1) @@ -34,7 +39,55 @@ struct mailname { */ void mnfree(struct mailname *); int ismymbox(struct mailname *); -char *getname(char *); + +/* + * Parse an address header, and return a sequence of email addresses. + * This function is the main entry point into the nmh address parser. + * It is used in conjunction with getm() to parse an email header. + * + * Arguments include: + * + * header - Pointer to the start of an email header. + * + * On the first call, header is copied and saved internally. Each email + * address in the header is returned on the first and subsequent calls + * to getname(). When there are no more email addresses available in + * the header, NULL is returned and the parser's internal state is + * reset. + */ + +char *getname(const char *header); char *getlocaladdr(void); char *auxformat(struct mailname *, int); -struct mailname *getm(char *, char *, int, int, char *); + +/* + * Parse an email address into it's components. + * + * Used in conjunction with getname() to parse a complete email header. + * + * Arguments include: + * + * str - Email address being parsed. + * dfhost - A default host to append to the email address if + * one is not included. If NULL, use nmh's idea of + * localhost(). + * dftype - If dfhost is given, use dftype as the email address type + * if no host is in the email address. + * wanthost - One of AD_HOST or AD_NHST. If AD_HOST, look up the + * "official name" of the host. Well, that's what the + * documentation says, at least ... support for that + * functionality was removed when hostable support was + * removed and the address parser was converted by default + * to always being in DUMB mode. So nowadays this only + * affects where error messages are put if there is no + * host part (set it to AD_HOST if you want error messages + * to appear on standard error). + * eresult - Any error string returned by the address parser. String + * must contain sufficient room for the error message. + * (BUFSIZ is used in general by the code). Can be NULL. + * + * A pointer to an allocated struct mailname corresponding to the email + * address is returned. + */ +struct mailname *getm(char *str, char *dfhost, int dftype, + int wanthost, char *eresult);