xref: /dflybsd-src/lib/libc/locale/mblocal.h (revision dff616f71d2401d2d44f647f79744eb1ebb3f189)
14776d4e8SJohn Marino /*
24776d4e8SJohn Marino  * Copyright 2013 Garrett D'Amore <garrett@damore.org>
34776d4e8SJohn Marino  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
40d5acd74SJohn Marino  * Copyright (c) 2004 Tim J. Robbins.
50d5acd74SJohn Marino  * All rights reserved.
60d5acd74SJohn Marino  *
70d5acd74SJohn Marino  * Copyright (c) 2011 The FreeBSD Foundation
80d5acd74SJohn Marino  * All rights reserved.
90d5acd74SJohn Marino  * Portions of this software were developed by David Chisnall
100d5acd74SJohn Marino  * under sponsorship from the FreeBSD Foundation.
110d5acd74SJohn Marino  *
120d5acd74SJohn Marino  * Redistribution and use in source and binary forms, with or without
130d5acd74SJohn Marino  * modification, are permitted provided that the following conditions
140d5acd74SJohn Marino  * are met:
150d5acd74SJohn Marino  * 1. Redistributions of source code must retain the above copyright
160d5acd74SJohn Marino  *    notice, this list of conditions and the following disclaimer.
170d5acd74SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
180d5acd74SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
190d5acd74SJohn Marino  *    documentation and/or other materials provided with the distribution.
200d5acd74SJohn Marino  *
210d5acd74SJohn Marino  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
220d5acd74SJohn Marino  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
230d5acd74SJohn Marino  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
240d5acd74SJohn Marino  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
250d5acd74SJohn Marino  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
260d5acd74SJohn Marino  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
270d5acd74SJohn Marino  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
280d5acd74SJohn Marino  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
290d5acd74SJohn Marino  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
300d5acd74SJohn Marino  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
310d5acd74SJohn Marino  * SUCH DAMAGE.
320d5acd74SJohn Marino  */
330d5acd74SJohn Marino 
340d5acd74SJohn Marino #ifndef _MBLOCAL_H_
350d5acd74SJohn Marino #define	_MBLOCAL_H_
360d5acd74SJohn Marino 
370d5acd74SJohn Marino #include <runetype.h>
380d5acd74SJohn Marino #include "xlocale_private.h"
390d5acd74SJohn Marino 
404776d4e8SJohn Marino #define	SS2	0x008e
414776d4e8SJohn Marino #define SS3	0x008f
420d5acd74SJohn Marino 
430d5acd74SJohn Marino /*
440d5acd74SJohn Marino  * Conversion function pointers for current encoding.
450d5acd74SJohn Marino  */
460d5acd74SJohn Marino struct xlocale_ctype {
470d5acd74SJohn Marino 	struct xlocale_component header;
480d5acd74SJohn Marino 	_RuneLocale *runes;
490d5acd74SJohn Marino 	size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
500d5acd74SJohn Marino 		size_t, mbstate_t * __restrict);
510d5acd74SJohn Marino 	int (*__mbsinit)(const mbstate_t *);
520d5acd74SJohn Marino 	size_t (*__mbsnrtowcs)(wchar_t * __restrict, const char ** __restrict,
530d5acd74SJohn Marino 		size_t, size_t, mbstate_t * __restrict);
540d5acd74SJohn Marino 	size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
550d5acd74SJohn Marino 	size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict,
560d5acd74SJohn Marino 		size_t, size_t, mbstate_t * __restrict);
578a84c799SMatthew Dillon 	size_t (*__mbintowcr)(wchar_t * __restrict dst,
588a84c799SMatthew Dillon 		const char * __restrict src, size_t dlen, size_t *slen,
598a84c799SMatthew Dillon 		int flags);
608a84c799SMatthew Dillon 	size_t (*__wcrtombin)(char * __restrict dst,
618a84c799SMatthew Dillon 		const wchar_t * __restrict src, size_t dlen, size_t *slen,
628a84c799SMatthew Dillon 		int flags);
630d5acd74SJohn Marino 	int __mb_cur_max;
640d5acd74SJohn Marino 	int __mb_sb_limit;
650d5acd74SJohn Marino };
660d5acd74SJohn Marino #define XLOCALE_CTYPE(x) ((struct xlocale_ctype*)(x)->components[XLC_CTYPE])
670d5acd74SJohn Marino extern struct xlocale_ctype __xlocale_global_ctype;
680d5acd74SJohn Marino 
690d5acd74SJohn Marino /*
700d5acd74SJohn Marino  * Rune initialization function prototypes.
710d5acd74SJohn Marino  */
72*dff616f7SSascha Wildner int	_none_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
73*dff616f7SSascha Wildner int	_UTF8_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
74*dff616f7SSascha Wildner int	_EUC_CN_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
75*dff616f7SSascha Wildner int	_EUC_JP_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
76*dff616f7SSascha Wildner int	_EUC_KR_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
77*dff616f7SSascha Wildner int	_EUC_TW_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
78*dff616f7SSascha Wildner int	_GB18030_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
79*dff616f7SSascha Wildner int	_GB2312_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
80*dff616f7SSascha Wildner int	_GBK_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
81*dff616f7SSascha Wildner int	_BIG5_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
82*dff616f7SSascha Wildner int	_MSKanji_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
83*dff616f7SSascha Wildner int	_ascii_init(struct xlocale_ctype *, _RuneLocale *) __dso_hidden;
840d5acd74SJohn Marino 
854776d4e8SJohn Marino typedef size_t (*mbrtowc_pfn_t)(wchar_t * __restrict,
864776d4e8SJohn Marino     const char * __restrict, size_t, mbstate_t * __restrict);
874776d4e8SJohn Marino typedef size_t (*wcrtomb_pfn_t)(char * __restrict, wchar_t,
884776d4e8SJohn Marino     mbstate_t * __restrict);
894776d4e8SJohn Marino size_t __mbsnrtowcs_std(wchar_t * __restrict, const char ** __restrict,
904776d4e8SJohn Marino     size_t, size_t, mbstate_t * __restrict, mbrtowc_pfn_t);
914776d4e8SJohn Marino size_t __wcsnrtombs_std(char * __restrict, const wchar_t ** __restrict,
924776d4e8SJohn Marino     size_t, size_t, mbstate_t * __restrict, wcrtomb_pfn_t);
930d5acd74SJohn Marino 
940d5acd74SJohn Marino #endif	/* _MBLOCAL_H_ */
95