/*
 * |-----------------------------------------------------------|
 * | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc.      |
 * | All Rights Reserved                                       |
 * |-----------------------------------------------------------|
 * |          Restricted Rights Legend                         |
 * | Use, duplication, or disclosure by the Government is      |
 * | subject to restrictions as set forth in                   |
 * | subparagraph (c)(1)(ii) of the Rights in Technical        |
 * | Data and Computer Software Clause of DFARS 252.227-7013.  |
 * |         MIPS Computer Systems, Inc.                       |
 * |         950 DeGuigne Avenue                               |
 * |         Sunnyvale, California 94088-3650, USA             |
 * |-----------------------------------------------------------|
 */
#ident	"$Header: scanf.c,v 1.10.2.1 92/06/24 14:01:42 marker Exp $"

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

/*LINTLIBRARY*/
#include <stdio.h>
#if defined(__STDC__)
#include <stdarg.h>
#else  /* __STDC__ */
#include <varargs.h>
#endif
#include <errno.h>

extern int _doscan();

/*VARARGS1*/
#if defined(__STDC__)
int scanf(
    const char *fmt,
    ...)
#else  /* __STDC__ */
int
scanf(fmt, va_alist)
char *fmt;
va_dcl
#endif /* __STDC__ */
{
	va_list ap;

#if defined(__STDC__)
	va_start(ap, fmt);
#else
	va_start(ap);
#endif /* __STDC__ */
	return(_doscan(stdin, fmt, ap));
}

/*VARARGS2*/
#if defined(__STDC__)
int   fscanf(
      FILE *iop,
      const  char *fmt,
      ...)
#else  /* __STDC__ */
int
fscanf(iop, fmt, va_alist)
FILE *iop;
char *fmt;
va_dcl
#endif /*  __STDC__ */
{
	va_list ap;

#ifdef        SYSTYPE_POSIX
        /* Check for write only file */
        if (stdin->_flag & _IOWRT) {
                errno = EBADF;
                return EOF;
        }
#endif

#if defined(__STDC__)
	va_start(ap, fmt);
#else
	va_start(ap);
#endif /* __STDC__ */
	return(_doscan(iop, fmt, ap));
}

/*VARARGS2*/
#if defined(__STDC__)
int   sscanf(
      const char *str,
      const char *fmt,
      ...)
#else /*  __STDC__ */
int sscanf(str, fmt, va_alist)
    register char *str;
    char *fmt;
    va_dcl
#endif /*  __STDC__ */
{
	va_list ap;
	FILE strbuf;

#if defined(__STDC__)
	va_start(ap, fmt);
#else
	va_start(ap);
#endif /* __STDC__ */
	strbuf._flag = _IOREAD;
	strbuf._ptr = strbuf._base = (unsigned char*)str;
	strbuf._cnt = strlen(str);
	strbuf._file = _NFILE;
	return(_doscan(&strbuf, fmt, ap));
}
