mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Rename sectorSuffix to sector_suffix for consistency
This commit is contained in:
@@ -158,7 +158,7 @@ typedef struct aaruformatContext
|
|||||||
/* Optical auxiliary buffers (NULL if not present) */
|
/* Optical auxiliary buffers (NULL if not present) */
|
||||||
uint8_t *sector_prefix; ///< Raw per-sector prefix (e.g., sync+header) uncorrected.
|
uint8_t *sector_prefix; ///< Raw per-sector prefix (e.g., sync+header) uncorrected.
|
||||||
uint8_t *sectorPrefixCorrected; ///< Corrected variant (post error correction) if stored.
|
uint8_t *sectorPrefixCorrected; ///< Corrected variant (post error correction) if stored.
|
||||||
uint8_t *sectorSuffix; ///< Raw per-sector suffix (EDC/ECC) uncorrected.
|
uint8_t *sector_suffix; ///< Raw per-sector suffix (EDC/ECC) uncorrected.
|
||||||
uint8_t *sectorSuffixCorrected; ///< Corrected suffix if stored separately.
|
uint8_t *sectorSuffixCorrected; ///< Corrected suffix if stored separately.
|
||||||
uint8_t *sectorSubchannel; ///< Raw 96-byte subchannel (if captured).
|
uint8_t *sectorSubchannel; ///< Raw 96-byte subchannel (if captured).
|
||||||
uint8_t *mode2_subheaders; ///< MODE2 Form1/Form2 8-byte subheaders (concatenated).
|
uint8_t *mode2_subheaders; ///< MODE2 Form1/Form2 8-byte subheaders (concatenated).
|
||||||
@@ -232,11 +232,10 @@ typedef struct aaruformatContext
|
|||||||
uint8_t currentTrackType; ///< Current track type (when writing optical images with tracks, needed for block
|
uint8_t currentTrackType; ///< Current track type (when writing optical images with tracks, needed for block
|
||||||
///< compression type).
|
///< compression type).
|
||||||
bool writingLong; ///< True if writing long sectors
|
bool writingLong; ///< True if writing long sectors
|
||||||
uint8_t *sectorSuffixBuffer; ///< Buffer for storing sector suffixes when writing optical images
|
size_t sector_prefix_length; ///< Length of sector_prefix
|
||||||
size_t sector_prefix_length; ///< Length of sectorPrefixBuffer
|
size_t sector_suffix_length; ///< Length of sector_suffix
|
||||||
size_t sectorSuffixBufferLength; ///< Length of sectorSuffixBuffer
|
size_t sector_prefix_offset; ///< Current position in sector_prefix
|
||||||
size_t sector_prefix_offset; ///< Current position in sectorPrefixBuffer
|
size_t sector_suffix_offset; ///< Current position in sector_suffix
|
||||||
size_t sectorSuffixBufferOffset; ///< Current position in sectorSuffixBuffer
|
|
||||||
} aaruformatContext;
|
} aaruformatContext;
|
||||||
|
|
||||||
/** \struct DumpHardwareEntriesWithData
|
/** \struct DumpHardwareEntriesWithData
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ int32_t process_data_block(aaruformatContext *ctx, IndexEntry *entry)
|
|||||||
if(entry->dataType == CdSectorSuffixCorrected)
|
if(entry->dataType == CdSectorSuffixCorrected)
|
||||||
ctx->sectorSuffixCorrected = data;
|
ctx->sectorSuffixCorrected = data;
|
||||||
else
|
else
|
||||||
ctx->sectorSuffix = data;
|
ctx->sector_suffix = data;
|
||||||
|
|
||||||
ctx->readableSectorTags[CdSectorSubHeader] = true;
|
ctx->readableSectorTags[CdSectorSubHeader] = true;
|
||||||
ctx->readableSectorTags[CdSectorEcc] = true;
|
ctx->readableSectorTags[CdSectorEcc] = true;
|
||||||
|
|||||||
10
src/close.c
10
src/close.c
@@ -916,8 +916,10 @@ static int32_t write_index_block(aaruformatContext *ctx)
|
|||||||
* @param context Opaque pointer returned by earlier open/create calls (must be an aaruformatContext).
|
* @param context Opaque pointer returned by earlier open/create calls (must be an aaruformatContext).
|
||||||
* @return 0 on success; -1 or negative libaaruformat error code on failure.
|
* @return 0 on success; -1 or negative libaaruformat error code on failure.
|
||||||
* @retval 0 All pending data flushed (if writing) and resources released successfully.
|
* @retval 0 All pending data flushed (if writing) and resources released successfully.
|
||||||
* @retval -1 Invalid context pointer or initial header rewrite failure (errno = EINVAL or AARUF_ERROR_CANNOT_WRITE_HEADER).
|
* @retval -1 Invalid context pointer or initial header rewrite failure (errno = EINVAL or
|
||||||
* @retval AARUF_ERROR_CANNOT_WRITE_HEADER A later write helper (e.g., index, DDT) failed and returned this code directly.
|
* AARUF_ERROR_CANNOT_WRITE_HEADER).
|
||||||
|
* @retval AARUF_ERROR_CANNOT_WRITE_HEADER A later write helper (e.g., index, DDT) failed and returned this code
|
||||||
|
* directly.
|
||||||
* @retval <other negative libaaruformat code> Propagated from a write helper if future helpers add more error codes.
|
* @retval <other negative libaaruformat code> Propagated from a write helper if future helpers add more error codes.
|
||||||
* @note On success the context memory itself is freed; the caller must not reuse the pointer.
|
* @note On success the context memory itself is freed; the caller must not reuse the pointer.
|
||||||
*/
|
*/
|
||||||
@@ -1027,8 +1029,8 @@ int aaruf_close(void *context)
|
|||||||
ctx->sector_prefix = NULL;
|
ctx->sector_prefix = NULL;
|
||||||
free(ctx->sectorPrefixCorrected);
|
free(ctx->sectorPrefixCorrected);
|
||||||
ctx->sectorPrefixCorrected = NULL;
|
ctx->sectorPrefixCorrected = NULL;
|
||||||
free(ctx->sectorSuffix);
|
free(ctx->sector_suffix);
|
||||||
ctx->sectorSuffix = NULL;
|
ctx->sector_suffix = NULL;
|
||||||
free(ctx->sectorSuffixCorrected);
|
free(ctx->sectorSuffixCorrected);
|
||||||
ctx->sectorSuffixCorrected = NULL;
|
ctx->sectorSuffixCorrected = NULL;
|
||||||
free(ctx->sectorSubchannel);
|
free(ctx->sectorSubchannel);
|
||||||
|
|||||||
@@ -827,7 +827,7 @@ int32_t aaruf_read_sector_long(void *context, const uint64_t sector_address, boo
|
|||||||
TRACE("Exiting aaruf_read_sector_long() = AARUF_ERROR_BUFFER_TOO_SMALL");
|
TRACE("Exiting aaruf_read_sector_long() = AARUF_ERROR_BUFFER_TOO_SMALL");
|
||||||
return AARUF_ERROR_BUFFER_TOO_SMALL;
|
return AARUF_ERROR_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
if((ctx->sectorSuffix == NULL || ctx->sector_prefix == NULL) &&
|
if((ctx->sector_suffix == NULL || ctx->sector_prefix == NULL) &&
|
||||||
(ctx->sectorSuffixCorrected == NULL || ctx->sectorPrefixCorrected == NULL))
|
(ctx->sectorSuffixCorrected == NULL || ctx->sectorPrefixCorrected == NULL))
|
||||||
return aaruf_read_sector(context, sector_address, negative, data, length);
|
return aaruf_read_sector(context, sector_address, negative, data, length);
|
||||||
|
|
||||||
@@ -907,8 +907,8 @@ int32_t aaruf_read_sector_long(void *context, const uint64_t sector_address, boo
|
|||||||
|
|
||||||
if(res != AARUF_STATUS_OK) return res;
|
if(res != AARUF_STATUS_OK) return res;
|
||||||
|
|
||||||
if(ctx->sectorSuffix != NULL)
|
if(ctx->sector_suffix != NULL)
|
||||||
memcpy(data + 2064, ctx->sectorSuffix + corrected_sector_address * 288, 288);
|
memcpy(data + 2064, ctx->sector_suffix + corrected_sector_address * 288, 288);
|
||||||
else if(ctx->sectorSuffixDdt != NULL)
|
else if(ctx->sectorSuffixDdt != NULL)
|
||||||
{
|
{
|
||||||
if((ctx->sectorSuffixDdt[corrected_sector_address] & CD_XFIX_MASK) == Correct)
|
if((ctx->sectorSuffixDdt[corrected_sector_address] & CD_XFIX_MASK) == Correct)
|
||||||
|
|||||||
61
src/write.c
61
src/write.c
@@ -589,14 +589,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ctx->sectorSuffixBuffer == NULL)
|
if(ctx->sector_suffix == NULL)
|
||||||
{
|
{
|
||||||
ctx->sectorSuffixBufferLength =
|
ctx->sector_suffix_length = 288 * (ctx->userDataDdtHeader.negative + ctx->imageInfo.Sectors +
|
||||||
288 * (ctx->userDataDdtHeader.negative + ctx->imageInfo.Sectors +
|
|
||||||
ctx->userDataDdtHeader.overflow);
|
ctx->userDataDdtHeader.overflow);
|
||||||
ctx->sectorSuffixBuffer = malloc(ctx->sectorSuffixBufferLength);
|
ctx->sector_suffix = malloc(ctx->sector_suffix_length);
|
||||||
|
|
||||||
if(ctx->sectorSuffixBuffer == NULL)
|
if(ctx->sector_suffix == NULL)
|
||||||
{
|
{
|
||||||
FATAL("Could not allocate memory for CD sector suffix buffer");
|
FATAL("Could not allocate memory for CD sector suffix buffer");
|
||||||
|
|
||||||
@@ -672,19 +671,19 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy CD suffix from data buffer to suffix buffer
|
// Copy CD suffix from data buffer to suffix buffer
|
||||||
memcpy(ctx->sectorSuffixBuffer + ctx->sectorSuffixBufferOffset, data + 2064, 288);
|
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2064, 288);
|
||||||
ctx->sectorSuffixDdtMini[corrected_sector_address] =
|
ctx->sectorSuffixDdtMini[corrected_sector_address] =
|
||||||
(uint16_t)(ctx->sectorSuffixBufferOffset / 288);
|
(uint16_t)(ctx->sector_suffix_offset / 288);
|
||||||
ctx->sectorSuffixDdtMini[corrected_sector_address] |= SectorStatusErrored << 12;
|
ctx->sectorSuffixDdtMini[corrected_sector_address] |= SectorStatusErrored << 12;
|
||||||
ctx->sectorSuffixBufferOffset += 288;
|
ctx->sector_suffix_offset += 288;
|
||||||
|
|
||||||
// Grow suffix buffer if needed
|
// Grow suffix buffer if needed
|
||||||
if(ctx->sectorSuffixBufferOffset >= ctx->sectorSuffixBufferLength)
|
if(ctx->sector_suffix_offset >= ctx->sector_suffix_length)
|
||||||
{
|
{
|
||||||
ctx->sectorSuffixBufferLength *= 2;
|
ctx->sector_suffix_length *= 2;
|
||||||
ctx->sectorSuffixBuffer = realloc(ctx->sectorSuffixBuffer, ctx->sectorSuffixBufferLength);
|
ctx->sector_suffix = realloc(ctx->sector_suffix, ctx->sector_suffix_length);
|
||||||
|
|
||||||
if(ctx->sectorSuffixBuffer == NULL)
|
if(ctx->sector_suffix == NULL)
|
||||||
{
|
{
|
||||||
FATAL("Could not allocate memory for CD sector suffix buffer");
|
FATAL("Could not allocate memory for CD sector suffix buffer");
|
||||||
|
|
||||||
@@ -746,14 +745,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ctx->sectorSuffixBuffer == NULL)
|
if(ctx->sector_suffix == NULL)
|
||||||
{
|
{
|
||||||
ctx->sectorSuffixBufferLength =
|
ctx->sector_suffix_length = 288 * (ctx->userDataDdtHeader.negative + ctx->imageInfo.Sectors +
|
||||||
288 * (ctx->userDataDdtHeader.negative + ctx->imageInfo.Sectors +
|
|
||||||
ctx->userDataDdtHeader.overflow);
|
ctx->userDataDdtHeader.overflow);
|
||||||
ctx->sectorSuffixBuffer = malloc(ctx->sectorSuffixBufferLength);
|
ctx->sector_suffix = malloc(ctx->sector_suffix_length);
|
||||||
|
|
||||||
if(ctx->sectorSuffixBuffer == NULL)
|
if(ctx->sector_suffix == NULL)
|
||||||
{
|
{
|
||||||
FATAL("Could not allocate memory for CD sector suffix buffer");
|
FATAL("Could not allocate memory for CD sector suffix buffer");
|
||||||
|
|
||||||
@@ -853,20 +851,19 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy CD suffix from data buffer to suffix buffer
|
// Copy CD suffix from data buffer to suffix buffer
|
||||||
memcpy(ctx->sectorSuffixBuffer + ctx->sectorSuffixBufferOffset, data + 2348, 4);
|
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2348, 4);
|
||||||
ctx->sectorSuffixDdtMini[corrected_sector_address] =
|
ctx->sectorSuffixDdtMini[corrected_sector_address] =
|
||||||
(uint16_t)(ctx->sectorSuffixBufferOffset / 288);
|
(uint16_t)(ctx->sector_suffix_offset / 288);
|
||||||
ctx->sectorSuffixDdtMini[corrected_sector_address] |= SectorStatusErrored << 12;
|
ctx->sectorSuffixDdtMini[corrected_sector_address] |= SectorStatusErrored << 12;
|
||||||
ctx->sectorSuffixBufferOffset += 288;
|
ctx->sector_suffix_offset += 288;
|
||||||
|
|
||||||
// Grow suffix buffer if needed
|
// Grow suffix buffer if needed
|
||||||
if(ctx->sectorSuffixBufferOffset >= ctx->sectorSuffixBufferLength)
|
if(ctx->sector_suffix_offset >= ctx->sector_suffix_length)
|
||||||
{
|
{
|
||||||
ctx->sectorSuffixBufferLength *= 2;
|
ctx->sector_suffix_length *= 2;
|
||||||
ctx->sectorSuffixBuffer =
|
ctx->sector_suffix = realloc(ctx->sector_suffix, ctx->sector_suffix_length);
|
||||||
realloc(ctx->sectorSuffixBuffer, ctx->sectorSuffixBufferLength);
|
|
||||||
|
|
||||||
if(ctx->sectorSuffixBuffer == NULL)
|
if(ctx->sector_suffix == NULL)
|
||||||
{
|
{
|
||||||
FATAL("Could not allocate memory for CD sector suffix buffer");
|
FATAL("Could not allocate memory for CD sector suffix buffer");
|
||||||
|
|
||||||
@@ -895,19 +892,19 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy CD suffix from data buffer to suffix buffer
|
// Copy CD suffix from data buffer to suffix buffer
|
||||||
memcpy(ctx->sectorSuffixBuffer + ctx->sectorSuffixBufferOffset, data + 2072, 280);
|
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2072, 280);
|
||||||
ctx->sectorSuffixDdtMini[corrected_sector_address] =
|
ctx->sectorSuffixDdtMini[corrected_sector_address] =
|
||||||
(uint16_t)(ctx->sectorSuffixBufferOffset / 288);
|
(uint16_t)(ctx->sector_suffix_offset / 288);
|
||||||
ctx->sectorSuffixDdtMini[corrected_sector_address] |= SectorStatusErrored << 12;
|
ctx->sectorSuffixDdtMini[corrected_sector_address] |= SectorStatusErrored << 12;
|
||||||
ctx->sectorSuffixBufferOffset += 288;
|
ctx->sector_suffix_offset += 288;
|
||||||
|
|
||||||
// Grow suffix buffer if needed
|
// Grow suffix buffer if needed
|
||||||
if(ctx->sectorSuffixBufferOffset >= ctx->sectorSuffixBufferLength)
|
if(ctx->sector_suffix_offset >= ctx->sector_suffix_length)
|
||||||
{
|
{
|
||||||
ctx->sectorSuffixBufferLength *= 2;
|
ctx->sector_suffix_length *= 2;
|
||||||
ctx->sectorSuffixBuffer = realloc(ctx->sectorSuffixBuffer, ctx->sectorSuffixBufferLength);
|
ctx->sector_suffix = realloc(ctx->sector_suffix, ctx->sector_suffix_length);
|
||||||
|
|
||||||
if(ctx->sectorSuffixBuffer == NULL)
|
if(ctx->sector_suffix == NULL)
|
||||||
{
|
{
|
||||||
FATAL("Could not allocate memory for CD sector suffix buffer");
|
FATAL("Could not allocate memory for CD sector suffix buffer");
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ int info(const char *path)
|
|||||||
|
|
||||||
if(ctx->sectorPrefixCorrected != NULL) printf("Sector prefix corrected array has been read.\n");
|
if(ctx->sectorPrefixCorrected != NULL) printf("Sector prefix corrected array has been read.\n");
|
||||||
|
|
||||||
if(ctx->sectorSuffix != NULL) printf("Sector suffix array has been read.\n");
|
if(ctx->sector_suffix != NULL) printf("Sector suffix array has been read.\n");
|
||||||
|
|
||||||
if(ctx->sectorSuffixCorrected != NULL) printf("Sector suffix corrected array has been read.\n");
|
if(ctx->sectorSuffixCorrected != NULL) printf("Sector suffix corrected array has been read.\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user