citrus_iconv_local.h revision 282275
1219019Sgabor/* $FreeBSD: stable/10/lib/libc/iconv/citrus_iconv_local.h 282275 2015-04-30 16:08:47Z tijl $ */ 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> 34255297Stheraven#include <stdbool.h> 35219019Sgabor 36219019Sgabor#define _CITRUS_ICONV_GETOPS_FUNC_BASE(_n_) \ 37219019Sgabor int _n_(struct _citrus_iconv_ops *) 38219019Sgabor#define _CITRUS_ICONV_GETOPS_FUNC(_n_) \ 39219019Sgabor _CITRUS_ICONV_GETOPS_FUNC_BASE(_citrus_##_n_##_iconv_getops) 40219019Sgabor 41219019Sgabor#define _CITRUS_ICONV_DECLS(_m_) \ 42219019Sgaborstatic int _citrus_##_m_##_iconv_init_shared \ 43219019Sgabor (struct _citrus_iconv_shared * __restrict, \ 44219019Sgabor const char * __restrict, const char * __restrict); \ 45219019Sgaborstatic void _citrus_##_m_##_iconv_uninit_shared \ 46219019Sgabor (struct _citrus_iconv_shared *); \ 47219019Sgaborstatic int _citrus_##_m_##_iconv_convert \ 48219019Sgabor (struct _citrus_iconv * __restrict, \ 49282275Stijl char * __restrict * __restrict, \ 50219019Sgabor size_t * __restrict, \ 51219019Sgabor char * __restrict * __restrict, \ 52219019Sgabor size_t * __restrict outbytes, \ 53219019Sgabor uint32_t, size_t * __restrict); \ 54219019Sgaborstatic int _citrus_##_m_##_iconv_init_context \ 55219019Sgabor (struct _citrus_iconv *); \ 56219019Sgaborstatic void _citrus_##_m_##_iconv_uninit_context \ 57219019Sgabor (struct _citrus_iconv *) 58219019Sgabor 59219019Sgabor 60219019Sgabor#define _CITRUS_ICONV_DEF_OPS(_m_) \ 61250938Sedextern struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops; \ 62219019Sgaborstruct _citrus_iconv_ops _citrus_##_m_##_iconv_ops = { \ 63219019Sgabor /* io_init_shared */ &_citrus_##_m_##_iconv_init_shared, \ 64219019Sgabor /* io_uninit_shared */ &_citrus_##_m_##_iconv_uninit_shared, \ 65219019Sgabor /* io_init_context */ &_citrus_##_m_##_iconv_init_context, \ 66219019Sgabor /* io_uninit_context */ &_citrus_##_m_##_iconv_uninit_context, \ 67219019Sgabor /* io_convert */ &_citrus_##_m_##_iconv_convert \ 68219019Sgabor} 69219019Sgabor 70219019Sgabortypedef _CITRUS_ICONV_GETOPS_FUNC_BASE((*_citrus_iconv_getops_t)); 71219019Sgabortypedef int (*_citrus_iconv_init_shared_t) 72219019Sgabor (struct _citrus_iconv_shared * __restrict, 73219019Sgabor const char * __restrict, const char * __restrict); 74219019Sgabortypedef void (*_citrus_iconv_uninit_shared_t) 75219019Sgabor (struct _citrus_iconv_shared *); 76219019Sgabortypedef int (*_citrus_iconv_convert_t) 77219019Sgabor (struct _citrus_iconv * __restrict, 78282275Stijl char *__restrict* __restrict, size_t * __restrict, 79219019Sgabor char * __restrict * __restrict, size_t * __restrict, uint32_t, 80219019Sgabor size_t * __restrict); 81219019Sgabortypedef int (*_citrus_iconv_init_context_t)(struct _citrus_iconv *); 82219019Sgabortypedef void (*_citrus_iconv_uninit_context_t)(struct _citrus_iconv *); 83219019Sgabor 84219019Sgaborstruct _citrus_iconv_ops { 85219019Sgabor _citrus_iconv_init_shared_t io_init_shared; 86219019Sgabor _citrus_iconv_uninit_shared_t io_uninit_shared; 87219019Sgabor _citrus_iconv_init_context_t io_init_context; 88219019Sgabor _citrus_iconv_uninit_context_t io_uninit_context; 89219019Sgabor _citrus_iconv_convert_t io_convert; 90219019Sgabor}; 91219019Sgabor 92219019Sgaborstruct _citrus_iconv_shared { 93219019Sgabor struct _citrus_iconv_ops *ci_ops; 94219019Sgabor void *ci_closure; 95219019Sgabor _CITRUS_HASH_ENTRY(_citrus_iconv_shared) ci_hash_entry; 96219019Sgabor TAILQ_ENTRY(_citrus_iconv_shared) ci_tailq_entry; 97219019Sgabor _citrus_module_t ci_module; 98219019Sgabor unsigned int ci_used_count; 99219019Sgabor char *ci_convname; 100219019Sgabor bool ci_discard_ilseq; 101219019Sgabor struct iconv_hooks *ci_hooks; 102258750Sgjb bool ci_ilseq_invalid; 103219019Sgabor}; 104219019Sgabor 105219019Sgaborstruct _citrus_iconv { 106219019Sgabor struct _citrus_iconv_shared *cv_shared; 107219019Sgabor void *cv_closure; 108219019Sgabor}; 109219019Sgabor 110219019Sgabor#endif 111