-// ----------------------------------------------------------------------------
-// $Id$
-// ----------------------------------------------------------------------------
-// Public Domain C Library - http://pdclib.sourceforge.net
-// This code is Public Domain. Use, modify, and redistribute at will.
-// ----------------------------------------------------------------------------
-// Input/output
-// ----------------------------------------------------------------------------
-
-#ifndef __STDIO_H
-#define __STDIO_H __STDIO_H
-
-// ----------------------------------------------------------------------------
-// MACROS
-
-#include "__NULL.h"
-
-#define _IOFBF // integer constant suitable as 3rd argument to setvbuf()
-#define _IOLBF // integer constant suitable as 3rd argument to setvbuf()
-#define _IONBF // integer constant suitable as 3rd argument to setvbuf()
-#define BUFSIZ // integer constant, size of the buffer used by setbuf(),
- // >= 256
-#define EOF // TODO
-#define FILENAME_MAX // length of filenames supported
-#define FOPEN_MAX // number of simultaneous open files supported, >= 8
-#define L_tmpnam // length of filenames generated by tmpnam()
-#define SEEK_CUR // integer constant suitable as 3rd argument to fseek()
-#define SEEK_END // integer constant suitable as 3rd argument to fseek()
-#define SEEK_SET // integer constant suitable as 3rd argument to fseek()
-#define TMP_MAX // number of unique filenames generateable by tmpnam(),
- // >= 25
-
-#define stderr // FILE*, not fully buffered
-#define stdin // FILE*, fully buffered only when not interactive device
-#define stdout // FILE*, fully buffered only when not interactive device
-
-// ----------------------------------------------------------------------------
-// TYPEDEFS
-
-#include "__size_t.h"
-
-typedef FILE; // object holding all stream information, including file pos,
- // buffer (optional), error indicator, EOF indicator
-typedef fpos_t; // position indicator type, other than array - personality?
- // (see mbstate_t)
-
-// ----------------------------------------------------------------------------
-// FUNCTIONS
+/* ----------------------------------------------------------------------------
+ * $Id$
+ * ----------------------------------------------------------------------------
+ * Public Domain C Library - http://pdclib.sourceforge.net
+ * This code is Public Domain. Use, modify, and redistribute at will.
+ * ----------------------------------------------------------------------------
+ * Input/output
+ * --------------------------------------------------------------------------*/
+
+#ifndef _STDIO_H
+#define _STDIO_H _STDIO_H
+
+#ifndef _NULL
+#include "__intern.h"
+#endif /* _NULL */
+
+/* ----------------------------------------------------------------------------
+ * MACROS
+ * --------------------------------------------------------------------------*/
+
+#define NULL _NULL
+
+#define _IOFBF 0 // @see setvbuf()
+#define _IOLBF 1 // @see setvbuf()
+#define _IONBF 2 // @see setvbuf()
+
+#define SEEK_SET 0 // @see fseek()
+#define SEEK_CUR 1 // @see fseek()
+#define SEEK_END 2 // @see fseek()
+
+#define EOF -1
+
+/* ----------------------------------------------------------------------------
+ * TYPEDEFS
+ * --------------------------------------------------------------------------*/
+
+#ifndef _SIZE_T
+#define _SIZE_T _SIZE_T
+typedef __size_t size_t
+#endif /* _SIZE_T */
+
+/* file position, buffer pointer, ErrorIndicator, EOFIndicator, HostRC */
+typedef FILE; /* TODO */
+
+/* file position */
+typedef fpos_t; /* TODO */
+
+extern FILE * stdin;
+extern FILE * stdout;
+extern FILE * stderr;
+
+/* ----------------------------------------------------------------------------
+ * FUNCTIONS
+ * --------------------------------------------------------------------------*/
+
+/* TABLE OF CONTENTS (in order of appearance)
+ *
+ * General File Handling
+ * * fopen()
+ * * freopen()
+ * * fflush()
+ * * feof()
+ * * ferror()
+ * * clearerr()
+ * * fclose()
+ *
+ * Rename / Remove
+ * * rename()
+ * * remove()
+ *
+ * Temporary Files
+ * * tmpfile()
+ * * tmpnam()
+ *
+ * File Positioning
+ * * fseek()
+ * * rewind()
+ * * ftell()
+ * * fgetpos()
+ * * fsetpos()
+ *
+ * Reading
+ * * fgetc()
+ * * getc()
+ * * getchar()
+ * * ungetc()
+ * * fgets()
+ * * gets()
+ *
+ * Writing
+ * * fputc()
+ * * putc()
+ * * putchar()
+ * * fputs()
+ * * puts()
+ *
+ * Formatted Reading
+ * * fscanf()
+ * * scanf()
+ * * sscanf()
+ * * vfscanf()
+ * * vscanf()
+ * * vsscanf()
+ *
+ * Formatted Writing
+ * * fprintf()
+ * * printf()
+ * * sprintf()
+ * * snprintf()
+ * * vfprintf()
+ * * vprintf()
+ * * vsprintf()
+ * * vsnprintf()
+ *
+ * Special
+ * * perror()
+ *
+ * Binary Read / Write
+ * * fread()
+ * * fwrite()
+ *
+ * Buffer Handling
+ * * setvbuf()
+ * * setbuf()
+ *
+ */
+
+/** File OPEN. Opens a file.
+ * @param filename Name of the file.
+ * @param mode One of r, w, a, rb, wb, ab, r+, w+, a+, rb+, wb+, ab+,
+ * specifying which mode to open the file in.
+ * @return A file handle associated with the opened file, NULL if failed.
+ */
+FILE * fopen( const char * restrict filename, const char * restrict mode );
+
+/** File REOPEN. Opens the file specified by the given name, associating it
+ * with the given file handle. If filename is NULL, it is attempted to change
+ * the mode of the already opened file associated with the given file handle.
+ * (This function can e.g. be used to reassociate stdin / stdout / stderr with
+ * a filename.)
+ * @param filename Name of the file to be opened.
+ * @param mode One of r, w, a, rb, wb, ab, r+, w+, a+, rb+, wb+, ab+,
+ * specifying which mode to open the file in.
+ * @param fh The file handle to associate with the opened file.
+ * @return fh if successful, NULL if failed.
+ */
+FILE * freopen( const char * restrict filename, const char * restrict mode, FILE * fh );
+
+/** File FLUSH. Flushes any output buffers of a file. If parameter is NULL,
+ * flushes output buffers for all file handles. The function is undefined for
+ * input streams or update streams when the last operation was input.
+ * @param fh The file handle.
+ * @return 0 if successful, EOF on write error (setting error indicator).
+ */
+int fflush( FILE * fh );
+
+/** File EOF. Tests whether EOF is set for a given file.
+ * @param fh The file handle.
+ * @return 0 if EOF is not set, non-zero if EOF is set.
+ */
+int feof( FILE * fh );
+
+/** File ERROR. Tests whether error indicator is set for a given file.
+ * @param fh The file handle.
+ * @return 0 if error indicator is not set, non-zero if set.
+ */
+int ferror( FILE * fh );