Improved invalid utf8 encoding error - g_get_charset() is now also reported.
[captive.git] / src / client / fuse / utf8.h
1 /* $Id$
2  * Include file for FUSE interface module utf8 conversions for libcaptive
3  * Copyright (C) 2002-2005 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #ifndef _CAPTIVE_CLIENT_FUSE_UTF8_H
21 #define _CAPTIVE_CLIENT_FUSE_UTF8_H 1
22
23
24 #include <captive/macros.h>
25 #include <glib/gerror.h>
26
27
28 G_BEGIN_DECLS
29
30 char *capfuse_utf8_engine_malloc_errorchecking(const char *funcname,
31                 gchar *(*func)(const gchar *opsysstring,gssize len,gsize *bytes_read,gsize *bytes_written,GError **error),
32                 const char *string);
33
34 #define capfuse_filename_to_utf8_malloc_errorchecking(name) \
35                 capfuse_utf8_engine_malloc_errorchecking("g_filename_to_utf8",g_filename_to_utf8,(name))
36 #define capfuse_filename_from_utf8_malloc_errorchecking(name) \
37                 capfuse_utf8_engine_malloc_errorchecking("g_filename_from_utf8",g_filename_from_utf8,(name))
38
39 #define CAPFUSE_FILENAME_TO_UTF8_ALLOCA(name) ({ \
40                 const char *_capfuse_filename_to_utf8_alloca_name=(name); \
41                 char *_capfuse_filename_to_utf8_alloca_r_malloc; \
42                 const char *_capfuse_filename_to_utf8_alloca_r; \
43                  \
44                 _capfuse_filename_to_utf8_alloca_r_malloc=capfuse_filename_to_utf8_malloc_errorchecking( \
45                                 _capfuse_filename_to_utf8_alloca_name); \
46                 if (!_capfuse_filename_to_utf8_alloca_r_malloc) \
47                         _capfuse_filename_to_utf8_alloca_r=_capfuse_filename_to_utf8_alloca_name; \
48                 else { \
49                         _capfuse_filename_to_utf8_alloca_r=captive_strdup_alloca(_capfuse_filename_to_utf8_alloca_r_malloc); \
50                         g_free(_capfuse_filename_to_utf8_alloca_r_malloc); \
51                         } \
52                 _capfuse_filename_to_utf8_alloca_r; \
53                 })
54
55 G_END_DECLS
56
57
58 #endif /* _CAPTIVE_CLIENT_FUSE_UTF8_H */