1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
24 /* Read formated data from a stream
26 ** Written by Kiem-Phong Vo.
30 int sfscanf(Sfio_t
* f
, const char* form
, ...)
45 f
= va_arg(args
,Sfio_t
*);
46 form
= va_arg(args
,char*);
49 rv
= (f
&& form
) ? sfvscanf(f
,form
,args
) : -1;
55 int sfvsscanf(const char* s
, const char* form
, va_list args
)
57 int sfvsscanf(s
, form
, args
)
68 /* make a fake stream */
69 SFCLEAR(&f
,NIL(Vtmutex_t
*));
70 f
.flags
= SF_STRING
|SF_READ
;
73 f
.size
= strlen((char*)s
);
74 f
.data
= f
.next
= f
.endw
= (uchar
*)s
;
75 f
.endb
= f
.endr
= f
.data
+f
.size
;
77 return sfvscanf(&f
,form
,args
);
81 int sfsscanf(const char* s
, const char* form
,...)
83 int sfsscanf(va_alist
)
95 s
= va_arg(args
,char*);
96 form
= va_arg(args
,char*);
99 rv
= (s
&& form
) ? sfvsscanf(s
,form
,args
) : -1;