101ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes/* $OpenBSD: wscanf.c,v 1.2 2012/12/05 23:20:01 deraadt Exp $ */ 201ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes 301ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes/*- 401ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * Copyright (c) 2002 Tim J. Robbins 501ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * All rights reserved. 601ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * 701ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * Redistribution and use in source and binary forms, with or without 801ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * modification, are permitted provided that the following conditions 901ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * are met: 1001ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * 1. Redistributions of source code must retain the above copyright 1101ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * notice, this list of conditions and the following disclaimer. 1201ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * 2. Redistributions in binary form must reproduce the above copyright 1301ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * notice, this list of conditions and the following disclaimer in the 1401ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * documentation and/or other materials provided with the distribution. 1501ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * 1601ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1701ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1801ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1901ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2001ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2101ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2201ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2301ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2401ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2501ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2601ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes * SUCH DAMAGE. 2701ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes */ 2801ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes 2901ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes#include <stdarg.h> 3001ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes#include <stdio.h> 3101ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes#include <wchar.h> 3201ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes 3301ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughesint 3401ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hugheswscanf(const wchar_t * __restrict fmt, ...) 3501ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes{ 3601ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes va_list ap; 3701ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes int r; 3801ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes 3901ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes va_start(ap, fmt); 4001ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes r = vfwscanf(stdin, fmt, ap); 4101ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes va_end(ap); 4201ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes 4301ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes return (r); 4401ae00f3170ad0e36c1657f6ff8c89dfa730fd37Elliott Hughes} 45