To provide a saner file/stream I/O interface for Q3 mods built as QVM bytecode.
Most of the libc stdio.h functions.
For opening as read, line format is auto-detected as much as possible (out of Unix, MacOS, MS-DOS).
This is significant for only
fgets(), for now.
For writing, no auto-conversion is done -- MS-DOS text format must be explicitly coded as such (e.g.
Semantics and syntax are based mostly on the documentation of GNU libc 2.1, which should be available on any GNU system (e.g. GNU/Linux, GNU/HURD, Cygwin32, DJGPP). The BSD libc documentation might suffice, but I'm not certain.
scanf family of functions is left unimplemented.
I really don't like
Functions related to temporary files (
mktemp, et. al) are not implemented.
Read-write mode is impossible in QVM. It can, however, be faked by closing and re-opening with alternating modes.
Write-seek is not implemented. This could be faked by using temporary files and writing back-and-forth, as suggested by Timbo of Tremulous Q3 mod.
errno is inconsistent.
The source as given has a limit of 40 open files.
This can be changed by altering the value of
FOPEN_MAX in the .h file.
Q3 v1.17 had a limit of 8 simultaneous open files.
This limit has probably been lifted in succeeding versions.
You can see vestiges of an attempt at an abstracted device layer in response to the standard file descriptors. Please don't laugh at me.