# lib/rpmps.c File Reference

`#include "system.h"`
`#include <rpmio.h>`
`#include <rpmcb.h>`
`#include <rpmlib.h>`
`#include "rpmps.h"`
`#include "debug.h"`

Include dependency graph for rpmps.c:

Go to the source code of this file.

## Defines
#define | _RPMPS_INTERNAL
#define | XSTRCMP(a, b) ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b))))
## Functions
rpmps | XrpmpsUnlink (rpmps ps, const char *msg, const char *fn, unsigned ln)
rpmps | XrpmpsLink (rpmps ps, const char *msg, const char *fn, unsigned ln)
int | rpmpsNumProblems (rpmps ps)
| Return number of problems in set.
rpmpsi | rpmpsInitIterator (rpmps ps)
| Initialize problem set iterator.
rpmpsi | rpmpsFreeIterator (rpmpsi psi)
| Destroy problem set iterator.
int | rpmpsNextIterator (rpmpsi psi)
| Return next problem set iterator index.
rpmProblem | rpmpsProblem (rpmpsi psi)
| Return current problem from problem set.
rpmps | rpmpsCreate (void)
| Create a problem set.
rpmps | rpmpsFree (rpmps ps)
| Destroy a problem set.
void | rpmpsAppend (rpmps ps, rpmProblemType type, const char *pkgNEVR, fnpyKey key, const char *dn, const char *bn, const char *altNEVR, uint64_t ulong1)
| Append a problem to current set of problems.
int | rpmpsTrim (rpmps ps, rpmps filter)
| Filter a problem set.
static int | vsnprintf (char *buf, int nb, const char *fmt, va_list ap)
static int | snprintf (char *buf, int nb, const char *fmt,...)
const char * | rpmProblemString (const rpmProblem prob)
| Return formatted string representation of a problem.
static int | sameProblem (const rpmProblem ap, const rpmProblem bp)
void | rpmpsPrint (FILE *fp, rpmps ps)
| Print problems to file handle.
rpmProblem | rpmpsGetProblem (rpmps ps, int num)
| Return a problem from problem set.
char * | rpmProblemGetPkgNEVR (rpmProblem prob)
| Return the package NEVR causing the problem.
char * | rpmProblemGetAltNEVR (rpmProblem prob)
| Return the second package NEVR causing the problem.
char * | rpmProblemGetStr (rpmProblem prob)
| Return a generic data string from a problem.
unsigned long long | rpmProblemGetLong (rpmProblem prob)
| Return generic pointer/long attribute from a problem.
rpmProblemType | rpmProblemGetType (rpmProblem prob)
| Return the problem type.
fnpyKey | rpmProblemKey (rpmProblem prob)
| Return the transaction key causing the problem.
## Variables
int | _rpmps_debug = 0

## Detailed Description

Definition in file rpmps.c.

## Define Documentation

#define _RPMPS_INTERNAL

Definition at line 11 of file rpmps.c.

#define XSTRCMP | ( | a,
|  | b |  | ) | ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b))))

Definition at line 167 of file rpmps.c.

Referenced by rpmpsTrim().

## Function Documentation

char* rpmProblemGetAltNEVR | ( | rpmProblem | prob | ) |

Return the second package NEVR causing the problem.

Parameters:

  | prob | rpm problem

Returns:
  NEVR string ptr, or NULL if unset

Definition at line 401 of file rpmps.c.

Referenced by rpmts_Check(), and verifyDependencies().

unsigned long long rpmProblemGetLong | ( | rpmProblem | prob | ) |

Return generic pointer/long attribute from a problem.

Parameters:

  | prob | rpm problem

Returns:
  a generic pointer/long attribute

Todo:
  needs a better name

Definition at line 411 of file rpmps.c.

char* rpmProblemGetPkgNEVR | ( | rpmProblem | prob | ) |

Return the package NEVR causing the problem.

Parameters:

  | prob | rpm problem

Returns:
  NEVR string ptr

Definition at line 396 of file rpmps.c.

Referenced by rpmts_Check(), and verifyDependencies().

char* rpmProblemGetStr | ( | rpmProblem | prob | ) |

Return a generic data string from a problem.

Parameters:

  | prob | rpm problem

Returns:
  a generic data string

Todo:
  needs a better name

Definition at line 406 of file rpmps.c.

rpmProblemType rpmProblemGetType | ( | rpmProblem | prob | ) |

Return the problem type.

Parameters:

  | prob | rpm problem

Returns:
  rpmProblemType

Definition at line 416 of file rpmps.c.

Referenced by rpmts_Check(), and rpmts_Run().

fnpyKey rpmProblemKey | ( | rpmProblem | prob | ) |

