Commit cbe0784b cbe0784baa226553e71eed96e77ead9b839b0539 by Sergey Poznyakoff

(address_aget_local_part,address_aget_domain): New functions.

1 parent 3d5be386
...@@ -48,6 +48,10 @@ extern int address_get_route ...@@ -48,6 +48,10 @@ extern int address_get_route
48 48
49 extern int address_aget_email 49 extern int address_aget_email
50 __P ((address_t, size_t, char **)); 50 __P ((address_t, size_t, char **));
51 extern int address_aget_local_part
52 __P ((address_t addr, size_t no, char **buf));
53 extern int address_aget_domain
54 __P ((address_t addr, size_t no, char **buf));
51 55
52 extern int address_is_group 56 extern int address_is_group
53 __P ((address_t, size_t, int*)); 57 __P ((address_t, size_t, int*));
......
...@@ -393,6 +393,56 @@ address_aget_email (address_t addr, size_t no, char **buf) ...@@ -393,6 +393,56 @@ address_aget_email (address_t addr, size_t no, char **buf)
393 } 393 }
394 394
395 int 395 int
396 address_aget_local_part (address_t addr, size_t no, char **buf)
397 {
398 int status = 0;
399 address_t subaddr;
400
401 if (addr == NULL || buf == NULL)
402 return EINVAL;
403
404 subaddr = _address_get_nth (addr, no);
405 if (!subaddr)
406 return ENOENT;
407
408 if (subaddr->local_part)
409 {
410 *buf = strdup (subaddr->local_part);
411 if (!*buf)
412 status = ENOMEM;
413 }
414 else
415 *buf = NULL;
416
417 return status;
418 }
419
420 int
421 address_aget_domain (address_t addr, size_t no, char **buf)
422 {
423 int status = 0;
424 address_t subaddr;
425
426 if (addr == NULL || buf == NULL)
427 return EINVAL;
428
429 subaddr = _address_get_nth (addr, no);
430 if (!subaddr)
431 return ENOENT;
432
433 if (subaddr->domain)
434 {
435 *buf = strdup (subaddr->domain);
436 if (!*buf)
437 status = ENOMEM;
438 }
439 else
440 *buf = NULL;
441
442 return status;
443 }
444
445 int
396 address_get_local_part (address_t addr, size_t no, char *buf, size_t len, 446 address_get_local_part (address_t addr, size_t no, char *buf, size_t len,
397 size_t * n) 447 size_t * n)
398 { 448 {
......