iconv.h revision 258537
11592Srgrimes/* $FreeBSD: head/include/iconv.h 258537 2013-11-25 01:26:06Z hrs $ */ 21592Srgrimes/* $NetBSD: iconv.h,v 1.6 2005/02/03 04:39:32 perry Exp $ */ 31592Srgrimes 41592Srgrimes/*- 51592Srgrimes * Copyright (c) 2003 Citrus Project, 61592Srgrimes * Copyright (c) 2009, 2010 Gabor Kovesdan <gabor@FreeBSD.org> 71592Srgrimes * All rights reserved. 81592Srgrimes * 91592Srgrimes * Redistribution and use in source and binary forms, with or without 101592Srgrimes * modification, are permitted provided that the following conditions 111592Srgrimes * are met: 121592Srgrimes * 1. Redistributions of source code must retain the above copyright 131592Srgrimes * notice, this list of conditions and the following disclaimer. 141592Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 151592Srgrimes * notice, this list of conditions and the following disclaimer in the 161592Srgrimes * documentation and/or other materials provided with the distribution. 171592Srgrimes * 181592Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 191592Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 201592Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21262435Sbrueffer * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 221592Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 231592Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 241592Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 251592Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 261592Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 271592Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 281592Srgrimes * SUCH DAMAGE. 291592Srgrimes * 301592Srgrimes */ 311592Srgrimes 321592Srgrimes#ifndef _ICONV_H_ 331592Srgrimes#define _ICONV_H_ 341592Srgrimes 351592Srgrimes#include <sys/cdefs.h> 361592Srgrimes#include <sys/types.h> 3727074Ssteve 381592Srgrimes#include <wchar.h> 3927074Ssteve 401592Srgrimes#include <sys/cdefs.h> 411592Srgrimes#include <sys/types.h> 421592Srgrimes 431592Srgrimes#ifdef __cplusplus 4431386Scharniertypedef bool __iconv_bool; 4527077Ssteve#elif __STDC_VERSION__ >= 199901L 4631386Scharniertypedef _Bool __iconv_bool; 4731386Scharnier#else 4850476Spetertypedef int __iconv_bool; 491592Srgrimes#endif 501592Srgrimes 511592Srgrimesstruct __tag_iconv_t; 521592Srgrimestypedef struct __tag_iconv_t *iconv_t; 53129652Sstefanf 541592Srgrimes__BEGIN_DECLS 551592Srgrimesiconv_t iconv_open(const char *, const char *); 561592Srgrimessize_t iconv(iconv_t, const char ** __restrict, 571592Srgrimes size_t * __restrict, char ** __restrict, 581592Srgrimes size_t * __restrict); 591592Srgrimesint iconv_close(iconv_t); 601592Srgrimes/* 611592Srgrimes * non-portable interfaces for iconv 621592Srgrimes */ 631592Srgrimesint __iconv_get_list(char ***, size_t *, __iconv_bool); 641592Srgrimesvoid __iconv_free_list(char **, size_t); 651592Srgrimessize_t __iconv(iconv_t, const char **, size_t *, char **, 661592Srgrimes size_t *, __uint32_t, size_t *); 671592Srgrimes#define __ICONV_F_HIDE_INVALID 0x0001 681592Srgrimes 691592Srgrimes/* 701592Srgrimes * GNU interfaces for iconv 711592Srgrimes */ 721592Srgrimestypedef struct { 731592Srgrimes void *spaceholder[64]; 741592Srgrimes} iconv_allocation_t; 751592Srgrimes 761592Srgrimesint iconv_open_into(const char *, const char *, iconv_allocation_t *); 771592Srgrimesvoid iconv_set_relocation_prefix(const char *, const char *); 781592Srgrimes 791592Srgrimes/* 801592Srgrimes * iconvctl() request macros 811592Srgrimes */ 821592Srgrimes#define ICONV_TRIVIALP 0 831592Srgrimes#define ICONV_GET_TRANSLITERATE 1 841592Srgrimes#define ICONV_SET_TRANSLITERATE 2 851592Srgrimes#define ICONV_GET_DISCARD_ILSEQ 3 8690377Simp#define ICONV_SET_DISCARD_ILSEQ 4 871592Srgrimes#define ICONV_SET_HOOKS 5 881592Srgrimes#define ICONV_SET_FALLBACKS 6 891592Srgrimes#define ICONV_GET_ILSEQ_INVALID 128 901592Srgrimes#define ICONV_SET_ILSEQ_INVALID 129 911592Srgrimes 921592Srgrimestypedef void (*iconv_unicode_char_hook) (unsigned int mbr, void *data); 931592Srgrimestypedef void (*iconv_wide_char_hook) (wchar_t wc, void *data); 941592Srgrimes 951592Srgrimesstruct iconv_hooks { 961592Srgrimes iconv_unicode_char_hook uc_hook; 971592Srgrimes iconv_wide_char_hook wc_hook; 981592Srgrimes void *data; 991592Srgrimes}; 1001592Srgrimes 1011592Srgrimes/* 1021592Srgrimes * Fallbacks aren't supported but type definitions are provided for 1031592Srgrimes * source compatibility. 1041592Srgrimes */ 1051592Srgrimestypedef void (*iconv_unicode_mb_to_uc_fallback) (const char*, 1061592Srgrimes size_t, void (*write_replacement) (const unsigned int *, 1071592Srgrimes size_t, void*), void*, void*); 1081592Srgrimestypedef void (*iconv_unicode_uc_to_mb_fallback) (unsigned int, 1091592Srgrimes void (*write_replacement) (const char *, size_t, void*), 1101592Srgrimes void*, void*); 1111592Srgrimestypedef void (*iconv_wchar_mb_to_wc_fallback) (const char*, size_t, 1121592Srgrimes void (*write_replacement) (const wchar_t *, size_t, void*), 11327074Ssteve void*, void*); 1141592Srgrimestypedef void (*iconv_wchar_wc_to_mb_fallback) (wchar_t, 1151592Srgrimes void (*write_replacement) (const char *, size_t, void*), 1161592Srgrimes void*, void*); 1171592Srgrimes 1181592Srgrimesstruct iconv_fallbacks { 1191592Srgrimes iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback; 1201592Srgrimes iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback; 1211592Srgrimes iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback; 1221592Srgrimes iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback; 1231592Srgrimes void *data; 1241592Srgrimes}; 1251592Srgrimes 1261592Srgrimes 1271592Srgrimesvoid iconvlist(int (*do_one) (unsigned int, const char * const *, 1281592Srgrimes void *), void *); 1291592Srgrimesconst char *iconv_canonicalize(const char *); 1301592Srgrimesint iconvctl(iconv_t, int, void *); 1311592Srgrimes__END_DECLS 1321592Srgrimes 1331592Srgrimes#endif /* !_ICONV_H_ */ 1341592Srgrimes