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