Replace legacy make with bmake
[dragonfly.git] / lib / libc / citrus / citrus_mapper.h
... / ...
CommitLineData
1/* $NetBSD: src/lib/libc/citrus/citrus_mapper.h,v 1.3 2003/07/12 15:39:19 tshiozak Exp $ */
2/* $DragonFly: src/lib/libc/citrus/citrus_mapper.h,v 1.2 2008/04/10 10:21:01 hasso 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_H_
31#define _CITRUS_MAPPER_H_
32
33struct _citrus_mapper_area;
34struct _citrus_mapper;
35struct _citrus_mapper_ops;
36struct _citrus_mapper_traits;
37
38__BEGIN_DECLS
39int _citrus_mapper_create_area(
40 struct _citrus_mapper_area *__restrict *__restrict,
41 const char *__restrict);
42int _citrus_mapper_open(struct _citrus_mapper_area *__restrict,
43 struct _citrus_mapper *__restrict *__restrict,
44 const char *__restrict);
45int _citrus_mapper_open_direct(
46 struct _citrus_mapper_area *__restrict,
47 struct _citrus_mapper *__restrict *__restrict,
48 const char *__restrict, const char *__restrict);
49void _citrus_mapper_close(struct _citrus_mapper *);
50void _citrus_mapper_set_persistent(struct _citrus_mapper * __restrict);
51__END_DECLS
52
53#include "citrus_mapper_local.h"
54
55/* return values of _citrus_mapper_convert */
56#define _CITRUS_MAPPER_CONVERT_SUCCESS (0)
57#define _CITRUS_MAPPER_CONVERT_NONIDENTICAL (1)
58#define _CITRUS_MAPPER_CONVERT_SRC_MORE (2)
59#define _CITRUS_MAPPER_CONVERT_DST_MORE (3)
60#define _CITRUS_MAPPER_CONVERT_ILSEQ (4)
61#define _CITRUS_MAPPER_CONVERT_FATAL (5)
62
63/*
64 * _citrus_mapper_convert:
65 * convert an index.
66 * - if the converter supports M:1 converter, the function may return
67 * _CITRUS_MAPPER_CONVERT_SRC_MORE and the storage pointed by dst
68 * may be unchanged in this case, although the internal status of
69 * the mapper is affected.
70 * - if the converter supports 1:N converter, the function may return
71 * _CITRUS_MAPPER_CONVERT_DST_MORE. In this case, the contiguous
72 * call of this function ignores src and changes the storage pointed
73 * by dst.
74 * - if the converter supports M:N converter, the function may behave
75 * the combination of the above.
76 *
77 */
78static __inline int
79_citrus_mapper_convert(struct _citrus_mapper * __restrict cm,
80 _citrus_index_t * __restrict dst,
81 _citrus_index_t src,
82 void * __restrict ps)
83{
84
85 _DIAGASSERT(cm && cm->cm_ops && cm->cm_ops->mo_convert && dst);
86
87 return (*cm->cm_ops->mo_convert)(cm, dst, src, ps);
88}
89
90/*
91 * _citrus_mapper_init_state:
92 * initialize the state.
93 */
94static __inline void
95_citrus_mapper_init_state(struct _citrus_mapper * __restrict cm,
96 void * __restrict ps)
97{
98
99 _DIAGASSERT(cm && cm->cm_ops && cm->cm_ops->mo_init_state);
100
101 (*cm->cm_ops->mo_init_state)(cm, ps);
102}
103
104/*
105 * _citrus_mapper_get_state_size:
106 * get the size of state storage.
107 */
108static __inline size_t
109_citrus_mapper_get_state_size(struct _citrus_mapper * __restrict cm)
110{
111
112 _DIAGASSERT(cm && cm->cm_traits);
113
114 return cm->cm_traits->mt_state_size;
115}
116
117/*
118 * _citrus_mapper_get_src_max:
119 * get the maximum number of suspended sources.
120 */
121static __inline size_t
122_citrus_mapper_get_src_max(struct _citrus_mapper * __restrict cm)
123{
124
125 _DIAGASSERT(cm && cm->cm_traits);
126
127 return cm->cm_traits->mt_src_max;
128}
129
130/*
131 * _citrus_mapper_get_dst_max:
132 * get the maximum number of suspended destinations.
133 */
134static __inline size_t
135_citrus_mapper_get_dst_max(struct _citrus_mapper * __restrict cm)
136{
137
138 _DIAGASSERT(cm && cm->cm_traits);
139
140 return cm->cm_traits->mt_dst_max;
141}
142
143#endif