/*
 * $Header: /smsa/bsd:include/stdio.h:bsd  1.12  $
 * $Source: /smsa/bsd:include/stdio.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 * 
 */
/*
 * Copyright (c) 1980 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)stdio.h	5.3 (Berkeley) 3/15/86
 */

#ifndef __stdio_h
#define __stdio_h


#ifndef __size_t
#define __size_t 1
typedef unsigned int size_t;   /* from <stddef.h> */
#endif

typedef char *__va_list;

#define NULL 0

typedef struct __fpos_t_struct {
    unsigned long __lo;
} fpos_t;

typedef struct __FILE_struct { 
	int	_cnt;
	char	*_ptr;
	char	*_base;
	int	_bufsiz;
	short	_flag;
	char	_file;
	char	_ungetb[4];	/* Four character pushback */
	int	_oldcnt;	/* Stored during ungetc() */
	char	*_oldptr;
} FILE;
#define	BUFSIZ	1024

#define	_IOREAD		00001
#define	_IOWRT		00002
#define	_IONBF		00004
#define	_IOMYBUF	00010
#define	_IOEOF		00020
#define	_IOERR		00040
#define	_IOSTRG		00100
#define	_IOLBF		00200
#define	_IORW		00400
#define _IOFBF		01000
#define _IOUGET		02000

#define	EOF		(-1)
#define FOPEN_MAX	64		/* must keep in step with <sys/param.h> */
#define FILENAME_MAX	1024
#define L_tmpnam	40

#define SEEK_SET 0 /* start of stream (see fseek) */
#define SEEK_CUR 1 /* current position in stream (see fseek) */
#define SEEK_END 2 /* end of stream (see fseek) */               

#define TMP_MAX 1000000000

extern FILE _iob[];

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

extern int remove(const char * /*filename*/);
extern int rename(const char * /*old*/, const char * /*new*/);
extern FILE *tmpfile(void);
extern char *tmpnam(char * /*s*/);
extern int fclose(FILE * /*stream*/);
extern int fflush(FILE * /*stream*/);
extern FILE *fopen(const char * /*filename*/, const char * /*mode*/);
extern FILE *freopen(const char * /*filename*/, const char * /*mode*/,
                     FILE * /*stream*/);
extern void setbuf(FILE * /*stream*/, char * /*buf*/);
extern int setvbuf(FILE * /*stream*/, char * /*buf*/,
                   int /*mode*/, size_t /*size*/);

#pragma -v1   /* hint to the compiler to check f/s/printf format */
extern int fprintf(FILE * /*stream*/, const char * /*format*/, ...);
extern int printf(const char * /*format*/, ...);
extern int sprintf(char * /*s*/, const char * /*format*/, ...);

#pragma -v2   /* hint to the compiler to check f/s/scanf format */
extern int fscanf(FILE * /*stream*/, const char * /*format*/, ...);
extern int scanf(const char * /*format*/, ...);
extern int sscanf(const char * /*s*/, const char * /*format*/, ...);

#pragma -v0   /* back to default */
extern int vprintf(const char * /*format*/, __va_list /*arg*/);
extern int vfprintf(FILE * /*stream*/,
                   const char * /*format*/, __va_list /*arg*/);
extern int vsprintf(char * /*s*/, const char * /*format*/, __va_list /*arg*/);

extern int fgetc(FILE * /*stream*/);
extern char *fgets(char * /*s*/, int /*n*/, FILE * /*stream*/);
extern int fputc(int /*c*/, FILE * /*stream*/);
extern int fputs(const char * /*s*/, FILE * /*stream*/);
extern int (getc)(FILE * /*stream*/);
extern int (getchar)(void);
#define getchar() getc(stdin)
extern char *gets(char * /*s*/);
extern int (putc)(int /*c*/, FILE * /*stream*/);
extern int (putchar)(int /*c*/);
#define putchar(ch) putc(ch, stdout)
extern int puts(const char * /*s*/);
extern int ungetc(int /*c*/, FILE * /*stream*/);
extern size_t fread(void * /*ptr*/,
                    size_t /*size*/, size_t /*nmemb*/, FILE * /*stream*/);
extern size_t fwrite(const void * /*ptr*/,
                    size_t /*size*/, size_t /*nmemb*/, FILE * /*stream*/);
extern int fgetpos(FILE * /*stream*/, fpos_t * /*pos*/);
extern int fseek(FILE * /*stream*/, long int /*offset*/, int /*whence*/);
extern int fsetpos(FILE * /*stream*/, const fpos_t * /*pos*/);
extern long int ftell(FILE * /*stream*/);
extern void rewind(FILE * /*stream*/);
extern void clearerr(FILE * /*stream*/);
extern int (feof)(FILE * /*stream*/);
extern int (ferror)(FILE * /*stream*/);
extern void perror(const char * /*s*/);

#define	feof(p)		(((p)->_flag&_IOEOF)!=0)
#define	ferror(p)	(((p)->_flag&_IOERR)!=0)
#define	clearerr(p)	((p)->_flag &= ~(_IOERR|_IOEOF))

#if defined(_BSD_C) || defined(_XOPEN_C)
#define	fileno(p)	((p)->_file)

extern FILE	*fdopen(int /*fildes*/, char * /*type*/);
extern FILE	*popen(char * /*command*/, char * /*type*/);
#endif /* _BSD_C || _XOPEN_C */

#if defined(_XOPEN_C)
extern int getw(FILE * /*stream*/);
extern int pclose(FILE * /*stream*/);
extern int putw(int /*w*/, FILE * /*stream*/);
extern char *tempnam(char * /*dir*/, char * /*pfx*/);

#define L_ctermid	20
#define L_cuserid	20
#define P_tmpdir	"/var/tmp"

#endif /* _XOPEN_C */

#endif /* !__stdio_h */


