mbstowcs.c revision 127986
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 127986 2004-04-07 08:33:23Z tjr $"); 29102697Stjr 30102697Stjr#include <stdlib.h> 31118593Stjr#include <wchar.h> 32102697Stjr 33102697Stjrsize_t 34106032Stjrmbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n) 35102697Stjr{ 36127986Stjr static const mbstate_t initial; 37127986Stjr mbstate_t mbs; 38102697Stjr 39127986Stjr mbs = initial; 40127944Stjr return (mbsrtowcs(pwcs, &s, n, &mbs)); 41102697Stjr} 42