citrus_iconv_local.h revision 219019
1219019Sgabor/* $FreeBSD: head/lib/libc/iconv/citrus_iconv_local.h 219019 2011-02-25 00:04:39Z gabor $ */ 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_) \ 60219019Sgaborstruct _citrus_iconv_ops _citrus_##_m_##_iconv_ops = { \ 61219019Sgabor /* io_init_shared */ &_citrus_##_m_##_iconv_init_shared, \ 62219019Sgabor /* io_uninit_shared */ &_citrus_##_m_##_iconv_uninit_shared, \ 63219019Sgabor /* io_init_context */ &_citrus_##_m_##_iconv_init_context, \ 64219019Sgabor /* io_uninit_context */ &_citrus_##_m_##_iconv_uninit_context, \ 65219019Sgabor /* io_convert */ &_citrus_##_m_##_iconv_convert \ 66219019Sgabor} 67219019Sgabor 68219019Sgabortypedef _CITRUS_ICONV_GETOPS_FUNC_BASE((*_citrus_iconv_getops_t)); 69219019Sgabortypedef int (*_citrus_iconv_init_shared_t) 70219019Sgabor (struct _citrus_iconv_shared * __restrict, 71219019Sgabor const char * __restrict, const char * __restrict); 72219019Sgabortypedef void (*_citrus_iconv_uninit_shared_t) 73219019Sgabor (struct _citrus_iconv_shared *); 74219019Sgabortypedef int (*_citrus_iconv_convert_t) 75219019Sgabor (struct _citrus_iconv * __restrict, 76219019Sgabor char *__restrict* __restrict, size_t * __restrict, 77219019Sgabor char * __restrict * __restrict, size_t * __restrict, uint32_t, 78219019Sgabor size_t * __restrict); 79219019Sgabortypedef int (*_citrus_iconv_init_context_t)(struct _citrus_iconv *); 80219019Sgabortypedef void (*_citrus_iconv_uninit_context_t)(struct _citrus_iconv *); 81219019Sgabor 82219019Sgaborstruct _citrus_iconv_ops { 83219019Sgabor _citrus_iconv_init_shared_t io_init_shared; 84219019Sgabor _citrus_iconv_uninit_shared_t io_uninit_shared; 85219019Sgabor _citrus_iconv_init_context_t io_init_context; 86219019Sgabor _citrus_iconv_uninit_context_t io_uninit_context; 87219019Sgabor _citrus_iconv_convert_t io_convert; 88219019Sgabor}; 89219019Sgabor 90219019Sgaborstruct _citrus_iconv_shared { 91219019Sgabor struct _citrus_iconv_ops *ci_ops; 92219019Sgabor void *ci_closure; 93219019Sgabor _CITRUS_HASH_ENTRY(_citrus_iconv_shared) ci_hash_entry; 94219019Sgabor TAILQ_ENTRY(_citrus_iconv_shared) ci_tailq_entry; 95219019Sgabor _citrus_module_t ci_module; 96219019Sgabor unsigned int ci_used_count; 97219019Sgabor char *ci_convname; 98219019Sgabor bool ci_discard_ilseq; 99219019Sgabor struct iconv_hooks *ci_hooks; 100219019Sgabor}; 101219019Sgabor 102219019Sgaborstruct _citrus_iconv { 103219019Sgabor struct _citrus_iconv_shared *cv_shared; 104219019Sgabor void *cv_closure; 105219019Sgabor}; 106219019Sgabor 107219019Sgabor#endif 108