Common openscap utilities. More...
#include "alloc.h"
Go to the source code of this file.
Data Structures | |
struct | oscap_string_map |
Define mapping between symbolic constant and its string representation. More... | |
Defines | |
#define | OSCAP_GENERIC_GETTER_CONV(RTYPE, CONV, SNAME, MNAME, MEXP) RTYPE SNAME##_get_##MNAME(const struct SNAME* item) { return (CONV(item->MEXP)); } |
Generate a getter function with an optional conversion. | |
#define | OSCAP_GENERIC_GETTER(RTYPE, SNAME, MNAME, MEXP) OSCAP_GENERIC_GETTER_CONV(RTYPE,,SNAME,MNAME,MEXP) |
Generate a getter function. | |
#define | OSCAP_GENERIC_GETTER_FORCE(RTYPE, SNAME, MNAME, MEXP) OSCAP_GENERIC_GETTER_CONV(RTYPE,(RTYPE),SNAME,MNAME,MEXP) |
Generate a getter function with an explicit conversion to the target data type. | |
#define | OSCAP_GETTER_FORCE(RTYPE, SNAME, MNAME) OSCAP_GENERIC_GETTER_FORCE(RTYPE,SNAME,MNAME,MNAME) |
Generate a getter function with an explicit conversion to the target data type. | |
#define | OSCAP_GETTER(RTYPE, SNAME, MNAME) OSCAP_GENERIC_GETTER(RTYPE,SNAME,MNAME,MNAME) |
Generate a getter function. | |
#define | ITERATOR_CAST(x) ((struct oscap_iterator*)(x)) |
#define | OSCAP_ITERATOR(n) struct n##_iterator* |
#define | OSCAP_ITERATOR_FWD(n) struct n##_iterator; |
#define | OSCAP_ITERATOR_HAS_MORE(n) bool n##_iterator_has_more(OSCAP_ITERATOR(n) it) { return oscap_iterator_has_more(ITERATOR_CAST(it)); } |
#define | OSCAP_ITERATOR_NEXT(t, n) t n##_iterator_next(OSCAP_ITERATOR(n) it) { return oscap_iterator_next(ITERATOR_CAST(it)); } |
#define | OSCAP_ITERATOR_FREE(n) void n##_iterator_free(OSCAP_ITERATOR(n) it) { oscap_iterator_free(ITERATOR_CAST(it)); } |
#define | OSCAP_ITERATOR_GEN_T(t, n) OSCAP_ITERATOR_FWD(n) OSCAP_ITERATOR_HAS_MORE(n) OSCAP_ITERATOR_NEXT(t,n) OSCAP_ITERATOR_FREE(n) |
#define | OSCAP_ITERATOR_GEN(n) OSCAP_ITERATOR_GEN_T(struct n*,n) |
#define | OSCAP_IGETTER_CONV(ITYPE, SNAME, MNAME, CONV) |
Generate an iterator getter function. | |
#define | OSCAP_IGETTER(ITYPE, SNAME, MNAME) OSCAP_IGETTER_CONV(ITYPE,SNAME,MNAME,) |
Generate an iterator getter function. | |
#define | OSCAP_IGETTER_GEN(ITYPE, SNAME, MNAME) OSCAP_IGETTER(ITYPE,SNAME,MNAME) OSCAP_ITERATOR_GEN(ITYPE) |
Generate an iterator and its getter. | |
#define | OSCAP_HGETTER_EXP(RTYPE, SNAME, MNAME, MEXP) |
Generete a geter function from a hash table. | |
#define | OSCAP_HGETTER(RTYPE, SNAME, MNAME) OSCAP_HGETTER_EXP(RTYPE,SNAME,MNAME,MNAME) |
Generete a geter function from a hash table. | |
#define | OSCAP_HGETTER_STRUCT(RTYPE, SNAME, MNAME) OSCAP_HGETTER_EXP(struct RTYPE*,SNAME,MNAME,MNAME) |
Generete a geter function from a hash table. | |
Typedefs | |
typedef void(* | oscap_destruct_func )(void *) |
Function pointer to an object destructor. | |
typedef void(* | oscap_consumer_func )(void *, void *) |
Function pointer to an object consumer. |
Common openscap utilities.
#define OSCAP_GENERIC_GETTER | ( | RTYPE, | |||
SNAME, | |||||
MNAME, | |||||
MEXP | ) | OSCAP_GENERIC_GETTER_CONV(RTYPE,,SNAME,MNAME,MEXP) |
Generate a getter function.
RTYPE | return type | |
SNAME | name of the structure of which we are getting a member | |
MNAME | member name affects how the resultant function will be called | |
MEXP | expression to get the member |
#define OSCAP_GENERIC_GETTER_CONV | ( | RTYPE, | |||
CONV, | |||||
SNAME, | |||||
MNAME, | |||||
MEXP | ) | RTYPE SNAME##_get_##MNAME(const struct SNAME* item) { return (CONV(item->MEXP)); } |
Generate a getter function with an optional conversion.
Header of the generated function will look like this (substitute the capital letter sequences with the actual parametres):
RTYPE SNAME_MNAME(const struct SNAME*);
RTYPE | return type | |
CONV | conversion expression, i.e. either a type conversion of form '(type)' or an unary function identifier | |
SNAME | name of the structure of which we are getting a member (without the struct keyword) | |
MNAME | member name affects how the resultant function will be called | |
MEXP | expression to get the member |
#define OSCAP_GENERIC_GETTER_FORCE | ( | RTYPE, | |||
SNAME, | |||||
MNAME, | |||||
MEXP | ) | OSCAP_GENERIC_GETTER_CONV(RTYPE,(RTYPE),SNAME,MNAME,MEXP) |
Generate a getter function with an explicit conversion to the target data type.
RTYPE | return type | |
SNAME | name of the structure of which we are getting a member | |
MNAME | member name affects how the resultant function will be called | |
MEXP | expression to get the member |
#define OSCAP_GETTER | ( | RTYPE, | |||
SNAME, | |||||
MNAME | ) | OSCAP_GENERIC_GETTER(RTYPE,SNAME,MNAME,MNAME) |
Generate a getter function.
Member name and second part of the generated function's name must match.
RTYPE | return type | |
SNAME | name of the structure of which we are getting a member | |
MNAME | member name affects how the resultant function will be called | |
MEXP | expression to get the member |
#define OSCAP_GETTER_FORCE | ( | RTYPE, | |||
SNAME, | |||||
MNAME | ) | OSCAP_GENERIC_GETTER_FORCE(RTYPE,SNAME,MNAME,MNAME) |
Generate a getter function with an explicit conversion to the target data type.
Member name and second part of the generated function's name must match.
RTYPE | return type | |
SNAME | name of the structure of which we are getting a member | |
MNAME | member name affects how the resultant function will be called | |
MEXP | expression to get the member |
#define OSCAP_HGETTER | ( | RTYPE, | |||
SNAME, | |||||
MNAME | ) | OSCAP_HGETTER_EXP(RTYPE,SNAME,MNAME,MNAME) |
Generete a geter function from a hash table.
Signature of the generated function will be as follows (substitute uppercase strings with actual params):
RTYPE SNAME_MNAME(const struct SNAME* item, const char* key);
RTYPE | type of the hash table item | |
SNAME | name of the structure | |
MNAME | structure member name |
#define OSCAP_HGETTER_EXP | ( | RTYPE, | |||
SNAME, | |||||
MNAME, | |||||
MEXP | ) |
RTYPE SNAME##_get_##MNAME(const struct SNAME* item, const char* key) \ { return oscap_htable_get(item->MEXP, key); }
Generete a geter function from a hash table.
Signature of the generated function will be as follows (substitute uppercase strings with actual params):
RTYPE SNAME_MNAME(const struct SNAME* item, const char* key);
RTYPE | type of the hash table item | |
SNAME | name of the structure | |
MNAME | structure member name | |
MEXP | expression to get the member variable (i.e. the hash table) |
#define OSCAP_HGETTER_STRUCT | ( | RTYPE, | |||
SNAME, | |||||
MNAME | ) | OSCAP_HGETTER_EXP(struct RTYPE*,SNAME,MNAME,MNAME) |
Generete a geter function from a hash table.
Signature of the generated function will be as follows (substitute uppercase strings with actual params):
struct RTYPE* SNAME_MNAME(const struct SNAME* item, const char* key);
RTYPE | type of the hash table item | |
SNAME | name of the structure | |
MNAME | structure member name |
#define OSCAP_IGETTER | ( | ITYPE, | |||
SNAME, | |||||
MNAME | ) | OSCAP_IGETTER_CONV(ITYPE,SNAME,MNAME,) |
Generate an iterator getter function.
Signature of the generated function will be as follows (substitute uppercase strings with actual params):
struct ITYPE_iterator* SNAME_MNAME(const struct SNAME*);
ITYPE | iterator type (without the '_iterator' suffix) | |
SNAME | name of type the structure containing the list | |
MANME | list itself |
#define OSCAP_IGETTER_CONV | ( | ITYPE, | |||
SNAME, | |||||
MNAME, | |||||
CONV | ) |
struct ITYPE##_iterator* SNAME##_get_##MNAME(const struct SNAME* item) \ { return oscap_iterator_new((CONV(item))->MNAME); }
Generate an iterator getter function.
Signature of the generated function will be as follows (substitute uppercase strings with actual params):
struct ITYPE_iterator* SNAME_MNAME(const struct SNAME*);
ITYPE | iterator type (without the '_iterator' suffix) | |
SNAME | name of type the structure containing the list | |
MANME | list itself | |
CONV | convert expression |
#define OSCAP_IGETTER_GEN | ( | ITYPE, | |||
SNAME, | |||||
MNAME | ) | OSCAP_IGETTER(ITYPE,SNAME,MNAME) OSCAP_ITERATOR_GEN(ITYPE) |
Generate an iterator and its getter.