next up previous contents index
Next: 3. Unix Command-line Interface Up: 2. The C Interface Previous: 2.6 Predefined Constants

  
2.7 File input/output

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 The return value from 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", SPMquotstdout", and SPMquotstderr".

     

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 SPMquotbegin_udi()", stdin", stdout", and SPMquotstderr" are opened with the following file-number variable names and file formats:

Variable name File format
SPMquotF_stdin" SPMquotUDI_FILE_BIN"
SPMquotF_stdout" UDI_FILE_BIN"
SPMquotF_stderr" SPMquotUDI_FILE_ASCII"
In general, the user only needs to call these special open routines if these default file formats are not acceptable.

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;


next up previous contents index
Next: 3. Unix Command-line Interface Up: 2. The C Interface Previous: 2.6 Predefined Constants
Diemo Schwarz
1999-03-04