<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>rpm: tools/dumpdb.c Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.4.7 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</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 id="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul></div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul></div> <h1>tools/dumpdb.c</h1><a href="dumpdb_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include "<a class="code" href="system_8h.html">system.h</a>"</span> <a name="l00002"></a><a class="code" href="dumpdb_8c.html#e44e96c1808be0a56730c26b8b3d2c2a">00002</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="system_8h.html#41c2f9db0a7e23392fbbebb1d1c185ec">__progname</a>; <a name="l00003"></a>00003 <a name="l00004"></a>00004 <span class="preprocessor">#include <<a class="code" href="rpmlib_8h.html">rpmlib.h</a>></span> <a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="header__internal_8h.html">header_internal.h</a>"</span> <a name="l00006"></a>00006 <a name="l00007"></a>00007 <span class="preprocessor">#include "<a class="code" href="rpmdb_8h.html">rpmdb.h</a>"</span> <a name="l00008"></a>00008 <a name="l00009"></a>00009 <span class="preprocessor">#include "<a class="code" href="debug_8h.html">debug.h</a>"</span> <a name="l00010"></a>00010 <a name="l00011"></a><a class="code" href="dumpdb_8c.html#3c04138a5bfe5d72780bb7e82a18e627">00011</a> <span class="keywordtype">int</span> <a class="code" href="rpmqv_8c.html#ef6c40289a6a07b460e1e2fc9568e404">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> ** <a class="code" href="compress_8c.html#b233d58a2d9af13ae09ea8fd82556856">argv</a>) <a name="l00012"></a>00012 { <a name="l00013"></a>00013 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dspBlockNum = 0; <span class="comment">/* default to all */</span> <a name="l00014"></a>00014 <a class="code" href="structrpmdb__s.html">rpmdb</a> db; <a name="l00015"></a>00015 <a name="l00016"></a>00016 <a class="code" href="system_8h.html#08b0a5a39651f29857ebec61a69217a2">setprogname</a>(argv[0]); <span class="comment">/* Retrofit glibc __progname */</span> <a name="l00017"></a>00017 <a class="code" href="group__rpmrc.html#gac91e0fc109eedd29b5aebed135b8580">rpmReadConfigFiles</a>(NULL, NULL); <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="keywordflow">if</span> (argc == 2) { <a name="l00020"></a>00020 dspBlockNum = atoi(argv[1]); <a name="l00021"></a>00021 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (argc != 1) { <a name="l00022"></a>00022 fprintf(stderr, <a class="code" href="system_8h.html#8a97de23397d8af6821824c0234d8c3c">_</a>(<span class="stringliteral">"dumpdb <block num>\n"</span>)); <a name="l00023"></a>00023 exit(1); <a name="l00024"></a>00024 } <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="keywordflow">if</span> (<a class="code" href="group__rpmdb.html#g803b20c733ed24a4e2361b8ab557b436">rpmdbOpen</a>(<span class="stringliteral">""</span>, &db, O_RDONLY, 0644)) { <a name="l00027"></a>00027 fprintf(stderr, <a class="code" href="system_8h.html#8a97de23397d8af6821824c0234d8c3c">_</a>(<span class="stringliteral">"cannot open Packages\n"</span>)); <a name="l00028"></a>00028 exit(1); <a name="l00029"></a>00029 } <a name="l00030"></a>00030 <a name="l00031"></a>00031 { <a class="code" href="structheaderToken__s.html">Header</a> h = NULL; <a name="l00032"></a>00032 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> blockNum = 0; <a name="l00033"></a>00033 <a class="code" href="struct__rpmdbMatchIterator.html">rpmdbMatchIterator</a> mi; <a name="l00034"></a>00034 <span class="preprocessor">#define _RECNUM rpmdbGetIteratorOffset(mi)</span> <a name="l00035"></a>00035 <span class="preprocessor"></span> <a name="l00036"></a>00036 mi = <a class="code" href="group__rpmdb.html#gaa190ebe0d275e0f46b6ed9561ed33e2">rpmdbInitIterator</a>(db, <a class="code" href="rpmlib_8h.html#39fcc4d1b52ef92e63e74b0f13ded353">RPMDBI_PACKAGES</a>, NULL, 0); <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="keywordflow">while</span> ((h = <a class="code" href="group__rpmdb.html#ga20413aa4018cf32e700decc7dba83f3">rpmdbNextIterator</a>(mi)) != NULL) { <a name="l00039"></a>00039 <a name="l00040"></a>00040 blockNum++; <a name="l00041"></a>00041 <span class="keywordflow">if</span> (!(dspBlockNum != 0 && dspBlockNum != blockNum)) <a name="l00042"></a>00042 <span class="keywordflow">continue</span>; <a name="l00043"></a>00043 <a name="l00044"></a>00044 <a class="code" href="group__header.html#g02dbaa1ed05e5e0d777c81826fd823b9">headerDump</a>(h, stdout, <a class="code" href="header__internal_8h.html#87ff559a9ed25921bf478e2dea34a84e">HEADER_DUMP_INLINE</a>, <a class="code" href="rpmlib_8h.html#8ecee0348aa330b50d6c0dc3dcc1101f">rpmTagTable</a>); <a name="l00045"></a>00045 fprintf(stdout, <span class="stringliteral">"Offset: %d\n"</span>, <a class="code" href="rpmdb_8c.html#b65ceae5fb726721ea17742080e19acc">_RECNUM</a>); <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="keywordflow">if</span> (dspBlockNum && blockNum > dspBlockNum) <a name="l00048"></a>00048 exit(0); <a name="l00049"></a>00049 } <a name="l00050"></a>00050 <a name="l00051"></a>00051 mi = <a class="code" href="group__rpmdb.html#g7d328106a65ab43bbef20b9897e463a4">rpmdbFreeIterator</a>(mi); <a name="l00052"></a>00052 <a name="l00053"></a>00053 } <a name="l00054"></a>00054 <a name="l00055"></a>00055 <a class="code" href="group__rpmdb.html#g6a784cca3ad8e152c47ce6e830673e8a">rpmdbClose</a>(db); <a name="l00056"></a>00056 <a name="l00057"></a>00057 <span class="keywordflow">return</span> 0; <a name="l00058"></a>00058 } </pre></div><hr size="1"><address style="align: right;"><small>Generated on 1 Oct 2013 for rpm by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address> </body> </html>