iconv.h revision 258537
1219019Sgabor/* $FreeBSD: head/include/iconv.h 258537 2013-11-25 01:26:06Z hrs $ */ 2219019Sgabor/* $NetBSD: iconv.h,v 1.6 2005/02/03 04:39:32 perry Exp $ */ 3219019Sgabor 4219019Sgabor/*- 5219019Sgabor * Copyright (c) 2003 Citrus Project, 6219019Sgabor * Copyright (c) 2009, 2010 Gabor Kovesdan <gabor@FreeBSD.org> 7219019Sgabor * All rights reserved. 8219019Sgabor * 9219019Sgabor * Redistribution and use in source and binary forms, with or without 10219019Sgabor * modification, are permitted provided that the following conditions 11219019Sgabor * are met: 12219019Sgabor * 1. Redistributions of source code must retain the above copyright 13219019Sgabor * notice, this list of conditions and the following disclaimer. 14219019Sgabor * 2. Redistributions in binary form must reproduce the above copyright 15219019Sgabor * notice, this list of conditions and the following disclaimer in the 16219019Sgabor * documentation and/or other materials provided with the distribution. 17219019Sgabor * 18219019Sgabor * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19219019Sgabor * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20219019Sgabor * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21219019Sgabor * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22219019Sgabor * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23219019Sgabor * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24219019Sgabor * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25219019Sgabor * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26219019Sgabor * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27219019Sgabor * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28219019Sgabor * SUCH DAMAGE. 29219019Sgabor * 30219019Sgabor */ 31219019Sgabor 32219019Sgabor#ifndef _ICONV_H_ 33219019Sgabor#define _ICONV_H_ 34219019Sgabor 35219019Sgabor#include <sys/cdefs.h> 36219019Sgabor#include <sys/types.h> 37219019Sgabor 38219019Sgabor#include <wchar.h> 39219019Sgabor 40219019Sgabor#include <sys/cdefs.h> 41219019Sgabor#include <sys/types.h> 42219019Sgabor 43255297Stheraven#ifdef __cplusplus 44255297Stheraventypedef bool __iconv_bool; 45255297Stheraven#elif __STDC_VERSION__ >= 199901L 46255297Stheraventypedef _Bool __iconv_bool; 47255297Stheraven#else 48255297Stheraventypedef int __iconv_bool; 49255297Stheraven#endif 50219019Sgabor 51219019Sgaborstruct __tag_iconv_t; 52219019Sgabortypedef struct __tag_iconv_t *iconv_t; 53219019Sgabor 54219019Sgabor__BEGIN_DECLS 55254273Spetericonv_t iconv_open(const char *, const char *); 56254273Spetersize_t iconv(iconv_t, const char ** __restrict, 57254273Speter size_t * __restrict, char ** __restrict, 58254273Speter size_t * __restrict); 59254273Speterint iconv_close(iconv_t); 60219019Sgabor/* 61219019Sgabor * non-portable interfaces for iconv 62219019Sgabor */ 63255297Stheravenint __iconv_get_list(char ***, size_t *, __iconv_bool); 64219019Sgaborvoid __iconv_free_list(char **, size_t); 65252547Spetersize_t __iconv(iconv_t, const char **, size_t *, char **, 66219019Sgabor size_t *, __uint32_t, size_t *); 67219019Sgabor#define __ICONV_F_HIDE_INVALID 0x0001 68219019Sgabor 69219019Sgabor/* 70219019Sgabor * GNU interfaces for iconv 71219019Sgabor */ 72219019Sgabortypedef struct { 73219019Sgabor void *spaceholder[64]; 74219019Sgabor} iconv_allocation_t; 75219019Sgabor 76219019Sgaborint iconv_open_into(const char *, const char *, iconv_allocation_t *); 77258283Spetervoid iconv_set_relocation_prefix(const char *, const char *); 78219019Sgabor 79219019Sgabor/* 80219019Sgabor * iconvctl() request macros 81219019Sgabor */ 82219019Sgabor#define ICONV_TRIVIALP 0 83219019Sgabor#define ICONV_GET_TRANSLITERATE 1 84219019Sgabor#define ICONV_SET_TRANSLITERATE 2 85219019Sgabor#define ICONV_GET_DISCARD_ILSEQ 3 86219019Sgabor#define ICONV_SET_DISCARD_ILSEQ 4 87219019Sgabor#define ICONV_SET_HOOKS 5 88219019Sgabor#define ICONV_SET_FALLBACKS 6 89258537Shrs#define ICONV_GET_ILSEQ_INVALID 128 90258537Shrs#define ICONV_SET_ILSEQ_INVALID 129 91219019Sgabor 92219019Sgabortypedef void (*iconv_unicode_char_hook) (unsigned int mbr, void *data); 93219019Sgabortypedef void (*iconv_wide_char_hook) (wchar_t wc, void *data); 94219019Sgabor 95219019Sgaborstruct iconv_hooks { 96219019Sgabor iconv_unicode_char_hook uc_hook; 97219019Sgabor iconv_wide_char_hook wc_hook; 98219019Sgabor void *data; 99219019Sgabor}; 100219019Sgabor 101219019Sgabor/* 102219019Sgabor * Fallbacks aren't supported but type definitions are provided for 103219019Sgabor * source compatibility. 104219019Sgabor */ 105219019Sgabortypedef void (*iconv_unicode_mb_to_uc_fallback) (const char*, 106219019Sgabor size_t, void (*write_replacement) (const unsigned int *, 107219019Sgabor size_t, void*), void*, void*); 108219019Sgabortypedef void (*iconv_unicode_uc_to_mb_fallback) (unsigned int, 109219019Sgabor void (*write_replacement) (const char *, size_t, void*), 110219019Sgabor void*, void*); 111219019Sgabortypedef void (*iconv_wchar_mb_to_wc_fallback) (const char*, size_t, 112219019Sgabor void (*write_replacement) (const wchar_t *, size_t, void*), 113219019Sgabor void*, void*); 114219019Sgabortypedef void (*iconv_wchar_wc_to_mb_fallback) (wchar_t, 115219019Sgabor void (*write_replacement) (const char *, size_t, void*), 116219019Sgabor void*, void*); 117219019Sgabor 118219019Sgaborstruct iconv_fallbacks { 119219019Sgabor iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback; 120219019Sgabor iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback; 121219019Sgabor iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback; 122219019Sgabor iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback; 123219019Sgabor void *data; 124219019Sgabor}; 125219019Sgabor 126219019Sgabor 127219019Sgaborvoid iconvlist(int (*do_one) (unsigned int, const char * const *, 128219019Sgabor void *), void *); 129219019Sgaborconst char *iconv_canonicalize(const char *); 130219019Sgaborint iconvctl(iconv_t, int, void *); 131219019Sgabor__END_DECLS 132219019Sgabor 133219019Sgabor#endif /* !_ICONV_H_ */ 134