1250883Sed/*-
2250883Sed * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org>
3250883Sed * All rights reserved.
4250883Sed *
5250883Sed * Redistribution and use in source and binary forms, with or without
6250883Sed * modification, are permitted provided that the following conditions
7250883Sed * are met:
8250883Sed * 1. Redistributions of source code must retain the above copyright
9250883Sed *    notice, this list of conditions and the following disclaimer.
10250883Sed * 2. Redistributions in binary form must reproduce the above copyright
11250883Sed *    notice, this list of conditions and the following disclaimer in the
12250883Sed *    documentation and/or other materials provided with the distribution.
13250883Sed *
14250883Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15250883Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16250883Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17250883Sed * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18250883Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19250883Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20250883Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21250883Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22250883Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23250883Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24250883Sed * SUCH DAMAGE.
25250883Sed */
26250883Sed
27250883Sed#include <sys/cdefs.h>
28250883Sed__FBSDID("$FreeBSD: releng/10.3/lib/libc/locale/mbrtoc32.c 250883 2013-05-21 19:59:37Z ed $");
29250883Sed
30250883Sed#include <uchar.h>
31250883Sed#include <wchar.h>
32250883Sed#include "xlocale_private.h"
33250883Sed
34250883Sedsize_t
35250883Sedmbrtoc32_l(char32_t * __restrict pc32, const char * __restrict s, size_t n,
36250883Sed    mbstate_t * __restrict ps, locale_t locale)
37250883Sed{
38250883Sed
39250883Sed	FIX_LOCALE(locale);
40250883Sed	if (ps == NULL)
41250883Sed		ps = &locale->mbrtoc32;
42250883Sed
43250883Sed	/* Assume wchar_t uses UTF-32. */
44250883Sed	return (mbrtowc_l(pc32, s, n, ps, locale));
45250883Sed}
46250883Sed
47250883Sedsize_t
48250883Sedmbrtoc32(char32_t * __restrict pc32, const char * __restrict s, size_t n,
49250883Sed    mbstate_t * __restrict ps)
50250883Sed{
51250883Sed
52250883Sed	return (mbrtoc32_l(pc32, s, n, ps, __get_locale()));
53250883Sed}
54