Files
cdesktop/cde/programs/dtksh/ksh93/src/lib/libast/sfio/sfscanf.c
2019-08-20 12:52:43 +02:00

114 lines
3.3 KiB
C

/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: sfscanf.c /main/3 1995/11/01 18:35:22 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
* AT&T CORP. *
* *
* Copyright (c) 1995 AT&T Corp. *
* All Rights Reserved *
* *
* This software is licensed by AT&T Corp. *
* under the terms and conditions of the license in *
* http://www.research.att.com/orgs/ssr/book/reuse *
* *
* This software was created by the *
* Software Engineering Research Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* gsf@research.att.com *
* *
***************************************************************/
#include "sfhdr.h"
/* Read formatted data from a stream
**
** Written by Kiem-Phong Vo (06/27/90)
*/
#if __STD_C
int sfscanf(Sfio_t *f, const char *form, ...)
#else
sfscanf(va_alist)
va_dcl
#endif
{
va_list args;
reg int rv;
#if __STD_C
va_start(args,form);
#else
reg Sfio_t *f;
reg char *form;
va_start(args);
f = va_arg(args,Sfio_t*);
form = va_arg(args,char*);
#endif
rv = sfvscanf(f,form,args);
va_end(args);
return rv;
}
#if __STD_C
int sfsscanf(const char *s, const char *form,...)
#else
sfsscanf(va_alist)
va_dcl
#endif
{
va_list args;
Sfio_t f;
reg int rv;
#if __STD_C
va_start(args,form);
#else
reg char *s;
reg char *form;
va_start(args);
s = va_arg(args,char*);
form = va_arg(args,char*);
#endif
if(!s)
return -1;
/* make a fake stream */
SFCLEAR(&f);
f.flags = SF_STRING|SF_READ;
f.mode = SF_READ;
f.size = strlen((char*)s);
f.data = f.next = f.endw = (uchar*)s;
f.endb = f.endr = f.data+f.size;
rv = sfvscanf(&f,form,args);
va_end(args);
return rv;
}