Add a test for g_atexit
[platform/upstream/glib.git] / glib / gconvert.h
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GLib Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GLib at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 #ifndef __G_CONVERT_H__
28 #define __G_CONVERT_H__
29
30 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
31 #error "Only <glib.h> can be included directly."
32 #endif
33
34 #include <glib/gerror.h>
35
36 G_BEGIN_DECLS
37
38 /**
39  * GConvertError:
40  * @G_CONVERT_ERROR_NO_CONVERSION: Conversion between the requested character
41  *     sets is not supported.
42  * @G_CONVERT_ERROR_ILLEGAL_SEQUENCE: Invalid byte sequence in conversion input.
43  * @G_CONVERT_ERROR_FAILED: Conversion failed for some reason.
44  * @G_CONVERT_ERROR_PARTIAL_INPUT: Partial character sequence at end of input.
45  * @G_CONVERT_ERROR_BAD_URI: URI is invalid.
46  * @G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: Pathname is not an absolute path.
47  * @G_CONVERT_ERROR_NO_MEMORY: No memory available. Since: 2.40
48  *
49  * Error codes returned by character set conversion routines.
50  */
51 typedef enum
52 {
53   G_CONVERT_ERROR_NO_CONVERSION,
54   G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
55   G_CONVERT_ERROR_FAILED,
56   G_CONVERT_ERROR_PARTIAL_INPUT,
57   G_CONVERT_ERROR_BAD_URI,
58   G_CONVERT_ERROR_NOT_ABSOLUTE_PATH,
59   G_CONVERT_ERROR_NO_MEMORY
60 } GConvertError;
61
62 /**
63  * G_CONVERT_ERROR:
64  *
65  * Error domain for character set conversions. Errors in this domain will
66  * be from the #GConvertError enumeration. See #GError for information on
67  * error domains.
68  */
69 #define G_CONVERT_ERROR g_convert_error_quark()
70 GLIB_AVAILABLE_IN_ALL
71 GQuark g_convert_error_quark (void);
72
73 /**
74  * GIconv:
75  *
76  * The <structname>GIConv</structname> struct wraps an
77  * iconv() conversion descriptor. It contains private data
78  * and should only be accessed using the following functions.
79  */
80 typedef struct _GIConv *GIConv;
81
82 GLIB_AVAILABLE_IN_ALL
83 GIConv g_iconv_open   (const gchar  *to_codeset,
84                        const gchar  *from_codeset);
85 GLIB_AVAILABLE_IN_ALL
86 gsize  g_iconv        (GIConv        converter,
87                        gchar       **inbuf,
88                        gsize        *inbytes_left,
89                        gchar       **outbuf,
90                        gsize        *outbytes_left);
91 GLIB_AVAILABLE_IN_ALL
92 gint   g_iconv_close  (GIConv        converter);
93
94
95 GLIB_AVAILABLE_IN_ALL
96 gchar* g_convert               (const gchar  *str,
97                                 gssize        len,            
98                                 const gchar  *to_codeset,
99                                 const gchar  *from_codeset,
100                                 gsize        *bytes_read,     
101                                 gsize        *bytes_written,  
102                                 GError      **error) G_GNUC_MALLOC;
103 GLIB_AVAILABLE_IN_ALL
104 gchar* g_convert_with_iconv    (const gchar  *str,
105                                 gssize        len,
106                                 GIConv        converter,
107                                 gsize        *bytes_read,     
108                                 gsize        *bytes_written,  
109                                 GError      **error) G_GNUC_MALLOC;
110 GLIB_AVAILABLE_IN_ALL
111 gchar* g_convert_with_fallback (const gchar  *str,
112                                 gssize        len,            
113                                 const gchar  *to_codeset,
114                                 const gchar  *from_codeset,
115                                 const gchar  *fallback,
116                                 gsize        *bytes_read,     
117                                 gsize        *bytes_written,  
118                                 GError      **error) G_GNUC_MALLOC;
119
120
121 /* Convert between libc's idea of strings and UTF-8.
122  */
123 GLIB_AVAILABLE_IN_ALL
124 gchar* g_locale_to_utf8   (const gchar  *opsysstring,
125                            gssize        len,            
126                            gsize        *bytes_read,     
127                            gsize        *bytes_written,  
128                            GError      **error) G_GNUC_MALLOC;
129 GLIB_AVAILABLE_IN_ALL
130 gchar* g_locale_from_utf8 (const gchar  *utf8string,
131                            gssize        len,            
132                            gsize        *bytes_read,     
133                            gsize        *bytes_written,  
134                            GError      **error) G_GNUC_MALLOC;
135
136 /* Convert between the operating system (or C runtime)
137  * representation of file names and UTF-8.
138  */
139 GLIB_AVAILABLE_IN_ALL
140 gchar* g_filename_to_utf8   (const gchar  *opsysstring,
141                              gssize        len,            
142                              gsize        *bytes_read,     
143                              gsize        *bytes_written,  
144                              GError      **error) G_GNUC_MALLOC;
145 GLIB_AVAILABLE_IN_ALL
146 gchar* g_filename_from_utf8 (const gchar  *utf8string,
147                              gssize        len,            
148                              gsize        *bytes_read,     
149                              gsize        *bytes_written,  
150                              GError      **error) G_GNUC_MALLOC;
151
152 GLIB_AVAILABLE_IN_ALL
153 gchar *g_filename_from_uri (const gchar *uri,
154                             gchar      **hostname,
155                             GError     **error) G_GNUC_MALLOC;
156   
157 GLIB_AVAILABLE_IN_ALL
158 gchar *g_filename_to_uri   (const gchar *filename,
159                             const gchar *hostname,
160                             GError     **error) G_GNUC_MALLOC;
161 GLIB_AVAILABLE_IN_ALL
162 gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC;
163 GLIB_AVAILABLE_IN_ALL
164 gboolean g_get_filename_charsets (const gchar ***charsets);
165
166 GLIB_AVAILABLE_IN_ALL
167 gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC;
168
169 GLIB_AVAILABLE_IN_ALL
170 gchar **g_uri_list_extract_uris (const gchar *uri_list) G_GNUC_MALLOC;
171
172 #ifdef G_OS_WIN32
173 #define g_filename_to_utf8   g_filename_to_utf8_utf8
174 #define g_filename_from_utf8 g_filename_from_utf8_utf8
175 #define g_filename_from_uri  g_filename_from_uri_utf8
176 #define g_filename_to_uri    g_filename_to_uri_utf8
177
178 GLIB_AVAILABLE_IN_ALL
179 gchar* g_filename_to_utf8_utf8   (const gchar  *opsysstring,
180                                   gssize        len,
181                                   gsize        *bytes_read,
182                                   gsize        *bytes_written,
183                                   GError      **error) G_GNUC_MALLOC;
184 GLIB_AVAILABLE_IN_ALL
185 gchar* g_filename_from_utf8_utf8 (const gchar  *utf8string,
186                                   gssize        len,
187                                   gsize        *bytes_read,
188                                   gsize        *bytes_written,
189                                   GError      **error) G_GNUC_MALLOC;
190 GLIB_AVAILABLE_IN_ALL
191 gchar *g_filename_from_uri_utf8  (const gchar  *uri,
192                                   gchar       **hostname,
193                                   GError      **error) G_GNUC_MALLOC;
194 GLIB_AVAILABLE_IN_ALL
195 gchar *g_filename_to_uri_utf8    (const gchar  *filename,
196                                   const gchar  *hostname,
197                                   GError      **error) G_GNUC_MALLOC;
198 #endif
199
200 G_END_DECLS
201
202 #endif /* __G_CONVERT_H__ */