10db70a6aSJohn Marino /* $FreeBSD: head/include/iconv.h 281550 2015-04-15 09:09:20Z tijl $ */ 20d5acd74SJohn Marino /* $NetBSD: iconv.h,v 1.6 2005/02/03 04:39:32 perry Exp $ */ 32180e8afSJoerg Sonnenberger 42180e8afSJoerg Sonnenberger /*- 52180e8afSJoerg Sonnenberger * Copyright (c) 2003 Citrus Project, 60d5acd74SJohn Marino * Copyright (c) 2009, 2010 Gabor Kovesdan <gabor@FreeBSD.org> 72180e8afSJoerg Sonnenberger * All rights reserved. 82180e8afSJoerg Sonnenberger * 92180e8afSJoerg Sonnenberger * Redistribution and use in source and binary forms, with or without 102180e8afSJoerg Sonnenberger * modification, are permitted provided that the following conditions 112180e8afSJoerg Sonnenberger * are met: 122180e8afSJoerg Sonnenberger * 1. Redistributions of source code must retain the above copyright 132180e8afSJoerg Sonnenberger * notice, this list of conditions and the following disclaimer. 142180e8afSJoerg Sonnenberger * 2. Redistributions in binary form must reproduce the above copyright 152180e8afSJoerg Sonnenberger * notice, this list of conditions and the following disclaimer in the 162180e8afSJoerg Sonnenberger * documentation and/or other materials provided with the distribution. 172180e8afSJoerg Sonnenberger * 182180e8afSJoerg Sonnenberger * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 192180e8afSJoerg Sonnenberger * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 202180e8afSJoerg Sonnenberger * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 212180e8afSJoerg Sonnenberger * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 222180e8afSJoerg Sonnenberger * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 232180e8afSJoerg Sonnenberger * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 242180e8afSJoerg Sonnenberger * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 252180e8afSJoerg Sonnenberger * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 262180e8afSJoerg Sonnenberger * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 272180e8afSJoerg Sonnenberger * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 282180e8afSJoerg Sonnenberger * SUCH DAMAGE. 292180e8afSJoerg Sonnenberger * 302180e8afSJoerg Sonnenberger */ 312180e8afSJoerg Sonnenberger 322180e8afSJoerg Sonnenberger #ifndef _ICONV_H_ 332180e8afSJoerg Sonnenberger #define _ICONV_H_ 342180e8afSJoerg Sonnenberger 350d5acd74SJohn Marino #include <sys/cdefs.h> 36*d960c16fSSascha Wildner #include <machine/stdint.h> 372180e8afSJoerg Sonnenberger 38*d960c16fSSascha Wildner #if __BSD_VISIBLE 390d5acd74SJohn Marino #include <wchar.h> 40*d960c16fSSascha Wildner #endif 410d5acd74SJohn Marino 42*d960c16fSSascha Wildner #ifndef _SIZE_T_DECLARED 43*d960c16fSSascha Wildner typedef __size_t size_t; 44*d960c16fSSascha Wildner #define _SIZE_T_DECLARED 45*d960c16fSSascha Wildner #endif 46*d960c16fSSascha Wildner 47*d960c16fSSascha Wildner #if __BSD_VISIBLE 480d5acd74SJohn Marino #ifdef __cplusplus 490d5acd74SJohn Marino typedef bool __iconv_bool; 500d5acd74SJohn Marino #elif __STDC_VERSION__ >= 199901L 510d5acd74SJohn Marino typedef _Bool __iconv_bool; 520d5acd74SJohn Marino #else 530d5acd74SJohn Marino typedef int __iconv_bool; 540d5acd74SJohn Marino #endif 55*d960c16fSSascha Wildner #endif 560d5acd74SJohn Marino 572180e8afSJoerg Sonnenberger struct __tag_iconv_t; 582180e8afSJoerg Sonnenberger typedef struct __tag_iconv_t *iconv_t; 592180e8afSJoerg Sonnenberger 602180e8afSJoerg Sonnenberger __BEGIN_DECLS 618eb95a56SSascha Wildner #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE 622180e8afSJoerg Sonnenberger iconv_t iconv_open(const char *, const char *); 630db70a6aSJohn Marino size_t iconv(iconv_t, char ** __restrict, 640d5acd74SJohn Marino size_t * __restrict, char ** __restrict, 650d5acd74SJohn Marino size_t * __restrict); 662180e8afSJoerg Sonnenberger int iconv_close(iconv_t); 678eb95a56SSascha Wildner #endif 68*d960c16fSSascha Wildner #if __BSD_VISIBLE 692180e8afSJoerg Sonnenberger /* 702180e8afSJoerg Sonnenberger * non-portable interfaces for iconv 712180e8afSJoerg Sonnenberger */ 720d5acd74SJohn Marino int __iconv_get_list(char ***, size_t *, __iconv_bool); 732180e8afSJoerg Sonnenberger void __iconv_free_list(char **, size_t); 740db70a6aSJohn Marino size_t __iconv(iconv_t, char **, size_t *, char **, 750d5acd74SJohn Marino size_t *, __uint32_t, size_t *); 762180e8afSJoerg Sonnenberger #define __ICONV_F_HIDE_INVALID 0x0001 770d5acd74SJohn Marino 780d5acd74SJohn Marino /* 790d5acd74SJohn Marino * GNU interfaces for iconv 800d5acd74SJohn Marino */ 810d5acd74SJohn Marino /* We have iconvctl() */ 820d5acd74SJohn Marino #define _ICONV_VERSION 0x0108 830d5acd74SJohn Marino extern int _iconv_version; 840d5acd74SJohn Marino 850d5acd74SJohn Marino typedef struct { 860d5acd74SJohn Marino void *spaceholder[64]; 870d5acd74SJohn Marino } iconv_allocation_t; 880d5acd74SJohn Marino 890d5acd74SJohn Marino int iconv_open_into(const char *, const char *, iconv_allocation_t *); 900db70a6aSJohn Marino void iconv_set_relocation_prefix(const char *, const char *); 910d5acd74SJohn Marino 920d5acd74SJohn Marino /* 930d5acd74SJohn Marino * iconvctl() request macros 940d5acd74SJohn Marino */ 950d5acd74SJohn Marino #define ICONV_TRIVIALP 0 960d5acd74SJohn Marino #define ICONV_GET_TRANSLITERATE 1 970d5acd74SJohn Marino #define ICONV_SET_TRANSLITERATE 2 980d5acd74SJohn Marino #define ICONV_GET_DISCARD_ILSEQ 3 990d5acd74SJohn Marino #define ICONV_SET_DISCARD_ILSEQ 4 1000d5acd74SJohn Marino #define ICONV_SET_HOOKS 5 1010d5acd74SJohn Marino #define ICONV_SET_FALLBACKS 6 1029d944071SJohn Marino #define ICONV_GET_ILSEQ_INVALID 128 1039d944071SJohn Marino #define ICONV_SET_ILSEQ_INVALID 129 1040d5acd74SJohn Marino 1050d5acd74SJohn Marino typedef void (*iconv_unicode_char_hook) (unsigned int mbr, void *data); 1060d5acd74SJohn Marino typedef void (*iconv_wide_char_hook) (wchar_t wc, void *data); 1070d5acd74SJohn Marino 1080d5acd74SJohn Marino struct iconv_hooks { 1090d5acd74SJohn Marino iconv_unicode_char_hook uc_hook; 1100d5acd74SJohn Marino iconv_wide_char_hook wc_hook; 1110d5acd74SJohn Marino void *data; 1120d5acd74SJohn Marino }; 1130d5acd74SJohn Marino 1140d5acd74SJohn Marino /* 1150d5acd74SJohn Marino * Fallbacks aren't supported but type definitions are provided for 1160d5acd74SJohn Marino * source compatibility. 1170d5acd74SJohn Marino */ 1180d5acd74SJohn Marino typedef void (*iconv_unicode_mb_to_uc_fallback) (const char*, 1190d5acd74SJohn Marino size_t, void (*write_replacement) (const unsigned int *, 1200d5acd74SJohn Marino size_t, void*), void*, void*); 1210d5acd74SJohn Marino typedef void (*iconv_unicode_uc_to_mb_fallback) (unsigned int, 1220d5acd74SJohn Marino void (*write_replacement) (const char *, size_t, void*), 1230d5acd74SJohn Marino void*, void*); 1240d5acd74SJohn Marino typedef void (*iconv_wchar_mb_to_wc_fallback) (const char*, size_t, 1250d5acd74SJohn Marino void (*write_replacement) (const wchar_t *, size_t, void*), 1260d5acd74SJohn Marino void*, void*); 1270d5acd74SJohn Marino typedef void (*iconv_wchar_wc_to_mb_fallback) (wchar_t, 1280d5acd74SJohn Marino void (*write_replacement) (const char *, size_t, void*), 1290d5acd74SJohn Marino void*, void*); 1300d5acd74SJohn Marino 1310d5acd74SJohn Marino struct iconv_fallbacks { 1320d5acd74SJohn Marino iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback; 1330d5acd74SJohn Marino iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback; 1340d5acd74SJohn Marino iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback; 1350d5acd74SJohn Marino iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback; 1360d5acd74SJohn Marino void *data; 1370d5acd74SJohn Marino }; 1380d5acd74SJohn Marino 1390d5acd74SJohn Marino 1400d5acd74SJohn Marino void iconvlist(int (*do_one) (unsigned int, const char * const *, 1410d5acd74SJohn Marino void *), void *); 1420d5acd74SJohn Marino const char *iconv_canonicalize(const char *); 1430d5acd74SJohn Marino int iconvctl(iconv_t, int, void *); 144*d960c16fSSascha Wildner #endif /* __BSD_VISIBLE */ 145*d960c16fSSascha Wildner 1462180e8afSJoerg Sonnenberger __END_DECLS 1472180e8afSJoerg Sonnenberger 1482180e8afSJoerg Sonnenberger #endif /* !_ICONV_H_ */ 149