/*
 * include/stand/stdio.h
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1995 by Ralf Baechle
 */
#ifndef __STDIO_H
#define __STDIO_H

#include <linux/types.h>
#include <arc/types.h>
#include <stand/libio.h>

#ifndef NULL
#define NULL (void *)0
#endif

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

#ifndef BUFSIZ
#define BUFSIZ 1024
#endif

#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2

typedef struct _IO_FILE FILE;

#define FOPEN_MAX     20
#define FILENAME_MAX  1024
#define DEFFILEMODE   0x644

/* limited by the number of possible unique combinations. see
 * libio/iotempname.c for details. */
#define TMP_MAX 238328

#define L_ctermid     9
#define L_cuserid     9
#define P_tmpdir      "\\tmp"
#define L_tmpnam      20

extern _IO_FILE __FILE[];

/*
 * Standard filedescriptors
 */
#define stdin (__FILE + 0)
#define stdout (__FILE + 1)
#define stderr (__FILE + 2)

extern void clearerr __P((FILE*));
extern int fclose __P((FILE*));
extern int feof __P((FILE*));
extern int ferror __P((FILE*));
extern int fflush __P((FILE*));
extern int fgetc __P((FILE *));
extern char* fgets __P((char*, int, FILE*));
extern FILE* fopen __P((const char*, const char*));
extern int fprintf __P((FILE*, const char* format, ...));
extern int fputc __P((int, FILE*));
extern int fputs __P((const char *str, FILE *f));
extern size_t fread __P((void*, size_t, size_t, FILE*));
extern FILE* freopen __P((const char*, const char*, FILE*));
extern int fscanf __P((FILE *f, const char* format, ...));
extern int fseek __P((FILE* f, long int offset, int whence));
#if 0
extern int fsetpos __P((FILE* f, const fpos_t *pos));
#endif
extern long int ftell __P((FILE* f));
extern size_t fwrite __P((const void*, size_t, size_t, FILE*));
extern int getc __P((FILE *));
extern int getchar __P((void));
extern char* gets __P((char*));
extern void perror __P((const char *));
extern int printf __P((const char* format, ...));
extern int putc __P((int, FILE *));
extern int putchar __P((int));
extern int puts __P((const char *str));
extern int remove __P((const char*));
extern int rename __P((const char* _old, const char* _new));
extern void rewind __P((FILE*));
extern int scanf __P((const char* format, ...));
extern void setbuf __P((FILE*, char*));
extern void setlinebuf __P((FILE*));
extern void setbuffer __P((FILE*, char*, int));
extern int setvbuf __P((FILE*, char*, int mode, size_t size));
extern int sprintf __P((char*, const char* format, ...));
extern int sscanf __P((const char* string, const char* format, ...));
extern FILE* tmpfile __P((void));
extern char* tmpnam __P((char*));
extern int ungetc __P((int c, FILE* f));
extern int vfprintf __P((FILE *f, char const *fmt0, _G_va_list));
extern int vprintf __P((char const *fmt, _G_va_list));
extern int vsprintf __P((char* string, const char* format, _G_va_list));

#if !defined(__STRICT_ANSI__)
extern int vfscanf __P((FILE*, const char *, _G_va_list));
extern int vscanf __P((const char *, _G_va_list));
extern int vsscanf __P((const char *, const char *, _G_va_list));

extern int getw __P((FILE*));
extern int putw __P((int, FILE*));

extern char* tempnam __P((const char *__dir, const char *__pfx));

extern int _sys_nerr;
extern char *_sys_errlist[];
 
#endif /* __STRICT_ANSI__ */

#ifdef __USE_GNU
#if 0
extern _IO_ssize_t getdelim __P ((char **, size_t *, int, FILE*));
#endif

extern int snprintf __P ((char *, size_t, const char *, ...));
extern int vsnprintf __P ((char *, size_t, const char *, _G_va_list));
#endif

#if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)
extern FILE *fdopen __P((int, const char *));
extern int fileno __P((FILE*));
extern FILE* popen __P((const char*, const char*));
extern int pclose __P((FILE*));
#endif

#endif /* __STDIO_H */
