convenience macros for option

Overview

description More…

// macros

#define TAPI_JOB_OPT_ADDR_PORT_PTR(_prefix, _concat_prefix, _struct, _field)
#define TAPI_JOB_OPT_ADDR_PORT_PTR_TYPE
#define TAPI_JOB_OPT_ARRAY(_struct, _lenfield, _arrfield, ...)
#define TAPI_JOB_OPT_ARRAY_GEN(func_, prefix_, concat_prefix_, sep_, suffix_, struct_, lenfield_, arrfield_, is_ptr_, ...)
#define TAPI_JOB_OPT_ARRAY_PTR(struct_, lenfield_, arrfield_, ...)
#define TAPI_JOB_OPT_BOOL(_prefix, _struct, _field)
#define TAPI_JOB_OPT_BOOL_TYPE
#define TAPI_JOB_OPT_CONTENT(optname_, ...)
#define TAPI_JOB_OPT_DOUBLE(_prefix, _concat_prefix, _suffix, _struct, _field)
#define TAPI_JOB_OPT_DOUBLE_TYPE
#define TAPI_JOB_OPT_DUMMY(_prefix)
#define TAPI_JOB_OPT_EMBED_ARRAY(_prefix, _concat_prefix, _sep, _suffix, _struct, _lenfield, _arrfield, ...)
#define TAPI_JOB_OPT_EMBED_ARRAY_PTR(prefix_, concat_prefix_, sep_, suffix_, struct_, lenfield_, arrfield_, ...)
#define TAPI_JOB_OPT_ENUM(_prefix, _concat_prefix, _struct, _field, _map)
#define TAPI_JOB_OPT_ENUM_BOOL(_prefix, _concat_prefix, _struct, _field, _map)
#define TAPI_JOB_OPT_ENUM_BOOL3(_prefix, _concat_prefix, _struct, _field, _map)
#define TAPI_JOB_OPT_ENUM_UNDEF
#define TAPI_JOB_OPT_OFFSETOF_CHK_SIZE(_struct, _field, _exptype)
#define TAPI_JOB_OPT_OMIT_UINT
#define TAPI_JOB_OPT_QUOTED_STRING(prefix_, quotation_mark_, struct_, field_)
#define TAPI_JOB_OPT_QUOTED_STRING_TYPE
#define TAPI_JOB_OPT_SOCKADDR_PTR(_prefix, _concat_prefix, _struct, _field)
#define TAPI_JOB_OPT_SOCKADDR_PTR_TYPE
#define TAPI_JOB_OPT_SOCKADDR_SUBNET(prefix_, concat_prefix_, struct_, field_)
#define TAPI_JOB_OPT_SOCKADDR_SUBNET_TYPE
#define TAPI_JOB_OPT_SOCKPORT_PTR(_prefix, _concat_prefix, _struct, _field)
#define TAPI_JOB_OPT_SOCKPORT_PTR_TYPE
#define TAPI_JOB_OPT_STRING(_prefix, _concat_prefix, _struct, _field)
#define TAPI_JOB_OPT_STRING_TYPE
#define TAPI_JOB_OPT_STRUCT(_prefix, _concat_prefix, _sep, _suffix, ...)
#define TAPI_JOB_OPT_UINT(_prefix, _concat_prefix, _suffix, _struct, _field)
#define TAPI_JOB_OPT_UINTMAX_T(_prefix, _concat_prefix, _suffix, _struct, _field)
#define TAPI_JOB_OPT_UINTMAX_T_TYPE
#define TAPI_JOB_OPT_UINT_OMITTABLE(_prefix, _concat_prefix, _suffix, _struct, _field)
#define TAPI_JOB_OPT_UINT_OMITTABLE_TYPE
#define TAPI_JOB_OPT_UINT_T(_prefix, _concat_prefix, _suffix, _struct, _field)
#define TAPI_JOB_OPT_UINT_TYPE
#define TAPI_JOB_OPT_UINT_T_HEX(_prefix, _concat_prefix, _suffix, _struct, _field)
#define TAPI_JOB_OPT_UINT_T_HEX_TYPE
#define TAPI_JOB_OPT_UINT_T_OCTAL(_prefix, _concat_prefix, _suffix, _struct, _field)
#define TAPI_JOB_OPT_UINT_T_OCTAL_TYPE
#define TAPI_JOB_OPT_UINT_T_TYPE

Detailed Documentation

description

Macros

#define TAPI_JOB_OPT_ADDR_PORT_PTR(_prefix, _concat_prefix, _struct, _field)

Bind struct sockaddr * argument (formatted as “address:port”). The argument won’t be included in command line if the field is NULL.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_struct

Option struct.

