vsscanf.c revision 227753
1102909Sjhb/*- 2318Srgrimes * Copyright (c) 1990, 1993 362114Speter * The Regents of the University of California. All rights reserved. 4318Srgrimes * 561640Speter * Copyright (c) 2011 The FreeBSD Foundation 6102909Sjhb * All rights reserved. 761640Speter * Portions of this software were developed by David Chisnall 861640Speter * under sponsorship from the FreeBSD Foundation. 999812Sbde * 1061640Speter * This code is derived from software contributed to Berkeley by 1161640Speter * Donn Seeley at UUNET Technologies, Inc. 1265639Salex * 1365639Salex * Redistribution and use in source and binary forms, with or without 1465639Salex * modification, are permitted provided that the following conditions 1593731Sjhb * are met: 1693731Sjhb * 1. Redistributions of source code must retain the above copyright 1793731Sjhb * notice, this list of conditions and the following disclaimer. 18102909Sjhb * 2. Redistributions in binary form must reproduce the above copyright 19318Srgrimes * notice, this list of conditions and the following disclaimer in the 20102909Sjhb * documentation and/or other materials provided with the distribution. 21102909Sjhb * 4. Neither the name of the University nor the names of its contributors 22102909Sjhb * may be used to endorse or promote products derived from this software 23102909Sjhb * without specific prior written permission. 24102909Sjhb * 25102909Sjhb * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26102909Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27102909Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28102909Sjhb * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29102909Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30128514Sbde * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31102909Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32121595Snjl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33102909Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34102909Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35102909Sjhb * SUCH DAMAGE. 36121595Snjl */ 37102909Sjhb 38318Srgrimes#if defined(LIBC_SCCS) && !defined(lint) 393743Swollmanstatic char sccsid[] = "@(#)vsscanf.c 8.1 (Berkeley) 6/4/93"; 403743Swollman#endif /* LIBC_SCCS and not lint */ 413743Swollman#include <sys/cdefs.h> 423743Swollman__FBSDID("$FreeBSD: head/lib/libc/stdio/vsscanf.c 227753 2011-11-20 14:45:42Z theraven $"); 43318Srgrimes 443743Swollman#include <stdio.h> 453743Swollman#include <string.h> 463743Swollman#include "local.h" 47112498Sru#include "xlocale_private.h" 48112498Sru 49112498Srustatic int 503743Swollmaneofread(void *, char *, int); 51318Srgrimes 523743Swollman/* ARGSUSED */ 533743Swollmanstatic int 5445681Spetereofread(void *cookie, char *buf, int len) 5551898Sbde{ 5651898Sbde 5751898Sbde return (0); 5851898Sbde} 59161567Sru 6051898Sbdeint 6151898Sbdevsscanf_l(const char * __restrict str, locale_t locale, 6245681Speter const char * __restrict fmt, __va_list ap) 6345681Speter{ 6445681Speter FILE f = FAKE_FILE; 6545681Speter FIX_LOCALE(locale); 6645681Speter 6745681Speter f._flags = __SRD; 6846840Speter f._bf._base = f._p = (unsigned char *)str; 6946840Speter f._bf._size = f._r = strlen(str); 7046840Speter f._read = eofread; 7185117Simp return (__svfscanf(&f, locale, fmt, ap)); 7285117Simp} 7351898Sbdeint 7446037Spetervsscanf(const char * __restrict str, const char * __restrict fmt, 7546840Speter __va_list ap) 76158349Snetchild{ 77158349Snetchild return vsscanf_l(str, __get_locale(), fmt, ap); 78110539Sphk} 7945681Speter