2 /* $NetBSD: citrus_stdenc.h,v 1.4 2005/10/29 18:02:04 tshiozak Exp $ */
5 * Copyright (c)2003 Citrus Project,
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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
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
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
53 #include "citrus_stdenc_local.h"
56 int _citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict,
57 char const * __restrict, const void * __restrict, size_t);
58 void _citrus_stdenc_close(struct _citrus_stdenc *);
62 _citrus_stdenc_init_state(struct _citrus_stdenc * __restrict ce,
66 return ((*ce->ce_ops->eo_init_state)(ce, ps));
70 _citrus_stdenc_mbtocs(struct _citrus_stdenc * __restrict ce,
71 _citrus_csid_t * __restrict csid, _citrus_index_t * __restrict idx,
72 const char ** __restrict s, size_t n, void * __restrict ps,
73 size_t * __restrict nresult, struct iconv_hooks *hooks)
76 return ((*ce->ce_ops->eo_mbtocs)(ce, csid, idx, s, n, ps, nresult,
81 _citrus_stdenc_cstomb(struct _citrus_stdenc * __restrict ce,
82 char * __restrict s, size_t n, _citrus_csid_t csid, _citrus_index_t idx,
83 void * __restrict ps, size_t * __restrict nresult,
84 struct iconv_hooks *hooks)
87 return ((*ce->ce_ops->eo_cstomb)(ce, s, n, csid, idx, ps, nresult,
92 _citrus_stdenc_wctomb(struct _citrus_stdenc * __restrict ce,
93 char * __restrict s, size_t n, _citrus_wc_t wc, void * __restrict ps,
94 size_t * __restrict nresult, struct iconv_hooks *hooks)
97 return ((*ce->ce_ops->eo_wctomb)(ce, s, n, wc, ps, nresult, hooks));
101 _citrus_stdenc_put_state_reset(struct _citrus_stdenc * __restrict ce,
102 char * __restrict s, size_t n, void * __restrict ps,
103 size_t * __restrict nresult)
106 return ((*ce->ce_ops->eo_put_state_reset)(ce, s, n, ps, nresult));
109 static __inline size_t
110 _citrus_stdenc_get_state_size(struct _citrus_stdenc *ce)
113 return (ce->ce_traits->et_state_size);
117 _citrus_stdenc_get_state_desc(struct _citrus_stdenc * __restrict ce,
118 void * __restrict ps, int id,
119 struct _citrus_stdenc_state_desc * __restrict d)
122 return ((*ce->ce_ops->eo_get_state_desc)(ce, ps, id, d));