2 /* $NetBSD: iconv.h,v 1.6 2005/02/03 04:39:32 perry Exp $ */
5 * Copyright (c) 2003 Citrus Project,
6 * Copyright (c) 2009, 2010 Gabor Kovesdan <gabor@FreeBSD.org>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
36 #include <sys/types.h>
40 #include <sys/cdefs.h>
41 #include <sys/types.h>
44 typedef bool __iconv_bool;
45 #elif __STDC_VERSION__ >= 199901L
46 typedef _Bool __iconv_bool;
48 typedef int __iconv_bool;
52 typedef struct __tag_iconv_t *iconv_t;
55 iconv_t iconv_open(const char *, const char *);
56 size_t iconv(iconv_t, const char ** __restrict,
57 size_t * __restrict, char ** __restrict,
59 int iconv_close(iconv_t);
61 * non-portable interfaces for iconv
63 int __iconv_get_list(char ***, size_t *, __iconv_bool);
64 void __iconv_free_list(char **, size_t);
65 size_t __iconv(iconv_t, const char **, size_t *, char **,
66 size_t *, __uint32_t, size_t *);
67 #define __ICONV_F_HIDE_INVALID 0x0001
70 * GNU interfaces for iconv
73 void *spaceholder[64];
76 int iconv_open_into(const char *, const char *, iconv_allocation_t *);
77 void iconv_set_relocation_prefix(const char *, const char *);
80 * iconvctl() request macros
82 #define ICONV_TRIVIALP 0
83 #define ICONV_GET_TRANSLITERATE 1
84 #define ICONV_SET_TRANSLITERATE 2
85 #define ICONV_GET_DISCARD_ILSEQ 3
86 #define ICONV_SET_DISCARD_ILSEQ 4
87 #define ICONV_SET_HOOKS 5
88 #define ICONV_SET_FALLBACKS 6
90 typedef void (*iconv_unicode_char_hook) (unsigned int mbr, void *data);
91 typedef void (*iconv_wide_char_hook) (wchar_t wc, void *data);
94 iconv_unicode_char_hook uc_hook;
95 iconv_wide_char_hook wc_hook;
100 * Fallbacks aren't supported but type definitions are provided for
101 * source compatibility.
103 typedef void (*iconv_unicode_mb_to_uc_fallback) (const char*,
104 size_t, void (*write_replacement) (const unsigned int *,
105 size_t, void*), void*, void*);
106 typedef void (*iconv_unicode_uc_to_mb_fallback) (unsigned int,
107 void (*write_replacement) (const char *, size_t, void*),
109 typedef void (*iconv_wchar_mb_to_wc_fallback) (const char*, size_t,
110 void (*write_replacement) (const wchar_t *, size_t, void*),
112 typedef void (*iconv_wchar_wc_to_mb_fallback) (wchar_t,
113 void (*write_replacement) (const char *, size_t, void*),
116 struct iconv_fallbacks {
117 iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback;
118 iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback;
119 iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback;
120 iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback;
125 void iconvlist(int (*do_one) (unsigned int, const char * const *,
127 const char *iconv_canonicalize(const char *);
128 int iconvctl(iconv_t, int, void *);
131 #endif /* !_ICONV_H_ */