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 |
|
---|
32 | RT_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 | */
|
---|
43 | typedef 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. */
|
---|
51 | typedef RTMANIFESTTEST* PRTMANIFESTTEST;
|
---|
52 |
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Verify the given SHA1 digests against the entries in the manifest file.
|
---|
56 | *
|
---|
57 | * Please note that not only the various digest have to match, but the
|
---|
58 | * filenames as well. If there are more or even less files listed in the
|
---|
59 | * manifest file than provided by paTests, VERR_MANIFEST_FILE_MISMATCH will be
|
---|
60 | * returned.
|
---|
61 | *
|
---|
62 | * @returns iprt status code.
|
---|
63 | *
|
---|
64 | * @param pszManifestFile Filename of the manifest file to verify.
|
---|
65 | * @param paTests Array of files & SHA1 sums.
|
---|
66 | * @param cTests Number of entries in paTests.
|
---|
67 | * @param piFailed A index to paTests in the
|
---|
68 | * VERR_MANIFEST_DIGEST_MISMATCH error case
|
---|
69 | * (optional).
|
---|
70 | */
|
---|
71 | RTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * This is analogous to function RTManifestVerify(), but calculates the SHA1
|
---|
75 | * sums of the given files itself.
|
---|
76 | *
|
---|
77 | * @returns iprt status code.
|
---|
78 | *
|
---|
79 | * @param pszManifestFile Filename of the manifest file to verify.
|
---|
80 | * @param papszFiles Array of files to check SHA1 sums.
|
---|
81 | * @param cFiles Number of entries in papszFiles.
|
---|
82 | * @param piFailed A index to papszFiles in the
|
---|
83 | * VERR_MANIFEST_DIGEST_MISMATCH error case
|
---|
84 | * (optional).
|
---|
85 | * @param pfnProgressCallback optional callback for the progress indication
|
---|
86 | * @param pvUser user defined pointer for the callback
|
---|
87 | */
|
---|
88 | RTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *piFailed,
|
---|
89 | PFNRTPROGRESS pfnProgressCallback, void *pvUser);
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Creates a manifest file for a set of files. The manifest file contains SHA1
|
---|
93 | * sums of every provided file and could be used to verify the data integrity
|
---|
94 | * of them.
|
---|
95 | *
|
---|
96 | * @returns iprt status code.
|
---|
97 | *
|
---|
98 | * @param pszManifestFile Filename of the manifest file to create.
|
---|
99 | * @param papszFiles Array of files to create SHA1 sums for.
|
---|
100 | * @param cFiles Number of entries in papszFiles.
|
---|
101 | * @param pfnProgressCallback optional callback for the progress indication
|
---|
102 | * @param pvUser user defined pointer for the callback
|
---|
103 | */
|
---|
104 | RTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles,
|
---|
105 | PFNRTPROGRESS pfnProgressCallback, void *pvUser);
|
---|
106 |
|
---|
107 | /** @} */
|
---|
108 |
|
---|
109 | RT_C_DECLS_END
|
---|
110 |
|
---|
111 | #endif
|
---|
112 |
|
---|