lib/rpmgi.c File Reference

#include "system.h"
#include <rpmlib.h>
#include <rpmte.h>
#include <rpmgi.h>
#include <rpmdb.h>
#include <rpmmacro.h>
#include "manifest.h"
#include "debug.h"

Go to the source code of this file.

Defines

#define _RPMGI_INTERNAL
#define _RPMTS_INTERNAL

Functions

static const char * ftsInfoStr (int fts_info)
static FD_t rpmgiOpen (const char *path, const char *fmode)
 Open a file after macro expanding path.
static rpmRC rpmgiLoadManifest (rpmgi gi, const char *path)
 Load manifest into iterator arg list.
static Header rpmgiReadHeader (rpmgi gi, const char *path)
 Return header from package.
static rpmRC rpmgiLoadReadHeader (rpmgi gi)
 Read next header from package, lazily expanding manifests as found.
static rpmRC rpmgiWalkPathFilter (rpmgi gi)
 Filter file tree walk path.
static rpmRC rpmgiWalkReadHeader (rpmgi gi)
 Read header from next package, lazily walking file tree.
static rpmRC rpmgiGlobArgv (rpmgi gi, ARGV_t argv)
 Append globbed arg list to iterator.
static rpmRC rpmgiInitFilter (rpmgi gi)
 Return rpmdb match iterator with filters (if any) set.
rpmgi XrpmgiUnlink (rpmgi gi, const char *msg, const char *fn, unsigned ln)
rpmgi XrpmgiLink (rpmgi gi, const char *msg, const char *fn, unsigned ln)
rpmgi rpmgiFree (rpmgi gi)
 Destroy a generalized iterator.
rpmgi rpmgiNew (rpmts ts, int tag, const void *keyp, size_t keylen)
 Return a generalized iterator.
rpmRC rpmgiNext (rpmgi gi)
 Perform next iteration step.
const char * rpmgiHdrPath (rpmgi gi)
 Return current header path.
Header rpmgiHeader (rpmgi gi)
 Return current iteration header.
rpmts rpmgiTs (rpmgi gi)
 Return current iteration transaction set.
rpmRC rpmgiSetArgs (rpmgi gi, ARGV_t argv, int ftsOpts, rpmgiFlags flags)
 Load iterator args.

Variables

int _rpmgi_debug = 0
rpmgiFlags giFlags = RPMGI_NONE
static int indent = 2
static const char * ftsInfoStrings []


Define Documentation

#define _RPMGI_INTERNAL

Definition at line 10 of file rpmgi.c.

#define _RPMTS_INTERNAL

Definition at line 11 of file rpmgi.c.


Function Documentation

static const char* ftsInfoStr ( int  fts_info  )  [static]

Definition at line 54 of file rpmgi.c.

References ftsInfoStrings.

Referenced by ftsPrint(), rpmfts_print(), and rpmgiWalkPathFilter().

rpmgi rpmgiFree ( rpmgi  gi  ) 

Destroy a generalized iterator.

Parameters:
gi generalized iterator
Returns:
NULL always

Definition at line 405 of file rpmgi.c.

References _free(), argvFree(), Fclose(), Fts_close(), headerFree(), rpmdbFreeIterator(), rpmgiUnlink, rpmtsFree(), and rpmtsiFree.

Referenced by rpmcliArgIter().

static rpmRC rpmgiGlobArgv ( rpmgi  gi,
ARGV_t  argv 
) [static]

Append globbed arg list to iterator.

Parameters:
gi generalized iterator
argv arg list to be globbed (or NULL)
Returns:
RPMRC_OK on success

Definition at line 288 of file rpmgi.c.

References argvAppend(), argvFree(), RPMDBI_ARGLIST, RPMDBI_FTSWALK, RPMDBI_HDLIST, RPMGI_NOGLOB, rpmGlob(), and RPMRC_OK.

Referenced by rpmgiSetArgs().

const char* rpmgiHdrPath ( rpmgi  gi  ) 

Return current header path.

Parameters:
gi generalized iterator
Returns:
header path

Definition at line 668 of file rpmgi.c.

Referenced by rpmcliArgIter().

Header rpmgiHeader ( rpmgi  gi  ) 

Return current iteration header.

Parameters:
gi generalized iterator
Returns:
header

