summaryrefslogtreecommitdiff
path: root/mh/mh_whatnow.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-12-21 17:40:17 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2011-12-21 17:40:17 +0200
commit690b1bf8506e50cb85d2634ba2db2fddbff99dfe (patch)
tree8a8892d675060991fc4103d83462a188c5fc511c /mh/mh_whatnow.c
parent924bc7276b9626615d7030fa565d0876bbfd9409 (diff)
downloadmailutils-690b1bf8506e50cb85d2634ba2db2fddbff99dfe.tar.gz
mailutils-690b1bf8506e50cb85d2634ba2db2fddbff99dfe.tar.bz2
Fix API for obtaining full email address.
Old API relied on passing a pointer to the buffer string and its size, which is defective. The new API, in addtion to that, provides functions for obtaining a pointer to the statically allocated original value, a pointer to dynamically allocated copy, and a function for formatting the address directly to a MU stream. Two functions are marked as deprecated: mu_address_to_string and mu_address_format_string. Both assume a pointer to an allocated string of a fixed size, which is far from being convenient nor reliable enough. * include/mailutils/address.h (MU_ADDR_HINT_ADDR): Rename to MU_ADDR_HINT_PRINTABLE (mu_address)<addr>: Rename to printable. (mu_address_sget_printable,mu_address_aget_printable) (mu_address_get_printable): New protos. (mu_stream_format_address): New proto. (mu_address_to_string) (mu_address_format_string): Mark as deprecated. (mu_validate_email): New proto. * examples/mta.c: Use mu_address_sget_printable instead of (mu_address_to_string) * libmailutils/address/addrstream.c: New file. * libmailutils/address/Makefile.am (libaddress_la_SOURCES): Add addrstream.c * libmailutils/address/address.c (mu_address_format_string): Rewrite using streams. (mu_address_to_string): Rewrite as a wrapper over mu_address_get_printable. (mu_address_sget_printable,mu_address_aget_printable) (mu_address_get_printable): New functions. * libmailutils/mime/mimehdr.c (_mime_header_parse): Initialize rc. * mail/util.c (util_merge_addresses): Use mu_address_aget_printable. * mh/mh.h (mh_annotate): Both string args are const. * mh/mh_init.c (mh_annotate): Likewise. * mh/mh_format.c (builtin_formataddr): Use mu_address_sget_printable. * mh/mh_whatnow.c (anno_data)<field,value>: Both are consts. (annotate): Use mu_address_sget_printable. * mh/send.c (set_address_header): Use mu_address_sget_printable. * mu/imap.c (format_email): Use mu_stream_format_address. * python/libmu_py/address.c (api_address_to_string): Likewise.
Diffstat (limited to 'mh/mh_whatnow.c')
-rw-r--r--mh/mh_whatnow.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c
index 4b4b21045..08b66fc26 100644
--- a/mh/mh_whatnow.c
+++ b/mh/mh_whatnow.c
@@ -264,8 +264,8 @@ invoke (const char *compname, const char *defval, int argc, char **argv,
struct anno_data
{
- char *field;
- char *value;
+ const char *field;
+ const char *value;
int date;
};
@@ -299,16 +299,12 @@ annotate (struct mh_whatnow_env *wh)
if (mu_address_get_nth (addr, i, &subaddr) == 0)
{
- size_t size;
struct anno_data d;
- mu_address_to_string (subaddr, NULL, 0, &size);
- d.value = xmalloc (size + 1);
d.field = wh->anno_field;
d.date = i == 1;
- mu_address_to_string (subaddr, d.value, size + 1, NULL);
- mu_list_foreach (wh->anno_list, anno, &d);
- free (d.value);
+ if (mu_address_sget_printable (subaddr, &d.value) == 0)
+ mu_list_foreach (wh->anno_list, anno, &d);
mu_address_destroy (&subaddr);
}
}

Return to:

Send suggestions and report system problems to the System administrator.