4640b80b18da1c8a42e5d6faa724d75958499638
[apps/madmutt.git] / charset.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9
10 #ifndef _CHARSET_H
11 #define _CHARSET_H
12
13 #ifdef HAVE_CONFIG_H
14 #include "config.h"
15 #endif
16
17 #ifdef HAVE_ICONV_H
18 #include <iconv.h>
19 #endif
20
21 extern char *Charset;
22 extern int Charset_is_utf8;
23
24 #ifndef HAVE_ICONV_T_DEF
25 typedef void *iconv_t;
26 #endif
27
28 #ifndef HAVE_ICONV
29 #  define iconv_open(a, b)     ((iconv_t)(-1))
30 #  define my_iconv(a,b,c,d,e)  0
31 #  define iconv_close(a)       0
32 #else
33 static inline ssize_t my_iconv(iconv_t ict, const char **inbuf, ssize_t *ilen,
34                                char **outbuf, ssize_t *olen)
35 {
36     return iconv(ict, (char **)inbuf, (size_t*)ilen, outbuf, (size_t*)olen);
37 }
38 #endif
39
40 int mutt_convert_string (char **, const char *, const char *, int);
41 const char *mutt_get_first_charset (const char *);
42 int mutt_convert_nonmime_string (char **);
43
44 iconv_t mutt_iconv_open (const char *, const char *, int);
45 ssize_t mutt_iconv (iconv_t, const char **, ssize_t *, char **, ssize_t *,
46                     const char **, const char *);
47
48 typedef void *FGETCONV;
49
50 FGETCONV *fgetconv_open (FILE *, const char *, const char *, int);
51 int fgetconv (FGETCONV *);
52 char *fgetconvs (char *, ssize_t, FGETCONV *);
53 void fgetconv_close (FGETCONV **);
54
55 void mutt_set_langinfo_charset (void);
56
57 #define M_ICONV_HOOK_FROM 1
58 #define M_ICONV_HOOK_TO   2
59
60 void mutt_set_charset(char *charset);
61 wchar_t replacement_char(void);
62
63 #endif /* _CHARSET_H */