summaryrefslogtreecommitdiff
path: root/src/VBox/Runtime/common/checksum
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2016-02-03 00:17:58 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2016-02-03 00:17:58 +0000
commit92e82d3f3c36a9772543375d2099bd7fbad0a0ef (patch)
tree4573f767e120674fd5218ec503da1e81e3c2b959 /src/VBox/Runtime/common/checksum
parentfa86b845a5e90bd13b49458fe5fd0356837db1eb (diff)
downloadVirtualBox-svn-92e82d3f3c36a9772543375d2099bd7fbad0a0ef.tar.gz
RTManifestSetAttr,RTManifestEntrySetAttr: Allow the attribute name to be NULL when there is a distinctive fType value given.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@59567 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Runtime/common/checksum')
-rw-r--r--src/VBox/Runtime/common/checksum/manifest2.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/VBox/Runtime/common/checksum/manifest2.cpp b/src/VBox/Runtime/common/checksum/manifest2.cpp
index 139fa3cc51f..9df7626f6a4 100644
--- a/src/VBox/Runtime/common/checksum/manifest2.cpp
+++ b/src/VBox/Runtime/common/checksum/manifest2.cpp
@@ -650,6 +650,26 @@ RTDECL(int) RTManifestEquals(RTMANIFEST hManifest1, RTMANIFEST hManifest2)
/**
+ * Translates a attribyte type to a attribute name.
+ *
+ * @returns Attribute name for fFlags, NULL if not translatable.
+ * @param fType The type flags. Only one bit should be set.
+ */
+static const char *rtManifestTypeToAttrName(uint32_t fType)
+{
+ switch (fType)
+ {
+ case RTMANIFEST_ATTR_SIZE: return "SIZE";
+ case RTMANIFEST_ATTR_MD5: return "MD5";
+ case RTMANIFEST_ATTR_SHA1: return "SHA1";
+ case RTMANIFEST_ATTR_SHA256: return "SHA256";
+ case RTMANIFEST_ATTR_SHA512: return "SHA512";
+ default: return NULL;
+ }
+}
+
+
+/**
* Worker common to RTManifestSetAttr and RTManifestEntrySetAttr.
*
* @returns IPRT status code.
@@ -720,9 +740,11 @@ RTDECL(int) RTManifestSetAttr(RTMANIFEST hManifest, const char *pszAttr, const c
RTMANIFESTINT *pThis = hManifest;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertReturn(pThis->u32Magic == RTMANIFEST_MAGIC, VERR_INVALID_HANDLE);
- AssertPtr(pszAttr);
AssertPtr(pszValue);
AssertReturn(RT_IS_POWER_OF_TWO(fType) && fType < RTMANIFEST_ATTR_END, VERR_INVALID_PARAMETER);
+ if (!pszAttr)
+ pszAttr = rtManifestTypeToAttrName(fType);
+ AssertPtr(pszAttr);
return rtManifestSetAttrWorker(&pThis->SelfEntry, pszAttr, pszValue, fType);
}
@@ -979,9 +1001,11 @@ RTDECL(int) RTManifestEntrySetAttr(RTMANIFEST hManifest, const char *pszEntry, c
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertReturn(pThis->u32Magic == RTMANIFEST_MAGIC, VERR_INVALID_HANDLE);
AssertPtr(pszEntry);
- AssertPtr(pszAttr);
AssertPtr(pszValue);
AssertReturn(RT_IS_POWER_OF_TWO(fType) && fType < RTMANIFEST_ATTR_END, VERR_INVALID_PARAMETER);
+ if (!pszAttr)
+ pszAttr = rtManifestTypeToAttrName(fType);
+ AssertPtr(pszAttr);
bool fNeedNormalization;
size_t cchEntry;