manifest2.cpp revision bd7c18002f48884a132bb0967408b6111dec326e
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * IPRT - Manifest, the core.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * Copyright (C) 2010 Oracle Corporation
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * available from http://www.virtualbox.org. This file is free software;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * you can redistribute it and/or modify it under the terms of the GNU
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * General Public License (GPL) as published by the Free Software
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * The contents of this file may alternatively be used under the terms
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * of the Common Development and Distribution License Version 1.0
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * VirtualBox OSE distribution, in which case the provisions of the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * CDDL are applicable instead of those of the GPL.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * You may elect to license modified versions of this file under the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * terms and conditions of either the GPL or the CDDL or both.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync/*******************************************************************************
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync* Header Files *
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync*******************************************************************************/
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync/*******************************************************************************
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync* Structures and Typedefs *
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync*******************************************************************************/
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * Manifest attribute.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * Used both for entries and manifest attributes.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The string space core (szName). */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The property value. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The attribute type if applicable, RTMANIFEST_ATTR_UNKNOWN if not. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** Whether it was visited by the equals operation or not. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The normalized property name that StrCore::pszString points at. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync/** Pointer to a manifest attribute. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * Manifest entry.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The string space core (szName). */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The entry attributes (hashes, checksums, size, etc) -
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * RTMANIFESTATTR. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The number of attributes. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** Whether it was visited by the equals operation or not. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The normalized entry name that StrCore::pszString points at. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync/** Pointer to a manifest entry. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * Manifest handle data.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** Magic value (RTMANIFEST_MAGIC). */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The number of references to this manifest. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** String space of the entries covered by this manifest -
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * RTMANIFESTENTRY. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The number of entries. */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /** The entry for the manifest itself. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync/** The value of RTMANIFESTINT::u32Magic. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * Argument package passed to rtManifestWriteStdAttr by rtManifestWriteStdEntry
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * and RTManifestWriteStandard.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The entry name. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync const char *pszEntry;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** The output I/O stream. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * Argument package used by RTManifestEqualsEx to pass it's arguments to the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * enumeration callback functions.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** Name of entries to ignore. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync const char * const *papszIgnoreEntries;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** Name of attributes to ignore. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync const char * const *papszIgnoreAttr;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** Flags governing the comparision. */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /** Where to return an error message (++) on failure. Can be NULL. */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /** The size of the buffer pszError points to. Can be 0. */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync /** Pointer to the 2nd manifest. */
const char *pszCurEntry;
if (!pThis)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
return cRefs;
if (!cRefs)
return cRefs;
return VERR_NOT_IMPLEMENTED;
if (ppsz)
while (*ppsz)
ppsz++;
RTStrPrintf(pEquals->pszError, pEquals->cbError, "Attribute '%s' was not found in the 1st manifest", pAttr->szName);
return VERR_NOT_EQUAL;
if (ppsz)
while (*ppsz)
ppsz++;
RTStrPrintf(pEquals->pszError, pEquals->cbError, "'%s' was not found in the 1st manifest", pEntry->StrCore.pszString);
return VERR_NOT_EQUAL;
if (ppsz)
while (*ppsz)
if (pAttr2)
ppsz++;
if (!pAttr2)
RTStrPrintf(pEquals->pszError, pEquals->cbError, "Attribute '%s' was not found in the 2nd manifest", pAttr1->szName);
return VERR_NOT_EQUAL;
return VERR_NOT_EQUAL;
DECLINLINE (int) rtManifestEntryCompare2(PRTMANIFESTEQUALS pEquals, PRTMANIFESTENTRY pEntry1, PRTMANIFESTENTRY pEntry2)
return rc;
if (ppsz)
while (*ppsz)
if (pEntry2)
ppsz++;
if (!pEntry2)
RTStrPrintf(pEquals->pszError, pEquals->cbError, "'%s' not found in the 2nd manifest", pEntry1->StrCore.pszString);
return VERR_NOT_EQUAL;
RTDECL(int) RTManifestEqualsEx(RTMANIFEST hManifest1, RTMANIFEST hManifest2, const char * const *papszIgnoreEntries,
return VINF_SUCCESS;
return VERR_NOT_EQUAL;
return rc;
static int rtManifestSetAttrWorker(PRTMANIFESTENTRY pEntry, const char *pszAttr, const char *pszValue, uint32_t fType)
char *pszValueCopy;
return rc;
if (pAttr)
if (!pAttr)
return VERR_NO_MEMORY;
AssertFailed();
return VERR_INTERNAL_ERROR_4;
return VINF_SUCCESS;
RTDECL(int) RTManifestSetAttr(RTMANIFEST hManifest, const char *pszAttr, const char *pszValue, uint32_t fType)
if (!pStrCore)
return VWRN_NOT_FOUND;
return VINF_SUCCESS;
static int rtManifestValidateNameEntry(const char *pszEntry, bool *pfNeedNormalization, size_t *pcchEntry)
int rc;
bool fNeedNormalization = false;
return rc;
if (!uc)
fNeedNormalization = true;
return VERR_INVALID_NAME;
if (pfNeedNormalization)
if (!cchEntry)
if (pcchEntry)
return rc;
char ch;
pszEntry++;
static int rtManifestGetEntry(RTMANIFESTINT *pThis, const char *pszEntry, bool fNeedNormalization, size_t cchEntry,
if (!fNeedNormalization)
return VERR_NO_TMP_MEMORY;
bool fNeedNormalization;
if (!pEntry)
return VERR_NO_MEMORY;
if (fNeedNormalization)
return VERR_INTERNAL_ERROR_4;
return rc;
RTDECL(int) RTManifestEntryUnsetAttr(RTMANIFEST hManifest, const char *pszEntry, const char *pszAttr)
bool fNeedNormalization;
return rc;
bool fNeedNormalization;
if (pEntry)
if (fNeedNormalization)
return rc;
bool fNeedNormalization;
return rc;
bool fNeedNormalization;
char ch;
return rc;
return VINF_BUFFER_OVERFLOW;
return VINF_SUCCESS;
return VINF_SUCCESS;
pszLine++;
cbLine--;
return VINF_BUFFER_OVERFLOW;
RTDECL(int) RTManifestReadStandardEx(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsIos, char *pszErr, size_t cbErr)
iLine++;
return VINF_SUCCESS;
return rc;
return VERR_OUT_OF_RANGE;
if (!*psz)
psz++;
if (*psz)
return VERR_PARSE_ERROR;
while (*psz)
psz++;
return VERR_PARSE_ERROR;
if (!*psz)
return VERR_PARSE_ERROR;
const char *pszAttr;
unsigned cBits;
unsigned uBase;
} s_aDecAttrs[] =
RTStrPrintf(pszErr, cbErr, "Malformed value ('%s') at %zu on line %u: %Rrc", pszValue, psz - szLine, iLine, rc);
return VERR_PARSE_ERROR;
const char *pszAttr;
unsigned cchHex;
} s_aHexAttrs[] =
return VERR_PARSE_ERROR;
return rc;
size_t cchLine = RTStrPrintf(szLine, sizeof(szLine), "%s (%s) = %s\n", pAttr->szName, pArgs->pszEntry, pAttr->pszValue);
return VERR_BUFFER_OVERFLOW;
return rc;