mbsrtowcs.c revision 132497
1124208Sdes/*- 2124208Sdes * Copyright (c) 2002-2004 Tim J. Robbins. 3124208Sdes * All rights reserved. 4124208Sdes * 5124208Sdes * Redistribution and use in source and binary forms, with or without 6124208Sdes * modification, are permitted provided that the following conditions 7124208Sdes * are met: 8124208Sdes * 1. Redistributions of source code must retain the above copyright 9124208Sdes * notice, this list of conditions and the following disclaimer. 10124208Sdes * 2. Redistributions in binary form must reproduce the above copyright 11124208Sdes * notice, this list of conditions and the following disclaimer in the 12124208Sdes * documentation and/or other materials provided with the distribution. 13124208Sdes * 14124208Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15124208Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16124208Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17124208Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18124208Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19124208Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20124208Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21124208Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22124208Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23124208Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24124208Sdes * SUCH DAMAGE. 2598937Sdes */ 2698937Sdes 2798937Sdes#include <sys/cdefs.h> 28295367Sdes__FBSDID("$FreeBSD: head/lib/libc/locale/mbsrtowcs.c 132497 2004-07-21 10:54:57Z tjr $"); 2998937Sdes 3098937Sdes#include <errno.h> 3198937Sdes#include <limits.h> 3298937Sdes#include <stdlib.h> 33162852Sdes#include <wchar.h> 3498937Sdes#include "mblocal.h" 3598937Sdes 3698937Sdessize_t 3798937Sdesmbsrtowcs(wchar_t * __restrict dst, const char ** __restrict src, size_t len, 3898937Sdes mbstate_t * __restrict ps) 3998937Sdes{ 4098937Sdes static mbstate_t mbs; 4198937Sdes 4298937Sdes if (ps == NULL) 4398937Sdes ps = &mbs; 4498937Sdes return (__mbsnrtowcs(dst, src, SIZE_T_MAX, len, ps)); 45221420Sdes} 46323124Sdes