![]() |
![]() |
![]() |
Initialize default POSIX-layer tables
#include <sys/iofunc.h> void iofunc_func_init( unsigned nconnect, resmgr_connect_funcs_t *connect, unsigned nio, resmgr_io_funcs_t *io );
libc
The iofunc_func_init() function initializes the passed connect and io structures with the POSIX-layer default functions. Only the nconnect and nio entries amount of data will be initialized -- this is in place to support forward compatibility. Generally, you will pass the constants _RESMGR_CONNECT_NFUNCS and _RESMGR_IO_NFUNCS for the nconnect and nio parameters.
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 |
iofunc_attr_init(), resmgr_attach()
![]() |
![]() |
![]() |