GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
jose_io(3) FreeBSD Library Functions Manual jose_io(3)

jose_io - IO Chaining.


struct jose_io_t
The interface for chained IO.


typedef jose_io_t jose_io_auto_t
Defines a jose_io_t which calls jose_io_decref() at end of scope.


jose_io_t * jose_io_incref (jose_io_t *io)
Increases the reference count of an IO object. void jose_io_decref (jose_io_t *io)
Decreases the reference count of an IO object. jose_io_t * jose_io_malloc (jose_cfg_t *cfg, void **buf, size_t *len)
Creates a new IO object which collects data into a dynamic buffer. void * jose_io_malloc_steal (void **buf)
Steals the buffer created by the jose_io_malloc() IO object. jose_io_t * jose_io_buffer (jose_cfg_t *cfg, void *buf, size_t *len)
Creates a new IO object which collects data into a static buffer. jose_io_t * jose_io_file (jose_cfg_t *cfg, FILE *file)
Creates a new IO object which writes data into a FILE. jose_io_t * jose_io_multiplex (jose_cfg_t *cfg, jose_io_t **nexts, bool all)
Creates a new IO object which multiplexes data into multiple IO objects.

IO Chaining.

Defines a jose_io_t which calls jose_io_decref() at end of scope. For example:

void foo() {
    uint8_t *buf = NULL;
    size_t len = 0;
    jose_io_auto_t *io = jose_io_malloc(NULL, &buf, &len);
    // jose_io_decref() implicitly called
}

Increases the reference count of an IO object. This function always succeeds.

Parameters:

io The jose_io_t entity you are using.

Returns:

The value of io (for convenience).

Decreases the reference count of an IO object. When the reference count reaches zero, io->free() is called.

Parameters:

io The jose_io_t entity you are using.

Creates a new IO object which collects data into a dynamic buffer. The dynamic buffer is allocated into the buf pointer you provided and the length of the buffer is stored in len. The pointer referenced by buf must remain valid for the entire duration of the returned IO object.

The default behavior is for the IO object to zero and free the buffer when it is freed. This means that, by default, you own the buffer pointer but the buffer itself is owned by the IO object. You can, however, steal the buffer by setting the buffer pointer to NULL.

See also:

jose_io_malloc_steal()

Parameters:

cfg The configuration context (optional).
buf A buffer pointer pointer.
len A pointer to the length of the buffer.

Returns:

The new IO object or NULL on error.

Steals the buffer created by the jose_io_malloc() IO object. This convenience function simply returns the value of *buf and then sets *buf to NULL.

See also:

jose_io_malloc()

Parameters:

buf A pointer to the buffer pointer.

Returns:

The value of *buf before it is set to NULL.

Creates a new IO object which collects data into a static buffer. The size of buf MUST be specified in the variable pointed to by len. This will be the maximum data written. However, after the function returns, the variable pointed to by len will contain the current length of data in the buffer.

Unlike jose_io_malloc(), you own the buffer and it is not zeroed or freed when the IO object is freed.

Parameters:

cfg The configuration context (optional).
buf A buffer pointer.
len A pointer to the length of the buffer.

Returns:

The new IO object or NULL on error.

Creates a new IO object which writes data into a FILE. This function DOES NOT take ownership of the FILE. You are still responsible for calling fclose() at the appropriate time.

Parameters:

cfg The configuration context (optional).
file The output file which MUST be opened for writing or appending.

Returns:

The new IO object or NULL on error.

Creates a new IO object which multiplexes data into multiple IO objects. If all is true, the success of all nexts is required. Otherwise, all but one of the nexts can fail before the error is propagated upward.

Parameters:

cfg The configuration context (optional).
nexts A NULL-terminated array of IO object pointers.
all Whether or not the success of all nexts is required.

Returns:

The new IO object or NULL on error.

Generated automatically by Doxygen for José from the source code.
Tue May 30 2017 José

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.