_field

Field name of the address in option struct.

#define TAPI_JOB_OPT_ADDR_PORT_PTR_TYPE

Value type used in TAPI_JOB_OPT_ADDR_PORT_PTR().

#define TAPI_JOB_OPT_ARRAY(_struct, _lenfield, _arrfield, ...)

Bind tapi_job_opt_array argument.

Parameters:

_struct

Option struct.

_lenfield

Field name of the array length in the option struct (size_t).

_arrfield

Field name of the array data field. It must be the genuine inline array, not a pointer, and it must come after the _lenfield

Binding for a element (must be a valid initializer list for tapi_job_opt_bind, e.g as provided by convenience macros; the argument is a vararg because members of the list are treated by the preprocessor as individual macro arguments). The offset of the binding shall be that of _arrfield[0] (mind the index) for field size checks to work correctly.

#define TAPI_JOB_OPT_ARRAY_GEN(func_, prefix_, concat_prefix_, sep_, suffix_, struct_, lenfield_, arrfield_, is_ptr_, ...)

Generic macro to bind tapi_job_opt_array argument.

This macros shall never be used directly.

See also:

TAPI_JOB_OPT_ARRAY(), TAPI_JOB_OPT_EMBED_ARRAY(), TAPI_JOB_OPT_ARRAY_PTR(), TAPI_JOB_OPT_EMBED_ARRAY_PTR(),

#define TAPI_JOB_OPT_ARRAY_PTR(struct_, lenfield_, arrfield_, ...)

Bind tapi_job_opt_array argument with pointer to array.

Parameters:

struct_

Option struct.

lenfield_

Field name of the array length in the option struct (size_t).

arrfield_

Field name of the pointer to array data field. It must be the pointer to array, and it must come after the lenfield_.

Binding for a element (must be a valid initializer list for tapi_job_opt_bind, e.g as provided by convenience macros; the argument is a vararg because members of the list are treated by the preprocessor as individual macro arguments). To set the correct offset, use TAPI_JOB_OPT_CONTENT() wrapper.

#define TAPI_JOB_OPT_BOOL(_prefix, _struct, _field)

Bind te_bool argument.

Parameters:

_prefix

Argument prefix.

_struct

Option struct.

_field

Field name of the bool in option struct.

#define TAPI_JOB_OPT_BOOL_TYPE

Value type used in TAPI_JOB_OPT_BOOL().

#define TAPI_JOB_OPT_CONTENT(optname_, ...)

An adaptor for indirect struct fields.

Macros for option formatting would not work with indirect non-struct values, since they calculate offset of a field from the start of a struct.

This adaptor creates an anonymous structure with a field of a correct type. For example, there is the following structure with a field:

typedef struct binds {
    size_t argc;
    const char **argv;
} binds;

Where argv is an pointer to an array of strings of argc length. This field can be processed as follows:

