⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0322-0325.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:




<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="0318-0321.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0326-0329.html">Next</A>

</CENTER></P>



<!-- END CODE //--><A NAME="PAGENUM-322"><P>Page 322</P></A>



<H4>

21.2.10.8. rpmdepDone()&#151;Free a Dependency Data Structure

</H4>



<P>This function frees the rpmDependencies structure pointed to by

rpmdep:

</P>



<!-- CODE SNIP //-->

<PRE>

#include  &lt;rpm/rpmlib.h&gt;



void  rpmdepDone(rpmDependencies rpmdep);

</PRE>

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



<H4><A NAME="ch21_ 50">

21.2.11. Diagnostic Output Control

</A></H4>



<P>The functions in this section are used to control the amount of diagnostic output produced

by other rpmlib functions. The rpmlib library can produce a wealth of diagnostic output,

making it easy to see what is going on at any given time.

</P>



<P>There are several different verbosity levels defined in

rpmlib.h. Their symbolic names are in the form

RPMMESS_xxx, where xxx is the name of the verbosity level. Note that the numeric

values of the verbosity levels increase with a decrease in verbosity.

</P>



<P>Unless otherwise set, the default verbosity level is

RPMMESS_NORMAL.

</P>



<H4><A NAME="ch21_ 51">

21.2.11.1. rpmIncreaseVerbosity()&#151;Increase Verbosity Level

</A></H4>



<P>This function is used to increase the current verbosity level by one:

</P>



<!-- CODE SNIP //-->

<PRE>

#include  &lt;rpm/rpmlib.h&gt;



void   rpmIncreaseVerbosity(void);

</PRE>

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



<H4><A NAME="ch21_ 52">

21.2.11.2. rpmSetVerbosity()&#151;Set Verbosity Level

</A></H4>



<P>This function is used to set the current verbosity level to

level. Note that no range checking is done to

level:

</P>



<!-- CODE SNIP //-->

<PRE>

#include   &lt;rpm/rpmlib.h&gt;



void   rpmSetVerbosity(int level);

</PRE>

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



<H4><A NAME="ch21_ 53">

21.2.11.3. rpmGetVerbosity()&#151;Return Verbosity Level

</A></H4>



<P>This function returns the current verbosity level:

</P>



<!-- CODE SNIP //-->

<PRE>

#include   &lt;rpm/rpmlib.h&gt;



int  rpmGetVerbosity(void);

</PRE>

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



<H4><A NAME="ch21_ 54">

21.2.11.4. rpmIsVerbose()&#151;Check Verbosity Level

</A></H4>



<P>This function checks the current verbosity level and returns

1 if the current level is set to RPMMESS_VERBOSE or a level of higher verbosity. Otherwise, it returns

0:

</P>



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





<!-- CODE SNIP //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;



int rpmIsVerbose(void);

</PRE>

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



<H4><A NAME="ch21_ 55">

21.2.11.5. rpmIsDebug()&#151;Check Debug Level

</A></H4>



<P>This function checks the current verbosity level and returns

1 if the current level is set to RPMMESS_DEBUG or a level of higher verbosity. Otherwise, it returns

0:

</P>

<!-- CODE SNIP //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;



int rpmIsDebug(void);

</PRE>

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



<H4><A NAME="ch21_ 56">

21.2.12. Signature Verification

</A></H4>



<P>The functions in this section deal with the verification of package signatures. A package

file may contain more than one type of signature. For example, a package may contain a

signature that contains the package's size, as well as a signature that contains cryptographically

derived data that can be used to prove the package's origin.

</P>



<P>Each type of signature has its own tag value. These tag values are defined in

rpmlib.h and are in the form RPMSIGTAG_xxx, where

xxx is the type of signature.

</P>



<H4><A NAME="ch21_ 57">

21.2.12.1. rpmVerifySignature()&#151;Verify a Package File's Signature

</A></H4>



<P>This function verifies the signature of the package pointed to by

file. The result of the verification is stored in

result, in a format suitable for printing:

</P>

<!-- CODE //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;



int rpmVerifySignature(char *file,

                       int_32 sigTag,

                      void *sig,

                       int count,

                        char *result);

</PRE>

<!-- END CODE //-->



<P>The sigTag parameter specifies the type of signature to be checked. The

sig parameter specifies the signature against which the package is to be verified. The

count parameter specifies the size of the signature; at present, this parameter is only used for PGP-based signatures.

</P>



<P>This function returns the following values:

</P>



<UL>

<LI>     

RPMSIG_OK&#151;The signature verified correctly.

<LI>     

RPMSIG_UNKNOWN&#151;The signature type is unknown.

<LI>     

