rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions | Variables
rpmgi.c File Reference
RPMGI Generalized Iterator API.
`#include "system.h"`
`#include <rpmio.h>`
`#include <rpmiotypes.h>`
`#include <rpmcb.h>`
`#include <rpmmacro.h>`
`#include <rpmtypes.h>`
`#include <rpmtag.h>`
`#include <rpmdb.h>`
`#include <rpmte.h>`
`#include <pkgio.h>`
`#include <rpmgi.h>`
`#include "manifest.h"`
`#include <rpmlib.h>`
`#include "debug.h"`
Include dependency graph for rpmgi.c:

Go to the source code of this file.

## Macros
#define | _RPMGI_INTERNAL
#define | _RPMTS_INTERNAL /* XXX ts->probs et al */

## 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. More...
static rpmRC | rpmgiLoadManifest (rpmgi gi, const char *path)
| Load manifest into iterator arg list. More...
Header | rpmgiReadHeader (rpmgi gi, const char *path)
| Return header from package. More...
static rpmRC | rpmgiLoadNextKey (rpmgi gi)
| Load next key from argv list. More...
static rpmRC | rpmgiLoadReadHeader (rpmgi gi)
| Read next header from package, lazily expanding manifests as found. More...
static rpmRC | rpmgiWalkPathFilter (rpmgi gi)
| Filter file tree walk path. More...
static rpmRC | rpmgiWalkReadHeader (rpmgi gi)
| Read header from next package, lazily walking file tree. More...
const char * | rpmgiEscapeSpaces (const char *s)
| Escape isspace(3) characters in string. More...
static rpmRC | rpmgiGlobArgv (rpmgi gi, ARGV_t argv)
| Append globbed arg list to iterator. More...
static rpmRC | rpmgiInitFilter (rpmgi gi)
| Return rpmdb match iterator with filters (if any) set. More...
static void | rpmgiFini (void *_gi)
static rpmgi | rpmgiGetPool (rpmioPool pool)
rpmgi | rpmgiNew (rpmts ts, int tag, const void *keyp, size_t keylen)
| Return a generalized iterator. More...
rpmRC | rpmgiNext (rpmgi gi)
| Perform next iteration step. More...
rpmgiFlags | rpmgiGetFlags (rpmgi gi)
| Return current iteration flags. More...
const char * | rpmgiHdrPath (rpmgi gi)
| Return current header path. More...
Header | rpmgiHeader (rpmgi gi)
| Return current iteration header. More...
rpmts | rpmgiTs (rpmgi gi)
| Return current iteration transaction set. More...
rpmRC | rpmgiSetArgs (rpmgi gi, ARGV_t argv, int ftsOpts, rpmgiFlags flags)
| Load iterator args. More...

## Variables
int | _rpmgi_debug = 0
rpmgiFlags | giFlags = RPMGI_NONE
static int | indent = 2
static const char * | ftsInfoStrings []
rpmioPool | _rpmgiPool
static const char * | _query_hdlist_path = "/usr/share/comps/%{_arch}/hdlist"

## Macro Definition Documentation

#define _RPMGI_INTERNAL

Definition at line 18 of file rpmgi.c.

#define _RPMTS_INTERNAL /* XXX ts->probs et al */

Definition at line 19 of file rpmgi.c.

## Function Documentation

static const char* ftsInfoStr | ( | int | fts_info | ) |
| static

Definition at line 73 of file rpmgi.c.

References ftsInfoStrings.

Referenced by rpmgiWalkPathFilter().

const char* rpmgiEscapeSpaces | ( | const char * | s | ) |

Escape isspace(3) characters in string.

Parameters

  s | string

Returns
  escaped string

Definition at line 330 of file rpmgi.c.

References xmalloc().

Referenced by IDTXglob(), and rpmgiGlobArgv().

static void rpmgiFini | ( | void * | _gi | ) |
| static

Definition at line 459 of file rpmgi.c.

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

Referenced by rpmgiGetPool().

rpmgiFlags rpmgiGetFlags | ( | rpmgi | gi | ) |

Return current iteration flags.

Parameters

  gi | generalized iterator

Returns
  flags

Definition at line 816 of file rpmgi.c.

References RPMGI_NONE.

Referenced by rpmcliArgIter().

static rpmgi rpmgiGetPool | ( | rpmioPool | pool | ) |
| static

Definition at line 491 of file rpmgi.c.

References _rpmgi_debug, _rpmgiPool, rpmgiFini(), rpmioGetPool(), and rpmioNewPool().

Referenced by rpmgiNew().

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 360 of file rpmgi.c.

References _free(), argvAppend(), argvFree(), RPMDBI_ARGLIST, RPMDBI_FTSWALK, RPMDBI_HDLIST, RPMGI_NOGLOB, rpmgiEscapeSpaces(), 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 821 of file rpmgi.c.

Referenced by rpmcliArgIter(), rpmcliInstall(), rpmcliSign(), and rpmReSign().

Header rpmgiHeader | ( | rpmgi | gi | ) |

Return current iteration header.

Parameters

  gi | generalized iterator

Returns
  header

Definition at line 826 of file rpmgi.c.

Referenced by rpmcliInstall(), and 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 404 of file rpmgi.c.

References _, _free(), _rpmgi_debug, RPMDBI_PACKAGES, rpmlog(), RPMLOG_NOTICE, rpmmiAddPattern(), rpmmiFree(), 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 119 of file rpmgi.c.

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

