1 /* $NetBSD: citrus_stdenc.h,v 1.4 2005/10/29 18:02:04 tshiozak Exp $ */
4 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c)2003 Citrus Project,
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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
32 #ifndef _CITRUS_STDENC_H_
33 #define _CITRUS_STDENC_H_
35 struct _citrus_stdenc;
36 struct _citrus_stdenc_ops;
37 struct _citrus_stdenc_traits;
39 #define _CITRUS_STDENC_SDID_GENERIC 0
40 struct _citrus_stdenc_state_desc
45 #define _CITRUS_STDENC_SDGEN_UNKNOWN 0
46 #define _CITRUS_STDENC_SDGEN_INITIAL 1
47 #define _CITRUS_STDENC_SDGEN_STABLE 2
48 #define _CITRUS_STDENC_SDGEN_INCOMPLETE_CHAR 3
49 #define _CITRUS_STDENC_SDGEN_INCOMPLETE_SHIFT 4
54 #include "citrus_stdenc_local.h"
57 int _citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict,
58 char const * __restrict, const void * __restrict, size_t);
59 void _citrus_stdenc_close(struct _citrus_stdenc *);
63 _citrus_stdenc_init_state(struct _citrus_stdenc * __restrict ce,
67 return ((*ce->ce_ops->eo_init_state)(ce, ps));
71 _citrus_stdenc_mbtocs(struct _citrus_stdenc * __restrict ce,
72 _citrus_csid_t * __restrict csid, _citrus_index_t * __restrict idx,
73 char ** __restrict s, size_t n, void * __restrict ps,
74 size_t * __restrict nresult, struct iconv_hooks *hooks)
77 return ((*ce->ce_ops->eo_mbtocs)(ce, csid, idx, s, n, ps, nresult,
82 _citrus_stdenc_cstomb(struct _citrus_stdenc * __restrict ce,
83 char * __restrict s, size_t n, _citrus_csid_t csid, _citrus_index_t idx,
84 void * __restrict ps, size_t * __restrict nresult,
85 struct iconv_hooks *hooks)
88 return ((*ce->ce_ops->eo_cstomb)(ce, s, n, csid, idx, ps, nresult,
93 _citrus_stdenc_wctomb(struct _citrus_stdenc * __restrict ce,
94 char * __restrict s, size_t n, _citrus_wc_t wc, void * __restrict ps,
95 size_t * __restrict nresult, struct iconv_hooks *hooks)
98 return ((*ce->ce_ops->eo_wctomb)(ce, s, n, wc, ps, nresult, hooks));
102 _citrus_stdenc_put_state_reset(struct _citrus_stdenc * __restrict ce,
103 char * __restrict s, size_t n, void * __restrict ps,
104 size_t * __restrict nresult)
107 return ((*ce->ce_ops->eo_put_state_reset)(ce, s, n, ps, nresult));
110 static __inline size_t
111 _citrus_stdenc_get_state_size(struct _citrus_stdenc *ce)
114 return (ce->ce_traits->et_state_size);
117 static __inline size_t
118 _citrus_stdenc_get_mb_cur_min(struct _citrus_stdenc *ce)
121 return (ce->ce_traits->et_mb_cur_min);
124 static __inline size_t
125 _citrus_stdenc_get_mb_cur_max(struct _citrus_stdenc *ce)
128 return (ce->ce_traits->et_mb_cur_max);
132 _citrus_stdenc_get_state_desc(struct _citrus_stdenc * __restrict ce,
133 void * __restrict ps, int id,
134 struct _citrus_stdenc_state_desc * __restrict d)
137 return ((*ce->ce_ops->eo_get_state_desc)(ce, ps, id, d));