diff --git a/lib/rpmlib.h b/lib/rpmlib.h index bb0d86c..1e4c9b3 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -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 diff --git a/rpmdb/hdrNVR.c b/rpmdb/hdrNVR.c index 9e593bf..89d4705 100644 --- a/rpmdb/hdrNVR.c +++ b/rpmdb/hdrNVR.c @@ -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)