TAPI_JOB_OPT_ARRAY_PTR(binds, argc, argv,
    TAPI_JOB_OPT_CONTENT(TAPI_JOB_OPT_STRING(NULL, FALSE))

New formatting macros shall define a *_TYPE macro for this adaptor to work (for example, TAPI_JOB_OPT_STRING_TYPE()).

Parameters:

optname_

Name of the macro.

Arguments required for the macro. Except for the last two: type and field.

#define TAPI_JOB_OPT_DOUBLE(_prefix, _concat_prefix, _suffix, _struct, _field)

Bind tapi_job_opt_double_t argument.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_suffix

Argument suffix.

_struct

Option struct.

_field

Field name in option struct.

#define TAPI_JOB_OPT_DOUBLE_TYPE

Value type used in TAPI_JOB_OPT_DOUBLE().

#define TAPI_JOB_OPT_DUMMY(_prefix)

Bind none argument.

Parameters:

_prefix

Option name.

#define TAPI_JOB_OPT_EMBED_ARRAY(_prefix, _concat_prefix, _sep, _suffix, _struct, _lenfield, _arrfield, ...)

Bind tapi_job_opt_array argument.

Unlike TAPI_JOB_OPT_ARRAY(), all array elements will be packed into a single argument, separated by _sep. This combined argument may have a _prefix and a _suffix, like e.g. TAPI_JOB_OPT_UINT()

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate the prefix with an argument if TRUE.

_sep

Array element separator.

_suffix

Argument suffix.

_struct

Option struct.

_lenfield

Field name of the array length in the option struct (size_t).

_arrfield

Field name of the array data field. It must be the genuine inline array, not a pointer, and it must come after the _lenfield.

Binding for a element (must be a valid initializer list for tapi_job_opt_bind, e.g as provided by convenience macros; the argument is a vararg because members of the list are treated by the preprocessor as individual macro arguments). The offset of the binding shall be that of _arrfield[0] (mind the index) for field size checks to work correctly.

#define TAPI_JOB_OPT_EMBED_ARRAY_PTR(prefix_, concat_prefix_, sep_, suffix_, struct_, lenfield_, arrfield_, ...)

Bind tapi_job_opt_array argument with pointer to array.

Unlike TAPI_JOB_OPT_ARRAY_PTR(), all array elements will be packed into a single argument, separated by sep_. This combined argument may have a prefix_ and a suffix_, like e.g. TAPI_JOB_OPT_UINT().

Parameters:

prefix_

Argument prefix.

concat_prefix_

Concatenate the prefix with an argument if TRUE.

sep_

Array element separator.

suffix_

Argument suffix.

struct_

Option struct.

lenfield_

Field name of the array length in the option struct (size_t).

arrfield_

Field name of the pointer to array data field. It must be the pointer to array, and it must come after the lenfield_.

Binding for a element (must be a valid initializer list for tapi_job_opt_bind, e.g as provided by convenience macros; the argument is a vararg because members of the list are treated by the preprocessor as individual macro arguments). To set the correct offset, use TAPI_JOB_OPT_CONTENT() wrapper.

#define TAPI_JOB_OPT_ENUM(_prefix, _concat_prefix, _struct, _field, _map)

Bind an enumeration argument using a custom mapping _map from values to strings.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_struct

Option struct.

_field

Field name of the enumeration in option struct. The field must have the same size as int. In most (if not all) standard ABIs this means enum -typed fields may be freely used. There is a compile-check for that constraint.

_map

Enumeration mapping (te_enum_map array)

#define TAPI_JOB_OPT_ENUM_BOOL(_prefix, _concat_prefix, _struct, _field, _map)

Bind a boolean argument using a custom mapping _map from values to strings.

Constrast with TAPI_JOB_OPT_BOOL which adds or omits the parameterless option depending on the booleanb value.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_struct

Option struct.

_field

Field name of the boolean in option struct. The field must have the same size as int. In most (if not all) standard ABIs this means enum -typed fields may be freely used. There is a compile-check for that constraint.

_map

Enumeration mapping (te_enum_map array). The map shall contain two elements for TRUE and FALSE

#define TAPI_JOB_OPT_ENUM_BOOL3(_prefix, _concat_prefix, _struct, _field, _map)

Bind a ternary boolean argument using a custom mapping _map from values to strings.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_struct

Option struct.

_field

Field name of the boolean in option struct. The field must have the same size as int. In most (if not all) standard ABIs this means enum -typed fields may be freely used. There is a compile-check for that constraint.

_map

Enumeration mapping (te_enum_map array). The map shall contain two elements for TE_BOOL3_TRUE and TE_BOOL3_FALSE.

#define TAPI_JOB_OPT_ENUM_UNDEF

Undefined value for enum option

#define TAPI_JOB_OPT_OFFSETOF_CHK_SIZE(_struct, _field, _exptype)

An auxiliary wrapper that provides an offset of the _field in the _struct statically checking that its size is the same as the size of _exptype

#define TAPI_JOB_OPT_OMIT_UINT

The value is used to omit uint argument when it is bound with TAPI_JOB_OPT_UINT_OMITTABLE.

#define TAPI_JOB_OPT_QUOTED_STRING(prefix_, quotation_mark_, struct_, field_)

Bind char * argument (formatted as ```` <quotation_mark>string<quotation_mark>).

Parameters:

prefix_

Argument prefix.

quotation_mark_

Quote symbol.

struct_

Option struct.

field_

Field name of the string in option struct.

#define TAPI_JOB_OPT_QUOTED_STRING_TYPE

Value type used in TAPI_JOB_OPT_QUOTED_STRING().

#define TAPI_JOB_OPT_SOCKADDR_PTR(_prefix, _concat_prefix, _struct, _field)

Bind struct sockaddr * argument. The argument won’t be included to command line if the field is NULL.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE

_struct

Option struct.

_field

Field name of the string in option struct.

#define TAPI_JOB_OPT_SOCKADDR_PTR_TYPE

Value type used in TAPI_JOB_OPT_SOCKADDR_PTR().

#define TAPI_JOB_OPT_SOCKADDR_SUBNET(prefix_, concat_prefix_, struct_, field_)

Bind te_sockaddr_subnet argument (formatted as addr/prefix_len).

The argument won’t be included in command line if the field is NULL.

Parameters:

prefix_

Argument prefix.

concat_prefix_

Concatenate prefix with argument if TRUE.

struct_

Option struct.

field_

Field name of the subnet in option struct.

#define TAPI_JOB_OPT_SOCKADDR_SUBNET_TYPE

Value type used in TAPI_JOB_OPT_SOCKADDR_SUBNET().

#define TAPI_JOB_OPT_SOCKPORT_PTR(_prefix, _concat_prefix, _struct, _field)

Bind struct sockaddr * argument (formatted as “port”). The argument won’t be included in command line if the field is NULL.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_struct

Option struct.

_field

Field name of the address in option struct.

#define TAPI_JOB_OPT_SOCKPORT_PTR_TYPE

Value type used in TAPI_JOB_OPT_SOCKPORT_PTR().

#define TAPI_JOB_OPT_STRING(_prefix, _concat_prefix, _struct, _field)

Bind char * argument.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE

_struct

Option struct.

_field

Field name of the string in option struct.

#define TAPI_JOB_OPT_STRING_TYPE

Value type used in TAPI_JOB_OPT_STRING().

#define TAPI_JOB_OPT_STRUCT(_prefix, _concat_prefix, _sep, _suffix, ...)

Bind tapi_job_opt_struct argument.

Unlike TAPI_JOB_OPT_ARRAY() and TAPI_JOB_OPT_EMBED_ARRAY(), it allows to create structures with different types of variables and output them using a separator _sep. This combined argument may have a _prefix and a _suffix, like e.g. TAPI_JOB_OPT_UINT().

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate the prefix with an argument if TRUE.

_sep

Array element separator.

_suffix

Argument suffix.

Bindings for elements (must be a valid initializer list for tapi_job_opt_bind, e.g as provided by convenience macros; the argument is a vararg because members of the list are treated by the preprocessor as individual macro arguments).

#define TAPI_JOB_OPT_UINT(_prefix, _concat_prefix, _suffix, _struct, _field)

Bind unsigned int argument.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE

_suffix

Argument suffix.

_struct

Option struct.

_field

Field name of the uint in option struct.

#define TAPI_JOB_OPT_UINTMAX_T(_prefix, _concat_prefix, _suffix, _struct, _field)

Bind tapi_job_opt_uintmax_t argument.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_suffix

Argument suffix.

_struct

Option struct.

_field

Field name in option struct.

#define TAPI_JOB_OPT_UINTMAX_T_TYPE

Value type used in TAPI_JOB_OPT_UINTMAX_T().

#define TAPI_JOB_OPT_UINT_OMITTABLE(_prefix, _concat_prefix, _suffix, _struct, _field)

Similar to TAPI_JOB_OPT_UINT, but the argument will not be included in command line options if argument’s value is equal to TAPI_JOB_OPT_OMIT_UINT. This implies that the real argument’s value cannot be equal to the value of TAPI_JOB_OPT_OMIT_UINT.

This macro is deprecated, use tapi_job_uint_t with TAPI_JOB_OPT_UINT_T() instead.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE

_suffix

Argument suffix.

_struct

Option struct.

_field

Field name of the uint in option struct.

#define TAPI_JOB_OPT_UINT_OMITTABLE_TYPE

Value type used in TAPI_JOB_OPT_UINT_OMITTABLE().

#define TAPI_JOB_OPT_UINT_T(_prefix, _concat_prefix, _suffix, _struct, _field)

Bind tapi_job_opt_uint_t argument.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_suffix

Argument suffix.

_struct

Option struct.

_field

Field name in option struct.

#define TAPI_JOB_OPT_UINT_TYPE

Value type used in TAPI_JOB_OPT_UINT().

#define TAPI_JOB_OPT_UINT_T_HEX(_prefix, _concat_prefix, _suffix, _struct, _field)

Bind tapi_job_opt_uint_t argument, specifying it in hexadecimal format in command line.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_suffix

Argument suffix.

_struct

Option struct.

_field

Field name in option struct.

#define TAPI_JOB_OPT_UINT_T_HEX_TYPE

Value type used in TAPI_JOB_OPT_UINT_T_HEX().

#define TAPI_JOB_OPT_UINT_T_OCTAL(_prefix, _concat_prefix, _suffix, _struct, _field)

Bind tapi_job_opt_uint_t argument, specifying it in octal format in command line.

Parameters:

_prefix

Argument prefix.

_concat_prefix

Concatenate prefix with argument if TRUE.

_suffix

Argument suffix.

_struct

Option struct.

_field

Field name in option struct.

#define TAPI_JOB_OPT_UINT_T_OCTAL_TYPE

Value type used in TAPI_JOB_OPT_UINT_T_OCTAL().

#define TAPI_JOB_OPT_UINT_T_TYPE

Value type used in TAPI_JOB_OPT_UINT_T().