1 /* $NetBSD: citrus_ctype.h,v 1.2 2003/03/05 20:18:15 tshiozak Exp $ */
4 * Copyright (c)2002 Citrus Project,
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #ifndef _CITRUS_CTYPE_H_
31 #define _CITRUS_CTYPE_H_
33 #include "citrus_ctype_local.h"
35 typedef struct _citrus_ctype_rec
*_citrus_ctype_t
;
38 int _citrus_ctype_open(_citrus_ctype_t
* __restrict
,
39 char const * __restrict
, void * __restrict
,
41 void _citrus_ctype_close(_citrus_ctype_t
);
44 static __inline
unsigned
45 _citrus_ctype_get_mb_cur_max(_citrus_ctype_t cc
)
48 _DIAGASSERT(cc
&& cc
->cc_ops
);
49 return (*cc
->cc_ops
->co_get_mb_cur_max
)(cc
->cc_closure
);
53 _citrus_ctype_mblen(_citrus_ctype_t cc
, const char *s
, size_t n
, int *nresult
)
56 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mblen
&& nresult
);
57 return (*cc
->cc_ops
->co_mblen
)(cc
->cc_closure
, s
, n
, nresult
);
61 _citrus_ctype_mbrlen(_citrus_ctype_t cc
, const char *s
, size_t n
,
62 void *pspriv
, size_t *nresult
)
65 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbrlen
&& nresult
);
66 return (*cc
->cc_ops
->co_mbrlen
)(cc
->cc_closure
, s
, n
, pspriv
, nresult
);
70 _citrus_ctype_mbrtowc(_citrus_ctype_t cc
, wchar_t *pwc
, const char *s
,
71 size_t n
, void *pspriv
, size_t *nresult
)
74 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbrtowc
);
75 return (*cc
->cc_ops
->co_mbrtowc
)(cc
->cc_closure
, pwc
, s
, n
, pspriv
,
80 _citrus_ctype_mbsinit(_citrus_ctype_t cc
, void const *pspriv
, int *nresult
)
83 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbsinit
&& nresult
);
84 return (*cc
->cc_ops
->co_mbsinit
)(cc
->cc_closure
, pspriv
, nresult
);
88 _citrus_ctype_mbsrtowcs(_citrus_ctype_t cc
, wchar_t *pwcs
, const char **s
,
89 size_t n
, void *pspriv
, size_t *nresult
)
92 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbsrtowcs
&& nresult
);
93 return (*cc
->cc_ops
->co_mbsrtowcs
)(cc
->cc_closure
, pwcs
, s
, n
, pspriv
,
98 _citrus_ctype_mbstowcs(_citrus_ctype_t cc
, wchar_t *pwcs
, const char *s
,
99 size_t n
, size_t *nresult
)
102 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbstowcs
&& nresult
);
103 return (*cc
->cc_ops
->co_mbstowcs
)(cc
->cc_closure
, pwcs
, s
, n
, nresult
);
107 _citrus_ctype_mbtowc(_citrus_ctype_t cc
, wchar_t *pw
, const char *s
, size_t n
,
111 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_mbtowc
&& nresult
);
112 return (*cc
->cc_ops
->co_mbtowc
)(cc
->cc_closure
, pw
, s
, n
, nresult
);
116 _citrus_ctype_wcrtomb(_citrus_ctype_t cc
, char *s
, wchar_t wc
,
117 void *pspriv
, size_t *nresult
)
120 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wcrtomb
&& nresult
);
121 return (*cc
->cc_ops
->co_wcrtomb
)(cc
->cc_closure
, s
, wc
, pspriv
,
126 _citrus_ctype_wcsrtombs(_citrus_ctype_t cc
, char *s
, const wchar_t **ppwcs
,
127 size_t n
, void *pspriv
, size_t *nresult
)
130 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wcsrtombs
&& nresult
);
131 return (*cc
->cc_ops
->co_wcsrtombs
)(cc
->cc_closure
, s
, ppwcs
, n
,
136 _citrus_ctype_wcstombs(_citrus_ctype_t cc
, char *s
, const wchar_t *wcs
,
137 size_t n
, size_t *nresult
)
140 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wcstombs
&& nresult
);
141 return (*cc
->cc_ops
->co_wcstombs
)(cc
->cc_closure
, s
, wcs
, n
, nresult
);
145 _citrus_ctype_wctomb(_citrus_ctype_t cc
, char *s
, wchar_t wc
, int *nresult
)
148 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wctomb
&& nresult
);
149 return (*cc
->cc_ops
->co_wctomb
)(cc
->cc_closure
, s
, wc
, nresult
);
153 _citrus_ctype_btowc(_citrus_ctype_t cc
, int c
, wint_t *wcresult
)
156 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_btowc
&& wcresult
);
157 return (*cc
->cc_ops
->co_btowc
)(cc
, c
, wcresult
);
161 _citrus_ctype_wctob(_citrus_ctype_t cc
, wint_t c
, int *cresult
)
164 _DIAGASSERT(cc
&& cc
->cc_ops
&& cc
->cc_ops
->co_wctob
&& cresult
);
165 return (*cc
->cc_ops
->co_wctob
)(cc
, c
, cresult
);
168 extern _citrus_ctype_rec_t _citrus_ctype_default
;