xref: /csrg-svn/lib/libc/stdio/sscanf.c (revision 46111)
1*46111Sbostic /*-
2*46111Sbostic  * Copyright (c) 1990 The Regents of the University of California.
3*46111Sbostic  * All rights reserved.
4*46111Sbostic  *
5*46111Sbostic  * This code is derived from software contributed to Berkeley by
6*46111Sbostic  * Chris Torek.
7*46111Sbostic  *
8*46111Sbostic  * %sccs.include.redist.c%
9*46111Sbostic  */
10*46111Sbostic 
11*46111Sbostic #if defined(LIBC_SCCS) && !defined(lint)
12*46111Sbostic static char sccsid[] = "@(#)sscanf.c	5.1 (Berkeley) 01/20/91";
13*46111Sbostic #endif /* LIBC_SCCS and not lint */
14*46111Sbostic 
15*46111Sbostic #include <stdio.h>
16*46111Sbostic #include <string.h>
17*46111Sbostic #if __STDC__
18*46111Sbostic #include <stdarg.h>
19*46111Sbostic #else
20*46111Sbostic #include <varargs.h>
21*46111Sbostic #endif
22*46111Sbostic #include "local.h"
23*46111Sbostic 
24*46111Sbostic /* ARGSUSED */
25*46111Sbostic static int
26*46111Sbostic eofread(cookie, buf, len)
27*46111Sbostic 	void *cookie;
28*46111Sbostic 	char *buf;
29*46111Sbostic 	int len;
30*46111Sbostic {
31*46111Sbostic 
32*46111Sbostic 	return (0);
33*46111Sbostic }
34*46111Sbostic 
35*46111Sbostic #if __STDC__
36*46111Sbostic sscanf(char *str, char const *fmt, ...)
37*46111Sbostic #else
38*46111Sbostic sscanf(str, fmt, va_alist)
39*46111Sbostic 	char *str;
40*46111Sbostic 	char *fmt;
41*46111Sbostic 	va_dcl
42*46111Sbostic #endif
43*46111Sbostic {
44*46111Sbostic 	int ret;
45*46111Sbostic 	va_list ap;
46*46111Sbostic 	FILE f;
47*46111Sbostic 
48*46111Sbostic 	f._flags = __SRD;
49*46111Sbostic 	f._bf._base = f._p = (unsigned char *)str;
50*46111Sbostic 	f._bf._size = f._r = strlen(str);
51*46111Sbostic 	f._read = eofread;
52*46111Sbostic 	f._ub._base = NULL;
53*46111Sbostic 	f._lb._base = NULL;
54*46111Sbostic #if __STDC__
55*46111Sbostic 	va_start(ap, fmt);
56*46111Sbostic #else
57*46111Sbostic 	va_start(ap);
58*46111Sbostic #endif
59*46111Sbostic 	ret = __svfscanf(&f, fmt, ap);
60*46111Sbostic 	va_end(ap);
61*46111Sbostic 	return (ret);
62*46111Sbostic }
63