# Problem Set API.

## Files
file | rpmps.h

| Structures and prototypes used for an "rpmps" problem set.
## Typedefs
typedef enum rpmprobFilterFlags_e | rpmprobFilterFlags
typedef struct rpmps_s * | rpmps
| Transaction problems found while processing a transaction set/.
typedef enum rpmProblemType_e | rpmProblemType
| Enumerate transaction set problem types.
## Enumerations
enum | rpmprobFilterFlags_e { RPMPROB_FILTER_NONE = 0, RPMPROB_FILTER_IGNOREOS = (1 << 0), RPMPROB_FILTER_IGNOREARCH = (1 << 1), RPMPROB_FILTER_REPLACEPKG = (1 << 2), RPMPROB_FILTER_FORCERELOCATE = (1 << 3), RPMPROB_FILTER_REPLACENEWFILES = (1 << 4), RPMPROB_FILTER_REPLACEOLDFILES = (1 << 5), RPMPROB_FILTER_OLDPACKAGE = (1 << 6), RPMPROB_FILTER_DISKSPACE = (1 << 7), RPMPROB_FILTER_DISKNODES = (1 << 8) }
enum | rpmProblemType_e { RPMPROB_BADARCH, RPMPROB_BADOS, RPMPROB_PKG_INSTALLED, RPMPROB_BADRELOCATE, RPMPROB_REQUIRES, RPMPROB_CONFLICT, RPMPROB_NEW_FILE_CONFLICT, RPMPROB_FILE_CONFLICT, RPMPROB_OLDPACKAGE, RPMPROB_DISKSPACE, RPMPROB_DISKNODES }
| Enumerate transaction set problem types. More...
## Functions
rpmProblem | rpmProblemCreate (rpmProblemType type, const char *pkgNEVR, fnpyKey key, const char *dn, const char *bn, const char *altNEVR, uint64_t number)
| Create a problem item.
rpmProblem | rpmProblemFree (rpmProblem prob)
| Destroy a problem item.
rpmProblem | rpmProblemLink (rpmProblem prob)
| Reference an rpmProblem instance.
rpmProblem | rpmProblemUnlink (rpmProblem prob)
| Unreference an rpmProblem instance.
const char * | rpmProblemGetPkgNEVR (const rpmProblem prob)
| Return package NEVR.
const char * | rpmProblemGetAltNEVR (const rpmProblem prob)
| Return related (e.g.
rpmProblemType | rpmProblemGetType (const rpmProblem prob)
| Return type of problem (dependency, diskpace etc).
fnpyKey | rpmProblemGetKey (const rpmProblem prob)
| Return filename or python object address of a problem.
const char * | rpmProblemGetStr (const rpmProblem prob)
| Return a generic data string from a problem.
rpm_loff_t | rpmProblemGetDiskNeed (const rpmProblem prob)
| Return disk requirement (needed disk space / number of inodes) depending on problem type.
char * | rpmProblemString (const rpmProblem prob)
| Return formatted string representation of a problem.
rpmps | rpmpsUnlink (rpmps ps, const char *msg)
| Unreference a problem set instance.
rpmps | rpmpsLink (rpmps ps, const char *msg)
| Reference a problem set instance.
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 | rpmpsGetProblem (rpmpsi psi)
| Return current problem from problem set.
rpmps | rpmpsCreate (void)
| Create a problem set.
rpmps | rpmpsFree (rpmps ps)
| Destroy a problem set.
void | rpmpsPrint (FILE *fp, rpmps ps)
| Print problems to file handle.
void | rpmpsAppendProblem (rpmps ps, rpmProblem prob)
| Append a problem to current set of problems.
void | rpmpsAppend (rpmps ps, rpmProblemType type, const char *pkgNEVR, fnpyKey key, const char *dn, const char *bn, const char *altNEVR, uint64_t number)
| Append a problem to current set of problems.
int | rpmpsTrim (rpmps ps, rpmps filter)
| Filter a problem set.

## Typedef Documentation

typedef enum rpmprobFilterFlags_e rpmprobFilterFlags

Todo:
  Generalize filter mechanism.

typedef enum rpmProblemType_e rpmProblemType

Enumerate transaction set problem types.

typedef struct rpmps_s* rpmps

Transaction problems found while processing a transaction set/.

Definition at line 42 of file rpmps.h.

## Enumeration Type Documentation

enum rpmprobFilterFlags_e

Todo:
  Generalize filter mechanism.

Enumerator:

  RPMPROB_FILTER_NONE |
  RPMPROB_FILTER_IGNOREOS | from --ignoreos
  RPMPROB_FILTER_IGNOREARCH | from --ignorearch
  RPMPROB_FILTER_REPLACEPKG | from --replacepkgs
  RPMPROB_FILTER_FORCERELOCATE | from --badreloc
  RPMPROB_FILTER_REPLACENEWFILES | from --replacefiles
  RPMPROB_FILTER_REPLACEOLDFILES | from --replacefiles
  RPMPROB_FILTER_OLDPACKAGE | from --oldpackage
  RPMPROB_FILTER_DISKSPACE | from --ignoresize
  RPMPROB_FILTER_DISKNODES | from --ignoresize

Definition at line 21 of file rpmps.h.

enum rpmProblemType_e

Enumerate transaction set problem types.

Enumerator:

  RPMPROB_BADARCH | package ... is for a different architecture
  RPMPROB_BADOS | package ... is for a different operating system
  RPMPROB_PKG_INSTALLED | package ... is already installed
  RPMPROB_BADRELOCATE | path ... is not relocatable for package ...
  RPMPROB_REQUIRES | package ... has unsatisfied Requires: ...
  RPMPROB_CONFLICT | package ... has unsatisfied Conflicts: ...
  RPMPROB_NEW_FILE_CONFLICT | file ... conflicts between attemped installs of ...
  RPMPROB_FILE_CONFLICT | file ... from install of ... conflicts with file from package ...
  RPMPROB_OLDPACKAGE | package ... (which is newer than ...) is already installed
  RPMPROB_DISKSPACE | installing package ... needs ... on the ... filesystem
  RPMPROB_DISKNODES | installing package ... needs ... on the ... filesystem

Definition at line 49 of file rpmps.h.

## Function Documentation

rpmProblem rpmProblemCreate | ( | rpmProblemType | type,
|  | const char * | pkgNEVR,
|  | fnpyKey | key,
|  | const char * | dn,
|  | const char * | bn,
|  | const char * | altNEVR,
|  | uint64_t | number |
| ) |  |  |

Create a problem item.

Parameters:

  | 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
  | number | generic number attribute

Returns:
  rpmProblem

rpmProblem rpmProblemFree | ( | rpmProblem | prob | ) |

Destroy a problem item.

Parameters:

  | prob | rpm problem

Returns:
  rpm problem (NULL)

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

Return related (e.g.

through a dependency) package NEVR

Parameters:

  | prob | rpm problem

Returns:
  related (e.g. through a dependency) package NEVR

rpm_loff_t rpmProblemGetDiskNeed | ( | const rpmProblem | prob | ) |

Return disk requirement (needed disk space / number of inodes) depending on problem type.

On problem types other than RPMPROB_DISKSPACE and RPMPROB_DISKNODES return value is undefined.

Parameters:

  | prob | rpm problem

Returns:
  disk requirement

fnpyKey rpmProblemGetKey | ( | const rpmProblem | prob | ) |

Return filename or python object address of a problem.

Parameters:

  | prob | rpm problem

Returns:
  filename or python object address

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

Return package NEVR.

Parameters:

  | prob | rpm problem

Returns:
  package NEVR

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

Return a generic data string from a problem.

Parameters:

  | prob | rpm problem

Returns:
  a generic data string

Todo:
  needs a better name

rpmProblemType rpmProblemGetType | ( | const rpmProblem | prob | ) |

Return type of problem (dependency, diskpace etc).

Parameters:

  | prob | rpm problem

Returns:
  type of problem

rpmProblem rpmProblemLink | ( | rpmProblem | prob | ) |

Reference an rpmProblem instance.

Parameters:

  | prob | rpm problem

Returns:
  rpm problem

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

Return formatted string representation of a problem.

Parameters:

  | prob | rpm problem

Returns:
  formatted string (malloc'd)

rpmProblem rpmProblemUnlink | ( | rpmProblem | prob | ) |

Unreference an rpmProblem instance.

Parameters:

  | prob | rpm problem

Returns:
  rpm problem

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

Append a problem to current set of problems.

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
  | number | generic number attribute

void rpmpsAppendProblem | ( | rpmps | ps,
|  | rpmProblem | prob |
| ) |  |  |

Append a problem to current set of problems.

Parameters:

  | ps | problem set
  | prob | rpmProblem

rpmps rpmpsCreate | ( | void |  | ) |

Create a problem set.

Returns:
  new problem set

rpmps rpmpsFree | ( | rpmps | ps | ) |

Destroy a problem set.

Parameters:

  | ps | problem set

Returns:
  NULL always

Referenced by checkSpec().

rpmpsi rpmpsFreeIterator | ( | rpmpsi | psi | ) |

Destroy problem set iterator.

Parameters:

  | psi | problem set iterator

Returns:
  problem set iterator (NULL)

rpmProblem rpmpsGetProblem | ( | rpmpsi | psi | ) |

Return current problem from problem set.

Parameters:

  | psi | problem set iterator

Returns:
  current rpmProblem

rpmpsi rpmpsInitIterator | ( | rpmps | ps | ) |

Initialize problem set iterator.

Parameters:

  | ps | problem set

Returns:
  problem set iterator

rpmps rpmpsLink | ( | rpmps | ps,
|  | const char * | msg |
| ) |  |  |

Reference a problem set instance.

Parameters:

  | ps | transaction set
  | msg |

Returns:
  new transaction set reference

int rpmpsNextIterator | ( | rpmpsi | psi | ) |

Return next problem set iterator index.

Parameters:

  | psi | problem set iterator

Returns:
  iterator index, -1 on termination

int rpmpsNumProblems | ( | rpmps | ps | ) |

Return number of problems in set.

Parameters:

  | ps | problem set

Returns:
  number of problems

Referenced by checkSpec().

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

Print problems to file handle.

Parameters:

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

Referenced by checkSpec().

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

rpmps rpmpsUnlink | ( | rpmps | ps,
|  | const char * | msg |
| ) |  |  |

Unreference a problem set instance.

Parameters:

  | ps | problem set
  | msg |

Returns:
  problem set