Add a few API bits for problem sets in transaction elements

- make rpmteProblems() public and refcount the returned sets
- add public rpmteCleanProblems() to destroy the per-element problem sets
- add internal rpmteAddDepProblem() for adding per-element dependency problems
This commit is contained in:
Panu Matilainen 2010-03-12 16:18:16 +02:00
parent ee24a84656
commit 1d98830819
3 changed files with 46 additions and 4 deletions

View File

@ -715,7 +715,14 @@ int rpmteHaveTransScript(rpmte te, rpmTag tag)
rpmps rpmteProblems(rpmte te)
{
return te ? te->probs : NULL;
return (te != NULL) ? rpmpsLink(te->probs, RPMDBG_M("rpmteProbs")) : NULL;
}
void rpmteCleanProblems(rpmte te)
{
if (te != NULL && te->probs != NULL) {
te->probs = rpmpsFree(te->probs);
}
}
void rpmteAddProblem(rpmte te, rpmProblemType type,
@ -730,6 +737,27 @@ void rpmteAddProblem(rpmte te, rpmProblemType type,
}
}
void rpmteAddDepProblem(rpmte te, const char * pkgNEVR, rpmds ds,
fnpyKey * suggestedKeys, int adding)
{
if (te != NULL) {
const char * DNEVR = rpmdsDNEVR(ds);
rpmProblemType type;
fnpyKey key = (suggestedKeys ? suggestedKeys[0] : NULL);
if (te->probs == NULL)
te->probs = rpmpsCreate();
switch ((unsigned)DNEVR[0]) {
case 'C': type = RPMPROB_CONFLICT; break;
default:
case 'R': type = RPMPROB_REQUIRES; break;
}
rpmpsAppend(te->probs, type, pkgNEVR, key, NULL, NULL, DNEVR, adding);
}
}
const char * rpmteTypeString(rpmte te)
{
switch(rpmteType(te)) {

View File

@ -170,6 +170,19 @@ rpmte rpmteParent(rpmte te);
*/
rpmte rpmteSetParent(rpmte te, rpmte pte);
/** \ingroup rpmte
* Return problem set info of transaction element.
* @param te transaction element
* @return problem set (or NULL if none)
*/
rpmps rpmteProblems(rpmte te);
/** \ingroup rpmte
* Destroy problem set info of transaction element.
* @param te transaction element
*/
void rpmteCleanProblems(rpmte te);
/** \ingroup rpmte
* Destroy dependency set info of transaction element.
* @param te transaction element

View File

@ -31,14 +31,15 @@ int rpmteMarkFailed(rpmte te, rpmts ts);
RPM_GNUC_INTERNAL
int rpmteHaveTransScript(rpmte te, rpmTag tag);
RPM_GNUC_INTERNAL
rpmps rpmteProblems(rpmte te);
RPM_GNUC_INTERNAL
void rpmteAddProblem(rpmte te, rpmProblemType type,
const char *dn, const char *bn,
const char *altNEVR, uint64_t number);
RPM_GNUC_INTERNAL
void rpmteAddDepProblem(rpmte te, const char * pkgNEVR, rpmds ds,
fnpyKey * suggestedKeys, int adding);
RPM_GNUC_INTERNAL
const char * rpmteTypeString(rpmte te);