\hypertarget{util_8h}{ \section{/home/pvrabec/openscap/openscap-\/0.5.7/src/common/util.h File Reference} \label{util_8h}\index{/home/pvrabec/openscap/openscap-\/0.5.7/src/common/util.h@{/home/pvrabec/openscap/openscap-\/0.5.7/src/common/util.h}} } Common openscap utilities. {\ttfamily \#include $<$stdbool.h$>$}\par {\ttfamily \#include $<$assert.h$>$}\par {\ttfamily \#include \char`\"{}public/oscap.h\char`\"{}}\par {\ttfamily \#include \char`\"{}public/alloc.h\char`\"{}}\par \subsection*{Data Structures} \begin{DoxyCompactItemize} \item struct \hyperlink{structoscap__string__map}{oscap\_\-string\_\-map} \begin{DoxyCompactList}\small\item\em Define mapping between symbolic constant and its string representation. \item\end{DoxyCompactList}\end{DoxyCompactItemize} \subsection*{Defines} \begin{DoxyCompactItemize} \item \hypertarget{util_8h_a1babff1afca81ac7c0fed50144d104fe}{ \#define {\bfseries \_\-\_\-attribute\_\-\_\-nonnull\_\-\_\-}(x)~assert((x) != NULL)} \label{util_8h_a1babff1afca81ac7c0fed50144d104fe} \item \hypertarget{util_8h_a563cdd8c1ef729ddb0efdcebb4d8454e}{ \#define {\bfseries OSCAP\_\-HIDDEN\_\-START}~\_\-Pragma(\char`\"{}GCC visibility push(hidden)\char`\"{})} \label{util_8h_a563cdd8c1ef729ddb0efdcebb4d8454e} \item \hypertarget{util_8h_af782b788db57b27e85421ab639b2b107}{ \#define {\bfseries OSCAP\_\-HIDDEN\_\-END}~\_\-Pragma(\char`\"{}GCC visibility pop\char`\"{})} \label{util_8h_af782b788db57b27e85421ab639b2b107} \item \#define \hyperlink{util_8h_a07984eadc1820caddf5fb09f8cc5f461}{OSCAP\_\-GENERIC\_\-GETTER\_\-CONV}(RTYPE, CONV, SNAME, MNAME, MEXP)~RTYPE SNAME\#\#\_\-get\_\-\#\#MNAME(const struct SNAME$\ast$ item) \{ return (CONV(item-\/$>$MEXP)); \} \begin{DoxyCompactList}\small\item\em Generate a getter function with an optional conversion. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a6537fbd7378c67b0a5cd34fbbb46cf32}{OSCAP\_\-GENERIC\_\-GETTER}(RTYPE, SNAME, MNAME, MEXP)~OSCAP\_\-GENERIC\_\-GETTER\_\-CONV(RTYPE,,SNAME,MNAME,MEXP) \begin{DoxyCompactList}\small\item\em Generate a getter function. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a2b5200ab726de57e775442cd5e6ea1c5}{OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE}(RTYPE, SNAME, MNAME, MEXP)~OSCAP\_\-GENERIC\_\-GETTER\_\-CONV(RTYPE,(RTYPE),SNAME,MNAME,MEXP) \begin{DoxyCompactList}\small\item\em Generate a getter function with an explicit conversion to the target data type. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a5b75e45a0f724a333b5da13bde0686ef}{OSCAP\_\-GETTER\_\-FORCE}(RTYPE, SNAME, MNAME)~OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE(RTYPE,SNAME,MNAME,MNAME) \begin{DoxyCompactList}\small\item\em Generate a getter function with an explicit conversion to the target data type. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_af0a2de3832f32a04e83b9fbfb5073541}{OSCAP\_\-GETTER}(RTYPE, SNAME, MNAME)~OSCAP\_\-GENERIC\_\-GETTER(RTYPE,SNAME,MNAME,MNAME) \begin{DoxyCompactList}\small\item\em Generate a getter function. \item\end{DoxyCompactList}\item \hypertarget{util_8h_a54330470d99c66955d018842686a4c08}{ \#define {\bfseries ITERATOR\_\-CAST}(x)~((struct \hyperlink{structoscap__iterator}{oscap\_\-iterator}$\ast$)(x))} \label{util_8h_a54330470d99c66955d018842686a4c08} \item \hypertarget{util_8h_aac231feffce19c6fb9e99436e078390a}{ \#define {\bfseries OSCAP\_\-ITERATOR}(n)~struct n\#\#\_\-iterator$\ast$} \label{util_8h_aac231feffce19c6fb9e99436e078390a} \item \hypertarget{util_8h_a5fd8671683f834ec3286535ab8c81bc6}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-FWD}(n)~struct n\#\#\_\-iterator;} \label{util_8h_a5fd8671683f834ec3286535ab8c81bc6} \item \hypertarget{util_8h_abf61d6175a466da3de64df35f19d30ec}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-HAS\_\-MORE}(n)~bool n\#\#\_\-iterator\_\-has\_\-more(OSCAP\_\-ITERATOR(n) it) \{ return oscap\_\-iterator\_\-has\_\-more(ITERATOR\_\-CAST(it)); \}} \label{util_8h_abf61d6175a466da3de64df35f19d30ec} \item \hypertarget{util_8h_a7f9a4599b8e4866cfacf0f59ddd24cb4}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-NEXT}(t, n)~t n\#\#\_\-iterator\_\-next(OSCAP\_\-ITERATOR(n) it) \{ return oscap\_\-iterator\_\-next(ITERATOR\_\-CAST(it)); \}} \label{util_8h_a7f9a4599b8e4866cfacf0f59ddd24cb4} \item \hypertarget{util_8h_afff4ae659802be92738f58c424fde14c}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-FREE}(n)~void n\#\#\_\-iterator\_\-free(OSCAP\_\-ITERATOR(n) it) \{ oscap\_\-iterator\_\-free(ITERATOR\_\-CAST(it)); \}} \label{util_8h_afff4ae659802be92738f58c424fde14c} \item \hypertarget{util_8h_aafffc0febb60e765fe00d2950dba3bb6}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-DETACH}(t, n)~t n\#\#\_\-iterator\_\-detach(OSCAP\_\-ITERATOR(n) it) \{ return oscap\_\-iterator\_\-detach(ITERATOR\_\-CAST(it)); \}} \label{util_8h_aafffc0febb60e765fe00d2950dba3bb6} \item \hypertarget{util_8h_a1c4f57de05949b06d112ca41a3a5c160}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-GEN\_\-T}(t, n)~OSCAP\_\-ITERATOR\_\-FWD(n) OSCAP\_\-ITERATOR\_\-HAS\_\-MORE(n) OSCAP\_\-ITERATOR\_\-NEXT(t,n) OSCAP\_\-ITERATOR\_\-FREE(n)} \label{util_8h_a1c4f57de05949b06d112ca41a3a5c160} \item \hypertarget{util_8h_a0dc22293c244079fc760a27d92b8eb51}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-GEN}(n)~OSCAP\_\-ITERATOR\_\-GEN\_\-T(struct n$\ast$,n)} \label{util_8h_a0dc22293c244079fc760a27d92b8eb51} \item \hypertarget{util_8h_a212d6a0fb2878b1c4b41cc4c6ee446e7}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-REMOVE\_\-T}(t, n, destructor)~void n\#\#\_\-iterator\_\-remove(OSCAP\_\-ITERATOR(n) it) \{ destructor(oscap\_\-iterator\_\-detach(ITERATOR\_\-CAST(it))); \}} \label{util_8h_a212d6a0fb2878b1c4b41cc4c6ee446e7} \item \hypertarget{util_8h_aa484850de2f761f4e26f31d65c2dc174}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-REMOVE}(n, destructor)~OSCAP\_\-ITERATOR\_\-REMOVE\_\-T(struct n$\ast$,n,destructor)} \label{util_8h_aa484850de2f761f4e26f31d65c2dc174} \item \hypertarget{util_8h_acd8134519d2874ad5cd90c088bf19e5a}{ \#define {\bfseries OSCAP\_\-ITERATOR\_\-REMOVE\_\-F}(n)~OSCAP\_\-ITERATOR\_\-REMOVE(n, n\#\#\_\-free)} \label{util_8h_acd8134519d2874ad5cd90c088bf19e5a} \item \#define \hyperlink{util_8h_aa9ea17012a7a5a4a4823e7ada948d930}{OSCAP\_\-IGETTER\_\-CONV}(ITYPE, SNAME, MNAME, CONV) \begin{DoxyCompactList}\small\item\em Generate an iterator getter function. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a2634e36b767ff8f1a538e5067842dc6a}{OSCAP\_\-IGETTER}(ITYPE, SNAME, MNAME)~OSCAP\_\-IGETTER\_\-CONV(ITYPE,SNAME,MNAME,) \begin{DoxyCompactList}\small\item\em Generate an iterator getter function. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_aa383eae0670f01c7b9d8f9780aedb9d1}{OSCAP\_\-IGETTER\_\-GEN}(ITYPE, SNAME, MNAME)~OSCAP\_\-IGETTER(ITYPE,SNAME,MNAME) OSCAP\_\-ITERATOR\_\-GEN(ITYPE) \begin{DoxyCompactList}\small\item\em Generate an iterator and its getter. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a1c95b2ccc329b8e3a1c7abd2cd5fee59}{OSCAP\_\-HGETTER\_\-EXP}(RTYPE, SNAME, MNAME, MEXP) \begin{DoxyCompactList}\small\item\em Generete a geter function from a hash table. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a830fc8c9d39d3004e3f28b69f7c43450}{OSCAP\_\-HGETTER}(RTYPE, SNAME, MNAME)~OSCAP\_\-HGETTER\_\-EXP(RTYPE,SNAME,MNAME,MNAME) \begin{DoxyCompactList}\small\item\em Generete a geter function from a hash table. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a8fe541399a78b234cbda8eb1532c12a1}{OSCAP\_\-HGETTER\_\-STRUCT}(RTYPE, SNAME, MNAME)~OSCAP\_\-HGETTER\_\-EXP(struct RTYPE$\ast$,SNAME,MNAME,MNAME) \begin{DoxyCompactList}\small\item\em Generete a geter function from a hash table. \item\end{DoxyCompactList}\item \hypertarget{util_8h_aa8d61176e91cfd82a052770db1383340}{ \#define {\bfseries OSCAP\_\-SETTER\_\-HEADER}(SNAME, MTYPE, MNAME)~bool SNAME\#\#\_\-set\_\-\#\#MNAME(struct SNAME $\ast$obj, MTYPE item)} \label{util_8h_aa8d61176e91cfd82a052770db1383340} \item \#define \hyperlink{util_8h_a98964606cf2ab84d093c1e4dae18f101}{OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK}(SNAME, MTYPE, MNAME, CHECK, DELETER, ASSIGNER) \begin{DoxyCompactList}\small\item\em Generete a setter function with a check. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a452283d465fda2043dd6f80ba43a35b3}{OSCAP\_\-SETTER\_\-GENERIC}(SNAME, MTYPE, MNAME, DELETER, ASSIGNER) \begin{DoxyCompactList}\small\item\em Generete a setter function without a check. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a94ff3491fb52ba23c0c66e1ca8afe115}{OSCAP\_\-SETTER\_\-GENERIC\_\-NODELETE}(SNAME, MTYPE, MNAME, ASSIGNER) \begin{DoxyCompactList}\small\item\em Generete a setter function without a check that does not delete the previous value. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a596f918f3ca6cbc014ec148262ba2d5c}{OSCAP\_\-SETTER\_\-SIMPLE}(SNAME, MTYPE, MNAME)~OSCAP\_\-SETTER\_\-GENERIC\_\-NODELETE(SNAME, MTYPE, MNAME, ) \begin{DoxyCompactList}\small\item\em Generete a setter function using a simple assignment. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a5f7f57c665211b0589af75b5e558ccf1}{OSCAP\_\-SETTER\_\-STRING}(SNAME, MNAME)~OSCAP\_\-SETTER\_\-GENERIC(SNAME, const char $\ast$, MNAME, free, oscap\_\-strdup) \begin{DoxyCompactList}\small\item\em Assign a string value to a structure member. \item\end{DoxyCompactList}\item \hypertarget{util_8h_ade0c5f5243684c8b21023c02b2e7073f}{ \#define \hyperlink{util_8h_ade0c5f5243684c8b21023c02b2e7073f}{OSCAP\_\-ACCESSOR\_\-STRING}(SNAME, MNAME)~OSCAP\_\-SETTER\_\-STRING(SNAME, MNAME) OSCAP\_\-GETTER(const char$\ast$, SNAME, MNAME)} \label{util_8h_ade0c5f5243684c8b21023c02b2e7073f} \begin{DoxyCompactList}\small\item\em Define both, getter and setter for a string structure member. \item\end{DoxyCompactList}\item \hypertarget{util_8h_a3b0299d8e4ca40797a73fd82c502e8a9}{ \#define \hyperlink{util_8h_a3b0299d8e4ca40797a73fd82c502e8a9}{OSCAP\_\-ACCESSOR\_\-SIMPLE}(MTYPE, SNAME, MNAME)~OSCAP\_\-SETTER\_\-SIMPLE(SNAME, MTYPE, MNAME) OSCAP\_\-GETTER(MTYPE, SNAME, MNAME)} \label{util_8h_a3b0299d8e4ca40797a73fd82c502e8a9} \begin{DoxyCompactList}\small\item\em Define both, getter and setter for a structure member using simple get/set. \item\end{DoxyCompactList}\item \#define \hyperlink{util_8h_a58a4f69509578fe726d273e47feadee9}{OSCAP\_\-INSERTER}(SNAME, FNAME, MTYPE, MNAME) \begin{DoxyCompactList}\small\item\em Generate function to insert an item into a list. \item\end{DoxyCompactList}\item \hypertarget{util_8h_a16b17690bb73f4419a3490ad834ba444}{ \#define {\bfseries OSCAP\_\-IGETINS}(ITYPE, SNAME, MNAME, FNAME)~OSCAP\_\-IGETTER(ITYPE, SNAME, MNAME) OSCAP\_\-INSERTER(SNAME, FNAME, ITYPE, MNAME)} \label{util_8h_a16b17690bb73f4419a3490ad834ba444} \item \hypertarget{util_8h_a17d23d9f0d184388cd700d4773639c54}{ \#define {\bfseries OSCAP\_\-IGETINS\_\-GEN}(ITYPE, SNAME, MNAME, FNAME)~OSCAP\_\-IGETTER\_\-GEN(ITYPE, SNAME, MNAME) OSCAP\_\-INSERTER(SNAME, FNAME, ITYPE, MNAME)} \label{util_8h_a17d23d9f0d184388cd700d4773639c54} \end{DoxyCompactItemize} \subsection*{Typedefs} \begin{DoxyCompactItemize} \item \hypertarget{util_8h_ad2a4648e28ae682b86489ac8be3a22fc}{ typedef void($\ast$ \hyperlink{util_8h_ad2a4648e28ae682b86489ac8be3a22fc}{oscap\_\-destruct\_\-func} )(void $\ast$)} \label{util_8h_ad2a4648e28ae682b86489ac8be3a22fc} \begin{DoxyCompactList}\small\item\em Function pointer to an object destructor. \item\end{DoxyCompactList}\item \hypertarget{util_8h_ac32fc75588117050825915e52af52992}{ typedef void($\ast$ \hyperlink{util_8h_ac32fc75588117050825915e52af52992}{oscap\_\-consumer\_\-func} )(void $\ast$, void $\ast$)} \label{util_8h_ac32fc75588117050825915e52af52992} \begin{DoxyCompactList}\small\item\em Function pointer to an object consumer. \item\end{DoxyCompactList}\end{DoxyCompactItemize} \subsection*{Functions} \begin{DoxyCompactItemize} \item char $\ast$ \hyperlink{util_8h_a6b16df3c5b6a73bb8e7ca890a5bcbbbf}{oscap\_\-strdup} (const char $\ast$str) \begin{DoxyCompactList}\small\item\em Use strdup on string, if string is NULL, return NULL. \item\end{DoxyCompactList}\item char $\ast$ \hyperlink{util_8h_aa7e2b327cb6228bbe863ce31048a8808}{oscap\_\-strsep} (char $\ast$$\ast$str, const char $\ast$delim) \begin{DoxyCompactList}\small\item\em Use strsep on string We can't use strsep from string.h because of compatibility issues. \item\end{DoxyCompactList}\end{DoxyCompactItemize} \subsection{Detailed Description} Common openscap utilities. \subsection{Define Documentation} \hypertarget{util_8h_a6537fbd7378c67b0a5cd34fbbb46cf32}{ \index{util.h@{util.h}!OSCAP\_\-GENERIC\_\-GETTER@{OSCAP\_\-GENERIC\_\-GETTER}} \index{OSCAP\_\-GENERIC\_\-GETTER@{OSCAP\_\-GENERIC\_\-GETTER}!util.h@{util.h}} \subsubsection[{OSCAP\_\-GENERIC\_\-GETTER}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-GENERIC\_\-GETTER(RTYPE, \/ SNAME, \/ MNAME, \/ MEXP)~OSCAP\_\-GENERIC\_\-GETTER\_\-CONV(RTYPE,,SNAME,MNAME,MEXP)}} \label{util_8h_a6537fbd7378c67b0a5cd34fbbb46cf32} Generate a getter function. \begin{DoxyParams}{Parameters} \item[{\em RTYPE}]return type \item[{\em SNAME}]name of the structure of which we are getting a member \item[{\em MNAME}]member name affects how the resultant function will be called \item[{\em MEXP}]expression to get the member \end{DoxyParams} \begin{DoxySeeAlso}{See also} \hyperlink{util_8h_a07984eadc1820caddf5fb09f8cc5f461}{OSCAP\_\-GENERIC\_\-GETTER\_\-CONV} \end{DoxySeeAlso} \hypertarget{util_8h_a07984eadc1820caddf5fb09f8cc5f461}{ \index{util.h@{util.h}!OSCAP\_\-GENERIC\_\-GETTER\_\-CONV@{OSCAP\_\-GENERIC\_\-GETTER\_\-CONV}} \index{OSCAP\_\-GENERIC\_\-GETTER\_\-CONV@{OSCAP\_\-GENERIC\_\-GETTER\_\-CONV}!util.h@{util.h}} \subsubsection[{OSCAP\_\-GENERIC\_\-GETTER\_\-CONV}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-GENERIC\_\-GETTER\_\-CONV(RTYPE, \/ CONV, \/ SNAME, \/ MNAME, \/ MEXP)~RTYPE SNAME\#\#\_\-get\_\-\#\#MNAME(const struct SNAME$\ast$ item) \{ return (CONV(item-\/$>$MEXP)); \}}} \label{util_8h_a07984eadc1820caddf5fb09f8cc5f461} 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): \begin{DoxyCode} RTYPE SNAME_MNAME(const struct SNAME*); \end{DoxyCode} \begin{DoxyParams}{Parameters} \item[{\em RTYPE}]return type \item[{\em CONV}]conversion expression, i.e. either a type conversion of form '(type)' or an unary function identifier \item[{\em SNAME}]name of the structure of which we are getting a member (without the struct keyword) \item[{\em MNAME}]member name affects how the resultant function will be called \item[{\em MEXP}]expression to get the member \end{DoxyParams} \hypertarget{util_8h_a2b5200ab726de57e775442cd5e6ea1c5}{ \index{util.h@{util.h}!OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE@{OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE}} \index{OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE@{OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE}!util.h@{util.h}} \subsubsection[{OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE(RTYPE, \/ SNAME, \/ MNAME, \/ MEXP)~OSCAP\_\-GENERIC\_\-GETTER\_\-CONV(RTYPE,(RTYPE),SNAME,MNAME,MEXP)}} \label{util_8h_a2b5200ab726de57e775442cd5e6ea1c5} Generate a getter function with an explicit conversion to the target data type. \begin{DoxyParams}{Parameters} \item[{\em RTYPE}]return type \item[{\em SNAME}]name of the structure of which we are getting a member \item[{\em MNAME}]member name affects how the resultant function will be called \item[{\em MEXP}]expression to get the member \end{DoxyParams} \begin{DoxySeeAlso}{See also} \hyperlink{util_8h_a07984eadc1820caddf5fb09f8cc5f461}{OSCAP\_\-GENERIC\_\-GETTER\_\-CONV} \end{DoxySeeAlso} \hypertarget{util_8h_af0a2de3832f32a04e83b9fbfb5073541}{ \index{util.h@{util.h}!OSCAP\_\-GETTER@{OSCAP\_\-GETTER}} \index{OSCAP\_\-GETTER@{OSCAP\_\-GETTER}!util.h@{util.h}} \subsubsection[{OSCAP\_\-GETTER}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-GETTER(RTYPE, \/ SNAME, \/ MNAME)~OSCAP\_\-GENERIC\_\-GETTER(RTYPE,SNAME,MNAME,MNAME)}} \label{util_8h_af0a2de3832f32a04e83b9fbfb5073541} Generate a getter function. Member name and second part of the generated function's name must match. \begin{DoxyParams}{Parameters} \item[{\em RTYPE}]return type \item[{\em SNAME}]name of the structure of which we are getting a member \item[{\em MNAME}]member name affects how the resultant function will be called \item[{\em MEXP}]expression to get the member \end{DoxyParams} \begin{DoxySeeAlso}{See also} \hyperlink{util_8h_a6537fbd7378c67b0a5cd34fbbb46cf32}{OSCAP\_\-GENERIC\_\-GETTER} \end{DoxySeeAlso} \hypertarget{util_8h_a5b75e45a0f724a333b5da13bde0686ef}{ \index{util.h@{util.h}!OSCAP\_\-GETTER\_\-FORCE@{OSCAP\_\-GETTER\_\-FORCE}} \index{OSCAP\_\-GETTER\_\-FORCE@{OSCAP\_\-GETTER\_\-FORCE}!util.h@{util.h}} \subsubsection[{OSCAP\_\-GETTER\_\-FORCE}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-GETTER\_\-FORCE(RTYPE, \/ SNAME, \/ MNAME)~OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE(RTYPE,SNAME,MNAME,MNAME)}} \label{util_8h_a5b75e45a0f724a333b5da13bde0686ef} 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. \begin{DoxyParams}{Parameters} \item[{\em RTYPE}]return type \item[{\em SNAME}]name of the structure of which we are getting a member \item[{\em MNAME}]member name affects how the resultant function will be called \item[{\em MEXP}]expression to get the member \end{DoxyParams} \begin{DoxySeeAlso}{See also} \hyperlink{util_8h_a2b5200ab726de57e775442cd5e6ea1c5}{OSCAP\_\-GENERIC\_\-GETTER\_\-FORCE} \end{DoxySeeAlso} \hypertarget{util_8h_a830fc8c9d39d3004e3f28b69f7c43450}{ \index{util.h@{util.h}!OSCAP\_\-HGETTER@{OSCAP\_\-HGETTER}} \index{OSCAP\_\-HGETTER@{OSCAP\_\-HGETTER}!util.h@{util.h}} \subsubsection[{OSCAP\_\-HGETTER}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-HGETTER(RTYPE, \/ SNAME, \/ MNAME)~OSCAP\_\-HGETTER\_\-EXP(RTYPE,SNAME,MNAME,MNAME)}} \label{util_8h_a830fc8c9d39d3004e3f28b69f7c43450} Generete a geter function from a hash table. Signature of the generated function will be as follows (substitute uppercase strings with actual params): \begin{DoxyCode} RTYPE SNAME_MNAME(const struct SNAME* item, const char* key); \end{DoxyCode} \begin{DoxyParams}{Parameters} \item[{\em RTYPE}]type of the hash table item \item[{\em SNAME}]name of the structure \item[{\em MNAME}]structure member name \end{DoxyParams} \hypertarget{util_8h_a1c95b2ccc329b8e3a1c7abd2cd5fee59}{ \index{util.h@{util.h}!OSCAP\_\-HGETTER\_\-EXP@{OSCAP\_\-HGETTER\_\-EXP}} \index{OSCAP\_\-HGETTER\_\-EXP@{OSCAP\_\-HGETTER\_\-EXP}!util.h@{util.h}} \subsubsection[{OSCAP\_\-HGETTER\_\-EXP}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-HGETTER\_\-EXP(RTYPE, \/ SNAME, \/ MNAME, \/ MEXP)}} \label{util_8h_a1c95b2ccc329b8e3a1c7abd2cd5fee59} {\bfseries Value:} \begin{DoxyCode} RTYPE SNAME##_get_##MNAME(const struct SNAME* item, const char* key) \ { return oscap_htable_get(item->MEXP, key); } \end{DoxyCode} Generete a geter function from a hash table. Signature of the generated function will be as follows (substitute uppercase strings with actual params): \begin{DoxyCode} RTYPE SNAME_MNAME(const struct SNAME* item, const char* key); \end{DoxyCode} \begin{DoxyParams}{Parameters} \item[{\em RTYPE}]type of the hash table item \item[{\em SNAME}]name of the structure \item[{\em MNAME}]structure member name \item[{\em MEXP}]expression to get the member variable (i.e. the hash table) \end{DoxyParams} \hypertarget{util_8h_a8fe541399a78b234cbda8eb1532c12a1}{ \index{util.h@{util.h}!OSCAP\_\-HGETTER\_\-STRUCT@{OSCAP\_\-HGETTER\_\-STRUCT}} \index{OSCAP\_\-HGETTER\_\-STRUCT@{OSCAP\_\-HGETTER\_\-STRUCT}!util.h@{util.h}} \subsubsection[{OSCAP\_\-HGETTER\_\-STRUCT}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-HGETTER\_\-STRUCT(RTYPE, \/ SNAME, \/ MNAME)~OSCAP\_\-HGETTER\_\-EXP(struct RTYPE$\ast$,SNAME,MNAME,MNAME)}} \label{util_8h_a8fe541399a78b234cbda8eb1532c12a1} Generete a geter function from a hash table. Signature of the generated function will be as follows (substitute uppercase strings with actual params): \begin{DoxyCode} struct RTYPE* SNAME_MNAME(const struct SNAME* item, const char* key); \end{DoxyCode} \begin{DoxyParams}{Parameters} \item[{\em RTYPE}]type of the hash table item \item[{\em SNAME}]name of the structure \item[{\em MNAME}]structure member name \end{DoxyParams} \hypertarget{util_8h_a2634e36b767ff8f1a538e5067842dc6a}{ \index{util.h@{util.h}!OSCAP\_\-IGETTER@{OSCAP\_\-IGETTER}} \index{OSCAP\_\-IGETTER@{OSCAP\_\-IGETTER}!util.h@{util.h}} \subsubsection[{OSCAP\_\-IGETTER}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-IGETTER(ITYPE, \/ SNAME, \/ MNAME)~OSCAP\_\-IGETTER\_\-CONV(ITYPE,SNAME,MNAME,)}} \label{util_8h_a2634e36b767ff8f1a538e5067842dc6a} Generate an iterator getter function. Signature of the generated function will be as follows (substitute uppercase strings with actual params): \begin{DoxyCode} struct ITYPE_iterator* SNAME_MNAME(const struct SNAME*); \end{DoxyCode} \begin{DoxyParams}{Parameters} \item[{\em ITYPE}]iterator type (without the '\_\-iterator' suffix) \item[{\em SNAME}]name of type the structure containing the list \item[{\em MANME}]list itself \end{DoxyParams} \hypertarget{util_8h_aa9ea17012a7a5a4a4823e7ada948d930}{ \index{util.h@{util.h}!OSCAP\_\-IGETTER\_\-CONV@{OSCAP\_\-IGETTER\_\-CONV}} \index{OSCAP\_\-IGETTER\_\-CONV@{OSCAP\_\-IGETTER\_\-CONV}!util.h@{util.h}} \subsubsection[{OSCAP\_\-IGETTER\_\-CONV}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-IGETTER\_\-CONV(ITYPE, \/ SNAME, \/ MNAME, \/ CONV)}} \label{util_8h_aa9ea17012a7a5a4a4823e7ada948d930} {\bfseries Value:} \begin{DoxyCode} struct ITYPE##_iterator* SNAME##_get_##MNAME(const struct SNAME* item) \ { return oscap_iterator_new((CONV(item))->MNAME); } \end{DoxyCode} Generate an iterator getter function. Signature of the generated function will be as follows (substitute uppercase strings with actual params): \begin{DoxyCode} struct ITYPE_iterator* SNAME_MNAME(const struct SNAME*); \end{DoxyCode} \begin{DoxyParams}{Parameters} \item[{\em ITYPE}]iterator type (without the '\_\-iterator' suffix) \item[{\em SNAME}]name of type the structure containing the list \item[{\em MANME}]list itself \item[{\em CONV}]convert expression \end{DoxyParams} \hypertarget{util_8h_aa383eae0670f01c7b9d8f9780aedb9d1}{ \index{util.h@{util.h}!OSCAP\_\-IGETTER\_\-GEN@{OSCAP\_\-IGETTER\_\-GEN}} \index{OSCAP\_\-IGETTER\_\-GEN@{OSCAP\_\-IGETTER\_\-GEN}!util.h@{util.h}} \subsubsection[{OSCAP\_\-IGETTER\_\-GEN}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-IGETTER\_\-GEN(ITYPE, \/ SNAME, \/ MNAME)~OSCAP\_\-IGETTER(ITYPE,SNAME,MNAME) OSCAP\_\-ITERATOR\_\-GEN(ITYPE)}} \label{util_8h_aa383eae0670f01c7b9d8f9780aedb9d1} Generate an iterator and its getter. \begin{DoxySeeAlso}{See also} \hyperlink{util_8h_a2634e36b767ff8f1a538e5067842dc6a}{OSCAP\_\-IGETTER} OSCAP\_\-ITERATOR\_\-GEN \end{DoxySeeAlso} \hypertarget{util_8h_a58a4f69509578fe726d273e47feadee9}{ \index{util.h@{util.h}!OSCAP\_\-INSERTER@{OSCAP\_\-INSERTER}} \index{OSCAP\_\-INSERTER@{OSCAP\_\-INSERTER}!util.h@{util.h}} \subsubsection[{OSCAP\_\-INSERTER}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-INSERTER(SNAME, \/ FNAME, \/ MTYPE, \/ MNAME)}} \label{util_8h_a58a4f69509578fe726d273e47feadee9} {\bfseries Value:} \begin{DoxyCode} bool SNAME##_add_##FNAME(struct SNAME *obj, struct MTYPE *item) \ { oscap_list_add(obj->MNAME, item); return true; } \end{DoxyCode} Generate function to insert an item into a list. Signature of the generated function will be as follows (substitute uppercase strings with actual params): \begin{DoxyCode} bool SNAME_add_FNAME(struct SNAME *obj, struct MTYPE *item); \end{DoxyCode} \begin{DoxyParams}{Parameters} \item[{\em SNAME}]structure typename (w/o the struct keyword) \item[{\em FNAME}]how should function name part after the \_\-add\_\- look like \item[{\em MTYPE}]list member type \item[{\em MNAME}]name of the list within the structure \end{DoxyParams} \hypertarget{util_8h_a452283d465fda2043dd6f80ba43a35b3}{ \index{util.h@{util.h}!OSCAP\_\-SETTER\_\-GENERIC@{OSCAP\_\-SETTER\_\-GENERIC}} \index{OSCAP\_\-SETTER\_\-GENERIC@{OSCAP\_\-SETTER\_\-GENERIC}!util.h@{util.h}} \subsubsection[{OSCAP\_\-SETTER\_\-GENERIC}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-SETTER\_\-GENERIC(SNAME, \/ MTYPE, \/ MNAME, \/ DELETER, \/ ASSIGNER)}} \label{util_8h_a452283d465fda2043dd6f80ba43a35b3} {\bfseries Value:} \begin{DoxyCode} OSCAP_SETTER_HEADER(SNAME, MTYPE, MNAME) \ { DELETER(obj->MNAME); obj->MNAME = ASSIGNER(item); return true; } \end{DoxyCode} Generete a setter function without a check. \begin{DoxySeeAlso}{See also} \hyperlink{util_8h_a98964606cf2ab84d093c1e4dae18f101}{OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK} \end{DoxySeeAlso} \hypertarget{util_8h_a98964606cf2ab84d093c1e4dae18f101}{ \index{util.h@{util.h}!OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK@{OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK}} \index{OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK@{OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK}!util.h@{util.h}} \subsubsection[{OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK(SNAME, \/ MTYPE, \/ MNAME, \/ CHECK, \/ DELETER, \/ ASSIGNER)}} \label{util_8h_a98964606cf2ab84d093c1e4dae18f101} {\bfseries Value:} \begin{DoxyCode} OSCAP_SETTER_HEADER(SNAME, MTYPE, MNAME) \ { if (!(CHECK)) return false; DELETER(obj->MNAME); obj->MNAME = ASSIGNER( item); return true; } \end{DoxyCode} Generete a setter function with a check. Signature of the generated function will be as follows (substitute uppercase strings with actual params): \begin{DoxyCode} bool SNAME_get_MNAME(struct SNAME *obj, MTYPE *item); \end{DoxyCode} \begin{DoxyParams}{Parameters} \item[{\em SNAME}]Name of the structure. \item[{\em MTYPE}]Type of the member item to set. \item[{\em MNAME}]Name of the member item to set. \item[{\em CHECK}]Code to check validity of the assignment (you can use obj and item variables here). \item[{\em DELETER}]Function used to delete the old value (or empty string). \item[{\em ASSIGNER}]Function used to assign value to the item. \end{DoxyParams} \hypertarget{util_8h_a94ff3491fb52ba23c0c66e1ca8afe115}{ \index{util.h@{util.h}!OSCAP\_\-SETTER\_\-GENERIC\_\-NODELETE@{OSCAP\_\-SETTER\_\-GENERIC\_\-NODELETE}} \index{OSCAP\_\-SETTER\_\-GENERIC\_\-NODELETE@{OSCAP\_\-SETTER\_\-GENERIC\_\-NODELETE}!util.h@{util.h}} \subsubsection[{OSCAP\_\-SETTER\_\-GENERIC\_\-NODELETE}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-SETTER\_\-GENERIC\_\-NODELETE(SNAME, \/ MTYPE, \/ MNAME, \/ ASSIGNER)}} \label{util_8h_a94ff3491fb52ba23c0c66e1ca8afe115} {\bfseries Value:} \begin{DoxyCode} OSCAP_SETTER_HEADER(SNAME, MTYPE, MNAME) \ { obj->MNAME = ASSIGNER(item); return true; } \end{DoxyCode} Generete a setter function without a check that does not delete the previous value. \begin{DoxySeeAlso}{See also} \hyperlink{util_8h_a98964606cf2ab84d093c1e4dae18f101}{OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK} \end{DoxySeeAlso} \hypertarget{util_8h_a596f918f3ca6cbc014ec148262ba2d5c}{ \index{util.h@{util.h}!OSCAP\_\-SETTER\_\-SIMPLE@{OSCAP\_\-SETTER\_\-SIMPLE}} \index{OSCAP\_\-SETTER\_\-SIMPLE@{OSCAP\_\-SETTER\_\-SIMPLE}!util.h@{util.h}} \subsubsection[{OSCAP\_\-SETTER\_\-SIMPLE}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-SETTER\_\-SIMPLE(SNAME, \/ MTYPE, \/ MNAME)~OSCAP\_\-SETTER\_\-GENERIC\_\-NODELETE(SNAME, MTYPE, MNAME, )}} \label{util_8h_a596f918f3ca6cbc014ec148262ba2d5c} Generete a setter function using a simple assignment. \begin{DoxySeeAlso}{See also} \hyperlink{util_8h_a98964606cf2ab84d093c1e4dae18f101}{OSCAP\_\-SETTER\_\-GENERIC\_\-CHECK} \end{DoxySeeAlso} \hypertarget{util_8h_a5f7f57c665211b0589af75b5e558ccf1}{ \index{util.h@{util.h}!OSCAP\_\-SETTER\_\-STRING@{OSCAP\_\-SETTER\_\-STRING}} \index{OSCAP\_\-SETTER\_\-STRING@{OSCAP\_\-SETTER\_\-STRING}!util.h@{util.h}} \subsubsection[{OSCAP\_\-SETTER\_\-STRING}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-SETTER\_\-STRING(SNAME, \/ MNAME)~OSCAP\_\-SETTER\_\-GENERIC(SNAME, const char $\ast$, MNAME, free, oscap\_\-strdup)}} \label{util_8h_a5f7f57c665211b0589af75b5e558ccf1} Assign a string value to a structure member. \begin{DoxyParams}{Parameters} \item[{\em SNAME}]Structure name \item[{\em MNAME}]Name of structure member containing the string to be set. \end{DoxyParams} \subsection{Function Documentation} \hypertarget{util_8h_a6b16df3c5b6a73bb8e7ca890a5bcbbbf}{ \index{util.h@{util.h}!oscap\_\-strdup@{oscap\_\-strdup}} \index{oscap\_\-strdup@{oscap\_\-strdup}!util.h@{util.h}} \subsubsection[{oscap\_\-strdup}]{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ oscap\_\-strdup (const char $\ast$ {\em str})}} \label{util_8h_a6b16df3c5b6a73bb8e7ca890a5bcbbbf} Use strdup on string, if string is NULL, return NULL. \begin{DoxyParams}{Parameters} \item[{\em str}]String we want to duplicate \end{DoxyParams} \hypertarget{util_8h_aa7e2b327cb6228bbe863ce31048a8808}{ \index{util.h@{util.h}!oscap\_\-strsep@{oscap\_\-strsep}} \index{oscap\_\-strsep@{oscap\_\-strsep}!util.h@{util.h}} \subsubsection[{oscap\_\-strsep}]{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ oscap\_\-strsep (char $\ast$$\ast$ {\em str}, \/ const char $\ast$ {\em delim})}} \label{util_8h_aa7e2b327cb6228bbe863ce31048a8808} Use strsep on string We can't use strsep from string.h because of compatibility issues. \begin{DoxyParams}{Parameters} \item[{\em str}]String we want to split \item[{\em delim}]Delimiter of string parts \end{DoxyParams}