2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright 2013 Garrett D'Amore <garrett@damore.org>
5 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
6 * Copyright (c) 2004 Tim J. Robbins.
9 * Copyright (c) 2011 The FreeBSD Foundation
11 * Portions of this software were developed by David Chisnall
12 * under sponsorship from the FreeBSD Foundation.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 #include "xlocale_private.h"
48 * Conversion function pointers for current encoding.
50 struct xlocale_ctype {
51 struct xlocale_component header;
53 size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
54 size_t, mbstate_t * __restrict);
55 int (*__mbsinit)(const mbstate_t *);
56 size_t (*__mbsnrtowcs)(wchar_t * __restrict, const char ** __restrict,
57 size_t, size_t, mbstate_t * __restrict);
58 size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
59 size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict,
60 size_t, size_t, mbstate_t * __restrict);
63 /** Persistent state used by mblen() calls. */
65 /** Persistent state used by mbrlen() calls. */
67 /** Persistent state used by mbrtoc16() calls. */
69 /** Persistent state used by mbrtoc32() calls. */
71 /** Persistent state used by mbrtowc() calls. */
73 /** Persistent state used by mbsnrtowcs() calls. */
74 __mbstate_t mbsnrtowcs;
75 /** Persistent state used by mbsrtowcs() calls. */
76 __mbstate_t mbsrtowcs;
77 /** Persistent state used by mbtowc() calls. */
79 /** Persistent state used by c16rtomb() calls. */
81 /** Persistent state used by c32rtomb() calls. */
83 /** Persistent state used by wcrtomb() calls. */
85 /** Persistent state used by wcsnrtombs() calls. */
86 __mbstate_t wcsnrtombs;
87 /** Persistent state used by wcsrtombs() calls. */
88 __mbstate_t wcsrtombs;
89 /** Persistent state used by wctomb() calls. */
92 #define XLOCALE_CTYPE(x) ((struct xlocale_ctype*)(x)->components[XLC_CTYPE])
93 extern struct xlocale_ctype __xlocale_global_ctype;
96 * Rune initialization function prototypes.
98 int _none_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
99 int _UTF8_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
100 int _EUC_CN_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
101 int _EUC_JP_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
102 int _EUC_KR_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
103 int _EUC_TW_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
104 int _GB18030_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
105 int _GB2312_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
106 int _GBK_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
107 int _BIG5_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
108 int _MSKanji_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
109 int _ascii_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
111 typedef size_t (*mbrtowc_pfn_t)(wchar_t * __restrict,
112 const char * __restrict, size_t, mbstate_t * __restrict);
113 typedef size_t (*wcrtomb_pfn_t)(char * __restrict, wchar_t,
114 mbstate_t * __restrict);
115 size_t __mbsnrtowcs_std(wchar_t * __restrict, const char ** __restrict,
116 size_t, size_t, mbstate_t * __restrict, mbrtowc_pfn_t);
117 size_t __wcsnrtombs_std(char * __restrict, const wchar_t ** __restrict,
118 size_t, size_t, mbstate_t * __restrict, wcrtomb_pfn_t);
120 #endif /* _MBLOCAL_H_ */