-->

Previous | Table of Contents | Next

Page 322

21.2.10.8. rpmdepDone()—Free a Dependency Data Structure

This function frees the rpmDependencies structure pointed to by rpmdep:


#include  <rpm/rpmlib.h>



void  rpmdepDone(rpmDependencies rpmdep);

21.2.11. Diagnostic Output Control

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.

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.

Unless otherwise set, the default verbosity level is RPMMESS_NORMAL.

21.2.11.1. rpmIncreaseVerbosity()—Increase Verbosity Level

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


#include  <rpm/rpmlib.h>



void   rpmIncreaseVerbosity(void);

21.2.11.2. rpmSetVerbosity()—Set Verbosity Level

This function is used to set the current verbosity level to level. Note that no range checking is done to level:


#include   <rpm/rpmlib.h>



void   rpmSetVerbosity(int level);

21.2.11.3. rpmGetVerbosity()—Return Verbosity Level

This function returns the current verbosity level:


#include   <rpm/rpmlib.h>



int  rpmGetVerbosity(void);

21.2.11.4. rpmIsVerbose()—Check Verbosity Level

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:

Page 323


#include <rpm/rpmlib.h>



int rpmIsVerbose(void);

21.2.11.5. rpmIsDebug()—Check Debug Level

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:


#include <rpm/rpmlib.h>



int rpmIsDebug(void);

21.2.12. Signature Verification

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.

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.

21.2.12.1. rpmVerifySignature()—Verify a Package File's Signature

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:


#include <rpm/rpmlib.h>



int rpmVerifySignature(char *file,

                       int_32 sigTag,

                      void *sig,

                       int count,

                        char *result);

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.

This function returns the following values:

Page 324

21.2.12.2. rpmFreeSignature()—Free Signature Read by rpmReadPackageInfo()

This function frees the signature h:


#include <rpm/rpmlib.h>

#include <rpm/header.h>



void rpmFreeSignature(Header h);

21.2.13. Header Manipulation

The header is one of the key data structures in rpmlib. The functions in this section perform basic manipulations of the header.

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.

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.

21.2.13.1. headerRead()—Read a Header

This function reads a header from file fd, converting it from network byte order to the host system's byte order:


#include <rpm/rpmlib.h>

#include <rpm/header.h>



Header headerRead(int fd,

                  int magicp);

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.

On error, this function returns NULL.

21.2.13.2. headerWrite()—Write a Header

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:


#include <rpm/rpmlib.h>

#include <rpm/header.h>



Page 325






void headerWrite(int fd,

                 Header h,

                  int magicp);

21.2.13.3. headerCopy()—Copy a Header

This function returns a copy of header h:


#include <rpm/rpmlib.h>

#include <rpm/header.h>



Header headerCopy(Header h);

21.2.13.4. headerSizeof()—Calculate a Header's Size

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:


#include <rpm/rpmlib.h>

#include <rpm/header.h>



unsigned int headerSizeof(Header h,

                          int magicp);

21.2.13.5. headerNew()—Create a New Header

This function returns a new header.


#include <rpm/rpmlib.h>

#include <rpm/header.h>



Header headerNew(void);

21.2.13.6. headerFree()—Deallocate a Header

This function deallocates the header specified by h:


#include <rpm/rpmlib.h>

#include <rpm/header.h>



void headerFree(Header h);

21.2.13.7. headerDump()—Print Header Structure in Human-Readable Form

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:


#include <rpm/rpmlib.h>

#include <rpm/header.h>



void headerDump(Header h,

                FILE *f,

                 int flags);



Previous | Table of Contents | Next