Loading...
Searching...
No Matches
errors.h
Go to the documentation of this file.
/*
* This file is part of the Aaru Data Preservation Suite.
* Copyright (c) 2019-2026 Natalia Portillo.
*
* 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/>.
*/
#ifndef LIBAARUFORMAT_ERRORS_H
#define LIBAARUFORMAT_ERRORS_H
#define AARUF_ERROR_NOT_AARUFORMAT (-1)
#define AARUF_ERROR_FILE_TOO_SMALL (-2)
#define AARUF_ERROR_INCOMPATIBLE_VERSION (-3)
#define AARUF_ERROR_CANNOT_READ_INDEX (-4)
#define AARUF_ERROR_SECTOR_OUT_OF_BOUNDS (-5)
#define AARUF_ERROR_CANNOT_READ_HEADER (-6)
#define AARUF_ERROR_CANNOT_READ_BLOCK (-7)
#define AARUF_ERROR_UNSUPPORTED_COMPRESSION (-8)
#define AARUF_ERROR_NOT_ENOUGH_MEMORY (-9)
#define AARUF_ERROR_BUFFER_TOO_SMALL (-10)
#define AARUF_ERROR_MEDIA_TAG_NOT_PRESENT (-11)
#define AARUF_ERROR_INCORRECT_MEDIA_TYPE (-12)
#define AARUF_ERROR_TRACK_NOT_FOUND (-13)
#define AARUF_ERROR_REACHED_UNREACHABLE_CODE (-14)
#define AARUF_ERROR_INVALID_TRACK_FORMAT (-15)
#define AARUF_ERROR_SECTOR_TAG_NOT_PRESENT (-16)
#define AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK (-17)
#define AARUF_ERROR_INVALID_BLOCK_CRC (-18)
#define AARUF_ERROR_CANNOT_CREATE_FILE (-19)
#define AARUF_ERROR_INVALID_APP_NAME_LENGTH (-20)
#define AARUF_ERROR_CANNOT_WRITE_HEADER (-21)
#define AARUF_READ_ONLY (-22)
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER (-23)
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA (-24)
#define AARUF_ERROR_CANNOT_SET_DDT_ENTRY (-25)
#define AARUF_ERROR_INCORRECT_DATA_SIZE (-26)
#define AARUF_ERROR_INVALID_TAG (-27)
#define AARUF_ERROR_TAPE_FILE_NOT_FOUND (-28)
#define AARUF_ERROR_TAPE_PARTITION_NOT_FOUND (-29)
#define AARUF_ERROR_METADATA_NOT_PRESENT (-30)
#define AARUF_ERROR_INVALID_SECTOR_LENGTH (-31)
#define AARUF_ERROR_FLUX_DATA_NOT_FOUND (-32)
#define AARUF_STATUS_OK 0
#define AARUF_STATUS_SECTOR_NOT_DUMPED 1
#define AARUF_STATUS_SECTOR_WITH_ERRORS 2
#define AARUF_STATUS_SECTOR_DELETED 3
static inline const char *aaruformat_error_string(int code)
{
switch(code)
{
/* Errors */
case AARUF_ERROR_NOT_AARUFORMAT:
return "Not an AaruFormat image";
case AARUF_ERROR_FILE_TOO_SMALL:
return "File too small";
case AARUF_ERROR_INCOMPATIBLE_VERSION:
return "Incompatible image version";
case AARUF_ERROR_CANNOT_READ_INDEX:
return "Cannot read index";
case AARUF_ERROR_SECTOR_OUT_OF_BOUNDS:
return "Sector out of bounds";
case AARUF_ERROR_CANNOT_READ_HEADER:
return "Cannot read header";
case AARUF_ERROR_CANNOT_READ_BLOCK:
return "Cannot read block";
case AARUF_ERROR_UNSUPPORTED_COMPRESSION:
return "Unsupported compression";
case AARUF_ERROR_NOT_ENOUGH_MEMORY:
return "Not enough memory";
case AARUF_ERROR_BUFFER_TOO_SMALL:
return "Buffer too small";
case AARUF_ERROR_MEDIA_TAG_NOT_PRESENT:
return "Media tag not present";
case AARUF_ERROR_INCORRECT_MEDIA_TYPE:
return "Incorrect media type";
case AARUF_ERROR_TRACK_NOT_FOUND:
return "Track not found";
case AARUF_ERROR_REACHED_UNREACHABLE_CODE:
return "Internal unreachable code reached";
case AARUF_ERROR_INVALID_TRACK_FORMAT:
return "Invalid track format";
case AARUF_ERROR_SECTOR_TAG_NOT_PRESENT:
return "Sector tag not present";
case AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK:
return "Cannot decompress block";
case AARUF_ERROR_INVALID_BLOCK_CRC:
return "Invalid block CRC";
case AARUF_ERROR_CANNOT_CREATE_FILE:
return "Cannot create file";
case AARUF_ERROR_INVALID_APP_NAME_LENGTH:
return "Invalid application name length";
case AARUF_ERROR_CANNOT_WRITE_HEADER:
return "Cannot write header";
case AARUF_READ_ONLY:
return "Read-only context";
case AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER:
return "Cannot write block header";
case AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA:
return "Cannot write block data";
case AARUF_ERROR_CANNOT_SET_DDT_ENTRY:
return "Cannot set DDT entry";
/* Status */
case AARUF_STATUS_OK:
return "OK";
case AARUF_STATUS_SECTOR_NOT_DUMPED:
return "Sector not dumped";
case AARUF_STATUS_SECTOR_WITH_ERRORS:
return "Sector with errors";
case AARUF_STATUS_SECTOR_DELETED:
return "Sector deleted";
}
return "Unknown error/status";
}
#endif // LIBAARUFORMAT_ERRORS_H
AARUF_ERROR_CANNOT_CREATE_FILE
#define AARUF_ERROR_CANNOT_CREATE_FILE
Output file could not be created / opened for write.
Definition errors.h:58
AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA
Failure writing block payload.
Definition errors.h:63
AARUF_STATUS_OK
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:77
AARUF_READ_ONLY
#define AARUF_READ_ONLY
Operation requires write mode but context is read-only.
Definition errors.h:61
AARUF_ERROR_INVALID_APP_NAME_LENGTH
#define AARUF_ERROR_INVALID_APP_NAME_LENGTH
Application name field length invalid (sanity limit).
Definition errors.h:59
AARUF_ERROR_INCORRECT_MEDIA_TYPE
#define AARUF_ERROR_INCORRECT_MEDIA_TYPE
Operation incompatible with image media type.
Definition errors.h:51
AARUF_ERROR_TRACK_NOT_FOUND
#define AARUF_ERROR_TRACK_NOT_FOUND
Referenced track number not present.
Definition errors.h:52
AARUF_ERROR_CANNOT_READ_HEADER
#define AARUF_ERROR_CANNOT_READ_HEADER
Failed to read container header.
Definition errors.h:45
AARUF_ERROR_NOT_ENOUGH_MEMORY
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
Definition errors.h:48
AARUF_ERROR_SECTOR_OUT_OF_BOUNDS
#define AARUF_ERROR_SECTOR_OUT_OF_BOUNDS
Requested logical sector outside media bounds.
Definition errors.h:44
AARUF_ERROR_INVALID_TRACK_FORMAT
#define AARUF_ERROR_INVALID_TRACK_FORMAT
Track metadata internally inconsistent or malformed.
Definition errors.h:54
AARUF_ERROR_INCOMPATIBLE_VERSION
#define AARUF_ERROR_INCOMPATIBLE_VERSION
Image uses a newer incompatible on-disk version.
Definition errors.h:42
AARUF_ERROR_CANNOT_READ_BLOCK
#define AARUF_ERROR_CANNOT_READ_BLOCK
Generic block read failure (seek/read error).
Definition errors.h:46
AARUF_STATUS_SECTOR_DELETED
#define AARUF_STATUS_SECTOR_DELETED
Sector logically marked deleted (e.g. filesystem deleted area).
Definition errors.h:80
AARUF_ERROR_CANNOT_SET_DDT_ENTRY
#define AARUF_ERROR_CANNOT_SET_DDT_ENTRY
Failed to encode/store a DDT entry (overflow or IO).
Definition errors.h:64
AARUF_ERROR_SECTOR_TAG_NOT_PRESENT
#define AARUF_ERROR_SECTOR_TAG_NOT_PRESENT
Requested sector tag (e.g. subchannel/prefix) not stored.
Definition errors.h:55
AARUF_ERROR_INVALID_BLOCK_CRC
#define AARUF_ERROR_INVALID_BLOCK_CRC
CRC64 mismatch indicating corruption.
Definition errors.h:57
AARUF_STATUS_SECTOR_NOT_DUMPED
#define AARUF_STATUS_SECTOR_NOT_DUMPED
Sector not captured (gap / missing / intentionally skipped).
Definition errors.h:78
AARUF_ERROR_CANNOT_READ_INDEX
#define AARUF_ERROR_CANNOT_READ_INDEX
Index block unreadable / truncated / bad identifier.
Definition errors.h:43
AARUF_ERROR_NOT_AARUFORMAT
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
Definition errors.h:40
AARUF_STATUS_SECTOR_WITH_ERRORS
#define AARUF_STATUS_SECTOR_WITH_ERRORS
Sector present but with unrecoverable or flagged errors.
Definition errors.h:79
AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK
#define AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK
Decompression routine failed or size mismatch.
Definition errors.h:56
AARUF_ERROR_FILE_TOO_SMALL
#define AARUF_ERROR_FILE_TOO_SMALL
File size insufficient for mandatory header / structures.
Definition errors.h:41
AARUF_ERROR_MEDIA_TAG_NOT_PRESENT
#define AARUF_ERROR_MEDIA_TAG_NOT_PRESENT
Requested media tag absent.
Definition errors.h:50
AARUF_ERROR_BUFFER_TOO_SMALL
#define AARUF_ERROR_BUFFER_TOO_SMALL
Caller-supplied buffer insufficient for data.
Definition errors.h:49
AARUF_ERROR_UNSUPPORTED_COMPRESSION
#define AARUF_ERROR_UNSUPPORTED_COMPRESSION
Block marked with unsupported compression algorithm.
Definition errors.h:47
aaruformat_error_string
static const char * aaruformat_error_string(int code)
Convert an AaruFormat error or status code to a static human-readable string.
Definition errors.h:92
AARUF_ERROR_CANNOT_WRITE_HEADER
#define AARUF_ERROR_CANNOT_WRITE_HEADER
Failure writing container header.
Definition errors.h:60
AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER
Failure writing block header.
Definition errors.h:62
AARUF_ERROR_REACHED_UNREACHABLE_CODE
#define AARUF_ERROR_REACHED_UNREACHABLE_CODE
Internal logic assertion hit unexpected path.
Definition errors.h:53