sscanf.c revision 1573
1219820Sjeff/*-
2331769Shselasky * Copyright (c) 1990, 1993
3219820Sjeff *	The Regents of the University of California.  All rights reserved.
4219820Sjeff *
5219820Sjeff * This code is derived from software contributed to Berkeley by
6219820Sjeff * Chris Torek.
7219820Sjeff *
8219820Sjeff * Redistribution and use in source and binary forms, with or without
9219820Sjeff * modification, are permitted provided that the following conditions
10219820Sjeff * are met:
11219820Sjeff * 1. Redistributions of source code must retain the above copyright
12219820Sjeff *    notice, this list of conditions and the following disclaimer.
13219820Sjeff * 2. Redistributions in binary form must reproduce the above copyright
14219820Sjeff *    notice, this list of conditions and the following disclaimer in the
15219820Sjeff *    documentation and/or other materials provided with the distribution.
16219820Sjeff * 3. All advertising materials mentioning features or use of this software
17219820Sjeff *    must display the following acknowledgement:
18219820Sjeff *	This product includes software developed by the University of
19219820Sjeff *	California, Berkeley and its contributors.
20219820Sjeff * 4. Neither the name of the University nor the names of its contributors
21219820Sjeff *    may be used to endorse or promote products derived from this software
22219820Sjeff *    without specific prior written permission.
23219820Sjeff *
24219820Sjeff * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25219820Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26219820Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27219820Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28219820Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29219820Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30219820Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31219820Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32219820Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33219820Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34331769Shselasky * SUCH DAMAGE.
35331769Shselasky */
36331769Shselasky
37331769Shselasky#if defined(LIBC_SCCS) && !defined(lint)
38331769Shselaskystatic char sccsid[] = "@(#)sscanf.c	8.1 (Berkeley) 6/4/93";
39331769Shselasky#endif /* LIBC_SCCS and not lint */
40219820Sjeff
41219820Sjeff#include <stdio.h>
42219820Sjeff#include <string.h>
43219820Sjeff#if __STDC__
44219820Sjeff#include <stdarg.h>
45219820Sjeff#else
46219820Sjeff#include <varargs.h>
47219820Sjeff#endif
48219820Sjeff#include "local.h"
49219820Sjeff
50219820Sjeff/* ARGSUSED */
51219820Sjeffstatic int
52219820Sjeffeofread(cookie, buf, len)
53219820Sjeff	void *cookie;
54219820Sjeff	char *buf;
55219820Sjeff	int len;
56219820Sjeff{
57219820Sjeff
58219820Sjeff	return (0);
59331769Shselasky}
60331769Shselasky
61331769Shselasky#if __STDC__
62331769Shselaskysscanf(const char *str, char const *fmt, ...)
63331769Shselasky#else
64331769Shselaskysscanf(str, fmt, va_alist)
65331769Shselasky	char *str;
66219820Sjeff	char *fmt;
67219820Sjeff	va_dcl
68219820Sjeff#endif
69219820Sjeff{
70219820Sjeff	int ret;
71219820Sjeff	va_list ap;
72219820Sjeff	FILE f;
73219820Sjeff
74219820Sjeff	f._flags = __SRD;
75219820Sjeff	f._bf._base = f._p = (unsigned char *)str;
76219820Sjeff	f._bf._size = f._r = strlen(str);
77219820Sjeff	f._read = eofread;
78219820Sjeff	f._ub._base = NULL;
79219820Sjeff	f._lb._base = NULL;
80219820Sjeff#if __STDC__
81219820Sjeff	va_start(ap, fmt);
82219820Sjeff#else
83219820Sjeff	va_start(ap);
84219820Sjeff#endif
85219820Sjeff	ret = __svfscanf(&f, fmt, ap);
86219820Sjeff	va_end(ap);
87219820Sjeff	return (ret);
88219820Sjeff}
89219820Sjeff