1 /* 2 * Copyright 2013 Garrett D'Amore <garrett@damore.org> 3 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 4 * Copyright (c) 2004 Tim J. Robbins. 5 * All rights reserved. 6 * 7 * Copyright (c) 2011 The FreeBSD Foundation 8 * All rights reserved. 9 * Portions of this software were developed by David Chisnall 10 * under sponsorship from the FreeBSD Foundation. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34 #ifndef _MBLOCAL_H_ 35 #define _MBLOCAL_H_ 36 37 #include <runetype.h> 38 #include "xlocale_private.h" 39 40 #define SS2 0x008e 41 #define SS3 0x008f 42 43 /* 44 * Conversion function pointers for current encoding. 45 */ 46 struct xlocale_ctype { 47 struct xlocale_component header; 48 _RuneLocale *runes; 49 size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict, 50 size_t, mbstate_t * __restrict); 51 int (*__mbsinit)(const mbstate_t *); 52 size_t (*__mbsnrtowcs)(wchar_t * __restrict, const char ** __restrict, 53 size_t, size_t, mbstate_t * __restrict); 54 size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict); 55 size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict, 56 size_t, size_t, mbstate_t * __restrict); 57 size_t (*__mbintowcr)(wchar_t * __restrict dst, 58 const char * __restrict src, size_t dlen, size_t *slen, 59 int flags); 60 size_t (*__wcrtombin)(char * __restrict dst, 61 const wchar_t * __restrict src, size_t dlen, size_t *slen, 62 int flags); 63 int __mb_cur_max; 64 int __mb_sb_limit; 65 }; 66 #define XLOCALE_CTYPE(x) ((struct xlocale_ctype*)(x)->components[XLC_CTYPE]) 67 extern struct xlocale_ctype __xlocale_global_ctype; 68 69 /* 70 * Rune initialization function prototypes. 71 */ 72 int _none_init(struct xlocale_ctype *, _RuneLocale *); 73 int _UTF8_init(struct xlocale_ctype *, _RuneLocale *); 74 int _EUC_CN_init(struct xlocale_ctype *, _RuneLocale *); 75 int _EUC_JP_init(struct xlocale_ctype *, _RuneLocale *); 76 int _EUC_KR_init(struct xlocale_ctype *, _RuneLocale *); 77 int _EUC_TW_init(struct xlocale_ctype *, _RuneLocale *); 78 int _GB18030_init(struct xlocale_ctype *, _RuneLocale *); 79 int _GB2312_init(struct xlocale_ctype *, _RuneLocale *); 80 int _GBK_init(struct xlocale_ctype *, _RuneLocale *); 81 int _BIG5_init(struct xlocale_ctype *, _RuneLocale *); 82 int _MSKanji_init(struct xlocale_ctype *, _RuneLocale *); 83 int _ascii_init(struct xlocale_ctype *, _RuneLocale *); 84 85 typedef size_t (*mbrtowc_pfn_t)(wchar_t * __restrict, 86 const char * __restrict, size_t, mbstate_t * __restrict); 87 typedef size_t (*wcrtomb_pfn_t)(char * __restrict, wchar_t, 88 mbstate_t * __restrict); 89 size_t __mbsnrtowcs_std(wchar_t * __restrict, const char ** __restrict, 90 size_t, size_t, mbstate_t * __restrict, mbrtowc_pfn_t); 91 size_t __wcsnrtombs_std(char * __restrict, const wchar_t ** __restrict, 92 size_t, size_t, mbstate_t * __restrict, wcrtomb_pfn_t); 93 94 #endif /* _MBLOCAL_H_ */ 95