0334-0336.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 127 行

HTML
127
字号


<HTML>

<HEAD>

<TITLE>Maximum RPM (RPM):A Guide to the RPM Library API:EarthWeb Inc.-</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311054 //-->

<!-- TITLE=Maximum RPM (RPM)//-->

<!-- AUTHOR=Edward Bailey//-->

<!-- PUBLISHER=Macmillan Computer Publishing//-->

<!-- IMPRINT=Sams//-->

<!-- CHAPTER=21 //-->

<!-- PAGES=0305-0336 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0330-0333.html">Previous</a> | <a href="../ewtoc.html">Table of Contents</a> | <a href="../appendix-a.html">Next</a></CENTER></P>



<A NAME="PAGENUM-334"><P>Page 334</P></A>



<P>After checking for successful status, the count of matching package records is checked. If

there is at least one match, the first matching record is retrieved and dumped. Note that there

could be more than one match. Although this example doesn't dump more than the first

matching record, it would be simple to access all matches by stepping through the

matches.recs array.

</P>



<P>Once we're done with the record, we free it, as well as the list of matching records:

</P>



<!-- CODE SNIP //-->

<PRE>

rpmdbClose(db);



}

</PRE>

<!-- END CODE SNIP //-->



<P>The last thing we do before exiting is close the database. Here's some sample output from

the program (note the successful status and the number of matches printed before the dump):

</P>



<!-- CODE //-->

<PRE>

# ./showdb2 rpm

Status is: 0

Number of matches: 1

Entry count: 37

Data count : 2920



             CT  TAG                 TYPE                 OFSET      COUNT

Entry      : 000 (1000)NAME        STRING_TYPE        0x00000000 00000001

       Data: 000 rpm

Entry      : 001 (1001)VERSION     STRING_TYPE        0x00000004 00000001

        Data: 000 2.2.9

Entry      : 002 (1002)RELEASE     STRING_TYPE        0x0000000a 00000001

       Data: 000 1

Entry      : 003 (1004)SUMMARY     STRING_TYPE        0x0000000c 00000001

        Data: 000 Red Hat Package Manager

...

Entry      : 034 (1049)REQUIRENAME STRING_ARRAY_TYPE 0x00000b40 00000003

         Data: 000 libz.so.1

         Data: 001 libdb.so.2

         Data: 002 libc.so.5

Entry      : 035 (1050)REQUIREVERSION STRING_ARRAY_TYPE 0x00000b5f 00000003

       Data: 000

       Data: 001

       Data: 002

Entry      : 036 (1064)RPMVERSION     STRING_TYPE      0x00000b62 00000001

       Data: 000 2.2.9

#



</PRE>

<!-- END CODE //-->



<A NAME="PAGENUM-335"><P>Page 335</P></A>









<H2>

<A NAME="ch21_ 74">

PART III<br>

Appendixes</A>

</H2>











<A NAME="PAGENUM-336"><P>Page 336</P></A>











<P><CENTER>

<a href="0330-0333.html">Previous</a> | <a href="../ewtoc.html">Table of Contents</a> | <a href="../appendix-a.html">Next</a></CENTER></P>











</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?