libuproc  1.2.0
Data Structures | Enumerations | Functions
object uproc_io_stream

Optionally compressed I/O stream. More...

Data Structures

struct  uproc_io_stream
 Optionally compressed I/O stream. More...
 

Enumerations

enum  uproc_io_type {
  UPROC_IO_STDIO,
  UPROC_IO_GZIP
}
 Underlying stream type. More...
 
enum  uproc_io_seek_whence {
  UPROC_IO_SEEK_SET,
  UPROC_IO_SEEK_CUR
}
 Third argument to uproc_io_seek() More...
 

Functions

uproc_io_streamuproc_io_open (const char *mode, enum uproc_io_type type, const char *pathfmt,...)
 Open a file. More...
 
uproc_io_streamuproc_io_openv (const char *mode, enum uproc_io_type type, const char *pathfmt, va_list ap)
 Open a file using a va_list. More...
 
int uproc_io_close (uproc_io_stream *stream)
 Close a file stream. More...
 
int uproc_io_printf (uproc_io_stream *stream, const char *fmt,...)
 Formatted output. More...
 
size_t uproc_io_read (void *ptr, size_t size, size_t nmemb, uproc_io_stream *stream)
 Read binary data. More...
 
size_t uproc_io_write (const void *ptr, size_t size, size_t nmemb, uproc_io_stream *stream)
 Write binary data. More...
 
char * uproc_io_gets (char *s, int size, uproc_io_stream *stream)
 (Partially) read a line More...
 
long uproc_io_getline (char **lineptr, size_t *n, uproc_io_stream *stream)
 Read an entire line. More...
 
int uproc_io_putc (int c, uproc_io_stream *stream)
 Write a character. More...
 
int uproc_io_puts (const char *s, uproc_io_stream *stream)
 Write a string and a trailing newline. More...
 
int uproc_io_seek (uproc_io_stream *stream, long offset, enum uproc_io_seek_whence whence)
 Set the file position. More...
 
long uproc_io_tell (uproc_io_stream *stream)
 Obtain current file position. More...
 
int uproc_io_eof (uproc_io_stream *stream)
 Test end-of-file indicator. More...
 

Detailed Description

Optionally compressed I/O stream.

Unless noted otherwise, a function called uproc_io_NAME() corresponds directly to its stdio.h counterpart called fNAME(). Most of the time, there also exists a similar gzNAME() function in zlib, but the order and types of parameters are always adapted from stdio.h.

Enumeration Type Documentation

Underlying stream type.

Enumerator
UPROC_IO_STDIO 

standard C's FILE pointer

UPROC_IO_GZIP 

transparent gzip stream using zlib

Third argument to uproc_io_seek()

These correspond to SEEK_SET and SEEK_CUR of stdio.h. SEEK_END is missing because gz streams don't support it.

Enumerator
UPROC_IO_SEEK_SET 

Set the cursor to an absolute position.

UPROC_IO_SEEK_CUR 

Set the new position relative to the current one.

Function Documentation

uproc_io_stream* uproc_io_open ( const char *  mode,
enum uproc_io_type  type,
const char *  pathfmt,
  ... 
)

Open a file.

Corresponds to using

where the file name is constructed by formatting pathfmt with the subsequent arguments (using sprintf).

uproc_io_stream* uproc_io_openv ( const char *  mode,
enum uproc_io_type  type,
const char *  pathfmt,
va_list  ap 
)

Open a file using a va_list.

Just like uproc_io_open, but with a va_list instead of a variable number of arguments.

int uproc_io_close ( uproc_io_stream stream)

Close a file stream.

int uproc_io_printf ( uproc_io_stream stream,
const char *  fmt,
  ... 
)

Formatted output.

size_t uproc_io_read ( void *  ptr,
size_t  size,
size_t  nmemb,
uproc_io_stream stream 
)

Read binary data.

size_t uproc_io_write ( const void *  ptr,
size_t  size,
size_t  nmemb,
uproc_io_stream stream 
)

Write binary data.

char* uproc_io_gets ( char *  s,
int  size,
uproc_io_stream stream 
)

(Partially) read a line

Corresponds to fgets(), not gets()!

long uproc_io_getline ( char **  lineptr,
size_t *  n,
uproc_io_stream stream 
)

Read an entire line.

Reads a whole line into *lineptr, reallocating it if necessary (works exactly like the POSIX getline function).

int uproc_io_putc ( int  c,
uproc_io_stream stream 
)

Write a character.

int uproc_io_puts ( const char *  s,
uproc_io_stream stream 
)

Write a string and a trailing newline.

int uproc_io_seek ( uproc_io_stream stream,
long  offset,
enum uproc_io_seek_whence  whence 
)

Set the file position.

long uproc_io_tell ( uproc_io_stream stream)

Obtain current file position.

int uproc_io_eof ( uproc_io_stream stream)

Test end-of-file indicator.