Definition at line 673 of file rpmgi.c.

Referenced by rpmgiShowMatches().

static rpmRC rpmgiInitFilter ( rpmgi  gi  )  [static]

Return rpmdb match iterator with filters (if any) set.

Parameters:
gi generalized iterator
Returns:
RPMRC_OK on success

Definition at line 330 of file rpmgi.c.

References _, _free(), _rpmgi_debug, rpmdbFreeIterator(), rpmdbSetIteratorRE(), RPMERR_QUERYINFO, rpmError, RPMMIRE_DEFAULT, RPMRC_FAIL, RPMRC_OK, RPMTAG_NAME, rpmtsInitIterator(), tagName(), tagValue(), and xstrdup().

Referenced by rpmgiNext().

static rpmRC rpmgiLoadManifest ( rpmgi  gi,
const char *  path 
) [static]

Load manifest into iterator arg list.

Parameters:
gi generalized iterator
path file path
Returns:
RPMRC_OK on success

Definition at line 96 of file rpmgi.c.

References Fclose(), rpmgiOpen(), RPMRC_FAIL, and rpmReadPackageManifest().

Referenced by rpmgiLoadReadHeader().

static rpmRC rpmgiLoadReadHeader ( rpmgi  gi  )  [static]

Read next header from package, lazily expanding manifests as found.

Todo:
An empty file read as manifest truncates argv returning RPMRC_NOTFOUND.
Todo:
Errors, e.g. non-existent path in manifest, will terminate iteration.
Todo:
Chained manifests lose an arg someplace.
Parameters:
gi generalized iterator
Returns:
RPMRC_OK on success

Definition at line 156 of file rpmgi.c.

References _free(), errno, headerFree(), headerLink(), RPMGI_NOHEADER, RPMGI_NOMANIFEST, rpmgiLoadManifest(), rpmgiReadHeader(), RPMRC_NOTFOUND, and RPMRC_OK.

Referenced by rpmgiNext().

rpmgi rpmgiNew ( rpmts  ts,
int  tag,
const void *  keyp,
size_t  keylen 
)

Return a generalized iterator.

Parameters:
ts transaction set
tag rpm tag
keyp key data (NULL for sequential access)
keylen key data length (0 will use strlen(keyp))
Returns:
new iterator

Definition at line 444 of file rpmgi.c.

References rpmgiLink, rpmtsLink, and xcalloc().

Referenced by rpmcliArgIter().

rpmRC rpmgiNext ( rpmgi  gi  ) 

Perform next iteration step.

Parameters:
gi generalized iterator
Returns:
RPMRC_OK on success, RPMRC_NOTFOUND on EOI

Definition at line 478 of file rpmgi.c.

References _, _free(), _rpmgi_debug, Fclose(), Fts_close(), Fts_open(), HEADER_MAGIC_YES, headerFree(), headerLink(), headerRead(), rpmdbFreeIterator(), rpmdbGetIteratorOffset(), RPMDBI_ADDED, RPMDBI_ARGLIST, RPMDBI_FTSWALK, RPMDBI_HDLIST, RPMDBI_PACKAGES, rpmdbNextIterator(), rpmExpand(), RPMGI_NOHEADER, RPMGI_TSADD, RPMGI_TSORDER, rpmgiInitFilter(), rpmgiLoadReadHeader(), rpmgiOpen(), rpmgiWalkReadHeader(), rpmIsVerbose, RPMMESS_VERBOSE, rpmMessage, rpmpsFree(), rpmpsNumProblems(), rpmpsPrint(), RPMRC_NOTFOUND, RPMRC_OK, rpmteHeader(), rpmtsAddInstallElement(), rpmtsCheck(), rpmtsCloseDB(), rpmtsiFree, rpmtsiInit, rpmtsiNext(), rpmtsOrder(), rpmtsProblems(), TR_ADDED, and xstrdup().

Referenced by rpmcliArgIter(), and rpmgiShowMatches().

static FD_t rpmgiOpen ( const char *  path,
const char *  fmode 
) [static]

Open a file after macro expanding path.

Todo:
There are two error messages printed on header, then manifest failures.
Parameters:
path file path
fmode open mode
Returns:
file handle

Definition at line 73 of file rpmgi.c.

