1 /* $NetBSD: src/lib/libc/citrus/citrus_ctype.h,v 1.2 2003/03/05 20:18:15 tshiozak Exp $ */
2 /* $DragonFly: src/lib/libc/citrus/citrus_ctype.h,v 1.2 2008/04/10 10:21:01 hasso Exp $ */
5 * Copyright (c)2002 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_CTYPE_H_
32 #define _CITRUS_CTYPE_H_
34 #include "citrus_ctype_local.h"
36 typedef struct _citrus_ctype_rec
*_citrus_ctype_t
;
39 int _citrus_ctype_open(_citrus_ctype_t
* __restrict
,
40 char const * __restrict
, void * __restrict
,
42 void _citrus_ctype_close(_citrus_ctype_t
);
45 static __inline
unsigned
46 _citrus_ctype_get_mb_cur_max(_citrus_ctype_t cc
)
49 _DIAGASSERT(cc
&& cc
->cc_ops
);
50 return (*cc
->cc_ops
->co_get_mb_cur_max
)(cc
->cc_closure
);
54 _citrus_ctype_mblen(_citrus_ctype_t cc
, const char *s
, size_t n
, int *nresult
)
57 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mblen
&& nresult
);
58 return (*cc
->cc_ops
->co_mblen
)(cc
->cc_closure
, s
, n
, nresult
);
62 _citrus_ctype_mbrlen(_citrus_ctype_t cc
, const char *s
, size_t n
,
63 void *pspriv
, size_t *nresult
)
66 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbrlen
&& nresult
);
67 return (*cc
->cc_ops
->co_mbrlen
)(cc
->cc_closure
, s
, n
, pspriv
, nresult
);
71 _citrus_ctype_mbrtowc(_citrus_ctype_t cc
, wchar_t *pwc
, const char *s
,
72 size_t n
, void *pspriv
, size_t *nresult
)
75 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbrtowc
);
76 return (*cc
->cc_ops
->co_mbrtowc
)(cc
->cc_closure
, pwc
, s
, n
, pspriv
,
81 _citrus_ctype_mbsinit(_citrus_ctype_t cc
, void const *pspriv
, int *nresult
)
84 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbsinit
&& nresult
);
85 return (*cc
->cc_ops
->co_mbsinit
)(cc
->cc_closure
, pspriv
, nresult
);
89 _citrus_ctype_mbsrtowcs(_citrus_ctype_t cc
, wchar_t *pwcs
, const char **s
,
90 size_t n
, void *pspriv
, size_t *nresult
)
93 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbsrtowcs
&& nresult
);
94 return (*cc
->cc_ops
->co_mbsrtowcs
)(cc
->cc_closure
, pwcs
, s
, n
, pspriv
,
99 _citrus_ctype_mbstowcs(_citrus_ctype_t cc
, wchar_t *pwcs
, const char *s
,
100 size_t n
, size_t *nresult
)
103 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbstowcs
&& nresult
);
104 return (*cc
->cc_ops
->co_mbstowcs
)(cc
->cc_closure
, pwcs
, s
, n
, nresult
);
108 _citrus_ctype_mbtowc(_citrus_ctype_t cc
, wchar_t *pw
, const char *s
, size_t n
,
112 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbtowc
&& nresult
);
113 return (*cc
->cc_ops
->co_mbtowc
)(cc
->cc_closure
, pw
, s
, n
, nresult
);
117 _citrus_ctype_wcrtomb(_citrus_ctype_t cc
, char *s
, wchar_t wc
,
118 void *pspriv
, size_t *nresult
)
121 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wcrtomb
&& nresult
);
122 return (*cc
->cc_ops
->co_wcrtomb
)(cc
->cc_closure
, s
, wc
, pspriv
,
127 _citrus_ctype_wcsrtombs(_citrus_ctype_t cc
, char *s
, const wchar_t **ppwcs
,
128 size_t n
, void *pspriv
, size_t *nresult
)
131 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wcsrtombs
&& nresult
);
132 return (*cc
->cc_ops
->co_wcsrtombs
)(cc
->cc_closure
, s
, ppwcs
, n
,
137 _citrus_ctype_wcstombs(_citrus_ctype_t cc
, char *s
, const wchar_t *wcs
,
138 size_t n
, size_t *nresult
)
141 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wcstombs
&& nresult
);
142 return (*cc
->cc_ops
->co_wcstombs
)(cc
->cc_closure
, s
, wcs
, n
, nresult
);
146 _citrus_ctype_wctomb(_citrus_ctype_t cc
, char *s
, wchar_t wc
, int *nresult
)
149 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wctomb
&& nresult
);
150 return (*cc
->cc_ops
->co_wctomb
)(cc
->cc_closure
, s
, wc
, nresult
);
154 _citrus_ctype_btowc(_citrus_ctype_t cc
, int c
, wint_t *wcresult
)
157 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_btowc
&& wcresult
);
158 return (*cc
->cc_ops
->co_btowc
)(cc
, c
, wcresult
);
162 _citrus_ctype_wctob(_citrus_ctype_t cc
, wint_t c
, int *cresult
)
165 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wctob
&& cresult
);
166 return (*cc
->cc_ops
->co_wctob
)(cc
, c
, cresult
);
169 extern _citrus_ctype_rec_t _citrus_ctype_default
;