Index: mailbox/Makefile.am =================================================================== RCS file: /cvs/mailutils/mailbox/Makefile.am,v retrieving revision 1.16 diff -u -r1.16 Makefile.am --- mailbox/Makefile.am 2001/03/09 23:53:34 1.16 +++ mailbox/Makefile.am 2001/03/13 04:07:27 @@ -41,6 +41,7 @@ misc.c \ monitor.c \ observer.c \ +parse822.c \ property.c \ registrar.c \ sendmail.c \ Index: mailbox/address.c =================================================================== RCS file: /cvs/mailutils/mailbox/address.c,v retrieving revision 1.6 diff -u -r1.6 address.c --- mailbox/address.c 2001/02/28 04:18:18 1.6 +++ mailbox/address.c 2001/03/13 04:07:28 @@ -125,6 +125,7 @@ /* Note: This again as for header.c an awfull way of doing things. Meaning I need a correct rfc822 Parser. This one does not understand group. There is not doubt a better way to do this. */ + static int address_parse (address_t *paddress, const char **paddr) { @@ -337,6 +338,12 @@ free (address->personal); if (address->email) free (address->email); + if (address->local_part) + free (address->local_part); + if (address->domain) + free (address->domain); + if (address->route) + free (address->route); current = address->next; free (address); } @@ -420,6 +427,70 @@ } return status; } + +int +address_get_local_part (address_t addr, size_t no, char *buf, size_t len, size_t *n) +{ + size_t i, j; + int status = EINVAL; + if (addr == NULL) + return EINVAL; + for (j = 1; addr; addr = addr->next, j++) + { + if (j == no) + { + i = _cpystr (buf, addr->local_part, len); + if (n) + *n = i; + status = 0; + break; + } + } + return status; +} + +int +address_get_domain (address_t addr, size_t no, char *buf, size_t len, size_t *n) +{ + size_t i, j; + int status = EINVAL; + if (addr == NULL) + return EINVAL; + for (j = 1; addr; addr = addr->next, j++) + { + if (j == no) + { + i = _cpystr (buf, addr->domain, len); + if (n) + *n = i; + status = 0; + break; + } + } + return status; +} + +int +address_get_route (address_t addr, size_t no, char *buf, size_t len, size_t *n) +{ + size_t i, j; + int status = EINVAL; + if (addr == NULL) + return EINVAL; + for (j = 1; addr; addr = addr->next, j++) + { + if (j == no) + { + i = _cpystr (buf, addr->route, len); + if (n) + *n = i; + status = 0; + break; + } + } + return status; +} + int address_to_string (address_t addr, char *buf, size_t len, size_t *n) Index: mailbox/mbx_imap.c =================================================================== RCS file: /cvs/mailutils/mailbox/mbx_imap.c,v retrieving revision 1.20 diff -u -r1.20 mbx_imap.c --- mailbox/mbx_imap.c 2001/02/28 04:18:18 1.20 +++ mailbox/mbx_imap.c 2001/03/13 04:07:31 @@ -21,6 +21,9 @@ #include #include +#ifdef HAVE_STRINGS_H +#include +#endif #include #include #include Index: mailbox/include/address0.h =================================================================== RCS file: /cvs/mailutils/mailbox/include/address0.h,v retrieving revision 1.3 diff -u -r1.3 address0.h --- mailbox/include/address0.h 2001/03/05 04:47:52 1.3 +++ mailbox/include/address0.h 2001/03/13 04:07:31 @@ -36,13 +36,34 @@ extern "C" { #endif +/* + * The data-structure representing an RFC822 MAILBOX. It may be + * one MAILBOX in a list of them, as found in an ADDRESS list or + * a MAILBOX list (as found in a GROUP). + * + * Capitalized names are from RFC 822, section 6.1 (Address Syntax). + */ struct _address { + char *addr; + /* the original string that this list of addresses was created + * from, only present at the head of the list */ + char *comments; + /* the collection of comments stripped during parsing this MAILBOX */ char *personal; + /* the PHRASE portion of a MAILBOX, called the DISPLAY-NAME in drums */ char *email; - char *addr; - size_t num; + /* the ADDR-SPEC, the address@hidden */ + char *local_part; + /* the LOCAL-PART of a MAILBOX */ + char *domain; + /* the DOMAIN of a MAILBOX */ + char *route; + /* the optional ROUTE in the ROUTE-ADDR form of MAILBOX */ + +// size_t num; -- didn't appear to be used anywhere... + struct _address *next; }; Index: include/mailutils/address.h =================================================================== RCS file: /cvs/mailutils/include/mailutils/address.h,v retrieving revision 1.3 diff -u -r1.3 address.h --- include/mailutils/address.h 2001/03/05 04:47:52 1.3 +++ include/mailutils/address.h 2001/03/13 04:07:32 @@ -36,16 +36,24 @@ typedef struct _address *address_t; extern int address_create __P ((address_t *, const char *)); +extern int address_create0 __P ((address_t *, const char *)); extern void address_destroy __P ((address_t *)); -extern int address_get_email __P ((address_t, size_t, char *, - size_t, size_t *)); -extern int address_get_personal __P ((address_t, size_t, char *, - size_t, size_t *)); -extern int address_get_comments __P ((address_t, size_t, char *, - size_t, size_t *)); -extern int address_to_string __P ((address_t, char *, size_t, size_t *)); -extern int address_get_count __P ((address_t, size_t *)); +extern int address_get_email + __P ((address_t, size_t, char *, size_t, size_t *)); +extern int address_get_local_part + __P ((address_t, size_t, char *, size_t, size_t *)); +extern int address_get_domain + __P ((address_t, size_t, char *, size_t, size_t *)); +extern int address_get_personal + __P ((address_t, size_t, char *, size_t, size_t *)); +extern int address_get_comments + __P ((address_t, size_t, char *, size_t, size_t *)); +extern int address_get_route + __P ((address_t, size_t, char *, size_t, size_t *)); + +extern int address_to_string __P ((address_t, char *, size_t, size_t *)); +extern int address_get_count __P ((address_t, size_t *)); #ifdef __cplusplus }