diff --git a/Makefile.autosetup b/Makefile.autosetup index a8b1f568350..9120c636327 100644 --- a/Makefile.autosetup +++ b/Makefile.autosetup @@ -60,11 +60,11 @@ NEOMUTTOBJS= mutt_account.o addrbook.o alias.o attach.o bcache.o body.o \ curs_main.o edit.o editmsg.o enter.o envelope.o filter.o \ flags.o from.o group.o handler.o hdrline.o \ header.o help.o history.o hook.o init.o keymap.o main.o \ - mbox.o menu.o mh.o muttlib.o mutt_address.o \ + mbox.o menu.o mh.o muttlib.o \ mutt_socket.o tags.o mx.o \ newsrc.o nntp.o pager.o parse.o pattern.o pop.o \ pop_auth.o pop_lib.o postpone.o query.o recvattach.o recvcmd.o \ - rfc1524.o rfc2047.o rfc2231.o rfc3676.o address.o \ + rfc1524.o rfc2047.o rfc2231.o rfc3676.o \ safe_asprintf.o score.o send.o sendlib.o sidebar.o mutt_signal.o \ resize.o smtp.o sort.o state.o status.o system.o thread.o url.o \ version.o @@ -87,8 +87,8 @@ ALLOBJS+= $(NEOMUTTOBJS) ############################################################################### # libmutt LIBMUTT= libmutt.a -LIBMUTTOBJS= mutt/base64.o mutt/buffer.o mutt/charset.o mutt/date.o \ - mutt/debug.o mutt/exit.o \ +LIBMUTTOBJS= mutt/address.o mutt/base64.o mutt/buffer.o mutt/charset.o \ + mutt/date.o mutt/debug.o mutt/exit.o \ mutt/file.o mutt/hash.o mutt/idna.o mutt/list.o \ mutt/mapping.o mutt/mbyte.o mutt/md5.o \ mutt/memory.o mutt/message.o mutt/mime.o mutt/parameter.o \ @@ -267,14 +267,14 @@ git_ver.h: $(ALL_FILES) cmp -s git_ver.h.tmp git_ver.h || mv git_ver.h.tmp git_ver.h; \ rm -f git_ver.h.tmp -hcache/hcversion.h: $(SRCDIR)/mutt.h $(SRCDIR)/address.h \ +hcache/hcversion.h: $(SRCDIR)/mutt.h $(SRCDIR)/mutt/address.h \ $(SRCDIR)/mutt/list.h $(SRCDIR)/mutt/buffer.h \ $(SRCDIR)/mutt/parameter.h $(SRCDIR)/body.h \ $(SRCDIR)/envelope.h $(SRCDIR)/header.h \ $(SRCDIR)/hcache/hcachever.sh \ $(PWD)/hcache ( echo '#include "config.h"'; echo '#include "mutt.h"'; \ - echo '#include "address.h"'; echo '#include "mutt/list.h"'; \ + echo '#include "mutt/address.h"'; echo '#include "mutt/list.h"'; \ echo '#include "mutt/buffer.h"'; echo '#include "mutt/parameter.h"'; \ echo '#include "body.h"'; echo '#include "envelope.h"'; \ echo '#include "header.h"';) | $(CPP) $(CFLAGS) - | \ diff --git a/addrbook.c b/addrbook.c index b97799d4a91..ce70601f8a3 100644 --- a/addrbook.c +++ b/addrbook.c @@ -26,7 +26,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "format_flags.h" #include "globals.h" diff --git a/alias.c b/alias.c index 60b7e358738..28a7b39d872 100644 --- a/alias.c +++ b/alias.c @@ -32,7 +32,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "alias.h" -#include "address.h" #include "envelope.h" #include "globals.h" #include "mutt_curses.h" diff --git a/commands.c b/commands.c index 129501183e5..af92f7081a5 100644 --- a/commands.c +++ b/commands.c @@ -32,7 +32,6 @@ #include "mutt/mutt.h" #include "conn/conn.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "body.h" #include "buffy.h" diff --git a/compose.c b/compose.c index 84abb6319e1..ac839b442d6 100644 --- a/compose.c +++ b/compose.c @@ -32,7 +32,6 @@ #include "mutt/mutt.h" #include "conn/conn.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "attach.h" #include "body.h" diff --git a/copy.c b/copy.c index 6f7b1a756ba..4faa6d8b144 100644 --- a/copy.c +++ b/copy.c @@ -28,7 +28,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "copy.h" -#include "address.h" #include "body.h" #include "context.h" #include "envelope.h" diff --git a/edit.c b/edit.c index 18d3f0d81a0..6dfce77b057 100644 --- a/edit.c +++ b/edit.c @@ -31,7 +31,6 @@ #include #include #include "mutt/mutt.h" -#include "address.h" #include "alias.h" #include "body.h" #include "context.h" diff --git a/envelope.c b/envelope.c index c59f8dd835f..264d8319625 100644 --- a/envelope.c +++ b/envelope.c @@ -39,7 +39,6 @@ #include #include "mutt/mutt.h" #include "envelope.h" -#include "address.h" #include "protos.h" /** diff --git a/group.c b/group.c index c780cfa9024..f92150b63e6 100644 --- a/group.c +++ b/group.c @@ -25,7 +25,6 @@ #include #include "mutt/mutt.h" #include "group.h" -#include "address.h" #include "globals.h" #include "protos.h" diff --git a/hcache/hcache.c b/hcache/hcache.c index 4c0187de4dc..1d289332ea9 100644 --- a/hcache/hcache.c +++ b/hcache/hcache.c @@ -48,7 +48,6 @@ #include #include #include "mutt/mutt.h" -#include "address.h" #include "backend.h" #include "body.h" #include "envelope.h" diff --git a/hdrline.c b/hdrline.c index e63b0f85748..6afed012562 100644 --- a/hdrline.c +++ b/hdrline.c @@ -31,7 +31,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "body.h" #include "context.h" #include "envelope.h" diff --git a/hook.c b/hook.c index 0ed9895d828..612e8566960 100644 --- a/hook.c +++ b/hook.c @@ -29,7 +29,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "envelope.h" #include "globals.h" #include "header.h" diff --git a/init.c b/init.c index 7be8ebe9569..93050d84864 100644 --- a/init.c +++ b/init.c @@ -38,7 +38,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "init.h" -#include "address.h" #include "alias.h" #include "context.h" #include "envelope.h" diff --git a/main.c b/main.c index 66d91cf0d0c..822ce32245c 100644 --- a/main.c +++ b/main.c @@ -37,7 +37,6 @@ #include "mutt/mutt.h" #include "conn/conn.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "body.h" #include "buffy.h" diff --git a/mbox.c b/mbox.c index a9d78d8f40c..84c986297d3 100644 --- a/mbox.c +++ b/mbox.c @@ -34,7 +34,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "body.h" #include "buffy.h" #include "context.h" diff --git a/address.c b/mutt/address.c similarity index 95% rename from address.c rename to mutt/address.c index 32810519465..e28b028159f 100644 --- a/address.c +++ b/mutt/address.c @@ -57,13 +57,17 @@ * | mutt_addr_valid_msgid() | Is this a valid Message ID? * | mutt_addr_write() | Write an Address to a buffer * | mutt_addr_write_single() | Write a single Address to a buffer + * | mutt_addrlist_to_intl() | Convert an Address list to Punycode + * | mutt_addrlist_to_local() | Convert an Address list from Punycode */ #include "config.h" #include #include -#include "mutt/mutt.h" #include "address.h" +#include "idna2.h" +#include "memory.h" +#include "string2.h" /** * AddressSpecials - Characters with special meaning for email addresses @@ -1231,3 +1235,68 @@ size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool disp *pbuf = 0; return pbuf - buf; } + +/** + * mutt_addrlist_to_intl - Convert an Address list to Punycode + * @param[in] a Address list to modify + * @param[out] err Pointer for failed addresses + * @retval 0 Success, all addresses converted + * @retval -1 Error, err will be set to the failed address + */ +int mutt_addrlist_to_intl(struct Address *a, char **err) +{ + char *user = NULL, *domain = NULL; + char *intl_mailbox = NULL; + int rc = 0; + + if (err) + *err = NULL; + + for (; a; a = a->next) + { + if (!a->mailbox || mutt_addr_is_intl(a)) + continue; + + if (mutt_addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1) + continue; + + intl_mailbox = mutt_idna_local_to_intl(user, domain); + if (!intl_mailbox) + { + rc = -1; + if (err && !*err) + *err = mutt_str_strdup(a->mailbox); + continue; + } + + mutt_addr_set_intl(a, intl_mailbox); + } + + return rc; +} + +/** + * mutt_addrlist_to_local - Convert an Address list from Punycode + * @param a Address list to modify + * @retval 0 Always + */ +int mutt_addrlist_to_local(struct Address *a) +{ + char *user = NULL, *domain = NULL; + char *local_mailbox = NULL; + + for (; a; a = a->next) + { + if (!a->mailbox || mutt_addr_is_local(a)) + continue; + + if (mutt_addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1) + continue; + + local_mailbox = mutt_idna_intl_to_local(user, domain, 0); + if (local_mailbox) + mutt_addr_set_local(a, local_mailbox); + } + + return 0; +} diff --git a/address.h b/mutt/address.h similarity index 100% rename from address.h rename to mutt/address.h diff --git a/mutt/mutt.h b/mutt/mutt.h index 4c9abe47d07..d77dc40fed6 100644 --- a/mutt/mutt.h +++ b/mutt/mutt.h @@ -27,6 +27,7 @@ * * | File | Description | * | :--------------- | :----------------- | + * | mutt/address.c | @subpage address | * | mutt/base64.c | @subpage base64 | * | mutt/buffer.c | @subpage buffer | * | mutt/charset.c | @subpage charset | @@ -57,6 +58,7 @@ #ifndef _MUTT_MUTT_H #define _MUTT_MUTT_H +#include "address.h" #include "base64.h" #include "buffer.h" #include "charset.h" diff --git a/mutt_address.c b/mutt_address.c deleted file mode 100644 index 14e2237218c..00000000000 --- a/mutt_address.c +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file - * Representation of an email address - * - * @authors - * Copyright (C) 1996-2000,2011-2013 Michael R. Elkins - * Copyright (C) 2017 Richard Russon - * - * @copyright - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 2 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include "config.h" -#include -#include "mutt/mutt.h" -#include "address.h" - -/** - * mutt_addrlist_to_intl - Convert an Address list to Punycode - * @param[in] a Address list to modify - * @param[out] err Pointer for failed addresses - * @retval 0 Success, all addresses converted - * @retval -1 Error, err will be set to the failed address - */ -int mutt_addrlist_to_intl(struct Address *a, char **err) -{ - char *user = NULL, *domain = NULL; - char *intl_mailbox = NULL; - int rc = 0; - - if (err) - *err = NULL; - - for (; a; a = a->next) - { - if (!a->mailbox || mutt_addr_is_intl(a)) - continue; - - if (mutt_addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1) - continue; - - intl_mailbox = mutt_idna_local_to_intl(user, domain); - if (!intl_mailbox) - { - rc = -1; - if (err && !*err) - *err = mutt_str_strdup(a->mailbox); - continue; - } - - mutt_addr_set_intl(a, intl_mailbox); - } - - return rc; -} - -/** - * mutt_addrlist_to_local - Convert an Address list from Punycode - * @param a Address list to modify - * @retval 0 Always - */ -int mutt_addrlist_to_local(struct Address *a) -{ - char *user = NULL, *domain = NULL; - char *local_mailbox = NULL; - - for (; a; a = a->next) - { - if (!a->mailbox || mutt_addr_is_local(a)) - continue; - - if (mutt_addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1) - continue; - - local_mailbox = mutt_idna_intl_to_local(user, domain, 0); - if (local_mailbox) - mutt_addr_set_local(a, local_mailbox); - } - - return 0; -} diff --git a/mutt_lua.c b/mutt_lua.c index a8b4a2526a2..6f099079c12 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -32,7 +32,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "mutt_lua.h" -#include "address.h" #include "globals.h" #include "mailbox.h" #include "mbtable.h" diff --git a/muttlib.c b/muttlib.c index fb01225f52b..1c825af9aba 100644 --- a/muttlib.c +++ b/muttlib.c @@ -42,7 +42,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "body.h" #include "envelope.h" diff --git a/mx.c b/mx.c index e32cd87f62e..c81d1a9c898 100644 --- a/mx.c +++ b/mx.c @@ -33,7 +33,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "mx.h" -#include "address.h" #include "body.h" #include "buffy.h" #include "context.h" diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index 4cf1795cd93..29b034474ee 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -34,7 +34,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "body.h" #include "content.h" diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index 1690c461e56..6f5a943ae09 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -44,7 +44,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "body.h" #include "crypt.h" diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index b684878ebea..a622ab64622 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -43,7 +43,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "pgp.h" -#include "address.h" #include "body.h" #include "crypt.h" #include "cryptglue.h" diff --git a/ncrypt/pgpinvoke.c b/ncrypt/pgpinvoke.c index b49c6ad1b4d..07e33c3a4b2 100644 --- a/ncrypt/pgpinvoke.c +++ b/ncrypt/pgpinvoke.c @@ -31,7 +31,6 @@ #include #include #include "mutt/mutt.h" -#include "address.h" #include "filter.h" #include "format_flags.h" #include "globals.h" diff --git a/ncrypt/pgpkey.c b/ncrypt/pgpkey.c index 91c3077d6d6..f56c8d38ac3 100644 --- a/ncrypt/pgpkey.c +++ b/ncrypt/pgpkey.c @@ -35,7 +35,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "pgpkey.h" -#include "address.h" #include "body.h" #include "crypt.h" #include "filter.h" diff --git a/ncrypt/smime.c b/ncrypt/smime.c index fa5f2a59c7c..60412fc234d 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -32,7 +32,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "smime.h" -#include "address.h" #include "alias.h" #include "body.h" #include "copy.h" diff --git a/parse.c b/parse.c index 219db043318..778798cc806 100644 --- a/parse.c +++ b/parse.c @@ -30,7 +30,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "body.h" #include "envelope.h" #include "globals.h" diff --git a/pattern.c b/pattern.c index 400de908a60..b82c14fcff4 100644 --- a/pattern.c +++ b/pattern.c @@ -37,7 +37,6 @@ #include "conn/conn.h" #include "mutt.h" #include "pattern.h" -#include "address.h" #include "body.h" #include "context.h" #include "copy.h" diff --git a/pop_auth.c b/pop_auth.c index e7999332b5b..bc1e0040092 100644 --- a/pop_auth.c +++ b/pop_auth.c @@ -27,7 +27,6 @@ #include "mutt/mutt.h" #include "conn/conn.h" #include "mutt.h" -#include "address.h" #include "globals.h" #include "mutt_account.h" #include "mutt_socket.h" diff --git a/query.c b/query.c index 0b0015ee30f..9ae9068c2f6 100644 --- a/query.c +++ b/query.c @@ -29,7 +29,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "envelope.h" #include "filter.h" diff --git a/recvcmd.c b/recvcmd.c index c7a3f85c325..e13087ae81f 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -27,7 +27,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "attach.h" #include "body.h" diff --git a/remailer.c b/remailer.c index 4ea72304cc2..bc4a58d8cf5 100644 --- a/remailer.c +++ b/remailer.c @@ -34,7 +34,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "remailer.h" -#include "address.h" #include "envelope.h" #include "filter.h" #include "format_flags.h" diff --git a/rfc2047.c b/rfc2047.c index 7a2c1d42007..9e88f6a305c 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -22,9 +22,9 @@ */ #include "config.h" +#include "mutt/address.h" #include "mutt/charset.h" #include "mutt/rfc2047.h" -#include "address.h" #include "globals.h" #include diff --git a/send.c b/send.c index fb3704cd521..ad8d902d38d 100644 --- a/send.c +++ b/send.c @@ -33,7 +33,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "alias.h" #include "body.h" #include "context.h" diff --git a/sendlib.c b/sendlib.c index f93e1fe9205..18f80f38040 100644 --- a/sendlib.c +++ b/sendlib.c @@ -37,7 +37,6 @@ #include #include "mutt/mutt.h" #include "mutt.h" -#include "address.h" #include "body.h" #include "buffy.h" #include "content.h" diff --git a/smtp.c b/smtp.c index fb5648e3232..d772df1ae99 100644 --- a/smtp.c +++ b/smtp.c @@ -34,7 +34,6 @@ #include "mutt/mutt.h" #include "conn/conn.h" #include "mutt.h" -#include "address.h" #include "globals.h" #include "mutt_account.h" #include "mutt_curses.h" diff --git a/sort.c b/sort.c index 452abe670fe..12c782b4caf 100644 --- a/sort.c +++ b/sort.c @@ -26,7 +26,6 @@ #include #include "mutt/mutt.h" #include "sort.h" -#include "address.h" #include "body.h" #include "context.h" #include "envelope.h" diff --git a/url.c b/url.c index 8adea2cab5c..b869eb4f5ab 100644 --- a/url.c +++ b/url.c @@ -31,7 +31,6 @@ #include "mutt/mutt.h" #include "mutt.h" #include "url.h" -#include "address.h" #include "envelope.h" #include "globals.h" #include "protos.h"