Files
libaaruformat/include/aaruformat/context.h

160 lines
5.5 KiB
C
Raw Normal View History

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
#include "crc64.h"
#include "hash_map.h"
2022-10-02 16:05:25 +01:00
#include "lru.h"
2022-05-28 12:10:04 +01:00
#include "structs.h"
#include "utarray.h"
2022-05-28 12:10:04 +01:00
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
typedef struct Crc64Context
{
2025-08-01 02:48:16 +01:00
uint64_t finalSeed;
uint64_t table[256];
uint64_t hashInt;
} Crc64Context;
typedef struct CdEccContext
{
bool inited_edc;
uint8_t *ecc_b_table;
uint8_t *ecc_f_table;
uint32_t *edc_table;
2025-08-01 02:48:16 +01:00
} 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
{
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-31 20:52:06 +01:00
uint64_t magic;
uint8_t libraryMajorVersion;
uint8_t libraryMinorVersion;
FILE *imageStream;
AaruHeaderV2 header;
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;
uint64_t *userDataDdt;
2019-03-31 20:52:06 +01:00
size_t mappedMemoryDdtSize;
uint32_t *sectorPrefixDdt;
uint32_t *sectorSuffixDdt;
2019-03-31 20:52:06 +01:00
GeometryBlockHeader geometryBlock;
MetadataBlockHeader metadataBlockHeader;
uint8_t *metadataBlock;
2019-03-31 20:52:06 +01:00
TracksHeader tracksHeader;
TrackEntry *trackEntries;
2019-03-31 20:52:06 +01:00
CicmMetadataBlock cicmBlockHeader;
uint8_t *cicmBlock;
2019-03-31 20:52:06 +01:00
DumpHardwareHeader dumpHardwareHeader;
2024-04-30 15:51:32 +01:00
struct DumpHardwareEntriesWithData *dumpHardwareEntriesWithData;
ImageInfo imageInfo;
CdEccContext *eccCdContext;
2019-03-31 20:52:06 +01:00
uint8_t numberOfDataTracks;
TrackEntry *dataTracks;
bool *readableSectorTags;
2022-10-02 16:05:25 +01:00
struct CacheHeader blockHeaderCache;
struct CacheHeader blockCache;
Checksums checksums;
mediaTagEntry *mediaTags;
2025-08-04 16:31:29 +01:00
DdtHeader2 userDataDdtHeader;
int ddtVersion;
uint16_t *userDataDdtMini;
uint32_t *userDataDdtBig;
uint16_t *sectorPrefixDdtMini;
uint16_t *sectorSuffixDdtMini;
uint64_t cachedDdtOffset;
uint64_t cachedDdtPosition;
uint64_t primaryDdtOffset;
uint16_t *cachedSecondaryDdtSmall;
uint32_t *cachedSecondaryDdtBig;
bool isWriting;
BlockHeader currentBlockHeader;
uint8_t *writingBuffer;
int currentBlockOffset;
crc64_ctx *crc64Context;
int writingBufferPosition;
uint64_t nextBlockPosition;
UT_array *indexEntries;
hash_map_t *sectorHashMap;
bool deduplicate;
2020-03-01 19:51:13 +00:00
} aaruformatContext;
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;
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