1 | /** @file
|
---|
2 | * IPRT - Manifest file handling.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
26 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
27 | * additional information or have any questions.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef ___iprt_manifest_h
|
---|
31 | #define ___iprt_manifest_h
|
---|
32 |
|
---|
33 | #include <iprt/cdefs.h>
|
---|
34 | #include <iprt/types.h>
|
---|
35 |
|
---|
36 | RT_C_DECLS_BEGIN
|
---|
37 |
|
---|
38 | /** @defgroup grp_rt_manifest RTManifest - Manifest file creation and checking
|
---|
39 | * @ingroup grp_rt
|
---|
40 | * @{
|
---|
41 | */
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Input structure for RTManifestVerify() which contains the filename & the
|
---|
45 | * SHA1 digest.
|
---|
46 | */
|
---|
47 | typedef struct RTMANIFESTTEST
|
---|
48 | {
|
---|
49 | /** The filename. */
|
---|
50 | char *pszTestFile;
|
---|
51 | /** The SHA1 digest of the file. */
|
---|
52 | char *pszTestDigest;
|
---|
53 | } RTMANIFESTTEST;
|
---|
54 | /** Pointer to the input structure. */
|
---|
55 | typedef RTMANIFESTTEST* PRTMANIFESTTEST;
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Verify the given SHA1 digests against the entries in the manifest file.
|
---|
59 | *
|
---|
60 | * Please note that not only the various digest have to match, but the
|
---|
61 | * filenames as well. If there are more or even less files listed in the
|
---|
62 | * manifest file than provided by paTests, VERR_MANIFEST_FILE_MISMATCH will be
|
---|
63 | * returned.
|
---|
64 | *
|
---|
65 | * @returns iprt status code.
|
---|
66 | *
|
---|
67 | * @param pszManifestFile Filename of the manifest file to verify.
|
---|
68 | * @param paTests Array of files & SHA1 sums.
|
---|
69 | * @param cTests Number of entries in paTests.
|
---|
70 | * @param piFailed A index to paTests in the
|
---|
71 | * VERR_MANIFEST_DIGEST_MISMATCH error case
|
---|
72 | * (optional).
|
---|
73 | */
|
---|
74 | RTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * This is analogous to function RTManifestVerify(), but calculates the SHA1
|
---|
78 | * sums of the given files itself.
|
---|
79 | *
|
---|
80 | * @returns iprt status code.
|
---|
81 | *
|
---|
82 | * @param pszManifestFile Filename of the manifest file to verify.
|
---|
83 | * @param papszFiles Array of files to check SHA1 sums.
|
---|
84 | * @param cFiles Number of entries in papszFiles.
|
---|
85 | * @param piFailed A index to papszFiles in the
|
---|
86 | * VERR_MANIFEST_DIGEST_MISMATCH error case
|
---|
87 | * (optional).
|
---|
88 | */
|
---|
89 | RTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *piFailed);
|
---|
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 | */
|
---|
102 | RTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles);
|
---|
103 |
|
---|
104 | /** @} */
|
---|
105 |
|
---|
106 | RT_C_DECLS_END
|
---|
107 |
|
---|
108 | #endif /* ___iprt_manifest_h */
|
---|
109 |
|
---|