|
libtrap
1.16.1
|
Functions | |
| int | trap_free_ifc_spec (trap_ifc_spec_t ifc_spec) |
| int | trap_init (trap_module_info_t *module_info, trap_ifc_spec_t ifc_spec) |
| int | trap_terminate () |
| int | trap_finalize () |
| int | trap_send_data (unsigned int ifcidx, const void *data, uint16_t size, int timeout) |
| int | trap_recv (uint32_t ifcidx, const void **data, uint16_t *size) |
| Receive data from input interface. More... | |
| int | trap_send (uint32_t ifcidx, const void *data, uint16_t size) |
| Send data via output interface. More... | |
| void | trap_set_verbose_level (int level) |
| int | trap_get_verbose_level () |
| void | trap_set_help_section (int level) |
| void | trap_print_help (const trap_module_info_t *module_info) |
| void | trap_print_ifc_spec_help () |
| int | trap_ifcctl (int8_t type, uint32_t ifcidx, int32_t request,...) |
| Control TRAP interface. More... | |
| void | trap_send_flush (uint32_t ifc) |
| Force flush of buffer. More... | |
Variables | |
| int | trap_last_error |
| Code of last error (one of the codes above) More... | |
| const char * | trap_last_error_msg |
| Human-readable message about last error. More... | |
| int trap_finalize | ( | ) |
Cleanup function. Disconnect all interfaces and do all necessary cleanup.
| int trap_free_ifc_spec | ( | trap_ifc_spec_t | ifc_spec | ) |
Destructor of trap_ifc_spec_t structure.
| [in] | ifc_spec | trap_ifc_spec_t structure to clear. |
| int trap_get_verbose_level | ( | ) |
Get verbosity level. See trap_set_verbose_level for list of levels.
| int trap_ifcctl | ( | int8_t | type, |
| uint32_t | ifcidx, | ||
| int32_t | request, | ||
| ... | |||
| ) |
Control TRAP interface.
| [in] | type | trap_ifc_type direction of interface |
| [in] | ifcidx | index of TRAP interface |
| [in] | request | trap_ifcctl_request type of operation |
| [in,out] | ... | arguments of request, see trap_ifcctl_request for more details on requests and their arguments. |
Examples:
| int trap_init | ( | trap_module_info_t * | module_info, |
| trap_ifc_spec_t | ifc_spec | ||
| ) |
Initialization function. Create and initialize all interfaces.
| [in] | module_info | Pointer to struct containing info about the module. |
| [in] | ifc_spec | Structure with specification of interface types and their parameters. |
| void trap_print_help | ( | const trap_module_info_t * | module_info | ) |
Print common TRAP help message. The help message contains information from module_info and describes common TRAP command-line parameters.
| [in] | module_info | Pointer to struct containing info about the module. |
| void trap_print_ifc_spec_help | ( | ) |
Print help about interface specifier. Prints help message about format of interface specifier and description of all available interface types. This message is normally a part of help printed by trap_print_help, this function is useful when you don't use standard TRAP command-line parameters but you still use the same format of interface specifier.
| int trap_recv | ( | uint32_t | ifcidx, |
| const void ** | data, | ||
| uint16_t * | size | ||
| ) |
Receive data from input interface.
Receive a message from interface specified by ifcidx and set pointer to the data. When function returns due to timeout, contents of data and size are undefined.
| [in] | ifcidx | Index of input IFC. |
| [out] | data | Pointer to received data. |
| [out] | size | Size of received data in bytes of data. |
| int trap_send | ( | uint32_t | ifcidx, |
| const void * | data, | ||
| uint16_t | size | ||
| ) |
Send data via output interface.
Send a message given by data pointer of size message size via interface specified by ifcidx that is the index of output interfaces (counted from 0).
| [in] | ifcidx | Index of input IFC. |
| [out] | data | Pointer to message to send. |
| [out] | size | Size of message in bytes. |
| int trap_send_data | ( | unsigned int | ifcidx, |
| const void * | data, | ||
| uint16_t | size, | ||
| int | timeout | ||
| ) |
Send data to output interface. Write data of size size given by data pointer into interface ifc. If data cannot be written immediately (e.g. because of full buffer or lost connection), wait until write is possible or timeout microseconds elapses. If timeout < 0, wait indefinitely.
| [in] | ifcidx | Index of interface to write into. |
| [in] | data | Pointer to data. |
| [in] | size | Number of bytes of data. |
| [in] | timeout | Timeout in microseconds for non-blocking mode; timeout can be also: TRAP_WAIT, TRAP_HALFWAIT, or TRAP_NO_WAIT. |
| void trap_send_flush | ( | uint32_t | ifc | ) |
Force flush of buffer.
| [in] | ifc | IFC Index of interface to write into. |
| void trap_set_help_section | ( | int | level | ) |
Set section for trap_print_help()
| [in] | level | 0 for default info about module, 1 for info about IFC specifier |
| void trap_set_verbose_level | ( | int | level | ) |
Set verbosity level of library functions. Verbosity levels may be:
| [in] | level | Desired level of verbosity. |
| int trap_terminate | ( | ) |
Function to terminate module's operation. This function stops all read/write operations on all interfaces. Any waiting in trap_recv() and trap_send()_data is interrupted and these functions return immediately with TRAP_E_TERMINATED. Any call of trap_recv() or trap_send() after call of this function returns TRAP_E_TERMINATED.
This function is used to terminate module's operation (asynchronously), e.g. in SIGTERM handler.
| int trap_last_error |
Code of last error (one of the codes above)
| const char* trap_last_error_msg |
Human-readable message about last error.
1.8.14