+/** Variable String N PRINT Formatted. Equivalent to vsprintf( dest, format,
+ args ), but will not write more than n characters.
+ @param dest The char array to write to.
+ @param n Maximum number of characters to write.
+ @param format The formatting string.
+ @param args The argument list created by the va_start macro.
+ @return Number of characters printed.
+ */
+int vsnprintf( char * restrict dest, size_t n, const char * restrict format, va_list ap );
+
+// ----------------------------------------------------------------------------
+
+/** Print ERROR.
+ Equivalent to fprintf( stderr, "%s: %s\n", text, strerror( errno ) ).
+ @param test Text to prepend the error message with.
+ */
+void perror( const char * text );
+
+// ----------------------------------------------------------------------------
+
+/** File READ. Reads a number of objects of a given size from file, and into
+ a memory area.
+ @param dest The memory area to write into.
+ @param size The size of one object.
+ @param n The number of objects to read.
+ @param fh The file handle.
+ @return The number of objects successfully read.
+ */
+size_t fread( void * restrict dest, size_t size, size_t n, FILE * restrict fh );
+
+/** File WRITE. Writes a number of objects from a memory area to file.
+ @param src The memory area to write from.
+ @param size The size of a single object.
+ @param n The number of objects to write.
+ @param fh The file handle.
+ @return The number of objects successfully written.
+ */
+size_t fwrite( const void * restrict src, size_t size, size_t n, FILE * restrict fh );
+
+// ----------------------------------------------------------------------------
+
+/** SET Virtual BUFfer. Sets buffering mode and (optionally) the memory used
+ for buffering, for a given file handle.
+ This function must only be called immediately after associating the file
+ handle with a file, before any operations are called on the file handle.
+ @param fh The file handle.
+ @param buf A pointer to the memory area to use for buffering, or NULL to
+ use internally assigned buffer memory.
+ @param mode One of _IOFBF, _IOLBF, _IONBF.
+ @param size Size of the memory area to be used for buffering.
+ */
+int setvbuf( FILE * restrict fh, char * restrict buf, int mode, size_t size );
+
+/** SET BUFfer. Equivalent to (void) setvbuf( fh, buf, _IOFBF, BUFSIZ ), or
+ (void) setvbuf( fh, NULL, _IONBF, BUFSIZ ) if buf == NULL.
+ @param fh The file handle to be passed to setvbuf().
+ @param buf The buffer pointer to be passed to setvbuf().
+ */
+void setbuf( FILE * restrict fh, char * restrict buf );
+
+// ----------------------------------------------------------------------------
+
+/* PDPC code - unreviewed
+/*
+ What we have is an internal buffer, which is 8 characters
+ longer than the actually used buffer. E.g. say BUFSIZ is
+ 512 bytes, then we actually allocate 520 bytes. The first
+ 2 characters will be junk, the next 2 characters set to NUL,
+ for protection against some backward-compares. The fourth-last
+ character is set to '\n', to protect against overscan. The
+ last 3 characters will be junk, to protect against memory
+ violation. intBuffer is the internal buffer, but everyone refers
+ to fbuf, which is actually set to the &intBuffer[4]. Also,
+ szfbuf is the size of the "visible" buffer, not the internal
+ buffer. The reason for the 2 junk characters at the beginning
+ is to align the buffer on a 4-byte boundary.
+*/
+
+typedef struct
+{
+#if (defined(__OS2__) || defined(__32BIT__))
+ unsigned long hfile; /* OS/2 file handle */
+#endif
+#if (defined(__MSDOS__) || defined(__DOS__) || defined(__POWERC))
+ int hfile; /* dos file handle */
+#endif
+#if (defined(__MVS__))
+ void *hfile;
+ int recfm;
+ int style;
+ int lrecl;
+ char ddname[9];
+#endif
+ int quickBin; /* 1 = do DosRead NOW!!!! */
+ int quickText; /* 1 = quick text mode */
+ int textMode; /* 1 = text mode, 0 = binary mode */
+ int intFno; /* internal file number */
+ unsigned long bufStartR; /* buffer start represents, e.g. if we
+ have read in 3 buffers, each of 512 bytes, and we are
+ currently reading from the 3rd buffer, then the first
+ character in the buffer would be 1024, so that is what is
+ put in bufStartR. */
+ char *fbuf; /* file buffer - this is what all the routines
+ look at. */
+ size_t szfbuf; /* size of file buffer (the one that the routines
+ see, and the user allocates, and what is actually
+ read in from disk) */
+ char *upto; /* what character is next to read from buffer */
+ char *endbuf; /* pointer PAST last character in buffer, ie it
+ points to the '\n' in the internal buffer */
+ int errorInd; /* whether an error has occurred on this file */
+ int eofInd; /* whether EOF has been reached on this file */
+ int ungetCh; /* character pushed back, -1 if none */
+ int bufTech; /* buffering technique, _IOFBF etc */
+ char *intBuffer; /* internal buffer */
+ int noNl; /* When doing gets, we don't copy NL */
+ int mode; /* __WRITE_MODE or __READ_MODE */
+ int update; /* Is file update (read + write)? */
+ int theirBuffer; /* Is the buffer supplied by them? */
+} FILE;
+