manifest.h revision db22a92f701bfcc17823963d6c8b745f68d44e30
2N/A * IPRT - Manifest file handling. 2N/A * Copyright (C) 2009 Oracle Corporation 2N/A * This file is part of VirtualBox Open Source Edition (OSE), as 2N/A * you can redistribute it and/or modify it under the terms of the GNU 2N/A * General Public License (GPL) as published by the Free Software 2N/A * Foundation, in version 2 as it comes in the "COPYING" file of the 2N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 2N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 2N/A * The contents of this file may alternatively be used under the terms 2N/A * of the Common Development and Distribution License Version 1.0 2N/A * (CDDL) only, as it comes in the "COPYING.CDDL" file of the 2N/A * VirtualBox OSE distribution, in which case the provisions of the 2N/A * CDDL are applicable instead of those of the GPL. 2N/A * You may elect to license modified versions of this file under the 2N/A * terms and conditions of either the GPL or the CDDL or both. /** @defgroup grp_rt_manifest RTManifest - Manifest file creation and checking /** @name Manifest attribute types. * The types can be ORed together to form a set. /** For use with other attributes. Representation unknown. */ /** The size of the content. Represented as a decimal number. */ /** The MD5 of the content. Represented as a hex string. */ /** The SHA-1 of the content. Represented as a hex string. */ /** The SHA-256 of the content. Represented as a hex string. */ /** The SHA-512 of the content. Represented as a hex string. */ /** The end of the valid values. */ * Creates an empty manifest. * @returns IPRT status code. * @param fFlags Flags, MBZ. * @param phManifest Where to return the handle to the manifest. * Retains a reference to the manifest handle. * @returns The new reference count, UINT32_MAX if the handle is invalid. * @param hManifest The handle to retain. * Releases a reference to the manifest handle. * @returns The new reference count, 0 if free. UINT32_MAX is returned if the * @param hManifest The handle to release. * NIL is quietly ignored (returns 0). * Creates a duplicate of the specified manifest. * @returns IPRT status code * @param hManifestSrc The manifest to clone. * @param phManifestDst Where to store the handle to the duplicate. * Compares two manifests for equality. * @returns IPRT status code. * @retval VINF_SUCCESS if equal. * @retval VERR_NOT_EQUAL if not equal. * @param hManifest1 The first manifest. * @param hManifest2 The second manifest. * @param papszIgnoreEntries Entries to ignore. Ends with a NULL entry. * @param papszIgnoreAttrs Attributes to ignore. Ends with a NULL entry. * @param pszEntry Where to store the name of the mismatching * entry, or as much of the name as there is room * for. This is always set. Optional. * @param cbEntry The size of the buffer pointed to by @a * Compares two manifests for equality. * @returns IPRT status code. * @retval VINF_SUCCESS if equal. * @retval VERR_NOT_EQUAL if not equal. * @param hManifest1 The first manifest. * @param hManifest2 The second manifest. * Sets a manifest attribute. * @returns IPRT status code. * @param hManifest The manifest handle. * @param pszAttr The attribute name. If this already exists, * its value will be replaced. * @param pszValue The value string. * @param fType The attribute type, pass * RTMANIFEST_ATTR_UNKNOWN if not known. * Unsets (removes) a manifest attribute if it exists. * @returns IPRT status code. * @retval VWRN_NOT_FOUND if not found. * @param hManifest The manifest handle. * @param pszAttr The attribute name. * Sets an attribute of a manifest entry. * @returns IPRT status code. * @param hManifest The manifest handle. * @param pszEntry The entry name. This will automatically be * added if there was no previous call to * RTManifestEntryAdd for this name. See * RTManifestEntryAdd for the entry name rules. * @param pszAttr The attribute name. If this already exists, * its value will be replaced. * @param pszValue The value string. * @param fType The attribute type, pass * RTMANIFEST_ATTR_UNKNOWN if not known. * Unsets (removes) an attribute of a manifest entry if they both exist. * @returns IPRT status code. * @retval VWRN_NOT_FOUND if not found. * @param hManifest The manifest handle. * @param pszEntry The entry name. * @param pszAttr The attribute name. * Adds a new entry to a manifest. * - The entry name can contain any character defined by unicode, except * control characters, ':', '(' and ')'. The exceptions are mainly there * because of uncertainty around how various formats handles these. * - It is considered case sensitive. * - Forward (unix) and backward (dos) slashes are considered path * separators and converted to forward slashes. * @returns IPRT status code. * @retval VWRN_ALREADY_EXISTS if the entry already exists. * @param hManifest The manifest handle. * @param pszEntry The entry name (UTF-8). * @remarks Some manifest formats will not be able to store an entry without * any attributes. So, this is just here in case it comes in handy * when dealing with formats which can. * @returns IPRT status code. * @param hManifest The manifest handle. * @param pszEntry The entry name. * Adds an entry for a file with the specified set of attributes. * @returns IPRT status code. * @param hManifest The manifest handle. * @param hVfsIos The I/O stream handle of the entry. This will * be processed to its end on successful return. * (Must be positioned at the start to get * @param pszEntry The entry name. * @param fAttrs The attributes to create for this stream. See * Reads in a "standard" manifest. * This reads the format used by OVF, the distinfo in FreeBSD ports, and * @returns IPRT status code. * @param hManifest The handle to the manifest where to add the * manifest that's read in. * @param hVfsIos The I/O stream to read the manifest from. * Writes a "standard" manifest. * This writes the format used by OVF, the distinfo in FreeBSD ports, and * @returns IPRT status code. * @param hManifest The handle to the manifest where to add the * manifest that's read in. * @param hVfsIos The I/O stream to read the manifest from. * Input structure for RTManifestVerify() which contains the filename & the /** The SHA1 digest of the file. */ /** Pointer to the input structure. */ * Verify the given SHA1 digests against the entries in the manifest file. * Please note that not only the various digest have to match, but the * filenames as well. If there are more or even less files listed in the * manifest file than provided by paTests, VERR_MANIFEST_FILE_MISMATCH will be * @returns iprt status code. * @param pszManifestFile Filename of the manifest file to verify. * @param paTests Array of files & SHA1 sums. * @param cTests Number of entries in paTests. * @param piFailed A index to paTests in the * VERR_MANIFEST_DIGEST_MISMATCH error case * This is analogous to function RTManifestVerify(), but calculates the SHA1 * sums of the given files itself. * @returns iprt status code. * @param pszManifestFile Filename of the manifest file to verify. * @param papszFiles Array of files to check SHA1 sums. * @param cFiles Number of entries in papszFiles. * @param piFailed A index to papszFiles in the * VERR_MANIFEST_DIGEST_MISMATCH error case * @param pfnProgressCallback optional callback for the progress indication * @param pvUser user defined pointer for the callback * Creates a manifest file for a set of files. The manifest file contains SHA1 * sums of every provided file and could be used to verify the data integrity * @returns iprt status code. * @param pszManifestFile Filename of the manifest file to create. * @param papszFiles Array of files to create SHA1 sums for. * @param cFiles Number of entries in papszFiles. * @param pfnProgressCallback optional callback for the progress indication * @param pvUser user defined pointer for the callback * Verify the given SHA1 digests against the entries in the manifest file in * @returns iprt status code. * @param pvBuf Pointer to memory buffer of the manifest file. * @param cbSize Size of the memory buffer. * @param paTests Array of file names and digests. * @param cTest Number of entries in paTests. * @param piFailed A index to paTests in the * VERR_MANIFEST_DIGEST_MISMATCH error case * Creates a manifest file in memory for a set of files. The manifest file * contains SHA1 sums of every provided file and could be used to verify the * data integrity of them. * @returns iprt status code. * @param ppvBuf Pointer to resulting memory buffer. * @param pcbSize Pointer for the size of the memory buffer. * @param paFiles Array of file names and digests. * @param cFiles Number of entries in paFiles.