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.
Showing
17 changed files
with
244 additions
and
168 deletions
libmailutils/address/addrstream.c
0 → 100644
-
Please register or sign in to post a comment