OLD | NEW |
(Empty) | |
| 1 /* Copyright (C) 1999-2003, 2005-2006, 2008-2011 Free Software Foundation, Inc. |
| 2 This file is part of the GNU LIBICONV Library. |
| 3 |
| 4 The GNU LIBICONV Library is free software; you can redistribute it |
| 5 and/or modify it under the terms of the GNU Library General Public |
| 6 License as published by the Free Software Foundation; either version 2 |
| 7 of the License, or (at your option) any later version. |
| 8 |
| 9 The GNU LIBICONV Library is distributed in the hope that it will be |
| 10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 Library General Public License for more details. |
| 13 |
| 14 You should have received a copy of the GNU Library General Public |
| 15 License along with the GNU LIBICONV Library; see the file COPYING.LIB. |
| 16 If not, write to the Free Software Foundation, Inc., 51 Franklin Street, |
| 17 Fifth Floor, Boston, MA 02110-1301, USA. */ |
| 18 |
| 19 /* When installed, this file is called "iconv.h". */ |
| 20 |
| 21 #ifndef _LIBICONV_H |
| 22 #define _LIBICONV_H |
| 23 |
| 24 #define _LIBICONV_VERSION 0x010E /* version number: (major<<8) + minor */ |
| 25 |
| 26 #define LIBICONV_DLL_EXPORTED |
| 27 extern LIBICONV_DLL_EXPORTED int _libiconv_version; /* Likewise */ |
| 28 |
| 29 /* We would like to #include any system header file which could define |
| 30 iconv_t, 1. in order to eliminate the risk that the user gets compilation |
| 31 errors because some other system header file includes /usr/include/iconv.h |
| 32 which defines iconv_t or declares iconv after this file, 2. when compiling |
| 33 for LIBICONV_PLUG, we need the proper iconv_t type in order to produce |
| 34 binary compatible code. |
| 35 But gcc's #include_next is not portable. Thus, once libiconv's iconv.h |
| 36 has been installed in /usr/local/include, there is no way any more to |
| 37 include the original /usr/include/iconv.h. We simply have to get away |
| 38 without it. |
| 39 Ad 1. The risk that a system header file does |
| 40 #include "iconv.h" or #include_next "iconv.h" |
| 41 is small. They all do #include <iconv.h>. |
| 42 Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It |
| 43 has to be a scalar type because (iconv_t)(-1) is a possible return value |
| 44 from iconv_open().) */ |
| 45 |
| 46 /* Define iconv_t ourselves. */ |
| 47 #undef iconv_t |
| 48 #define iconv_t libiconv_t |
| 49 typedef void* iconv_t; |
| 50 |
| 51 /* Get size_t declaration. |
| 52 Get wchar_t declaration if it exists. */ |
| 53 #include <stddef.h> |
| 54 |
| 55 /* Get errno declaration and values. */ |
| 56 #include <errno.h> |
| 57 /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, |
| 58 have EILSEQ in a different header. On these systems, define EILSEQ |
| 59 ourselves. */ |
| 60 #ifndef EILSEQ |
| 61 #define EILSEQ @EILSEQ@ |
| 62 #endif |
| 63 |
| 64 |
| 65 #ifdef __cplusplus |
| 66 extern "C" { |
| 67 #endif |
| 68 |
| 69 |
| 70 /* Allocates descriptor for code conversion from encoding ‘fromcode’ to |
| 71 encoding ‘tocode’. */ |
| 72 #ifndef LIBICONV_PLUG |
| 73 #define iconv_open libiconv_open |
| 74 #endif |
| 75 extern LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char*
fromcode); |
| 76 |
| 77 /* Converts, using conversion descriptor ‘cd’, at most ‘*inbytesleft’ bytes |
| 78 starting at ‘*inbuf’, writing at most ‘*outbytesleft’ bytes starting at |
| 79 ‘*outbuf’. |
| 80 Decrements ‘*inbytesleft’ and increments ‘*inbuf’ by the same amount. |
| 81 Decrements ‘*outbytesleft’ and increments ‘*outbuf’ by the same amount. */ |
| 82 #ifndef LIBICONV_PLUG |
| 83 #define iconv libiconv |
| 84 #endif |
| 85 extern LIBICONV_DLL_EXPORTED size_t iconv (iconv_t cd, const char* * inbuf, size
_t *inbytesleft, char* * outbuf, size_t *outbytesleft); |
| 86 |
| 87 /* Frees resources allocated for conversion descriptor ‘cd’. */ |
| 88 #ifndef LIBICONV_PLUG |
| 89 #define iconv_close libiconv_close |
| 90 #endif |
| 91 extern LIBICONV_DLL_EXPORTED int iconv_close (iconv_t cd); |
| 92 |
| 93 |
| 94 #ifdef __cplusplus |
| 95 } |
| 96 #endif |
| 97 |
| 98 |
| 99 #ifndef LIBICONV_PLUG |
| 100 |
| 101 /* Nonstandard extensions. */ |
| 102 |
| 103 #if USE_MBSTATE_T |
| 104 #if BROKEN_WCHAR_H |
| 105 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before |
| 106 <wchar.h>. |
| 107 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be |
| 108 included before <wchar.h>. */ |
| 109 #include <stddef.h> |
| 110 #include <stdio.h> |
| 111 #include <time.h> |
| 112 #endif |
| 113 #include <wchar.h> |
| 114 #endif |
| 115 |
| 116 #ifdef __cplusplus |
| 117 extern "C" { |
| 118 #endif |
| 119 |
| 120 /* A type that holds all memory needed by a conversion descriptor. |
| 121 A pointer to such an object can be used as an iconv_t. */ |
| 122 typedef struct { |
| 123 void* dummy1[28]; |
| 124 #if USE_MBSTATE_T |
| 125 mbstate_t dummy2; |
| 126 #endif |
| 127 } iconv_allocation_t; |
| 128 |
| 129 /* Allocates descriptor for code conversion from encoding ‘fromcode’ to |
| 130 encoding ‘tocode’ into preallocated memory. Returns an error indicator |
| 131 (0 or -1 with errno set). */ |
| 132 #define iconv_open_into libiconv_open_into |
| 133 extern LIBICONV_DLL_EXPORTED int iconv_open_into (const char* tocode, const char
* fromcode, |
| 134 iconv_allocation_t* resultp); |
| 135 |
| 136 /* Control of attributes. */ |
| 137 #define iconvctl libiconvctl |
| 138 extern LIBICONV_DLL_EXPORTED int iconvctl (iconv_t cd, int request, void* argume
nt); |
| 139 |
| 140 /* Hook performed after every successful conversion of a Unicode character. */ |
| 141 typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data); |
| 142 /* Hook performed after every successful conversion of a wide character. */ |
| 143 typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data); |
| 144 /* Set of hooks. */ |
| 145 struct iconv_hooks { |
| 146 iconv_unicode_char_hook uc_hook; |
| 147 iconv_wide_char_hook wc_hook; |
| 148 void* data; |
| 149 }; |
| 150 |
| 151 /* Fallback function. Invoked when a small number of bytes could not be |
| 152 converted to a Unicode character. This function should process all |
| 153 bytes from inbuf and may produce replacement Unicode characters by calling |
| 154 the write_replacement callback repeatedly. */ |
| 155 typedef void (*iconv_unicode_mb_to_uc_fallback) |
| 156 (const char* inbuf, size_t inbufsize, |
| 157 void (*write_replacement) (const unsigned int *buf, size_t buflen, |
| 158 void* callback_arg), |
| 159 void* callback_arg, |
| 160 void* data); |
| 161 /* Fallback function. Invoked when a Unicode character could not be converted |
| 162 to the target encoding. This function should process the character and |
| 163 may produce replacement bytes (in the target encoding) by calling the |
| 164 write_replacement callback repeatedly. */ |
| 165 typedef void (*iconv_unicode_uc_to_mb_fallback) |
| 166 (unsigned int code, |
| 167 void (*write_replacement) (const char *buf, size_t buflen, |
| 168 void* callback_arg), |
| 169 void* callback_arg, |
| 170 void* data); |
| 171 #if HAVE_WCHAR_T |
| 172 /* Fallback function. Invoked when a number of bytes could not be converted to |
| 173 a wide character. This function should process all bytes from inbuf and may |
| 174 produce replacement wide characters by calling the write_replacement |
| 175 callback repeatedly. */ |
| 176 typedef void (*iconv_wchar_mb_to_wc_fallback) |
| 177 (const char* inbuf, size_t inbufsize, |
| 178 void (*write_replacement) (const wchar_t *buf, size_t buflen, |
| 179 void* callback_arg), |
| 180 void* callback_arg, |
| 181 void* data); |
| 182 /* Fallback function. Invoked when a wide character could not be converted to |
| 183 the target encoding. This function should process the character and may |
| 184 produce replacement bytes (in the target encoding) by calling the |
| 185 write_replacement callback repeatedly. */ |
| 186 typedef void (*iconv_wchar_wc_to_mb_fallback) |
| 187 (wchar_t code, |
| 188 void (*write_replacement) (const char *buf, size_t buflen, |
| 189 void* callback_arg), |
| 190 void* callback_arg, |
| 191 void* data); |
| 192 #else |
| 193 /* If the wchar_t type does not exist, these two fallback functions are never |
| 194 invoked. Their argument list therefore does not matter. */ |
| 195 typedef void (*iconv_wchar_mb_to_wc_fallback) (); |
| 196 typedef void (*iconv_wchar_wc_to_mb_fallback) (); |
| 197 #endif |
| 198 /* Set of fallbacks. */ |
| 199 struct iconv_fallbacks { |
| 200 iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback; |
| 201 iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback; |
| 202 iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback; |
| 203 iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback; |
| 204 void* data; |
| 205 }; |
| 206 |
| 207 /* Requests for iconvctl. */ |
| 208 #define ICONV_TRIVIALP 0 /* int *argument */ |
| 209 #define ICONV_GET_TRANSLITERATE 1 /* int *argument */ |
| 210 #define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ |
| 211 #define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */ |
| 212 #define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */ |
| 213 #define ICONV_SET_HOOKS 5 /* const struct iconv_hooks *argument */ |
| 214 #define ICONV_SET_FALLBACKS 6 /* const struct iconv_fallbacks *argument *
/ |
| 215 |
| 216 /* Listing of locale independent encodings. */ |
| 217 #define iconvlist libiconvlist |
| 218 extern LIBICONV_DLL_EXPORTED void iconvlist (int (*do_one) (unsigned int namesco
unt, |
| 219 const char * const * names, |
| 220 void* data), |
| 221 void* data); |
| 222 |
| 223 /* Canonicalize an encoding name. |
| 224 The result is either a canonical encoding name, or name itself. */ |
| 225 extern LIBICONV_DLL_EXPORTED const char * iconv_canonicalize (const char * name)
; |
| 226 |
| 227 /* Support for relocatable packages. */ |
| 228 |
| 229 /* Sets the original and the current installation prefix of the package. |
| 230 Relocation simply replaces a pathname starting with the original prefix |
| 231 by the corresponding pathname with the current prefix instead. Both |
| 232 prefixes should be directory names without trailing slash (i.e. use "" |
| 233 instead of "/"). */ |
| 234 extern LIBICONV_DLL_EXPORTED void libiconv_set_relocation_prefix (const char *or
ig_prefix, |
| 235 const char *curr_prefix); |
| 236 |
| 237 #ifdef __cplusplus |
| 238 } |
| 239 #endif |
| 240 |
| 241 #endif |
| 242 |
| 243 |
| 244 #endif /* _LIBICONV_H */ |
OLD | NEW |