Commit 64394108 6439410895dfb5847bbbe742ee7ab249ffb594f9 by Alain Magloire

Makefile.am address.c mbx_imap.c include/address0.h

Changes need for the new address_t.
1 parent 754ec3a4
......@@ -41,6 +41,7 @@ mime.c \
misc.c \
monitor.c \
observer.c \
parse822.c \
property.c \
registrar.c \
sendmail.c \
......@@ -57,6 +58,4 @@ url_pop.c \
url_sendmail.c \
url_smtp.c
libmailbox_la_LDFLAGS = -version-info 0:0:0
......
......@@ -125,6 +125,7 @@ gettoken (const char **ptr)
/* 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 @@ address_destroy (address_t *paddress)
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);
}
......@@ -422,6 +429,70 @@ address_get_email (address_t addr, size_t no, char *buf, size_t len, size_t *n)
}
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)
{
size_t i;
......
......@@ -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 LOCAL-PART@DOMAIN */
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;
};
......
......@@ -21,6 +21,9 @@
#include <errno.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <stdlib.h>
#include <assert.h>
#include <time.h>
......