1 /* $NetBSD: src/lib/libc/citrus/citrus_ctype_local.h,v 1.2 2003/03/05 20:18:15 tshiozak Exp $ */
2 /* $DragonFly: src/lib/libc/citrus/citrus_ctype_local.h,v 1.1 2005/03/11 23:33:53 joerg Exp $ */
6 * Copyright (c)2002 Citrus Project,
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #ifndef _CITRUS_CTYPE_LOCAL_H_
33 #define _CITRUS_CTYPE_LOCAL_H_
35 #define _CITRUS_CTYPE_GETOPS_FUNC_BASE(_n_) \
36 int _n_(_citrus_ctype_ops_rec_t *, size_t, uint32_t)
37 #define _CITRUS_CTYPE_GETOPS_FUNC(_n_) \
38 _CITRUS_CTYPE_GETOPS_FUNC_BASE(_citrus_##_n_##_ctype_getops)
40 #define _CITRUS_CTYPE_DECLS(_e_) \
41 static int _citrus_##_e_##_ctype_init \
42 (void ** __restrict, void * __restrict, size_t, size_t); \
43 static void _citrus_##_e_##_ctype_uninit(void *); \
44 static unsigned _citrus_##_e_##_ctype_get_mb_cur_max(void *); \
45 static int _citrus_##_e_##_ctype_mblen(void * __restrict, \
46 const char * __restrict, \
47 size_t, int * __restrict); \
48 static int _citrus_##_e_##_ctype_mbrlen(void * __restrict, \
49 const char * __restrict, \
50 size_t, void * __restrict, \
51 size_t * __restrict); \
52 static int _citrus_##_e_##_ctype_mbrtowc(void * __restrict, \
53 wchar_t * __restrict, \
54 const char * __restrict, size_t, \
56 size_t * __restrict); \
57 static int _citrus_##_e_##_ctype_mbsinit(void * __restrict, \
58 void const * __restrict, \
60 static int _citrus_##_e_##_ctype_mbsrtowcs(void * __restrict, \
61 wchar_t * __restrict, \
62 const char ** __restrict, \
63 size_t, void * __restrict, \
64 size_t * __restrict); \
65 static int _citrus_##_e_##_ctype_mbstowcs(void * __restrict, \
66 wchar_t * __restrict, \
67 const char * __restrict, \
68 size_t, size_t * __restrict); \
69 static int _citrus_##_e_##_ctype_mbtowc(void * __restrict, \
70 wchar_t * __restrict, \
71 const char * __restrict, \
72 size_t, int * __restrict); \
73 static int _citrus_##_e_##_ctype_wcrtomb(void * __restrict, \
74 char * __restrict, wchar_t, \
76 size_t * __restrict); \
77 static int _citrus_##_e_##_ctype_wcsrtombs(void * __restrict, \
79 const wchar_t ** __restrict, \
80 size_t, void * __restrict, \
81 size_t * __restrict); \
82 static int _citrus_##_e_##_ctype_wcstombs(void * __restrict, \
84 const wchar_t * __restrict, \
85 size_t, size_t * __restrict); \
86 static int _citrus_##_e_##_ctype_wctomb(void * __restrict, \
88 wchar_t, int * __restrict); \
89 static int _citrus_##_e_##_ctype_btowc(_citrus_ctype_rec_t * __restrict, \
90 int, wint_t * __restrict); \
91 static int _citrus_##_e_##_ctype_wctob(_citrus_ctype_rec_t * __restrict, \
92 wint_t, int * __restrict)
94 #define _CITRUS_CTYPE_DEF_OPS(_e_) \
95 _citrus_ctype_ops_rec_t _citrus_##_e_##_ctype_ops = { \
96 /* co_abi_version */ _CITRUS_CTYPE_ABI_VERSION, \
97 /* co_init */ &_citrus_##_e_##_ctype_init, \
98 /* co_uninit */ &_citrus_##_e_##_ctype_uninit, \
99 /* co_get_mb_cur_max */ &_citrus_##_e_##_ctype_get_mb_cur_max, \
100 /* co_mblen */ &_citrus_##_e_##_ctype_mblen, \
101 /* co_mbrlen */ &_citrus_##_e_##_ctype_mbrlen, \
102 /* co_mbrtowc */ &_citrus_##_e_##_ctype_mbrtowc, \
103 /* co_mbsinit */ &_citrus_##_e_##_ctype_mbsinit, \
104 /* co_mbsrtowcs */ &_citrus_##_e_##_ctype_mbsrtowcs, \
105 /* co_mbstowcs */ &_citrus_##_e_##_ctype_mbstowcs, \
106 /* co_mbtowc */ &_citrus_##_e_##_ctype_mbtowc, \
107 /* co_wcrtomb */ &_citrus_##_e_##_ctype_wcrtomb, \
108 /* co_wcsrtombs */ &_citrus_##_e_##_ctype_wcsrtombs, \
109 /* co_wcstombs */ &_citrus_##_e_##_ctype_wcstombs, \
110 /* co_wctomb */ &_citrus_##_e_##_ctype_wctomb, \
111 /* co_btowc */ &_citrus_##_e_##_ctype_btowc, \
112 /* co_wctob */ &_citrus_##_e_##_ctype_wctob \
115 typedef struct _citrus_ctype_ops_rec _citrus_ctype_ops_rec_t;
116 typedef struct _citrus_ctype_rec _citrus_ctype_rec_t;
118 typedef int (*_citrus_ctype_init_t)
119 (void ** __restrict, void * __restrict, size_t, size_t);
120 typedef void (*_citrus_ctype_uninit_t)(void *);
121 typedef unsigned (*_citrus_ctype_get_mb_cur_max_t)(void *);
122 typedef int (*_citrus_ctype_mblen_t)
123 (void * __restrict, const char * __restrict, size_t, int * __restrict);
124 typedef int (*_citrus_ctype_mbrlen_t)
125 (void * __restrict, const char * __restrict, size_t,
126 void * __restrict, size_t * __restrict);
127 typedef int (*_citrus_ctype_mbrtowc_t)
128 (void * __restrict, wchar_t * __restrict, const char * __restrict,
129 size_t, void * __restrict, size_t * __restrict);
130 typedef int (*_citrus_ctype_mbsinit_t)
131 (void * __restrict, const void * __restrict, int * __restrict);
132 typedef int (*_citrus_ctype_mbsrtowcs_t)
133 (void * __restrict, wchar_t * __restrict, const char ** __restrict,
134 size_t, void * __restrict,
135 size_t * __restrict);
136 typedef int (*_citrus_ctype_mbstowcs_t)
137 (void * __restrict, wchar_t * __restrict, const char * __restrict,
138 size_t, size_t * __restrict);
139 typedef int (*_citrus_ctype_mbtowc_t)
140 (void * __restrict, wchar_t * __restrict, const char * __restrict,
141 size_t, int * __restrict);
142 typedef int (*_citrus_ctype_wcrtomb_t)
143 (void * __restrict, char * __restrict, wchar_t, void * __restrict,
144 size_t * __restrict);
145 typedef int (*_citrus_ctype_wcsrtombs_t)
146 (void * __restrict, char * __restrict, const wchar_t ** __restrict,
147 size_t, void * __restrict, size_t * __restrict);
148 typedef int (*_citrus_ctype_wcstombs_t)
149 (void * __restrict, char * __restrict, const wchar_t * __restrict,
150 size_t, size_t * __restrict);
151 typedef int (*_citrus_ctype_wctomb_t)
152 (void * __restrict, char * __restrict, wchar_t, int * __restrict);
153 typedef int (*_citrus_ctype_btowc_t)
154 (_citrus_ctype_rec_t * __restrict, int, wint_t * __restrict);
155 typedef int (*_citrus_ctype_wctob_t)
156 (_citrus_ctype_rec_t * __restrict, wint_t, int * __restrict);
159 * ABI Version change log:
163 * ops record: btowc and wctob are added.
164 * ctype record: unchanged.
166 #define _CITRUS_CTYPE_ABI_VERSION 0x00000002
167 struct _citrus_ctype_ops_rec {
168 uint32_t co_abi_version;
169 /* version 0x00000001 */
170 _citrus_ctype_init_t co_init;
171 _citrus_ctype_uninit_t co_uninit;
172 _citrus_ctype_get_mb_cur_max_t co_get_mb_cur_max;
173 _citrus_ctype_mblen_t co_mblen;
174 _citrus_ctype_mbrlen_t co_mbrlen;
175 _citrus_ctype_mbrtowc_t co_mbrtowc;
176 _citrus_ctype_mbsinit_t co_mbsinit;
177 _citrus_ctype_mbsrtowcs_t co_mbsrtowcs;
178 _citrus_ctype_mbstowcs_t co_mbstowcs;
179 _citrus_ctype_mbtowc_t co_mbtowc;
180 _citrus_ctype_wcrtomb_t co_wcrtomb;
181 _citrus_ctype_wcsrtombs_t co_wcsrtombs;
182 _citrus_ctype_wcstombs_t co_wcstombs;
183 _citrus_ctype_wctomb_t co_wctomb;
184 /* version 0x00000002 */
185 _citrus_ctype_btowc_t co_btowc;
186 _citrus_ctype_wctob_t co_wctob;
189 #define _CITRUS_DEFAULT_CTYPE_NAME "NONE"
190 #define _CITRUS_DEFAULT_CTYPE_OPS _citrus_NONE_ctype_ops
191 #define _CITRUS_DEFAULT_CTYPE_HEADER "citrus_none.h"
193 typedef _CITRUS_CTYPE_GETOPS_FUNC_BASE((*_citrus_ctype_getops_t));
194 struct _citrus_ctype_rec {
195 _citrus_ctype_ops_rec_t *cc_ops;
197 _citrus_module_t cc_module;