1 /* $NetBSD: src/lib/libc/citrus/citrus_stdenc.h,v 1.3 2003/07/10 08:50:44 tshiozak Exp $ */
2 /* $DragonFly: src/lib/libc/citrus/citrus_stdenc.h,v 1.1 2005/03/11 23:33:53 joerg 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 #include "citrus_stdenc_local.h"
41 int _citrus_stdenc_open(struct _citrus_stdenc
* __restrict
* __restrict
,
42 char const * __restrict
,
43 const void * __restrict
, size_t);
44 void _citrus_stdenc_close(struct _citrus_stdenc
*);
48 _citrus_stdenc_init_state(struct _citrus_stdenc
* __restrict ce
,
51 _DIAGASSERT(ce
&& ce
->ce_ops
&& ce
->ce_ops
->eo_init_state
);
52 return (*ce
->ce_ops
->eo_init_state
)(ce
, ps
);
56 _citrus_stdenc_mbtocs(struct _citrus_stdenc
* __restrict ce
,
57 _citrus_csid_t
* __restrict csid
,
58 _citrus_index_t
* __restrict idx
,
59 const char ** __restrict s
, size_t n
,
60 void * __restrict ps
, size_t * __restrict nresult
)
62 _DIAGASSERT(ce
&& ce
->ce_ops
&& ce
->ce_ops
->eo_mbtocs
);
63 return (*ce
->ce_ops
->eo_mbtocs
)(ce
, csid
, idx
, s
, n
, ps
, nresult
);
67 _citrus_stdenc_cstomb(struct _citrus_stdenc
* __restrict ce
,
68 char * __restrict s
, size_t n
,
69 _citrus_csid_t csid
, _citrus_index_t idx
,
70 void * __restrict ps
, size_t * __restrict nresult
)
72 _DIAGASSERT(ce
&& ce
->ce_ops
&& ce
->ce_ops
->eo_cstomb
);
73 return (*ce
->ce_ops
->eo_cstomb
)(ce
, s
, n
, csid
, idx
, ps
, nresult
);
77 _citrus_stdenc_mbtowc(struct _citrus_stdenc
* __restrict ce
,
78 _citrus_wc_t
* __restrict wc
,
79 const char ** __restrict s
, size_t n
,
80 void * __restrict ps
, size_t * __restrict nresult
)
82 _DIAGASSERT(ce
&& ce
->ce_ops
&& ce
->ce_ops
->eo_mbtocs
);
83 return (*ce
->ce_ops
->eo_mbtowc
)(ce
, wc
, s
, n
, ps
, nresult
);
87 _citrus_stdenc_wctomb(struct _citrus_stdenc
* __restrict ce
,
88 char * __restrict s
, size_t n
, _citrus_wc_t wc
,
89 void * __restrict ps
, size_t * __restrict nresult
)
91 _DIAGASSERT(ce
&& ce
->ce_ops
&& ce
->ce_ops
->eo_cstomb
);
92 return (*ce
->ce_ops
->eo_wctomb
)(ce
, s
, n
, wc
, ps
, nresult
);
96 _citrus_stdenc_put_state_reset(struct _citrus_stdenc
* __restrict ce
,
97 char * __restrict s
, size_t n
,
99 size_t * __restrict nresult
)
101 _DIAGASSERT(ce
&& ce
->ce_ops
&& ce
->ce_ops
->eo_put_state_reset
);
102 return (*ce
->ce_ops
->eo_put_state_reset
)(ce
, s
, n
, ps
, nresult
);
105 static __inline
size_t
106 _citrus_stdenc_get_state_size(struct _citrus_stdenc
*ce
)
108 _DIAGASSERT(ce
&& ce
->ce_traits
);
109 return ce
->ce_traits
->et_state_size
;
112 static __inline
size_t
113 _citrus_stdenc_get_mb_cur_max(struct _citrus_stdenc
*ce
)
115 _DIAGASSERT(ce
&& ce
->ce_traits
);
116 return ce
->ce_traits
->et_mb_cur_max
;