xref: /freebsd/lib/libc/stdio/swscanf.c (revision 3c87aa1d3dc1d8dad3efad322852a8e1e76dee55)
11f4ff850STim J. Robbins /*-
21f4ff850STim J. Robbins  * Copyright (c) 2002 Tim J. Robbins
31f4ff850STim J. Robbins  * All rights reserved.
41f4ff850STim J. Robbins  *
5*3c87aa1dSDavid Chisnall  * Copyright (c) 2011 The FreeBSD Foundation
6*3c87aa1dSDavid Chisnall  * All rights reserved.
7*3c87aa1dSDavid Chisnall  * Portions of this software were developed by David Chisnall
8*3c87aa1dSDavid Chisnall  * under sponsorship from the FreeBSD Foundation.
9*3c87aa1dSDavid Chisnall  *
101f4ff850STim J. Robbins  * Redistribution and use in source and binary forms, with or without
111f4ff850STim J. Robbins  * modification, are permitted provided that the following conditions
121f4ff850STim J. Robbins  * are met:
131f4ff850STim J. Robbins  * 1. Redistributions of source code must retain the above copyright
141f4ff850STim J. Robbins  *    notice, this list of conditions and the following disclaimer.
151f4ff850STim J. Robbins  * 2. Redistributions in binary form must reproduce the above copyright
161f4ff850STim J. Robbins  *    notice, this list of conditions and the following disclaimer in the
171f4ff850STim J. Robbins  *    documentation and/or other materials provided with the distribution.
181f4ff850STim J. Robbins  *
191f4ff850STim J. Robbins  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
201f4ff850STim J. Robbins  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
211f4ff850STim J. Robbins  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
221f4ff850STim J. Robbins  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
231f4ff850STim J. Robbins  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
241f4ff850STim J. Robbins  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
251f4ff850STim J. Robbins  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
261f4ff850STim J. Robbins  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
271f4ff850STim J. Robbins  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
281f4ff850STim J. Robbins  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
291f4ff850STim J. Robbins  * SUCH DAMAGE.
301f4ff850STim J. Robbins  */
311f4ff850STim J. Robbins 
321f4ff850STim J. Robbins #include <sys/cdefs.h>
331f4ff850STim J. Robbins __FBSDID("$FreeBSD$");
341f4ff850STim J. Robbins 
351f4ff850STim J. Robbins #include <stdarg.h>
361f4ff850STim J. Robbins #include <stdio.h>
371f4ff850STim J. Robbins #include <wchar.h>
38*3c87aa1dSDavid Chisnall #include <xlocale.h>
391f4ff850STim J. Robbins 
401f4ff850STim J. Robbins int
411f4ff850STim J. Robbins swscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt, ...)
421f4ff850STim J. Robbins {
431f4ff850STim J. Robbins 	va_list ap;
441f4ff850STim J. Robbins 	int r;
451f4ff850STim J. Robbins 
461f4ff850STim J. Robbins 	va_start(ap, fmt);
471f4ff850STim J. Robbins 	r = vswscanf(str, fmt, ap);
481f4ff850STim J. Robbins 	va_end(ap);
491f4ff850STim J. Robbins 
501f4ff850STim J. Robbins 	return (r);
511f4ff850STim J. Robbins }
52*3c87aa1dSDavid Chisnall int
53*3c87aa1dSDavid Chisnall swscanf_l(const wchar_t * __restrict str, locale_t locale,
54*3c87aa1dSDavid Chisnall 		const wchar_t * __restrict fmt, ...)
55*3c87aa1dSDavid Chisnall {
56*3c87aa1dSDavid Chisnall 	va_list ap;
57*3c87aa1dSDavid Chisnall 	int r;
58*3c87aa1dSDavid Chisnall 
59*3c87aa1dSDavid Chisnall 	va_start(ap, fmt);
60*3c87aa1dSDavid Chisnall 	r = vswscanf_l(str, locale, fmt, ap);
61*3c87aa1dSDavid Chisnall 	va_end(ap);
62*3c87aa1dSDavid Chisnall 
63*3c87aa1dSDavid Chisnall 	return (r);
64*3c87aa1dSDavid Chisnall }
65