xref: /netbsd-src/lib/libc/stdio/wscanf.c (revision 9790c07a61e7977e601194d4a83c50a66bbb4a34)
1*9790c07aSjoerg /*	$NetBSD: wscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $	*/
2f432bbb6Schristos 
3f432bbb6Schristos /*-
4f432bbb6Schristos  * Copyright (c) 2002 Tim J. Robbins
5f432bbb6Schristos  * All rights reserved.
6f432bbb6Schristos  *
7f432bbb6Schristos  * Redistribution and use in source and binary forms, with or without
8f432bbb6Schristos  * modification, are permitted provided that the following conditions
9f432bbb6Schristos  * are met:
10f432bbb6Schristos  * 1. Redistributions of source code must retain the above copyright
11f432bbb6Schristos  *    notice, this list of conditions and the following disclaimer.
12f432bbb6Schristos  * 2. Redistributions in binary form must reproduce the above copyright
13f432bbb6Schristos  *    notice, this list of conditions and the following disclaimer in the
14f432bbb6Schristos  *    documentation and/or other materials provided with the distribution.
15f432bbb6Schristos  *
16f432bbb6Schristos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17f432bbb6Schristos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18f432bbb6Schristos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19f432bbb6Schristos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20f432bbb6Schristos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21f432bbb6Schristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22f432bbb6Schristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23f432bbb6Schristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24f432bbb6Schristos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25f432bbb6Schristos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26f432bbb6Schristos  * SUCH DAMAGE.
27f432bbb6Schristos  */
28f432bbb6Schristos 
29f432bbb6Schristos #include <sys/cdefs.h>
30f432bbb6Schristos #if defined(LIBC_SCCS) && !defined(lint)
31f432bbb6Schristos #if 0
32f432bbb6Schristos __FBSDID("$FreeBSD: src/lib/libc/stdio/wscanf.c,v 1.1 2002/09/23 12:40:06 tjr Exp $");
33f432bbb6Schristos #else
34*9790c07aSjoerg __RCSID("$NetBSD: wscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $");
35f432bbb6Schristos #endif
36f432bbb6Schristos #endif /* LIBC_SCCS and not lint */
37f432bbb6Schristos 
38*9790c07aSjoerg #include "namespace.h"
39*9790c07aSjoerg 
40f432bbb6Schristos #include <stdarg.h>
41f432bbb6Schristos #include <stdio.h>
42f432bbb6Schristos #include <wchar.h>
43f432bbb6Schristos 
__weak_alias(wscanf_l,_wscanf_l)44*9790c07aSjoerg __weak_alias(wscanf_l, _wscanf_l)
45*9790c07aSjoerg 
46f432bbb6Schristos int
47f432bbb6Schristos wscanf(const wchar_t * __restrict fmt, ...)
48f432bbb6Schristos {
49f432bbb6Schristos 	va_list ap;
50f432bbb6Schristos 	int r;
51f432bbb6Schristos 
52f432bbb6Schristos 	va_start(ap, fmt);
53f432bbb6Schristos 	r = vfwscanf(stdin, fmt, ap);
54f432bbb6Schristos 	va_end(ap);
55f432bbb6Schristos 
56526d9427Schristos 	return r;
57f432bbb6Schristos }
58*9790c07aSjoerg 
59*9790c07aSjoerg int
wscanf_l(locale_t loc,const wchar_t * __restrict fmt,...)60*9790c07aSjoerg wscanf_l(locale_t loc, const wchar_t * __restrict fmt, ...)
61*9790c07aSjoerg {
62*9790c07aSjoerg 	va_list ap;
63*9790c07aSjoerg 	int r;
64*9790c07aSjoerg 
65*9790c07aSjoerg 	va_start(ap, fmt);
66*9790c07aSjoerg 	r = vfwscanf_l(stdin, loc, fmt, ap);
67*9790c07aSjoerg 	va_end(ap);
68*9790c07aSjoerg 
69*9790c07aSjoerg 	return r;
70*9790c07aSjoerg }
71