Add citrus backend code and iconv front end. This is intentionally
[dragonfly.git] / lib / libc / citrus / citrus_mapper_local.h
1 /*      $NetBSD: src/lib/libc/citrus/citrus_mapper_local.h,v 1.1 2003/06/25 09:51:36 tshiozak Exp $     */
2 /*      $DragonFly: src/lib/libc/citrus/citrus_mapper_local.h,v 1.1 2005/03/11 23:33:53 joerg Exp $ */
3
4 /*-
5  * Copyright (c)2003 Citrus Project,
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29
30 #ifndef _CITRUS_MAPPER_LOCAL_H_
31 #define _CITRUS_MAPPER_LOCAL_H_
32
33 #define _CITRUS_MAPPER_GETOPS_FUNC_BASE(_n_)                            \
34 int _n_(struct _citrus_mapper_ops *, size_t, u_int32_t)
35 #define _CITRUS_MAPPER_GETOPS_FUNC(_n_)                                 \
36 _CITRUS_MAPPER_GETOPS_FUNC_BASE(_citrus_##_n_##_mapper_getops)
37
38 #define _CITRUS_MAPPER_DECLS(_m_)                                       \
39 static int      _citrus_##_m_##_mapper_init                             \
40         (struct _citrus_mapper_area *__restrict,                        \
41          struct _citrus_mapper * __restrict, const char * __restrict,   \
42          const void * __restrict, size_t,                               \
43          struct _citrus_mapper_traits * __restrict, size_t);            \
44 static void     _citrus_##_m_##_mapper_uninit(struct _citrus_mapper *); \
45 static int      _citrus_##_m_##_mapper_convert                          \
46         (struct _citrus_mapper * __restrict,                            \
47          _citrus_index_t * __restrict, _citrus_index_t,                 \
48          void * __restrict);                                            \
49 static void     _citrus_##_m_##_mapper_init_state                       \
50         (struct _citrus_mapper * __restrict, void * __restrict);
51
52 #define _CITRUS_MAPPER_DEF_OPS(_m_)                                     \
53 struct _citrus_mapper_ops _citrus_##_m_##_mapper_ops = {                \
54         /* mo_abi_version */    _CITRUS_MAPPER_ABI_VERSION,             \
55         /* mo_init */           &_citrus_##_m_##_mapper_init,           \
56         /* mo_uninit */         &_citrus_##_m_##_mapper_uninit,         \
57         /* mo_convert */        &_citrus_##_m_##_mapper_convert,        \
58         /* mo_init_state */     &_citrus_##_m_##_mapper_init_state      \
59 }
60
61 typedef _CITRUS_MAPPER_GETOPS_FUNC_BASE((*_citrus_mapper_getops_t));
62 typedef int     (*_citrus_mapper_init_t)(
63         struct _citrus_mapper_area *__restrict,
64         struct _citrus_mapper *__restrict, const char *__restrict,
65         const void *__restrict, size_t,
66         struct _citrus_mapper_traits * __restrict, size_t);
67 typedef void    (*_citrus_mapper_uninit_t)(struct _citrus_mapper *);
68 typedef int     (*_citrus_mapper_convert_t)(struct _citrus_mapper * __restrict,
69                                             _citrus_index_t * __restrict,
70                                             _citrus_index_t,
71                                             void * __restrict);
72 typedef void    (*_citrus_mapper_init_state_t)(
73         struct _citrus_mapper * __restrict, void * __restrict);
74
75 /*
76  * ABI version change log
77  *   0x00000001
78  *     initial version
79  */
80 #define _CITRUS_MAPPER_ABI_VERSION      0x00000001
81 struct _citrus_mapper_ops {
82         uint32_t                        mo_abi_version;
83         /* version 0x00000001 */
84         _citrus_mapper_init_t           mo_init;
85         _citrus_mapper_uninit_t         mo_uninit;
86         _citrus_mapper_convert_t        mo_convert;
87         _citrus_mapper_init_state_t     mo_init_state;
88 };
89
90 struct _citrus_mapper_traits {
91         /* version 0x00000001 */
92         size_t                          mt_state_size;
93         size_t                          mt_src_max;
94         size_t                          mt_dst_max;
95 };
96
97 struct _citrus_mapper {
98         struct _citrus_mapper_ops               *cm_ops;
99         void                                    *cm_closure;
100         _citrus_module_t                        cm_module;
101         struct _citrus_mapper_traits            *cm_traits;
102         _CITRUS_HASH_ENTRY(_citrus_mapper)      cm_entry;
103         int                                     cm_refcount;
104         char                                    *cm_key;
105 };
106 #endif