citrus_iconv_local.h revision 250938
1219019Sgabor/* $FreeBSD: head/lib/libc/iconv/citrus_iconv_local.h 250938 2013-05-23 18:07:01Z ed $ */ 2219019Sgabor/* $NetBSD: citrus_iconv_local.h,v 1.3 2008/02/09 14:56:20 junyoung Exp $ */ 3219019Sgabor 4219019Sgabor/*- 5219019Sgabor * Copyright (c)2003 Citrus Project, 6219019Sgabor * All rights reserved. 7219019Sgabor * 8219019Sgabor * Redistribution and use in source and binary forms, with or without 9219019Sgabor * modification, are permitted provided that the following conditions 10219019Sgabor * are met: 11219019Sgabor * 1. Redistributions of source code must retain the above copyright 12219019Sgabor * notice, this list of conditions and the following disclaimer. 13219019Sgabor * 2. Redistributions in binary form must reproduce the above copyright 14219019Sgabor * notice, this list of conditions and the following disclaimer in the 15219019Sgabor * documentation and/or other materials provided with the distribution. 16219019Sgabor * 17219019Sgabor * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18219019Sgabor * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19219019Sgabor * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20219019Sgabor * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21219019Sgabor * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22219019Sgabor * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23219019Sgabor * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24219019Sgabor * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25219019Sgabor * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26219019Sgabor * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27219019Sgabor * SUCH DAMAGE. 28219019Sgabor */ 29219019Sgabor 30219019Sgabor#ifndef _CITRUS_ICONV_LOCAL_H_ 31219019Sgabor#define _CITRUS_ICONV_LOCAL_H_ 32219019Sgabor 33219019Sgabor#include <iconv.h> 34219019Sgabor 35219019Sgabor#define _CITRUS_ICONV_GETOPS_FUNC_BASE(_n_) \ 36219019Sgabor int _n_(struct _citrus_iconv_ops *) 37219019Sgabor#define _CITRUS_ICONV_GETOPS_FUNC(_n_) \ 38219019Sgabor _CITRUS_ICONV_GETOPS_FUNC_BASE(_citrus_##_n_##_iconv_getops) 39219019Sgabor 40219019Sgabor#define _CITRUS_ICONV_DECLS(_m_) \ 41219019Sgaborstatic int _citrus_##_m_##_iconv_init_shared \ 42219019Sgabor (struct _citrus_iconv_shared * __restrict, \ 43219019Sgabor const char * __restrict, const char * __restrict); \ 44219019Sgaborstatic void _citrus_##_m_##_iconv_uninit_shared \ 45219019Sgabor (struct _citrus_iconv_shared *); \ 46219019Sgaborstatic int _citrus_##_m_##_iconv_convert \ 47219019Sgabor (struct _citrus_iconv * __restrict, \ 48219019Sgabor char * __restrict * __restrict, \ 49219019Sgabor size_t * __restrict, \ 50219019Sgabor char * __restrict * __restrict, \ 51219019Sgabor size_t * __restrict outbytes, \ 52219019Sgabor uint32_t, size_t * __restrict); \ 53219019Sgaborstatic int _citrus_##_m_##_iconv_init_context \ 54219019Sgabor (struct _citrus_iconv *); \ 55219019Sgaborstatic void _citrus_##_m_##_iconv_uninit_context \ 56219019Sgabor (struct _citrus_iconv *) 57219019Sgabor 58219019Sgabor 59219019Sgabor#define _CITRUS_ICONV_DEF_OPS(_m_) \ 60250938Sedextern struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops; \ 61219019Sgaborstruct _citrus_iconv_ops _citrus_##_m_##_iconv_ops = { \ 62219019Sgabor /* io_init_shared */ &_citrus_##_m_##_iconv_init_shared, \ 63219019Sgabor /* io_uninit_shared */ &_citrus_##_m_##_iconv_uninit_shared, \ 64219019Sgabor /* io_init_context */ &_citrus_##_m_##_iconv_init_context, \ 65219019Sgabor /* io_uninit_context */ &_citrus_##_m_##_iconv_uninit_context, \ 66219019Sgabor /* io_convert */ &_citrus_##_m_##_iconv_convert \ 67219019Sgabor} 68219019Sgabor 69219019Sgabortypedef _CITRUS_ICONV_GETOPS_FUNC_BASE((*_citrus_iconv_getops_t)); 70219019Sgabortypedef int (*_citrus_iconv_init_shared_t) 71219019Sgabor (struct _citrus_iconv_shared * __restrict, 72219019Sgabor const char * __restrict, const char * __restrict); 73219019Sgabortypedef void (*_citrus_iconv_uninit_shared_t) 74219019Sgabor (struct _citrus_iconv_shared *); 75219019Sgabortypedef int (*_citrus_iconv_convert_t) 76219019Sgabor (struct _citrus_iconv * __restrict, 77219019Sgabor char *__restrict* __restrict, size_t * __restrict, 78219019Sgabor char * __restrict * __restrict, size_t * __restrict, uint32_t, 79219019Sgabor size_t * __restrict); 80219019Sgabortypedef int (*_citrus_iconv_init_context_t)(struct _citrus_iconv *); 81219019Sgabortypedef void (*_citrus_iconv_uninit_context_t)(struct _citrus_iconv *); 82219019Sgabor 83219019Sgaborstruct _citrus_iconv_ops { 84219019Sgabor _citrus_iconv_init_shared_t io_init_shared; 85219019Sgabor _citrus_iconv_uninit_shared_t io_uninit_shared; 86219019Sgabor _citrus_iconv_init_context_t io_init_context; 87219019Sgabor _citrus_iconv_uninit_context_t io_uninit_context; 88219019Sgabor _citrus_iconv_convert_t io_convert; 89219019Sgabor}; 90219019Sgabor 91219019Sgaborstruct _citrus_iconv_shared { 92219019Sgabor struct _citrus_iconv_ops *ci_ops; 93219019Sgabor void *ci_closure; 94219019Sgabor _CITRUS_HASH_ENTRY(_citrus_iconv_shared) ci_hash_entry; 95219019Sgabor TAILQ_ENTRY(_citrus_iconv_shared) ci_tailq_entry; 96219019Sgabor _citrus_module_t ci_module; 97219019Sgabor unsigned int ci_used_count; 98219019Sgabor char *ci_convname; 99219019Sgabor bool ci_discard_ilseq; 100219019Sgabor struct iconv_hooks *ci_hooks; 101219019Sgabor}; 102219019Sgabor 103219019Sgaborstruct _citrus_iconv { 104219019Sgabor struct _citrus_iconv_shared *cv_shared; 105219019Sgabor void *cv_closure; 106219019Sgabor}; 107219019Sgabor 108219019Sgabor#endif 109