base64 implementation from madmutt--.
[apps/madmutt.git] / charset.h
1 /*
2  *  This program is free software; you can redistribute it and/or modify
3  *  it under the terms of the GNU General Public License as published by
4  *  the Free Software Foundation; either version 2 of the License, or (at
5  *  your option) any later version.
6  *
7  *  This program is distributed in the hope that it will be useful, but
8  *  WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  *  General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
15  *  MA 02110-1301, USA.
16  *
17  *  Copyright © 2006 Pierre Habouzit
18  */
19 /*
20  * Copyright notice from original mutt:
21  * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
22  *
23  * This file is part of mutt-ng, see http://www.muttng.org/.
24  * It's licensed under the GNU General Public License,
25  * please see the file GPL in the top level source directory.
26  */
27
28 #ifndef _CHARSET_H
29 #define _CHARSET_H
30
31 #ifdef HAVE_CONFIG_H
32 #  include "config.h"
33 #endif
34
35 #include <lib-lua/lib-lua.h>
36 #include "charset.li"
37
38 /****************************************************************************/
39 /* charset functions                                                        */
40 /****************************************************************************/
41
42 extern int Charset_is_utf8;
43 extern wchar_t CharsetReplacement;
44
45 void charset_canonicalize(char *, ssize_t, const char *);
46 int  charset_is_utf8(const char *);
47 int  charset_is_us_ascii(const char *);
48 const char *charset_getfirst(const char *);
49
50
51 /****************************************************************************/
52 /* iconv-line functions                                                     */
53 /****************************************************************************/
54
55 #define MUTT_ICONV_ERROR  ((iconv_t)(-1))
56
57 #include <iconv.h>
58
59 static inline ssize_t
60 my_iconv(iconv_t ict, const char **in, ssize_t *il, char **out, ssize_t *ol) {
61     return iconv(ict, (char **)in, (size_t*)il, out, (size_t*)ol);
62 }
63
64 #define M_ICONV_HOOK_FROM 1
65 #define M_ICONV_HOOK_TO   2
66
67 iconv_t mutt_iconv_open(const char *, const char *, int);
68 ssize_t mutt_iconv(iconv_t, const char **, ssize_t *, char **, ssize_t *,
69                    const char **, const char *);
70
71 int mutt_convert_string(char **, const char *, const char *, int);
72 int mutt_convert_nonmime_string (char **);
73
74
75 /****************************************************************************/
76 /* fgetconv functions                                                       */
77 /****************************************************************************/
78
79 typedef struct fgetconv_t fgetconv_t;
80
81 fgetconv_t *fgetconv_open(FILE *, const char *, const char *, int);
82 void fgetconv_close(fgetconv_t **);
83
84 int fgetconv(fgetconv_t *);
85 char *fgetconvs(char *, ssize_t, fgetconv_t *);
86
87 #endif /* _CHARSET_H */