Introduce headerNVRD()

It's similar to headerNVR() but also returns disttag.
This commit is contained in:
Дмитрий Левин 2019-01-10 23:20:03 +00:00
parent 9618b8946f
commit 3cb012d5c3
2 changed files with 28 additions and 1 deletions

View File

@ -103,6 +103,22 @@ int headerNVR(Header h,
/*@null@*/ /*@out@*/ const char ** rp)
/*@modifies *np, *vp, *rp @*/;
/** \ingroup header
* Return name, version, release, and disttag strings from header.
* @param h header
* @retval *np name pointer (or NULL)
* @retval *vp version pointer (or NULL)
* @retval *rp release pointer (or NULL)
* @retval *dp disttag pointer (or NULL)
* @return 0 always
*/
int headerNVRD(Header h,
/*@null@*/ /*@out@*/ const char ** np,
/*@null@*/ /*@out@*/ const char ** vp,
/*@null@*/ /*@out@*/ const char ** rp,
/*@null@*/ /*@out@*/ const char ** dp)
/*@modifies *np, *vp, *rp, *dp @*/;
/** \ingroup header
* Return name, epoch, version, release, arch strings from header.
* @param h header

View File

@ -6,7 +6,8 @@
#include "rpmlib.h"
#include "debug.h"
int headerNVR(Header h, const char **np, const char **vp, const char **rp)
int headerNVRD(Header h, const char **np, const char **vp, const char **rp,
const char **dp)
{
int type;
int count;
@ -27,10 +28,20 @@ int headerNVR(Header h, const char **np, const char **vp, const char **rp)
&& type == RPM_STRING_TYPE && count == 1))
*rp = NULL;
}
if (dp) {
if (!(headerGetEntry(h, RPMTAG_DISTTAG, &type, (void **) dp, &count)
&& type == RPM_STRING_TYPE && count == 1))
*dp = NULL;
}
/*@=boundswrite@*/
return 0;
}
int headerNVR(Header h, const char **np, const char **vp, const char **rp)
{
return headerNVRD(h, np, vp, rp, NULL);
}
int headerNEVRA(Header h, const char **np,
/*@unused@*/ const char **ep, const char **vp, const char **rp,
const char **ap)