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 <sys/cdefs.h> 351f4ff850STim J. Robbins __FBSDID("$FreeBSD$"); 361f4ff850STim J. Robbins 371f4ff850STim J. Robbins #include <stdarg.h> 381f4ff850STim J. Robbins #include <stdio.h> 391f4ff850STim J. Robbins #include <wchar.h> 403c87aa1dSDavid Chisnall #include <xlocale.h> 411f4ff850STim J. Robbins 421f4ff850STim J. Robbins int 431f4ff850STim J. Robbins fwscanf(FILE * __restrict fp, const wchar_t * __restrict fmt, ...) 441f4ff850STim J. Robbins { 451f4ff850STim J. Robbins va_list ap; 461f4ff850STim J. Robbins int r; 471f4ff850STim J. Robbins 481f4ff850STim J. Robbins va_start(ap, fmt); 491f4ff850STim J. Robbins r = vfwscanf(fp, fmt, ap); 501f4ff850STim J. Robbins va_end(ap); 511f4ff850STim J. Robbins 521f4ff850STim J. Robbins return (r); 531f4ff850STim J. Robbins } 543c87aa1dSDavid Chisnall int 553c87aa1dSDavid Chisnall fwscanf_l(FILE * __restrict fp, locale_t locale, const wchar_t * __restrict fmt, ...) 563c87aa1dSDavid Chisnall { 573c87aa1dSDavid Chisnall va_list ap; 583c87aa1dSDavid Chisnall int r; 593c87aa1dSDavid Chisnall 603c87aa1dSDavid Chisnall va_start(ap, fmt); 613c87aa1dSDavid Chisnall r = vfwscanf_l(fp, locale, fmt, ap); 623c87aa1dSDavid Chisnall va_end(ap); 633c87aa1dSDavid Chisnall 643c87aa1dSDavid Chisnall return (r); 653c87aa1dSDavid Chisnall } 66