man stream_open () - stream_open, stream_read, stream_getline, stream_write, stream_close - cached I/O operations.

NAME

stream_open, stream_read, stream_getline, stream_write, stream_close - cached I/O operations.

LIBRARIES

Abz Library (-labz), Debug Library (-ldebug)

SYNOPSIS

#include <abz/stream.h>

void stream_open(struct stream *stream, int fd");
ssize_t stream_read(struct stream *stream, void *buf, size_t count");
ssize_t stream_getline(struct stream *stream, char **buf");
ssize_t stream_write(struct stream *stream, const char *buf, size_t count");
void stream_close(struct stream *stream");

DESCRIPTION

These functions perform I/O operations on a file descriptor and possibly caches read data. These functions should not be mixed with calls to read() or write().

stream_open() initializes the stream structure. It should be called before any of the other functions. The fd parameter should be an open file descriptor.

stream_read() attempts to read up to count bytes from the stream into the buffer starting at buf. If count is zero, read() returns zero and has no other results. If count is greater than SSIZE_MAX, the result is unspecified.

stream_getline() reads exactly one line of data, including the trailing 'n' from the stream. It allocates memory for, and stores the result in buf. This function should only be called on file descriptors with blocking I/O selected as it will only return when a newline character is found or at the end of a file.

stream_write() writes up to count bytes to the file referenced by the file descriptor fd from the buffer starting at buf.

stream_close() free resources allocated for the stream and close and the file descriptor.

RETURN VALUES

Except for stream_open() and stream_close(), all of these functions return the number of bytes transferred or -1 if an error occurred. Call abz_get_error() to retrieve error messages.

NOTES

None of the libabz routines are thread-safe. I'm not planning to change this either! For more information, please see http://threading.2038bug.com/

SEE ALSO

AUTHOR

Written by Abraham vd Merwe <abz@blio.com>

CETTE PAGE DOCUMENTE AUSSI :