Allow inclusion of Citrus modules in statically linked binaries.
[dragonfly.git] / lib / libc / citrus / citrus_ctype_local.h
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.2 2005/07/04 08:02:43 joerg Exp $ */
3
4
5 /*-
6  * Copyright (c)2002 Citrus Project,
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
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.
17  *
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
28  * SUCH DAMAGE.
29  *
30  */
31
32 #ifndef _CITRUS_CTYPE_LOCAL_H_
33 #define _CITRUS_CTYPE_LOCAL_H_
34
35 #include "citrus_module.h"
36
37 #define _CITRUS_CTYPE_GETOPS_FUNC_BASE(_n_)                             \
38 int _n_(_citrus_ctype_ops_rec_t *, size_t, uint32_t)
39 #define _CITRUS_CTYPE_GETOPS_FUNC(_n_)                                  \
40 _CITRUS_CTYPE_GETOPS_FUNC_BASE(_citrus_##_n_##_ctype_getops)
41
42 #define _CITRUS_CTYPE_DECLS(_e_)                                              \
43 static int      _citrus_##_e_##_ctype_init                                    \
44         (void ** __restrict, void * __restrict, size_t, size_t);              \
45 static void     _citrus_##_e_##_ctype_uninit(void *);                         \
46 static unsigned _citrus_##_e_##_ctype_get_mb_cur_max(void *);                 \
47 static int      _citrus_##_e_##_ctype_mblen(void * __restrict,                \
48                                      const char * __restrict,                 \
49                                      size_t, int * __restrict);               \
50 static int      _citrus_##_e_##_ctype_mbrlen(void * __restrict,               \
51                                       const char * __restrict,                \
52                                       size_t, void * __restrict,              \
53                                       size_t * __restrict);                   \
54 static int      _citrus_##_e_##_ctype_mbrtowc(void * __restrict,              \
55                                        wchar_t * __restrict,                  \
56                                        const char * __restrict, size_t,       \
57                                        void * __restrict,                     \
58                                        size_t * __restrict);                  \
59 static int      _citrus_##_e_##_ctype_mbsinit(void * __restrict,              \
60                                        void const * __restrict,               \
61                                        int * __restrict);                     \
62 static int      _citrus_##_e_##_ctype_mbsrtowcs(void * __restrict,            \
63                                          wchar_t * __restrict,                \
64                                          const char ** __restrict,            \
65                                          size_t, void * __restrict,           \
66                                          size_t * __restrict);                \
67 static int      _citrus_##_e_##_ctype_mbstowcs(void * __restrict,             \
68                                         wchar_t * __restrict,                 \
69                                         const char * __restrict,              \
70                                         size_t, size_t * __restrict);         \
71 static int      _citrus_##_e_##_ctype_mbtowc(void * __restrict,               \
72                                       wchar_t * __restrict,                   \
73                                       const char * __restrict,                \
74                                       size_t, int * __restrict);              \
75 static int      _citrus_##_e_##_ctype_wcrtomb(void * __restrict,              \
76                                        char * __restrict, wchar_t,            \
77                                        void * __restrict,                     \
78                                        size_t * __restrict);                  \
79 static int      _citrus_##_e_##_ctype_wcsrtombs(void * __restrict,            \
80                                          char * __restrict,                   \
81                                          const wchar_t ** __restrict,         \
82                                          size_t, void * __restrict,           \
83                                          size_t * __restrict);                \
84 static int      _citrus_##_e_##_ctype_wcstombs(void * __restrict,             \
85                                         char * __restrict,                    \
86                                         const wchar_t * __restrict,           \
87                                         size_t, size_t * __restrict);         \
88 static int      _citrus_##_e_##_ctype_wctomb(void * __restrict,               \
89                                       char * __restrict,                      \
90                                       wchar_t, int * __restrict);             \
91 static int      _citrus_##_e_##_ctype_btowc(_citrus_ctype_rec_t * __restrict, \
92                                       int, wint_t * __restrict);              \
93 static int      _citrus_##_e_##_ctype_wctob(_citrus_ctype_rec_t * __restrict, \
94                                       wint_t, int * __restrict);              \
95 CITRUS_MODULE(_e_, ctype, _citrus_##_e_##_ctype_getops)
96
97 #define _CITRUS_CTYPE_DEF_OPS(_e_)                                      \
98 _citrus_ctype_ops_rec_t _citrus_##_e_##_ctype_ops = {                   \
99         /* co_abi_version */    _CITRUS_CTYPE_ABI_VERSION,              \
100         /* co_init */           &_citrus_##_e_##_ctype_init,            \
101         /* co_uninit */         &_citrus_##_e_##_ctype_uninit,          \
102         /* co_get_mb_cur_max */ &_citrus_##_e_##_ctype_get_mb_cur_max,  \
103         /* co_mblen */          &_citrus_##_e_##_ctype_mblen,           \
104         /* co_mbrlen */         &_citrus_##_e_##_ctype_mbrlen,          \
105         /* co_mbrtowc */        &_citrus_##_e_##_ctype_mbrtowc,         \
106         /* co_mbsinit */        &_citrus_##_e_##_ctype_mbsinit,         \
107         /* co_mbsrtowcs */      &_citrus_##_e_##_ctype_mbsrtowcs,       \
108         /* co_mbstowcs */       &_citrus_##_e_##_ctype_mbstowcs,        \
109         /* co_mbtowc */         &_citrus_##_e_##_ctype_mbtowc,          \
110         /* co_wcrtomb */        &_citrus_##_e_##_ctype_wcrtomb,         \
111         /* co_wcsrtombs */      &_citrus_##_e_##_ctype_wcsrtombs,       \
112         /* co_wcstombs */       &_citrus_##_e_##_ctype_wcstombs,        \
113         /* co_wctomb */         &_citrus_##_e_##_ctype_wctomb,          \
114         /* co_btowc */          &_citrus_##_e_##_ctype_btowc,           \
115         /* co_wctob */          &_citrus_##_e_##_ctype_wctob            \
116 }
117
118 typedef struct _citrus_ctype_ops_rec    _citrus_ctype_ops_rec_t;
119 typedef struct _citrus_ctype_rec        _citrus_ctype_rec_t;
120
121 typedef int     (*_citrus_ctype_init_t)
122         (void ** __restrict, void * __restrict, size_t, size_t);
123 typedef void    (*_citrus_ctype_uninit_t)(void *);
124 typedef unsigned (*_citrus_ctype_get_mb_cur_max_t)(void *);
125 typedef int     (*_citrus_ctype_mblen_t)
126         (void * __restrict, const char * __restrict, size_t, int * __restrict);
127 typedef int     (*_citrus_ctype_mbrlen_t)
128         (void * __restrict, const char * __restrict, size_t,
129          void * __restrict, size_t * __restrict);
130 typedef int     (*_citrus_ctype_mbrtowc_t)
131         (void * __restrict, wchar_t * __restrict, const char * __restrict,
132          size_t, void * __restrict, size_t * __restrict);
133 typedef int     (*_citrus_ctype_mbsinit_t)
134         (void * __restrict, const void * __restrict, int * __restrict);
135 typedef int     (*_citrus_ctype_mbsrtowcs_t)
136         (void * __restrict, wchar_t * __restrict, const char ** __restrict,
137          size_t, void * __restrict,
138          size_t * __restrict);
139 typedef int     (*_citrus_ctype_mbstowcs_t)
140         (void * __restrict, wchar_t * __restrict, const char * __restrict,
141          size_t, size_t * __restrict);
142 typedef int     (*_citrus_ctype_mbtowc_t)
143         (void * __restrict, wchar_t * __restrict, const char * __restrict,
144          size_t, int * __restrict);
145 typedef int     (*_citrus_ctype_wcrtomb_t)
146         (void * __restrict, char * __restrict, wchar_t, void * __restrict,
147          size_t * __restrict);
148 typedef int     (*_citrus_ctype_wcsrtombs_t)
149         (void * __restrict, char * __restrict, const wchar_t ** __restrict,
150          size_t, void * __restrict, size_t * __restrict);
151 typedef int     (*_citrus_ctype_wcstombs_t)
152         (void * __restrict, char * __restrict, const wchar_t * __restrict,
153          size_t, size_t * __restrict);
154 typedef int     (*_citrus_ctype_wctomb_t)
155         (void * __restrict, char * __restrict, wchar_t, int * __restrict);
156 typedef int     (*_citrus_ctype_btowc_t)
157         (_citrus_ctype_rec_t * __restrict, int, wint_t * __restrict);
158 typedef int     (*_citrus_ctype_wctob_t)
159         (_citrus_ctype_rec_t * __restrict, wint_t, int * __restrict);
160
161 /*
162  * ABI Version change log:
163  *   0x00000001
164  *     initial version
165  *   0x00000002
166  *     ops record:      btowc and wctob are added.
167  *     ctype record:    unchanged.
168  */
169 #define _CITRUS_CTYPE_ABI_VERSION       0x00000002
170 struct _citrus_ctype_ops_rec {
171         uint32_t                        co_abi_version;
172         /* version 0x00000001 */
173         _citrus_ctype_init_t            co_init;
174         _citrus_ctype_uninit_t          co_uninit;
175         _citrus_ctype_get_mb_cur_max_t  co_get_mb_cur_max;
176         _citrus_ctype_mblen_t           co_mblen;
177         _citrus_ctype_mbrlen_t          co_mbrlen;
178         _citrus_ctype_mbrtowc_t         co_mbrtowc;
179         _citrus_ctype_mbsinit_t         co_mbsinit;
180         _citrus_ctype_mbsrtowcs_t       co_mbsrtowcs;
181         _citrus_ctype_mbstowcs_t        co_mbstowcs;
182         _citrus_ctype_mbtowc_t          co_mbtowc;
183         _citrus_ctype_wcrtomb_t         co_wcrtomb;
184         _citrus_ctype_wcsrtombs_t       co_wcsrtombs;
185         _citrus_ctype_wcstombs_t        co_wcstombs;
186         _citrus_ctype_wctomb_t          co_wctomb;
187         /* version 0x00000002 */
188         _citrus_ctype_btowc_t           co_btowc;
189         _citrus_ctype_wctob_t           co_wctob;
190 };
191
192 #define _CITRUS_DEFAULT_CTYPE_NAME      "NONE"
193 #define _CITRUS_DEFAULT_CTYPE_OPS       _citrus_NONE_ctype_ops
194 #define _CITRUS_DEFAULT_CTYPE_HEADER    "citrus_none.h"
195
196 typedef _CITRUS_CTYPE_GETOPS_FUNC_BASE((*_citrus_ctype_getops_t));
197 struct _citrus_ctype_rec {
198         _citrus_ctype_ops_rec_t *cc_ops;
199         void                    *cc_closure;
200         _citrus_module_t        cc_module;
201 };
202
203 #endif