iofunc_func_init()

Initialize the default POSIX-layer function tables

Synopsis:

#include <sys/iofunc.h>

void iofunc_func_init(
         unsigned nconnect,
         resmgr_connect_funcs_t *connect,
         unsigned nio,
         resmgr_io_funcs_t *io );

Arguments:

nconnect
The number of entries in the connect table that you want to fill. Typically, you pass _RESMGR_CONNECT_NFUNCS for this argument.
connect
A pointer to a resmgr_connect_funcs_t structure that you want to fill with the default connect functions.
nio
The number of entries in the io table that you want to fill. Typically, you pass _RESMGR_IO_NFUNCS for this argument.
io
A pointer to a resmgr_io_funcs_t structure that you want to fill with the default I/O functions.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The iofunc_func_init() function initializes the passed connect and io structures with the POSIX-layer default functions. For information about the default functions, see resmgr_connect_funcs_t and resmgr_io_funcs_t.

The nconnect and nio arguments indicate how many entries this function should fill. This is in place to support forward compatibility.

Examples:

Fill a connect and I/O function table with the POSIX-layer defaults:

#include <sys/iofunc.h>

static resmgr_connect_funcs_t my_connect_functions;
static resmgr_io_funcs_t my_io_functions;

int main (int argc, char **argv)
{
…
    iofunc_func_init (_RESMGR_CONNECT_NFUNCS, &my_connect_functions,
                      _RESMGR_IO_NFUNCS, &my_io_functions);

/*
 * At this point, the defaults have been filled in.
 * You may now override some of the default functions with
 * functions that you have written:
*/

    my_io_functions.io_read = my_io_read;
…
}

The above example initializes your connect and I/O function structures (my_connect_functions and my_io_functions) with the POSIX-layer defaults. If you didn't override any of the functions, your resource manager would behave like /dev/null — any data written to it would be discarded, and an attempt to read data from it would immediately return an EOF.

Since this isn't desirable in most cases, you'll often provide functionality for some functions, such as reading, writing, and device control to your device. In the example above, we've explicitly supplied our own handler for reading from the device, via a function called my_io_read().

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

iofunc_attr_init(), resmgr_attach(), resmgr_connect_funcs_t, resmgr_io_funcs_t

Writing a Resource Manager

Resource Managers chapter of Getting Started with QNX Neutrino