Sophie

Sophie

distrib > Mandriva > current > x86_64 > by-pkgid > 3736f276bb1ccfbcee6cb2d27b25d981 > files > 562

openscap-devel-0.5.7-1mdv2010.1.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Open SCAP Library: /home/pvrabec/openscap/openscap-0.5.7/src/common/util.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<h1>/home/pvrabec/openscap/openscap-0.5.7/src/common/util.h</h1><a href="util_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright 2009 Red Hat Inc., Durham, North Carolina.</span>
<a name="l00003"></a>00003 <span class="comment"> * All Rights Reserved.</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
<a name="l00006"></a>00006 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
<a name="l00007"></a>00007 <span class="comment"> * License as published by the Free Software Foundation; either</span>
<a name="l00008"></a>00008 <span class="comment"> * version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00013"></a>00013 <span class="comment"> * Lesser General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment"> *</span>
<a name="l00015"></a>00015 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
<a name="l00016"></a>00016 <span class="comment"> * License along with this library; if not, write to the Free Software</span>
<a name="l00017"></a>00017 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * Authors:</span>
<a name="l00020"></a>00020 <span class="comment"> *      Lukas Kuklinek &lt;lkuklinek@redhat.com&gt;</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022 
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef OSCAP_UTIL_H_</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_UTIL_H_</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;stdbool.h&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &quot;<a class="code" href="oscap_8h.html" title="General OpenScap functions and types.">public/oscap.h</a>&quot;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="alloc_8h.html" title="OpenScap allocation helpers.">public/alloc.h</a>&quot;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="preprocessor">#define __attribute__nonnull__(x) assert((x) != NULL)</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>
<a name="l00038"></a>00038 <span class="keyword">struct </span><a class="code" href="structoscap__import__source.html">oscap_import_source</a>;
<a name="l00039"></a>00039 <span class="keyword">struct </span><a class="code" href="structoscap__export__target.html">oscap_export_target</a>;
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="comment">/*</span>
<a name="l00042"></a>00042 <span class="comment"> * Start a list of declarations that should not be available from outside the</span>
<a name="l00043"></a>00043 <span class="comment"> * library.  Must be matched with OSCAP_HIDDEN_END.</span>
<a name="l00044"></a>00044 <span class="comment"> */</span>
<a name="l00045"></a>00045 <span class="preprocessor">#define OSCAP_HIDDEN_START _Pragma(&quot;GCC visibility push(hidden)&quot;)</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>
<a name="l00047"></a>00047 <span class="comment">/*</span>
<a name="l00048"></a>00048 <span class="comment"> * Start a list of declarations that should not be available from outside the</span>
<a name="l00049"></a>00049 <span class="comment"> * library started by OSCAP_HIDDEN_END.</span>
<a name="l00050"></a>00050 <span class="comment"> */</span>
<a name="l00051"></a>00051 <span class="preprocessor">#define OSCAP_HIDDEN_END _Pragma(&quot;GCC visibility pop&quot;)</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span>
<a name="l00056"></a><a class="code" href="util_8h.html#ad2a4648e28ae682b86489ac8be3a22fc">00056</a> <span class="keyword">typedef</span> void (*<a class="code" href="util_8h.html#ad2a4648e28ae682b86489ac8be3a22fc" title="Function pointer to an object destructor.">oscap_destruct_func</a>) (<span class="keywordtype">void</span> *);
<a name="l00057"></a>00057 
<a name="l00061"></a><a class="code" href="util_8h.html#ac32fc75588117050825915e52af52992">00061</a> <span class="keyword">typedef</span> void (*<a class="code" href="util_8h.html#ac32fc75588117050825915e52af52992" title="Function pointer to an object consumer.">oscap_consumer_func</a>) (<span class="keywordtype">void</span> *, <span class="keywordtype">void</span> *);
<a name="l00062"></a>00062 
<a name="l00073"></a><a class="code" href="util_8h.html#a07984eadc1820caddf5fb09f8cc5f461">00073</a> <span class="preprocessor">#define OSCAP_GENERIC_GETTER_CONV(RTYPE,CONV,SNAME,MNAME,MEXP) \</span>
<a name="l00074"></a>00074 <span class="preprocessor">        RTYPE SNAME##_get_##MNAME(const struct SNAME* item) { return (CONV(item-&gt;MEXP)); }</span>
<a name="l00075"></a>00075 <span class="preprocessor"></span>
<a name="l00084"></a><a class="code" href="util_8h.html#a6537fbd7378c67b0a5cd34fbbb46cf32">00084</a> <span class="preprocessor">#define OSCAP_GENERIC_GETTER(RTYPE,SNAME,MNAME,MEXP) \</span>
<a name="l00085"></a>00085 <span class="preprocessor">        OSCAP_GENERIC_GETTER_CONV(RTYPE,,SNAME,MNAME,MEXP)</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span>
<a name="l00095"></a><a class="code" href="util_8h.html#a2b5200ab726de57e775442cd5e6ea1c5">00095</a> <span class="preprocessor">#define OSCAP_GENERIC_GETTER_FORCE(RTYPE,SNAME,MNAME,MEXP) \</span>
<a name="l00096"></a>00096 <span class="preprocessor">        OSCAP_GENERIC_GETTER_CONV(RTYPE,(RTYPE),SNAME,MNAME,MEXP)</span>
<a name="l00097"></a>00097 <span class="preprocessor"></span>
<a name="l00107"></a><a class="code" href="util_8h.html#a5b75e45a0f724a333b5da13bde0686ef">00107</a> <span class="preprocessor">#define OSCAP_GETTER_FORCE(RTYPE,SNAME,MNAME) \</span>
<a name="l00108"></a>00108 <span class="preprocessor">        OSCAP_GENERIC_GETTER_FORCE(RTYPE,SNAME,MNAME,MNAME)</span>
<a name="l00109"></a>00109 <span class="preprocessor"></span>
<a name="l00119"></a><a class="code" href="util_8h.html#af0a2de3832f32a04e83b9fbfb5073541">00119</a> <span class="preprocessor">#define OSCAP_GETTER(RTYPE,SNAME,MNAME) \</span>
<a name="l00120"></a>00120 <span class="preprocessor">        OSCAP_GENERIC_GETTER(RTYPE,SNAME,MNAME,MNAME)</span>
<a name="l00121"></a>00121 <span class="preprocessor"></span>
<a name="l00122"></a>00122 <span class="preprocessor">#define ITERATOR_CAST(x) ((struct oscap_iterator*)(x))</span>
<a name="l00123"></a>00123 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_ITERATOR(n) struct n##_iterator*</span>
<a name="l00124"></a>00124 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_ITERATOR_FWD(n) struct n##_iterator;</span>
<a name="l00125"></a>00125 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_ITERATOR_HAS_MORE(n) bool n##_iterator_has_more(OSCAP_ITERATOR(n) it) { return oscap_iterator_has_more(ITERATOR_CAST(it)); }</span>
<a name="l00126"></a>00126 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_ITERATOR_NEXT(t,n) t n##_iterator_next(OSCAP_ITERATOR(n) it) { return oscap_iterator_next(ITERATOR_CAST(it)); }</span>
<a name="l00127"></a>00127 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_ITERATOR_FREE(n) void n##_iterator_free(OSCAP_ITERATOR(n) it) { oscap_iterator_free(ITERATOR_CAST(it)); }</span>
<a name="l00128"></a>00128 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_ITERATOR_DETACH(t,n) t n##_iterator_detach(OSCAP_ITERATOR(n) it) { return oscap_iterator_detach(ITERATOR_CAST(it)); }</span>
<a name="l00129"></a>00129 <span class="preprocessor"></span><span class="preprocessor">#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)</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_ITERATOR_GEN(n) OSCAP_ITERATOR_GEN_T(struct n*,n)</span>
<a name="l00131"></a>00131 <span class="preprocessor"></span>
<a name="l00132"></a>00132 <span class="preprocessor">#define OSCAP_ITERATOR_REMOVE_T(t,n,destructor) \</span>
<a name="l00133"></a>00133 <span class="preprocessor">                void n##_iterator_remove(OSCAP_ITERATOR(n) it) { destructor(oscap_iterator_detach(ITERATOR_CAST(it))); }</span>
<a name="l00134"></a>00134 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_ITERATOR_REMOVE(n,destructor) OSCAP_ITERATOR_REMOVE_T(struct n*,n,destructor)</span>
<a name="l00135"></a>00135 <span class="preprocessor"></span><span class="preprocessor">#define OSCAP_ITERATOR_REMOVE_F(n) OSCAP_ITERATOR_REMOVE(n, n##_free)</span>
<a name="l00136"></a>00136 <span class="preprocessor"></span>
<a name="l00137"></a>00137 
<a name="l00147"></a><a class="code" href="util_8h.html#aa9ea17012a7a5a4a4823e7ada948d930">00147</a> <span class="preprocessor">#define OSCAP_IGETTER_CONV(ITYPE,SNAME,MNAME,CONV) \</span>
<a name="l00148"></a>00148 <span class="preprocessor">        struct ITYPE##_iterator* SNAME##_get_##MNAME(const struct SNAME* item) \</span>
<a name="l00149"></a>00149 <span class="preprocessor">        { return oscap_iterator_new((CONV(item))-&gt;MNAME); }</span>
<a name="l00150"></a>00150 <span class="preprocessor"></span>
<a name="l00159"></a><a class="code" href="util_8h.html#a2634e36b767ff8f1a538e5067842dc6a">00159</a> <span class="preprocessor">#define OSCAP_IGETTER(ITYPE,SNAME,MNAME) OSCAP_IGETTER_CONV(ITYPE,SNAME,MNAME,)</span>
<a name="l00160"></a>00160 <span class="preprocessor"></span>
<a name="l00166"></a><a class="code" href="util_8h.html#aa383eae0670f01c7b9d8f9780aedb9d1">00166</a> <span class="preprocessor">#define OSCAP_IGETTER_GEN(ITYPE,SNAME,MNAME) OSCAP_IGETTER(ITYPE,SNAME,MNAME) OSCAP_ITERATOR_GEN(ITYPE)</span>
<a name="l00167"></a>00167 <span class="preprocessor"></span>
<a name="l00177"></a><a class="code" href="util_8h.html#a1c95b2ccc329b8e3a1c7abd2cd5fee59">00177</a> <span class="preprocessor">#define OSCAP_HGETTER_EXP(RTYPE,SNAME,MNAME,MEXP) \</span>
<a name="l00178"></a>00178 <span class="preprocessor">        RTYPE SNAME##_get_##MNAME(const struct SNAME* item, const char* key) \</span>
<a name="l00179"></a>00179 <span class="preprocessor">        { return oscap_htable_get(item-&gt;MEXP, key); }</span>
<a name="l00180"></a>00180 <span class="preprocessor"></span>
<a name="l00189"></a><a class="code" href="util_8h.html#a830fc8c9d39d3004e3f28b69f7c43450">00189</a> <span class="preprocessor">#define OSCAP_HGETTER(RTYPE,SNAME,MNAME) OSCAP_HGETTER_EXP(RTYPE,SNAME,MNAME,MNAME)</span>
<a name="l00190"></a>00190 <span class="preprocessor"></span>
<a name="l00199"></a><a class="code" href="util_8h.html#a8fe541399a78b234cbda8eb1532c12a1">00199</a> <span class="preprocessor">#define OSCAP_HGETTER_STRUCT(RTYPE,SNAME,MNAME) OSCAP_HGETTER_EXP(struct RTYPE*,SNAME,MNAME,MNAME)</span>
<a name="l00200"></a>00200 <span class="preprocessor"></span>
<a name="l00201"></a>00201 <span class="preprocessor">#define OSCAP_SETTER_HEADER(SNAME, MTYPE, MNAME) bool SNAME##_set_##MNAME(struct SNAME *obj, MTYPE item)</span>
<a name="l00202"></a>00202 <span class="preprocessor"></span>
<a name="l00214"></a><a class="code" href="util_8h.html#a98964606cf2ab84d093c1e4dae18f101">00214</a> <span class="preprocessor">#define OSCAP_SETTER_GENERIC_CHECK(SNAME, MTYPE, MNAME, CHECK, DELETER, ASSIGNER) \</span>
<a name="l00215"></a>00215 <span class="preprocessor">        OSCAP_SETTER_HEADER(SNAME, MTYPE, MNAME) \</span>
<a name="l00216"></a>00216 <span class="preprocessor">        { if (!(CHECK)) return false; DELETER(obj-&gt;MNAME); obj-&gt;MNAME = ASSIGNER(item); return true; }</span>
<a name="l00217"></a>00217 <span class="preprocessor"></span>
<a name="l00222"></a><a class="code" href="util_8h.html#a452283d465fda2043dd6f80ba43a35b3">00222</a> <span class="preprocessor">#define OSCAP_SETTER_GENERIC(SNAME, MTYPE, MNAME, DELETER, ASSIGNER) \</span>
<a name="l00223"></a>00223 <span class="preprocessor">        OSCAP_SETTER_HEADER(SNAME, MTYPE, MNAME) \</span>
<a name="l00224"></a>00224 <span class="preprocessor">        { DELETER(obj-&gt;MNAME); obj-&gt;MNAME = ASSIGNER(item); return true; }</span>
<a name="l00225"></a>00225 <span class="preprocessor"></span>
<a name="l00230"></a><a class="code" href="util_8h.html#a94ff3491fb52ba23c0c66e1ca8afe115">00230</a> <span class="preprocessor">#define OSCAP_SETTER_GENERIC_NODELETE(SNAME, MTYPE, MNAME, ASSIGNER) \</span>
<a name="l00231"></a>00231 <span class="preprocessor">        OSCAP_SETTER_HEADER(SNAME, MTYPE, MNAME) \</span>
<a name="l00232"></a>00232 <span class="preprocessor">        { obj-&gt;MNAME = ASSIGNER(item); return true; }</span>
<a name="l00233"></a>00233 <span class="preprocessor"></span>
<a name="l00238"></a><a class="code" href="util_8h.html#a596f918f3ca6cbc014ec148262ba2d5c">00238</a> <span class="preprocessor">#define OSCAP_SETTER_SIMPLE(SNAME, MTYPE, MNAME) \</span>
<a name="l00239"></a>00239 <span class="preprocessor">        OSCAP_SETTER_GENERIC_NODELETE(SNAME, MTYPE, MNAME, )</span>
<a name="l00240"></a>00240 <span class="preprocessor"></span>
<a name="l00246"></a><a class="code" href="util_8h.html#a5f7f57c665211b0589af75b5e558ccf1">00246</a> <span class="preprocessor">#define OSCAP_SETTER_STRING(SNAME, MNAME) \</span>
<a name="l00247"></a>00247 <span class="preprocessor">        OSCAP_SETTER_GENERIC(SNAME, const char *, MNAME, free, oscap_strdup)</span>
<a name="l00248"></a>00248 <span class="preprocessor"></span>
<a name="l00252"></a><a class="code" href="util_8h.html#ade0c5f5243684c8b21023c02b2e7073f">00252</a> <span class="preprocessor">#define OSCAP_ACCESSOR_STRING(SNAME, MNAME) \</span>
<a name="l00253"></a>00253 <span class="preprocessor">        OSCAP_SETTER_STRING(SNAME, MNAME) OSCAP_GETTER(const char*, SNAME, MNAME)</span>
<a name="l00254"></a>00254 <span class="preprocessor"></span>
<a name="l00258"></a><a class="code" href="util_8h.html#a3b0299d8e4ca40797a73fd82c502e8a9">00258</a> <span class="preprocessor">#define OSCAP_ACCESSOR_SIMPLE(MTYPE, SNAME, MNAME) \</span>
<a name="l00259"></a>00259 <span class="preprocessor">        OSCAP_SETTER_SIMPLE(SNAME, MTYPE, MNAME) OSCAP_GETTER(MTYPE, SNAME, MNAME)</span>
<a name="l00260"></a>00260 <span class="preprocessor"></span>
<a name="l00270"></a><a class="code" href="util_8h.html#a58a4f69509578fe726d273e47feadee9">00270</a> <span class="preprocessor">#define OSCAP_INSERTER(SNAME, FNAME, MTYPE, MNAME) \</span>
<a name="l00271"></a>00271 <span class="preprocessor">        bool SNAME##_add_##FNAME(struct SNAME *obj, struct MTYPE *item) \</span>
<a name="l00272"></a>00272 <span class="preprocessor">        { oscap_list_add(obj-&gt;MNAME, item); return true; }</span>
<a name="l00273"></a>00273 <span class="preprocessor"></span>
<a name="l00274"></a>00274 <span class="comment">/* Generate iterator getter and list inserter */</span>
<a name="l00275"></a>00275 <span class="preprocessor">#define OSCAP_IGETINS(ITYPE, SNAME, MNAME, FNAME) \</span>
<a name="l00276"></a>00276 <span class="preprocessor">        OSCAP_IGETTER(ITYPE, SNAME, MNAME) OSCAP_INSERTER(SNAME, FNAME, ITYPE, MNAME)</span>
<a name="l00277"></a>00277 <span class="preprocessor"></span><span class="comment">/* Generate iterator getter, list inserter, and iterator manipulation functions. */</span>
<a name="l00278"></a>00278 <span class="preprocessor">#define OSCAP_IGETINS_GEN(ITYPE, SNAME, MNAME, FNAME) \</span>
<a name="l00279"></a>00279 <span class="preprocessor">        OSCAP_IGETTER_GEN(ITYPE, SNAME, MNAME) OSCAP_INSERTER(SNAME, FNAME, ITYPE, MNAME)</span>
<a name="l00280"></a>00280 <span class="preprocessor"></span>
<a name="l00288"></a><a class="code" href="structoscap__string__map.html">00288</a> <span class="keyword">struct </span><a class="code" href="structoscap__string__map.html" title="Define mapping between symbolic constant and its string representation.">oscap_string_map</a> {
<a name="l00289"></a>00289         <span class="keywordtype">int</span> value;              <span class="comment">/* integer/enum value */</span>
<a name="l00290"></a>00290         <span class="keyword">const</span> <span class="keywordtype">char</span> *string;     <span class="comment">/* string representation of the value */</span>
<a name="l00291"></a>00291 };
<a name="l00292"></a>00292 
<a name="l00299"></a>00299 <span class="keywordtype">int</span> <a class="code" href="structoscap__string__map.html#a6bda0f46c76ca15d381bbc08d932dfaa" title="Convert a string to an enumeration constant.">oscap_string_to_enum</a>(<span class="keyword">const</span> <span class="keyword">struct</span> <a class="code" href="structoscap__string__map.html" title="Define mapping between symbolic constant and its string representation.">oscap_string_map</a> *map, <span class="keyword">const</span> <span class="keywordtype">char</span> *str);
<a name="l00300"></a>00300 
<a name="l00307"></a>00307 <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="structoscap__string__map.html#aa1d9de0387526ec8dbb26b494ef1703d" title="Convert an enumeration constant to its corresponding string representation.">oscap_enum_to_string</a>(<span class="keyword">const</span> <span class="keyword">struct</span> <a class="code" href="structoscap__string__map.html" title="Define mapping between symbolic constant and its string representation.">oscap_string_map</a> *map, <span class="keywordtype">int</span> val);
<a name="l00308"></a>00308 
<a name="l00313"></a>00313 <span class="keywordtype">char</span> *oscap_strdup(<span class="keyword">const</span> <span class="keywordtype">char</span> *str);
<a name="l00314"></a>00314 
<a name="l00321"></a>00321 <span class="keywordtype">char</span> *oscap_strsep(<span class="keywordtype">char</span> **str, <span class="keyword">const</span> <span class="keywordtype">char</span> *delim);
<a name="l00322"></a>00322 
<a name="l00323"></a>00323 <span class="preprocessor">#endif                          </span><span class="comment">/* OSCAP_UTIL_H_ */</span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 26 Feb 2010 for Open SCAP Library by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>