Initialize the default POSIX-layer function tables
#include <sys/iofunc.h> void iofunc_func_init( unsigned nconnect, resmgr_connect_funcs_t *connect, unsigned nio, resmgr_io_funcs_t *io );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
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.
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().
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |