xref: /freebsd/lib/libc/locale/mblocal.h (revision 3c87aa1d3dc1d8dad3efad322852a8e1e76dee55)
12051a8f2STim J. Robbins /*-
22051a8f2STim J. Robbins  * Copyright (c) 2004 Tim J. Robbins.
32051a8f2STim J. Robbins  * All rights reserved.
42051a8f2STim J. Robbins  *
5*3c87aa1dSDavid Chisnall  * Copyright (c) 2011 The FreeBSD Foundation
6*3c87aa1dSDavid Chisnall  * All rights reserved.
7*3c87aa1dSDavid Chisnall  * Portions of this software were developed by David Chisnall
8*3c87aa1dSDavid Chisnall  * under sponsorship from the FreeBSD Foundation.
9*3c87aa1dSDavid Chisnall  *
102051a8f2STim J. Robbins  * Redistribution and use in source and binary forms, with or without
112051a8f2STim J. Robbins  * modification, are permitted provided that the following conditions
122051a8f2STim J. Robbins  * are met:
132051a8f2STim J. Robbins  * 1. Redistributions of source code must retain the above copyright
142051a8f2STim J. Robbins  *    notice, this list of conditions and the following disclaimer.
152051a8f2STim J. Robbins  * 2. Redistributions in binary form must reproduce the above copyright
162051a8f2STim J. Robbins  *    notice, this list of conditions and the following disclaimer in the
172051a8f2STim J. Robbins  *    documentation and/or other materials provided with the distribution.
182051a8f2STim J. Robbins  *
192051a8f2STim J. Robbins  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
202051a8f2STim J. Robbins  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
212051a8f2STim J. Robbins  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
222051a8f2STim J. Robbins  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
232051a8f2STim J. Robbins  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
242051a8f2STim J. Robbins  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
252051a8f2STim J. Robbins  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
262051a8f2STim J. Robbins  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
272051a8f2STim J. Robbins  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
282051a8f2STim J. Robbins  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
292051a8f2STim J. Robbins  * SUCH DAMAGE.
302051a8f2STim J. Robbins  *
312051a8f2STim J. Robbins  * $FreeBSD$
322051a8f2STim J. Robbins  */
332051a8f2STim J. Robbins 
342051a8f2STim J. Robbins #ifndef _MBLOCAL_H_
352051a8f2STim J. Robbins #define	_MBLOCAL_H_
362051a8f2STim J. Robbins 
37a964324eSRong-En Fan #include <runetype.h>
38*3c87aa1dSDavid Chisnall #include "xlocale_private.h"
39a964324eSRong-En Fan 
40e94c6cb4SAlexey Zelkin 
41e94c6cb4SAlexey Zelkin /*
422051a8f2STim J. Robbins  * Conversion function pointers for current encoding.
432051a8f2STim J. Robbins  */
44*3c87aa1dSDavid Chisnall struct xlocale_ctype {
45*3c87aa1dSDavid Chisnall 	struct xlocale_component header;
46*3c87aa1dSDavid Chisnall 	_RuneLocale *runes;
47*3c87aa1dSDavid Chisnall 	size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
482051a8f2STim J. Robbins 		size_t, mbstate_t * __restrict);
49*3c87aa1dSDavid Chisnall 	int (*__mbsinit)(const mbstate_t *);
50*3c87aa1dSDavid Chisnall 	size_t (*__mbsnrtowcs)(wchar_t * __restrict, const char ** __restrict,
511949a347STim J. Robbins 		size_t, size_t, mbstate_t * __restrict);
52*3c87aa1dSDavid Chisnall 	size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
53*3c87aa1dSDavid Chisnall 	size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict,
541949a347STim J. Robbins 		size_t, size_t, mbstate_t * __restrict);
55*3c87aa1dSDavid Chisnall 	int __mb_cur_max;
56*3c87aa1dSDavid Chisnall 	int __mb_sb_limit;
57*3c87aa1dSDavid Chisnall };
58*3c87aa1dSDavid Chisnall #define XLOCALE_CTYPE(x) ((struct xlocale_ctype*)(x)->components[XLC_CTYPE])
59*3c87aa1dSDavid Chisnall extern struct xlocale_ctype __xlocale_global_ctype;
60*3c87aa1dSDavid Chisnall 
61*3c87aa1dSDavid Chisnall /*
62*3c87aa1dSDavid Chisnall  * Rune initialization function prototypes.
63*3c87aa1dSDavid Chisnall  */
64*3c87aa1dSDavid Chisnall int	_none_init(struct xlocale_ctype *, _RuneLocale *);
65*3c87aa1dSDavid Chisnall int	_ascii_init(struct xlocale_ctype *, _RuneLocale *);
66*3c87aa1dSDavid Chisnall int	_UTF8_init(struct xlocale_ctype *, _RuneLocale *);
67*3c87aa1dSDavid Chisnall int	_EUC_init(struct xlocale_ctype *, _RuneLocale *);
68*3c87aa1dSDavid Chisnall int	_GB18030_init(struct xlocale_ctype *, _RuneLocale *);
69*3c87aa1dSDavid Chisnall int	_GB2312_init(struct xlocale_ctype *, _RuneLocale *);
70*3c87aa1dSDavid Chisnall int	_GBK_init(struct xlocale_ctype *, _RuneLocale *);
71*3c87aa1dSDavid Chisnall int	_BIG5_init(struct xlocale_ctype *, _RuneLocale *);
72*3c87aa1dSDavid Chisnall int	_MSKanji_init(struct xlocale_ctype *, _RuneLocale *);
732051a8f2STim J. Robbins 
741949a347STim J. Robbins extern size_t __mbsnrtowcs_std(wchar_t * __restrict, const char ** __restrict,
751949a347STim J. Robbins 	size_t, size_t, mbstate_t * __restrict);
761949a347STim J. Robbins extern size_t __wcsnrtombs_std(char * __restrict, const wchar_t ** __restrict,
771949a347STim J. Robbins 	size_t, size_t, mbstate_t * __restrict);
782051a8f2STim J. Robbins 
792051a8f2STim J. Robbins #endif	/* _MBLOCAL_H_ */
80