manifest.h revision 7f04ee3001f2049e136709d4f807af40a4538bbd
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync/** @file
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * IPRT - Manifest file handling.
fa11a1e5d812c442cfc865cfdcf9934074d35b7fvboxsync */
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync/*
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync *
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * available from http://www.virtualbox.org. This file is free software;
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * General Public License (GPL) as published by the Free Software
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * The contents of this file may alternatively be used under the terms
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * of the Common Development and Distribution License Version 1.0
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * VirtualBox OSE distribution, in which case the provisions of the
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * CDDL are applicable instead of those of the GPL.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * You may elect to license modified versions of this file under the
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * terms and conditions of either the GPL or the CDDL or both.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * additional information or have any questions.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync */
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync#ifndef ___iprt_manifest_h
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync#define ___iprt_manifest_h
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync#include <iprt/cdefs.h>
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync#include <iprt/types.h>
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsyncRT_C_DECLS_BEGIN
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync/** @group grp_rt_manifest RTManifest - Manifest file creation and checking.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @ingroup grp_rt
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @{
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync */
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync/**
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * Input structure for RTManifestVerify which contains the filename & the SHA1
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * digest.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync */
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsynctypedef struct RTMANIFESTTEST
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync{
188b39ae923237e5efe949661eeec5aa150425a0vboxsync char *pszTestFile; /** The filename */
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync char *pszTestDigest; /** The SHA1 digest of the file */
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync} RTMANIFESTTEST;
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync/** Pointer to the input structure. */
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsynctypedef RTMANIFESTTEST* PRTMANIFESTTEST;
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync/**
40788f70a2bd319d0d36dfbe7b73c0e9c364d87dvboxsync * Verify the given SHA1 digests to the entries in the manifest file.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * Please note that not only the various digest have to much, but the filenames
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * as well. If there are more or even less files listed in the manifest file
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * than provided by pTestList, VERR_MANIFEST_FILE_MISMATCH will be returned.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @returns VBox status code.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @param pszManifestFile Filename of the manifest file to verify.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @param pTestList List of files & SHA1 sums.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @param cTests Number of entries in pTestList
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @param piFailed A index to pTestList in the
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * VERR_MANIFEST_DIGEST_MISMATCH error case
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * (optional).
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync */
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsyncRTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST pTestList, size_t cTests, size_t *piFailed);
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync/**
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * This is analogous to function RTManifestVerify, but calculates the SHA1 sums
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * of the given files itself.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @returns VBox status code.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @param pszManifestFile Filename of the manifest file to verify.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @param ppszFiles List of files to check SHA1 sums.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @param cFiles Number of entries in ppszFiles.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @param piFailed A index to ppszFiles in the
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * VERR_MANIFEST_DIGEST_MISMATCH error case
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * (optional).
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync */
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsyncRTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *piFailed);
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync/**
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * Creates a manifest file for a set of files. The manifest file contains SHA1
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * sums of every provided file and could be used to verify the data integrity
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * of them.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync * @returns VBox status code.
3cdf227bdf099f60b22215d6ea7685ec5ec64fe6vboxsync *
* @param pszManifestFile Filename of the manifest file to create.
* @param ppszFiles List of files to create SHA1 sums for.
* @param cFiles Number of entries in ppszFiles.
*/
RTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles);
/** @} */
RT_C_DECLS_END
#endif /* ___iprt_manifest_h */