VirtualBox

source: vbox/trunk/include/iprt/manifest.h@ 30034

Last change on this file since 30034 was 29901, checked in by vboxsync, 15 years ago

IPRT: added progress callback support to SHA1 digest calculation and manifest verification

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/** @file
2 * IPRT - Manifest file handling.
3 */
4
5/*
6 * Copyright (C) 2009 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_manifest_h
27#define ___iprt_manifest_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32RT_C_DECLS_BEGIN
33
34/** @defgroup grp_rt_manifest RTManifest - Manifest file creation and checking
35 * @ingroup grp_rt
36 * @{
37 */
38
39/**
40 * Input structure for RTManifestVerify() which contains the filename & the
41 * SHA1 digest.
42 */
43typedef struct RTMANIFESTTEST
44{
45 /** The filename. */
46 char *pszTestFile;
47 /** The SHA1 digest of the file. */
48 char *pszTestDigest;
49} RTMANIFESTTEST;
50/** Pointer to the input structure. */
51typedef RTMANIFESTTEST* PRTMANIFESTTEST;
52
53/**
54 * Manifest progress callback.
55 *
56 * @returns IPRT status code.
57 *
58 * @param uPercent The progress completion percentage.
59 * @param pvUser The user defined parameter.
60 */
61typedef DECLCALLBACK(int) FNRTMANIFESTPROGRESS(unsigned uPercent, void *pvUser);
62/** Pointer to a manifest progress callback. */
63typedef FNRTMANIFESTPROGRESS *PFNRTMANIFESTPROGRESS;
64
65/**
66 * Verify the given SHA1 digests against the entries in the manifest file.
67 *
68 * Please note that not only the various digest have to match, but the
69 * filenames as well. If there are more or even less files listed in the
70 * manifest file than provided by paTests, VERR_MANIFEST_FILE_MISMATCH will be
71 * returned.
72 *
73 * @returns iprt status code.
74 *
75 * @param pszManifestFile Filename of the manifest file to verify.
76 * @param paTests Array of files & SHA1 sums.
77 * @param cTests Number of entries in paTests.
78 * @param piFailed A index to paTests in the
79 * VERR_MANIFEST_DIGEST_MISMATCH error case
80 * (optional).
81 */
82RTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
83
84/**
85 * This is analogous to function RTManifestVerify(), but calculates the SHA1
86 * sums of the given files itself.
87 *
88 * @returns iprt status code.
89 *
90 * @param pszManifestFile Filename of the manifest file to verify.
91 * @param papszFiles Array of files to check SHA1 sums.
92 * @param cFiles Number of entries in papszFiles.
93 * @param piFailed A index to papszFiles in the
94 * VERR_MANIFEST_DIGEST_MISMATCH error case
95 * (optional).
96 * @param pfnProgressCallback optional callback for the progress indication
97 * @param pvUser user defined pointer for the callback
98 */
99RTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *piFailed, PFNRTMANIFESTPROGRESS pfnProgressCallback, void *pvUser);
100
101/**
102 * Creates a manifest file for a set of files. The manifest file contains SHA1
103 * sums of every provided file and could be used to verify the data integrity
104 * of them.
105 *
106 * @returns iprt status code.
107 *
108 * @param pszManifestFile Filename of the manifest file to create.
109 * @param papszFiles Array of files to create SHA1 sums for.
110 * @param cFiles Number of entries in papszFiles.
111 * @param pfnProgressCallback optional callback for the progress indication
112 * @param pvUser user defined pointer for the callback
113 */
114RTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, PFNRTMANIFESTPROGRESS pfnProgressCallback, void *pvUser);
115
116/** @} */
117
118RT_C_DECLS_END
119
120#endif /* ___iprt_manifest_h */
121
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette