Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
iconv.h265 linesDownload Raw Back to include
1/* Copyright (C) 1999-2024 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 Lesser General Public
6   License as published by the Free Software Foundation; either version 2.1
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   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 the GNU LIBICONV Library; see the file COPYING.LIB.
16   If not, see <https://www.gnu.org/licenses/>.  */
17
18/* When installed, this file is called "iconv.h". */
19
20#ifndef _LIBICONV_H
21#define _LIBICONV_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#define _LIBICONV_VERSION 0x0112    /* version number: (major<<8) + minor */
28
29#if 0 && BUILDING_LIBICONV
30# define LIBICONV_SHLIB_EXPORTED __attribute__((__visibility__("default")))
31#elif defined _MSC_VER && BUILDING_LIBICONV
32/* When building with MSVC, exporting a symbol means that the object file
33   contains a "linker directive" of the form /EXPORT:symbol.  This can be
34   inspected through the "objdump -s --section=.drectve FILE" or
35   "dumpbin /directives FILE" commands.
36   The symbols from this file should be exported if and only if the object
37   file gets included in a DLL.  Libtool, on Windows platforms, defines
38   the C macro DLL_EXPORT (together with PIC) when compiling for a shared
39   library (called DLL under Windows) and does not define it when compiling
40   an object file meant to be linked statically into some executable.  */
41# if defined DLL_EXPORT
42#  define LIBICONV_SHLIB_EXPORTED __declspec(dllexport)
43# else
44#  define LIBICONV_SHLIB_EXPORTED
45# endif
46#else
47# define LIBICONV_SHLIB_EXPORTED
48#endif
49extern LIBICONV_SHLIB_EXPORTED  int _libiconv_version; /* Likewise */
50
51#ifdef __cplusplus
52}
53#endif
54
55/* We would like to #include any system header file which could define
56   iconv_t, in order to eliminate the risk that the user gets compilation
57   errors because some other system header file includes /usr/include/iconv.h
58   which defines iconv_t or declares iconv after this file.
59   But gcc's #include_next is not portable. Thus, once libiconv's iconv.h
60   has been installed in /usr/local/include, there is no way any more to
61   include the original /usr/include/iconv.h. We simply have to get away
62   without it.
63   The risk that a system header file does
64   #include "iconv.h"  or  #include_next "iconv.h"
65   is small. They all do #include <iconv.h>. */
66
67/* Define iconv_t ourselves. */
68#undef iconv_t
69#define iconv_t libiconv_t
70typedef void* iconv_t;
71
72/* Get size_t declaration.
73   Get wchar_t declaration if it exists. */
74#include <stddef.h>
75
76/* Get errno declaration and values. */
77#include <errno.h>
78/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
79   have EILSEQ in a different header.  On these systems, define EILSEQ
80   ourselves. */
81#ifndef EILSEQ
82#define EILSEQ 
83#endif
84
85
86#ifdef __cplusplus
87extern "C" {
88#endif
89
90
91/* Allocates descriptor for code conversion from encoding ‘fromcode’ to
92   encoding ‘tocode’. */
93#define iconv_open libiconv_open
94extern LIBICONV_SHLIB_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode);
95
96/* Converts, using conversion descriptor ‘cd’, at most ‘*inbytesleft’ bytes
97   starting at ‘*inbuf’, writing at most ‘*outbytesleft’ bytes starting at
98   ‘*outbuf’.
99   Decrements ‘*inbytesleft’ and increments ‘*inbuf’ by the same amount.
100   Decrements ‘*outbytesleft’ and increments ‘*outbuf’ by the same amount. */
101#define iconv libiconv
102extern LIBICONV_SHLIB_EXPORTED size_t iconv (iconv_t cd,  char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
103
104/* Frees resources allocated for conversion descriptor ‘cd’. */
105#define iconv_close libiconv_close
106extern LIBICONV_SHLIB_EXPORTED int iconv_close (iconv_t cd);
107
108
109#ifdef __cplusplus
110}
111#endif
112
113
114/* Nonstandard extensions. */
115
116#if 1
117#if 0
118/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
119   <wchar.h>.
120   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
121   included before <wchar.h>.  */
122#include <stddef.h>
123#include <stdio.h>
124#include <time.h>
125#endif
126#include <wchar.h>
127#endif
128
129#ifdef __cplusplus
130extern "C" {
131#endif
132
133/* A type that holds all memory needed by a conversion descriptor.
134   A pointer to such an object can be used as an iconv_t. */
135typedef struct {
136  void* dummy1[28];
137#if 1
138  mbstate_t dummy2;
139#endif
140} iconv_allocation_t;
141
142/* Allocates descriptor for code conversion from encoding ‘fromcode’ to
143   encoding ‘tocode’ into preallocated memory. Returns an error indicator
144   (0 or -1 with errno set). */
145#define iconv_open_into libiconv_open_into
146extern LIBICONV_SHLIB_EXPORTED int iconv_open_into (const char* tocode, const char* fromcode,
147                            iconv_allocation_t* resultp);
148
149/* Control of attributes. */
150#define iconvctl libiconvctl
151extern LIBICONV_SHLIB_EXPORTED int iconvctl (iconv_t cd, int request, void* argument);
152
153/* Hook performed after every successful conversion of a Unicode character. */
154typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data);
155/* Hook performed after every successful conversion of a wide character. */
156typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data);
157/* Set of hooks. */
158struct iconv_hooks {
159  iconv_unicode_char_hook uc_hook;
160  iconv_wide_char_hook wc_hook;
161  void* data;
162};
163
164/* Fallback function.  Invoked when a small number of bytes could not be
165   converted to a Unicode character.  This function should process all
166   bytes from inbuf and may produce replacement Unicode characters by calling
167   the write_replacement callback repeatedly.  */
168typedef void (*iconv_unicode_mb_to_uc_fallback)
169             (const char* inbuf, size_t inbufsize,
170              void (*write_replacement) (const unsigned int *buf, size_t buflen,
171                                         void* callback_arg),
172              void* callback_arg,
173              void* data);
174/* Fallback function.  Invoked when a Unicode character could not be converted
175   to the target encoding.  This function should process the character and
176   may produce replacement bytes (in the target encoding) by calling the
177   write_replacement callback repeatedly.  */
178typedef void (*iconv_unicode_uc_to_mb_fallback)
179             (unsigned int code,
180              void (*write_replacement) (const char *buf, size_t buflen,
181                                         void* callback_arg),
182              void* callback_arg,
183              void* data);
184/* Fallback function.  Invoked when a number of bytes could not be converted to
185   a wide character.  This function should process all bytes from inbuf and may
186   produce replacement wide characters by calling the write_replacement
187   callback repeatedly.  */
188typedef void (*iconv_wchar_mb_to_wc_fallback)
189             (const char* inbuf, size_t inbufsize,
190              void (*write_replacement) (const wchar_t *buf, size_t buflen,
191                                         void* callback_arg),
192              void* callback_arg,
193              void* data);
194/* Fallback function.  Invoked when a wide character could not be converted to
195   the target encoding.  This function should process the character and may
196   produce replacement bytes (in the target encoding) by calling the
197   write_replacement callback repeatedly.  */
198typedef void (*iconv_wchar_wc_to_mb_fallback)
199             (wchar_t code,
200              void (*write_replacement) (const char *buf, size_t buflen,
201                                         void* callback_arg),
202              void* callback_arg,
203              void* data);
204/* Set of fallbacks. */
205struct iconv_fallbacks {
206  iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback;
207  iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback;
208  iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback;
209  iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback;
210  void* data;
211};
212
213/* Surfaces.
214   The concept of surfaces is described in the 'recode' manual.  */
215#define ICONV_SURFACE_NONE             0
216/* In EBCDIC encodings, 0x15 (which encodes the "newline function", see the
217   Unicode standard, chapter 5) maps to U+000A instead of U+0085.  This is
218   for interoperability with C programs and Unix environments on z/OS.  */
219#define ICONV_SURFACE_EBCDIC_ZOS_UNIX  1
220
221/* Requests for iconvctl. */
222#define ICONV_TRIVIALP                    0  /* int *argument */
223#define ICONV_GET_TRANSLITERATE           1  /* int *argument */
224#define ICONV_SET_TRANSLITERATE           2  /* const int *argument */
225#define ICONV_GET_DISCARD_ILSEQ           3  /* int *argument */
226#define ICONV_SET_DISCARD_ILSEQ           4  /* const int *argument */
227#define ICONV_SET_HOOKS                   5  /* const struct iconv_hooks *argument */
228#define ICONV_SET_FALLBACKS               6  /* const struct iconv_fallbacks *argument */
229#define ICONV_GET_FROM_SURFACE            7  /* unsigned int *argument */
230#define ICONV_SET_FROM_SURFACE            8  /* const unsigned int *argument */
231#define ICONV_GET_TO_SURFACE              9  /* unsigned int *argument */
232#define ICONV_SET_TO_SURFACE             10  /* const unsigned int *argument */
233#define ICONV_GET_DISCARD_INVALID        11  /* int *argument */
234#define ICONV_SET_DISCARD_INVALID        12  /* const int *argument */
235#define ICONV_GET_DISCARD_NON_IDENTICAL  13  /* int *argument */
236#define ICONV_SET_DISCARD_NON_IDENTICAL  14  /* const int *argument */
237
238/* Listing of locale independent encodings. */
239#define iconvlist libiconvlist
240extern LIBICONV_SHLIB_EXPORTED void iconvlist (int (*do_one) (unsigned int namescount,
241                                      const char * const * names,
242                                      void* data),
243                       void* data);
244
245/* Canonicalize an encoding name.
246   The result is either a canonical encoding name, or name itself. */
247extern LIBICONV_SHLIB_EXPORTED const char * iconv_canonicalize (const char * name);
248
249/* Support for relocatable packages.  */
250
251/* Sets the original and the current installation prefix of the package.
252   Relocation simply replaces a pathname starting with the original prefix
253   by the corresponding pathname with the current prefix instead.  Both
254   prefixes should be directory names without trailing slash (i.e. use ""
255   instead of "/").  */
256extern LIBICONV_SHLIB_EXPORTED void libiconv_set_relocation_prefix (const char *orig_prefix,
257                                            const char *curr_prefix);
258
259#ifdef __cplusplus
260}
261#endif
262
263
264#endif /* _LIBICONV_H */
265 
codekingpro/portable-devtools · Team Ai