*
 *
 * Module stdio.h  V012AM02 === 040491
 *
 * 040491 012A02 rjs  added fdopen prototype
 * 061390 011I01 sbw  size_t in fread and fwrite prototypes
 * 080989 011F01 sbw  Prototype for fgetc
 * 042788 010G01 rma  fix putc macro (garbled redirected output)
 * 091487 010A01 rma  initial submittal
 *
 *
 *    PROPRIETARY PROGRAM MATERIAL
 * REPRODUCTION OR DISCLOSURE IS PROHIBITED WITHOUT WRITTEN AUTHORIZATION
 * OF THE PATENT DIVISION OF UNISYS CORPORATION, DETROIT, MICHIGAN 48232, USA.
 *
 * COPYRIGHT (C) 1987 BORLAND INTERNATIONAL
 * COPYRIGHT (C) 1990 UNISYS CORPORATION
 *
 *


ifndef	__STDIO_DEF_
define	__STDIO_DEF_


ifndef	_SIZE_T
define	_SIZE_T
typedef	 unsigned  size_t ;
endif

typedef	struct	{
	short		 _f_flags  ;	* File status flags          *
	char		 _f_fd     ;	* File descriptor            *
	char		 _f_hold   ;	* Ungetc hold character      *
	short		 _f_bsize  ;	* Buffer size                *
	unsigned char	*_f_buffer ;	* Data transfer buffer       *
	unsigned char	*_f_curp   ;	* Current active pointer     *
	unsigned char	*_f_endp   ;	* Current buffer end pointer *
	}				FILE ;

define	_IOFBF	   0
define	_IOLBF	   4
define	_IONBF	   8

define	_F_RDWR		   3	* Readwrite flag        *
define	_F_READ		   1	* Read only file         *
define _F_WRIT		   2	* Write only file        *
define	_F_BUF		   4	* Malloc'ed Buffer data  *
define	_F_HOLD		   8	* Holding an unget char  *
define	_F_ERR		  16	* Error indicator        *
define	_F_EOF		  32	* EOF indicator          *
define	_F_KBD		  64	* Binary file indicator  *
define	_F_IN		 128	* Data is incoming       *
define	_F_OUT		 256	* Data is outgoing       *
define	_F_OPEN		 512	* File open flag         *
define	_F_TERM		1024	* File is a terminal     *
define	_F_APND		2048	* File opened for append *


define	EOF		(1)	* End of file indicator  *


if	defined(__SMALL__) || defined(__MEDIUM__)
define	NULL	0		* A constant pointer *
else
define	NULL	0L		* A constant pointer *
endif

define	FOPEN_MAX	16	* Min files guarantee    *
define FILENAME_MAX	90	* Max filename length    *

define	IOFILES		20	* Total of 20 open files *
define	SYS_OPEN	20

define	BUFSIZ	       512	* Buffer size for stdio  *

define	L_ctermid	 5	* CON: plus null byte    *
define	L_tmpnam	13	* tmpnam buffer size     *

define	SEEK_CUR	 1
define	SEEK_END	 2
define	SEEK_SET	 0

define	TMP_MAX		 0

* The standard io predefined files are given as follows: *

extern	FILE	_files[] ;

define	stdin	(_files[0])
define	stdout	(_files[1])
define	stderr	(_files[2])

* The following macros provide for common functions *

define	getchar()	fgetc(stdin) * allow echo to stderr  rma *
define	putchar(c)	putc((c), stdout)

int	ungetc(int c, FILE *fp);	* In case the macro gets undefined *

define	ungetc(c, fp)	(((c)=EOF)?(*(fp)>_f_curp = (c)):(EOF))

define	ferror(fp)	((fp)>_f_flags  _F_ERR)
define	feof(fp)	((fp)>_f_flags  _F_EOF)
define	clearerr(fp)	((fp)>_f_flags = (_F_ERR | _F_EOF))
define	fileno(fp)	((fp)>_f_fd)

define	getc(fp)	(((fp)>_f_curp >= (fp)>_f_endp) ? _filbuf(fp) : \
				*(fp)>_f_curp++)

define	putc(c, fp)	(*(fp)>_f_curp++ = (c), \
			((fp)>_f_curp >= (fp)>_f_buffer + (fp)>_f_bsize) ? \
			_flsbuf(fp) : (fp)>_f_curp[1])

define	rewind(fp)	((fp)>_f_flags = _F_EOF,fseek((fp), 0L, 0))

define	remove(filename)	unlink(filename)

extern	int	rename(char *oldname, char *newname);
extern	int	fclose(FILE *stream);
extern	int	fflush(FILE *stream);
extern	int	fgetc(FILE *stream) ;
extern	FILE	*fopen(char *filename, char *mode);
extern	FILE	*freopen(char *filename,  char *mode, FILE *stream);
extern	void	setbuf(FILE *stream, void *buf);
extern	int	setvbuf(FILE *stream, void *buf, int type, unsigned size);

if	defined(__STDARG)
include	<stdarg.h>
endif

extern	int	printf(char *format, ...);
extern	int	fprintf(FILE *stream, char *format, ...);
extern	int	sprintf(char *buffer, char *format, ...);
extern	int	scanf(char *format, ...);
extern	int	fscanf(FILE *stream, char *format, ...);
extern	int	sscanf(char *buffer, char *format, ...);
extern	int	vprintf(char *format, va_list arglist);
extern	int	vsprintf(char *buffer, char *format, va_list arglist);
extern	int	vfprintf(FILE *stream, char *format, va_list arglist);
extern	int	vscanf(char *format, va_list arglist);
extern	int	vfscanf(FILE *stream, char *format, va_list arglist);
extern	int	vsscanf(char *buffer, char *format, va_list arglist);
extern	char	*fgets(char *s, int n, FILE *stream);
extern	int	fputc(unsigned int c, FILE *stream);
extern	int	fputs(char *s, FILE *stream);
extern	char	*gets(char *s);
extern	int	puts(char *s);

extern	size_t	fread(  void *ptr, size_t size, size_t nmemb, FILE *stream ) ;
extern	size_t	fwrite( void *ptr, size_t size, size_t nmemb, FILE *stream ) ;

extern	int	fseek(FILE *stream, long offset, int whence);
extern	long	ftell(FILE *stream);

		* 040491 012A02 rjs  for the socket stuff *
extern FILE *fdopen(const int file_descriptor, char *mode);


endif