RPMSIG_BAD&#151;The signature did not verify correctly.

<LI>     

RPMSIG_NOKEY&#151;The key required to check this signature is not available.

</UL>



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





<H4><A NAME="ch21_ 58">

21.2.12.2. rpmFreeSignature()&#151;Free Signature Read

by rpmReadPackageInfo()

</A></H4>



<P>This function frees the signature h:

</P>

<!-- CODE SNIP //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;

#include &lt;rpm/header.h&gt;



void rpmFreeSignature(Header h);

</PRE>

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



<H4><A NAME="ch21_ 59">

21.2.13. Header Manipulation

</A></H4>



<P>The header is one of the key data structures in rpmlib. The functions in this section

perform basic manipulations of the header.

</P>



<P>The header is actually a data structure. It is not necessary to fully understand the actual

data structure, but it is necessary to understand the basic concepts on which the header is based.

</P>



<P>The header serves as a kind of miniature database. It can be searched for specific

information, which can then be retrieved easily. As in a database, the information contained in the

header can be of varying sizes.

</P>



<H4><A NAME="ch21_ 60">

21.2.13.1. headerRead()&#151;Read a Header

</A></H4>



<P>This function reads a header from file fd, converting it from network byte order to the

host system's byte order:

</P>



<!-- CODE SNIP //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;

#include &lt;rpm/header.h&gt;



Header headerRead(int fd,

                  int magicp);

</PRE>

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



<P>If magicp is defined to be HEADER_MAGIC_YES,

headerRead() will expect header magic numbers and will return an error if they are not present. Likewise, if

magicp is defined to be HEADER_MAGIC_NO,

headerRead() will not check the header's magic numbers and will return

an error if they are present.

</P>



<P>On error, this function returns NULL.

</P>



<H4><A NAME="ch21_ 61">

21.2.13.2. headerWrite()&#151;Write a Header

</A></H4>



<P>This function writes the header h to the file

fd, converting it from host byte order to network byte order. If

magicp is defined to be HEADER_MAGIC_YES,

headerWrite() will add the appropriate magic numbers to the header being written. If

magicp is defined to be HEADER_MAGIC_NO,

headerWrite() will not include magic numbers:

</P>

<!-- CODE SNIP //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;

#include &lt;rpm/header.h&gt;



</PRE>

<!-- END CODE SNIP //--><A NAME="PAGENUM-325"><P>Page 325</P></A><!-- CODE SNIP //-->

<PRE>





void headerWrite(int fd,

                 Header h,

                  int magicp);

</PRE>

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



<H4>

21.2.13.3. headerCopy()&#151;Copy a Header

</H4>



<P>This function returns a copy of header h:

</P>

<!-- CODE SNIP //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;

#include &lt;rpm/header.h&gt;



Header headerCopy(Header h);

</PRE>

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



<H4><A NAME="ch21_ 62">

21.2.13.4. headerSizeof()&#151;Calculate a Header's Size

</A></H4>



<P>This function returns the number of bytes the header

h takes up on disk. Note that in versions of RPM prior to 2.3.3, this function also changes the location of the data

in the header. The result is that pointers from

headerGetEntry() will no longer be valid. Therefore, any

pointers acquired before calling headerSizeof() should be discarded:

</P>



<!-- CODE SNIP //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;

#include &lt;rpm/header.h&gt;



unsigned int headerSizeof(Header h,

                          int magicp);

</PRE>

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



<H4><A NAME="ch21_ 63">

21.2.13.5. headerNew()&#151;Create a New Header

</A></H4>



<P>This function returns a new header.

</P>

<!-- CODE SNIP //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;

#include &lt;rpm/header.h&gt;



Header headerNew(void);

</PRE>

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



<H4><A NAME="ch21_ 64">

21.2.13.6. headerFree()&#151;Deallocate a Header

</A></H4>



<P>This function deallocates the header specified by

h:

</P>

<!-- CODE SNIP //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;

#include &lt;rpm/header.h&gt;



void headerFree(Header h);

</PRE>

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



<H4><A NAME="ch21_ 65">

21.2.13.7. headerDump()&#151;Print Header Structure in Human-Readable Form

</A></H4>



<P>This function prints the structure of the header

h to the file f. If the flags parameter is defined to be

HEADER_DUMP_INLINE, the header's data is also printed:

</P>

<!-- CODE //-->

<PRE>

#include &lt;rpm/rpmlib.h&gt;

#include &lt;rpm/header.h&gt;



void headerDump(Header h,

                FILE *f,

                 int flags);



</PRE>

<P><CENTER>

<a href="0318-0321.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0326-0329.html">Next</A>

</CENTER></P>











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

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

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