[21742] | 1 | /** @file
|
---|
| 2 | * IPRT - Manifest file handling.
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
[98103] | 6 | * Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
[21742] | 7 | *
|
---|
[96407] | 8 | * This file is part of VirtualBox base platform packages, as
|
---|
| 9 | * available from https://www.virtualbox.org.
|
---|
[21742] | 10 | *
|
---|
[96407] | 11 | * This program is free software; you can redistribute it and/or
|
---|
| 12 | * modify it under the terms of the GNU General Public License
|
---|
| 13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 14 | * License.
|
---|
| 15 | *
|
---|
| 16 | * This program is distributed in the hope that it will be useful, but
|
---|
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 19 | * General Public License for more details.
|
---|
| 20 | *
|
---|
| 21 | * You should have received a copy of the GNU General Public License
|
---|
| 22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 23 | *
|
---|
[21742] | 24 | * The contents of this file may alternatively be used under the terms
|
---|
| 25 | * of the Common Development and Distribution License Version 1.0
|
---|
[96407] | 26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
| 27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
[21742] | 28 | * CDDL are applicable instead of those of the GPL.
|
---|
| 29 | *
|
---|
| 30 | * You may elect to license modified versions of this file under the
|
---|
| 31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
[96407] | 32 | *
|
---|
| 33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
[21742] | 34 | */
|
---|
| 35 |
|
---|
[76557] | 36 | #ifndef IPRT_INCLUDED_manifest_h
|
---|
| 37 | #define IPRT_INCLUDED_manifest_h
|
---|
[76507] | 38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 39 | # pragma once
|
---|
| 40 | #endif
|
---|
[21742] | 41 |
|
---|
| 42 | #include <iprt/cdefs.h>
|
---|
| 43 | #include <iprt/types.h>
|
---|
| 44 |
|
---|
| 45 | RT_C_DECLS_BEGIN
|
---|
| 46 |
|
---|
[21754] | 47 | /** @defgroup grp_rt_manifest RTManifest - Manifest file creation and checking
|
---|
[21742] | 48 | * @ingroup grp_rt
|
---|
| 49 | * @{
|
---|
| 50 | */
|
---|
| 51 |
|
---|
[34381] | 52 | /** @name Manifest attribute types.
|
---|
| 53 | * The types can be ORed together to form a set.
|
---|
| 54 | * @{ */
|
---|
| 55 | /** For use with other attributes. Representation unknown. */
|
---|
| 56 | #define RTMANIFEST_ATTR_UNKNOWN 0
|
---|
| 57 | /** The size of the content. Represented as a decimal number. */
|
---|
| 58 | #define RTMANIFEST_ATTR_SIZE RT_BIT_32(0)
|
---|
| 59 | /** The MD5 of the content. Represented as a hex string. */
|
---|
| 60 | #define RTMANIFEST_ATTR_MD5 RT_BIT_32(1)
|
---|
| 61 | /** The SHA-1 of the content. Represented as a hex string. */
|
---|
| 62 | #define RTMANIFEST_ATTR_SHA1 RT_BIT_32(2)
|
---|
| 63 | /** The SHA-256 of the content. Represented as a hex string. */
|
---|
| 64 | #define RTMANIFEST_ATTR_SHA256 RT_BIT_32(3)
|
---|
| 65 | /** The SHA-512 of the content. Represented as a hex string. */
|
---|
| 66 | #define RTMANIFEST_ATTR_SHA512 RT_BIT_32(4)
|
---|
| 67 | /** The end of the valid values. */
|
---|
| 68 | #define RTMANIFEST_ATTR_END RT_BIT_32(5)
|
---|
[39877] | 69 | /** Wildcard for use in queries. */
|
---|
| 70 | #define RTMANIFEST_ATTR_ANY UINT32_C(0xffffffff)
|
---|
[34381] | 71 | /** @} */
|
---|
| 72 |
|
---|
| 73 |
|
---|
[21742] | 74 | /**
|
---|
[34381] | 75 | * Creates an empty manifest.
|
---|
| 76 | *
|
---|
| 77 | * @returns IPRT status code.
|
---|
| 78 | * @param fFlags Flags, MBZ.
|
---|
| 79 | * @param phManifest Where to return the handle to the manifest.
|
---|
| 80 | */
|
---|
| 81 | RTDECL(int) RTManifestCreate(uint32_t fFlags, PRTMANIFEST phManifest);
|
---|
| 82 |
|
---|
| 83 | /**
|
---|
| 84 | * Retains a reference to the manifest handle.
|
---|
| 85 | *
|
---|
| 86 | * @returns The new reference count, UINT32_MAX if the handle is invalid.
|
---|
| 87 | * @param hManifest The handle to retain.
|
---|
| 88 | */
|
---|
| 89 | RTDECL(uint32_t) RTManifestRetain(RTMANIFEST hManifest);
|
---|
| 90 |
|
---|
| 91 | /**
|
---|
| 92 | * Releases a reference to the manifest handle.
|
---|
| 93 | *
|
---|
| 94 | * @returns The new reference count, 0 if free. UINT32_MAX is returned if the
|
---|
| 95 | * handle is invalid.
|
---|
| 96 | * @param hManifest The handle to release.
|
---|
| 97 | * NIL is quietly ignored (returns 0).
|
---|
| 98 | */
|
---|
| 99 | RTDECL(uint32_t) RTManifestRelease(RTMANIFEST hManifest);
|
---|
| 100 |
|
---|
| 101 | /**
|
---|
| 102 | * Creates a duplicate of the specified manifest.
|
---|
| 103 | *
|
---|
| 104 | * @returns IPRT status code
|
---|
| 105 | * @param hManifestSrc The manifest to clone.
|
---|
| 106 | * @param phManifestDst Where to store the handle to the duplicate.
|
---|
| 107 | */
|
---|
| 108 | RTDECL(int) RTManifestDup(RTMANIFEST hManifestSrc, PRTMANIFEST phManifestDst);
|
---|
| 109 |
|
---|
| 110 | /**
|
---|
| 111 | * Compares two manifests for equality.
|
---|
| 112 | *
|
---|
[34418] | 113 | * @returns IPRT status code.
|
---|
| 114 | * @retval VINF_SUCCESS if equal.
|
---|
| 115 | * @retval VERR_NOT_EQUAL if not equal.
|
---|
| 116 | *
|
---|
[34381] | 117 | * @param hManifest1 The first manifest.
|
---|
| 118 | * @param hManifest2 The second manifest.
|
---|
| 119 | * @param papszIgnoreEntries Entries to ignore. Ends with a NULL entry.
|
---|
| 120 | * @param papszIgnoreAttrs Attributes to ignore. Ends with a NULL entry.
|
---|
[34535] | 121 | * @param fFlags A combination of RTMANIFEST_EQUALS_XXX values.
|
---|
| 122 | * @param pszError Where to store the name of the mismatching
|
---|
[34418] | 123 | * entry, or as much of the name as there is room
|
---|
| 124 | * for. This is always set. Optional.
|
---|
[34535] | 125 | * @param cbError The size of the buffer pointed to by @a
|
---|
| 126 | * pszError.
|
---|
[34381] | 127 | */
|
---|
| 128 | RTDECL(int) RTManifestEqualsEx(RTMANIFEST hManifest1, RTMANIFEST hManifest2, const char * const *papszIgnoreEntries,
|
---|
[57926] | 129 | const char * const *papszIgnoreAttrs, uint32_t fFlags, char *pszError, size_t cbError);
|
---|
[34381] | 130 |
|
---|
[34535] | 131 | /** @defgroup RTMANIFEST_EQUALS_XXX RTManifestEqualsEx flags
|
---|
| 132 | * @{ */
|
---|
| 133 | /** Ignore missing attributes if there is one or more to compare. */
|
---|
| 134 | #define RTMANIFEST_EQUALS_IGN_MISSING_ATTRS RT_BIT_32(0)
|
---|
| 135 | /** Ignore attributes missing in the 1st manifest.
|
---|
| 136 | * @todo implement this */
|
---|
| 137 | #define RTMANIFEST_EQUALS_IGN_MISSING_ATTRS_1ST RT_BIT_32(1)
|
---|
[68918] | 138 | /** Ignore missing entries in the 2nd manifest. */
|
---|
| 139 | #define RTMANIFEST_EQUALS_IGN_MISSING_ENTRIES_2ND RT_BIT_32(2)
|
---|
[34535] | 140 | /** Mask of valid flags. */
|
---|
[68918] | 141 | #define RTMANIFEST_EQUALS_VALID_MASK UINT32_C(0x00000005)
|
---|
[34535] | 142 | /** @} */
|
---|
| 143 |
|
---|
[34381] | 144 | /**
|
---|
| 145 | * Compares two manifests for equality.
|
---|
| 146 | *
|
---|
[34418] | 147 | * @returns IPRT status code.
|
---|
| 148 | * @retval VINF_SUCCESS if equal.
|
---|
| 149 | * @retval VERR_NOT_EQUAL if not equal.
|
---|
| 150 | *
|
---|
[34381] | 151 | * @param hManifest1 The first manifest.
|
---|
| 152 | * @param hManifest2 The second manifest.
|
---|
| 153 | */
|
---|
| 154 | RTDECL(int) RTManifestEquals(RTMANIFEST hManifest1, RTMANIFEST hManifest2);
|
---|
| 155 |
|
---|
| 156 | /**
|
---|
[59575] | 157 | *
|
---|
| 158 | * @returns IPRT status code.
|
---|
| 159 | * @param hManifest Handle to the manifest.
|
---|
| 160 | * @param fEntriesOnly Whether to only gather attribute types from the
|
---|
| 161 | * entries (@c true), or also include the manifest
|
---|
| 162 | * attributes (@c false).
|
---|
| 163 | * @param pfTypes Where to return the attributes.
|
---|
| 164 | */
|
---|
| 165 | RTDECL(int) RTManifestQueryAllAttrTypes(RTMANIFEST hManifest, bool fEntriesOnly, uint32_t *pfTypes);
|
---|
| 166 |
|
---|
| 167 | /**
|
---|
[34381] | 168 | * Sets a manifest attribute.
|
---|
| 169 | *
|
---|
| 170 | * @returns IPRT status code.
|
---|
[59567] | 171 | * @param hManifest The manifest handle.
|
---|
| 172 | * @param pszAttr The attribute name, if NULL it will be termined from @a
|
---|
| 173 | * fType gives it. If this already exists, its value will
|
---|
| 174 | * be replaced.
|
---|
| 175 | * @param pszValue The value string.
|
---|
| 176 | * @param fType The attribute type. If not know, pass
|
---|
| 177 | * RTMANIFEST_ATTR_UNKNOWN with a valid attribute
|
---|
| 178 | * name string (@a pszAttr).
|
---|
[34381] | 179 | */
|
---|
| 180 | RTDECL(int) RTManifestSetAttr(RTMANIFEST hManifest, const char *pszAttr, const char *pszValue, uint32_t fType);
|
---|
| 181 |
|
---|
| 182 | /**
|
---|
| 183 | * Unsets (removes) a manifest attribute if it exists.
|
---|
| 184 | *
|
---|
| 185 | * @returns IPRT status code.
|
---|
| 186 | * @retval VWRN_NOT_FOUND if not found.
|
---|
| 187 | *
|
---|
| 188 | * @param hManifest The manifest handle.
|
---|
| 189 | * @param pszAttr The attribute name.
|
---|
| 190 | */
|
---|
| 191 | RTDECL(int) RTManifestUnsetAttr(RTMANIFEST hManifest, const char *pszAttr);
|
---|
| 192 |
|
---|
| 193 | /**
|
---|
[57926] | 194 | * Query a manifest attribute.
|
---|
[39877] | 195 | *
|
---|
| 196 | * @returns IPRT status code.
|
---|
| 197 | * @retval VERR_BUFFER_OVERFLOW if the value buffer is too small. The @a
|
---|
| 198 | * pszValue buffer will not be modified.
|
---|
| 199 | * @retval VERR_MANIFEST_ATTR_NOT_FOUND
|
---|
| 200 | * @retval VERR_MANIFEST_ATTR_TYPE_NOT_FOUND
|
---|
| 201 | * @retval VERR_MANIFEST_ATTR_TYPE_MISMATCH
|
---|
| 202 | *
|
---|
| 203 | * @param hManifest The manifest handle.
|
---|
| 204 | * @param pszAttr The attribute name. If NULL, it will be
|
---|
| 205 | * selected by @a fType alone.
|
---|
| 206 | * @param fType The attribute types the entry should match. Pass
|
---|
| 207 | * Pass RTMANIFEST_ATTR_ANY match any. If more
|
---|
| 208 | * than one is given, the first matching one is
|
---|
| 209 | * returned.
|
---|
| 210 | * @param pszValue Where to return value.
|
---|
| 211 | * @param cbValue The size of the buffer @a pszValue points to.
|
---|
| 212 | * @param pfType Where to return the attribute type value.
|
---|
| 213 | */
|
---|
| 214 | RTDECL(int) RTManifestQueryAttr(RTMANIFEST hManifest, const char *pszAttr, uint32_t fType,
|
---|
| 215 | char *pszValue, size_t cbValue, uint32_t *pfType);
|
---|
| 216 |
|
---|
| 217 | /**
|
---|
[34381] | 218 | * Sets an attribute of a manifest entry.
|
---|
| 219 | *
|
---|
| 220 | * @returns IPRT status code.
|
---|
[59567] | 221 | * @param hManifest The manifest handle.
|
---|
| 222 | * @param pszEntry The entry name. This will automatically be
|
---|
| 223 | * added if there was no previous call to
|
---|
| 224 | * RTManifestEntryAdd for this name. See
|
---|
| 225 | * RTManifestEntryAdd for the entry name rules.
|
---|
| 226 | * @param pszAttr The attribute name, if NULL it will be termined from @a
|
---|
| 227 | * fType gives it. If this already exists, its value will
|
---|
| 228 | * be replaced.
|
---|
| 229 | * @param pszValue The value string.
|
---|
| 230 | * @param fType The attribute type. If not know, pass
|
---|
| 231 | * RTMANIFEST_ATTR_UNKNOWN with a valid attribute
|
---|
| 232 | * name string (@a pszAttr).
|
---|
[34381] | 233 | */
|
---|
| 234 | RTDECL(int) RTManifestEntrySetAttr(RTMANIFEST hManifest, const char *pszEntry, const char *pszAttr,
|
---|
| 235 | const char *pszValue, uint32_t fType);
|
---|
| 236 |
|
---|
| 237 | /**
|
---|
| 238 | * Unsets (removes) an attribute of a manifest entry if they both exist.
|
---|
| 239 | *
|
---|
| 240 | * @returns IPRT status code.
|
---|
| 241 | * @retval VWRN_NOT_FOUND if not found.
|
---|
| 242 | *
|
---|
| 243 | * @param hManifest The manifest handle.
|
---|
| 244 | * @param pszEntry The entry name.
|
---|
| 245 | * @param pszAttr The attribute name.
|
---|
| 246 | */
|
---|
| 247 | RTDECL(int) RTManifestEntryUnsetAttr(RTMANIFEST hManifest, const char *pszEntry, const char *pszAttr);
|
---|
| 248 |
|
---|
| 249 | /**
|
---|
[39877] | 250 | * Query a manifest entry attribute.
|
---|
| 251 | *
|
---|
| 252 | * @returns IPRT status code.
|
---|
| 253 | * @retval VERR_BUFFER_OVERFLOW if the value buffer is too small. The @a
|
---|
| 254 | * pszValue buffer will not be modified.
|
---|
| 255 | * @retval VERR_NOT_FOUND if the entry was not found.
|
---|
| 256 | * @retval VERR_MANIFEST_ATTR_NOT_FOUND
|
---|
| 257 | * @retval VERR_MANIFEST_ATTR_TYPE_NOT_FOUND
|
---|
| 258 | * @retval VERR_MANIFEST_ATTR_TYPE_MISMATCH
|
---|
| 259 | *
|
---|
| 260 | * @param hManifest The manifest handle.
|
---|
| 261 | * @param pszEntry The entry name.
|
---|
| 262 | * @param pszAttr The attribute name. If NULL, it will be
|
---|
| 263 | * selected by @a fType alone.
|
---|
| 264 | * @param fType The attribute types the entry should match. Pass
|
---|
| 265 | * Pass RTMANIFEST_ATTR_ANY match any. If more
|
---|
| 266 | * than one is given, the first matching one is
|
---|
| 267 | * returned.
|
---|
| 268 | * @param pszValue Where to return value.
|
---|
| 269 | * @param cbValue The size of the buffer @a pszValue points to.
|
---|
| 270 | * @param pfType Where to return the attribute type value.
|
---|
| 271 | */
|
---|
| 272 | RTDECL(int) RTManifestEntryQueryAttr(RTMANIFEST hManifest, const char *pszEntry, const char *pszAttr, uint32_t fType,
|
---|
| 273 | char *pszValue, size_t cbValue, uint32_t *pfType);
|
---|
| 274 |
|
---|
| 275 | /**
|
---|
[34381] | 276 | * Adds a new entry to a manifest.
|
---|
| 277 | *
|
---|
| 278 | * The entry name rules:
|
---|
| 279 | * - The entry name can contain any character defined by unicode, except
|
---|
| 280 | * control characters, ':', '(' and ')'. The exceptions are mainly there
|
---|
| 281 | * because of uncertainty around how various formats handles these.
|
---|
| 282 | * - It is considered case sensitive.
|
---|
| 283 | * - Forward (unix) and backward (dos) slashes are considered path
|
---|
| 284 | * separators and converted to forward slashes.
|
---|
| 285 | *
|
---|
| 286 | * @returns IPRT status code.
|
---|
| 287 | * @retval VWRN_ALREADY_EXISTS if the entry already exists.
|
---|
| 288 | *
|
---|
| 289 | * @param hManifest The manifest handle.
|
---|
| 290 | * @param pszEntry The entry name (UTF-8).
|
---|
| 291 | *
|
---|
| 292 | * @remarks Some manifest formats will not be able to store an entry without
|
---|
| 293 | * any attributes. So, this is just here in case it comes in handy
|
---|
| 294 | * when dealing with formats which can.
|
---|
| 295 | */
|
---|
| 296 | RTDECL(int) RTManifestEntryAdd(RTMANIFEST hManifest, const char *pszEntry);
|
---|
| 297 |
|
---|
| 298 | /**
|
---|
| 299 | * Removes an entry.
|
---|
| 300 | *
|
---|
| 301 | * @returns IPRT status code.
|
---|
| 302 | * @param hManifest The manifest handle.
|
---|
| 303 | * @param pszEntry The entry name.
|
---|
| 304 | */
|
---|
| 305 | RTDECL(int) RTManifestEntryRemove(RTMANIFEST hManifest, const char *pszEntry);
|
---|
| 306 |
|
---|
[34435] | 307 | /**
|
---|
| 308 | * Add an entry for an I/O stream using a passthru stream.
|
---|
| 309 | *
|
---|
| 310 | * The passthru I/O stream will hash all the data read from or written to the
|
---|
| 311 | * stream and automatically add an entry to the manifest with the desired
|
---|
| 312 | * attributes when it is released. Alternatively one can call
|
---|
| 313 | * RTManifestPtIosAddEntryNow() to have more control over exactly when this
|
---|
| 314 | * action is performed and which status it yields.
|
---|
| 315 | *
|
---|
| 316 | * @returns IPRT status code.
|
---|
| 317 | * @param hManifest The manifest to add the entry to.
|
---|
| 318 | * @param hVfsIos The I/O stream to pass thru to/from.
|
---|
| 319 | * @param pszEntry The entry name.
|
---|
| 320 | * @param fAttrs The attributes to create for this stream.
|
---|
| 321 | * @param fReadOrWrite Whether it's a read or write I/O stream.
|
---|
| 322 | * @param phVfsIosPassthru Where to return the new handle.
|
---|
| 323 | */
|
---|
| 324 | RTDECL(int) RTManifestEntryAddPassthruIoStream(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsIos, const char *pszEntry,
|
---|
| 325 | uint32_t fAttrs, bool fReadOrWrite, PRTVFSIOSTREAM phVfsIosPassthru);
|
---|
[34381] | 326 |
|
---|
| 327 | /**
|
---|
[34435] | 328 | * Adds the entry to the manifest right now.
|
---|
| 329 | *
|
---|
| 330 | * @returns IPRT status code.
|
---|
| 331 | * @param hVfsPtIos The manifest passthru I/O stream returned by
|
---|
| 332 | * RTManifestEntryAddPassthruIoStream().
|
---|
| 333 | */
|
---|
| 334 | RTDECL(int) RTManifestPtIosAddEntryNow(RTVFSIOSTREAM hVfsPtIos);
|
---|
| 335 |
|
---|
| 336 | /**
|
---|
[59620] | 337 | * Checks if the give I/O stream is a manifest passthru instance or not.
|
---|
| 338 | *
|
---|
| 339 | * @returns true if it's a manifest passthru I/O stream, false if not.
|
---|
| 340 | * @param hVfsPtIos Possible the manifest passthru I/O stream handle.
|
---|
| 341 | */
|
---|
| 342 | RTDECL(bool) RTManifestPtIosIsInstanceOf(RTVFSIOSTREAM hVfsPtIos);
|
---|
| 343 |
|
---|
| 344 | /**
|
---|
[34381] | 345 | * Adds an entry for a file with the specified set of attributes.
|
---|
| 346 | *
|
---|
| 347 | * @returns IPRT status code.
|
---|
| 348 | *
|
---|
| 349 | * @param hManifest The manifest handle.
|
---|
| 350 | * @param hVfsIos The I/O stream handle of the entry. This will
|
---|
| 351 | * be processed to its end on successful return.
|
---|
| 352 | * (Must be positioned at the start to get
|
---|
| 353 | * the expected results.)
|
---|
| 354 | * @param pszEntry The entry name.
|
---|
[34391] | 355 | * @param fAttrs The attributes to create for this stream. See
|
---|
| 356 | * RTMANIFEST_ATTR_XXX.
|
---|
[34381] | 357 | */
|
---|
| 358 | RTDECL(int) RTManifestEntryAddIoStream(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsIos, const char *pszEntry, uint32_t fAttrs);
|
---|
| 359 |
|
---|
| 360 | /**
|
---|
[34845] | 361 | * Checks if there is a manifest entry by the given name.
|
---|
| 362 | *
|
---|
| 363 | * @returns true if there is, false if not or if the handle is invalid.
|
---|
| 364 | * @param hManifest The manifest handle.
|
---|
| 365 | * @param pszEntry The entry name.
|
---|
| 366 | */
|
---|
| 367 | RTDECL(bool) RTManifestEntryExists(RTMANIFEST hManifest, const char *pszEntry);
|
---|
| 368 |
|
---|
| 369 | /**
|
---|
[34381] | 370 | * Reads in a "standard" manifest.
|
---|
| 371 | *
|
---|
| 372 | * This reads the format used by OVF, the distinfo in FreeBSD ports, and
|
---|
| 373 | * others.
|
---|
| 374 | *
|
---|
| 375 | * @returns IPRT status code.
|
---|
| 376 | * @param hManifest The handle to the manifest where to add the
|
---|
| 377 | * manifest that's read in.
|
---|
| 378 | * @param hVfsIos The I/O stream to read the manifest from.
|
---|
| 379 | */
|
---|
| 380 | RTDECL(int) RTManifestReadStandard(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsIos);
|
---|
| 381 |
|
---|
| 382 | /**
|
---|
[34449] | 383 | * Reads in a "standard" manifest.
|
---|
| 384 | *
|
---|
| 385 | * This reads the format used by OVF, the distinfo in FreeBSD ports, and
|
---|
| 386 | * others.
|
---|
| 387 | *
|
---|
| 388 | * @returns IPRT status code.
|
---|
| 389 | * @param hManifest The handle to the manifest where to add the
|
---|
| 390 | * manifest that's read in.
|
---|
| 391 | * @param hVfsIos The I/O stream to read the manifest from.
|
---|
| 392 | * @param pszErr Where to return extended error info on failure.
|
---|
| 393 | * Optional.
|
---|
| 394 | * @param cbErr The size of the buffer @a pszErr points to.
|
---|
| 395 | */
|
---|
| 396 | RTDECL(int) RTManifestReadStandardEx(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsIos, char *pszErr, size_t cbErr);
|
---|
| 397 |
|
---|
| 398 | /**
|
---|
[36555] | 399 | * Reads in a "standard" manifest from the specified file.
|
---|
| 400 | *
|
---|
| 401 | * This reads the format used by OVF, the distinfo in FreeBSD ports, and
|
---|
| 402 | * others.
|
---|
| 403 | *
|
---|
| 404 | * @returns IPRT status code.
|
---|
| 405 | * @param hManifest The handle to the manifest where to add the
|
---|
| 406 | * manifest that's read in.
|
---|
| 407 | * @param pszFilename The name of the file to read in.
|
---|
| 408 | */
|
---|
| 409 | RTDECL(int) RTManifestReadStandardFromFile(RTMANIFEST hManifest, const char *pszFilename);
|
---|
| 410 |
|
---|
| 411 | /**
|
---|
[34381] | 412 | * Writes a "standard" manifest.
|
---|
| 413 | *
|
---|
| 414 | * This writes the format used by OVF, the distinfo in FreeBSD ports, and
|
---|
| 415 | * others.
|
---|
| 416 | *
|
---|
| 417 | * @returns IPRT status code.
|
---|
[36555] | 418 | * @param hManifest The handle to the manifest to write.
|
---|
[34381] | 419 | * @param hVfsIos The I/O stream to read the manifest from.
|
---|
| 420 | */
|
---|
| 421 | RTDECL(int) RTManifestWriteStandard(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsIos);
|
---|
| 422 |
|
---|
[36555] | 423 | /**
|
---|
| 424 | * Writes a "standard" manifest to the specified file.
|
---|
| 425 | *
|
---|
| 426 | * @returns IPRT status code.
|
---|
| 427 | * @param hManifest The handle to the manifest to write.
|
---|
| 428 | * @param pszFilename The name of the file.
|
---|
| 429 | */
|
---|
| 430 | RTDECL(int) RTManifestWriteStandardToFile(RTMANIFEST hManifest, const char *pszFilename);
|
---|
[34381] | 431 |
|
---|
| 432 |
|
---|
| 433 |
|
---|
| 434 |
|
---|
[36555] | 435 |
|
---|
[34381] | 436 | /**
|
---|
[21754] | 437 | * Input structure for RTManifestVerify() which contains the filename & the
|
---|
[40329] | 438 | * SHA1/SHA256 digest.
|
---|
[21742] | 439 | */
|
---|
| 440 | typedef struct RTMANIFESTTEST
|
---|
| 441 | {
|
---|
[21754] | 442 | /** The filename. */
|
---|
[33289] | 443 | const char *pszTestFile;
|
---|
[40329] | 444 | /** The SHA1/SHA256 digest of the file. */
|
---|
[33289] | 445 | const char *pszTestDigest;
|
---|
[21742] | 446 | } RTMANIFESTTEST;
|
---|
| 447 | /** Pointer to the input structure. */
|
---|
| 448 | typedef RTMANIFESTTEST* PRTMANIFESTTEST;
|
---|
| 449 |
|
---|
[29901] | 450 |
|
---|
| 451 | /**
|
---|
[21756] | 452 | * Verify the given SHA1 digests against the entries in the manifest file.
|
---|
[21742] | 453 | *
|
---|
[21754] | 454 | * Please note that not only the various digest have to match, but the
|
---|
| 455 | * filenames as well. If there are more or even less files listed in the
|
---|
| 456 | * manifest file than provided by paTests, VERR_MANIFEST_FILE_MISMATCH will be
|
---|
| 457 | * returned.
|
---|
[21742] | 458 | *
|
---|
[21757] | 459 | * @returns iprt status code.
|
---|
[21742] | 460 | *
|
---|
| 461 | * @param pszManifestFile Filename of the manifest file to verify.
|
---|
[21754] | 462 | * @param paTests Array of files & SHA1 sums.
|
---|
| 463 | * @param cTests Number of entries in paTests.
|
---|
| 464 | * @param piFailed A index to paTests in the
|
---|
[21742] | 465 | * VERR_MANIFEST_DIGEST_MISMATCH error case
|
---|
| 466 | * (optional).
|
---|
[46980] | 467 | * @deprecated Use the RTMANIFEST based API instead.
|
---|
[21742] | 468 | */
|
---|
[21754] | 469 | RTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
|
---|
[21742] | 470 |
|
---|
| 471 | /**
|
---|
[21754] | 472 | * This is analogous to function RTManifestVerify(), but calculates the SHA1
|
---|
| 473 | * sums of the given files itself.
|
---|
[21742] | 474 | *
|
---|
[21757] | 475 | * @returns iprt status code.
|
---|
[21742] | 476 | *
|
---|
| 477 | * @param pszManifestFile Filename of the manifest file to verify.
|
---|
[21754] | 478 | * @param papszFiles Array of files to check SHA1 sums.
|
---|
[21756] | 479 | * @param cFiles Number of entries in papszFiles.
|
---|
| 480 | * @param piFailed A index to papszFiles in the
|
---|
[21742] | 481 | * VERR_MANIFEST_DIGEST_MISMATCH error case
|
---|
| 482 | * (optional).
|
---|
[29901] | 483 | * @param pfnProgressCallback optional callback for the progress indication
|
---|
| 484 | * @param pvUser user defined pointer for the callback
|
---|
[46980] | 485 | * @deprecated Use the RTMANIFEST based API instead.
|
---|
[21742] | 486 | */
|
---|
[30079] | 487 | RTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *piFailed,
|
---|
| 488 | PFNRTPROGRESS pfnProgressCallback, void *pvUser);
|
---|
[21742] | 489 |
|
---|
| 490 | /**
|
---|
| 491 | * Creates a manifest file for a set of files. The manifest file contains SHA1
|
---|
| 492 | * sums of every provided file and could be used to verify the data integrity
|
---|
| 493 | * of them.
|
---|
| 494 | *
|
---|
[21757] | 495 | * @returns iprt status code.
|
---|
[21742] | 496 | *
|
---|
| 497 | * @param pszManifestFile Filename of the manifest file to create.
|
---|
[40329] | 498 | * @param enmDigestType The digest type (RTDIGESTTYPE_*)
|
---|
[21754] | 499 | * @param papszFiles Array of files to create SHA1 sums for.
|
---|
| 500 | * @param cFiles Number of entries in papszFiles.
|
---|
[29901] | 501 | * @param pfnProgressCallback optional callback for the progress indication
|
---|
| 502 | * @param pvUser user defined pointer for the callback
|
---|
[46980] | 503 | * @deprecated Use the RTMANIFEST based API instead.
|
---|
[21742] | 504 | */
|
---|
[40329] | 505 | RTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, RTDIGESTTYPE enmDigestType,
|
---|
| 506 | const char * const *papszFiles, size_t cFiles,
|
---|
[30079] | 507 | PFNRTPROGRESS pfnProgressCallback, void *pvUser);
|
---|
[21742] | 508 |
|
---|
[33057] | 509 | /**
|
---|
[46980] | 510 | * Queries the first digest type found in the given manifest.
|
---|
[45227] | 511 | *
|
---|
| 512 | * @returns iprt status code.
|
---|
| 513 | *
|
---|
| 514 | * @param pvBuf Pointer to memory buffer of the manifest file.
|
---|
| 515 | * @param cbSize Size of the memory buffer.
|
---|
[48934] | 516 | * @param penmDigestType Where to return the first digest type found in
|
---|
[46980] | 517 | * the manifest.
|
---|
| 518 | * @deprecated Use the RTMANIFEST based API instead.
|
---|
[45227] | 519 | */
|
---|
[46980] | 520 | RTR3DECL(int) RTManifestVerifyDigestType(void const *pvBuf, size_t cbSize, RTDIGESTTYPE *penmDigestType);
|
---|
[45227] | 521 |
|
---|
| 522 | /**
|
---|
[33289] | 523 | * Verify the given SHA1 digests against the entries in the manifest file in
|
---|
| 524 | * memory.
|
---|
| 525 | *
|
---|
| 526 | * @returns iprt status code.
|
---|
| 527 | *
|
---|
| 528 | * @param pvBuf Pointer to memory buffer of the manifest file.
|
---|
| 529 | * @param cbSize Size of the memory buffer.
|
---|
| 530 | * @param paTests Array of file names and digests.
|
---|
[57926] | 531 | * @param cTests Number of entries in paTests.
|
---|
[33289] | 532 | * @param piFailed A index to paTests in the
|
---|
| 533 | * VERR_MANIFEST_DIGEST_MISMATCH error case
|
---|
| 534 | * (optional).
|
---|
[46980] | 535 | * @deprecated Use the RTMANIFEST based API instead.
|
---|
[33289] | 536 | */
|
---|
| 537 | RTR3DECL(int) RTManifestVerifyFilesBuf(void *pvBuf, size_t cbSize, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
|
---|
| 538 |
|
---|
| 539 | /**
|
---|
[33057] | 540 | * Creates a manifest file in memory for a set of files. The manifest file
|
---|
| 541 | * contains SHA1 sums of every provided file and could be used to verify the
|
---|
| 542 | * data integrity of them.
|
---|
| 543 | *
|
---|
| 544 | * @returns iprt status code.
|
---|
| 545 | *
|
---|
| 546 | * @param ppvBuf Pointer to resulting memory buffer.
|
---|
| 547 | * @param pcbSize Pointer for the size of the memory buffer.
|
---|
[40329] | 548 | * @param enmDigestType Which type of digest ("SHA1", "SHA256", ...)
|
---|
[33289] | 549 | * @param paFiles Array of file names and digests.
|
---|
| 550 | * @param cFiles Number of entries in paFiles.
|
---|
[46980] | 551 | * @deprecated Use the RTMANIFEST based API instead.
|
---|
[33057] | 552 | */
|
---|
[40329] | 553 | RTR3DECL(int) RTManifestWriteFilesBuf(void **ppvBuf, size_t *pcbSize, RTDIGESTTYPE enmDigestType, PRTMANIFESTTEST paFiles, size_t cFiles);
|
---|
[33057] | 554 |
|
---|
[21742] | 555 | /** @} */
|
---|
| 556 |
|
---|
| 557 | RT_C_DECLS_END
|
---|
| 558 |
|
---|
[76585] | 559 | #endif /* !IPRT_INCLUDED_manifest_h */
|
---|
[21742] | 560 |
|
---|