wcsrtombs.c revision 256281
1166435Sjhb/*- 2173228Sjhb * Copyright (c) 2002-2004 Tim J. Robbins. 3166435Sjhb * All rights reserved. 4173228Sjhb * 5166435Sjhb * Copyright (c) 2011 The FreeBSD Foundation 6166435Sjhb * All rights reserved. 7166435Sjhb * Portions of this software were developed by David Chisnall 8166435Sjhb * under sponsorship from the FreeBSD Foundation. 9166435Sjhb * 10166435Sjhb * Redistribution and use in source and binary forms, with or without 11166435Sjhb * modification, are permitted provided that the following conditions 12166435Sjhb * are met: 13166435Sjhb * 1. Redistributions of source code must retain the above copyright 14166435Sjhb * notice, this list of conditions and the following disclaimer. 15166435Sjhb * 2. Redistributions in binary form must reproduce the above copyright 16166435Sjhb * notice, this list of conditions and the following disclaimer in the 17166435Sjhb * documentation and/or other materials provided with the distribution. 18166435Sjhb * 19166435Sjhb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20166435Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21166435Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22166435Sjhb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23166435Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24166435Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25166435Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26166435Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27166435Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28166435Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29166435Sjhb * SUCH DAMAGE. 30166435Sjhb */ 31166435Sjhb 32166435Sjhb#include <sys/cdefs.h> 33166435Sjhb__FBSDID("$FreeBSD: stable/10/lib/libc/locale/wcsrtombs.c 227753 2011-11-20 14:45:42Z theraven $"); 34166435Sjhb 35166435Sjhb#include <limits.h> 36166435Sjhb#include <stdlib.h> 37166435Sjhb#include <string.h> 38166435Sjhb#include <wchar.h> 39166435Sjhb#include "mblocal.h" 40166435Sjhb 41166435Sjhbsize_t 42166435Sjhbwcsrtombs_l(char * __restrict dst, const wchar_t ** __restrict src, size_t len, 43173576Sjb mbstate_t * __restrict ps, locale_t locale) 44166435Sjhb{ 45166435Sjhb FIX_LOCALE(locale); 46166435Sjhb if (ps == NULL) 47166435Sjhb ps = &locale->wcsrtombs; 48212326Sjhb return (XLOCALE_CTYPE(locale)->__wcsnrtombs(dst, src, SIZE_T_MAX, len, ps)); 49212326Sjhb} 50166435Sjhb 51166435Sjhbsize_t 52166435Sjhbwcsrtombs(char * __restrict dst, const wchar_t ** __restrict src, size_t len, 53166435Sjhb mbstate_t * __restrict ps) 54166435Sjhb{ 55166435Sjhb return wcsrtombs_l(dst, src, len, ps, __get_locale()); 56166435Sjhb} 57166435Sjhb