mbstowcs.c revision 129179
1102697Stjr/*-
2127944Stjr * Copyright (c) 2002-2004 Tim J. Robbins.
3118593Stjr * All rights reserved.
4102697Stjr *
5102697Stjr * Redistribution and use in source and binary forms, with or without
6102697Stjr * modification, are permitted provided that the following conditions
7102697Stjr * are met:
8102697Stjr * 1. Redistributions of source code must retain the above copyright
9102697Stjr *    notice, this list of conditions and the following disclaimer.
10102697Stjr * 2. Redistributions in binary form must reproduce the above copyright
11102697Stjr *    notice, this list of conditions and the following disclaimer in the
12102697Stjr *    documentation and/or other materials provided with the distribution.
13102697Stjr *
14118593Stjr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15102697Stjr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16102697Stjr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17118593Stjr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18102697Stjr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19102697Stjr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20102697Stjr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21102697Stjr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22102697Stjr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23102697Stjr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24102697Stjr * SUCH DAMAGE.
25102697Stjr */
26102697Stjr
27102697Stjr#include <sys/cdefs.h>
28102697Stjr__FBSDID("$FreeBSD: head/lib/libc/locale/mbstowcs.c 129179 2004-05-13 11:20:27Z tjr $");
29102697Stjr
30102697Stjr#include <stdlib.h>
31118593Stjr#include <wchar.h>
32129179Stjr#include "mblocal.h"
33102697Stjr
34102697Stjrsize_t
35106032Stjrmbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
36102697Stjr{
37127986Stjr	static const mbstate_t initial;
38127986Stjr	mbstate_t mbs;
39102697Stjr
40127986Stjr	mbs = initial;
41129179Stjr	return (__mbsrtowcs(pwcs, &s, n, &mbs));
42102697Stjr}
43