libtrap
1.16.1
|
Data Structures | |
struct | trap_module_info_parameter_s |
struct | trap_module_info_s |
Macros | |
#define | GEN_LONG_OPT_STRUCT_LINE(p_short_opt, p_long_opt, p_description, p_required_argument, p_argument_type) {p_long_opt, p_required_argument, 0, p_short_opt}, |
#define | GEN_LONG_OPT_STRUCT(PARAMS) |
#define | ALLOCATE_BASIC_INFO_2(module_info, p_name, p_description, p_input, p_output) |
#define | ALLOCATE_BASIC_INFO(p_name, p_description, p_input, p_output) ALLOCATE_BASIC_INFO_2(module_info, p_name, p_description, p_input, p_output) |
#define | ALLOCATE_PARAM_ITEMS_2(m, param_id, p_short_opt, p_long_opt, p_description, p_required_argument, p_argument_type) |
#define | ALLOCATE_PARAM_ITEMS(p_short_opt, p_long_opt, p_description, p_required_argument, p_argument_type) |
#define | FREE_BASIC_INFO(p_name, p_description, p_input, p_output) |
#define | FREE_PARAM_ITEMS(p_short_opt, p_long_opt, p_description, p_required_argument, p_argument_type) |
#define | GENERATE_GETOPT_STRING(p_short_opt, p_long_opt, p_description, p_required_argument, p_argument_type) |
#define | COUNT_MODULE_PARAMS(p_short_opt, p_long_opt, p_description, p_required_argument, p_argument_type) trap_module_params_cnt++; |
#define | INIT_MODULE_INFO_STRUCT(BASIC, PARAMS) |
#define | FREE_MODULE_INFO_STRUCT(BASIC, PARAMS) |
Typedefs | |
typedef struct trap_module_info_parameter_s | trap_module_info_parameter_t |
typedef struct trap_module_info_s | trap_module_info_t |
Functions | |
trap_module_info_t * | trap_create_module_info (const char *mname, const char *mdesc, int8_t i_ifcs, int8_t o_ifcs, uint16_t param_count) |
int | trap_update_module_param (trap_module_info_t *m, uint16_t param_id, char shortopt, const char *longopt, const char *desc, int req_arg, const char *arg_type) |
This section contains a set of macros that should be used for definition of parameters for a module. Usage of these macros helps to generate machine readable information about module that can be read e.g. by supervisor.
This example show the usage of macros defined in this section.
#define ALLOCATE_BASIC_INFO | ( | p_name, | |
p_description, | |||
p_input, | |||
p_output | |||
) | ALLOCATE_BASIC_INFO_2(module_info, p_name, p_description, p_input, p_output) |
Macro for allocation and initialization of module basic information in global module_info
[in] | p_name | module's name |
[in] | p_description | module's description |
[in] | p_input | number of input IFCs |
[in] | p_output | number of output IFCs |
Definition at line 202 of file trap_module_info.h.
#define ALLOCATE_BASIC_INFO_2 | ( | module_info, | |
p_name, | |||
p_description, | |||
p_input, | |||
p_output | |||
) |
Macro for allocation and initialization of module basic information
[in,out] | module_info | pointer to module_info |
[in] | p_name | module's name |
[in] | p_description | module's description |
[in] | p_input | number of input IFCs |
[in] | p_output | number of output IFCs |
Definition at line 179 of file trap_module_info.h.
#define ALLOCATE_PARAM_ITEMS | ( | p_short_opt, | |
p_long_opt, | |||
p_description, | |||
p_required_argument, | |||
p_argument_type | |||
) |
Macro for allocation and initialization of module parameters information in global module_info
[in] | p_short_opt | short option |
[in] | p_long_opt | long option |
[in] | p_description | option description |
[in] | p_required_argument | no_argument | required_argument | optional_argument |
[in] | p_argument_type | data type of option argument |
Definition at line 257 of file trap_module_info.h.
#define ALLOCATE_PARAM_ITEMS_2 | ( | m, | |
param_id, | |||
p_short_opt, | |||
p_long_opt, | |||
p_description, | |||
p_required_argument, | |||
p_argument_type | |||
) |
Macro for allocation and initialization of module parameters information
[in] | m | module_info pointer |
[in] | param_id | index of parameter to set |
[in] | p_short_opt | short option |
[in] | p_long_opt | long option |
[in] | p_description | option description |
[in] | p_required_argument | no_argument | required_argument | optional_argument |
[in] | p_argument_type | data type of option argument |
Definition at line 215 of file trap_module_info.h.
#define COUNT_MODULE_PARAMS | ( | p_short_opt, | |
p_long_opt, | |||
p_description, | |||
p_required_argument, | |||
p_argument_type | |||
) | trap_module_params_cnt++; |
Macro counting number of module parameters - memory allocation purpose
Definition at line 308 of file trap_module_info.h.
#define FREE_BASIC_INFO | ( | p_name, | |
p_description, | |||
p_input, | |||
p_output | |||
) |
Macro releasing memory allocated for module basic information in global variable module_info
Definition at line 263 of file trap_module_info.h.
#define FREE_MODULE_INFO_STRUCT | ( | BASIC, | |
PARAMS | |||
) |
Macro releasing whole module_info structure allocated in global variable module_info First argument is macro defining module basic information (name, description, number of input/output interfaces) Second argument is macro defining all module parameters and their values
Definition at line 361 of file trap_module_info.h.
#define FREE_PARAM_ITEMS | ( | p_short_opt, | |
p_long_opt, | |||
p_description, | |||
p_required_argument, | |||
p_argument_type | |||
) |
Macro releasing memory allocated for module parameters information in global variable module_info
Definition at line 275 of file trap_module_info.h.
#define GEN_LONG_OPT_STRUCT | ( | PARAMS | ) |
Macro generating long_options field for getopt_long function according to given macro with parameters
Definition at line 165 of file trap_module_info.h.
#define GEN_LONG_OPT_STRUCT_LINE | ( | p_short_opt, | |
p_long_opt, | |||
p_description, | |||
p_required_argument, | |||
p_argument_type | |||
) | {p_long_opt, p_required_argument, 0, p_short_opt}, |
Macro generating one line of long_options field for getopt_long function
Definition at line 161 of file trap_module_info.h.
#define GENERATE_GETOPT_STRING | ( | p_short_opt, | |
p_long_opt, | |||
p_description, | |||
p_required_argument, | |||
p_argument_type | |||
) |
Definition at line 295 of file trap_module_info.h.
#define INIT_MODULE_INFO_STRUCT | ( | BASIC, | |
PARAMS | |||
) |
Macro initializing whole module_info structure in global variable module_info First argument is macro defining module basic information (name, description, number of input/output interfaces) Second argument is macro defining all module parameters and their values Last pointer of module info parameters array is NULL to detect end of the array without any counter
Definition at line 315 of file trap_module_info.h.
typedef struct trap_module_info_parameter_s trap_module_info_parameter_t |
Structure with information about one module parameter Every parameter contains short_opt, long_opt, description, flag whether the parameter requires argument and argument type.
typedef struct trap_module_info_s trap_module_info_t |
Structure with information about module This struct contains basic information about the module, such as module's name, number of interfaces etc. It's supposed to be filled with static data and passed to trap_init function.
trap_module_info_t* trap_create_module_info | ( | const char * | mname, |
const char * | mdesc, | ||
int8_t | i_ifcs, | ||
int8_t | o_ifcs, | ||
uint16_t | param_count | ||
) |
Allocate module info with empty parameters array.
[in] | mname | name of Nemea module |
[in] | mdesc | description of Nemea module |
[in] | i_ifcs | number of input IFCs |
[in] | o_ifcs | number of output IFCs |
[in] | param_count | number of parameters |
int trap_update_module_param | ( | trap_module_info_t * | m, |
uint16_t | param_id, | ||
char | shortopt, | ||
const char * | longopt, | ||
const char * | desc, | ||
int | req_arg, | ||
const char * | arg_type | ||
) |
Set module's parameter in the allocated module_info structure.
[in,out] | m | pointer to allocated module_info |
[in] | param_id | index of parameter which is set |
[in] | shortopt | short form of the parameter e.g. 'f' for -f |
[in] | longopt | long form of the parameter e.g. "file" for –file |
[in] | desc | description of the parameter |
[in] | req_arg | requirement of argument, use standard required_argument, no_argument, optional_argument |
[in] | arg_type | data type of argument |