Included in the UDI library are interface routines to the Universal File Input/Output (UIO) package, a library of C-language routines which provide a way to handle both binary and ASCII format files.
The UDI - UIO interface provides routines for opening/closing files and reading/writing UDI objects.
int udi_open_file(filename, filetype, filemode) char *filename, *filemode; int filetype;Where
SPMquot
filename" is the full pathname of the file to be opened.
SPMquot
filetype" is one of the following
UDI_FILE_ASCII" |
ASCII-format file |
UDI_FILE_ASCII_N" |
ASCII-format file with line numbers |
UDI_FILE_BIN" |
binary-format file |
SPMquot
filemode" is one of the following
SPMquot a" |
open file for writing at end of file, or create for writing |
w" |
open new file for writing |
r" |
open existing file for reading |
udi_open_file" is a file number which needs to be
passed to the read/write routines. An error will be signalled by UDI
if there's a problem opening the file, and may be handled like any other
UDI error.
int uio_close_file(filenumber) int filenumber; /* this should be the value returned from udi_open_file */
There are special routines for opening stdin",
SPMquot
stdout", and
SPMquot
stderr".
int udi_open_stdin(filetype) int filetype; int udi_open_stdout(filetype) int filetype; int udi_open_stderr(filetype) int filetype;During the initialization process in
SPMquot
begin_udi()",
stdin",
stdout", and SPMquot
stderr" are opened with the following file-number
variable names and file formats:
Variable name | File format |
SPMquot F_stdin" |
SPMquot UDI_FILE_BIN" |
SPMquot F_stdout" |
UDI_FILE_BIN" |
SPMquot F_stderr" |
SPMquot UDI_FILE_ASCII" |
There exist four routines for reading/writing UDI objects.
int read_object(file, object) int file; /* the file number returned from udi_open */ UDI_object object; /* the object which will receive the data */ int read_part_object(file, object, offset, num) int file; UDI_object object; int offset; /* the element offset into object */ int num; /* the number of elements to be read */Both of these routines return the number of elements read into
object".
void write_object(file, object) int file; UDI_object object; void write_part_object(file, object, offset, num) int file; UDI_object object; int offset, num;