mutt stable branch with some hacks
1/*
2 * Copyright (C) 2003,2005 Thomas Roessler <roessler@does-not-exist.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#ifndef _MUTT_IDNA_H
20# define _MUTT_IDNA_H
21
22#include "rfc822.h"
23#include "charset.h"
24
25#ifdef HAVE_IDNA_H
26#include <idna.h>
27#elif defined(HAVE_IDN_IDNA_H)
28#include <idn/idna.h>
29#elif defined(HAVE_IDN2_H)
30#include <idn2.h>
31#elif defined(HAVE_IDN_IDN2_H)
32#include <idn/idn2.h>
33#endif
34
35#define MI_MAY_BE_IRREVERSIBLE (1 << 0)
36
37/* Work around incompatibilities in the libidn API */
38
39#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
40# if (!defined(HAVE_IDNA_TO_ASCII_8Z) && defined(HAVE_IDNA_TO_ASCII_FROM_UTF8))
41# define idna_to_ascii_8z(a,b,c) idna_to_ascii_from_utf8(a,b,(c)&1,((c)&2)?1:0)
42# endif
43# if (!defined(HAVE_IDNA_TO_ASCII_LZ) && defined(HAVE_IDNA_TO_ASCII_FROM_LOCALE))
44# define idna_to_ascii_lz(a,b,c) idna_to_ascii_from_locale(a,b,(c)&1,((c)&2)?1:0)
45# endif
46# if (!defined(HAVE_IDNA_TO_UNICODE_8Z8Z) && defined(HAVE_IDNA_TO_UNICODE_UTF8_FROM_UTF8))
47# define idna_to_unicode_8z8z(a,b,c) idna_to_unicode_utf8_from_utf8(a,b,(c)&1,((c)&2)?1:0)
48# endif
49#endif /* defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) */
50
51
52#ifdef HAVE_ICONV
53int mutt_addrlist_to_intl (ADDRESS *, char **);
54int mutt_addrlist_to_local (ADDRESS *);
55
56void mutt_env_to_local (ENVELOPE *);
57int mutt_env_to_intl (ENVELOPE *, char **, char **);
58
59const char *mutt_addr_for_display (ADDRESS *a);
60#else
61static inline int mutt_addrlist_to_intl (ADDRESS *addr, char **err)
62{
63 return 0;
64}
65
66static inline int mutt_addrlist_to_local (ADDRESS *addr)
67{
68 return 0;
69}
70
71static inline void mutt_env_to_local (ENVELOPE *env)
72{
73 return;
74}
75
76static inline int mutt_env_to_intl (ENVELOPE *env, char **tag, char **err)
77{
78 return 0;
79}
80
81static inline const char *mutt_addr_for_display (ADDRESS *a)
82{
83 return a->mailbox;
84}
85#endif /* HAVE_LIBICONV */
86
87
88#endif