Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

Input/output abstraction object


Functions

ssize_t io_printf (io_t *io, const char *fmt,...)
 Write a string to io using printf-style format strings.
ssize_t io_write (io_t *io, const char *buf, size_t size)
 Write a block of data to an io_t object.
ssize_t io_putc (io_t *io, char c)
 Write a char to an io_t object.
int io_is_secure (io_t *io)
ssize_t io_flush (io_t *io)
 Flush the write buffer.
ssize_t io_read (io_t *io, char *buf, size_t size)
 Read a block of data from an io_t object.
ssize_t io_gets (io_t *io, char *buf, size_t size)
 Read a line from an io_t object.
ssize_t io_get_until (io_t *io, char stop_at, char *buf, size_t size)
 Read a chunk of data until the given character is found.
ssize_t io_getc (io_t *io, char *c)
 Read a char from an io_t object.
ssize_t io_copy (io_t *out, io_t *in, size_t size)
 Copy a block of data between two io_t objects.
ssize_t io_pipe (io_t *out, io_t *in)
 Write the input stream to the output stream.
int io_codec_add_head (io_t *io, codec_t *codec)
 Insert a codec at the head the codec chain.
int io_codec_add_tail (io_t *io, codec_t *codec)
 Append a codec to the codec chain.
int io_codecs_remove (io_t *io)
 Flush, remove and free all codecs in the codec chain.
enum io_type_e io_type (io_t *io)
 Returns the type of the given io.

Detailed Description


Function Documentation

ssize_t io_printf io_t io,
const char *  fmt,
  ...
 

Printf-like function used to easily write strings to io using well-known printf format strings. See printf(3) manual for format description.

Parameters:
io the io_t object to write to
fmt printf-style format string
... format string arguments
Returns:
the number of chars written on success, -1 on error

Definition at line 641 of file io.c.

References io_write().

ssize_t io_write io_t io,
const char *  buf,
size_t  size
 

Write size bytes of buf to io.

Parameters:
io the io_t object
buf the buffer with the bytes to write
size number of bytes to write
Returns:
the number of bytes written or -1 on error.

Definition at line 725 of file io.c.

References io_flush(), io_s::wbuf, and io_s::wcount.

Referenced by io_copy(), io_pipe(), io_printf(), and io_putc().

ssize_t io_putc io_t io,
char  c
[inline]
 

Write the character c to io

Parameters:
io the io_t object
c the char to write
Returns:
the number of bytes written (i.e. 1) on success or -1 on error.

Definition at line 766 of file io.c.

References io_write().

ssize_t io_flush io_t io  ) 
 

Force a write of all buffered data to the output device.

Parameters:
io the io_t object to be flushed
Returns:
zero on success, -1 on error

Definition at line 691 of file io.c.

References io_s::wbuf, io_s::wcount, and io_s::write.

Referenced by io_write().

ssize_t io_read io_t io,
char *  buf,
size_t  size
 

Read size bytes from io and save them to buf (that must be big enough).

Parameters:
io the io_t object onto which the read operation is performed
buf the buffer that will contain the read bytes
size number of bytes to read
Returns:
the number of bytes read and saved to buf, 0 on end of file condition, and -1 on error.

Definition at line 594 of file io.c.

References io_s::eof, io_s::rbuf, io_s::rcount, and io_s::roff.

Referenced by io_copy(), io_getc(), io_pipe(), and u_md5io().

ssize_t io_gets io_t io,
char *  buf,
size_t  size
 

Read a line from in and save it to buf that must be at least size bytes long.

Parameters:
io the io_t object
buf destination buffer
size size of buf
Returns:
the length of the line on success, 0 on EOF or -1 on error.

Definition at line 890 of file io.c.

References io_get_until().

ssize_t io_get_until io_t io,
char  stop_at,
char *  buf,
size_t  size
 

Read from in and save it to buf that must be at least size bytes long. Read stops when stop_at characted is found in the incoming stream.

Parameters:
io the io_t object
stop_at reads until this character is found
buf destination buffer
size size of buf
Returns:
the length of the line on success, 0 on EOF or -1 on error.

Definition at line 818 of file io.c.

References io_s::rbuf, io_s::rcount, and io_s::roff.

Referenced by io_gets().

ssize_t io_getc io_t io,
char *  pc
[inline]
 

Read a char from the io_t object io and save it at *pc.

Parameters:
io the io_t object
pc on success will hold the read character
Returns:
the number of bytes read (i.e. 1) on success or -1 on error.

Definition at line 781 of file io.c.

References io_read().

ssize_t io_copy io_t out,
io_t in,
size_t  size
 

Read from in a block of data size bytes long and write it to the out output io_t object

Parameters:
out output io_t object
in input io_t object
size number of bytes to copy
Returns:
the number of bytes copied (that can be less the size in case of EOF on in) or -1 on error.

Definition at line 159 of file io.c.

References io_read(), and io_write().

ssize_t io_pipe io_t out,
io_t in
 

Read all data from in and copy it to out

Parameters:
out output IO object
in input IO object
Returns:
the number of bytes read from in and written to out or -1 on error

Definition at line 90 of file io.c.

References io_read(), and io_write().

int io_codec_add_head io_t io,
codec_t c
 

Parameters:
io the io_t object
c the codec to append
Returns:
0 on success, non-zero on error

Definition at line 903 of file io.c.

References io_s::codec_chain.

int io_codec_add_tail io_t io,
codec_t c
 

Parameters:
io the io_t object
c the codec to append
Returns:
0 on success, non-zero on error

Definition at line 922 of file io.c.

References io_s::codec_chain.

int io_codecs_remove io_t io  ) 
 

Parameters:
io the io_t object
Returns:
0 on success, non-zero on error

Definition at line 940 of file io.c.

References io_s::codec_chain, and io_s::wbuf.

enum io_type_e io_type io_t io  ) 
 

Return the type of the given io (see enum io_type_e).

Parameters:
io input IO object
Returns:
on of enum io_type_e defined item

Definition at line 73 of file io.c.

References io_s::type.