iofunc_func_init()

Инициализировать стандартные таблицы функций POSIX-уровня

Прототип:

#include <sys/iofunc.h>
void iofunc_func_init( unsigned nconnect,
resmgr_connect_funcs_t *connect,
unsigned nio,
resmgr_io_funcs_t *io );

Аргументы:

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.

Библиотека:

libc

Описание:

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().

Классификация:

ЗОСРВ «Нейтрино»

Точка остановки потока
Нет
Обработчик прерываний
Нет
Обработчик сигналов
Да
В потоке
Да

Тематические ссылки:

iofunc_attr_init(), resmgr_attach(), resmgr_connect_funcs_t, resmgr_io_funcs_t




Предыдущий раздел: Описание API системной библиотеки