11f4ff850STim J. Robbins /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3d915a14eSPedro F. Giffuni *
41f4ff850STim J. Robbins * Copyright (c) 2002 Tim J. Robbins
51f4ff850STim J. Robbins * All rights reserved.
61f4ff850STim J. Robbins *
73c87aa1dSDavid Chisnall * Copyright (c) 2011 The FreeBSD Foundation
85b5fa75aSEd Maste *
93c87aa1dSDavid Chisnall * Portions of this software were developed by David Chisnall
103c87aa1dSDavid Chisnall * under sponsorship from the FreeBSD Foundation.
113c87aa1dSDavid Chisnall *
121f4ff850STim J. Robbins * Redistribution and use in source and binary forms, with or without
131f4ff850STim J. Robbins * modification, are permitted provided that the following conditions
141f4ff850STim J. Robbins * are met:
151f4ff850STim J. Robbins * 1. Redistributions of source code must retain the above copyright
161f4ff850STim J. Robbins * notice, this list of conditions and the following disclaimer.
171f4ff850STim J. Robbins * 2. Redistributions in binary form must reproduce the above copyright
181f4ff850STim J. Robbins * notice, this list of conditions and the following disclaimer in the
191f4ff850STim J. Robbins * documentation and/or other materials provided with the distribution.
201f4ff850STim J. Robbins *
211f4ff850STim J. Robbins * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
221f4ff850STim J. Robbins * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231f4ff850STim J. Robbins * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241f4ff850STim J. Robbins * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
251f4ff850STim J. Robbins * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261f4ff850STim J. Robbins * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271f4ff850STim J. Robbins * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281f4ff850STim J. Robbins * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291f4ff850STim J. Robbins * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301f4ff850STim J. Robbins * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311f4ff850STim J. Robbins * SUCH DAMAGE.
321f4ff850STim J. Robbins */
331f4ff850STim J. Robbins
341f4ff850STim J. Robbins #include <stdarg.h>
351f4ff850STim J. Robbins #include <stdio.h>
361f4ff850STim J. Robbins #include <wchar.h>
373c87aa1dSDavid Chisnall #include <xlocale.h>
381f4ff850STim J. Robbins
391f4ff850STim J. Robbins int
wscanf(const wchar_t * __restrict fmt,...)401f4ff850STim J. Robbins wscanf(const wchar_t * __restrict fmt, ...)
411f4ff850STim J. Robbins {
421f4ff850STim J. Robbins va_list ap;
431f4ff850STim J. Robbins int r;
441f4ff850STim J. Robbins
451f4ff850STim J. Robbins va_start(ap, fmt);
461f4ff850STim J. Robbins r = vfwscanf(stdin, fmt, ap);
471f4ff850STim J. Robbins va_end(ap);
481f4ff850STim J. Robbins
491f4ff850STim J. Robbins return (r);
501f4ff850STim J. Robbins }
513c87aa1dSDavid Chisnall int
wscanf_l(locale_t locale,const wchar_t * __restrict fmt,...)523c87aa1dSDavid Chisnall wscanf_l(locale_t locale, const wchar_t * __restrict fmt, ...)
533c87aa1dSDavid Chisnall {
543c87aa1dSDavid Chisnall va_list ap;
553c87aa1dSDavid Chisnall int r;
563c87aa1dSDavid Chisnall
573c87aa1dSDavid Chisnall va_start(ap, fmt);
583c87aa1dSDavid Chisnall r = vfwscanf_l(stdin, locale, fmt, ap);
593c87aa1dSDavid Chisnall va_end(ap);
603c87aa1dSDavid Chisnall
613c87aa1dSDavid Chisnall return (r);
623c87aa1dSDavid Chisnall }
63