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 \ ...@@ -41,6 +41,7 @@ mime.c \
41 misc.c \ 41 misc.c \
42 monitor.c \ 42 monitor.c \
43 observer.c \ 43 observer.c \
44 parse822.c \
44 property.c \ 45 property.c \
45 registrar.c \ 46 registrar.c \
46 sendmail.c \ 47 sendmail.c \
...@@ -57,6 +58,4 @@ url_pop.c \ ...@@ -57,6 +58,4 @@ url_pop.c \
57 url_sendmail.c \ 58 url_sendmail.c \
58 url_smtp.c 59 url_smtp.c
59 60
60
61 libmailbox_la_LDFLAGS = -version-info 0:0:0 61 libmailbox_la_LDFLAGS = -version-info 0:0:0
62
......
...@@ -125,6 +125,7 @@ gettoken (const char **ptr) ...@@ -125,6 +125,7 @@ gettoken (const char **ptr)
125 /* Note: This again as for header.c an awfull way of doing things. 125 /* Note: This again as for header.c an awfull way of doing things.
126 Meaning I need a correct rfc822 Parser. This one does not 126 Meaning I need a correct rfc822 Parser. This one does not
127 understand group. There is not doubt a better way to do this. */ 127 understand group. There is not doubt a better way to do this. */
128
128 static int 129 static int
129 address_parse (address_t *paddress, const char **paddr) 130 address_parse (address_t *paddress, const char **paddr)
130 { 131 {
...@@ -337,6 +338,12 @@ address_destroy (address_t *paddress) ...@@ -337,6 +338,12 @@ address_destroy (address_t *paddress)
337 free (address->personal); 338 free (address->personal);
338 if (address->email) 339 if (address->email)
339 free (address->email); 340 free (address->email);
341 if (address->local_part)
342 free (address->local_part);
343 if (address->domain)
344 free (address->domain);
345 if (address->route)
346 free (address->route);
340 current = address->next; 347 current = address->next;
341 free (address); 348 free (address);
342 } 349 }
...@@ -422,6 +429,70 @@ address_get_email (address_t addr, size_t no, char *buf, size_t len, size_t *n) ...@@ -422,6 +429,70 @@ address_get_email (address_t addr, size_t no, char *buf, size_t len, size_t *n)
422 } 429 }
423 430
424 int 431 int
432 address_get_local_part (address_t addr, size_t no, char *buf, size_t len, size_t *n)
433 {
434 size_t i, j;
435 int status = EINVAL;
436 if (addr == NULL)
437 return EINVAL;
438 for (j = 1; addr; addr = addr->next, j++)
439 {
440 if (j == no)
441 {
442 i = _cpystr (buf, addr->local_part, len);
443 if (n)
444 *n = i;
445 status = 0;
446 break;
447 }
448 }
449 return status;
450 }
451
452 int
453 address_get_domain (address_t addr, size_t no, char *buf, size_t len, size_t *n)
454 {
455 size_t i, j;
456 int status = EINVAL;
457 if (addr == NULL)
458 return EINVAL;
459 for (j = 1; addr; addr = addr->next, j++)
460 {
461 if (j == no)
462 {
463 i = _cpystr (buf, addr->domain, len);
464 if (n)
465 *n = i;
466 status = 0;
467 break;
468 }
469 }
470 return status;
471 }
472
473 int
474 address_get_route (address_t addr, size_t no, char *buf, size_t len, size_t *n)
475 {
476 size_t i, j;
477 int status = EINVAL;
478 if (addr == NULL)
479 return EINVAL;
480 for (j = 1; addr; addr = addr->next, j++)
481 {
482 if (j == no)
483 {
484 i = _cpystr (buf, addr->route, len);
485 if (n)
486 *n = i;
487 status = 0;
488 break;
489 }
490 }
491 return status;
492 }
493
494
495 int
425 address_to_string (address_t addr, char *buf, size_t len, size_t *n) 496 address_to_string (address_t addr, char *buf, size_t len, size_t *n)
426 { 497 {
427 size_t i; 498 size_t i;
......
...@@ -36,13 +36,34 @@ ...@@ -36,13 +36,34 @@
36 extern "C" { 36 extern "C" {
37 #endif 37 #endif
38 38
39 /*
40 * The data-structure representing an RFC822 MAILBOX. It may be
41 * one MAILBOX in a list of them, as found in an ADDRESS list or
42 * a MAILBOX list (as found in a GROUP).
43 *
44 * Capitalized names are from RFC 822, section 6.1 (Address Syntax).
45 */
39 struct _address 46 struct _address
40 { 47 {
48 char *addr;
49 /* the original string that this list of addresses was created
50 * from, only present at the head of the list */
51
41 char *comments; 52 char *comments;
53 /* the collection of comments stripped during parsing this MAILBOX */
42 char *personal; 54 char *personal;
55 /* the PHRASE portion of a MAILBOX, called the DISPLAY-NAME in drums */
43 char *email; 56 char *email;
44 char *addr; 57 /* the ADDR-SPEC, the LOCAL-PART@DOMAIN */
45 size_t num; 58 char *local_part;
59 /* the LOCAL-PART of a MAILBOX */
60 char *domain;
61 /* the DOMAIN of a MAILBOX */
62 char *route;
63 /* the optional ROUTE in the ROUTE-ADDR form of MAILBOX */
64
65 // size_t num; -- didn't appear to be used anywhere...
66
46 struct _address *next; 67 struct _address *next;
47 }; 68 };
48 69
......
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
21 21
22 #include <errno.h> 22 #include <errno.h>
23 #include <string.h> 23 #include <string.h>
24 #ifdef HAVE_STRINGS_H
25 #include <strings.h>
26 #endif
24 #include <stdlib.h> 27 #include <stdlib.h>
25 #include <assert.h> 28 #include <assert.h>
26 #include <time.h> 29 #include <time.h>
......