2 /* $NetBSD: citrus_mapper.h,v 1.3 2003/07/12 15:39:19 tshiozak Exp $ */
5 * SPDX-License-Identifier: BSD-2-Clause
7 * Copyright (c)2003 Citrus Project,
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #ifndef _CITRUS_MAPPER_H_
33 #define _CITRUS_MAPPER_H_
35 struct _citrus_mapper_area;
36 struct _citrus_mapper;
37 struct _citrus_mapper_ops;
38 struct _citrus_mapper_traits;
41 int _citrus_mapper_create_area(
42 struct _citrus_mapper_area *__restrict *__restrict,
43 const char *__restrict);
44 int _citrus_mapper_open(struct _citrus_mapper_area *__restrict,
45 struct _citrus_mapper *__restrict *__restrict,
46 const char *__restrict);
47 int _citrus_mapper_open_direct(
48 struct _citrus_mapper_area *__restrict,
49 struct _citrus_mapper *__restrict *__restrict,
50 const char *__restrict, const char *__restrict);
51 void _citrus_mapper_close(struct _citrus_mapper *);
52 void _citrus_mapper_set_persistent(struct _citrus_mapper * __restrict);
55 #include "citrus_mapper_local.h"
57 /* return values of _citrus_mapper_convert */
58 #define _CITRUS_MAPPER_CONVERT_SUCCESS (0)
59 #define _CITRUS_MAPPER_CONVERT_NONIDENTICAL (1)
60 #define _CITRUS_MAPPER_CONVERT_SRC_MORE (2)
61 #define _CITRUS_MAPPER_CONVERT_DST_MORE (3)
62 #define _CITRUS_MAPPER_CONVERT_ILSEQ (4)
63 #define _CITRUS_MAPPER_CONVERT_FATAL (5)
66 * _citrus_mapper_convert:
68 * - if the converter supports M:1 converter, the function may return
69 * _CITRUS_MAPPER_CONVERT_SRC_MORE and the storage pointed by dst
70 * may be unchanged in this case, although the internal status of
71 * the mapper is affected.
72 * - if the converter supports 1:N converter, the function may return
73 * _CITRUS_MAPPER_CONVERT_DST_MORE. In this case, the contiguous
74 * call of this function ignores src and changes the storage pointed
76 * - if the converter supports M:N converter, the function may behave
77 * the combination of the above.
81 _citrus_mapper_convert(struct _citrus_mapper * __restrict cm,
82 _citrus_index_t * __restrict dst, _citrus_index_t src,
86 return ((*cm->cm_ops->mo_convert)(cm, dst, src, ps));
90 * _citrus_mapper_init_state:
91 * initialize the state.
94 _citrus_mapper_init_state(struct _citrus_mapper * __restrict cm)
97 (*cm->cm_ops->mo_init_state)();
101 * _citrus_mapper_get_state_size:
102 * get the size of state storage.
104 static __inline size_t
105 _citrus_mapper_get_state_size(struct _citrus_mapper * __restrict cm)
108 return (cm->cm_traits->mt_state_size);
112 * _citrus_mapper_get_src_max:
113 * get the maximum number of suspended sources.
115 static __inline size_t
116 _citrus_mapper_get_src_max(struct _citrus_mapper * __restrict cm)
119 return (cm->cm_traits->mt_src_max);
123 * _citrus_mapper_get_dst_max:
124 * get the maximum number of suspended destinations.
126 static __inline size_t
127 _citrus_mapper_get_dst_max(struct _citrus_mapper * __restrict cm)
130 return (cm->cm_traits->mt_dst_max);