2022-05-28 12:57:21 +01:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Aaru Data Preservation Suite.
|
2025-08-01 21:19:45 +01:00
|
|
|
* Copyright (c) 2019-2025 Natalia Portillo.
|
2022-05-28 12:57:21 +01:00
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-03-01 19:53:05 +00:00
|
|
|
#ifndef LIBAARUFORMAT_CONTEXT_H
|
|
|
|
|
#define LIBAARUFORMAT_CONTEXT_H
|
2019-03-17 20:39:40 +00:00
|
|
|
|
2022-10-02 16:05:25 +01:00
|
|
|
#include "lru.h"
|
2022-05-28 12:10:04 +01:00
|
|
|
#include "structs.h"
|
|
|
|
|
|
2022-10-04 19:44:34 +01:00
|
|
|
#ifndef MD5_DIGEST_LENGTH
|
|
|
|
|
#define MD5_DIGEST_LENGTH 16
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef SHA1_DIGEST_LENGTH
|
|
|
|
|
#define SHA1_DIGEST_LENGTH 20
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef SHA256_DIGEST_LENGTH
|
|
|
|
|
#define SHA256_DIGEST_LENGTH 32
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-08-02 20:23:32 +01:00
|
|
|
typedef struct Crc64Context
|
|
|
|
|
{
|
2025-08-01 02:48:16 +01:00
|
|
|
uint64_t finalSeed;
|
|
|
|
|
uint64_t table[256];
|
|
|
|
|
uint64_t hashInt;
|
|
|
|
|
} Crc64Context;
|
|
|
|
|
|
2025-08-02 20:23:32 +01:00
|
|
|
typedef struct CdEccContext
|
|
|
|
|
{
|
|
|
|
|
bool initedEdc;
|
2025-08-04 16:31:29 +01:00
|
|
|
uint8_t * eccBTable;
|
|
|
|
|
uint8_t * eccFTable;
|
2025-08-01 02:48:16 +01:00
|
|
|
uint32_t *edcTable;
|
|
|
|
|
} CdEccContext;
|
|
|
|
|
|
2022-10-04 19:44:34 +01:00
|
|
|
typedef struct Checksums
|
|
|
|
|
{
|
|
|
|
|
bool hasMd5;
|
|
|
|
|
bool hasSha1;
|
|
|
|
|
bool hasSha256;
|
|
|
|
|
bool hasSpamSum;
|
|
|
|
|
uint8_t md5[MD5_DIGEST_LENGTH];
|
|
|
|
|
uint8_t sha1[SHA1_DIGEST_LENGTH];
|
|
|
|
|
uint8_t sha256[SHA256_DIGEST_LENGTH];
|
2024-04-30 15:51:32 +01:00
|
|
|
uint8_t *spamsum;
|
2022-10-04 19:44:34 +01:00
|
|
|
} Checksums;
|
|
|
|
|
|
2022-10-04 20:32:26 +01:00
|
|
|
typedef struct mediaTagEntry
|
|
|
|
|
{
|
2025-08-04 16:31:29 +01:00
|
|
|
uint8_t * data;
|
2022-10-04 20:32:26 +01:00
|
|
|
int32_t type;
|
|
|
|
|
uint32_t length;
|
|
|
|
|
UT_hash_handle hh;
|
|
|
|
|
} mediaTagEntry;
|
|
|
|
|
|
2020-03-01 19:51:13 +00:00
|
|
|
typedef struct aaruformatContext
|
2019-03-17 20:39:40 +00:00
|
|
|
{
|
2019-03-31 20:52:06 +01:00
|
|
|
uint64_t magic;
|
|
|
|
|
uint8_t libraryMajorVersion;
|
|
|
|
|
uint8_t libraryMinorVersion;
|
2025-08-04 16:31:29 +01:00
|
|
|
FILE * imageStream;
|
2025-08-02 20:23:32 +01:00
|
|
|
AaruHeaderV2 header;
|
2025-08-04 16:31:29 +01:00
|
|
|
uint8_t * sectorPrefix;
|
|
|
|
|
uint8_t * sectorPrefixCorrected;
|
|
|
|
|
uint8_t * sectorSuffix;
|
|
|
|
|
uint8_t * sectorSuffixCorrected;
|
|
|
|
|
uint8_t * sectorSubchannel;
|
|
|
|
|
uint8_t * mode2Subheaders;
|
2019-03-31 20:52:06 +01:00
|
|
|
uint8_t shift;
|
|
|
|
|
bool inMemoryDdt;
|
2025-08-04 16:31:29 +01:00
|
|
|
uint64_t * userDataDdt;
|
2019-03-31 20:52:06 +01:00
|
|
|
size_t mappedMemoryDdtSize;
|
2025-08-04 16:31:29 +01:00
|
|
|
uint32_t * sectorPrefixDdt;
|
|
|
|
|
uint32_t * sectorSuffixDdt;
|
2019-03-31 20:52:06 +01:00
|
|
|
GeometryBlockHeader geometryBlock;
|
|
|
|
|
MetadataBlockHeader metadataBlockHeader;
|
2025-08-04 16:31:29 +01:00
|
|
|
uint8_t * metadataBlock;
|
2019-03-31 20:52:06 +01:00
|
|
|
TracksHeader tracksHeader;
|
2025-08-04 16:31:29 +01:00
|
|
|
TrackEntry * trackEntries;
|
2019-03-31 20:52:06 +01:00
|
|
|
CicmMetadataBlock cicmBlockHeader;
|
2025-08-04 16:31:29 +01:00
|
|
|
uint8_t * cicmBlock;
|
2019-03-31 20:52:06 +01:00
|
|
|
DumpHardwareHeader dumpHardwareHeader;
|
2024-04-30 15:51:32 +01:00
|
|
|
struct DumpHardwareEntriesWithData *dumpHardwareEntriesWithData;
|
2019-03-31 20:52:06 +01:00
|
|
|
struct ImageInfo imageInfo;
|
2025-08-04 16:31:29 +01:00
|
|
|
CdEccContext * eccCdContext;
|
2019-03-31 20:52:06 +01:00
|
|
|
uint8_t numberOfDataTracks;
|
2025-08-04 16:31:29 +01:00
|
|
|
TrackEntry * dataTracks;
|
|
|
|
|
bool * readableSectorTags;
|
2022-10-02 16:05:25 +01:00
|
|
|
struct CacheHeader blockHeaderCache;
|
|
|
|
|
struct CacheHeader blockCache;
|
2022-10-04 19:44:34 +01:00
|
|
|
struct Checksums checksums;
|
2025-08-04 16:31:29 +01:00
|
|
|
struct mediaTagEntry * mediaTags;
|
|
|
|
|
DdtHeader2 userDataDdtHeader;
|
|
|
|
|
int ddtVersion;
|
2020-03-01 19:51:13 +00:00
|
|
|
} aaruformatContext;
|
2019-03-17 20:39:40 +00:00
|
|
|
|
2019-03-20 00:23:30 +00:00
|
|
|
typedef struct DumpHardwareEntriesWithData
|
|
|
|
|
{
|
2019-03-31 20:52:06 +01:00
|
|
|
DumpHardwareEntry entry;
|
2024-04-30 15:51:32 +01:00
|
|
|
struct DumpExtent *extents;
|
2025-08-04 16:31:29 +01:00
|
|
|
uint8_t * manufacturer;
|
|
|
|
|
uint8_t * model;
|
|
|
|
|
uint8_t * revision;
|
|
|
|
|
uint8_t * firmware;
|
|
|
|
|
uint8_t * serial;
|
|
|
|
|
uint8_t * softwareName;
|
|
|
|
|
uint8_t * softwareVersion;
|
|
|
|
|
uint8_t * softwareOperatingSystem;
|
2019-03-20 00:23:30 +00:00
|
|
|
} DumpHardwareEntriesWithData;
|
|
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
|
|
|
|
|
typedef struct DumpExtent
|
|
|
|
|
{
|
|
|
|
|
uint64_t start;
|
|
|
|
|
uint64_t end;
|
|
|
|
|
} DumpExtent;
|
|
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
2024-04-30 15:51:32 +01:00
|
|
|
#endif // LIBAARUFORMAT_CONTEXT_H
|