1 /* $NetBSD: citrus_iconv_local.h,v 1.2 2003/07/01 09:42:16 tshiozak Exp $ */
4 * Copyright (c)2003 Citrus Project,
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef _CITRUS_ICONV_LOCAL_H_
30 #define _CITRUS_ICONV_LOCAL_H_
32 #define _CITRUS_ICONV_GETOPS_FUNC_BASE(_n_) \
33 int _n_(struct _citrus_iconv_ops *, size_t, uint32_t)
34 #define _CITRUS_ICONV_GETOPS_FUNC(_n_) \
35 _CITRUS_ICONV_GETOPS_FUNC_BASE(_citrus_##_n_##_iconv_getops)
37 #define _CITRUS_ICONV_DECLS(_m_) \
38 static int _citrus_##_m_##_iconv_init_shared \
39 (struct _citrus_iconv_shared * __restrict, \
40 const char * __restrict, \
41 const char * __restrict, const char * __restrict, \
42 const void * __restrict, size_t); \
43 static void _citrus_##_m_##_iconv_uninit_shared \
44 (struct _citrus_iconv_shared *); \
45 static int _citrus_##_m_##_iconv_convert \
46 (struct _citrus_iconv * __restrict, \
47 const char * __restrict * __restrict, size_t * __restrict, \
48 char * __restrict * __restrict, size_t * __restrict outbytes, \
49 uint32_t, size_t * __restrict); \
50 static int _citrus_##_m_##_iconv_init_context \
51 (struct _citrus_iconv *); \
52 static void _citrus_##_m_##_iconv_uninit_context \
53 (struct _citrus_iconv *)
56 #define _CITRUS_ICONV_DEF_OPS(_m_) \
57 struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops = { \
58 /* io_abi_version */ _CITRUS_ICONV_ABI_VERSION, \
59 /* io_init_shared */ &_citrus_##_m_##_iconv_init_shared, \
60 /* io_uninit_shared */ &_citrus_##_m_##_iconv_uninit_shared, \
61 /* io_init_context */ &_citrus_##_m_##_iconv_init_context, \
62 /* io_uninit_context */ &_citrus_##_m_##_iconv_uninit_context, \
63 /* io_convert */ &_citrus_##_m_##_iconv_convert \
66 typedef _CITRUS_ICONV_GETOPS_FUNC_BASE((*_citrus_iconv_getops_t
));
67 typedef int (*_citrus_iconv_init_shared_t
)
68 (struct _citrus_iconv_shared
* __restrict
,
69 const char * __restrict
, const char * __restrict
,
70 const char * __restrict
, const void * __restrict
, size_t);
71 typedef void (*_citrus_iconv_uninit_shared_t
)
72 (struct _citrus_iconv_shared
*);
73 typedef int (*_citrus_iconv_convert_t
)
74 (struct _citrus_iconv
* __restrict
,
75 const char *__restrict
* __restrict
, size_t * __restrict
,
76 char * __restrict
* __restrict
, size_t * __restrict
, uint32_t,
78 typedef int (*_citrus_iconv_init_context_t
)(struct _citrus_iconv
*);
79 typedef void (*_citrus_iconv_uninit_context_t
)(struct _citrus_iconv
*);
81 struct _citrus_iconv_ops
{
82 uint32_t io_abi_version
;
83 _citrus_iconv_init_shared_t io_init_shared
;
84 _citrus_iconv_uninit_shared_t io_uninit_shared
;
85 _citrus_iconv_init_context_t io_init_context
;
86 _citrus_iconv_uninit_context_t io_uninit_context
;
87 _citrus_iconv_convert_t io_convert
;
89 #define _CITRUS_ICONV_ABI_VERSION 2
91 struct _citrus_iconv_shared
{
92 struct _citrus_iconv_ops
*ci_ops
;
95 _CITRUS_HASH_ENTRY(_citrus_iconv_shared
) ci_hash_entry
;
96 TAILQ_ENTRY(_citrus_iconv_shared
) ci_tailq_entry
;
97 _citrus_module_t ci_module
;
98 unsigned int ci_used_count
;
102 struct _citrus_iconv
{
103 struct _citrus_iconv_shared
*cv_shared
;