/*
 * |-----------------------------------------------------------|
 * | 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             |
 * |-----------------------------------------------------------|
 */
/* $Header: stdio.h,v 1.24.1.1 92/06/24 13:57:12 marker Exp $ */


#ifndef	_STDIO_
#define	_STDIO_	1


/*	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.	*/

#ifndef _NFILE
#define _NFILE	100

#if defined(__STDC__)
#ifndef _VA_LIST_
#define _VA_LIST_
typedef char *va_list;
#endif  /* _VA_LIST_ */

/*  New Ansi C macros  */
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned int    size_t;
#endif

#ifndef SEEK_SET
#define SEEK_SET        0       /* Set file pointer to "offset" */
#endif

#ifndef SEEK_CUR
#define SEEK_CUR        1       /* Set file pointer to current plus "offset" */
#endif

#ifndef SEEK_END
#define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
#endif

#endif /* __STDC__ */

#if defined (mips) || defined (__mips)
#define BUFSIZ	4096
#endif
#if u370
#define BUFSIZ	4096
#endif
#if vax || u3b || M32 || u3b15 || u3b5 || u3b2
#define BUFSIZ	1024
#endif
#if pdp11
#define BUFSIZ	512
#endif

/* buffer size for multi-character output to unbuffered files */
#define _SBFSIZ 8

typedef struct {
#if vax || u3b || M32 || u3b15 || u3b5 || u3b2 || mips || __mips
	int	_cnt;
	unsigned char	*_ptr;
#else
	unsigned char	*_ptr;
	int	_cnt;
#endif
	unsigned char	*_base;
	char	_flag;
	char	_file;
} FILE;

/*
 * _IOLBF means that a file's output will be buffered line by line
 * In addition to being flags, _IONBF, _IOLBF and _IOFBF are possible
 * values for "type" in setvbuf.
 */
#define _IOFBF		0000
#define _IOREAD		0001
#define _IOWRT		0002
#define _IONBF		0004
#define _IOMYBUF	0010
#define _IOEOF		0020
#define _IOERR		0040
#define _IOLBF		0100
#define _IORW		0200

#ifndef NULL
#define NULL		0
#endif
#ifndef EOF
#define EOF		(-1)
#endif

#if defined(__STDC__)

#define FILENAME_MAX	1024  /* corresponds to PATH_MAX in limits.h of posix */
#define FOPEN_MAX	100   /* corresponds to OPEN_MAX in limits.h of posix */
typedef  long fpos_t;

/* Symbolic constants for the "lseek" routine: */
/* may cause name conflict with posix headers  */
#define TMP_MAX		17576	/* minimum number of unique file names   */
#endif  /* __STDC__ */


#define stdin		(&_iob[0])
#define stdout		(&_iob[1])
#define stderr		(&_iob[2])

#define _bufend(p)	_bufendtab[(p)->_file]
#define _bufsiz(p)	(_bufend(p) - (p)->_base)


#if defined(__STDC__)

extern void	clearerr(FILE *);
extern int 	feof(FILE *);
extern int 	ferror(FILE *);
#ifndef _REMOVE_
extern int	remove(const char *);
#endif
extern int	rename(const char *, const char *);
extern FILE     *tmpfile(void);
extern char     *tmpnam(char *);
extern int	fclose(FILE *);
extern int	fflush(FILE *);
extern FILE     *fopen(const char *, const char *);
extern FILE     *freopen(const char *, const char *, FILE *);
extern void	setbuf(FILE *, char *);
extern int	setvbuf(FILE *, char *, int, size_t);
extern int	fprintf(FILE *, const char *, ...);
extern int	fscanf(FILE *, const char *, ...);
extern int	printf(const char *, ...);
extern int	scanf(const char *, ...);
extern int	sprintf(char *, const char *, ...);
extern int	sscanf(const char *, const char *, ...);
extern int	vfprintf(FILE *, const char *, va_list);
extern int	vprintf(const char *, va_list);
extern int	vsprintf(char *, const char *, va_list);
extern int	fgetc(FILE *);
extern char     *gets(char *);
extern char     *fgets(char *, int, FILE *);
extern int	fputc(int, FILE *);
extern int	fputs(const char *, FILE *);
extern int	puts(const char *);
extern int	ungetc(int, FILE *);
extern size_t	fread(void *, size_t, size_t, FILE *);
extern size_t	fwrite(const void *, size_t, size_t, FILE *);
extern int	fgetpos(FILE *, fpos_t *);
extern int	fseek(FILE *, long, int);
extern int	fsetpos(FILE *, const fpos_t *);
extern long int	ftell(FILE *);
extern void	rewind(FILE *);
extern void	perror(const char *);
#else  /* __STDC__ */

extern FILE	*fopen(), *freopen(), *tmpfile();
extern long	ftell();
extern void	rewind(), setbuf();
extern char	*fgets(), *gets(), *tempnam(), *tmpnam();
extern int	fclose(), fflush(), fread(), fwrite(), fseek(), fgetc(),
		    printf(), fprintf(), sprintf(),
		    vprintf(), vfprintf(), vsprintf(), fputc(),
		    puts(), fputs(), scanf(), fscanf(), sscanf(),
		    setvbuf(), ungetc();
#endif /* __STDC__ */

#ifndef lint
#define getc(p)		(--(p)->_cnt < 0 ? _filbuf(p) : (int) *(p)->_ptr++)
#define putc(x, p)	(--(p)->_cnt < 0 ? \
			_flsbuf((unsigned char) (x), (p)) : \
			(int) (*(p)->_ptr++ = (unsigned char) (x)))
#define getchar()	getc(stdin)
#define putchar(x)	putc((x), stdout)
#define clearerr(p)	((void) ((p)->_flag &= ~(_IOERR | _IOEOF)))
#define feof(p)		((p)->_flag & _IOEOF)
#define ferror(p)	((p)->_flag & _IOERR)
#define fileno(p)	(p)->_file
#endif

#if defined(__STDC__)
#if (__STDC__ == 0)
#define L_ctermid	9
#define L_cuserid	9
#define P_tmpdir	"/usr/tmp/"
extern char	        *ctermid(char *);
extern char	        *cuserid(char *);
extern FILE		*fdopen(int, char *);
extern FILE             *popen(char *, char *);
extern int              pclose(FILE *);
extern int              putw(int, FILE *);

#endif
#else /* defined(__STDC__) */

#define L_ctermid	9
#define L_cuserid	9
#define P_tmpdir	"/usr/tmp/"
extern char	        *ctermid(), *cuserid();
extern FILE		*fdopen();
extern int              getw();
extern FILE             *popen();
extern int              pclose();
extern int              putw();

#endif
#define L_tmpnam	25 /* (sizeof(P_tmpdir) + 15) */
extern unsigned char *_bufendtab[];
extern FILE	_iob[];
#ifndef         __SYSTEM__
#define         __SYSTEM__
#if defined (__STDC__)
extern int      system (const char *);
#else /* __STDC__ */
extern int	system();
#endif /* __STDC__ */
#endif		/* __SYSTEM__ */

#endif

#endif	/* _STDIO_ */
