vsscanf.c revision 200799
1198157Srrs/*- 2198157Srrs * Copyright (c) 1990, 1993 3198157Srrs * The Regents of the University of California. All rights reserved. 4198157Srrs * 5198157Srrs * This code is derived from software contributed to Berkeley by 6198157Srrs * Donn Seeley at UUNET Technologies, Inc. 7198157Srrs * 8198157Srrs * Redistribution and use in source and binary forms, with or without 9198157Srrs * modification, are permitted provided that the following conditions 10198157Srrs * are met: 11198157Srrs * 1. Redistributions of source code must retain the above copyright 12198157Srrs * notice, this list of conditions and the following disclaimer. 13198157Srrs * 2. Redistributions in binary form must reproduce the above copyright 14198157Srrs * notice, this list of conditions and the following disclaimer in the 15198157Srrs * documentation and/or other materials provided with the distribution. 16198157Srrs * 4. Neither the name of the University nor the names of its contributors 17198157Srrs * may be used to endorse or promote products derived from this software 18198157Srrs * without specific prior written permission. 19198157Srrs * 20198157Srrs * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21198157Srrs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22198157Srrs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23198157Srrs * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24198157Srrs * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25198157Srrs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26198157Srrs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27198157Srrs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28198157Srrs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29198157Srrs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30198157Srrs * SUCH DAMAGE. 31198157Srrs */ 32198157Srrs 33198157Srrs#if defined(LIBC_SCCS) && !defined(lint) 34198157Srrsstatic char sccsid[] = "@(#)vsscanf.c 8.1 (Berkeley) 6/4/93"; 35198157Srrs#endif /* LIBC_SCCS and not lint */ 36198157Srrs#include <sys/cdefs.h> 37198157Srrs__FBSDID("$FreeBSD: head/lib/libc/stdio/vsscanf.c 200799 2009-12-21 19:55:05Z delphij $"); 38198626Srrs 39198157Srrs#include <stdio.h> 40198157Srrs#include <string.h> 41198626Srrs#include "local.h" 42198157Srrs 43198157Srrsstatic int 44198626Srrseofread(void *, char *, int); 45198157Srrs 46198157Srrs/* ARGSUSED */ 47198157Srrsstatic int 48198626Srrseofread(void *cookie, char *buf, int len) 49198157Srrs{ 50198626Srrs 51198626Srrs return (0); 52198626Srrs} 53198157Srrs 54198157Srrsint 55198626Srrsvsscanf(const char * __restrict str, const char * __restrict fmt, 56198626Srrs __va_list ap) 57198626Srrs{ 58198626Srrs FILE f; 59198626Srrs 60198157Srrs f._file = -1; 61198157Srrs f._flags = __SRD; 62198157Srrs f._bf._base = f._p = (unsigned char *)str; 63198157Srrs f._bf._size = f._r = strlen(str); 64198157Srrs f._read = eofread; 65198157Srrs f._ub._base = NULL; 66198157Srrs f._lb._base = NULL; 67198157Srrs f._orientation = 0; 68198157Srrs memset(&f._mbstate, 0, sizeof(mbstate_t)); 69198157Srrs return (__svfscanf(&f, fmt, ap)); 70198157Srrs} 71198157Srrs