<!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/project/openscap/openscap-0.7.4/src/OVAL/probes/SEAP/generic/spb.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.7.4 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Open SCAP Library</div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">/home/pvrabec/project/openscap/openscap-0.7.4/src/OVAL/probes/SEAP/generic/spb.h</div> </div> </div> <div class="contents"> <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"> * "Daniel Kopecek" <dkopecek@redhat.com></span> <a name="l00021"></a>00021 <span class="comment"> */</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#pragma once</span> <a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#ifndef SPB_H</span> <a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#define SPB_H</span> <a name="l00026"></a>00026 <span class="preprocessor"></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <stddef.h></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <inttypes.h></span> <a name="l00029"></a>00029 <span class="preprocessor">#include <common/util.h></span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="preprocessor">#define __XC(a, b) OSCAP_CONCAT(a, b)</span> <a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#define _sym(n) __XC(__XC(_sym, __LINE__), n)</span> <a name="l00033"></a>00033 <span class="preprocessor"></span> <a name="l00034"></a>00034 <span class="keyword">typedef</span> uint32_t spb_flags_t; <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="preprocessor">#define SPB_FLAG_FREE 0x00000001</span> <a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#define SPB_FLAG_JOIN 0x00000002</span> <a name="l00038"></a>00038 <span class="preprocessor"></span><span class="preprocessor">#define SPB_FLAG_FILE 0x00000004</span> <a name="l00039"></a>00039 <span class="preprocessor"></span> <a name="l00040"></a>00040 <span class="keyword">typedef</span> uint64_t spb_size_t; <a name="l00041"></a>00041 <span class="preprocessor">#define SPB_SZ_FMT "%"PRIo64</span> <a name="l00042"></a>00042 <span class="preprocessor"></span> <a name="l00043"></a><a class="code" href="structspb__item__t.html">00043</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00044"></a>00044 <span class="keywordtype">void</span> *base; <span class="comment">/* buffer base address */</span> <a name="l00045"></a>00045 spb_size_t gend; <span class="comment">/* sparse buffer index of the last byte of this buffer */</span> <a name="l00046"></a>00046 } <a class="code" href="structspb__item__t.html">spb_item_t</a>; <a name="l00047"></a>00047 <a name="l00048"></a><a class="code" href="structspb__t.html">00048</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00049"></a>00049 <a class="code" href="structspb__item__t.html">spb_item_t</a> *buffer; <span class="comment">/* array of buffers representing the sparse buffer */</span> <a name="l00050"></a>00050 uint32_t btotal; <span class="comment">/* number of buffer */</span> <a name="l00051"></a>00051 uint32_t balloc; <span class="comment">/* number of allocated slots */</span> <a name="l00052"></a>00052 uint32_t bflags; <span class="comment">/* flags - not used at the moment */</span> <a name="l00053"></a>00053 } <a class="code" href="structspb__t.html">spb_t</a>; <a name="l00054"></a>00054 <a name="l00055"></a>00055 <span class="preprocessor">#define SPB_DEFAULT_BALLOC 32 </span><span class="comment">/* default number of pre-allocated slots */</span> <a name="l00056"></a>00056 <span class="preprocessor">#define SPB_BALLOC_HIGHTRESH 512 </span><span class="comment">/* the number of new slots is doubled until this limit is reached */</span> <a name="l00057"></a>00057 <span class="preprocessor">#define SPB_BALLOC_ADD 32 </span><span class="comment">/* number of slot to add when we reached the high threshold */</span> <a name="l00058"></a>00058 <a name="l00067"></a>00067 <a class="code" href="structspb__t.html">spb_t</a> *spb_new (<span class="keywordtype">void</span> *buffer, <span class="keywordtype">size_t</span> buflen, uint32_t balloc); <a name="l00068"></a>00068 <a name="l00069"></a>00069 <span class="keywordtype">void</span> spb_free (<a class="code" href="structspb__t.html">spb_t</a> *spb, spb_flags_t flags); <a name="l00070"></a>00070 <a name="l00077"></a>00077 uint32_t spb_bindex (<a class="code" href="structspb__t.html">spb_t</a> *spb, spb_size_t index); <a name="l00078"></a>00078 <a name="l00083"></a>00083 spb_size_t spb_size (<a class="code" href="structspb__t.html">spb_t</a> *spb); <a name="l00084"></a>00084 <a name="l00093"></a>00093 <span class="preprocessor">#define spb_iterate_oct(spb, start, end, name) </span><span class="comment">/* TODO */</span> while(0) <a name="l00094"></a>00094 <a name="l00095"></a>00095 <span class="preprocessor">#define spb_iterate(spb, start, name, icode) \</span> <a name="l00096"></a>00096 <span class="preprocessor"> do { \</span> <a name="l00097"></a>00097 <span class="preprocessor"> spb_size_t _sym(istart) = (start); \</span> <a name="l00098"></a>00098 <span class="preprocessor"> spb_t *_sym(ispb) = (spb); \</span> <a name="l00099"></a>00099 <span class="preprocessor"> uint32_t _sym(idx) = spb_bindex(_sym(ispb), _sym(istart)); \</span> <a name="l00100"></a>00100 <span class="preprocessor"> size_t _sym(l_off) = (size_t)(_sym(idx) > 0 ? start - _sym(ispb)->buffer[_sym(idx) - 1].gend - 1 : start); \</span> <a name="l00101"></a>00101 <span class="preprocessor"> \</span> <a name="l00102"></a>00102 <span class="preprocessor"> for (; _sym(idx) < _sym(ispb)->btotal; ++_sym(idx)) { \</span> <a name="l00103"></a>00103 <span class="preprocessor"> register size_t _sym(l); \</span> <a name="l00104"></a>00104 <span class="preprocessor"> register uint8_t *_sym(b); \</span> <a name="l00105"></a>00105 <span class="preprocessor"> \</span> <a name="l00106"></a>00106 <span class="preprocessor"> _sym(l) = (size_t)(_sym(idx) > 0 ? \</span> <a name="l00107"></a>00107 <span class="preprocessor"> _sym(ispb)->buffer[_sym(idx)].gend - _sym(ispb)->buffer[_sym(idx) - 1].gend : \</span> <a name="l00108"></a>00108 <span class="preprocessor"> _sym(ispb)->buffer[_sym(idx)].gend + 1) - _sym(l_off); \</span> <a name="l00109"></a>00109 <span class="preprocessor"> _sym(b) = ((uint8_t *)(_sym(ispb)->buffer[_sym(idx)].base)) + _sym(l_off); \</span> <a name="l00110"></a>00110 <span class="preprocessor"> \</span> <a name="l00111"></a>00111 <span class="preprocessor"> for (; _sym(l) > 0; --_sym(l), ++_sym(b)) { \</span> <a name="l00112"></a>00112 <span class="preprocessor"> (name) = *_sym(b); \</span> <a name="l00113"></a>00113 <span class="preprocessor"> icode; \</span> <a name="l00114"></a>00114 <span class="preprocessor"> } \</span> <a name="l00115"></a>00115 <span class="preprocessor"> \</span> <a name="l00116"></a>00116 <span class="preprocessor"> if (_sym(l) > 0) \</span> <a name="l00117"></a>00117 <span class="preprocessor"> break; \</span> <a name="l00118"></a>00118 <span class="preprocessor"> \</span> <a name="l00119"></a>00119 <span class="preprocessor"> _sym(l_off) = 0; \</span> <a name="l00120"></a>00120 <span class="preprocessor"> } \</span> <a name="l00121"></a>00121 <span class="preprocessor"> } while (0)</span> <a name="l00122"></a>00122 <span class="preprocessor"></span> <a name="l00129"></a>00129 <span class="keywordtype">int</span> spb_add (<a class="code" href="structspb__t.html">spb_t</a> *spb, <span class="keywordtype">void</span> *buffer, <span class="keywordtype">size_t</span> buflen); <a name="l00130"></a>00130 <a name="l00138"></a>00138 <span class="keywordtype">int</span> spb_pick (<a class="code" href="structspb__t.html">spb_t</a> *spb, spb_size_t start, spb_size_t size, <span class="keywordtype">void</span> *dst); <a name="l00139"></a>00139 <a name="l00150"></a>00150 <span class="keywordtype">int</span> spb_pick_raw (<a class="code" href="structspb__t.html">spb_t</a> *spb, uint32_t bindex, spb_size_t start, spb_size_t size, <span class="keywordtype">void</span> *dst); <a name="l00151"></a>00151 <a name="l00164"></a>00164 <span class="keywordtype">int</span> spb_pick_cb (<a class="code" href="structspb__t.html">spb_t</a> *spb, spb_size_t start, spb_size_t size, <span class="keywordtype">void</span> *cb (<span class="keywordtype">void</span> *, <span class="keywordtype">void</span> *, <span class="keywordtype">size_t</span>), <span class="keywordtype">void</span> *cbarg); <a name="l00165"></a>00165 <a name="l00166"></a>00166 spb_size_t spb_drop_head (<a class="code" href="structspb__t.html">spb_t</a> *spb, spb_size_t size, spb_flags_t flags); <a name="l00167"></a>00167 <a name="l00168"></a>00168 uint8_t spb_octet (<a class="code" href="structspb__t.html">spb_t</a> *spb, spb_size_t idx); <a name="l00169"></a>00169 <span class="keyword">const</span> uint8_t *spb_direct (<a class="code" href="structspb__t.html">spb_t</a> *spb, spb_size_t start, spb_size_t size); <a name="l00170"></a>00170 <a name="l00171"></a>00171 <span class="preprocessor">#endif </span><span class="comment">/* SPB_H */</span> </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Mon Jul 25 2011 for Open SCAP Library by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>