References _, _free(), Fclose(), Ferror(), Fopen(), Fstrerror(), RPMERR_OPEN, rpmError, and rpmExpand().

Referenced by rpmgiLoadManifest(), rpmgiNext(), and rpmgiReadHeader().

static Header rpmgiReadHeader ( rpmgi  gi,
const char *  path 
) [static]

Return header from package.

Parameters:
gi generalized iterator
path file path
Returns:
header (NULL on failure)

Definition at line 117 of file rpmgi.c.

References Fclose(), headerFree(), rpmgiOpen(), RPMRC_FAIL, RPMRC_NOKEY, RPMRC_NOTFOUND, RPMRC_NOTTRUSTED, RPMRC_OK, and rpmReadPackageFile().

Referenced by rpmgiLoadReadHeader(), and rpmgiWalkReadHeader().

rpmRC rpmgiSetArgs ( rpmgi  gi,
ARGV_t  argv,
int  ftsOpts,
rpmgiFlags  flags 
)

Load iterator args.

Parameters:
gi generalized iterator
argv arg list
ftsOpts fts(3) flags
flags iterator flags
Returns:
RPMRC_OK on success

Definition at line 687 of file rpmgi.c.

References rpmgiGlobArgv().

Referenced by rpmcliArgIter().

rpmts rpmgiTs ( rpmgi  gi  ) 

Return current iteration transaction set.

Parameters:
gi generalized iterator
Returns:
transaction set

Definition at line 680 of file rpmgi.c.

static rpmRC rpmgiWalkPathFilter ( rpmgi  gi  )  [static]

Filter file tree walk path.

Parameters:
gi generalized iterator
Returns:
RPMRC_OK on success

Definition at line 205 of file rpmgi.c.

References _rpmgi_debug, FTS_D, FTS_DC, FTS_DEFAULT, FTS_DNR, FTS_DOT, FTS_DP, FTS_ERR, FTS_F, _ftsent::fts_info, FTS_INIT, _ftsent::fts_level, _ftsent::fts_name, _ftsent::fts_namelen, FTS_NS, FTS_NSOK, FTS_SL, FTS_SLNONE, FTS_W, ftsInfoStr(), indent, RPMMESS_DEBUG, rpmMessage, RPMRC_NOTFOUND, and RPMRC_OK.

Referenced by rpmgiWalkReadHeader().

static rpmRC rpmgiWalkReadHeader ( rpmgi  gi  )  [static]

Read header from next package, lazily walking file tree.

Parameters:
gi generalized iterator
Returns:
RPMRC_OK on success

Definition at line 254 of file rpmgi.c.

References Fts_read(), headerFree(), headerLink(), RPMGI_NOHEADER, rpmgiReadHeader(), rpmgiWalkPathFilter(), RPMRC_NOTFOUND, and RPMRC_OK.

Referenced by rpmgiNext().

rpmgi XrpmgiLink ( rpmgi  gi,
const char *  msg,
const char *  fn,
unsigned  ln 
)

Todo:
Remove debugging entry from the ABI.

Definition at line 394 of file rpmgi.c.

References _rpmgi_debug.

rpmgi XrpmgiUnlink ( rpmgi  gi,
const char *  msg,
const char *  fn,
unsigned  ln 
)

Todo:
Remove debugging entry from the ABI.

Definition at line 383 of file rpmgi.c.

References _rpmgi_debug.


Variable Documentation

int _rpmgi_debug = 0

Definition at line 26 of file rpmgi.c.

const char* ftsInfoStrings[] [static]

Initial value:

 {
    "UNKNOWN",
    "D",
    "DC",
    "DEFAULT",
    "DNR",
    "DOT",
    "DP",
    "ERR",
    "F",
    "INIT",
    "NS",
    "NSOK",
    "SL",
    "SLNONE",
    "W",
}

Definition at line 35 of file rpmgi.c.

Referenced by ftsInfoStr().

rpmgiFlags giFlags = RPMGI_NONE

Definition at line 29 of file rpmgi.c.

Referenced by rpmcliArgIter().

int indent = 2 [static]

Definition at line 32 of file rpmgi.c.

Referenced by ftsPrint(), ftsStashLatest(), rpmfts_print(), and rpmgiWalkPathFilter().


Generated on Fri Oct 12 08:44:55 2007 for rpm by  doxygen 1.5.2