diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-12-21 17:40:17 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-12-21 17:40:17 +0200 |
commit | 690b1bf8506e50cb85d2634ba2db2fddbff99dfe (patch) | |
tree | 8a8892d675060991fc4103d83462a188c5fc511c /mu | |
parent | 924bc7276b9626615d7030fa565d0876bbfd9409 (diff) | |
download | mailutils-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 'mu')
-rw-r--r-- | mu/imap.c | 7 |
1 files changed, 1 insertions, 6 deletions
@@ -196,12 +196,7 @@ format_email (mu_stream_t str, const char *name, mu_address_t addr) if (!addr) mu_stream_printf (str, "NIL"); else - { - size_t sz = mu_address_format_string (addr, NULL, 0); - char *buf = xmalloc (sz + 1); - mu_address_format_string (addr, buf, sz); - mu_stream_write (str, buf, strlen (buf), NULL); - } + mu_stream_format_address (str, addr); mu_stream_printf (str, "\n"); } |