Referenced by rpmgiLoadReadHeader().

static rpmRC rpmgiLoadNextKey | ( | rpmgi | gi | ) |
| static

Load next key from argv list.

Parameters

  gi | generalized iterator

Returns
  RPMRC_OK on success

Definition at line 167 of file rpmgi.c.

References RPMRC_NOTFOUND, and RPMRC_OK.

Referenced by rpmgiNext().

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.

  Errors, e.g. non-existent path in manifest, will terminate iteration.

  Chained manifests lose an arg someplace.

Parameters

  gi | generalized iterator

Returns
  RPMRC_OK on success

Definition at line 191 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 505 of file rpmgi.c.

References rpmgiGetPool(), rpmgiLink(), rpmtsLink(), rpmtsOrder(), and xcalloc().

Referenced by main(), rpmcliArgIter(), rpmcliInstall(), rpmcliSign(), and rpmReSign().

rpmRC rpmgiNext | ( | rpmgi | gi | ) |

Perform next iteration step.

Parameters

  gi | generalized iterator

Returns
  RPMRC_OK on success, RPMRC_NOTFOUND on EOI

Definition at line 546 of file rpmgi.c.

References _, _free(), _query_hdlist_path, _rpmgi_debug, Fclose(), Fts_close(), Fts_open(), headerFree(), headerGetInstance(), headerLink(), rpmdbBlockDBI(), RPMDBI_ADDED, RPMDBI_ARGLIST, RPMDBI_DEPENDS, RPMDBI_FTSWALK, RPMDBI_HDLIST, RPMDBI_PACKAGES, RPMDBI_REMOVED, RPMDEPS_FLAG_DEPLOOPS, rpmExpand(), RPMGI_ERASING, RPMGI_NOHEADER, RPMGI_TSADD, RPMGI_TSORDER, rpmgiInitFilter(), rpmgiLoadNextKey(), rpmgiLoadReadHeader(), rpmgiOpen(), rpmgiWalkReadHeader(), rpmIsVerbose, rpmlog(), RPMLOG_ERR, RPMLOG_INFO, rpmmiFree(), rpmmiInstance(), rpmmiNext(), rpmpkgRead(), rpmpsFree(), rpmpsNumProblems(), rpmpsPrint(), RPMRC_NOTFOUND, RPMRC_OK, RPMTAG_BASENAMES, RPMTAG_PROVIDENAME, rpmteHeader(), rpmteType(), rpmtsAddEraseElement(), rpmtsAddInstallElement(), rpmtsCheck(), rpmtsDFlags(), rpmtsGetRdb(), rpmtsiFree(), rpmtsiInit(), rpmtsiNext(), rpmtsProblems(), rpmtsSetDFlags(), rpmtsSetGoal(), tagName(), TR_ADDED, TR_REMOVED, TSM_ERASE, TSM_INSTALL, and xstrdup().

Referenced by main(), rpmcliArgIter(), rpmcliInstall(), rpmcliSign(), rpmgiShowMatches(), and rpmReSign().

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 92 of file rpmgi.c.

References _, _free(), errno, Fclose(), Ferror(), Fopen(), Fstrerror(), rpmExpand(), rpmlog(), and RPMLOG_ERR.

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

Header rpmgiReadHeader | ( | rpmgi | gi,
|  | const char * | path
| ) |  |

Return header from package.

Parameters

  gi | generalized iterator
  path | file path

Returns
  header (NULL on failure)

Definition at line 133 of file rpmgi.c.

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

Referenced by rpmcliInstall(), 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 840 of file rpmgi.c.

References rpmgiGlobArgv(), and RPMRC_FAIL.

Referenced by main(), rpmcliArgIter(), rpmcliInstall(), rpmcliSign(), and rpmReSign().

rpmts rpmgiTs | ( | rpmgi | gi | ) |

Return current iteration transaction set.

Parameters

  gi | generalized iterator

Returns
  transaction set

Definition at line 833 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 242 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, rpmlog(), RPMLOG_DEBUG, 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 293 of file rpmgi.c.

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

Referenced by rpmgiNext().

## Variable Documentation

const char* _query_hdlist_path = "/usr/share/comps/%{_arch}/hdlist"
| static

Definition at line 544 of file rpmgi.c.

Referenced by rpmgiNext().

int _rpmgi_debug = 0

Definition at line 37 of file rpmgi.c.

Referenced by rpmgiGetPool(), rpmgiInitFilter(), rpmgiNext(), and rpmgiWalkPathFilter().

rpmioPool _rpmgiPool

Definition at line 489 of file rpmgi.c.

Referenced by rpmgiGetPool().

const char* ftsInfoStrings[]
| static

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

Definition at line 52 of file rpmgi.c.

Referenced by ftsInfoStr().

rpmgiFlags giFlags = RPMGI_NONE

Definition at line 42 of file rpmgi.c.

Referenced by main(), and rpmcliArgIter().

int indent = 2
| static

Definition at line 47 of file rpmgi.c.

Referenced by FDGyamlTag(), mtreeCWalk(), mtreeVisitF(), output(), PRCOyamlTag(), rpmdcCWalk(), rpmfts_print(), rpmgiWalkPathFilter(), yamlstrcpy(), and yamlstrlen().