citrus_stdenc_local.h revision 1.1 1 /* $NetBSD: citrus_stdenc_local.h,v 1.1 2003/06/25 09:51:40 tshiozak Exp $ */
2
3 /*-
4 * Copyright (c)2003 Citrus Project,
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
15 *
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
26 * SUCH DAMAGE.
27 *
28 */
29
30 #ifndef _CITRUS_STDENC_LOCAL_H_
31 #define _CITRUS_STDENC_LOCAL_H_
32
33 #define _CITRUS_STDENC_GETOPS_FUNC_BASE(n) \
34 int n(struct _citrus_stdenc_ops *, size_t, u_int32_t)
35 #define _CITRUS_STDENC_GETOPS_FUNC(_e_) \
36 _CITRUS_STDENC_GETOPS_FUNC_BASE(_citrus_##_e_##_stdenc_getops)
37 typedef _CITRUS_STDENC_GETOPS_FUNC_BASE((*_citrus_stdenc_getops_t));
38
39
40 #define _CITRUS_STDENC_DECLS(_e_) \
41 static int _citrus_##_e_##_stdenc_init \
42 (struct _citrus_stdenc * __restrict, const void * __restrict, \
43 size_t, struct _citrus_stdenc_traits * __restrict); \
44 static void _citrus_##_e_##_stdenc_uninit(struct _citrus_stdenc *); \
45 static int _citrus_##_e_##_stdenc_init_state \
46 (struct _citrus_stdenc * __restrict, void * __restrict); \
47 static int _citrus_##_e_##_stdenc_mbtocs \
48 (struct _citrus_stdenc * __restrict, \
49 _citrus_csid_t * __restrict, _citrus_index_t * __restrict, \
50 const char ** __restrict, size_t, \
51 void * __restrict, size_t * __restrict); \
52 static int _citrus_##_e_##_stdenc_cstomb \
53 (struct _citrus_stdenc * __restrict, char * __restrict, \
54 size_t, _citrus_csid_t, _citrus_index_t, \
55 void * __restrict, size_t * __restrict); \
56 static int _citrus_##_e_##_stdenc_mbtowc \
57 (struct _citrus_stdenc * __restrict, \
58 _citrus_wc_t * __restrict, \
59 const char ** __restrict, size_t, \
60 void * __restrict, size_t * __restrict); \
61 static int _citrus_##_e_##_stdenc_wctomb \
62 (struct _citrus_stdenc * __restrict, char * __restrict, size_t, \
63 _citrus_wc_t, void * __restrict, size_t * __restrict)
64
65 #define _CITRUS_STDENC_DEF_OPS(_e_) \
66 struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops = { \
67 /* eo_abi_version */ _CITRUS_STDENC_ABI_VERSION, \
68 /* eo_init */ &_citrus_##_e_##_stdenc_init, \
69 /* eo_uninit */ &_citrus_##_e_##_stdenc_uninit, \
70 /* eo_init_state */ &_citrus_##_e_##_stdenc_init_state, \
71 /* eo_mbtocs */ &_citrus_##_e_##_stdenc_mbtocs, \
72 /* eo_cstomb */ &_citrus_##_e_##_stdenc_cstomb, \
73 /* eo_mbtowc */ &_citrus_##_e_##_stdenc_mbtowc, \
74 /* eo_wctomb */ &_citrus_##_e_##_stdenc_wctomb, \
75 }
76
77 typedef int (*_citrus_stdenc_init_t)
78 (struct _citrus_stdenc * __reatrict, const void * __restrict , size_t,
79 struct _citrus_stdenc_traits * __restrict);
80 typedef void (*_citrus_stdenc_uninit_t)(struct _citrus_stdenc * __restrict);
81 typedef int (*_citrus_stdenc_init_state_t)
82 (struct _citrus_stdenc * __restrict, void * __restrict);
83 typedef int (*_citrus_stdenc_mbtocs_t)
84 (struct _citrus_stdenc * __restrict,
85 _citrus_csid_t * __restrict, _citrus_index_t * __restrict,
86 const char ** __restrict, size_t,
87 void * __restrict, size_t * __restrict);
88 typedef int (*_citrus_stdenc_cstomb_t)
89 (struct _citrus_stdenc *__restrict, char * __restrict, size_t,
90 _citrus_csid_t, _citrus_index_t, void * __restrict,
91 size_t * __restrict);
92 typedef int (*_citrus_stdenc_mbtowc_t)
93 (struct _citrus_stdenc * __restrict,
94 _citrus_wc_t * __restrict,
95 const char ** __restrict, size_t,
96 void * __restrict, size_t * __restrict);
97 typedef int (*_citrus_stdenc_wctomb_t)
98 (struct _citrus_stdenc *__restrict, char * __restrict, size_t,
99 _citrus_wc_t, void * __restrict, size_t * __restrict);
100
101 /*
102 * ABI version change log
103 * 0x00000001
104 * initial version
105 */
106 #define _CITRUS_STDENC_ABI_VERSION 0x00000001
107 struct _citrus_stdenc_ops {
108 u_int32_t eo_abi_version;
109 /* version 0x00000001 */
110 _citrus_stdenc_init_t eo_init;
111 _citrus_stdenc_uninit_t eo_uninit;
112 _citrus_stdenc_init_state_t eo_init_state;
113 _citrus_stdenc_mbtocs_t eo_mbtocs;
114 _citrus_stdenc_cstomb_t eo_cstomb;
115 _citrus_stdenc_mbtowc_t eo_mbtowc;
116 _citrus_stdenc_wctomb_t eo_wctomb;
117 };
118
119 struct _citrus_stdenc_traits {
120 /* version 0x00000001 */
121 size_t et_state_size;
122 size_t et_mb_cur_max;
123 };
124
125 struct _citrus_stdenc {
126 /* public */
127 /* version 0x00000001 */
128 struct _citrus_stdenc_ops *ce_ops;
129 void *ce_closure;
130 /* private */
131 _citrus_module_t ce_module;
132 struct _citrus_stdenc_traits *ce_traits;
133 };
134
135 #define _CITRUS_DEFAULT_STDENC_NAME "NONE"
136
137 #endif
138