-// ----------------------------------------------------------------------------
-// $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
-
-#define _IOFBF // TODO
-#define _IOLBF // TODO
-#define _IONBF // TODO
-#define BUFSIZ // TODO
-#define EOF // TODO
-#define FILENAME_MAX // TODO
-#define FOPEN_MAX // TODO
-#define L_tmpnam // TODO
-#define NULL 0
-#define SEEK_CUR // TODO
-#define SEEK_END // TODO
-#define SEEK_SET // TODO
-#define TMP_MAX // TODO
-
-#define stderr // TODO
-#define stdin // TODO
-#define stdout // TODO
-
-// ----------------------------------------------------------------------------
-// TYPEDEFS
-
-typedef FILE; // TODO
-typedef fpos_t; // TODO
-typedef size_t; // TODO
-
-// ----------------------------------------------------------------------------
-// FUNCTIONS
-
-// TODO: Documentation.
+/* $Id$ */
-void clearerr( FILE * stream );
-int fclose( FILE * stream );
-int feof( FILE * stream );
-int ferror( FILE * stream );
-int fflush( FILE * stream );
-FILE * fopen( const char * restrict filename, const char * restrict mode );
-FILE * freopen( const char * restrict filename, const char * restrict mode, FILE * stream );
+/* Release $Name$ */
+
+/* Input/output <stdio.h>
+
+ This file is part of the Public Domain C Library (PDCLib).
+ Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#ifndef _PDCLIB_STDIO_H
+#define _PDCLIB_STDIO_H _PDCLIB_STDIO_H
+
+#ifndef _PDCLIB_INT_H
+#define _PDCLIB_INT_H _PDCLIB_INT_H
+#include <_PDCLIB_int.h>
+#endif
+
+#ifndef _PDCLIB_SIZE_T_DEFINED
+#define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED
+typedef _PDCLIB_size_t size_t;
+#endif
+
+#ifndef _PDCLIB_NULL_DEFINED
+#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED
+#define NULL _PDCLIB_NULL
+#endif
+
+/* See setvbuf(), third argument */
+/* Fully buffered - transmit block-wise */
+#define _IOFBF 1
+/* Line buffered - transmit line-wise */
+#define _IOLBF 2
+/* Not buffered - transmit immediately */
+#define _IONBF 4
+
+/* See setbuf(). Minimum 256. */
+#define BUFSIZ 1024
+
+/* Internal-only flags for representing mode */
+#define _PDCLIB_FREAD 1
+#define _PDCLIB_FWRITE 2
+#define _PDCLIB_FAPPEND 4
+#define _PDCLIB_FRW 8
+#define _PDCLIB_FBIN 16
+
+typedef struct _PDCLIB_file_t FILE;
+typedef _PDCLIB_fpos_t fpos_t;
+
+/* Must be integer and of negative value */
+#define EOF -1
+
+/* Maximum number of files this implementation can open simultaneously. Minimum 8. */
+#define FOPEN_MAX 1
+
+/* Maximum file name length (plus terminating \0) this implementation does
+ guarantee can be opened. If there is no limit on the length of filenames,
+ this should be a recommended size for filename buffers.
+*/
+#define FILENAME_MAX 1024
+
+/* Buffer size for tmpnam() */
+#define L_tmpnam 1024
+
+/* Number of distinct file names that can be generated by tmpnam(). */
+#define TMP_MAX 50
+
+/* See fseek(), third argument */
+#define SEEK_CUR 1
+#define SEEK_END 2
+#define SEEK_SET 4
+
+typedef struct
+{
+ _PDCLIB_fd_t handle; /* OS-specific file descriptor */
+ _PDCLIB_fpos_t position; /* file position indicator */
+ void * buffer; /* file buffer */
+ size_t bufsize; /* size of buffer */
+ int status; /* misc. status bits */
+ /*mbstate_t mbstate;*//* multibyte parse state */ /* TODO: Unmask. */
+ FILE * next; /* provisions for linked list handling */
+} FILE;
+
+/* Text-mode I/O is at liberty to skip non-printing characters and trailing spaces.
+ Binary I/O is at liberty to add trailing zero bytes.
+ First operation decides "orientation" of the stream (wide / byte).
+ freopen() removes orientation; see also fwide().
+ Binary wide-oriented streams have the file-positioning restrictions ascribed to both text and binary streams.
+ For wide-oriented streams, after a successful call to a file-positioning function that leaves the file position indicator prior to the end-of-file, a wide character output function can overwrite a partial multibyte character; any file contents beyond the byte(s) written are henceforth indeterminate.
+ Whether a file of zero length (unwritten-to) actually exists is implementation-defined.
+ Wide text input from file: fgetwc() / mbrtowc()
+ Wide text output to file: wcrtomb() / fputwc()
+ Multibyte encoding in file may contain embedded null bytes
+ Multibyte encoding in file need not begin / end in initial shift state.
+ Conversion may trigger EILSEQ.
+*/
+
+/* Operations on files */
int remove( const char * filename );
int rename( const char * old, const char * new );
-void rewind( FILE * stream );
-void setbuf( FILE * restrict stream, char * restrict buf );
-int setvbuf( FILE * restrict stream, char * restrict buf, int mode, size_t size );
-FILE * tmpfile( void )
-char * tmpnam( char * s );
+FILE * tmpfile( void ); /* TODO: Implement. */
+char * tmpnam( char * s ); /* TODO: Implement. */
-int fseek( FILE * stream, long offset, int mode );
-int fsetpos( FILE * stream, const fpos_t * pos );
-int fgetpos( FILE * restrict stream, fpos_t * restrict pos );
-long ftell( FILE * stream );
+/* File access functions */
+int fclose( FILE * stream );
+int fflush( FILE * stream );
+FILE * fopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode );
+FILE * freopen( const char * _PDCLIB_restrict filename, const char * _PDCLIB_restrict mode, FILE * _PDCLIB_restrict stream );
+void setbuf( FILE * _PDCLIB_restrict stream, char * _PDCLIB_restrict buf );
+int setvbuf( FILE * _PDCLIB_restrict stream, char * _PDCLIB_restrict buf, int mode, size_t size );
+/* Formatted input/output functions */
+int fprintf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, ... );
+int fscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, ... );
+int printf( const char * _PDCLIB_restrict format, ... );
+int scanf( const char * _PDCLIB_restrict format, ... );
+int snprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restrict format, ... );
+int sprintf( char * _PDCLIB_restrict s, const char * _PDCLIB_restrict format, ... );
+int sscanf( const char * _PDCLIB_restrict s, const char * _PDCLIB_restrict format, ... );
+int vfprintf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vfscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vprintf( const char * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vscanf( const char * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vsnprintf( char * _PDCLIB_restrict s, size_t n, const char * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vsprintf( char * _PDCLIB_restrict s, const char * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vsscanf( const char * _PDCLIB_restrict s, const char * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+
+/* Character input/output functions */
int fgetc( FILE * stream );
-char *fgets( char * restrict s, int n, FILE * restrict stream );
-size_t fread( void * restrict ptr, size_t size, size_t nelem, FILE * restrict stream );
+char * fgets( char * _PDCLIB_restrict s, int n, FILE * _PDCLIB_restrict stream );
+int fputc( int c, FILE * stream );
+int fputs( const char * _PDCLIB_restrict s, FILE * _PDCLIB_restrict stream );
int getc( FILE * stream );
int getchar( void );
char * gets( char * s );
-int ungetc( int c, FILE * stream );
-
-int fputc( int c, FILE * stream );
-int fputs( const char * restrict s, FILE * restrict stream );
-size_t fwrite( const void * restrict ptr, size_t size, size_t nelem, FILE * restrict stream );
-void perror( const char * s );
int putc( int c, FILE * stream );
int putchar( int c );
int puts( const char * s );
+int ungetc( int c, FILE * stream );
+
+/* Direct input/output functions */
+size_t fread( void * _PDCLIB_restrict ptr, size_t size, size_t nmemb, FILE * _PDCLIB_restrict stream );
+size_t fwrite( const void * _PDCLIB_restrict ptr, size_t size, size_t nmemb, FILE * _PDCLIB_restrict stream );
+
+/* File positioning functions */
+int fgetpos( FILE * _PDCLIB_restrict stream, fpos_t * _PDCLIB_restrict pos );
+int fseek( FILE * stream, long int offset, int whence );
+int fsetpos( FILE * stream, const fpos_t * pos );
+long int ftell( FILE * stream );
+void rewind( FILE * stream );
+
+/* Error-handling functions */
+void clearerr( FILE * stream );
+int feof( FILE * stream );
+int ferror( FILE * stream );
+void perror( const char * s );
-int fscanf( FILE * restrict stream, const char * restrict format, ... );
-int scanf( const char * restrict format, ... );
-int sscanf( const char * restrict s, const char * restrict format, ... );
-int vfscanf( FILE * restrict stream, const char * restrict format, va_list ap );
-int vscanf( const char * restrict format, va_list ap );
-int vsscanf( const char * restrict s, const char * restrict format, va_list ap );
-
-int fprintf( FILE * restrict stream, const char * restrict format, ... );
-int printf( const char * restrict format, ... );
-int snprintf( char * restrict s, size_t n, const char * restrict format, ... );
-int sprintf( char * restrict s, const char * restrict format, ... );
-int vfprintf( FILE * restrict stream, const char * restrict format, va_list ap );
-int vprintf( const char * restrict format, va_list ap );
-int vsnprintf( char * restrict s, size_t n, const char * restrict format, va_list ap );
-int vsprintf( char * restrict s, const char * restrict format, va_list ap);
-
-#endif // __STDIO_H
+#endif