1 /* $FreeBSD: head/include/iconv.h 281550 2015-04-15 09:09:20Z tijl $ */
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 <machine/stdint.h>
42 #ifndef _SIZE_T_DECLARED
43 typedef __size_t
size_t;
44 #define _SIZE_T_DECLARED
49 typedef bool __iconv_bool
;
50 #elif __STDC_VERSION__ >= 199901L
51 typedef _Bool __iconv_bool
;
53 typedef int __iconv_bool
;
58 typedef struct __tag_iconv_t
*iconv_t
;
61 #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
62 iconv_t
iconv_open(const char *, const char *);
63 size_t iconv(iconv_t
, char ** __restrict
,
64 size_t * __restrict
, char ** __restrict
,
66 int iconv_close(iconv_t
);
70 * non-portable interfaces for iconv
72 int __iconv_get_list(char ***, size_t *, __iconv_bool
);
73 void __iconv_free_list(char **, size_t);
74 size_t __iconv(iconv_t
, char **, size_t *, char **,
75 size_t *, __uint32_t
, size_t *);
76 #define __ICONV_F_HIDE_INVALID 0x0001
79 * GNU interfaces for iconv
81 /* We have iconvctl() */
82 #define _ICONV_VERSION 0x0108
83 extern int _iconv_version
;
86 void *spaceholder
[64];
89 int iconv_open_into(const char *, const char *, iconv_allocation_t
*);
90 void iconv_set_relocation_prefix(const char *, const char *);
93 * iconvctl() request macros
95 #define ICONV_TRIVIALP 0
96 #define ICONV_GET_TRANSLITERATE 1
97 #define ICONV_SET_TRANSLITERATE 2
98 #define ICONV_GET_DISCARD_ILSEQ 3
99 #define ICONV_SET_DISCARD_ILSEQ 4
100 #define ICONV_SET_HOOKS 5
101 #define ICONV_SET_FALLBACKS 6
102 #define ICONV_GET_ILSEQ_INVALID 128
103 #define ICONV_SET_ILSEQ_INVALID 129
105 typedef void (*iconv_unicode_char_hook
) (unsigned int mbr
, void *data
);
106 typedef void (*iconv_wide_char_hook
) (wchar_t wc
, void *data
);
109 iconv_unicode_char_hook uc_hook
;
110 iconv_wide_char_hook wc_hook
;
115 * Fallbacks aren't supported but type definitions are provided for
116 * source compatibility.
118 typedef void (*iconv_unicode_mb_to_uc_fallback
) (const char*,
119 size_t, void (*write_replacement
) (const unsigned int *,
120 size_t, void*), void*, void*);
121 typedef void (*iconv_unicode_uc_to_mb_fallback
) (unsigned int,
122 void (*write_replacement
) (const char *, size_t, void*),
124 typedef void (*iconv_wchar_mb_to_wc_fallback
) (const char*, size_t,
125 void (*write_replacement
) (const wchar_t *, size_t, void*),
127 typedef void (*iconv_wchar_wc_to_mb_fallback
) (wchar_t,
128 void (*write_replacement
) (const char *, size_t, void*),
131 struct iconv_fallbacks
{
132 iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback
;
133 iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback
;
134 iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback
;
135 iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback
;
140 void iconvlist(int (*do_one
) (unsigned int, const char * const *,
142 const char *iconv_canonicalize(const char *);
143 int iconvctl(iconv_t
, int, void *);
144 #endif /* __BSD_VISIBLE */
148 #endif /* !_ICONV_H_ */