Return the transaction key causing the problem.

Parameters:

  | prob | rpm problem

Returns:
  fnpkey ptr if any or NULL

Definition at line 421 of file rpmps.c.

Referenced by rpmts_Check().

const char* rpmProblemString | ( | const rpmProblem | prob | ) |

Return formatted string representation of a problem.

Parameters:

  | prob | rpm problem

Returns:
  formatted string (malloc'd)

Definition at line 234 of file rpmps.c.

References _, N_, RPMPROB_BADPLATFORM, RPMPROB_BADPRETRANS, RPMPROB_BADRELOCATE, RPMPROB_CONFLICT, RPMPROB_DISKNODES, RPMPROB_DISKSPACE, RPMPROB_FILE_CONFLICT, RPMPROB_NEW_FILE_CONFLICT, RPMPROB_NOREPACKAGE, RPMPROB_OLDPACKAGE, RPMPROB_PKG_INSTALLED, RPMPROB_RDONLY, RPMPROB_REQUIRES, snprintf(), and xmalloc().

Referenced by rpmps_iternext(), rpmps_subscript(), rpmpsPrint(), and rpmts_Run().

void rpmpsAppend | ( | rpmps | ps,
|  | rpmProblemType | type,
|  | const char * | pkgNEVR,
|  | fnpyKey | key,
|  | const char * | dn,
|  | const char * | bn,
|  | const char * | altNEVR,
|  | uint64_t | ulong1 |
| ) |  |  |

Append a problem to current set of problems.

Warning:
  This function's args have changed, so the function cannot be used portably

Parameters:

  | ps | problem set
  | type | type of problem
  | pkgNEVR | package name
  | key | filename or python object address
  | dn | directory name
  | bn | file base name
  | altNEVR | related (e.g. through a dependency) package name
  | ulong1 | generic pointer/long attribute

Definition at line 126 of file rpmps.c.

References stpcpy(), xcalloc(), xrealloc(), and xstrdup().

Referenced by cmpArgvStr(), ensureOlder(), handleInstInstalledFiles(), handleOverlappedFiles(), relocateFileList(), rpmdsProblem(), rpmps_Append(), rpmps_ass_sub(), rpmtsAddInstallElement(), rpmtsCheckDSIProblems(), and rpmtsRun().

rpmps rpmpsCreate | ( | void |  | ) |

Create a problem set.

Returns:
  new problem set

Definition at line 99 of file rpmps.c.

References rpmpsLink, and xcalloc().

Referenced by rpmps_init(), rpmRollback(), rpmtsCheck(), and rpmtsRun().

rpmps rpmpsFree | ( | rpmps | ps | ) |

Destroy a problem set.

Parameters:

  | ps | problem set

Returns:
  NULL always

Definition at line 105 of file rpmps.c.

References _free(), and rpmpsUnlink.

Referenced by checkPackageDeps(), cmpArgvStr(), ensureOlder(), handleInstInstalledFiles(), handleOverlappedFiles(), relocateFileList(), rpmcliInstallProblems(), rpmgiNext(), rpmps_dealloc(), rpmps_free(), rpmRollback(), rpmts_Check(), rpmts_Run(), rpmtsAddInstallElement(), rpmtsCheck(), rpmtsCheckDSIProblems(), rpmtsClean(), rpmtsRun(), and verifyDependencies().

rpmpsi rpmpsFreeIterator | ( | rpmpsi | psi | ) |

Destroy problem set iterator.

Parameters:

  | psi | problem set iterator

Returns:
  problem set iterator (NULL)

Definition at line 67 of file rpmps.c.

References _free(), and rpmpsUnlink.

Referenced by rpmps_iternext(), rpmps_subscript(), rpmpsPrint(), rpmts_Check(), rpmts_Run(), and verifyDependencies().

rpmProblem rpmpsGetProblem | ( | rpmps | ps,
|  | int | num |
| ) |  |  |

Return a problem from problem set.

Parameters:

  | ps | problem set
  | num | problem number

Returns:
  rpmProblem, or NULL if error

Definition at line 389 of file rpmps.c.

rpmpsi rpmpsInitIterator | ( | rpmps | ps | ) |

Initialize problem set iterator.

Parameters:

  | ps | problem set

Returns:
  problem set iterator

Definition at line 56 of file rpmps.c.

References rpmpsLink, and xcalloc().

Referenced by rpmps_iter(), rpmps_iternext(), rpmps_subscript(), rpmpsPrint(), rpmts_Check(), rpmts_Run(), and verifyDependencies().

int rpmpsNextIterator | ( | rpmpsi | psi | ) |

Return next problem set iterator index.

Parameters:

  | psi | problem set iterator

Returns:
  iterator index, -1 on termination

Definition at line 76 of file rpmps.c.

References rpmpsNumProblems().

Referenced by rpmps_iternext(), rpmps_subscript(), rpmpsPrint(), rpmts_Check(), rpmts_Run(), and verifyDependencies().

int rpmpsNumProblems | ( | rpmps | ps | ) |

Return number of problems in set.

Parameters:

  | ps | problem set

Returns:
  number of problems

Definition at line 48 of file rpmps.c.

Referenced by rpmcliInstallProblems(), rpmgiNext(), rpmps_length(), rpmpsNextIterator(), rpmpsProblem(), rpmtsCheck(), rpmtsRun(), and verifyDependencies().

void rpmpsPrint | ( | FILE * | fp,
|  | rpmps | ps |
| ) |  |  |

Print problems to file handle.

Parameters:

  | fp | file handle (NULL uses stderr)
  | ps | problem set

Definition at line 349 of file rpmps.c.

References _free(), rpmProblemString(), rpmpsFreeIterator(), rpmpsInitIterator(), rpmpsNextIterator(), rpmpsProblem(), and sameProblem().

Referenced by rpmcliInstallProblems(), rpmgiNext(), and rpmps_print().

rpmProblem rpmpsProblem | ( | rpmpsi | psi | ) |

Return current problem from problem set.

Parameters:

  | psi | problem set iterator

Returns:
  current rpmProblem

Definition at line 90 of file rpmps.c.

References rpmpsNumProblems().

Referenced by rpmps_iternext(), rpmps_subscript(), rpmpsPrint(), rpmts_Check(), rpmts_Run(), and verifyDependencies().

int rpmpsTrim | ( | rpmps | ps,
|  | rpmps | filter |
| ) |  |  |

Filter a problem set.

As the problem sets are generated in an order solely dependent on the ordering of the packages in the transaction, and that ordering can't be changed, the problem sets must be parallel to one another. Additionally, the filter set must be a subset of the target set, given the operations available on transaction set. This is good, as it lets us perform this trim in linear time, rather then logarithmic or quadratic.

Parameters:

  | ps | problem set
  | filter | problem filter (or NULL)

Returns:
  0 no problems, 1 if problems remain

Definition at line 169 of file rpmps.c.

References XSTRCMP.

Referenced by rpmtsRun().

static int sameProblem | ( | const rpmProblem | ap,
|  | const rpmProblem | bp |
| ) |  |  | `[static]`

Definition at line 328 of file rpmps.c.

Referenced by rpmpsPrint().

static int snprintf | ( | char * | buf,
|  | int | nb,
|  | const char * | fmt,
|  |  | ... |
| ) |  |  | `[inline, static]`

Definition at line 223 of file rpmps.c.

References vsnprintf().

Referenced by _tagName(), doSetupMacro(), formatValue(), genSourceRpmName(), headerCheck(), pgpsigFormat(), prepFetchVerbose(), processSourceFiles(), rdLead(), rdSignature(), rpmdbMoveDatabase(), rpmdbRemoveDatabase(), rpmfcHelper(), rpmProblemString(), rpmpsmStage(), rpmReadHeader(), rpmtsFindPubkey(), shescapeFormat(), singleSprintf(), xmlFormat(), and yamlFormat().

static int vsnprintf | ( | char * | buf,
|  | int | nb,
|  | const char * | fmt,
|  | va_list | ap |
| ) |  |  | `[inline, static]`

Definition at line 215 of file rpmps.c.

Referenced by snprintf(), and vrpmlog().

rpmps XrpmpsLink | ( | rpmps | ps,
|  | const char * | msg,
|  | const char * | fn,
|  | unsigned | ln |
| ) |  |  |

Todo:
  Remove debugging entry from the ABI.

Definition at line 35 of file rpmps.c.

References _rpmps_debug.

rpmps XrpmpsUnlink | ( | rpmps | ps,
|  | const char * | msg,
|  | const char * | fn,
|  | unsigned | ln |
| ) |  |  |

Todo:
  Remove debugging entry from the ABI.

Definition at line 22 of file rpmps.c.

References _rpmps_debug.

## Variable Documentation

int _rpmps_debug = 0

Definition at line 20 of file rpmps.c.

Referenced by rpmps_alloc(), rpmps_ass_sub(), rpmps_dealloc(), rpmps_Debug(), rpmps_free(), rpmps_getattro(), rpmps_init(), rpmps_iter(), rpmps_iternext(), rpmps_length(), rpmps_new(), rpmps_print(), rpmps_setattro(), rpmps_subscript(), XrpmpsLink(), and XrpmpsUnlink().