MFC 1.36: Fix a bug in the mount scan.
[dragonfly.git] / lib / libc / citrus / citrus_stdenc.h
blobac614c687263429a82de94d5092c21f54c572299
1 /* $NetBSD: citrus_stdenc.h,v 1.4 2005/10/29 18:02:04 tshiozak Exp $ */
2 /* $DragonFly: src/lib/libc/citrus/citrus_stdenc.h,v 1.2 2008/04/10 10:21:01 hasso Exp $ */
4 /*-
5 * Copyright (c)2003 Citrus Project,
6 * All rights reserved.
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.
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.
31 #ifndef _CITRUS_STDENC_H_
32 #define _CITRUS_STDENC_H_
34 struct _citrus_stdenc;
35 struct _citrus_stdenc_ops;
36 struct _citrus_stdenc_traits;
38 #define _CITRUS_STDENC_SDID_GENERIC 0
39 struct _citrus_stdenc_state_desc
41 union {
42 struct {
43 int state;
44 #define _CITRUS_STDENC_SDGEN_UNKNOWN 0
45 #define _CITRUS_STDENC_SDGEN_INITIAL 1
46 #define _CITRUS_STDENC_SDGEN_STABLE 2
47 #define _CITRUS_STDENC_SDGEN_INCOMPLETE_CHAR 3
48 #define _CITRUS_STDENC_SDGEN_INCOMPLETE_SHIFT 4
49 } generic;
50 } u;
53 #include "citrus_stdenc_local.h"
55 __BEGIN_DECLS
56 int _citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict,
57 char const * __restrict,
58 const void * __restrict, size_t);
59 void _citrus_stdenc_close(struct _citrus_stdenc *);
60 __END_DECLS
62 static __inline int
63 _citrus_stdenc_init_state(struct _citrus_stdenc * __restrict ce,
64 void * __restrict ps)
66 _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_init_state);
67 return (*ce->ce_ops->eo_init_state)(ce, ps);
70 static __inline int
71 _citrus_stdenc_mbtocs(struct _citrus_stdenc * __restrict ce,
72 _citrus_csid_t * __restrict csid,
73 _citrus_index_t * __restrict idx,
74 const char ** __restrict s, size_t n,
75 void * __restrict ps, size_t * __restrict nresult)
77 _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_mbtocs);
78 return (*ce->ce_ops->eo_mbtocs)(ce, csid, idx, s, n, ps, nresult);
81 static __inline int
82 _citrus_stdenc_cstomb(struct _citrus_stdenc * __restrict ce,
83 char * __restrict s, size_t n,
84 _citrus_csid_t csid, _citrus_index_t idx,
85 void * __restrict ps, size_t * __restrict nresult)
87 _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_cstomb);
88 return (*ce->ce_ops->eo_cstomb)(ce, s, n, csid, idx, ps, nresult);
91 static __inline int
92 _citrus_stdenc_mbtowc(struct _citrus_stdenc * __restrict ce,
93 _citrus_wc_t * __restrict wc,
94 const char ** __restrict s, size_t n,
95 void * __restrict ps, size_t * __restrict nresult)
97 _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_mbtocs);
98 return (*ce->ce_ops->eo_mbtowc)(ce, wc, s, n, ps, nresult);
101 static __inline int
102 _citrus_stdenc_wctomb(struct _citrus_stdenc * __restrict ce,
103 char * __restrict s, size_t n, _citrus_wc_t wc,
104 void * __restrict ps, size_t * __restrict nresult)
106 _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_cstomb);
107 return (*ce->ce_ops->eo_wctomb)(ce, s, n, wc, ps, nresult);
110 static __inline int
111 _citrus_stdenc_put_state_reset(struct _citrus_stdenc * __restrict ce,
112 char * __restrict s, size_t n,
113 void * __restrict ps,
114 size_t * __restrict nresult)
116 _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_put_state_reset);
117 return (*ce->ce_ops->eo_put_state_reset)(ce, s, n, ps, nresult);
120 static __inline size_t
121 _citrus_stdenc_get_state_size(struct _citrus_stdenc *ce)
123 _DIAGASSERT(ce && ce->ce_traits);
124 return ce->ce_traits->et_state_size;
127 static __inline size_t
128 _citrus_stdenc_get_mb_cur_max(struct _citrus_stdenc *ce)
130 _DIAGASSERT(ce && ce->ce_traits);
131 return ce->ce_traits->et_mb_cur_max;
134 static __inline int
135 _citrus_stdenc_get_state_desc(struct _citrus_stdenc * __restrict ce,
136 void * __restrict ps,
137 int id,
138 struct _citrus_stdenc_state_desc * __restrict d)
141 _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_get_state_desc);
143 return (*ce->ce_ops->eo_get_state_desc)(ce, ps, id, d);
146 #endif