mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
General refactor and cleanup.
This commit is contained in:
156
3rdparty/flac.cmake
vendored
156
3rdparty/flac.cmake
vendored
@@ -42,20 +42,20 @@ include(TestBigEndian)
|
||||
check_include_file("byteswap.h" HAVE_BYTESWAP_H)
|
||||
check_include_file("inttypes.h" HAVE_INTTYPES_H)
|
||||
check_include_file("stdint.h" HAVE_STDINT_H)
|
||||
if(MSVC)
|
||||
check_include_file("intrin.h" FLAC__HAS_X86INTRIN)
|
||||
else()
|
||||
check_include_file("x86intrin.h" FLAC__HAS_X86INTRIN)
|
||||
endif()
|
||||
if (MSVC)
|
||||
check_include_file("intrin.h" FLAC__HAS_X86INTRIN)
|
||||
else ()
|
||||
check_include_file("x86intrin.h" FLAC__HAS_X86INTRIN)
|
||||
endif ()
|
||||
|
||||
#check_function_exists(fseeko HAVE_FSEEKO)
|
||||
|
||||
check_c_source_compiles("int main() { return __builtin_bswap16 (0) ; }" HAVE_BSWAP16)
|
||||
check_c_source_compiles("int main() { return __builtin_bswap32 (0) ; }" HAVE_BSWAP32)
|
||||
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"))
|
||||
test_big_endian(CPU_IS_BIG_ENDIAN)
|
||||
endif()
|
||||
if (NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"))
|
||||
test_big_endian(CPU_IS_BIG_ENDIAN)
|
||||
endif ()
|
||||
|
||||
check_c_compiler_flag(-mstackrealign HAVE_STACKREALIGN_FLAG)
|
||||
|
||||
@@ -64,11 +64,11 @@ include_directories("3rdparty/flac/include")
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}/3rdparty/flac")
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
-D_USE_MATH_DEFINES)
|
||||
endif()
|
||||
if (MSVC)
|
||||
add_definitions(
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
-D_USE_MATH_DEFINES)
|
||||
endif ()
|
||||
|
||||
option(WITH_ASM "Use any assembly optimization routines" ON)
|
||||
|
||||
@@ -82,90 +82,90 @@ include(CheckCSourceCompiles)
|
||||
include(CheckCPUArch)
|
||||
|
||||
check_cpu_arch_x64(FLAC__CPU_X86_64)
|
||||
if(NOT FLAC__CPU_X86_64)
|
||||
check_cpu_arch_x86(FLAC__CPU_IA32)
|
||||
endif()
|
||||
if (NOT FLAC__CPU_X86_64)
|
||||
check_cpu_arch_x86(FLAC__CPU_IA32)
|
||||
endif ()
|
||||
|
||||
if(FLAC__CPU_X86_64 OR FLAC__CPU_IA32)
|
||||
set(FLAC__ALIGN_MALLOC_DATA 1)
|
||||
option(WITH_AVX "Enable AVX, AVX2 optimizations" ON)
|
||||
endif()
|
||||
if (FLAC__CPU_X86_64 OR FLAC__CPU_IA32)
|
||||
set(FLAC__ALIGN_MALLOC_DATA 1)
|
||||
option(WITH_AVX "Enable AVX, AVX2 optimizations" ON)
|
||||
endif ()
|
||||
|
||||
include(CheckLanguage)
|
||||
check_language(ASM_NASM)
|
||||
if(CMAKE_ASM_NASM_COMPILER)
|
||||
enable_language(ASM_NASM)
|
||||
add_definitions(-DFLAC__HAS_NASM)
|
||||
endif()
|
||||
if (CMAKE_ASM_NASM_COMPILER)
|
||||
enable_language(ASM_NASM)
|
||||
add_definitions(-DFLAC__HAS_NASM)
|
||||
endif ()
|
||||
|
||||
if(NOT WITH_ASM)
|
||||
add_definitions(-DFLAC__NO_ASM)
|
||||
endif()
|
||||
if (NOT WITH_ASM)
|
||||
add_definitions(-DFLAC__NO_ASM)
|
||||
endif ()
|
||||
|
||||
if(FLAC__CPU_IA32)
|
||||
if(WITH_ASM AND CMAKE_ASM_NASM_COMPILER)
|
||||
add_subdirectory(ia32)
|
||||
endif()
|
||||
if (FLAC__CPU_IA32)
|
||||
if (WITH_ASM AND CMAKE_ASM_NASM_COMPILER)
|
||||
add_subdirectory(ia32)
|
||||
endif ()
|
||||
|
||||
option(WITH_SSE "Enable SSE2 optimizations" ON)
|
||||
check_c_compiler_flag(-msse2 HAVE_MSSE2_FLAG)
|
||||
if(WITH_SSE)
|
||||
add_compile_options(
|
||||
$<$<BOOL:${HAVE_MSSE2_FLAG}>:-msse2>
|
||||
$<$<BOOL:${MSVC}>:/arch:SSE2>)
|
||||
endif()
|
||||
endif()
|
||||
option(WITH_SSE "Enable SSE2 optimizations" ON)
|
||||
check_c_compiler_flag(-msse2 HAVE_MSSE2_FLAG)
|
||||
if (WITH_SSE)
|
||||
add_compile_options(
|
||||
$<$<BOOL:${HAVE_MSSE2_FLAG}>:-msse2>
|
||||
$<$<BOOL:${MSVC}>:/arch:SSE2>)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
include_directories("3rdparty/flac/src/libFLAC/include")
|
||||
|
||||
target_sources(aaruformat PRIVATE
|
||||
3rdparty/flac/src/libFLAC/bitmath.c
|
||||
3rdparty/flac/src/libFLAC/bitreader.c
|
||||
3rdparty/flac/src/libFLAC/bitwriter.c
|
||||
3rdparty/flac/src/libFLAC/cpu.c
|
||||
3rdparty/flac/src/libFLAC/crc.c
|
||||
3rdparty/flac/src/libFLAC/fixed.c
|
||||
3rdparty/flac/src/libFLAC/fixed_intrin_sse2.c
|
||||
3rdparty/flac/src/libFLAC/fixed_intrin_ssse3.c
|
||||
3rdparty/flac/src/libFLAC/float.c
|
||||
3rdparty/flac/src/libFLAC/format.c
|
||||
3rdparty/flac/src/libFLAC/lpc.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_sse.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_sse2.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_sse41.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_avx2.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_vsx.c
|
||||
3rdparty/flac/src/libFLAC/md5.c
|
||||
3rdparty/flac/src/libFLAC/memory.c
|
||||
3rdparty/flac/src/libFLAC/metadata_iterators.c
|
||||
3rdparty/flac/src/libFLAC/metadata_object.c
|
||||
3rdparty/flac/src/libFLAC/stream_decoder.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder_intrin_sse2.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder_intrin_ssse3.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder_intrin_avx2.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder_framing.c
|
||||
3rdparty/flac/src/libFLAC/window.c
|
||||
$<$<BOOL:${WIN32}>:3rdparty/flac/include/share/windows_unicode_filenames.h>
|
||||
$<$<BOOL:${WIN32}>:3rdparty/flac/src/libFLAC/windows_unicode_filenames.c>
|
||||
$<$<BOOL:${OGG_FOUND}>:ogg_decoder_aspect.c>
|
||||
$<$<BOOL:${OGG_FOUND}>:ogg_encoder_aspect.c>
|
||||
$<$<BOOL:${OGG_FOUND}>:ogg_helper.c>
|
||||
$<$<BOOL:${OGG_FOUND}>:ogg_mapping.c>)
|
||||
3rdparty/flac/src/libFLAC/bitmath.c
|
||||
3rdparty/flac/src/libFLAC/bitreader.c
|
||||
3rdparty/flac/src/libFLAC/bitwriter.c
|
||||
3rdparty/flac/src/libFLAC/cpu.c
|
||||
3rdparty/flac/src/libFLAC/crc.c
|
||||
3rdparty/flac/src/libFLAC/fixed.c
|
||||
3rdparty/flac/src/libFLAC/fixed_intrin_sse2.c
|
||||
3rdparty/flac/src/libFLAC/fixed_intrin_ssse3.c
|
||||
3rdparty/flac/src/libFLAC/float.c
|
||||
3rdparty/flac/src/libFLAC/format.c
|
||||
3rdparty/flac/src/libFLAC/lpc.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_sse.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_sse2.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_sse41.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_avx2.c
|
||||
3rdparty/flac/src/libFLAC/lpc_intrin_vsx.c
|
||||
3rdparty/flac/src/libFLAC/md5.c
|
||||
3rdparty/flac/src/libFLAC/memory.c
|
||||
3rdparty/flac/src/libFLAC/metadata_iterators.c
|
||||
3rdparty/flac/src/libFLAC/metadata_object.c
|
||||
3rdparty/flac/src/libFLAC/stream_decoder.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder_intrin_sse2.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder_intrin_ssse3.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder_intrin_avx2.c
|
||||
3rdparty/flac/src/libFLAC/stream_encoder_framing.c
|
||||
3rdparty/flac/src/libFLAC/window.c
|
||||
$<$<BOOL:${WIN32}>:3rdparty/flac/include/share/windows_unicode_filenames.h>
|
||||
$<$<BOOL:${WIN32}>:3rdparty/flac/src/libFLAC/windows_unicode_filenames.c>
|
||||
$<$<BOOL:${OGG_FOUND}>:ogg_decoder_aspect.c>
|
||||
$<$<BOOL:${OGG_FOUND}>:ogg_encoder_aspect.c>
|
||||
$<$<BOOL:${OGG_FOUND}>:ogg_helper.c>
|
||||
$<$<BOOL:${OGG_FOUND}>:ogg_mapping.c>)
|
||||
|
||||
target_compile_definitions(aaruformat PUBLIC FLAC__NO_DLL)
|
||||
target_compile_definitions(aaruformat PUBLIC FLAC__NO_FILEIO)
|
||||
|
||||
# Disable fortify source when not-release or when cross-building with MingW for WoA
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo OR "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
set(DODEFINE_FORTIFY_SOURCE 0)
|
||||
endif()
|
||||
if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo OR "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
set(DODEFINE_FORTIFY_SOURCE 0)
|
||||
endif ()
|
||||
|
||||
set_property(TARGET aaruformat PROPERTY C_VISIBILITY_PRESET hidden)
|
||||
|
||||
if(ARCHITECTURE_IS_64BIT)
|
||||
set(ENABLE_64_BIT_WORDS 1)
|
||||
endif()
|
||||
if (ARCHITECTURE_IS_64BIT)
|
||||
set(ENABLE_64_BIT_WORDS 1)
|
||||
endif ()
|
||||
|
||||
configure_file(3rdparty/flac/config.cmake.h.in 3rdparty/flac/config.h)
|
||||
|
||||
|
||||
84
3rdparty/lzma.cmake
vendored
84
3rdparty/lzma.cmake
vendored
@@ -10,27 +10,27 @@ target_compile_definitions(aaruformat PUBLIC _7ZIP_ST)
|
||||
|
||||
# All assembly for x86 and x64 disabled because it uses a custom, non GAS, non MASM, assembler
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
set(IS_X64 1)
|
||||
target_compile_definitions(aaruformat PUBLIC IS_X64)
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
set(IS_X64 1)
|
||||
target_compile_definitions(aaruformat PUBLIC IS_X64)
|
||||
|
||||
# if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
# set(USE_ASM 1)
|
||||
# endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686")
|
||||
set(IS_X86 1)
|
||||
target_compile_definitions(aaruformat PUBLIC IS_X86)
|
||||
# set(USE_ASM 1)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
set(IS_ARM64 1)
|
||||
target_compile_definitions(aaruformat PUBLIC IS_ARM64)
|
||||
set(USE_ASM 1)
|
||||
endif()
|
||||
# if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
# set(USE_ASM 1)
|
||||
# endif()
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686")
|
||||
set(IS_X86 1)
|
||||
target_compile_definitions(aaruformat PUBLIC IS_X86)
|
||||
# set(USE_ASM 1)
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
set(IS_ARM64 1)
|
||||
target_compile_definitions(aaruformat PUBLIC IS_ARM64)
|
||||
set(USE_ASM 1)
|
||||
endif ()
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang" OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
||||
set(USE_CLANG 1)
|
||||
target_compile_definitions(aaruformat PUBLIC USE_CLANG)
|
||||
endif()
|
||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang" OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
||||
set(USE_CLANG 1)
|
||||
target_compile_definitions(aaruformat PUBLIC USE_CLANG)
|
||||
endif ()
|
||||
|
||||
#target_compile_options(lzma PUBLIC -Wall)
|
||||
#target_compile_options(lzma PUBLIC -Werror)
|
||||
@@ -38,12 +38,12 @@ endif()
|
||||
target_compile_definitions(aaruformat PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-DABI_LINUX>)
|
||||
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
target_compile_options(aaruformat PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-elf64>)
|
||||
else()
|
||||
target_compile_options(aaruformat PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-elf>)
|
||||
target_compile_definitions(aaruformat PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-DABI_CDECL>)
|
||||
endif()
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
target_compile_options(aaruformat PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-elf64>)
|
||||
else ()
|
||||
target_compile_options(aaruformat PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-elf>)
|
||||
target_compile_definitions(aaruformat PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-DABI_CDECL>)
|
||||
endif ()
|
||||
|
||||
#target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/7zAlloc.c)
|
||||
#target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/7zArcIn.c)
|
||||
@@ -98,11 +98,11 @@ target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/LzmaLib.c)
|
||||
|
||||
#target_sources(aaruformat PRIVATE ${LZMA_ASM_DIRECTORY}/x86/7zCrcOpt.asm)
|
||||
|
||||
if(USE_ASM)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
set(USE_X86_ASM 1)
|
||||
endif()
|
||||
endif()
|
||||
if (USE_ASM)
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
set(USE_X86_ASM 1)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
#if(USE_X86_ASM)
|
||||
# target_sources(aaruformat PRIVATE ${LZMA_ASM_DIRECTORY}/x86/7zCrcOpt.asm)
|
||||
@@ -118,20 +118,20 @@ endif()
|
||||
# target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/AesOpt.c)
|
||||
#endif()
|
||||
|
||||
if(USE_LZMA_DEC_ASM)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
target_sources(aaruformat PRIVATE ${LZMA_ASM_DIRECTORY}/x86/LzmaDecOpt.asm)
|
||||
endif()
|
||||
if (USE_LZMA_DEC_ASM)
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
target_sources(aaruformat PRIVATE ${LZMA_ASM_DIRECTORY}/x86/LzmaDecOpt.asm)
|
||||
endif ()
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
target_sources(aaruformat PRIVATE ${LZMA_ASM_DIRECTORY}/arm64/LzmaDecOpt.S)
|
||||
# target_sources(aaruformat PRIVATE ${LZMA_ASM_DIRECTORY}/arm64/7zAsm.S)
|
||||
endif()
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
target_sources(aaruformat PRIVATE ${LZMA_ASM_DIRECTORY}/arm64/LzmaDecOpt.S)
|
||||
# target_sources(aaruformat PRIVATE ${LZMA_ASM_DIRECTORY}/arm64/7zAsm.S)
|
||||
endif ()
|
||||
|
||||
target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/LzmaDec.c)
|
||||
else()
|
||||
target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/LzmaDec.c)
|
||||
endif()
|
||||
target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/LzmaDec.c)
|
||||
else ()
|
||||
target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/LzmaDec.c)
|
||||
endif ()
|
||||
|
||||
#target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/XzDec.c)
|
||||
#target_sources(aaruformat PRIVATE ${LZMA_C_DIRECTORY}/XzEnc.c)
|
||||
|
||||
194
CMakeLists.txt
194
CMakeLists.txt
@@ -16,29 +16,29 @@ cmake_minimum_required(VERSION 3.13)
|
||||
# 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/>.
|
||||
|
||||
IF(APPLE)
|
||||
IF("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
|
||||
SET(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Build architectures for Mac OS X" FORCE)
|
||||
ENDIF()
|
||||
ENDIF(APPLE)
|
||||
IF (APPLE)
|
||||
IF ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
|
||||
SET(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Build architectures for Mac OS X" FORCE)
|
||||
ENDIF ()
|
||||
ENDIF (APPLE)
|
||||
|
||||
project(libaaruformat C)
|
||||
|
||||
add_compile_definitions(__STDC_FORMAT_MACROS=1)
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC" AND "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "ARMV7")
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
else()
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
endif()
|
||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC" AND "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "ARMV7")
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
else ()
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
endif ()
|
||||
|
||||
if("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
|
||||
set(WIN32 TRUE)
|
||||
endif()
|
||||
if ("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
|
||||
set(WIN32 TRUE)
|
||||
endif ()
|
||||
|
||||
add_link_options(-static-libgcc)
|
||||
endif()
|
||||
add_link_options(-static-libgcc)
|
||||
endif ()
|
||||
|
||||
message("Detected system processor: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
message("Detected vs platform name: ${CMAKE_C_COMPILER_ARCHITECTURE_ID}")
|
||||
@@ -48,57 +48,57 @@ message("Detected platform: ${CMAKE_C_PLATFORM_ID}")
|
||||
message("Size of (void*): ${CMAKE_SIZEOF_VOID_P}")
|
||||
|
||||
# Check if target is 64-bit
|
||||
if("${CMAKE_SIZEOF_VOID_P}" MATCHES "8" OR "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "x64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "AMD64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64")
|
||||
set(ARCHITECTURE_IS_64BIT TRUE)
|
||||
endif()
|
||||
if ("${CMAKE_SIZEOF_VOID_P}" MATCHES "8" OR "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "x64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "AMD64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64")
|
||||
set(ARCHITECTURE_IS_64BIT TRUE)
|
||||
endif ()
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" MATCHES "Release")
|
||||
add_compile_definitions(NDEBUG)
|
||||
if ("${CMAKE_BUILD_TYPE}" MATCHES "Release")
|
||||
add_compile_definitions(NDEBUG)
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
||||
add_compile_options("/O2" "/fp:fast")
|
||||
if(${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "X86" OR ${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "x64")
|
||||
add_compile_options("/arch:SSE2")
|
||||
endif()
|
||||
else()
|
||||
add_compile_options(-ffast-math -O3)
|
||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
||||
add_compile_options("/O2" "/fp:fast")
|
||||
if (${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "X86" OR ${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "x64")
|
||||
add_compile_options("/arch:SSE2")
|
||||
endif ()
|
||||
else ()
|
||||
add_compile_options(-ffast-math -O3)
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-march=core2 -mtune=westmere -mfpmath=sse)
|
||||
endif()
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
if (NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-march=core2 -mtune=westmere -mfpmath=sse)
|
||||
endif ()
|
||||
|
||||
add_compile_options(-msse3)
|
||||
add_compile_options(-msse3)
|
||||
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-march=armv8-a)
|
||||
endif()
|
||||
if (NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif ()
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
if (NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-march=armv8-a)
|
||||
endif ()
|
||||
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
||||
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-march=armv7+fp -mfpu=vfpv3-d16)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if (NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif ()
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
||||
if (NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-march=armv7+fp -mfpu=vfpv3-d16)
|
||||
endif ()
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
|
||||
if (NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
add_library(aaruformat SHARED include/aaruformat/consts.h include/aaruformat/enums.h include/aaru.h include/aaruformat.h
|
||||
include/aaruformat/decls.h include/aaruformat/structs.h src/identify.c src/open.c include/aaruformat/context.h
|
||||
src/close.c include/aaruformat/errors.h src/read.c include/aaruformat/crc64.h src/cst.c src/ecc_cd.c src/helpers.c
|
||||
src/simd.c include/aaruformat/simd.h src/crc64/crc64.c src/crc64/crc64_clmul.c src/crc64/crc64_vmull.c
|
||||
src/crc64/arm_vmull.c src/crc64/arm_vmull.h src/spamsum.c include/aaruformat/spamsum.h include/aaruformat/flac.h
|
||||
src/flac.c src/lzma.c src/lru.c include/aaruformat/lru.h include/aaruformat/endian.h src/verify.c)
|
||||
include/aaruformat/decls.h include/aaruformat/structs.h src/identify.c src/open.c include/aaruformat/context.h
|
||||
src/close.c include/aaruformat/errors.h src/read.c include/aaruformat/crc64.h src/cst.c src/ecc_cd.c src/helpers.c
|
||||
src/simd.c include/aaruformat/simd.h src/crc64/crc64.c src/crc64/crc64_clmul.c src/crc64/crc64_vmull.c
|
||||
src/crc64/arm_vmull.c src/crc64/arm_vmull.h src/spamsum.c include/aaruformat/spamsum.h include/aaruformat/flac.h
|
||||
src/flac.c src/lzma.c src/lru.c include/aaruformat/lru.h include/aaruformat/endian.h src/verify.c)
|
||||
|
||||
include_directories(include include/aaruformat)
|
||||
|
||||
@@ -106,29 +106,29 @@ include(3rdparty/flac.cmake)
|
||||
include(3rdparty/lzma.cmake)
|
||||
|
||||
MACRO(TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE target)
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
||||
FOREACH(arg IN LISTS ARGN)
|
||||
SET_TARGET_PROPERTIES(
|
||||
${target} PROPERTIES LINK_FLAGS "/WHOLEARCHIVE:${lib}"
|
||||
)
|
||||
ENDFOREACH()
|
||||
ELSE()
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
SET(LINK_FLAGS "-Wl,-all_load")
|
||||
SET(UNDO_FLAGS "-Wl,-noall_load")
|
||||
ELSE()
|
||||
SET(LINK_FLAGS "-Wl,--whole-archive")
|
||||
SET(UNDO_FLAGS "-Wl,--no-whole-archive")
|
||||
ENDIF()
|
||||
TARGET_LINK_LIBRARIES(${target} ${LINK_FLAGS} ${ARGN} ${UNDO_FLAGS})
|
||||
ENDIF()
|
||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
||||
FOREACH (arg IN LISTS ARGN)
|
||||
SET_TARGET_PROPERTIES(
|
||||
${target} PROPERTIES LINK_FLAGS "/WHOLEARCHIVE:${lib}"
|
||||
)
|
||||
ENDFOREACH ()
|
||||
ELSE ()
|
||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
SET(LINK_FLAGS "-Wl,-all_load")
|
||||
SET(UNDO_FLAGS "-Wl,-noall_load")
|
||||
ELSE ()
|
||||
SET(LINK_FLAGS "-Wl,--whole-archive")
|
||||
SET(UNDO_FLAGS "-Wl,--no-whole-archive")
|
||||
ENDIF ()
|
||||
TARGET_LINK_LIBRARIES(${target} ${LINK_FLAGS} ${ARGN} ${UNDO_FLAGS})
|
||||
ENDIF ()
|
||||
ENDMACRO()
|
||||
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"))
|
||||
set_property(TARGET aaruformat PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
||||
else()
|
||||
set_property(TARGET aaruformat PROPERTY POSITION_INDEPENDENT_CODE FALSE)
|
||||
endif()
|
||||
if (NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"))
|
||||
set_property(TARGET aaruformat PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
||||
else ()
|
||||
set_property(TARGET aaruformat PROPERTY POSITION_INDEPENDENT_CODE FALSE)
|
||||
endif ()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-modules")
|
||||
|
||||
@@ -137,32 +137,32 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-modules")
|
||||
find_package(OpenSSL QUIET)
|
||||
find_package(LibreSSL QUIET)
|
||||
|
||||
if(OpenSSL_FOUND)
|
||||
message("-- OpenSSL VERSION: ${OPENSSL_VERSION}")
|
||||
endif()
|
||||
if (OpenSSL_FOUND)
|
||||
message("-- OpenSSL VERSION: ${OPENSSL_VERSION}")
|
||||
endif ()
|
||||
|
||||
if(LIBRESSL_FOUND)
|
||||
message("-- LibreSSL VERSION: ${LIBRESSL_VERSION}")
|
||||
endif()
|
||||
if (LIBRESSL_FOUND)
|
||||
message("-- LibreSSL VERSION: ${LIBRESSL_VERSION}")
|
||||
endif ()
|
||||
|
||||
if(OpenSSL_FOUND OR LIBRESSL_FOUND)
|
||||
add_compile_definitions(AARU_HAS_SHA256)
|
||||
endif()
|
||||
if (OpenSSL_FOUND OR LIBRESSL_FOUND)
|
||||
add_compile_definitions(AARU_HAS_SHA256)
|
||||
endif ()
|
||||
|
||||
if(LIBRESSL_FOUND)
|
||||
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE(aaruformat ${LIBRESSL_CRYPTO_LIBRARY})
|
||||
elseif(OpenSSL_FOUND)
|
||||
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE(aaruformat ${OPENSSL_CRYPTO_LIBRARY})
|
||||
endif()
|
||||
if (LIBRESSL_FOUND)
|
||||
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE(aaruformat ${LIBRESSL_CRYPTO_LIBRARY})
|
||||
elseif (OpenSSL_FOUND)
|
||||
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE(aaruformat ${OPENSSL_CRYPTO_LIBRARY})
|
||||
endif ()
|
||||
|
||||
include_directories(include 3rdparty/uthash/src)
|
||||
|
||||
include(CheckLibraryExists)
|
||||
|
||||
check_library_exists(m log "" HAVE_LIB_M)
|
||||
if(HAVE_LIB_M)
|
||||
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE(aaruformat m)
|
||||
endif()
|
||||
if (HAVE_LIB_M)
|
||||
TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE(aaruformat m)
|
||||
endif ()
|
||||
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(tool)
|
||||
@@ -1,4 +1,5 @@
|
||||
# libaaruformat
|
||||
|
||||
C implementation of [Aaru](https://www.github.com/aaru-dps/Aaru) file format.
|
||||
|
||||
Work in progress, don't expect it to work yet.
|
||||
@@ -9,6 +10,7 @@ This means any hash or compression algorithm must be statically linked inside th
|
||||
cmake is not a hard dependency, it's merely for the ease of using IDEs (specifically CLion).
|
||||
|
||||
Things still to be implemented that are already in the C# version:
|
||||
|
||||
- Tape file blocks
|
||||
- Automatic media type generation from C# enumeration
|
||||
- Nuget package for linking with Aaru
|
||||
@@ -17,6 +19,7 @@ Things still to be implemented that are already in the C# version:
|
||||
- Deduplication (requires SHA256)
|
||||
|
||||
Things to be implemented not in the C# version:
|
||||
|
||||
- Compile for Dreamcast (KallistiOS preferibly)
|
||||
- Compile for PlayStation Portable
|
||||
- Compile for Wii
|
||||
|
||||
510
include/aaru.h
510
include/aaru.h
@@ -18,7 +18,7 @@
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#endif
|
||||
|
||||
#ifndef LIBAARUFORMAT_AARU_H
|
||||
@@ -35,150 +35,150 @@ typedef enum
|
||||
{
|
||||
// Generics, types 0 to 9
|
||||
/** Unknown disk type */
|
||||
Unknown = 0,
|
||||
Unknown = 0,
|
||||
/** Unknown magneto-optical */
|
||||
UnknownMO = 1,
|
||||
UnknownMO = 1,
|
||||
/** Generic hard disk */
|
||||
GENERIC_HDD = 2,
|
||||
/** Microdrive type hard disk */
|
||||
Microdrive = 3,
|
||||
Microdrive = 3,
|
||||
/** Zoned hard disk */
|
||||
Zone_HDD = 4,
|
||||
Zone_HDD = 4,
|
||||
/** USB flash drives */
|
||||
FlashDrive = 5,
|
||||
FlashDrive = 5,
|
||||
// Generics, types 0 to 9
|
||||
|
||||
// Somewhat standard Compact Disc formats, types 10 to 39
|
||||
/** Any unknown or standard violating CD */
|
||||
CD = 10,
|
||||
CD = 10,
|
||||
/** CD Digital Audio (Red Book) */
|
||||
CDDA = 11,
|
||||
CDDA = 11,
|
||||
/** CD+G (Red Book) */
|
||||
CDG = 12,
|
||||
CDG = 12,
|
||||
/** CD+EG (Red Book) */
|
||||
CDEG = 13,
|
||||
CDEG = 13,
|
||||
/** CD-i (Green Book) */
|
||||
CDI = 14,
|
||||
CDI = 14,
|
||||
/** CD-ROM (Yellow Book) */
|
||||
CDROM = 15,
|
||||
CDROM = 15,
|
||||
/** CD-ROM XA (Yellow Book) */
|
||||
CDROMXA = 16,
|
||||
CDROMXA = 16,
|
||||
/** CD+ (Blue Book) */
|
||||
CDPLUS = 17,
|
||||
CDPLUS = 17,
|
||||
/** CD-MO (Orange Book) */
|
||||
CDMO = 18,
|
||||
CDMO = 18,
|
||||
/** CD-Recordable (Orange Book) */
|
||||
CDR = 19,
|
||||
CDR = 19,
|
||||
/** CD-ReWritable (Orange Book) */
|
||||
CDRW = 20,
|
||||
CDRW = 20,
|
||||
/** Mount-Rainier CD-RW */
|
||||
CDMRW = 21,
|
||||
CDMRW = 21,
|
||||
/** Video CD (White Book) */
|
||||
VCD = 22,
|
||||
VCD = 22,
|
||||
/** Super Video CD (White Book) */
|
||||
SVCD = 23,
|
||||
SVCD = 23,
|
||||
/** Photo CD (Beige Book) */
|
||||
PCD = 24,
|
||||
PCD = 24,
|
||||
/** Super Audio CD (Scarlet Book) */
|
||||
SACD = 25,
|
||||
SACD = 25,
|
||||
/** Double-Density CD-ROM (Purple Book) */
|
||||
DDCD = 26,
|
||||
DDCD = 26,
|
||||
/** DD CD-R (Purple Book) */
|
||||
DDCDR = 27,
|
||||
DDCDR = 27,
|
||||
/** DD CD-RW (Purple Book) */
|
||||
DDCDRW = 28,
|
||||
DDCDRW = 28,
|
||||
/** DTS audio CD (non-standard) */
|
||||
DTSCD = 29,
|
||||
DTSCD = 29,
|
||||
/** CD-MIDI (Red Book) */
|
||||
CDMIDI = 30,
|
||||
CDMIDI = 30,
|
||||
/** CD-Video (ISO/IEC 61104) */
|
||||
CDV = 31,
|
||||
CDV = 31,
|
||||
/** 120mm, Phase-Change, 1298496 sectors, 512 bytes/sector, PD650, ECMA-240, ISO 15485 */
|
||||
PD650 = 32,
|
||||
PD650 = 32,
|
||||
/** 120mm, Write-Once, 1281856 sectors, 512 bytes/sector, PD650, ECMA-240, ISO 15485 */
|
||||
PD650_WORM = 33, /**
|
||||
* CD-i Ready, contains a track before the first TOC track, in mode 2, and all TOC tracks are
|
||||
* Audio. Subchannel marks track as audio pause.
|
||||
*/
|
||||
CDIREADY = 34,
|
||||
FMTOWNS = 35,
|
||||
CDIREADY = 34,
|
||||
FMTOWNS = 35,
|
||||
// Somewhat standard Compact Disc formats, types 10 to 39
|
||||
|
||||
// Standard DVD formats, types 40 to 50
|
||||
/** DVD-ROM (applies to DVD Video and DVD Audio) */
|
||||
DVDROM = 40,
|
||||
DVDROM = 40,
|
||||
/** DVD-R */
|
||||
DVDR = 41,
|
||||
DVDR = 41,
|
||||
/** DVD-RW */
|
||||
DVDRW = 42,
|
||||
DVDRW = 42,
|
||||
/** DVD+R */
|
||||
DVDPR = 43,
|
||||
DVDPR = 43,
|
||||
/** DVD+RW */
|
||||
DVDPRW = 44,
|
||||
DVDPRW = 44,
|
||||
/** DVD+RW DL */
|
||||
DVDPRWDL = 45,
|
||||
DVDPRWDL = 45,
|
||||
/** DVD-R DL */
|
||||
DVDRDL = 46,
|
||||
DVDRDL = 46,
|
||||
/** DVD+R DL */
|
||||
DVDPRDL = 47,
|
||||
DVDPRDL = 47,
|
||||
/** DVD-RAM */
|
||||
DVDRAM = 48,
|
||||
DVDRAM = 48,
|
||||
/** DVD-RW DL */
|
||||
DVDRWDL = 49,
|
||||
DVDRWDL = 49,
|
||||
/** DVD-Download */
|
||||
DVDDownload = 50,
|
||||
// Standard DVD formats, types 40 to 50
|
||||
|
||||
// Standard HD-DVD formats, types 51 to 59
|
||||
/** HD DVD-ROM (applies to HD DVD Video) */
|
||||
HDDVDROM = 51,
|
||||
HDDVDROM = 51,
|
||||
/** HD DVD-RAM */
|
||||
HDDVDRAM = 52,
|
||||
HDDVDRAM = 52,
|
||||
/** HD DVD-R */
|
||||
HDDVDR = 53,
|
||||
HDDVDR = 53,
|
||||
/** HD DVD-RW */
|
||||
HDDVDRW = 54,
|
||||
HDDVDRW = 54,
|
||||
/** HD DVD-R DL */
|
||||
HDDVDRDL = 55,
|
||||
HDDVDRDL = 55,
|
||||
/** HD DVD-RW DL */
|
||||
HDDVDRWDL = 56,
|
||||
// Standard HD-DVD formats, types 51 to 59
|
||||
|
||||
// Standard Blu-ray formats, types 60 to 69
|
||||
/** BD-ROM (and BD Video) */
|
||||
BDROM = 60,
|
||||
BDROM = 60,
|
||||
/** BD-R */
|
||||
BDR = 61,
|
||||
BDR = 61,
|
||||
/** BD-RE */
|
||||
BDRE = 62,
|
||||
BDRE = 62,
|
||||
/** BD-R XL */
|
||||
BDRXL = 63,
|
||||
BDRXL = 63,
|
||||
/** BD-RE XL */
|
||||
BDREXL = 64,
|
||||
// Standard Blu-ray formats, types 60 to 69
|
||||
|
||||
// Rare or uncommon optical standards, types 70 to 79
|
||||
/** Enhanced Versatile Disc */
|
||||
EVD = 70,
|
||||
EVD = 70,
|
||||
/** Forward Versatile Disc */
|
||||
FVD = 71,
|
||||
FVD = 71,
|
||||
/** Holographic Versatile Disc */
|
||||
HVD = 72,
|
||||
HVD = 72,
|
||||
/** China Blue High Definition */
|
||||
CBHD = 73,
|
||||
CBHD = 73,
|
||||
/** High Definition Versatile Multilayer Disc */
|
||||
HDVMD = 74,
|
||||
/** Versatile Compact Disc High Density */
|
||||
VCDHD = 75,
|
||||
/** Stacked Volumetric Optical Disc */
|
||||
SVOD = 76,
|
||||
SVOD = 76,
|
||||
/** Five Dimensional disc */
|
||||
FDDVD = 77,
|
||||
// Rare or uncommon optical standards, types 70 to 79
|
||||
|
||||
// LaserDisc based, types 80 to 89
|
||||
/** Pioneer LaserDisc */
|
||||
LD = 80,
|
||||
LD = 80,
|
||||
/** Pioneer LaserDisc data */
|
||||
LDROM = 81,
|
||||
LDROM2 = 82,
|
||||
@@ -188,7 +188,7 @@ typedef enum
|
||||
|
||||
// MiniDisc based, types 90 to 99
|
||||
/** Sony Hi-MD */
|
||||
HiMD = 90,
|
||||
HiMD = 90,
|
||||
/** Sony MiniDisc */
|
||||
MD = 91,
|
||||
MDData = 92,
|
||||
@@ -197,28 +197,28 @@ typedef enum
|
||||
|
||||
// Plasmon UDO, types 100 to 109
|
||||
/** 5.25", Phase-Change, 1834348 sectors, 8192 bytes/sector, Ultra Density Optical, ECMA-350, ISO 17345 */
|
||||
UDO = 100,
|
||||
UDO = 100,
|
||||
/** 5.25", Phase-Change, 3669724 sectors, 8192 bytes/sector, Ultra Density Optical 2, ECMA-380, ISO 11976 */
|
||||
UDO2 = 101,
|
||||
UDO2 = 101,
|
||||
/** 5.25", Write-Once, 3668759 sectors, 8192 bytes/sector, Ultra Density Optical 2, ECMA-380, ISO 11976 */
|
||||
UDO2_WORM = 102,
|
||||
// Plasmon UDO, types 100 to 109
|
||||
|
||||
// Sony game media, types 110 to 129
|
||||
PlayStationMemoryCard = 110,
|
||||
PlayStationMemoryCard2 = 111,
|
||||
PlayStationMemoryCard = 110,
|
||||
PlayStationMemoryCard2 = 111,
|
||||
/** Sony PlayStation game CD */
|
||||
PS1CD = 112,
|
||||
PS1CD = 112,
|
||||
/** Sony PlayStation 2 game CD */
|
||||
PS2CD = 113,
|
||||
PS2CD = 113,
|
||||
/** Sony PlayStation 2 game DVD */
|
||||
PS2DVD = 114,
|
||||
PS2DVD = 114,
|
||||
/** Sony PlayStation 3 game DVD */
|
||||
PS3DVD = 115,
|
||||
PS3DVD = 115,
|
||||
/** Sony PlayStation 3 game Blu-ray */
|
||||
PS3BD = 116,
|
||||
PS3BD = 116,
|
||||
/** Sony PlayStation 4 game Blu-ray */
|
||||
PS4BD = 117,
|
||||
PS4BD = 117,
|
||||
/** Sony PlayStation Portable Universal Media Disc (ECMA-365) */
|
||||
UMD = 118,
|
||||
PlayStationVitaGameCard = 119,
|
||||
@@ -226,7 +226,7 @@ typedef enum
|
||||
|
||||
// Microsoft game media, types 130 to 149
|
||||
/** Microsoft X-box Game Disc */
|
||||
XGD = 130,
|
||||
XGD = 130,
|
||||
/** Microsoft X-box 360 Game Disc */
|
||||
XGD2 = 131,
|
||||
/** Microsoft X-box 360 Game Disc */
|
||||
@@ -237,11 +237,11 @@ typedef enum
|
||||
|
||||
// Sega game media, types 150 to 169
|
||||
/** Sega MegaCD */
|
||||
MEGACD = 150,
|
||||
MEGACD = 150,
|
||||
/** Sega Saturn disc */
|
||||
SATURNCD = 151,
|
||||
/** Sega/Yamaha Gigabyte Disc */
|
||||
GDROM = 152,
|
||||
GDROM = 152,
|
||||
/** Sega/Yamaha recordable Gigabyte Disc */
|
||||
GDR = 153,
|
||||
SegaCard = 154,
|
||||
@@ -250,40 +250,40 @@ typedef enum
|
||||
|
||||
// Other game media, types 170 to 179
|
||||
/** PC-Engine / TurboGrafx cartridge */
|
||||
HuCard = 170,
|
||||
HuCard = 170,
|
||||
/** PC-Engine / TurboGrafx CD */
|
||||
SuperCDROM2 = 171,
|
||||
/** Atari Jaguar CD */
|
||||
JaguarCD = 172,
|
||||
JaguarCD = 172,
|
||||
/** 3DO CD */
|
||||
ThreeDO = 173,
|
||||
ThreeDO = 173,
|
||||
/** NEC PC-FX */
|
||||
PCFX = 174,
|
||||
PCFX = 174,
|
||||
/** NEO-GEO CD */
|
||||
NeoGeoCD = 175,
|
||||
NeoGeoCD = 175,
|
||||
/** Commodore CDTV */
|
||||
CDTV = 176,
|
||||
CDTV = 176,
|
||||
/** Amiga CD32 */
|
||||
CD32 = 177,
|
||||
CD32 = 177,
|
||||
/** Nuon (DVD based videogame console) */
|
||||
Nuon = 178,
|
||||
Nuon = 178,
|
||||
/** Bandai Playdia */
|
||||
Playdia = 179,
|
||||
Playdia = 179,
|
||||
// Other game media, types 170 to 179
|
||||
|
||||
// Apple standard floppy format, types 180 to 189
|
||||
/** 5.25", SS, DD, 35 tracks, 13 spt, 256 bytes/sector, GCR */
|
||||
Apple32SS = 180,
|
||||
Apple32SS = 180,
|
||||
/** 5.25", DS, DD, 35 tracks, 13 spt, 256 bytes/sector, GCR */
|
||||
Apple32DS = 181,
|
||||
Apple32DS = 181,
|
||||
/** 5.25", SS, DD, 35 tracks, 16 spt, 256 bytes/sector, GCR */
|
||||
Apple33SS = 182,
|
||||
Apple33SS = 182,
|
||||
/** 5.25", DS, DD, 35 tracks, 16 spt, 256 bytes/sector, GCR */
|
||||
Apple33DS = 183,
|
||||
Apple33DS = 183,
|
||||
/** 3.5", SS, DD, 80 tracks, 8 to 12 spt, 512 bytes/sector, GCR */
|
||||
AppleSonySS = 184,
|
||||
AppleSonySS = 184,
|
||||
/** 3.5", DS, DD, 80 tracks, 8 to 12 spt, 512 bytes/sector, GCR */
|
||||
AppleSonyDS = 185,
|
||||
AppleSonyDS = 185,
|
||||
/** 5.25", DS, ?D, ?? tracks, ?? spt, 512 bytes/sector, GCR, opposite side heads, aka Twiggy */
|
||||
AppleFileWare = 186,
|
||||
// Apple standard floppy format
|
||||
@@ -298,57 +298,57 @@ typedef enum
|
||||
/** 5.25", DS, DD, 40 tracks, 9 spt, 512 bytes/sector, MFM */
|
||||
DOS_525_DS_DD_9 = 193,
|
||||
/** 5.25", DS, HD, 80 tracks, 15 spt, 512 bytes/sector, MFM */
|
||||
DOS_525_HD = 194,
|
||||
DOS_525_HD = 194,
|
||||
/** 3.5", SS, DD, 80 tracks, 8 spt, 512 bytes/sector, MFM */
|
||||
DOS_35_SS_DD_8 = 195,
|
||||
DOS_35_SS_DD_8 = 195,
|
||||
/** 3.5", SS, DD, 80 tracks, 9 spt, 512 bytes/sector, MFM */
|
||||
DOS_35_SS_DD_9 = 196,
|
||||
DOS_35_SS_DD_9 = 196,
|
||||
/** 3.5", DS, DD, 80 tracks, 8 spt, 512 bytes/sector, MFM */
|
||||
DOS_35_DS_DD_8 = 197,
|
||||
DOS_35_DS_DD_8 = 197,
|
||||
/** 3.5", DS, DD, 80 tracks, 9 spt, 512 bytes/sector, MFM */
|
||||
DOS_35_DS_DD_9 = 198,
|
||||
DOS_35_DS_DD_9 = 198,
|
||||
/** 3.5", DS, HD, 80 tracks, 18 spt, 512 bytes/sector, MFM */
|
||||
DOS_35_HD = 199,
|
||||
DOS_35_HD = 199,
|
||||
/** 3.5", DS, ED, 80 tracks, 36 spt, 512 bytes/sector, MFM */
|
||||
DOS_35_ED = 200,
|
||||
DOS_35_ED = 200,
|
||||
/** 3.5", DS, HD, 80 tracks, 21 spt, 512 bytes/sector, MFM */
|
||||
DMF = 201,
|
||||
DMF = 201,
|
||||
/** 3.5", DS, HD, 82 tracks, 21 spt, 512 bytes/sector, MFM */
|
||||
DMF_82 = 202, /**
|
||||
* 5.25", DS, HD, 80 tracks, ? spt, ??? + ??? + ??? bytes/sector, MFM track 0 = ??15 sectors, 512
|
||||
* bytes/sector, falsified to DOS as 19 spt, 512 bps
|
||||
*/
|
||||
XDF_525 = 203, /**
|
||||
* 3.5", DS, HD, 80 tracks, 4 spt, 8192 + 2048 + 1024 + 512 bytes/sector, MFM track 0 = 19
|
||||
* sectors, 512 bytes/sector, falsified to DOS as 23 spt, 512 bps
|
||||
*/
|
||||
XDF_35 = 204,
|
||||
DMF_82 = 202, /**
|
||||
* 5.25", DS, HD, 80 tracks, ? spt, ??? + ??? + ??? bytes/sector, MFM track 0 = ??15 sectors, 512
|
||||
* bytes/sector, falsified to DOS as 19 spt, 512 bps
|
||||
*/
|
||||
XDF_525 = 203, /**
|
||||
* 3.5", DS, HD, 80 tracks, 4 spt, 8192 + 2048 + 1024 + 512 bytes/sector, MFM track 0 = 19
|
||||
* sectors, 512 bytes/sector, falsified to DOS as 23 spt, 512 bps
|
||||
*/
|
||||
XDF_35 = 204,
|
||||
// IBM/Microsoft PC standard floppy formats, types 190 to 209
|
||||
|
||||
// IBM standard floppy formats, types 210 to 219
|
||||
/** 8", SS, SD, 32 tracks, 8 spt, 319 bytes/sector, FM */
|
||||
IBM23FD = 210,
|
||||
IBM23FD = 210,
|
||||
/** 8", SS, SD, 73 tracks, 26 spt, 128 bytes/sector, FM */
|
||||
IBM33FD_128 = 211,
|
||||
IBM33FD_128 = 211,
|
||||
/** 8", SS, SD, 74 tracks, 15 spt, 256 bytes/sector, FM, track 0 = 26 sectors, 128 bytes/sector */
|
||||
IBM33FD_256 = 212,
|
||||
IBM33FD_256 = 212,
|
||||
/** 8", SS, SD, 74 tracks, 8 spt, 512 bytes/sector, FM, track 0 = 26 sectors, 128 bytes/sector */
|
||||
IBM33FD_512 = 213,
|
||||
IBM33FD_512 = 213,
|
||||
/** 8", DS, SD, 74 tracks, 26 spt, 128 bytes/sector, FM, track 0 = 26 sectors, 128 bytes/sector */
|
||||
IBM43FD_128 = 214,
|
||||
IBM43FD_128 = 214,
|
||||
/** 8", DS, SD, 74 tracks, 26 spt, 256 bytes/sector, FM, track 0 = 26 sectors, 128 bytes/sector */
|
||||
IBM43FD_256 = 215, /**
|
||||
* 8", DS, DD, 74 tracks, 26 spt, 256 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
IBM53FD_256 = 216, /**
|
||||
* 8", DS, DD, 74 tracks, 15 spt, 512 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
IBM53FD_512 = 217, /**
|
||||
* 8", DS, DD, 74 tracks, 8 spt, 1024 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
IBM43FD_256 = 215, /**
|
||||
* 8", DS, DD, 74 tracks, 26 spt, 256 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
IBM53FD_256 = 216, /**
|
||||
* 8", DS, DD, 74 tracks, 15 spt, 512 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
IBM53FD_512 = 217, /**
|
||||
* 8", DS, DD, 74 tracks, 8 spt, 1024 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
IBM53FD_1024 = 218,
|
||||
// IBM standard floppy formats, types 210 to 219
|
||||
|
||||
@@ -373,24 +373,24 @@ typedef enum
|
||||
/** 5,25", SS, DD, 80 tracks, 16 spt, 256 bytes/sector, MFM */
|
||||
ACORN_525_SS_DD_80 = 233,
|
||||
/** 5,25", DS, DD, 80 tracks, 16 spt, 256 bytes/sector, MFM */
|
||||
ACORN_525_DS_DD = 234,
|
||||
ACORN_525_DS_DD = 234,
|
||||
/** 3,5", DS, DD, 80 tracks, 5 spt, 1024 bytes/sector, MFM */
|
||||
ACORN_35_DS_DD = 235,
|
||||
ACORN_35_DS_DD = 235,
|
||||
/** 3,5", DS, HD, 80 tracks, 10 spt, 1024 bytes/sector, MFM */
|
||||
ACORN_35_DS_HD = 236,
|
||||
ACORN_35_DS_HD = 236,
|
||||
// Acorn standard floppy formats, types 230 to 239
|
||||
|
||||
// Atari standard floppy formats, types 240 to 249
|
||||
/** 5,25", SS, SD, 40 tracks, 18 spt, 128 bytes/sector, FM */
|
||||
ATARI_525_SD = 240,
|
||||
ATARI_525_SD = 240,
|
||||
/** 5,25", SS, ED, 40 tracks, 26 spt, 128 bytes/sector, MFM */
|
||||
ATARI_525_ED = 241,
|
||||
ATARI_525_ED = 241,
|
||||
/** 5,25", SS, DD, 40 tracks, 18 spt, 256 bytes/sector, MFM */
|
||||
ATARI_525_DD = 242,
|
||||
ATARI_525_DD = 242,
|
||||
/** 3,5", SS, DD, 80 tracks, 10 spt, 512 bytes/sector, MFM */
|
||||
ATARI_35_SS_DD = 243,
|
||||
ATARI_35_SS_DD = 243,
|
||||
/** 3,5", DS, DD, 80 tracks, 10 spt, 512 bytes/sector, MFM */
|
||||
ATARI_35_DS_DD = 244,
|
||||
ATARI_35_DS_DD = 244,
|
||||
/** 3,5", SS, DD, 80 tracks, 11 spt, 512 bytes/sector, MFM */
|
||||
ATARI_35_SS_DD_11 = 245,
|
||||
/** 3,5", DS, DD, 80 tracks, 11 spt, 512 bytes/sector, MFM */
|
||||
@@ -399,44 +399,44 @@ typedef enum
|
||||
|
||||
// Commodore standard floppy formats, types 250 to 259
|
||||
/** 3,5", DS, DD, 80 tracks, 10 spt, 512 bytes/sector, MFM (1581) */
|
||||
CBM_35_DD = 250,
|
||||
CBM_35_DD = 250,
|
||||
/** 3,5", DS, DD, 80 tracks, 11 spt, 512 bytes/sector, MFM (Amiga) */
|
||||
CBM_AMIGA_35_DD = 251,
|
||||
/** 3,5", DS, HD, 80 tracks, 22 spt, 512 bytes/sector, MFM (Amiga) */
|
||||
CBM_AMIGA_35_HD = 252,
|
||||
/** 5,25", SS, DD, 35 tracks, GCR */
|
||||
CBM_1540 = 253,
|
||||
CBM_1540 = 253,
|
||||
/** 5,25", SS, DD, 40 tracks, GCR */
|
||||
CBM_1540_Ext = 254,
|
||||
CBM_1540_Ext = 254,
|
||||
/** 5,25", DS, DD, 35 tracks, GCR */
|
||||
CBM_1571 = 255,
|
||||
CBM_1571 = 255,
|
||||
// Commodore standard floppy formats, types 250 to 259
|
||||
|
||||
// NEC/SHARP standard floppy formats, types 260 to 269
|
||||
/** 8", DS, SD, 77 tracks, 26 spt, 128 bytes/sector, FM */
|
||||
NEC_8_SD = 260,
|
||||
NEC_8_SD = 260,
|
||||
/** 8", DS, DD, 77 tracks, 26 spt, 256 bytes/sector, MFM */
|
||||
NEC_8_DD = 261,
|
||||
NEC_8_DD = 261,
|
||||
/** 5.25", SS, SD, 80 tracks, 16 spt, 256 bytes/sector, FM */
|
||||
NEC_525_SS = 262,
|
||||
NEC_525_SS = 262,
|
||||
/** 5.25", DS, SD, 80 tracks, 16 spt, 256 bytes/sector, MFM */
|
||||
NEC_525_DS = 263,
|
||||
NEC_525_DS = 263,
|
||||
/** 5,25", DS, HD, 77 tracks, 8 spt, 1024 bytes/sector, MFM */
|
||||
NEC_525_HD = 264,
|
||||
NEC_525_HD = 264,
|
||||
/** 3,5", DS, HD, 77 tracks, 8 spt, 1024 bytes/sector, MFM, aka mode 3 */
|
||||
NEC_35_HD_8 = 265,
|
||||
NEC_35_HD_8 = 265,
|
||||
/** 3,5", DS, HD, 80 tracks, 15 spt, 512 bytes/sector, MFM */
|
||||
NEC_35_HD_15 = 266,
|
||||
/** 3,5", DS, TD, 240 tracks, 38 spt, 512 bytes/sector, MFM */
|
||||
NEC_35_TD = 267,
|
||||
NEC_35_TD = 267,
|
||||
/** 5,25", DS, HD, 77 tracks, 8 spt, 1024 bytes/sector, MFM */
|
||||
SHARP_525 = NEC_525_HD,
|
||||
SHARP_525 = NEC_525_HD,
|
||||
/** 3,5", DS, HD, 80 tracks, 9 spt, 1024 bytes/sector, MFM */
|
||||
SHARP_525_9 = 268,
|
||||
SHARP_525_9 = 268,
|
||||
/** 3,5", DS, HD, 77 tracks, 8 spt, 1024 bytes/sector, MFM */
|
||||
SHARP_35 = NEC_35_HD_8,
|
||||
SHARP_35 = NEC_35_HD_8,
|
||||
/** 3,5", DS, HD, 80 tracks, 9 spt, 1024 bytes/sector, MFM */
|
||||
SHARP_35_9 = 269,
|
||||
SHARP_35_9 = 269,
|
||||
// NEC/SHARP standard floppy formats, types 260 to 269
|
||||
|
||||
// ECMA floppy standards, types 270 to 289
|
||||
@@ -444,7 +444,7 @@ typedef enum
|
||||
* 5,25", DS, DD, 80 tracks, 8 spt, 1024 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128 bytes/sector, track
|
||||
* 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
ECMA_99_8 = 270, /**
|
||||
ECMA_99_8 = 270, /**
|
||||
* 5,25", DS, DD, 77 tracks, 15 spt, 512 bytes/sector, MFM, track 0 side 0 = 26 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
@@ -454,21 +454,21 @@ typedef enum
|
||||
*/
|
||||
ECMA_99_26 = 272,
|
||||
/** 3,5", DS, DD, 80 tracks, 9 spt, 512 bytes/sector, MFM */
|
||||
ECMA_100 = DOS_35_DS_DD_9,
|
||||
ECMA_100 = DOS_35_DS_DD_9,
|
||||
/** 3,5", DS, HD, 80 tracks, 18 spt, 512 bytes/sector, MFM */
|
||||
ECMA_125 = DOS_35_HD,
|
||||
ECMA_125 = DOS_35_HD,
|
||||
/** 3,5", DS, ED, 80 tracks, 36 spt, 512 bytes/sector, MFM */
|
||||
ECMA_147 = DOS_35_ED,
|
||||
ECMA_147 = DOS_35_ED,
|
||||
/** 8", SS, SD, 77 tracks, 26 spt, 128 bytes/sector, FM */
|
||||
ECMA_54 = 273,
|
||||
ECMA_54 = 273,
|
||||
/** 8", DS, SD, 77 tracks, 26 spt, 128 bytes/sector, FM */
|
||||
ECMA_59 = 274,
|
||||
ECMA_59 = 274,
|
||||
/** 5,25", SS, DD, 35 tracks, 9 spt, 256 bytes/sector, FM, track 0 side 0 = 16 sectors, 128 bytes/sector */
|
||||
ECMA_66 = 275, /**
|
||||
ECMA_66 = 275, /**
|
||||
* 8", DS, DD, 77 tracks, 8 spt, 1024 bytes/sector, FM, track 0 side 0 = 26 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
ECMA_69_8 = 276, /**
|
||||
ECMA_69_8 = 276, /**
|
||||
* 8", DS, DD, 77 tracks, 15 spt, 512 bytes/sector, FM, track 0 side 0 = 26 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector
|
||||
*/
|
||||
@@ -480,13 +480,13 @@ typedef enum
|
||||
* 5,25", DS, DD, 40 tracks, 16 spt, 256 bytes/sector, FM, track 0 side 0 = 16 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 16 sectors, 256 bytes/sector
|
||||
*/
|
||||
ECMA_70 = 279, /**
|
||||
ECMA_70 = 279, /**
|
||||
* 5,25", DS, DD, 80 tracks, 16 spt, 256 bytes/sector, FM, track 0 side 0 = 16 sectors, 128
|
||||
* bytes/sector, track 0 side 1 = 16 sectors, 256 bytes/sector
|
||||
*/
|
||||
ECMA_78 = 280,
|
||||
ECMA_78 = 280,
|
||||
/** 5,25", DS, DD, 80 tracks, 9 spt, 512 bytes/sector, FM */
|
||||
ECMA_78_2 = 281,
|
||||
ECMA_78_2 = 281,
|
||||
// ECMA floppy standards, types 270 to 289
|
||||
|
||||
// Non-standard PC formats (FDFORMAT, 2M, etc), types 290 to 308
|
||||
@@ -495,9 +495,9 @@ typedef enum
|
||||
/** 5,25", DS, HD, 82 tracks, 17 spt, 512 bytes/sector, MFM */
|
||||
FDFORMAT_525_HD = 291,
|
||||
/** 3,5", DS, DD, 82 tracks, 10 spt, 512 bytes/sector, MFM */
|
||||
FDFORMAT_35_DD = 292,
|
||||
FDFORMAT_35_DD = 292,
|
||||
/** 3,5", DS, HD, 82 tracks, 21 spt, 512 bytes/sector, MFM */
|
||||
FDFORMAT_35_HD = 293,
|
||||
FDFORMAT_35_HD = 293,
|
||||
// Non-standard PC formats (FDFORMAT, 2M, etc), types 290 to 308
|
||||
|
||||
// Apricot ACT standard floppy formats, type 309
|
||||
@@ -548,11 +548,11 @@ typedef enum
|
||||
Data8 = 361,
|
||||
MiniDV = 362,
|
||||
/** D/CAS-25: Digital data on Compact Cassette form factor, special magnetic media, 9-track */
|
||||
Dcas25 = 363,
|
||||
Dcas25 = 363,
|
||||
/** D/CAS-85: Digital data on Compact Cassette form factor, special magnetic media, 17-track */
|
||||
Dcas85 = 364,
|
||||
Dcas85 = 364,
|
||||
/** D/CAS-103: Digital data on Compact Cassette form factor, special magnetic media, 21-track */
|
||||
Dcas103 = 365,
|
||||
Dcas103 = 365,
|
||||
// Audio media, types 360 to 369
|
||||
|
||||
// CompactFlash Association, types 370 to 379
|
||||
@@ -636,21 +636,21 @@ typedef enum
|
||||
GameBoyAdvanceGamePak = 451,
|
||||
GameBoyGamePak = 452,
|
||||
/** Nintendo GameCube Optical Disc */
|
||||
GOD = 453,
|
||||
N64DD = 454,
|
||||
N64GamePak = 455,
|
||||
NESGamePak = 456,
|
||||
Nintendo3DSGameCard = 457,
|
||||
NintendoDiskCard = 458,
|
||||
NintendoDSGameCard = 459,
|
||||
NintendoDSiGameCard = 460,
|
||||
SNESGamePak = 461,
|
||||
SNESGamePakUS = 462,
|
||||
GOD = 453,
|
||||
N64DD = 454,
|
||||
N64GamePak = 455,
|
||||
NESGamePak = 456,
|
||||
Nintendo3DSGameCard = 457,
|
||||
NintendoDiskCard = 458,
|
||||
NintendoDSGameCard = 459,
|
||||
NintendoDSiGameCard = 460,
|
||||
SNESGamePak = 461,
|
||||
SNESGamePakUS = 462,
|
||||
/** Nintendo Wii Optical Disc */
|
||||
WOD = 463,
|
||||
WOD = 463,
|
||||
/** Nintendo Wii U Optical Disc */
|
||||
WUOD = 464,
|
||||
SwitchGameCard = 465,
|
||||
WUOD = 464,
|
||||
SwitchGameCard = 465,
|
||||
// Nintendo, types 450 to 469
|
||||
|
||||
// IBM Tapes, types 470 to 479
|
||||
@@ -773,68 +773,68 @@ typedef enum
|
||||
|
||||
// Magneto-optical, types 630 to 659
|
||||
/** 5,25", M.O., ??? sectors, 1024 bytes/sector, ECMA-153, ISO 11560 */
|
||||
ECMA_153 = 630,
|
||||
ECMA_153 = 630,
|
||||
/** 5,25", M.O., ??? sectors, 512 bytes/sector, ECMA-153, ISO 11560 */
|
||||
ECMA_153_512 = 631,
|
||||
ECMA_153_512 = 631,
|
||||
/** 3,5", M.O., 249850 sectors, 512 bytes/sector, ECMA-154, ISO 10090 */
|
||||
ECMA_154 = 632,
|
||||
ECMA_154 = 632,
|
||||
/** 5,25", M.O., 904995 sectors, 512 bytes/sector, ECMA-183, ISO 13481 */
|
||||
ECMA_183_512 = 633,
|
||||
ECMA_183_512 = 633,
|
||||
/** 5,25", M.O., 498526 sectors, 1024 bytes/sector, ECMA-183, ISO 13481 */
|
||||
ECMA_183 = 634,
|
||||
ECMA_183 = 634,
|
||||
/** 5,25", M.O., 1128772 or 1163337 sectors, 512 bytes/sector, ECMA-183, ISO 13549 */
|
||||
ECMA_184_512 = 635,
|
||||
ECMA_184_512 = 635,
|
||||
/** 5,25", M.O., 603466 or 637041 sectors, 1024 bytes/sector, ECMA-183, ISO 13549 */
|
||||
ECMA_184 = 636,
|
||||
ECMA_184 = 636,
|
||||
/** 300mm, M.O., ??? sectors, 1024 bytes/sector, ECMA-189, ISO 13614 */
|
||||
ECMA_189 = 637,
|
||||
ECMA_189 = 637,
|
||||
/** 300mm, M.O., ??? sectors, 1024 bytes/sector, ECMA-190, ISO 13403 */
|
||||
ECMA_190 = 638,
|
||||
ECMA_190 = 638,
|
||||
/** 5,25", M.O., 936921 or 948770 sectors, 1024 bytes/sector, ECMA-195, ISO 13842 */
|
||||
ECMA_195 = 639,
|
||||
ECMA_195 = 639,
|
||||
/** 5,25", M.O., 1644581 or 1647371 sectors, 512 bytes/sector, ECMA-195, ISO 13842 */
|
||||
ECMA_195_512 = 640,
|
||||
ECMA_195_512 = 640,
|
||||
/** 3,5", M.O., 446325 sectors, 512 bytes/sector, ECMA-201, ISO 13963 */
|
||||
ECMA_201 = 641,
|
||||
ECMA_201 = 641,
|
||||
/** 3,5", M.O., 429975 sectors, 512 bytes/sector, embossed, ISO 13963 */
|
||||
ECMA_201_ROM = 642,
|
||||
ECMA_201_ROM = 642,
|
||||
/** 3,5", M.O., 371371 sectors, 1024 bytes/sector, ECMA-223 */
|
||||
ECMA_223 = 643,
|
||||
ECMA_223 = 643,
|
||||
/** 3,5", M.O., 694929 sectors, 512 bytes/sector, ECMA-223 */
|
||||
ECMA_223_512 = 644,
|
||||
ECMA_223_512 = 644,
|
||||
/** 5,25", M.O., 1244621 sectors, 1024 bytes/sector, ECMA-238, ISO 15486 */
|
||||
ECMA_238 = 645,
|
||||
ECMA_238 = 645,
|
||||
/** 3,5", M.O., 318988, 320332 or 321100 sectors, 2048 bytes/sector, ECMA-239, ISO 15498 */
|
||||
ECMA_239 = 646,
|
||||
ECMA_239 = 646,
|
||||
/** 356mm, M.O., 14476734 sectors, 1024 bytes/sector, ECMA-260, ISO 15898 */
|
||||
ECMA_260 = 647,
|
||||
ECMA_260 = 647,
|
||||
/** 356mm, M.O., 24445990 sectors, 1024 bytes/sector, ECMA-260, ISO 15898 */
|
||||
ECMA_260_Double = 648,
|
||||
/** 5,25", M.O., 1128134 sectors, 2048 bytes/sector, ECMA-280, ISO 18093 */
|
||||
ECMA_280 = 649,
|
||||
ECMA_280 = 649,
|
||||
/** 300mm, M.O., 7355716 sectors, 2048 bytes/sector, ECMA-317, ISO 20162 */
|
||||
ECMA_317 = 650,
|
||||
ECMA_317 = 650,
|
||||
/** 5,25", M.O., 1095840 sectors, 4096 bytes/sector, ECMA-322, ISO 22092 */
|
||||
ECMA_322 = 651,
|
||||
ECMA_322 = 651,
|
||||
/** 5,25", M.O., 2043664 sectors, 2048 bytes/sector, ECMA-322, ISO 22092 */
|
||||
ECMA_322_2k = 652,
|
||||
ECMA_322_2k = 652,
|
||||
/** 3,5", M.O., 605846 sectors, 2048 bytes/sector, Cherry Book, GigaMo, ECMA-351, ISO 17346 */
|
||||
GigaMo = 653,
|
||||
GigaMo = 653,
|
||||
/** 3,5", M.O., 1063146 sectors, 2048 bytes/sector, Cherry Book 2, GigaMo 2, ECMA-353, ISO 22533 */
|
||||
GigaMo2 = 654,
|
||||
GigaMo2 = 654,
|
||||
// Magneto-optical, types 630 to 659
|
||||
|
||||
// Other floppy standards, types 660 to 689
|
||||
CompactFloppy = 660,
|
||||
DemiDiskette = 661,
|
||||
/** 3.5", 652 tracks, 2 sides, 512 bytes/sector, Floptical, ECMA-207, ISO 14169 */
|
||||
Floptical = 662,
|
||||
HiFD = 663,
|
||||
QuickDisk = 664,
|
||||
UHD144 = 665,
|
||||
VideoFloppy = 666,
|
||||
Wafer = 667,
|
||||
ZXMicrodrive = 668,
|
||||
Floptical = 662,
|
||||
HiFD = 663,
|
||||
QuickDisk = 664,
|
||||
UHD144 = 665,
|
||||
VideoFloppy = 666,
|
||||
Wafer = 667,
|
||||
ZXMicrodrive = 668,
|
||||
// Other floppy standards, types 660 to 669
|
||||
|
||||
// Miscellaneous, types 670 to 689
|
||||
@@ -872,47 +872,47 @@ typedef enum
|
||||
* 2382 cylinders, 4 tracks/cylinder, 42 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector,
|
||||
* 204890112 bytes
|
||||
*/
|
||||
RA60 = 700, /**
|
||||
RA60 = 700, /**
|
||||
* 546 cylinders, 14 tracks/cylinder, 31 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 121325568 bytes
|
||||
*/
|
||||
RA80 = 701, /**
|
||||
RA80 = 701, /**
|
||||
* 1248 cylinders, 14 tracks/cylinder, 51 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 456228864 bytes
|
||||
*/
|
||||
RA81 = 702, /**
|
||||
RA81 = 702, /**
|
||||
* 302 cylinders, 4 tracks/cylinder, 42 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 25976832 bytes
|
||||
*/
|
||||
RC25 = 703, /**
|
||||
RC25 = 703, /**
|
||||
* 615 cylinders, 4 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 21411840 bytes
|
||||
*/
|
||||
RD31 = 704, /**
|
||||
RD31 = 704, /**
|
||||
* 820 cylinders, 6 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 42823680 bytes
|
||||
*/
|
||||
RD32 = 705, /**
|
||||
RD32 = 705, /**
|
||||
* 306 cylinders, 4 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 10653696 bytes
|
||||
*/
|
||||
RD51 = 706, /**
|
||||
RD51 = 706, /**
|
||||
* 480 cylinders, 7 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 30965760 bytes
|
||||
*/
|
||||
RD52 = 707, /**
|
||||
RD52 = 707, /**
|
||||
* 1024 cylinders, 7 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 75497472 bytes
|
||||
*/
|
||||
RD53 = 708, /**
|
||||
RD53 = 708, /**
|
||||
* 1225 cylinders, 8 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 159936000 bytes
|
||||
*/
|
||||
RD54 = 709, /**
|
||||
RD54 = 709, /**
|
||||
* 411 cylinders, 3 tracks/cylinder, 22 sectors/track, 256 words/sector, 16 bits/word, 512
|
||||
* bytes/sector, 13888512 bytes
|
||||
*/
|
||||
RK06 = 710, /**
|
||||
RK06 = 710, /**
|
||||
* 411 cylinders, 3 tracks/cylinder, 20 sectors/track, 256 words/sector, 18 bits/word, 576
|
||||
* bytes/sector, 14204160 bytes
|
||||
*/
|
||||
@@ -920,7 +920,7 @@ typedef enum
|
||||
* 815 cylinders, 3 tracks/cylinder, 22 sectors/track, 256 words/sector, 16 bits/word, 512
|
||||
* bytes/sector, 27540480 bytes
|
||||
*/
|
||||
RK07 = 712, /**
|
||||
RK07 = 712, /**
|
||||
* 815 cylinders, 3 tracks/cylinder, 20 sectors/track, 256 words/sector, 18 bits/word, 576
|
||||
* bytes/sector, 28166400 bytes
|
||||
*/
|
||||
@@ -928,19 +928,19 @@ typedef enum
|
||||
* 823 cylinders, 5 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 67420160 bytes
|
||||
*/
|
||||
RM02 = 714, /**
|
||||
RM02 = 714, /**
|
||||
* 823 cylinders, 5 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 67420160 bytes
|
||||
*/
|
||||
RM03 = 715, /**
|
||||
RM03 = 715, /**
|
||||
* 823 cylinders, 19 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 256196608 bytes
|
||||
*/
|
||||
RM05 = 716, /**
|
||||
RM05 = 716, /**
|
||||
* 203 cylinders, 10 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 22865920 bytes
|
||||
*/
|
||||
RP02 = 717, /**
|
||||
RP02 = 717, /**
|
||||
* 203 cylinders, 10 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576
|
||||
* bytes/sector, 23385600 bytes
|
||||
*/
|
||||
@@ -948,7 +948,7 @@ typedef enum
|
||||
* 400 cylinders, 10 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 45056000 bytes
|
||||
*/
|
||||
RP03 = 719, /**
|
||||
RP03 = 719, /**
|
||||
* 400 cylinders, 10 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576
|
||||
* bytes/sector, 46080000 bytes
|
||||
*/
|
||||
@@ -956,7 +956,7 @@ typedef enum
|
||||
* 411 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 87960576 bytes
|
||||
*/
|
||||
RP04 = 721, /**
|
||||
RP04 = 721, /**
|
||||
* 411 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576
|
||||
* bytes/sector, 89959680 bytes
|
||||
*/
|
||||
@@ -964,7 +964,7 @@ typedef enum
|
||||
* 411 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 87960576 bytes
|
||||
*/
|
||||
RP05 = 723, /**
|
||||
RP05 = 723, /**
|
||||
* 411 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576
|
||||
* bytes/sector, 89959680 bytes
|
||||
*/
|
||||
@@ -972,7 +972,7 @@ typedef enum
|
||||
* 815 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512
|
||||
* bytes/sector, 174423040 bytes
|
||||
*/
|
||||
RP06 = 725, /**
|
||||
RP06 = 725, /**
|
||||
* 815 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576
|
||||
* bytes/sector, 178387200 bytes
|
||||
*/
|
||||
@@ -1001,9 +1001,9 @@ typedef enum
|
||||
typedef struct ImageInfo
|
||||
{
|
||||
/** Image contains partitions (or tracks for optical media) */
|
||||
uint8_t HasPartitions;
|
||||
uint8_t HasPartitions;
|
||||
/** Image contains sessions (optical media only) */
|
||||
uint8_t HasSessions;
|
||||
uint8_t HasSessions;
|
||||
/** Size of the image without headers */
|
||||
uint64_t ImageSize;
|
||||
/** Sectors contained in the image */
|
||||
@@ -1015,47 +1015,47 @@ typedef struct ImageInfo
|
||||
/** Sector tags contained by the image */
|
||||
// List<SectorTagType> ReadableSectorTags;
|
||||
/** Image version */
|
||||
uint8_t* Version;
|
||||
uint8_t *Version;
|
||||
/** Application that created the image */
|
||||
uint8_t* Application;
|
||||
uint8_t *Application;
|
||||
/** Version of the application that created the image */
|
||||
uint8_t* ApplicationVersion;
|
||||
uint8_t *ApplicationVersion;
|
||||
/** Who (person) created the image? */
|
||||
uint8_t* Creator;
|
||||
uint8_t *Creator;
|
||||
/** Image creation time */
|
||||
int64_t CreationTime;
|
||||
int64_t CreationTime;
|
||||
/** Image last modification time */
|
||||
int64_t LastModificationTime;
|
||||
int64_t LastModificationTime;
|
||||
/** Title of the media represented by the image */
|
||||
uint8_t* MediaTitle;
|
||||
uint8_t *MediaTitle;
|
||||
/** Image comments */
|
||||
uint8_t* Comments;
|
||||
uint8_t *Comments;
|
||||
/** Manufacturer of the media represented by the image */
|
||||
uint8_t* MediaManufacturer;
|
||||
uint8_t *MediaManufacturer;
|
||||
/** Model of the media represented by the image */
|
||||
uint8_t* MediaModel;
|
||||
uint8_t *MediaModel;
|
||||
/** Serial number of the media represented by the image */
|
||||
uint8_t* MediaSerialNumber;
|
||||
uint8_t *MediaSerialNumber;
|
||||
/** Barcode of the media represented by the image */
|
||||
uint8_t* MediaBarcode;
|
||||
uint8_t *MediaBarcode;
|
||||
/** Part number of the media represented by the image */
|
||||
uint8_t* MediaPartNumber;
|
||||
uint8_t *MediaPartNumber;
|
||||
/** Media type represented by the image */
|
||||
uint32_t MediaType;
|
||||
/** Number in sequence for the media represented by the image */
|
||||
int32_t MediaSequence;
|
||||
int32_t MediaSequence;
|
||||
/** Last media of the sequence the media represented by the image corresponds to */
|
||||
int32_t LastMediaSequence;
|
||||
int32_t LastMediaSequence;
|
||||
/** Manufacturer of the drive used to read the media represented by the image */
|
||||
uint8_t* DriveManufacturer;
|
||||
uint8_t *DriveManufacturer;
|
||||
/** Model of the drive used to read the media represented by the image */
|
||||
uint8_t* DriveModel;
|
||||
uint8_t *DriveModel;
|
||||
/** Serial number of the drive used to read the media represented by the image */
|
||||
uint8_t* DriveSerialNumber;
|
||||
uint8_t *DriveSerialNumber;
|
||||
/** Firmware revision of the drive used to read the media represented by the image */
|
||||
uint8_t* DriveFirmwareRevision;
|
||||
uint8_t *DriveFirmwareRevision;
|
||||
/** Type of the media represented by the image to use in XML sidecars */
|
||||
uint8_t XmlMediaType;
|
||||
uint8_t XmlMediaType;
|
||||
// CHS geometry...
|
||||
/** Cylinders of the media represented by the image */
|
||||
uint32_t Cylinders;
|
||||
@@ -1155,19 +1155,19 @@ typedef enum
|
||||
* On floppy disks, data in last cylinder usually in a different format that contains
|
||||
* duplication or manufacturing information
|
||||
*/
|
||||
Floppy_LeadOut = 59, /* DVD Disc Control Blocks */
|
||||
DCB = 60, /* Compact Disc First Track Pregap */
|
||||
CD_FirstTrackPregap = 61, /* Compact Disc Lead-out */
|
||||
CD_LeadOut = 62, /* SCSI MODE SENSE (6) */
|
||||
SCSI_MODESENSE_6 = 63, /* SCSI MODE SENSE (10) */
|
||||
SCSI_MODESENSE_10 = 64, /* USB descriptors */
|
||||
USB_Descriptors = 65, /* XGD unlocked DMI */
|
||||
Xbox_DMI = 66, /* XDG unlocked PFI */
|
||||
Xbox_PFI = 67, /* Compact Disc Lead-in */
|
||||
CD_LeadIn = 68
|
||||
Floppy_LeadOut = 59, /* DVD Disc Control Blocks */
|
||||
DCB = 60, /* Compact Disc First Track Pregap */
|
||||
CD_FirstTrackPregap = 61, /* Compact Disc Lead-out */
|
||||
CD_LeadOut = 62, /* SCSI MODE SENSE (6) */
|
||||
SCSI_MODESENSE_6 = 63, /* SCSI MODE SENSE (10) */
|
||||
SCSI_MODESENSE_10 = 64, /* USB descriptors */
|
||||
USB_Descriptors = 65, /* XGD unlocked DMI */
|
||||
Xbox_DMI = 66, /* XDG unlocked PFI */
|
||||
Xbox_PFI = 67, /* Compact Disc Lead-in */
|
||||
CD_LeadIn = 68
|
||||
} MediaTagType;
|
||||
|
||||
#endif // LIBAARUFORMAT_AARU_H
|
||||
#endif // LIBAARUFORMAT_AARU_H
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@@ -34,4 +34,4 @@
|
||||
#include "aaruformat/spamsum.h"
|
||||
#include "aaruformat/structs.h"
|
||||
|
||||
#endif // LIBAARUFORMAT_AARUFORMAT_H
|
||||
#endif // LIBAARUFORMAT_AARUFORMAT_H
|
||||
|
||||
@@ -18,40 +18,40 @@
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
||||
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
||||
#endif
|
||||
|
||||
#ifndef LIBAARUFORMAT_CONSTS_H
|
||||
#define LIBAARUFORMAT_CONSTS_H
|
||||
|
||||
/** Magic identidier = "DICMFRMT". */
|
||||
#define DIC_MAGIC 0x544D52464D434944
|
||||
#define DIC_MAGIC 0x544D52464D434944
|
||||
/** Magic identidier = "AARUFRMT". */
|
||||
#define AARU_MAGIC 0x544D524655524141
|
||||
#define AARU_MAGIC 0x544D524655524141
|
||||
/** Image format version. A change in this number indicates an incompatible change to the format that prevents older
|
||||
* implementations from reading it correctly, if at all. */
|
||||
#define AARUF_VERSION 1
|
||||
#define AARUF_VERSION 1
|
||||
/** Maximum read cache size, 512MiB. */
|
||||
#define MAX_CACHE_SIZE 536870912
|
||||
#define MAX_CACHE_SIZE 536870912
|
||||
/** Size in bytes of LZMA properties. */
|
||||
#define LZMA_PROPERTIES_LENGTH 5
|
||||
/** Maximum number of entries for the DDT cache. */
|
||||
#define MAX_DDT_ENTRY_CACHE 16000000
|
||||
#define MAX_DDT_ENTRY_CACHE 16000000
|
||||
/** How many samples are contained in a RedBook sector. */
|
||||
#define SAMPLES_PER_SECTOR 588
|
||||
#define SAMPLES_PER_SECTOR 588
|
||||
/** Maximum number of samples for a FLAC block. Bigger than 4608 gives no benefit. */
|
||||
#define MAX_FLAKE_BLOCK 4608
|
||||
#define MAX_FLAKE_BLOCK 4608
|
||||
/** Minimum number of samples for a FLAC block. CUETools.Codecs.FLAKE does not support it to be smaller than 256. */
|
||||
#define MIN_FLAKE_BLOCK 256
|
||||
#define MIN_FLAKE_BLOCK 256
|
||||
/** This mask is to check for flags in CompactDisc suffix/prefix DDT */
|
||||
#define CD_XFIX_MASK 0xFF000000
|
||||
#define CD_XFIX_MASK 0xFF000000
|
||||
/** This mask is to check for position in CompactDisc suffix/prefix deduplicated block */
|
||||
#define CD_DFIX_MASK 0x00FFFFFF
|
||||
#define CD_DFIX_MASK 0x00FFFFFF
|
||||
|
||||
#define CRC64_ECMA_POLY 0xC96C5795D7870F42
|
||||
#define CRC64_ECMA_SEED 0xFFFFFFFFFFFFFFFF
|
||||
|
||||
#endif // LIBAARUFORMAT_CONSTS_H
|
||||
#endif // LIBAARUFORMAT_CONSTS_H
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@@ -43,12 +43,12 @@ typedef struct Checksums
|
||||
uint8_t md5[MD5_DIGEST_LENGTH];
|
||||
uint8_t sha1[SHA1_DIGEST_LENGTH];
|
||||
uint8_t sha256[SHA256_DIGEST_LENGTH];
|
||||
uint8_t* spamsum;
|
||||
uint8_t *spamsum;
|
||||
} Checksums;
|
||||
|
||||
typedef struct mediaTagEntry
|
||||
{
|
||||
uint8_t* data;
|
||||
uint8_t *data;
|
||||
int32_t type;
|
||||
uint32_t length;
|
||||
UT_hash_handle hh;
|
||||
@@ -59,52 +59,52 @@ typedef struct aaruformatContext
|
||||
uint64_t magic;
|
||||
uint8_t libraryMajorVersion;
|
||||
uint8_t libraryMinorVersion;
|
||||
FILE* imageStream;
|
||||
FILE *imageStream;
|
||||
AaruHeader header;
|
||||
uint8_t* sectorPrefix;
|
||||
uint8_t* sectorPrefixCorrected;
|
||||
uint8_t* sectorSuffix;
|
||||
uint8_t* sectorSuffixCorrected;
|
||||
uint8_t* sectorSubchannel;
|
||||
uint8_t* mode2Subheaders;
|
||||
uint8_t *sectorPrefix;
|
||||
uint8_t *sectorPrefixCorrected;
|
||||
uint8_t *sectorSuffix;
|
||||
uint8_t *sectorSuffixCorrected;
|
||||
uint8_t *sectorSubchannel;
|
||||
uint8_t *mode2Subheaders;
|
||||
uint8_t shift;
|
||||
bool inMemoryDdt;
|
||||
uint64_t* userDataDdt;
|
||||
uint64_t *userDataDdt;
|
||||
size_t mappedMemoryDdtSize;
|
||||
uint32_t* sectorPrefixDdt;
|
||||
uint32_t* sectorSuffixDdt;
|
||||
uint32_t *sectorPrefixDdt;
|
||||
uint32_t *sectorSuffixDdt;
|
||||
GeometryBlockHeader geometryBlock;
|
||||
MetadataBlockHeader metadataBlockHeader;
|
||||
uint8_t* metadataBlock;
|
||||
uint8_t *metadataBlock;
|
||||
TracksHeader tracksHeader;
|
||||
TrackEntry* trackEntries;
|
||||
TrackEntry *trackEntries;
|
||||
CicmMetadataBlock cicmBlockHeader;
|
||||
uint8_t* cicmBlock;
|
||||
uint8_t *cicmBlock;
|
||||
DumpHardwareHeader dumpHardwareHeader;
|
||||
struct DumpHardwareEntriesWithData* dumpHardwareEntriesWithData;
|
||||
struct DumpHardwareEntriesWithData *dumpHardwareEntriesWithData;
|
||||
struct ImageInfo imageInfo;
|
||||
CdEccContext* eccCdContext;
|
||||
CdEccContext *eccCdContext;
|
||||
uint8_t numberOfDataTracks;
|
||||
TrackEntry* dataTracks;
|
||||
bool* readableSectorTags;
|
||||
TrackEntry *dataTracks;
|
||||
bool *readableSectorTags;
|
||||
struct CacheHeader blockHeaderCache;
|
||||
struct CacheHeader blockCache;
|
||||
struct Checksums checksums;
|
||||
struct mediaTagEntry* mediaTags;
|
||||
struct mediaTagEntry *mediaTags;
|
||||
} aaruformatContext;
|
||||
|
||||
typedef struct DumpHardwareEntriesWithData
|
||||
{
|
||||
DumpHardwareEntry entry;
|
||||
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;
|
||||
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;
|
||||
} DumpHardwareEntriesWithData;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
@@ -117,4 +117,4 @@ typedef struct DumpExtent
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // LIBAARUFORMAT_CONTEXT_H
|
||||
#endif // LIBAARUFORMAT_CONTEXT_H
|
||||
|
||||
@@ -232,9 +232,10 @@ const static uint64_t crc64_table[4][256] = {
|
||||
0xA0A13C6791602FF9, 0xBD4FB639B34C8E25, 0x9B7C28DBD5396C41, 0x8692A285F715CD9D, 0xD71B151F19D2A889,
|
||||
0xCAF59F413BFE0955, 0xECC601A35D8BEB31, 0xF1288BFD7FA74AED, 0x4FD56E9680052119, 0x523BE4C8A22980C5,
|
||||
0x74087A2AC45C62A1, 0x69E6F074E670C37D, 0x386F47EE08B7A669, 0x2581CDB02A9B07B5, 0x03B253524CEEE5D1,
|
||||
0x1E5CD90C6EC2440D}};
|
||||
0x1E5CD90C6EC2440D}
|
||||
};
|
||||
|
||||
#define CRC64_ECMA_POLY 0xC96C5795D7870F42
|
||||
#define CRC64_ECMA_SEED 0xFFFFFFFFFFFFFFFF
|
||||
|
||||
#endif // LIBAARUFORMAT_CRC64_H
|
||||
#endif // LIBAARUFORMAT_CRC64_H
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define AARU_CALL __stdcall
|
||||
#define AARU_CALL __stdcall
|
||||
#define AARU_EXPORT EXTERNC __declspec(dllexport)
|
||||
#define AARU_LOCAL
|
||||
#ifndef PATH_MAX
|
||||
@@ -38,11 +38,11 @@
|
||||
#define AARU_CALL
|
||||
#if defined(__APPLE__)
|
||||
#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
|
||||
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
||||
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
|
||||
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
||||
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
||||
#else
|
||||
#define AARU_EXPORT EXTERNC
|
||||
#define AARU_LOCAL
|
||||
@@ -56,149 +56,104 @@
|
||||
#define FORCE_INLINE static inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
AARU_EXPORT int AARU_CALL aaruf_identify(const char* filename);
|
||||
AARU_EXPORT int AARU_CALL aaruf_identify(const char *filename);
|
||||
|
||||
AARU_EXPORT int AARU_CALL aaruf_identify_stream(FILE* imageStream);
|
||||
AARU_EXPORT int AARU_CALL aaruf_identify_stream(FILE *imageStream);
|
||||
|
||||
AARU_EXPORT void* AARU_CALL aaruf_open(const char* filepath);
|
||||
AARU_EXPORT void *AARU_CALL aaruf_open(const char *filepath);
|
||||
|
||||
AARU_EXPORT int AARU_CALL aaruf_close(void* context);
|
||||
AARU_EXPORT int AARU_CALL aaruf_close(void *context);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* length);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_read_media_tag(void *context, uint8_t *data, int32_t tag, uint32_t *length);
|
||||
|
||||
AARU_EXPORT crc64_ctx* AARU_CALL aaruf_crc64_init();
|
||||
AARU_EXPORT int AARU_CALL aaruf_crc64_update(crc64_ctx* ctx, const uint8_t* data, uint32_t len);
|
||||
AARU_EXPORT int AARU_CALL aaruf_crc64_final(crc64_ctx* ctx, uint64_t* crc);
|
||||
AARU_EXPORT void AARU_CALL aaruf_crc64_free(crc64_ctx* ctx);
|
||||
AARU_EXPORT void AARU_CALL aaruf_crc64_slicing(uint64_t* previous_crc, const uint8_t* data, uint32_t len);
|
||||
AARU_EXPORT uint64_t AARU_CALL aaruf_crc64_data(const uint8_t* data, uint32_t len);
|
||||
AARU_EXPORT crc64_ctx *AARU_CALL aaruf_crc64_init();
|
||||
AARU_EXPORT int AARU_CALL aaruf_crc64_update(crc64_ctx *ctx, const uint8_t *data, uint32_t len);
|
||||
AARU_EXPORT int AARU_CALL aaruf_crc64_final(crc64_ctx *ctx, uint64_t *crc);
|
||||
AARU_EXPORT void AARU_CALL aaruf_crc64_free(crc64_ctx *ctx);
|
||||
AARU_EXPORT void AARU_CALL aaruf_crc64_slicing(uint64_t *previous_crc, const uint8_t *data, uint32_t len);
|
||||
AARU_EXPORT uint64_t AARU_CALL aaruf_crc64_data(const uint8_t *data, uint32_t len);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32_t* length);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void* context,
|
||||
uint64_t sectorAddress,
|
||||
uint8_t* data,
|
||||
uint32_t* length);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32_t *length);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void *context, uint64_t sectorAddress, uint8_t *data,
|
||||
uint32_t *length);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_verify_image(void* context);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_verify_image(void *context);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t length);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t length);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t length);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_cst_untransform(const uint8_t *sequential, uint8_t *interleaved, size_t length);
|
||||
|
||||
AARU_EXPORT void* AARU_CALL aaruf_ecc_cd_init();
|
||||
AARU_EXPORT void *AARU_CALL aaruf_ecc_cd_init();
|
||||
|
||||
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct(void* context, const uint8_t* sector);
|
||||
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct(void *context, const uint8_t *sector);
|
||||
|
||||
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct_mode2(void* context, const uint8_t* sector);
|
||||
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector);
|
||||
|
||||
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_check(void* context,
|
||||
const uint8_t* address,
|
||||
const uint8_t* data,
|
||||
uint32_t majorCount,
|
||||
uint32_t minorCount,
|
||||
uint32_t majorMult,
|
||||
uint32_t minorInc,
|
||||
const uint8_t* ecc,
|
||||
int32_t addressOffset,
|
||||
int32_t dataOffset,
|
||||
int32_t eccOffset);
|
||||
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_check(void *context, const uint8_t *address, const uint8_t *data,
|
||||
uint32_t majorCount, uint32_t minorCount, uint32_t majorMult,
|
||||
uint32_t minorInc, const uint8_t *ecc, int32_t addressOffset,
|
||||
int32_t dataOffset, int32_t eccOffset);
|
||||
|
||||
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_write(void* context,
|
||||
const uint8_t* address,
|
||||
const uint8_t* data,
|
||||
uint32_t majorCount,
|
||||
uint32_t minorCount,
|
||||
uint32_t majorMult,
|
||||
uint32_t minorInc,
|
||||
uint8_t* ecc,
|
||||
int32_t addressOffset,
|
||||
int32_t dataOffset,
|
||||
int32_t eccOffset);
|
||||
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_write(void *context, const uint8_t *address, const uint8_t *data,
|
||||
uint32_t majorCount, uint32_t minorCount, uint32_t majorMult,
|
||||
uint32_t minorInc, uint8_t *ecc, int32_t addressOffset,
|
||||
int32_t dataOffset, int32_t eccOffset);
|
||||
|
||||
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_write_sector(void* context,
|
||||
const uint8_t* address,
|
||||
const uint8_t* data,
|
||||
uint8_t* ecc,
|
||||
int32_t addressOffset,
|
||||
int32_t dataOffset,
|
||||
int32_t eccOffset);
|
||||
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_write_sector(void *context, const uint8_t *address, const uint8_t *data,
|
||||
uint8_t *ecc, int32_t addressOffset, int32_t dataOffset,
|
||||
int32_t eccOffset);
|
||||
|
||||
AARU_LOCAL void AARU_CALL aaruf_cd_lba_to_msf(int64_t pos, uint8_t* minute, uint8_t* second, uint8_t* frame);
|
||||
AARU_LOCAL void AARU_CALL aaruf_cd_lba_to_msf(int64_t pos, uint8_t *minute, uint8_t *second, uint8_t *frame);
|
||||
|
||||
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_reconstruct_prefix(uint8_t* sector, uint8_t type, int64_t lba);
|
||||
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_reconstruct_prefix(uint8_t *sector, uint8_t type, int64_t lba);
|
||||
|
||||
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_reconstruct(void* context, uint8_t* sector, uint8_t type);
|
||||
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_reconstruct(void *context, uint8_t *sector, uint8_t type);
|
||||
|
||||
AARU_EXPORT uint32_t AARU_CALL aaruf_edc_cd_compute(void* context, uint32_t edc, const uint8_t* src, int size, int pos);
|
||||
AARU_EXPORT uint32_t AARU_CALL aaruf_edc_cd_compute(void *context, uint32_t edc, const uint8_t *src, int size, int pos);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL
|
||||
aaruf_read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress, uint32_t* length, uint8_t track);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_read_track_sector(void *context, uint8_t *data, uint64_t sectorAddress,
|
||||
uint32_t *length, uint8_t track);
|
||||
|
||||
AARU_LOCAL int32_t AARU_CALL aaruf_get_media_tag_type_for_datatype(int32_t type);
|
||||
|
||||
AARU_LOCAL int32_t AARU_CALL aaruf_get_xml_mediatype(int32_t type);
|
||||
|
||||
AARU_EXPORT spamsum_ctx* AARU_CALL aaruf_spamsum_init(void);
|
||||
AARU_EXPORT int AARU_CALL aaruf_spamsum_update(spamsum_ctx* ctx, const uint8_t* data, uint32_t len);
|
||||
AARU_EXPORT int AARU_CALL aaruf_spamsum_final(spamsum_ctx* ctx, uint8_t* result);
|
||||
AARU_EXPORT void AARU_CALL aaruf_spamsum_free(spamsum_ctx* ctx);
|
||||
AARU_EXPORT spamsum_ctx *AARU_CALL aaruf_spamsum_init(void);
|
||||
AARU_EXPORT int AARU_CALL aaruf_spamsum_update(spamsum_ctx *ctx, const uint8_t *data, uint32_t len);
|
||||
AARU_EXPORT int AARU_CALL aaruf_spamsum_final(spamsum_ctx *ctx, uint8_t *result);
|
||||
AARU_EXPORT void AARU_CALL aaruf_spamsum_free(spamsum_ctx *ctx);
|
||||
|
||||
AARU_LOCAL void fuzzy_engine_step(spamsum_ctx* ctx, uint8_t c);
|
||||
AARU_LOCAL void roll_hash(spamsum_ctx* ctx, uint8_t c);
|
||||
AARU_LOCAL void fuzzy_try_reduce_blockhash(spamsum_ctx* ctx);
|
||||
AARU_LOCAL void fuzzy_try_fork_blockhash(spamsum_ctx* ctx);
|
||||
AARU_LOCAL void fuzzy_engine_step(spamsum_ctx *ctx, uint8_t c);
|
||||
AARU_LOCAL void roll_hash(spamsum_ctx *ctx, uint8_t c);
|
||||
AARU_LOCAL void fuzzy_try_reduce_blockhash(spamsum_ctx *ctx);
|
||||
AARU_LOCAL void fuzzy_try_fork_blockhash(spamsum_ctx *ctx);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL aaruf_flac_decode_redbook_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size);
|
||||
AARU_EXPORT size_t AARU_CALL aaruf_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size,
|
||||
const uint8_t *src_buffer, size_t src_size);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL aaruf_flac_encode_redbook_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size,
|
||||
uint32_t blocksize,
|
||||
int32_t do_mid_side_stereo,
|
||||
int32_t loose_mid_side_stereo,
|
||||
const char* apodization,
|
||||
uint32_t max_lpc_order,
|
||||
uint32_t qlp_coeff_precision,
|
||||
int32_t do_qlp_coeff_prec_search,
|
||||
int32_t do_exhaustive_model_search,
|
||||
uint32_t min_residual_partition_order,
|
||||
uint32_t max_residual_partition_order,
|
||||
const char* application_id,
|
||||
uint32_t application_id_len);
|
||||
AARU_EXPORT size_t AARU_CALL aaruf_flac_encode_redbook_buffer(
|
||||
uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize,
|
||||
int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order,
|
||||
uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
|
||||
uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id,
|
||||
uint32_t application_id_len);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_lzma_decode_buffer(uint8_t* dst_buffer,
|
||||
size_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t* src_size,
|
||||
const uint8_t* props,
|
||||
size_t propsSize);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_lzma_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
|
||||
size_t *src_size, const uint8_t *props, size_t propsSize);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_lzma_encode_buffer(uint8_t* dst_buffer,
|
||||
size_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size,
|
||||
uint8_t* outProps,
|
||||
size_t* outPropsSize,
|
||||
int32_t level,
|
||||
uint32_t dictSize,
|
||||
int32_t lc,
|
||||
int32_t lp,
|
||||
int32_t pb,
|
||||
int32_t fb,
|
||||
int32_t numThreads);
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_lzma_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
|
||||
size_t src_size, uint8_t *outProps, size_t *outPropsSize,
|
||||
int32_t level, uint32_t dictSize, int32_t lc, int32_t lp,
|
||||
int32_t pb, int32_t fb, int32_t numThreads);
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
|
||||
AARU_EXPORT int have_clmul();
|
||||
AARU_EXPORT int have_ssse3();
|
||||
AARU_EXPORT int have_avx2();
|
||||
|
||||
AARU_EXPORT CLMUL uint64_t AARU_CALL aaruf_crc64_clmul(uint64_t crc, const uint8_t* data, long length);
|
||||
AARU_EXPORT CLMUL uint64_t AARU_CALL aaruf_crc64_clmul(uint64_t crc, const uint8_t *data, long length);
|
||||
#endif
|
||||
|
||||
#if defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__) || defined(_M_ARM)
|
||||
@@ -206,7 +161,7 @@ AARU_EXPORT int have_neon();
|
||||
AARU_EXPORT int have_arm_crc32();
|
||||
AARU_EXPORT int have_arm_crypto();
|
||||
|
||||
AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previous_crc, const uint8_t* data, long len);
|
||||
AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previous_crc, const uint8_t *data, long len);
|
||||
#endif
|
||||
|
||||
#endif // LIBAARUFORMAT_DECLS_H
|
||||
#endif // LIBAARUFORMAT_DECLS_H
|
||||
|
||||
@@ -58,8 +58,8 @@
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <machine/bswap.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(__BSWAP_RENAME) && !defined(__bswap_32)
|
||||
#define bswap_16(x) bswap16(x)
|
||||
#define bswap_32(x) bswap32(x)
|
||||
@@ -74,16 +74,16 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define bswap_16(x) ((uint16_t)((((uint16_t)(x)&0xff00) >> 8) | (((uint16_t)(x)&0x00ff) << 8)))
|
||||
#define bswap_32(x) \
|
||||
((uint32_t)((((uint32_t)(x)&0xff000000) >> 24) | (((uint32_t)(x)&0x00ff0000) >> 8) | \
|
||||
(((uint32_t)(x)&0x0000ff00) << 8) | (((uint32_t)(x)&0x000000ff) << 24)))
|
||||
#define bswap_64(x) \
|
||||
((uint64_t)((((uint64_t)(x)&0xff00000000000000ULL) >> 56) | (((uint64_t)(x)&0x00ff000000000000ULL) >> 40) | \
|
||||
(((uint64_t)(x)&0x0000ff0000000000ULL) >> 24) | (((uint64_t)(x)&0x000000ff00000000ULL) >> 8) | \
|
||||
(((uint64_t)(x)&0x00000000ff000000ULL) << 8) | (((uint64_t)(x)&0x0000000000ff0000ULL) << 24) | \
|
||||
(((uint64_t)(x)&0x000000000000ff00ULL) << 40) | (((uint64_t)(x)&0x00000000000000ffULL) << 56)))
|
||||
#define bswap_16(x) ((uint16_t)((((uint16_t)(x) & 0xff00) >> 8) | (((uint16_t)(x) & 0x00ff) << 8)))
|
||||
#define bswap_32(x) \
|
||||
((uint32_t)((((uint32_t)(x) & 0xff000000) >> 24) | (((uint32_t)(x) & 0x00ff0000) >> 8) | \
|
||||
(((uint32_t)(x) & 0x0000ff00) << 8) | (((uint32_t)(x) & 0x000000ff) << 24)))
|
||||
#define bswap_64(x) \
|
||||
((uint64_t)((((uint64_t)(x) & 0xff00000000000000ULL) >> 56) | (((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
|
||||
(((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | (((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
|
||||
(((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | (((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
|
||||
(((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | (((uint64_t)(x) & 0x00000000000000ffULL) << 56)))
|
||||
|
||||
#endif
|
||||
|
||||
#endif //LIBAARUFORMAT_ENDIAN_H
|
||||
#endif // LIBAARUFORMAT_ENDIAN_H
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#endif
|
||||
|
||||
#ifndef LIBAARUFORMAT_ENUMS_H
|
||||
@@ -38,196 +38,196 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
/** No data */
|
||||
NoData = 0,
|
||||
NoData = 0,
|
||||
/** User data */
|
||||
UserData = 1,
|
||||
UserData = 1,
|
||||
/** CompactDisc partial Table of Contents */
|
||||
CompactDiscPartialToc = 2,
|
||||
CompactDiscPartialToc = 2,
|
||||
/** CompactDisc session information */
|
||||
CompactDiscSessionInfo = 3,
|
||||
CompactDiscSessionInfo = 3,
|
||||
/** CompactDisc Table of Contents */
|
||||
CompactDiscToc = 4,
|
||||
CompactDiscToc = 4,
|
||||
/** CompactDisc Power Management Area */
|
||||
CompactDiscPma = 5,
|
||||
CompactDiscPma = 5,
|
||||
/** CompactDisc Absolute Time In Pregroove */
|
||||
CompactDiscAtip = 6,
|
||||
CompactDiscAtip = 6,
|
||||
/** CompactDisc Lead-in's CD-Text */
|
||||
CompactDiscLeadInCdText = 7,
|
||||
CompactDiscLeadInCdText = 7,
|
||||
/** DVD Physical Format Information */
|
||||
DvdPfi = 8,
|
||||
DvdPfi = 8,
|
||||
/** DVD Lead-in's Copyright Management Information */
|
||||
DvdLeadInCmi = 9,
|
||||
DvdLeadInCmi = 9,
|
||||
/** DVD Disc Key */
|
||||
DvdDiscKey = 10,
|
||||
DvdDiscKey = 10,
|
||||
/** DVD Burst Cutting Area */
|
||||
DvdBca = 11,
|
||||
DvdBca = 11,
|
||||
/** DVD DMI */
|
||||
DvdDmi = 12,
|
||||
DvdDmi = 12,
|
||||
/** DVD Media Identifier */
|
||||
DvdMediaIdentifier = 13,
|
||||
DvdMediaIdentifier = 13,
|
||||
/** DVD Media Key Block */
|
||||
DvdMediaKeyBlock = 14,
|
||||
DvdMediaKeyBlock = 14,
|
||||
/** DVD-RAM Disc Definition Structure */
|
||||
DvdRamDds = 15,
|
||||
DvdRamDds = 15,
|
||||
/** DVD-RAM Medium Status */
|
||||
DvdRamMediumStatus = 16,
|
||||
DvdRamMediumStatus = 16,
|
||||
/** DVD-RAM Spare Area Information */
|
||||
DvdRamSpareArea = 17,
|
||||
DvdRamSpareArea = 17,
|
||||
/** DVD-R RMD */
|
||||
DvdRRmd = 18,
|
||||
DvdRRmd = 18,
|
||||
/** DVD-R Pre-recorded Information */
|
||||
DvdRPrerecordedInfo = 19,
|
||||
DvdRPrerecordedInfo = 19,
|
||||
/** DVD-R Media Identifier */
|
||||
DvdRMediaIdentifier = 20,
|
||||
DvdRMediaIdentifier = 20,
|
||||
/** DVD-R Physical Format Information */
|
||||
DvdRPfi = 21,
|
||||
DvdRPfi = 21,
|
||||
/** DVD ADress In Pregroove */
|
||||
DvdAdip = 22,
|
||||
DvdAdip = 22,
|
||||
/** HD DVD Copy Protection Information */
|
||||
HdDvdCpi = 23,
|
||||
HdDvdCpi = 23,
|
||||
/** HD DVD Medium Status */
|
||||
HdDvdMediumStatus = 24,
|
||||
HdDvdMediumStatus = 24,
|
||||
/** DVD DL Layer Capacity */
|
||||
DvdDlLayerCapacity = 25,
|
||||
DvdDlLayerCapacity = 25,
|
||||
/** DVD DL Middle Zone Address */
|
||||
DvdDlMiddleZoneAddress = 26,
|
||||
DvdDlMiddleZoneAddress = 26,
|
||||
/** DVD DL Jump Interval Size */
|
||||
DvdDlJumpIntervalSize = 27,
|
||||
DvdDlJumpIntervalSize = 27,
|
||||
/** DVD DL Manual Layer Jump LBA */
|
||||
DvdDlManualLayerJumpLba = 28,
|
||||
DvdDlManualLayerJumpLba = 28,
|
||||
/** Bluray Disc Information */
|
||||
BlurayDi = 29,
|
||||
BlurayDi = 29,
|
||||
/** Bluray Burst Cutting Area */
|
||||
BlurayBca = 30,
|
||||
BlurayBca = 30,
|
||||
/** Bluray Disc Definition Structure */
|
||||
BlurayDds = 31,
|
||||
BlurayDds = 31,
|
||||
/** Bluray Cartridge Status */
|
||||
BlurayCartridgeStatus = 32,
|
||||
BlurayCartridgeStatus = 32,
|
||||
/** Bluray Spare Area Information */
|
||||
BluraySpareArea = 33,
|
||||
BluraySpareArea = 33,
|
||||
/** AACS Volume Identifier */
|
||||
AacsVolumeIdentifier = 34,
|
||||
AacsVolumeIdentifier = 34,
|
||||
/** AACS Serial Number */
|
||||
AacsSerialNumber = 35,
|
||||
AacsSerialNumber = 35,
|
||||
/** AACS Media Identifier */
|
||||
AacsMediaIdentifier = 36,
|
||||
AacsMediaIdentifier = 36,
|
||||
/** AACS Media Key Block */
|
||||
AacsMediaKeyBlock = 37,
|
||||
AacsMediaKeyBlock = 37,
|
||||
/** AACS Data Keys */
|
||||
AacsDataKeys = 38,
|
||||
AacsDataKeys = 38,
|
||||
/** AACS LBA Extents */
|
||||
AacsLbaExtents = 39,
|
||||
AacsLbaExtents = 39,
|
||||
/** CPRM Media Key Block */
|
||||
CprmMediaKeyBlock = 40,
|
||||
CprmMediaKeyBlock = 40,
|
||||
/** Recognized Layers */
|
||||
HybridRecognizedLayers = 41,
|
||||
HybridRecognizedLayers = 41,
|
||||
/** MMC Write Protection */
|
||||
ScsiMmcWriteProtection = 42,
|
||||
ScsiMmcWriteProtection = 42,
|
||||
/** MMC Disc Information */
|
||||
ScsiMmcDiscInformation = 43,
|
||||
ScsiMmcDiscInformation = 43,
|
||||
/** MMC Track Resources Information */
|
||||
ScsiMmcTrackResourcesInformation = 44,
|
||||
/** MMC POW Resources Information */
|
||||
ScsiMmcPowResourcesInformation = 45,
|
||||
ScsiMmcPowResourcesInformation = 45,
|
||||
/** SCSI INQUIRY RESPONSE */
|
||||
ScsiInquiry = 46,
|
||||
ScsiInquiry = 46,
|
||||
/** SCSI MODE PAGE 2Ah */
|
||||
ScsiModePage2A = 47,
|
||||
ScsiModePage2A = 47,
|
||||
/** ATA IDENTIFY response */
|
||||
AtaIdentify = 48,
|
||||
AtaIdentify = 48,
|
||||
/** ATAPI IDENTIFY response */
|
||||
AtapiIdentify = 49,
|
||||
AtapiIdentify = 49,
|
||||
/** PCMCIA CIS */
|
||||
PcmciaCis = 50,
|
||||
PcmciaCis = 50,
|
||||
/** SecureDigital CID */
|
||||
SecureDigitalCid = 51,
|
||||
SecureDigitalCid = 51,
|
||||
/** SecureDigital CSD */
|
||||
SecureDigitalCsd = 52,
|
||||
SecureDigitalCsd = 52,
|
||||
/** SecureDigital SCR */
|
||||
SecureDigitalScr = 53,
|
||||
SecureDigitalScr = 53,
|
||||
/** SecureDigital OCR */
|
||||
SecureDigitalOcr = 54,
|
||||
SecureDigitalOcr = 54,
|
||||
/** MultiMediaCard CID */
|
||||
MultiMediaCardCid = 55,
|
||||
MultiMediaCardCid = 55,
|
||||
/** MultiMediaCard CSD */
|
||||
MultiMediaCardCsd = 56,
|
||||
MultiMediaCardCsd = 56,
|
||||
/** MultiMediaCard OCR */
|
||||
MultiMediaCardOcr = 57,
|
||||
MultiMediaCardOcr = 57,
|
||||
/** MultiMediaCard Extended CSD */
|
||||
MultiMediaCardExtendedCsd = 58,
|
||||
MultiMediaCardExtendedCsd = 58,
|
||||
/** Xbox Security Sector */
|
||||
XboxSecuritySector = 59,
|
||||
XboxSecuritySector = 59,
|
||||
/** Floppy Lead-out */
|
||||
FloppyLeadOut = 60,
|
||||
FloppyLeadOut = 60,
|
||||
/** Dvd Disc Control Block */
|
||||
DvdDiscControlBlock = 61,
|
||||
DvdDiscControlBlock = 61,
|
||||
/** CompactDisc First track pregap */
|
||||
CompactDiscFirstTrackPregap = 62,
|
||||
CompactDiscFirstTrackPregap = 62,
|
||||
/** CompactDisc Lead-out */
|
||||
CompactDiscLeadOut = 63,
|
||||
CompactDiscLeadOut = 63,
|
||||
/** SCSI MODE SENSE (6) response */
|
||||
ScsiModeSense6 = 64,
|
||||
ScsiModeSense6 = 64,
|
||||
/** SCSI MODE SENSE (10) response */
|
||||
ScsiModeSense10 = 65,
|
||||
ScsiModeSense10 = 65,
|
||||
/** USB descriptors */
|
||||
UsbDescriptors = 66,
|
||||
UsbDescriptors = 66,
|
||||
/** Xbox DMI */
|
||||
XboxDmi = 67,
|
||||
XboxDmi = 67,
|
||||
/** Xbox Physical Format Information */
|
||||
XboxPfi = 68,
|
||||
XboxPfi = 68,
|
||||
/** CompactDisc sector prefix (sync, header */
|
||||
CdSectorPrefix = 69,
|
||||
CdSectorPrefix = 69,
|
||||
/** CompactDisc sector suffix (edc, ecc p, ecc q) */
|
||||
CdSectorSuffix = 70,
|
||||
CdSectorSuffix = 70,
|
||||
/** CompactDisc subchannel */
|
||||
CdSectorSubchannel = 71,
|
||||
CdSectorSubchannel = 71,
|
||||
/** Apple Profile (20 byte) tag */
|
||||
AppleProfileTag = 72,
|
||||
AppleProfileTag = 72,
|
||||
/** Apple Sony (12 byte) tag */
|
||||
AppleSonyTag = 73,
|
||||
AppleSonyTag = 73,
|
||||
/** Priam Data Tower (24 byte) tag */
|
||||
PriamDataTowerTag = 74,
|
||||
PriamDataTowerTag = 74,
|
||||
/** CompactDisc Media Catalogue Number (as in Lead-in), 13 bytes, ASCII */
|
||||
CompactDiscMediaCatalogueNumber = 75,
|
||||
CompactDiscMediaCatalogueNumber = 75,
|
||||
/** CompactDisc sector prefix (sync, header), only incorrect stored */
|
||||
CdSectorPrefixCorrected = 76,
|
||||
CdSectorPrefixCorrected = 76,
|
||||
/** CompactDisc sector suffix (edc, ecc p, ecc q), only incorrect stored */
|
||||
CdSectorSuffixCorrected = 77,
|
||||
CdSectorSuffixCorrected = 77,
|
||||
/** CompactDisc MODE 2 subheader */
|
||||
CompactDiscMode2Subheader = 78,
|
||||
CompactDiscMode2Subheader = 78,
|
||||
/** CompactDisc Lead-in */
|
||||
CompactDiscLeadIn = 79
|
||||
CompactDiscLeadIn = 79
|
||||
} DataType;
|
||||
|
||||
/** List of known blocks types */
|
||||
typedef enum
|
||||
{
|
||||
/** Block containing data */
|
||||
DataBlock = 0x4B4C4244,
|
||||
DataBlock = 0x4B4C4244,
|
||||
/** Block containing a deduplication table */
|
||||
DeDuplicationTable = 0X2A544444,
|
||||
DeDuplicationTable = 0X2A544444,
|
||||
/** Block containing the index */
|
||||
IndexBlock = 0X58444E49,
|
||||
IndexBlock = 0X58444E49,
|
||||
/** Block containing logical geometry */
|
||||
GeometryBlock = 0x4D4F4547,
|
||||
GeometryBlock = 0x4D4F4547,
|
||||
/** Block containing metadata */
|
||||
MetadataBlock = 0x4154454D,
|
||||
MetadataBlock = 0x4154454D,
|
||||
/** Block containing optical disc tracks */
|
||||
TracksBlock = 0x534B5254,
|
||||
TracksBlock = 0x534B5254,
|
||||
/** Block containing CICM XML metadata */
|
||||
CicmBlock = 0x4D434943,
|
||||
CicmBlock = 0x4D434943,
|
||||
/** Block containing contents checksums */
|
||||
ChecksumBlock = 0x4D534B43,
|
||||
ChecksumBlock = 0x4D534B43,
|
||||
/** TODO: Block containing data position measurements */
|
||||
DataPositionMeasurementBlock = 0x2A4D5044,
|
||||
/** TODO: Block containing a snapshot index */
|
||||
SnapshotBlock = 0x50414E53,
|
||||
SnapshotBlock = 0x50414E53,
|
||||
/** TODO: Block containing how to locate the parent image */
|
||||
ParentBlock = 0x50524E54,
|
||||
ParentBlock = 0x50524E54,
|
||||
/** Block containing an array of hardware used to create the image */
|
||||
DumpHardwareBlock = 0x2A504D44,
|
||||
DumpHardwareBlock = 0x2A504D44,
|
||||
/** TODO: Block containing list of files for a tape image */
|
||||
TapeFileBlock = 0x454C4654
|
||||
TapeFileBlock = 0x454C4654
|
||||
} BlockType;
|
||||
|
||||
typedef enum
|
||||
@@ -277,16 +277,16 @@ typedef enum
|
||||
* Media that is physically block-based or abstracted like that
|
||||
|
||||
*/
|
||||
BlockMedia = 1, /**
|
||||
BlockMedia = 1, /**
|
||||
* Media that can be accessed by-byte or by-bit, like chips
|
||||
*/
|
||||
LinearMedia = 2, /**
|
||||
* Media that can only store data when it is modulated to audio
|
||||
*/
|
||||
AudioMedia = 3
|
||||
AudioMedia = 3
|
||||
} XmlMediaType;
|
||||
|
||||
#endif // LIBAARUFORMAT_ENUMS_H
|
||||
#endif // LIBAARUFORMAT_ENUMS_H
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@@ -19,28 +19,28 @@
|
||||
#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_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_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_STATUS_OK 0
|
||||
#define AARUF_STATUS_SECTOR_NOT_DUMPED 1
|
||||
#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
|
||||
#define AARUF_STATUS_SECTOR_DELETED 3
|
||||
|
||||
#endif // LIBAARUFORMAT_ERRORS_H
|
||||
#endif // LIBAARUFORMAT_ERRORS_H
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const uint8_t* src_buffer;
|
||||
const uint8_t *src_buffer;
|
||||
size_t src_len;
|
||||
size_t src_pos;
|
||||
uint8_t* dst_buffer;
|
||||
uint8_t *dst_buffer;
|
||||
size_t dst_len;
|
||||
size_t dst_pos;
|
||||
uint8_t error;
|
||||
} aaru_flac_ctx;
|
||||
|
||||
#endif // LIBAARUFORMAT_FLAC_H
|
||||
#endif // LIBAARUFORMAT_FLAC_H
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
|
||||
struct CacheEntry
|
||||
{
|
||||
char* key;
|
||||
void* value;
|
||||
char *key;
|
||||
void *value;
|
||||
UT_hash_handle hh;
|
||||
};
|
||||
|
||||
struct CacheHeader
|
||||
{
|
||||
uint64_t max_items;
|
||||
struct CacheEntry* cache;
|
||||
struct CacheEntry *cache;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -27,7 +27,7 @@ struct CacheHeader
|
||||
* @param key Key
|
||||
* @return Value if found, NULL if not
|
||||
*/
|
||||
void* find_in_cache(struct CacheHeader* cache, char* key);
|
||||
void *find_in_cache(struct CacheHeader *cache, char *key);
|
||||
|
||||
/**
|
||||
* Adds an item to the specified cache
|
||||
@@ -35,7 +35,7 @@ void* find_in_cache(struct CacheHeader* cache, char* key);
|
||||
* @param key Key
|
||||
* @param value Value
|
||||
*/
|
||||
void add_to_cache(struct CacheHeader* cache, char* key, void* value);
|
||||
void add_to_cache(struct CacheHeader *cache, char *key, void *value);
|
||||
|
||||
/**
|
||||
* Finds an item in the specified cache using a 64-bit integer key
|
||||
@@ -43,7 +43,7 @@ void add_to_cache(struct CacheHeader* cache, char* key, void* value);
|
||||
* @param key Key
|
||||
* @return Value if found, NULL if not
|
||||
*/
|
||||
void* find_in_cache_uint64(struct CacheHeader* cache, uint64_t key);
|
||||
void *find_in_cache_uint64(struct CacheHeader *cache, uint64_t key);
|
||||
|
||||
/**
|
||||
* Adds an item to the specified cache using a 64-bit integer key
|
||||
@@ -51,6 +51,6 @@ void* find_in_cache_uint64(struct CacheHeader* cache, uint64_t key);
|
||||
* @param key Key
|
||||
* @param value Value
|
||||
*/
|
||||
void add_to_cache_uint64(struct CacheHeader* cache, uint64_t key, void* value);
|
||||
void add_to_cache_uint64(struct CacheHeader *cache, uint64_t key, void *value);
|
||||
|
||||
#endif // LIBAARUFORMAT_LRU_H
|
||||
#endif // LIBAARUFORMAT_LRU_H
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#define ALIGNED_(n) __attribute__((aligned(n)))
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -33,21 +33,21 @@
|
||||
#define SSSE3
|
||||
#define CLMUL
|
||||
#else
|
||||
#define AVX2 __attribute__((target("avx2")))
|
||||
#define AVX2 __attribute__((target("avx2")))
|
||||
#define SSSE3 __attribute__((target("ssse3")))
|
||||
#define CLMUL __attribute__((target("pclmul,sse4.1")))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if(defined(__arm__) || defined(_M_ARM)) && !defined(_WIN32)
|
||||
#define HWCAP_NEON (1 << 12)
|
||||
#define HWCAP2_AES (1 << 0)
|
||||
#define HWCAP_NEON (1 << 12)
|
||||
#define HWCAP2_AES (1 << 0)
|
||||
#define HWCAP2_CRC32 (1 << 4)
|
||||
#endif
|
||||
|
||||
#if(defined(__aarch64__) || defined(_M_ARM64)) && !defined(_WIN32)
|
||||
#define HWCAP_NEON (1 << 1)
|
||||
#define HWCAP_AES (1 << 3)
|
||||
#define HWCAP_NEON (1 << 1)
|
||||
#define HWCAP_AES (1 << 3)
|
||||
#define HWCAP_CRC32 (1 << 7)
|
||||
#endif
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
#define TARGET_WITH_CRYPTO
|
||||
#define TARGET_WITH_SIMD
|
||||
|
||||
#else // _MSC_VER
|
||||
#else // _MSC_VER
|
||||
|
||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
#define TARGET_ARMV8_WITH_CRC __attribute__((target("arch=armv8-a+crc")))
|
||||
#endif
|
||||
|
||||
#endif // __ARM_ARCH >= 8
|
||||
#endif // __ARM_ARCH >= 8
|
||||
|
||||
#ifdef __clang__
|
||||
#define TARGET_WITH_CRYPTO __attribute__((target("armv8-a,crypto")))
|
||||
@@ -104,10 +104,10 @@
|
||||
#define TARGET_WITH_SIMD __attribute__((target("fpu=neon")))
|
||||
#endif
|
||||
|
||||
#endif // __aarch64__ || _M_ARM64
|
||||
#endif // __aarch64__ || _M_ARM64
|
||||
|
||||
#endif // _MSC_VER
|
||||
#endif // _MSC_VER
|
||||
|
||||
#endif // __aarch64__ || _M_ARM64 || __arm__ || _M_ARM
|
||||
#endif // __aarch64__ || _M_ARM64 || __arm__ || _M_ARM
|
||||
|
||||
#endif // LIBAARUFORMAT_SIMD_H
|
||||
#endif // LIBAARUFORMAT_SIMD_H
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
|
||||
#include "decls.h"
|
||||
|
||||
#define SPAMSUM_LENGTH 64
|
||||
#define NUM_BLOCKHASHES 31
|
||||
#define ROLLING_WINDOW 7
|
||||
#define HASH_INIT 0x28021967
|
||||
#define HASH_PRIME 0x01000193
|
||||
#define MIN_BLOCKSIZE 3
|
||||
#define SPAMSUM_LENGTH 64
|
||||
#define NUM_BLOCKHASHES 31
|
||||
#define ROLLING_WINDOW 7
|
||||
#define HASH_INIT 0x28021967
|
||||
#define HASH_PRIME 0x01000193
|
||||
#define MIN_BLOCKSIZE 3
|
||||
#define FUZZY_MAX_RESULT ((2 * SPAMSUM_LENGTH) + 20)
|
||||
|
||||
typedef struct
|
||||
@@ -58,4 +58,4 @@ typedef struct
|
||||
roll_state roll;
|
||||
} spamsum_ctx;
|
||||
|
||||
#endif // LIBAARUFORMAT_SPAMSUM_H_
|
||||
#endif // LIBAARUFORMAT_SPAMSUM_H_
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#endif
|
||||
|
||||
#ifndef LIBAARUFORMAT_STRUCTS_H
|
||||
@@ -38,23 +38,23 @@ typedef struct AaruHeader
|
||||
/**Header identifier, <see cref="AARU_MAGIC" /> */
|
||||
uint64_t identifier;
|
||||
/**UTF-16LE name of the application that created the image */
|
||||
uint8_t application[64];
|
||||
uint8_t application[64];
|
||||
/**Image format major version. A new major version means a possibly incompatible change of format */
|
||||
uint8_t imageMajorVersion;
|
||||
uint8_t imageMajorVersion;
|
||||
/**Image format minor version. A new minor version indicates a compatible change of format */
|
||||
uint8_t imageMinorVersion;
|
||||
uint8_t imageMinorVersion;
|
||||
/**Major version of the application that created the image */
|
||||
uint8_t applicationMajorVersion;
|
||||
uint8_t applicationMajorVersion;
|
||||
/**Minor version of the application that created the image */
|
||||
uint8_t applicationMinorVersion;
|
||||
uint8_t applicationMinorVersion;
|
||||
/**Type of media contained on image */
|
||||
uint32_t mediaType;
|
||||
/**Offset to index */
|
||||
uint64_t indexOffset;
|
||||
/**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image creation time */
|
||||
int64_t creationTime;
|
||||
int64_t creationTime;
|
||||
/**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image last written time */
|
||||
int64_t lastWrittenTime;
|
||||
int64_t lastWrittenTime;
|
||||
} AaruHeader;
|
||||
|
||||
/**Header for a deduplication table. Table follows it */
|
||||
@@ -67,7 +67,7 @@ typedef struct DdtHeader
|
||||
/**Compression algorithm used to compress the DDT */
|
||||
uint16_t compression;
|
||||
/**Each entry is ((uint8_t offset in file) << shift) + (sector offset in block) */
|
||||
uint8_t shift;
|
||||
uint8_t shift;
|
||||
/**How many entries are in the table */
|
||||
uint64_t entries;
|
||||
/**Compressed length for the DDT */
|
||||
@@ -141,9 +141,9 @@ typedef struct MetadataBlockHeader
|
||||
/**Size in uint8_ts of this whole metadata block */
|
||||
uint32_t blockSize;
|
||||
/**Sequence of media set this media beint64_ts to */
|
||||
int32_t mediaSequence;
|
||||
int32_t mediaSequence;
|
||||
/**Total number of media on the media set this media beint64_ts to */
|
||||
int32_t lastMediaSequence;
|
||||
int32_t lastMediaSequence;
|
||||
/**Offset to start of creator string from start of this block */
|
||||
uint32_t creatorOffset;
|
||||
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
|
||||
@@ -281,14 +281,14 @@ typedef struct ChecksumHeader
|
||||
/**Length in uint8_ts of the block */
|
||||
uint32_t length;
|
||||
/**How many checksums follow */
|
||||
uint8_t entries;
|
||||
uint8_t entries;
|
||||
} ChecksumHeader;
|
||||
|
||||
/**Checksum entry, followed by checksum data itself */
|
||||
typedef struct ChecksumEntry
|
||||
{
|
||||
/**Checksum algorithm */
|
||||
uint8_t type;
|
||||
uint8_t type;
|
||||
/**Length in uint8_ts of checksum that follows this structure */
|
||||
uint32_t length;
|
||||
} ChecksumEntry;
|
||||
@@ -303,14 +303,14 @@ typedef struct Crc64Context
|
||||
typedef struct CdEccContext
|
||||
{
|
||||
bool initedEdc;
|
||||
uint8_t* eccBTable;
|
||||
uint8_t* eccFTable;
|
||||
uint32_t* edcTable;
|
||||
uint8_t *eccBTable;
|
||||
uint8_t *eccFTable;
|
||||
uint32_t *edcTable;
|
||||
} CdEccContext;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // LIBAARUFORMAT_STRUCTS_H
|
||||
#endif // LIBAARUFORMAT_STRUCTS_H
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
10
src/close.c
10
src/close.c
@@ -26,11 +26,11 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
int aaruf_close(void* context)
|
||||
int aaruf_close(void *context)
|
||||
{
|
||||
int i;
|
||||
mediaTagEntry* mediaTag;
|
||||
mediaTagEntry* tmpMediaTag;
|
||||
mediaTagEntry *mediaTag;
|
||||
mediaTagEntry *tmpMediaTag;
|
||||
|
||||
if(context == NULL)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ int aaruf_close(void* context)
|
||||
return -1;
|
||||
}
|
||||
|
||||
aaruformatContext* ctx = context;
|
||||
aaruformatContext *ctx = context;
|
||||
|
||||
// Not a libaaruformat context
|
||||
if(ctx->magic != AARU_MAGIC)
|
||||
@@ -77,7 +77,7 @@ int aaruf_close(void* context)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __linux__ // TODO: Implement
|
||||
#ifdef __linux__ // TODO: Implement
|
||||
if(!ctx->inMemoryDdt)
|
||||
{
|
||||
munmap(ctx->userDataDdt, ctx->mappedMemoryDdtSize);
|
||||
|
||||
@@ -71,19 +71,19 @@ TARGET_WITH_SIMD uint64x2_t sse2neon_vmull_p64(uint64x1_t _a, uint64x1_t _b)
|
||||
uint8x16_t k16_00 = vcombine_u8(vcreate_u8(0x000000000000ffff), vcreate_u8(0x0000000000000000));
|
||||
|
||||
// Do the multiplies, rotating with vext to get all combinations
|
||||
uint8x16_t d = vreinterpretq_u8_p16(vmull_p8(a, b)); // D = A0 * B0
|
||||
uint8x16_t e = vreinterpretq_u8_p16(vmull_p8(a, vext_p8(b, b, 1))); // E = A0 * B1
|
||||
uint8x16_t f = vreinterpretq_u8_p16(vmull_p8(vext_p8(a, a, 1), b)); // F = A1 * B0
|
||||
uint8x16_t g = vreinterpretq_u8_p16(vmull_p8(a, vext_p8(b, b, 2))); // G = A0 * B2
|
||||
uint8x16_t h = vreinterpretq_u8_p16(vmull_p8(vext_p8(a, a, 2), b)); // H = A2 * B0
|
||||
uint8x16_t i = vreinterpretq_u8_p16(vmull_p8(a, vext_p8(b, b, 3))); // I = A0 * B3
|
||||
uint8x16_t j = vreinterpretq_u8_p16(vmull_p8(vext_p8(a, a, 3), b)); // J = A3 * B0
|
||||
uint8x16_t k = vreinterpretq_u8_p16(vmull_p8(a, vext_p8(b, b, 4))); // L = A0 * B4
|
||||
uint8x16_t d = vreinterpretq_u8_p16(vmull_p8(a, b)); // D = A0 * B0
|
||||
uint8x16_t e = vreinterpretq_u8_p16(vmull_p8(a, vext_p8(b, b, 1))); // E = A0 * B1
|
||||
uint8x16_t f = vreinterpretq_u8_p16(vmull_p8(vext_p8(a, a, 1), b)); // F = A1 * B0
|
||||
uint8x16_t g = vreinterpretq_u8_p16(vmull_p8(a, vext_p8(b, b, 2))); // G = A0 * B2
|
||||
uint8x16_t h = vreinterpretq_u8_p16(vmull_p8(vext_p8(a, a, 2), b)); // H = A2 * B0
|
||||
uint8x16_t i = vreinterpretq_u8_p16(vmull_p8(a, vext_p8(b, b, 3))); // I = A0 * B3
|
||||
uint8x16_t j = vreinterpretq_u8_p16(vmull_p8(vext_p8(a, a, 3), b)); // J = A3 * B0
|
||||
uint8x16_t k = vreinterpretq_u8_p16(vmull_p8(a, vext_p8(b, b, 4))); // L = A0 * B4
|
||||
|
||||
// Add cross products
|
||||
uint8x16_t l = veorq_u8(e, f); // L = E + F
|
||||
uint8x16_t m = veorq_u8(g, h); // M = G + H
|
||||
uint8x16_t n = veorq_u8(i, j); // N = I + J
|
||||
uint8x16_t l = veorq_u8(e, f); // L = E + F
|
||||
uint8x16_t m = veorq_u8(g, h); // M = G + H
|
||||
uint8x16_t n = veorq_u8(i, j); // N = I + J
|
||||
|
||||
// Interleave. Using vzip1 and vzip2 prevents Clang from emitting TBL
|
||||
// instructions.
|
||||
@@ -117,16 +117,16 @@ TARGET_WITH_SIMD uint64x2_t sse2neon_vmull_p64(uint64x1_t _a, uint64x1_t _b)
|
||||
uint8x16_t t2 = vreinterpretq_u8_u64(vuzp1q_u64(vreinterpretq_u64_u8(t2t3_l), vreinterpretq_u64_u8(t2t3_h)));
|
||||
uint8x16_t t3 = vreinterpretq_u8_u64(vuzp2q_u64(vreinterpretq_u64_u8(t2t3_l), vreinterpretq_u64_u8(t2t3_h)));
|
||||
#else
|
||||
uint8x16_t t1 = vcombine_u8(vget_high_u8(t0t1_l), vget_high_u8(t0t1_h));
|
||||
uint8x16_t t0 = vcombine_u8(vget_low_u8(t0t1_l), vget_low_u8(t0t1_h));
|
||||
uint8x16_t t3 = vcombine_u8(vget_high_u8(t2t3_l), vget_high_u8(t2t3_h));
|
||||
uint8x16_t t2 = vcombine_u8(vget_low_u8(t2t3_l), vget_low_u8(t2t3_h));
|
||||
uint8x16_t t1 = vcombine_u8(vget_high_u8(t0t1_l), vget_high_u8(t0t1_h));
|
||||
uint8x16_t t0 = vcombine_u8(vget_low_u8(t0t1_l), vget_low_u8(t0t1_h));
|
||||
uint8x16_t t3 = vcombine_u8(vget_high_u8(t2t3_l), vget_high_u8(t2t3_h));
|
||||
uint8x16_t t2 = vcombine_u8(vget_low_u8(t2t3_l), vget_low_u8(t2t3_h));
|
||||
#endif
|
||||
// Shift the cross products
|
||||
uint8x16_t t0_shift = vextq_u8(t0, t0, 15); // t0 << 8
|
||||
uint8x16_t t1_shift = vextq_u8(t1, t1, 14); // t1 << 16
|
||||
uint8x16_t t2_shift = vextq_u8(t2, t2, 13); // t2 << 24
|
||||
uint8x16_t t3_shift = vextq_u8(t3, t3, 12); // t3 << 32
|
||||
uint8x16_t t0_shift = vextq_u8(t0, t0, 15); // t0 << 8
|
||||
uint8x16_t t1_shift = vextq_u8(t1, t1, 14); // t1 << 16
|
||||
uint8x16_t t2_shift = vextq_u8(t2, t2, 13); // t2 << 24
|
||||
uint8x16_t t3_shift = vextq_u8(t3, t3, 12); // t3 << 32
|
||||
|
||||
// Accumulate the products
|
||||
uint8x16_t cross1 = veorq_u8(t0_shift, t1_shift);
|
||||
@@ -138,9 +138,9 @@ TARGET_WITH_SIMD uint64x2_t sse2neon_vmull_p64(uint64x1_t _a, uint64x1_t _b)
|
||||
|
||||
TARGET_WITH_SIMD uint64x2_t mm_shuffle_epi8(uint64x2_t a, uint64x2_t b)
|
||||
{
|
||||
uint8x16_t tbl = vreinterpretq_u8_u64(a); // input a
|
||||
uint8x16_t idx = vreinterpretq_u8_u64(b); // input b
|
||||
uint8x16_t idx_masked = vandq_u8(idx, vdupq_n_u8(0x8F)); // avoid using meaningless bits
|
||||
uint8x16_t tbl = vreinterpretq_u8_u64(a); // input a
|
||||
uint8x16_t idx = vreinterpretq_u8_u64(b); // input b
|
||||
uint8x16_t idx_masked = vandq_u8(idx, vdupq_n_u8(0x8F)); // avoid using meaningless bits
|
||||
#if defined(__aarch64__)
|
||||
return vreinterpretq_u64_u8(vqtbl1q_u8(tbl, idx_masked));
|
||||
#else
|
||||
@@ -154,13 +154,13 @@ TARGET_WITH_SIMD uint64x2_t mm_shuffle_epi8(uint64x2_t a, uint64x2_t b)
|
||||
TARGET_WITH_SIMD uint64x2_t mm_srli_si128(uint64x2_t a, int imm)
|
||||
{
|
||||
uint8x16_t tmp[2] = {vreinterpretq_u8_u64(a), vdupq_n_u8(0)};
|
||||
return vreinterpretq_u64_u8(vld1q_u8(((uint8_t const*)tmp) + imm));
|
||||
return vreinterpretq_u64_u8(vld1q_u8(((uint8_t const *)tmp) + imm));
|
||||
}
|
||||
|
||||
TARGET_WITH_SIMD uint64x2_t mm_slli_si128(uint64x2_t a, int imm)
|
||||
{
|
||||
uint8x16_t tmp[2] = {vdupq_n_u8(0), vreinterpretq_u8_u64(a)};
|
||||
return vreinterpretq_u64_u8(vld1q_u8(((uint8_t const*)tmp) + (16 - imm)));
|
||||
return vreinterpretq_u64_u8(vld1q_u8(((uint8_t const *)tmp) + (16 - imm)));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,4 +29,4 @@ TARGET_WITH_SIMD uint64x2_t mm_slli_si128(uint64x2_t a, int imm);
|
||||
|
||||
#endif
|
||||
|
||||
#endif // LIBAARUFORMAT_NATIVE_ARM_VMULL_H
|
||||
#endif // LIBAARUFORMAT_NATIVE_ARM_VMULL_H
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
AARU_EXPORT crc64_ctx* AARU_CALL aaruf_crc64_init(void)
|
||||
AARU_EXPORT crc64_ctx *AARU_CALL aaruf_crc64_init(void)
|
||||
{
|
||||
int i, slice;
|
||||
crc64_ctx* ctx = (crc64_ctx*)malloc(sizeof(crc64_ctx));
|
||||
crc64_ctx *ctx = (crc64_ctx *)malloc(sizeof(crc64_ctx));
|
||||
|
||||
if(!ctx) return NULL;
|
||||
|
||||
@@ -32,11 +32,11 @@ AARU_EXPORT crc64_ctx* AARU_CALL aaruf_crc64_init(void)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
AARU_EXPORT int AARU_CALL aaruf_crc64_update(crc64_ctx* ctx, const uint8_t* data, uint32_t len)
|
||||
AARU_EXPORT int AARU_CALL aaruf_crc64_update(crc64_ctx *ctx, const uint8_t *data, uint32_t len)
|
||||
{
|
||||
if(!ctx || !data) return -1;
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
if(have_clmul())
|
||||
{
|
||||
@@ -62,17 +62,17 @@ AARU_EXPORT int AARU_CALL aaruf_crc64_update(crc64_ctx* ctx, const uint8_t* data
|
||||
return 0;
|
||||
}
|
||||
|
||||
AARU_EXPORT void AARU_CALL aaruf_crc64_slicing(uint64_t* previous_crc, const uint8_t* data, uint32_t len)
|
||||
AARU_EXPORT void AARU_CALL aaruf_crc64_slicing(uint64_t *previous_crc, const uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint64_t c = *previous_crc;
|
||||
|
||||
if(len > 4)
|
||||
{
|
||||
const uint8_t* limit;
|
||||
const uint8_t *limit;
|
||||
|
||||
while((uintptr_t)(data)&3)
|
||||
while((uintptr_t)(data) & 3)
|
||||
{
|
||||
c = crc64_table[0][*data++ ^ ((c)&0xFF)] ^ ((c) >> 8);
|
||||
c = crc64_table[0][*data++ ^ ((c) & 0xFF)] ^ ((c) >> 8);
|
||||
--len;
|
||||
}
|
||||
|
||||
@@ -81,20 +81,20 @@ AARU_EXPORT void AARU_CALL aaruf_crc64_slicing(uint64_t* previous_crc, const uin
|
||||
|
||||
while(data < limit)
|
||||
{
|
||||
const uint32_t tmp = c ^ *(const uint32_t*)(data);
|
||||
const uint32_t tmp = c ^ *(const uint32_t *)(data);
|
||||
data += 4;
|
||||
|
||||
c = crc64_table[3][((tmp)&0xFF)] ^ crc64_table[2][(((tmp) >> 8) & 0xFF)] ^ ((c) >> 32) ^
|
||||
c = crc64_table[3][((tmp) & 0xFF)] ^ crc64_table[2][(((tmp) >> 8) & 0xFF)] ^ ((c) >> 32) ^
|
||||
crc64_table[1][(((tmp) >> 16) & 0xFF)] ^ crc64_table[0][((tmp) >> 24)];
|
||||
}
|
||||
}
|
||||
|
||||
while(len-- != 0) c = crc64_table[0][*data++ ^ ((c)&0xFF)] ^ ((c) >> 8);
|
||||
while(len-- != 0) c = crc64_table[0][*data++ ^ ((c) & 0xFF)] ^ ((c) >> 8);
|
||||
|
||||
*previous_crc = c;
|
||||
}
|
||||
|
||||
AARU_EXPORT int AARU_CALL aaruf_crc64_final(crc64_ctx* ctx, uint64_t* crc)
|
||||
AARU_EXPORT int AARU_CALL aaruf_crc64_final(crc64_ctx *ctx, uint64_t *crc)
|
||||
{
|
||||
if(!ctx) return -1;
|
||||
|
||||
@@ -103,14 +103,14 @@ AARU_EXPORT int AARU_CALL aaruf_crc64_final(crc64_ctx* ctx, uint64_t* crc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AARU_EXPORT void AARU_CALL aaruf_crc64_free(crc64_ctx* ctx)
|
||||
AARU_EXPORT void AARU_CALL aaruf_crc64_free(crc64_ctx *ctx)
|
||||
{
|
||||
if(ctx) free(ctx);
|
||||
}
|
||||
|
||||
AARU_EXPORT uint64_t AARU_CALL aaruf_crc64_data(const uint8_t* data, uint32_t len)
|
||||
AARU_EXPORT uint64_t AARU_CALL aaruf_crc64_data(const uint8_t *data, uint32_t len)
|
||||
{
|
||||
crc64_ctx* ctx = aaruf_crc64_init();
|
||||
crc64_ctx *ctx = aaruf_crc64_init();
|
||||
uint64_t crc = 0;
|
||||
|
||||
if(!ctx) return crc;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
|
||||
#include <inttypes.h>
|
||||
@@ -66,9 +66,9 @@ static const uint8_t shuffleMasks[] = {
|
||||
0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80,
|
||||
};
|
||||
|
||||
CLMUL static void shiftRight128(__m128i in, size_t n, __m128i* outLeft, __m128i* outRight)
|
||||
CLMUL static void shiftRight128(__m128i in, size_t n, __m128i *outLeft, __m128i *outRight)
|
||||
{
|
||||
const __m128i maskA = _mm_loadu_si128((const __m128i*)(shuffleMasks + (16 - n)));
|
||||
const __m128i maskA = _mm_loadu_si128((const __m128i *)(shuffleMasks + (16 - n)));
|
||||
const __m128i maskB = _mm_xor_si128(maskA, _mm_cmpeq_epi8(_mm_setzero_si128(), _mm_setzero_si128()));
|
||||
|
||||
*outLeft = _mm_shuffle_epi8(in, maskB);
|
||||
@@ -80,28 +80,28 @@ CLMUL static __m128i fold(__m128i in, __m128i foldConstants)
|
||||
return _mm_xor_si128(_mm_clmulepi64_si128(in, foldConstants, 0x00), _mm_clmulepi64_si128(in, foldConstants, 0x11));
|
||||
}
|
||||
|
||||
AARU_EXPORT CLMUL uint64_t AARU_CALL aaruf_crc64_clmul(uint64_t crc, const uint8_t* data, long length)
|
||||
AARU_EXPORT CLMUL uint64_t AARU_CALL aaruf_crc64_clmul(uint64_t crc, const uint8_t *data, long length)
|
||||
{
|
||||
const uint64_t k1 = 0xe05dd497ca393ae4; // bitReflect(expMod65(128 + 64, poly, 1)) << 1;
|
||||
const uint64_t k2 = 0xdabe95afc7875f40; // bitReflect(expMod65(128, poly, 1)) << 1;
|
||||
const uint64_t mu = 0x9c3e466c172963d5; // (bitReflect(div129by65(poly)) << 1) | 1;
|
||||
const uint64_t p = 0x92d8af2baf0e1e85; // (bitReflect(poly) << 1) | 1;
|
||||
const uint64_t k1 = 0xe05dd497ca393ae4; // bitReflect(expMod65(128 + 64, poly, 1)) << 1;
|
||||
const uint64_t k2 = 0xdabe95afc7875f40; // bitReflect(expMod65(128, poly, 1)) << 1;
|
||||
const uint64_t mu = 0x9c3e466c172963d5; // (bitReflect(div129by65(poly)) << 1) | 1;
|
||||
const uint64_t p = 0x92d8af2baf0e1e85; // (bitReflect(poly) << 1) | 1;
|
||||
|
||||
const __m128i foldConstants1 = _mm_set_epi64x(k2, k1);
|
||||
const __m128i foldConstants2 = _mm_set_epi64x(p, mu);
|
||||
|
||||
const uint8_t* end = data + length;
|
||||
const uint8_t *end = data + length;
|
||||
|
||||
// Align pointers
|
||||
const __m128i* alignedData = (const __m128i*)((uintptr_t)data & ~(uintptr_t)15);
|
||||
const __m128i* alignedEnd = (const __m128i*)(((uintptr_t)end + 15) & ~(uintptr_t)15);
|
||||
const __m128i *alignedData = (const __m128i *)((uintptr_t)data & ~(uintptr_t)15);
|
||||
const __m128i *alignedEnd = (const __m128i *)(((uintptr_t)end + 15) & ~(uintptr_t)15);
|
||||
|
||||
const size_t leadInSize = data - (const uint8_t*)alignedData;
|
||||
const size_t leadOutSize = (const uint8_t*)alignedEnd - end;
|
||||
const size_t leadInSize = data - (const uint8_t *)alignedData;
|
||||
const size_t leadOutSize = (const uint8_t *)alignedEnd - end;
|
||||
|
||||
const size_t alignedLength = alignedEnd - alignedData;
|
||||
|
||||
const __m128i leadInMask = _mm_loadu_si128((const __m128i*)(shuffleMasks + (16 - leadInSize)));
|
||||
const __m128i leadInMask = _mm_loadu_si128((const __m128i *)(shuffleMasks + (16 - leadInSize)));
|
||||
const __m128i data0 = _mm_blendv_epi8(_mm_setzero_si128(), _mm_load_si128(alignedData), leadInMask);
|
||||
|
||||
#if defined(_WIN64)
|
||||
@@ -122,7 +122,7 @@ AARU_EXPORT CLMUL uint64_t AARU_CALL aaruf_crc64_clmul(uint64_t crc, const uint8
|
||||
|
||||
const __m128i P = _mm_xor_si128(A, crc0);
|
||||
R = _mm_xor_si128(_mm_clmulepi64_si128(P, foldConstants1, 0x10),
|
||||
_mm_xor_si128(_mm_srli_si128(P, 8), _mm_slli_si128(crc1, 8)));
|
||||
_mm_xor_si128(_mm_srli_si128(P, 8), _mm_slli_si128(crc1, 8)));
|
||||
}
|
||||
else if(alignedLength == 2)
|
||||
{
|
||||
@@ -140,7 +140,7 @@ AARU_EXPORT CLMUL uint64_t AARU_CALL aaruf_crc64_clmul(uint64_t crc, const uint8
|
||||
|
||||
const __m128i P = _mm_xor_si128(_mm_xor_si128(B, C), crc0);
|
||||
R = _mm_xor_si128(_mm_clmulepi64_si128(P, foldConstants1, 0x10),
|
||||
_mm_xor_si128(_mm_srli_si128(P, 8), _mm_slli_si128(crc1, 8)));
|
||||
_mm_xor_si128(_mm_srli_si128(P, 8), _mm_slli_si128(crc1, 8)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -31,12 +31,12 @@ static const uint8_t shuffleMasks[] = {
|
||||
0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80,
|
||||
};
|
||||
|
||||
TARGET_WITH_SIMD FORCE_INLINE void shiftRight128(uint64x2_t in, size_t n, uint64x2_t* outLeft, uint64x2_t* outRight)
|
||||
TARGET_WITH_SIMD FORCE_INLINE void shiftRight128(uint64x2_t in, size_t n, uint64x2_t *outLeft, uint64x2_t *outRight)
|
||||
{
|
||||
const uint64x2_t maskA =
|
||||
vreinterpretq_u64_u32(vld1q_u32((const uint32_t*)(const uint64x2_t*)(shuffleMasks + (16 - n))));
|
||||
vreinterpretq_u64_u32(vld1q_u32((const uint32_t *)(const uint64x2_t *)(shuffleMasks + (16 - n))));
|
||||
uint64x2_t b = vreinterpretq_u64_u8(vceqq_u8(vreinterpretq_u8_u64(vreinterpretq_u64_u32(vdupq_n_u32(0))),
|
||||
vreinterpretq_u8_u64(vreinterpretq_u64_u32(vdupq_n_u32(0)))));
|
||||
vreinterpretq_u8_u64(vreinterpretq_u64_u32(vdupq_n_u32(0)))));
|
||||
const uint64x2_t maskB = vreinterpretq_u64_u32(veorq_u32(vreinterpretq_u32_u64(maskA), vreinterpretq_u32_u64(b)));
|
||||
|
||||
*outLeft = mm_shuffle_epi8(in, maskB);
|
||||
@@ -49,36 +49,35 @@ TARGET_WITH_SIMD FORCE_INLINE uint64x2_t fold(uint64x2_t in, uint64x2_t foldCons
|
||||
sse2neon_vmull_p64(vget_high_u64(in), vget_high_u64(foldConstants)));
|
||||
}
|
||||
|
||||
AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previous_crc, const uint8_t* data, long len)
|
||||
AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previous_crc, const uint8_t *data, long len)
|
||||
{
|
||||
const uint64_t k1 = 0xe05dd497ca393ae4; // bitReflect(expMod65(128 + 64, poly, 1)) << 1;
|
||||
const uint64_t k2 = 0xdabe95afc7875f40; // bitReflect(expMod65(128, poly, 1)) << 1;
|
||||
const uint64_t mu = 0x9c3e466c172963d5; // (bitReflect(div129by65(poly)) << 1) | 1;
|
||||
const uint64_t p = 0x92d8af2baf0e1e85; // (bitReflect(poly) << 1) | 1;
|
||||
const uint64_t k1 = 0xe05dd497ca393ae4; // bitReflect(expMod65(128 + 64, poly, 1)) << 1;
|
||||
const uint64_t k2 = 0xdabe95afc7875f40; // bitReflect(expMod65(128, poly, 1)) << 1;
|
||||
const uint64_t mu = 0x9c3e466c172963d5; // (bitReflect(div129by65(poly)) << 1) | 1;
|
||||
const uint64_t p = 0x92d8af2baf0e1e85; // (bitReflect(poly) << 1) | 1;
|
||||
|
||||
const uint64x2_t foldConstants1 = vcombine_u64(vcreate_u64(k1), vcreate_u64(k2));
|
||||
const uint64x2_t foldConstants2 = vcombine_u64(vcreate_u64(mu), vcreate_u64(p));
|
||||
|
||||
const uint8_t* end = data + len;
|
||||
const uint8_t *end = data + len;
|
||||
|
||||
// Align pointers
|
||||
const uint64x2_t* alignedData = (const uint64x2_t*)((uintptr_t)data & ~(uintptr_t)15);
|
||||
const uint64x2_t* alignedEnd = (const uint64x2_t*)(((uintptr_t)end + 15) & ~(uintptr_t)15);
|
||||
const uint64x2_t *alignedData = (const uint64x2_t *)((uintptr_t)data & ~(uintptr_t)15);
|
||||
const uint64x2_t *alignedEnd = (const uint64x2_t *)(((uintptr_t)end + 15) & ~(uintptr_t)15);
|
||||
|
||||
const size_t leadInSize = data - (const uint8_t*)alignedData;
|
||||
const size_t leadOutSize = (const uint8_t*)alignedEnd - end;
|
||||
const size_t leadInSize = data - (const uint8_t *)alignedData;
|
||||
const size_t leadOutSize = (const uint8_t *)alignedEnd - end;
|
||||
|
||||
const size_t alignedLength = alignedEnd - alignedData;
|
||||
|
||||
const uint64x2_t leadInMask =
|
||||
vreinterpretq_u64_u32(vld1q_u32((const uint32_t*)(const uint64x2_t*)(shuffleMasks + (16 - leadInSize))));
|
||||
vreinterpretq_u64_u32(vld1q_u32((const uint32_t *)(const uint64x2_t *)(shuffleMasks + (16 - leadInSize))));
|
||||
uint64x2_t a = vreinterpretq_u64_u32(vdupq_n_u32(0));
|
||||
uint64x2_t b = vreinterpretq_u64_u32(
|
||||
vld1q_u32((const uint32_t*)alignedData)); // Use a signed shift right to create a mask with the sign bit
|
||||
vld1q_u32((const uint32_t *)alignedData)); // Use a signed shift right to create a mask with the sign bit
|
||||
const uint64x2_t data0 =
|
||||
vreinterpretq_u64_u8(vbslq_u8(vreinterpretq_u8_s8(vshrq_n_s8(vreinterpretq_s8_u64(leadInMask), 7)),
|
||||
vreinterpretq_u8_u64(b),
|
||||
vreinterpretq_u8_u64(a)));
|
||||
vreinterpretq_u8_u64(b), vreinterpretq_u8_u64(a)));
|
||||
|
||||
const uint64x2_t initialCrc = vsetq_lane_u64(~previous_crc, vdupq_n_u64(0), 0);
|
||||
|
||||
@@ -94,11 +93,11 @@ AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previ
|
||||
|
||||
const uint64x2_t P = veorq_u64(A, crc0);
|
||||
R = veorq_u64(sse2neon_vmull_p64(vget_low_u64(P), vget_high_u64(foldConstants1)),
|
||||
veorq_u64(mm_srli_si128(P, 8), mm_slli_si128(crc1, 8)));
|
||||
veorq_u64(mm_srli_si128(P, 8), mm_slli_si128(crc1, 8)));
|
||||
}
|
||||
else if(alignedLength == 2)
|
||||
{
|
||||
const uint64x2_t data1 = vreinterpretq_u64_u32(vld1q_u32((const uint32_t*)(alignedData + 1)));
|
||||
const uint64x2_t data1 = vreinterpretq_u64_u32(vld1q_u32((const uint32_t *)(alignedData + 1)));
|
||||
|
||||
if(len < 8)
|
||||
{
|
||||
@@ -112,7 +111,7 @@ AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previ
|
||||
|
||||
const uint64x2_t P = veorq_u64(veorq_u64(B, C), crc0);
|
||||
R = veorq_u64(sse2neon_vmull_p64(vget_low_u64(P), vget_high_u64(foldConstants1)),
|
||||
veorq_u64(mm_srli_si128(P, 8), mm_slli_si128(crc1, 8)));
|
||||
veorq_u64(mm_srli_si128(P, 8), mm_slli_si128(crc1, 8)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -141,7 +140,7 @@ AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previ
|
||||
|
||||
while(len >= 32)
|
||||
{
|
||||
accumulator = fold(veorq_u64(vreinterpretq_u64_u32(vld1q_u32((const uint32_t*)alignedData)), accumulator),
|
||||
accumulator = fold(veorq_u64(vreinterpretq_u64_u32(vld1q_u32((const uint32_t *)alignedData)), accumulator),
|
||||
foldConstants1);
|
||||
|
||||
len -= 16;
|
||||
@@ -149,12 +148,13 @@ AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previ
|
||||
}
|
||||
|
||||
uint64x2_t P;
|
||||
if(len == 16) P = veorq_u64(accumulator, vreinterpretq_u64_u32(vld1q_u32((const uint32_t*)alignedData)));
|
||||
if(len == 16)
|
||||
P = veorq_u64(accumulator, vreinterpretq_u64_u32(vld1q_u32((const uint32_t *)alignedData)));
|
||||
else
|
||||
{
|
||||
const uint64x2_t end0 =
|
||||
veorq_u64(accumulator, vreinterpretq_u64_u32(vld1q_u32((const uint32_t*)alignedData)));
|
||||
const uint64x2_t end1 = vreinterpretq_u64_u32(vld1q_u32((const uint32_t*)(alignedData + 1)));
|
||||
veorq_u64(accumulator, vreinterpretq_u64_u32(vld1q_u32((const uint32_t *)alignedData)));
|
||||
const uint64x2_t end1 = vreinterpretq_u64_u32(vld1q_u32((const uint32_t *)(alignedData + 1)));
|
||||
|
||||
uint64x2_t A, B, C, D;
|
||||
shiftRight128(end0, leadOutSize, &A, &B);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
int32_t aaruf_cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t length)
|
||||
int32_t aaruf_cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t length)
|
||||
{
|
||||
uint8_t *p, *q, *r, *s, *t, *u, *v, *w;
|
||||
size_t qStart;
|
||||
@@ -156,7 +156,7 @@ int32_t aaruf_cst_transform(const uint8_t* interleaved, uint8_t* sequential, siz
|
||||
return AARUF_STATUS_OK;
|
||||
}
|
||||
|
||||
int32_t aaruf_cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t length)
|
||||
int32_t aaruf_cst_untransform(const uint8_t *sequential, uint8_t *interleaved, size_t length)
|
||||
{
|
||||
uint8_t *p, *q, *r, *s, *t, *u, *v, *w;
|
||||
size_t qStart;
|
||||
|
||||
107
src/ecc_cd.c
107
src/ecc_cd.c
@@ -24,16 +24,16 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
void* aaruf_ecc_cd_init()
|
||||
void *aaruf_ecc_cd_init()
|
||||
{
|
||||
CdEccContext* context;
|
||||
CdEccContext *context;
|
||||
uint32_t edc, i, j;
|
||||
|
||||
context = (CdEccContext*)malloc(sizeof(CdEccContext));
|
||||
context = (CdEccContext *)malloc(sizeof(CdEccContext));
|
||||
|
||||
if(context == NULL) return NULL;
|
||||
|
||||
context->eccFTable = (uint8_t*)malloc(sizeof(uint8_t) * 256);
|
||||
context->eccFTable = (uint8_t *)malloc(sizeof(uint8_t) * 256);
|
||||
|
||||
if(context->eccFTable == NULL)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ void* aaruf_ecc_cd_init()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
context->eccBTable = (uint8_t*)malloc(sizeof(uint8_t) * 256);
|
||||
context->eccBTable = (uint8_t *)malloc(sizeof(uint8_t) * 256);
|
||||
|
||||
if(context->eccBTable == NULL)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ void* aaruf_ecc_cd_init()
|
||||
free(context);
|
||||
return NULL;
|
||||
}
|
||||
context->edcTable = (uint32_t*)malloc(sizeof(uint32_t) * 256);
|
||||
context->edcTable = (uint32_t *)malloc(sizeof(uint32_t) * 256);
|
||||
|
||||
if(context->edcTable == NULL)
|
||||
{
|
||||
@@ -74,15 +74,15 @@ void* aaruf_ecc_cd_init()
|
||||
return context;
|
||||
}
|
||||
|
||||
bool aaruf_ecc_cd_is_suffix_correct(void* context, const uint8_t* sector)
|
||||
bool aaruf_ecc_cd_is_suffix_correct(void *context, const uint8_t *sector)
|
||||
{
|
||||
CdEccContext* ctx;
|
||||
CdEccContext *ctx;
|
||||
uint32_t storedEdc, edc, calculatedEdc;
|
||||
int size, pos;
|
||||
|
||||
if(context == NULL || sector == NULL) return false;
|
||||
|
||||
ctx = (CdEccContext*)context;
|
||||
ctx = (CdEccContext *)context;
|
||||
|
||||
if(!ctx->initedEdc) return false;
|
||||
|
||||
@@ -108,16 +108,16 @@ bool aaruf_ecc_cd_is_suffix_correct(void* context, const uint8_t* sector)
|
||||
return calculatedEdc == storedEdc;
|
||||
}
|
||||
|
||||
bool aaruf_ecc_cd_is_suffix_correct_mode2(void* context, const uint8_t* sector)
|
||||
bool aaruf_ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector)
|
||||
{
|
||||
CdEccContext* ctx;
|
||||
CdEccContext *ctx;
|
||||
uint32_t storedEdc, edc, calculatedEdc;
|
||||
int size, pos;
|
||||
uint8_t zeroaddress[4];
|
||||
|
||||
if(context == NULL || sector == NULL) return false;
|
||||
|
||||
ctx = (CdEccContext*)context;
|
||||
ctx = (CdEccContext *)context;
|
||||
|
||||
if(!ctx->initedEdc) return false;
|
||||
|
||||
@@ -139,25 +139,17 @@ bool aaruf_ecc_cd_is_suffix_correct_mode2(void* context, const uint8_t* sector)
|
||||
return calculatedEdc == storedEdc;
|
||||
}
|
||||
|
||||
bool aaruf_ecc_cd_check(void* context,
|
||||
const uint8_t* address,
|
||||
const uint8_t* data,
|
||||
uint32_t majorCount,
|
||||
uint32_t minorCount,
|
||||
uint32_t majorMult,
|
||||
uint32_t minorInc,
|
||||
const uint8_t* ecc,
|
||||
int32_t addressOffset,
|
||||
int32_t dataOffset,
|
||||
int32_t eccOffset)
|
||||
bool aaruf_ecc_cd_check(void *context, const uint8_t *address, const uint8_t *data, uint32_t majorCount,
|
||||
uint32_t minorCount, uint32_t majorMult, uint32_t minorInc, const uint8_t *ecc,
|
||||
int32_t addressOffset, int32_t dataOffset, int32_t eccOffset)
|
||||
{
|
||||
CdEccContext* ctx;
|
||||
CdEccContext *ctx;
|
||||
uint32_t size, major, idx, minor;
|
||||
uint8_t eccA, eccB, temp;
|
||||
|
||||
if(context == NULL || address == NULL || data == NULL || ecc == NULL) return false;
|
||||
|
||||
ctx = (CdEccContext*)context;
|
||||
ctx = (CdEccContext *)context;
|
||||
|
||||
if(!ctx->initedEdc) return false;
|
||||
|
||||
@@ -184,25 +176,17 @@ bool aaruf_ecc_cd_check(void* context,
|
||||
return true;
|
||||
}
|
||||
|
||||
void aaruf_ecc_cd_write(void* context,
|
||||
const uint8_t* address,
|
||||
const uint8_t* data,
|
||||
uint32_t majorCount,
|
||||
uint32_t minorCount,
|
||||
uint32_t majorMult,
|
||||
uint32_t minorInc,
|
||||
uint8_t* ecc,
|
||||
int32_t addressOffset,
|
||||
int32_t dataOffset,
|
||||
int32_t eccOffset)
|
||||
void aaruf_ecc_cd_write(void *context, const uint8_t *address, const uint8_t *data, uint32_t majorCount,
|
||||
uint32_t minorCount, uint32_t majorMult, uint32_t minorInc, uint8_t *ecc, int32_t addressOffset,
|
||||
int32_t dataOffset, int32_t eccOffset)
|
||||
{
|
||||
CdEccContext* ctx;
|
||||
CdEccContext *ctx;
|
||||
uint32_t size, major, idx, minor;
|
||||
uint8_t eccA, eccB, temp;
|
||||
|
||||
if(context == NULL || address == NULL || data == NULL || ecc == NULL) return;
|
||||
|
||||
ctx = (CdEccContext*)context;
|
||||
ctx = (CdEccContext *)context;
|
||||
|
||||
if(!ctx->initedEdc) return;
|
||||
|
||||
@@ -229,28 +213,22 @@ void aaruf_ecc_cd_write(void* context,
|
||||
}
|
||||
}
|
||||
|
||||
void aaruf_ecc_cd_write_sector(void* context,
|
||||
const uint8_t* address,
|
||||
const uint8_t* data,
|
||||
uint8_t* ecc,
|
||||
int32_t addressOffset,
|
||||
int32_t dataOffset,
|
||||
int32_t eccOffset)
|
||||
void aaruf_ecc_cd_write_sector(void *context, const uint8_t *address, const uint8_t *data, uint8_t *ecc,
|
||||
int32_t addressOffset, int32_t dataOffset, int32_t eccOffset)
|
||||
{
|
||||
aaruf_ecc_cd_write(context, address, data, 86, 24, 2, 86, ecc, addressOffset, dataOffset, eccOffset); // P
|
||||
aaruf_ecc_cd_write(context, address, data, 52, 43, 86, 88, ecc, addressOffset, dataOffset, eccOffset + 0xAC); // Q
|
||||
aaruf_ecc_cd_write(context, address, data, 86, 24, 2, 86, ecc, addressOffset, dataOffset, eccOffset); // P
|
||||
aaruf_ecc_cd_write(context, address, data, 52, 43, 86, 88, ecc, addressOffset, dataOffset, eccOffset + 0xAC); // Q
|
||||
}
|
||||
|
||||
void aaruf_cd_lba_to_msf(int64_t pos, uint8_t* minute, uint8_t* second, uint8_t* frame)
|
||||
void aaruf_cd_lba_to_msf(int64_t pos, uint8_t *minute, uint8_t *second, uint8_t *frame)
|
||||
{
|
||||
*minute = (uint8_t)((pos + 150) / 75 / 60);
|
||||
*second = (uint8_t)((pos + 150) / 75 % 60);
|
||||
*frame = (uint8_t)((pos + 150) % 75);
|
||||
}
|
||||
|
||||
void aaruf_ecc_cd_reconstruct_prefix(uint8_t* sector, // must point to a full 2352-byte sector
|
||||
uint8_t type,
|
||||
int64_t lba)
|
||||
void aaruf_ecc_cd_reconstruct_prefix(uint8_t *sector, // must point to a full 2352-byte sector
|
||||
uint8_t type, int64_t lba)
|
||||
{
|
||||
uint8_t minute, second, frame;
|
||||
|
||||
@@ -301,22 +279,23 @@ void aaruf_ecc_cd_reconstruct_prefix(uint8_t* sector, // must point to a full 23
|
||||
sector[0x012] = sector[0x016];
|
||||
sector[0x013] = sector[0x017];
|
||||
break;
|
||||
default: return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void aaruf_ecc_cd_reconstruct(void* context,
|
||||
uint8_t* sector, // must point to a full 2352-byte sector
|
||||
void aaruf_ecc_cd_reconstruct(void *context,
|
||||
uint8_t *sector, // must point to a full 2352-byte sector
|
||||
uint8_t type)
|
||||
{
|
||||
uint32_t computedEdc;
|
||||
uint8_t zeroaddress[4];
|
||||
|
||||
CdEccContext* ctx;
|
||||
CdEccContext *ctx;
|
||||
|
||||
if(context == NULL || sector == NULL) return;
|
||||
|
||||
ctx = (CdEccContext*)context;
|
||||
ctx = (CdEccContext *)context;
|
||||
|
||||
if(!ctx->initedEdc) return;
|
||||
|
||||
@@ -337,7 +316,8 @@ void aaruf_ecc_cd_reconstruct(void* context,
|
||||
computedEdc = aaruf_edc_cd_compute(context, 0, sector, 0x91C, 0x10);
|
||||
memcpy(sector + 0x92C, &computedEdc, 4);
|
||||
break;
|
||||
default: return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&zeroaddress, 0, 4);
|
||||
@@ -361,8 +341,11 @@ void aaruf_ecc_cd_reconstruct(void* context,
|
||||
sector[0x81B] = 0x00;
|
||||
aaruf_ecc_cd_write_sector(context, sector, sector, sector, 0xC, 0x10, 0x81C);
|
||||
break;
|
||||
case CdMode2Form1: aaruf_ecc_cd_write_sector(context, zeroaddress, sector, sector, 0, 0x10, 0x81C); break;
|
||||
default: return;
|
||||
case CdMode2Form1:
|
||||
aaruf_ecc_cd_write_sector(context, zeroaddress, sector, sector, 0, 0x10, 0x81C);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -370,13 +353,13 @@ void aaruf_ecc_cd_reconstruct(void* context,
|
||||
//
|
||||
}
|
||||
|
||||
uint32_t aaruf_edc_cd_compute(void* context, uint32_t edc, const uint8_t* src, int size, int pos)
|
||||
uint32_t aaruf_edc_cd_compute(void *context, uint32_t edc, const uint8_t *src, int size, int pos)
|
||||
{
|
||||
CdEccContext* ctx;
|
||||
CdEccContext *ctx;
|
||||
|
||||
if(context == NULL || src == NULL) return 0;
|
||||
|
||||
ctx = (CdEccContext*)context;
|
||||
ctx = (CdEccContext *)context;
|
||||
|
||||
if(!ctx->initedEdc) return 0;
|
||||
|
||||
|
||||
104
src/flac.c
104
src/flac.c
@@ -27,23 +27,19 @@
|
||||
#include "../3rdparty/flac/include/FLAC/stream_encoder.h"
|
||||
#include "flac.h"
|
||||
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data);
|
||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder,
|
||||
const FLAC__Frame* frame,
|
||||
const FLAC__int32* const buffer[],
|
||||
void* client_data);
|
||||
static void
|
||||
error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data);
|
||||
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
|
||||
size_t *bytes, void *client_data);
|
||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame,
|
||||
const FLAC__int32 *const buffer[], void *client_data);
|
||||
static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status,
|
||||
void *client_data);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL aaruf_flac_decode_redbook_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size)
|
||||
AARU_EXPORT size_t AARU_CALL aaruf_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size,
|
||||
const uint8_t *src_buffer, size_t src_size)
|
||||
{
|
||||
FLAC__StreamDecoder* decoder;
|
||||
FLAC__StreamDecoder *decoder;
|
||||
FLAC__StreamDecoderInitStatus init_status;
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)malloc(sizeof(aaru_flac_ctx));
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)malloc(sizeof(aaru_flac_ctx));
|
||||
size_t ret_size;
|
||||
|
||||
memset(ctx, 0, sizeof(aaru_flac_ctx));
|
||||
@@ -66,8 +62,8 @@ AARU_EXPORT size_t AARU_CALL aaruf_flac_decode_redbook_buffer(uint8_t* dst
|
||||
|
||||
FLAC__stream_decoder_set_md5_checking(decoder, false);
|
||||
|
||||
init_status = FLAC__stream_decoder_init_stream(
|
||||
decoder, read_callback, NULL, NULL, NULL, NULL, write_callback, NULL, error_callback, ctx);
|
||||
init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, NULL, NULL, NULL, NULL, write_callback, NULL,
|
||||
error_callback, ctx);
|
||||
|
||||
if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
||||
{
|
||||
@@ -87,10 +83,10 @@ AARU_EXPORT size_t AARU_CALL aaruf_flac_decode_redbook_buffer(uint8_t* dst
|
||||
return ret_size;
|
||||
}
|
||||
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data)
|
||||
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
|
||||
size_t *bytes, void *client_data)
|
||||
{
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||
|
||||
if(ctx->src_len - ctx->src_pos < *bytes) *bytes = ctx->src_len - ctx->src_pos;
|
||||
|
||||
@@ -102,14 +98,12 @@ static FLAC__StreamDecoderReadStatus
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder,
|
||||
const FLAC__Frame* frame,
|
||||
const FLAC__int32* const buffer[],
|
||||
void* client_data)
|
||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame,
|
||||
const FLAC__int32 *const buffer[], void *client_data)
|
||||
{
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||
size_t i;
|
||||
uint16_t* buffer16 = (uint16_t*)(ctx->dst_buffer + ctx->dst_pos);
|
||||
uint16_t *buffer16 = (uint16_t *)(ctx->dst_buffer + ctx->dst_pos);
|
||||
|
||||
// Why FLAC does not interleave the channels as PCM do, oh the mistery, we could use memcpy instead of looping
|
||||
for(i = 0; i < frame->header.blocksize && ctx->dst_pos < ctx->dst_len; i++)
|
||||
@@ -134,47 +128,34 @@ static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder*
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
static void error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data)
|
||||
static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
|
||||
{
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||
|
||||
fprintf(stderr, "Got error callback: %s\n", FLAC__StreamDecoderErrorStatusString[status]);
|
||||
|
||||
ctx->error = 1;
|
||||
}
|
||||
|
||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder* encoder,
|
||||
const FLAC__byte buffer[],
|
||||
size_t bytes,
|
||||
uint32_t samples,
|
||||
uint32_t current_frame,
|
||||
void* client_data);
|
||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
||||
const FLAC__byte buffer[], size_t bytes, uint32_t samples,
|
||||
uint32_t current_frame, void *client_data);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL aaruf_flac_encode_redbook_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size,
|
||||
uint32_t blocksize,
|
||||
int32_t do_mid_side_stereo,
|
||||
int32_t loose_mid_side_stereo,
|
||||
const char* apodization,
|
||||
uint32_t max_lpc_order,
|
||||
uint32_t qlp_coeff_precision,
|
||||
int32_t do_qlp_coeff_prec_search,
|
||||
int32_t do_exhaustive_model_search,
|
||||
uint32_t min_residual_partition_order,
|
||||
uint32_t max_residual_partition_order,
|
||||
const char* application_id,
|
||||
uint32_t application_id_len)
|
||||
AARU_EXPORT size_t AARU_CALL aaruf_flac_encode_redbook_buffer(
|
||||
uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize,
|
||||
int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order,
|
||||
uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
|
||||
uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id,
|
||||
uint32_t application_id_len)
|
||||
{
|
||||
FLAC__StreamEncoder* encoder;
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)malloc(sizeof(aaru_flac_ctx));
|
||||
FLAC__StreamEncoder *encoder;
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)malloc(sizeof(aaru_flac_ctx));
|
||||
FLAC__StreamEncoderInitStatus init_status;
|
||||
size_t ret_size;
|
||||
FLAC__int32* pcm;
|
||||
FLAC__int32 *pcm;
|
||||
int i;
|
||||
int16_t* buffer16 = (int16_t*)src_buffer;
|
||||
FLAC__StreamMetadata* metadata[1];
|
||||
int16_t *buffer16 = (int16_t *)src_buffer;
|
||||
FLAC__StreamMetadata *metadata[1];
|
||||
|
||||
memset(ctx, 0, sizeof(aaru_flac_ctx));
|
||||
|
||||
@@ -228,8 +209,8 @@ AARU_EXPORT size_t AARU_CALL aaruf_flac_encode_redbook_buffer(uint8_t* dst
|
||||
|
||||
if(application_id_len > 0 && application_id != NULL)
|
||||
if((metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)) != NULL)
|
||||
FLAC__metadata_object_application_set_data(
|
||||
metadata[0], (unsigned char*)application_id, application_id_len, true);
|
||||
FLAC__metadata_object_application_set_data(metadata[0], (unsigned char *)application_id, application_id_len,
|
||||
true);
|
||||
|
||||
FLAC__stream_encoder_set_metadata(encoder, metadata, 1);
|
||||
|
||||
@@ -260,14 +241,11 @@ AARU_EXPORT size_t AARU_CALL aaruf_flac_encode_redbook_buffer(uint8_t* dst
|
||||
return ret_size;
|
||||
}
|
||||
|
||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder* encoder,
|
||||
const FLAC__byte buffer[],
|
||||
size_t bytes,
|
||||
uint32_t samples,
|
||||
uint32_t current_frame,
|
||||
void* client_data)
|
||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
||||
const FLAC__byte buffer[], size_t bytes, uint32_t samples,
|
||||
uint32_t current_frame, void *client_data)
|
||||
{
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||
|
||||
if(bytes > ctx->dst_len - ctx->dst_pos) bytes = ctx->dst_len - ctx->dst_pos;
|
||||
|
||||
|
||||
216
src/helpers.c
216
src/helpers.c
@@ -25,76 +25,146 @@ int32_t aaruf_get_media_tag_type_for_datatype(int32_t type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case CompactDiscPartialToc: return CD_TOC;
|
||||
case CompactDiscSessionInfo: return CD_SessionInfo;
|
||||
case CompactDiscToc: return CD_FullTOC;
|
||||
case CompactDiscPma: return CD_PMA;
|
||||
case CompactDiscAtip: return CD_ATIP;
|
||||
case CompactDiscLeadInCdText: return CD_TEXT;
|
||||
case DvdPfi: return DVD_PFI;
|
||||
case DvdLeadInCmi: return DVD_CMI;
|
||||
case DvdDiscKey: return DVD_DiscKey;
|
||||
case DvdBca: return DVD_BCA;
|
||||
case DvdDmi: return DVD_DMI;
|
||||
case DvdMediaIdentifier: return DVD_MediaIdentifier;
|
||||
case DvdMediaKeyBlock: return DVD_MKB;
|
||||
case DvdRamDds: return DVDRAM_DDS;
|
||||
case DvdRamMediumStatus: return DVDRAM_MediumStatus;
|
||||
case DvdRamSpareArea: return DVDRAM_SpareArea;
|
||||
case DvdRRmd: return DVDR_RMD;
|
||||
case DvdRPrerecordedInfo: return DVDR_PreRecordedInfo;
|
||||
case DvdRMediaIdentifier: return DVDR_MediaIdentifier;
|
||||
case DvdRPfi: return DVDR_PFI;
|
||||
case DvdAdip: return DVD_ADIP;
|
||||
case HdDvdCpi: return HDDVD_CPI;
|
||||
case HdDvdMediumStatus: return HDDVD_MediumStatus;
|
||||
case DvdDlLayerCapacity: return DVDDL_LayerCapacity;
|
||||
case DvdDlMiddleZoneAddress: return DVDDL_MiddleZoneAddress;
|
||||
case DvdDlJumpIntervalSize: return DVDDL_JumpIntervalSize;
|
||||
case DvdDlManualLayerJumpLba: return DVDDL_ManualLayerJumpLBA;
|
||||
case BlurayDi: return BD_DI;
|
||||
case BlurayBca: return BD_BCA;
|
||||
case BlurayDds: return BD_DDS;
|
||||
case BlurayCartridgeStatus: return BD_CartridgeStatus;
|
||||
case BluraySpareArea: return BD_SpareArea;
|
||||
case AacsVolumeIdentifier: return AACS_VolumeIdentifier;
|
||||
case AacsSerialNumber: return AACS_SerialNumber;
|
||||
case AacsMediaIdentifier: return AACS_MediaIdentifier;
|
||||
case AacsMediaKeyBlock: return AACS_MKB;
|
||||
case AacsDataKeys: return AACS_DataKeys;
|
||||
case AacsLbaExtents: return AACS_LBAExtents;
|
||||
case CprmMediaKeyBlock: return AACS_CPRM_MKB;
|
||||
case HybridRecognizedLayers: return Hybrid_RecognizedLayers;
|
||||
case ScsiMmcWriteProtection: return MMC_WriteProtection;
|
||||
case ScsiMmcDiscInformation: return MMC_DiscInformation;
|
||||
case ScsiMmcTrackResourcesInformation: return MMC_TrackResourcesInformation;
|
||||
case ScsiMmcPowResourcesInformation: return MMC_POWResourcesInformation;
|
||||
case ScsiInquiry: return SCSI_INQUIRY;
|
||||
case ScsiModePage2A: return SCSI_MODEPAGE_2A;
|
||||
case AtaIdentify: return ATA_IDENTIFY;
|
||||
case AtapiIdentify: return ATAPI_IDENTIFY;
|
||||
case PcmciaCis: return PCMCIA_CIS;
|
||||
case SecureDigitalCid: return SD_CID;
|
||||
case SecureDigitalCsd: return SD_CSD;
|
||||
case SecureDigitalScr: return SD_SCR;
|
||||
case SecureDigitalOcr: return SD_OCR;
|
||||
case MultiMediaCardCid: return MMC_CID;
|
||||
case MultiMediaCardCsd: return MMC_CSD;
|
||||
case MultiMediaCardOcr: return MMC_OCR;
|
||||
case MultiMediaCardExtendedCsd: return MMC_ExtendedCSD;
|
||||
case XboxSecuritySector: return Xbox_SecuritySector;
|
||||
case FloppyLeadOut: return Floppy_LeadOut;
|
||||
case DvdDiscControlBlock: return DCB;
|
||||
case CompactDiscFirstTrackPregap: return CD_FirstTrackPregap;
|
||||
case CompactDiscLeadOut: return CD_LeadOut;
|
||||
case ScsiModeSense6: return SCSI_MODESENSE_6;
|
||||
case ScsiModeSense10: return SCSI_MODESENSE_10;
|
||||
case UsbDescriptors: return USB_Descriptors;
|
||||
case XboxDmi: return Xbox_DMI;
|
||||
case XboxPfi: return Xbox_PFI;
|
||||
case CompactDiscMediaCatalogueNumber: return CD_MCN;
|
||||
case CompactDiscLeadIn: return CD_LeadIn;
|
||||
default: return -1;
|
||||
case CompactDiscPartialToc:
|
||||
return CD_TOC;
|
||||
case CompactDiscSessionInfo:
|
||||
return CD_SessionInfo;
|
||||
case CompactDiscToc:
|
||||
return CD_FullTOC;
|
||||
case CompactDiscPma:
|
||||
return CD_PMA;
|
||||
case CompactDiscAtip:
|
||||
return CD_ATIP;
|
||||
case CompactDiscLeadInCdText:
|
||||
return CD_TEXT;
|
||||
case DvdPfi:
|
||||
return DVD_PFI;
|
||||
case DvdLeadInCmi:
|
||||
return DVD_CMI;
|
||||
case DvdDiscKey:
|
||||
return DVD_DiscKey;
|
||||
case DvdBca:
|
||||
return DVD_BCA;
|
||||
case DvdDmi:
|
||||
return DVD_DMI;
|
||||
case DvdMediaIdentifier:
|
||||
return DVD_MediaIdentifier;
|
||||
case DvdMediaKeyBlock:
|
||||
return DVD_MKB;
|
||||
case DvdRamDds:
|
||||
return DVDRAM_DDS;
|
||||
case DvdRamMediumStatus:
|
||||
return DVDRAM_MediumStatus;
|
||||
case DvdRamSpareArea:
|
||||
return DVDRAM_SpareArea;
|
||||
case DvdRRmd:
|
||||
return DVDR_RMD;
|
||||
case DvdRPrerecordedInfo:
|
||||
return DVDR_PreRecordedInfo;
|
||||
case DvdRMediaIdentifier:
|
||||
return DVDR_MediaIdentifier;
|
||||
case DvdRPfi:
|
||||
return DVDR_PFI;
|
||||
case DvdAdip:
|
||||
return DVD_ADIP;
|
||||
case HdDvdCpi:
|
||||
return HDDVD_CPI;
|
||||
case HdDvdMediumStatus:
|
||||
return HDDVD_MediumStatus;
|
||||
case DvdDlLayerCapacity:
|
||||
return DVDDL_LayerCapacity;
|
||||
case DvdDlMiddleZoneAddress:
|
||||
return DVDDL_MiddleZoneAddress;
|
||||
case DvdDlJumpIntervalSize:
|
||||
return DVDDL_JumpIntervalSize;
|
||||
case DvdDlManualLayerJumpLba:
|
||||
return DVDDL_ManualLayerJumpLBA;
|
||||
case BlurayDi:
|
||||
return BD_DI;
|
||||
case BlurayBca:
|
||||
return BD_BCA;
|
||||
case BlurayDds:
|
||||
return BD_DDS;
|
||||
case BlurayCartridgeStatus:
|
||||
return BD_CartridgeStatus;
|
||||
case BluraySpareArea:
|
||||
return BD_SpareArea;
|
||||
case AacsVolumeIdentifier:
|
||||
return AACS_VolumeIdentifier;
|
||||
case AacsSerialNumber:
|
||||
return AACS_SerialNumber;
|
||||
case AacsMediaIdentifier:
|
||||
return AACS_MediaIdentifier;
|
||||
case AacsMediaKeyBlock:
|
||||
return AACS_MKB;
|
||||
case AacsDataKeys:
|
||||
return AACS_DataKeys;
|
||||
case AacsLbaExtents:
|
||||
return AACS_LBAExtents;
|
||||
case CprmMediaKeyBlock:
|
||||
return AACS_CPRM_MKB;
|
||||
case HybridRecognizedLayers:
|
||||
return Hybrid_RecognizedLayers;
|
||||
case ScsiMmcWriteProtection:
|
||||
return MMC_WriteProtection;
|
||||
case ScsiMmcDiscInformation:
|
||||
return MMC_DiscInformation;
|
||||
case ScsiMmcTrackResourcesInformation:
|
||||
return MMC_TrackResourcesInformation;
|
||||
case ScsiMmcPowResourcesInformation:
|
||||
return MMC_POWResourcesInformation;
|
||||
case ScsiInquiry:
|
||||
return SCSI_INQUIRY;
|
||||
case ScsiModePage2A:
|
||||
return SCSI_MODEPAGE_2A;
|
||||
case AtaIdentify:
|
||||
return ATA_IDENTIFY;
|
||||
case AtapiIdentify:
|
||||
return ATAPI_IDENTIFY;
|
||||
case PcmciaCis:
|
||||
return PCMCIA_CIS;
|
||||
case SecureDigitalCid:
|
||||
return SD_CID;
|
||||
case SecureDigitalCsd:
|
||||
return SD_CSD;
|
||||
case SecureDigitalScr:
|
||||
return SD_SCR;
|
||||
case SecureDigitalOcr:
|
||||
return SD_OCR;
|
||||
case MultiMediaCardCid:
|
||||
return MMC_CID;
|
||||
case MultiMediaCardCsd:
|
||||
return MMC_CSD;
|
||||
case MultiMediaCardOcr:
|
||||
return MMC_OCR;
|
||||
case MultiMediaCardExtendedCsd:
|
||||
return MMC_ExtendedCSD;
|
||||
case XboxSecuritySector:
|
||||
return Xbox_SecuritySector;
|
||||
case FloppyLeadOut:
|
||||
return Floppy_LeadOut;
|
||||
case DvdDiscControlBlock:
|
||||
return DCB;
|
||||
case CompactDiscFirstTrackPregap:
|
||||
return CD_FirstTrackPregap;
|
||||
case CompactDiscLeadOut:
|
||||
return CD_LeadOut;
|
||||
case ScsiModeSense6:
|
||||
return SCSI_MODESENSE_6;
|
||||
case ScsiModeSense10:
|
||||
return SCSI_MODESENSE_10;
|
||||
case UsbDescriptors:
|
||||
return USB_Descriptors;
|
||||
case XboxDmi:
|
||||
return Xbox_DMI;
|
||||
case XboxPfi:
|
||||
return Xbox_PFI;
|
||||
case CompactDiscMediaCatalogueNumber:
|
||||
return CD_MCN;
|
||||
case CompactDiscLeadIn:
|
||||
return CD_LeadIn;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +263,9 @@ int32_t aaruf_get_xml_mediatype(int32_t type)
|
||||
case MilCD:
|
||||
case VideoNow:
|
||||
case VideoNowColor:
|
||||
case VideoNowXp: return OpticalDisc;
|
||||
default: return BlockMedia;
|
||||
case VideoNowXp:
|
||||
return OpticalDisc;
|
||||
default:
|
||||
return BlockMedia;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
* @return If positive, confidence value, with 100 being maximum confidentiality, and 0 not recognizing the file.
|
||||
* If negative, error value
|
||||
*/
|
||||
int aaruf_identify(const char* filename)
|
||||
int aaruf_identify(const char *filename)
|
||||
{
|
||||
FILE* stream;
|
||||
FILE *stream;
|
||||
|
||||
stream = fopen(filename, "rb");
|
||||
|
||||
@@ -50,7 +50,7 @@ int aaruf_identify(const char* filename)
|
||||
* @return If positive, confidence value, with 100 being maximum confidentiality, and 0 not recognizing the file.
|
||||
* If negative, error value
|
||||
*/
|
||||
int aaruf_identify_stream(FILE* imageStream)
|
||||
int aaruf_identify_stream(FILE *imageStream)
|
||||
{
|
||||
fseek(imageStream, 0, SEEK_SET);
|
||||
|
||||
|
||||
14
src/lru.c
14
src/lru.c
@@ -8,9 +8,9 @@
|
||||
// by Jehiah Czebotar 2011 - jehiah@gmail.com
|
||||
// this code is in the public domain http://unlicense.org/
|
||||
|
||||
void* find_in_cache(struct CacheHeader* cache, char* key)
|
||||
void *find_in_cache(struct CacheHeader *cache, char *key)
|
||||
{
|
||||
struct CacheEntry* entry;
|
||||
struct CacheEntry *entry;
|
||||
HASH_FIND_STR(cache->cache, key, entry);
|
||||
if(entry)
|
||||
{
|
||||
@@ -22,7 +22,7 @@ void* find_in_cache(struct CacheHeader* cache, char* key)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void add_to_cache(struct CacheHeader* cache, char* key, void* value)
|
||||
void add_to_cache(struct CacheHeader *cache, char *key, void *value)
|
||||
{
|
||||
struct CacheEntry *entry, *tmp_entry;
|
||||
// TODO: Is this needed or we're just losing cycles? uthash does not free the entry
|
||||
@@ -45,9 +45,9 @@ void add_to_cache(struct CacheHeader* cache, char* key, void* value)
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE char* int64_to_string(uint64_t number)
|
||||
FORCE_INLINE char *int64_to_string(uint64_t number)
|
||||
{
|
||||
char* charKey;
|
||||
char *charKey;
|
||||
|
||||
charKey = malloc(17);
|
||||
|
||||
@@ -72,12 +72,12 @@ FORCE_INLINE char* int64_to_string(uint64_t number)
|
||||
return charKey;
|
||||
}
|
||||
|
||||
void* find_in_cache_uint64(struct CacheHeader* cache, uint64_t key)
|
||||
void *find_in_cache_uint64(struct CacheHeader *cache, uint64_t key)
|
||||
{
|
||||
return find_in_cache(cache, int64_to_string(key));
|
||||
}
|
||||
|
||||
void add_to_cache_uint64(struct CacheHeader* cache, uint64_t key, void* value)
|
||||
void add_to_cache_uint64(struct CacheHeader *cache, uint64_t key, void *value)
|
||||
{
|
||||
return add_to_cache(cache, int64_to_string(key), value);
|
||||
}
|
||||
29
src/lzma.c
29
src/lzma.c
@@ -23,30 +23,17 @@
|
||||
|
||||
#include "../3rdparty/lzma-21.03beta/C/LzmaLib.h"
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_lzma_decode_buffer(uint8_t* dst_buffer,
|
||||
size_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t* srcLen,
|
||||
const uint8_t* props,
|
||||
size_t propsSize)
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_lzma_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
|
||||
size_t *srcLen, const uint8_t *props, size_t propsSize)
|
||||
{
|
||||
return LzmaUncompress(dst_buffer, dst_size, src_buffer, srcLen, props, propsSize);
|
||||
}
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_lzma_encode_buffer(uint8_t* dst_buffer,
|
||||
size_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t srcLen,
|
||||
uint8_t* outProps,
|
||||
size_t* outPropsSize,
|
||||
int32_t level,
|
||||
uint32_t dictSize,
|
||||
int32_t lc,
|
||||
int32_t lp,
|
||||
int32_t pb,
|
||||
int32_t fb,
|
||||
int32_t numThreads)
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_lzma_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
|
||||
size_t srcLen, uint8_t *outProps, size_t *outPropsSize,
|
||||
int32_t level, uint32_t dictSize, int32_t lc, int32_t lp,
|
||||
int32_t pb, int32_t fb, int32_t numThreads)
|
||||
{
|
||||
return LzmaCompress(
|
||||
dst_buffer, dst_size, src_buffer, srcLen, outProps, outPropsSize, level, dictSize, lc, lp, pb, fb, numThreads);
|
||||
return LzmaCompress(dst_buffer, dst_size, src_buffer, srcLen, outProps, outPropsSize, level, dictSize, lc, lp, pb,
|
||||
fb, numThreads);
|
||||
}
|
||||
|
||||
346
src/open.c
346
src/open.c
@@ -28,29 +28,29 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
void* aaruf_open(const char* filepath)
|
||||
void *aaruf_open(const char *filepath)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
aaruformatContext *ctx;
|
||||
int errorNo;
|
||||
size_t readBytes;
|
||||
long pos;
|
||||
IndexHeader idxHeader;
|
||||
IndexEntry* idxEntries;
|
||||
uint8_t* data;
|
||||
uint8_t* cmpData;
|
||||
uint8_t* cstData;
|
||||
uint32_t* cdDdt;
|
||||
IndexEntry *idxEntries;
|
||||
uint8_t *data;
|
||||
uint8_t *cmpData;
|
||||
uint8_t *cstData;
|
||||
uint32_t *cdDdt;
|
||||
uint64_t crc64;
|
||||
int i, j, k;
|
||||
uint16_t e;
|
||||
uint8_t lzmaProperties[LZMA_PROPERTIES_LENGTH];
|
||||
size_t lzmaSize;
|
||||
ChecksumHeader checksum_header;
|
||||
ChecksumEntry* checksum_entry;
|
||||
mediaTagEntry* mediaTag;
|
||||
mediaTagEntry* oldMediaTag;
|
||||
ChecksumEntry *checksum_entry;
|
||||
mediaTagEntry *mediaTag;
|
||||
mediaTagEntry *oldMediaTag;
|
||||
|
||||
ctx = (aaruformatContext*)malloc(sizeof(aaruformatContext));
|
||||
ctx = (aaruformatContext *)malloc(sizeof(aaruformatContext));
|
||||
memset(ctx, 0, sizeof(aaruformatContext));
|
||||
|
||||
if(ctx == NULL)
|
||||
@@ -97,12 +97,10 @@ void* aaruf_open(const char* filepath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Opening image version %d.%d\n",
|
||||
ctx->header.imageMajorVersion,
|
||||
fprintf(stderr, "libaaruformat: Opening image version %d.%d\n", ctx->header.imageMajorVersion,
|
||||
ctx->header.imageMinorVersion);
|
||||
|
||||
ctx->readableSectorTags = (bool*)malloc(sizeof(bool) * MaxSectorTag);
|
||||
ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * MaxSectorTag);
|
||||
|
||||
if(ctx->readableSectorTags == NULL)
|
||||
{
|
||||
@@ -115,20 +113,18 @@ void* aaruf_open(const char* filepath)
|
||||
memset(ctx->readableSectorTags, 0, sizeof(bool) * MaxSectorTag);
|
||||
|
||||
ctx->imageInfo.Application = ctx->header.application;
|
||||
ctx->imageInfo.ApplicationVersion = (uint8_t*)malloc(32);
|
||||
ctx->imageInfo.ApplicationVersion = (uint8_t *)malloc(32);
|
||||
if(ctx->imageInfo.ApplicationVersion != NULL)
|
||||
{
|
||||
memset(ctx->imageInfo.ApplicationVersion, 0, 32);
|
||||
sprintf((char*)ctx->imageInfo.ApplicationVersion,
|
||||
"%d.%d",
|
||||
ctx->header.applicationMajorVersion,
|
||||
sprintf((char *)ctx->imageInfo.ApplicationVersion, "%d.%d", ctx->header.applicationMajorVersion,
|
||||
ctx->header.applicationMinorVersion);
|
||||
}
|
||||
ctx->imageInfo.Version = (uint8_t*)malloc(32);
|
||||
ctx->imageInfo.Version = (uint8_t *)malloc(32);
|
||||
if(ctx->imageInfo.Version != NULL)
|
||||
{
|
||||
memset(ctx->imageInfo.Version, 0, 32);
|
||||
sprintf((char*)ctx->imageInfo.Version, "%d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion);
|
||||
sprintf((char *)ctx->imageInfo.Version, "%d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion);
|
||||
}
|
||||
ctx->imageInfo.MediaType = ctx->header.mediaType;
|
||||
|
||||
@@ -161,12 +157,10 @@ void* aaruf_open(const char* filepath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Index at %" PRIu64 " contains %d entries\n",
|
||||
ctx->header.indexOffset,
|
||||
fprintf(stderr, "libaaruformat: Index at %" PRIu64 " contains %d entries\n", ctx->header.indexOffset,
|
||||
idxHeader.entries);
|
||||
|
||||
idxEntries = (IndexEntry*)malloc(sizeof(IndexEntry) * idxHeader.entries);
|
||||
idxEntries = (IndexEntry *)malloc(sizeof(IndexEntry) * idxHeader.entries);
|
||||
|
||||
if(idxEntries == NULL)
|
||||
{
|
||||
@@ -191,11 +185,8 @@ void* aaruf_open(const char* filepath)
|
||||
|
||||
for(i = 0; i < idxHeader.entries; i++)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Block type %4.4s with data type %d is indexed to be at %" PRIu64 "\n",
|
||||
(char*)&idxEntries[i].blockType,
|
||||
idxEntries[i].dataType,
|
||||
idxEntries[i].offset);
|
||||
fprintf(stderr, "libaaruformat: Block type %4.4s with data type %d is indexed to be at %" PRIu64 "\n",
|
||||
(char *)&idxEntries[i].blockType, idxEntries[i].dataType, idxEntries[i].offset);
|
||||
}
|
||||
|
||||
bool foundUserDataDdt = false;
|
||||
@@ -208,8 +199,7 @@ void* aaruf_open(const char* filepath)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Could not seek to %" PRIu64 " as indicated by index entry %d, continuing...\n",
|
||||
idxEntries[i].offset,
|
||||
i);
|
||||
idxEntries[i].offset, i);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -227,8 +217,8 @@ void* aaruf_open(const char* filepath)
|
||||
|
||||
if(readBytes != sizeof(BlockHeader))
|
||||
{
|
||||
fprintf(
|
||||
stderr, "libaaruformat: Could not read block header at %" PRIu64 "\n", idxEntries[i].offset);
|
||||
fprintf(stderr, "libaaruformat: Could not read block header at %" PRIu64 "\n",
|
||||
idxEntries[i].offset);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -246,8 +236,7 @@ void* aaruf_open(const char* filepath)
|
||||
|
||||
if(blockHeader.identifier != idxEntries[i].blockType)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
fprintf(stderr, "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
idxEntries[i].offset);
|
||||
break;
|
||||
}
|
||||
@@ -257,39 +246,33 @@ void* aaruf_open(const char* filepath)
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Expected block with data type %4.4s at position %" PRIu64
|
||||
" but found data type %4.4s\n",
|
||||
(char*)&idxEntries[i].blockType,
|
||||
idxEntries[i].offset,
|
||||
(char*)&blockHeader.type);
|
||||
(char *)&idxEntries[i].blockType, idxEntries[i].offset, (char *)&blockHeader.type);
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Found data block with type %4.4s at position %" PRIu64 "\n",
|
||||
(char*)&idxEntries[i].blockType,
|
||||
idxEntries[i].offset);
|
||||
fprintf(stderr, "libaaruformat: Found data block with type %4.4s at position %" PRIu64 "\n",
|
||||
(char *)&idxEntries[i].blockType, idxEntries[i].offset);
|
||||
|
||||
if(blockHeader.compression == Lzma || blockHeader.compression == LzmaClauniaSubchannelTransform)
|
||||
{
|
||||
if(blockHeader.compression == LzmaClauniaSubchannelTransform &&
|
||||
blockHeader.type != CdSectorSubchannel)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Invalid compression type %d for block with data type %d, continuing...\n",
|
||||
blockHeader.compression,
|
||||
blockHeader.type);
|
||||
fprintf(stderr, "Invalid compression type %d for block with data type %d, continuing...\n",
|
||||
blockHeader.compression, blockHeader.type);
|
||||
break;
|
||||
}
|
||||
|
||||
lzmaSize = blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
cmpData = (uint8_t*)malloc(lzmaSize);
|
||||
cmpData = (uint8_t *)malloc(lzmaSize);
|
||||
if(cmpData == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate memory for block, continuing...\n");
|
||||
break;
|
||||
}
|
||||
|
||||
data = (uint8_t*)malloc(blockHeader.length);
|
||||
data = (uint8_t *)malloc(blockHeader.length);
|
||||
if(data == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate memory for block, continuing...\n");
|
||||
@@ -316,8 +299,8 @@ void* aaruf_open(const char* filepath)
|
||||
}
|
||||
|
||||
readBytes = blockHeader.length;
|
||||
errorNo = aaruf_lzma_decode_buffer(
|
||||
data, &readBytes, cmpData, &lzmaSize, lzmaProperties, LZMA_PROPERTIES_LENGTH);
|
||||
errorNo = aaruf_lzma_decode_buffer(data, &readBytes, cmpData, &lzmaSize, lzmaProperties,
|
||||
LZMA_PROPERTIES_LENGTH);
|
||||
|
||||
if(errorNo != 0)
|
||||
{
|
||||
@@ -363,7 +346,7 @@ void* aaruf_open(const char* filepath)
|
||||
}
|
||||
else if(blockHeader.compression == None)
|
||||
{
|
||||
data = (uint8_t*)malloc(blockHeader.length);
|
||||
data = (uint8_t *)malloc(blockHeader.length);
|
||||
if(data == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate memory for block, continuing...\n");
|
||||
@@ -381,8 +364,7 @@ void* aaruf_open(const char* filepath)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Found unknown compression type %d, continuing...\n",
|
||||
fprintf(stderr, "libaaruformat: Found unknown compression type %d, continuing...\n",
|
||||
blockHeader.compression);
|
||||
break;
|
||||
}
|
||||
@@ -399,8 +381,7 @@ void* aaruf_open(const char* filepath)
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64
|
||||
", continuing...\n",
|
||||
crc64,
|
||||
blockHeader.crc64);
|
||||
crc64, blockHeader.crc64);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -420,7 +401,8 @@ void* aaruf_open(const char* filepath)
|
||||
break;
|
||||
case CdSectorSuffix:
|
||||
case CdSectorSuffixCorrected:
|
||||
if(idxEntries[i].dataType == CdSectorSuffixCorrected) ctx->sectorSuffixCorrected = data;
|
||||
if(idxEntries[i].dataType == CdSectorSuffixCorrected)
|
||||
ctx->sectorSuffixCorrected = data;
|
||||
else
|
||||
ctx->sectorSuffix = data;
|
||||
|
||||
@@ -440,9 +422,11 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->sectorSubchannel = data;
|
||||
ctx->readableSectorTags[AppleSectorTag] = true;
|
||||
break;
|
||||
case CompactDiscMode2Subheader: ctx->mode2Subheaders = data; break;
|
||||
case CompactDiscMode2Subheader:
|
||||
ctx->mode2Subheaders = data;
|
||||
break;
|
||||
default:
|
||||
mediaTag = (mediaTagEntry*)malloc(sizeof(mediaTagEntry));
|
||||
mediaTag = (mediaTagEntry *)malloc(sizeof(mediaTagEntry));
|
||||
|
||||
if(mediaTag == NULL)
|
||||
{
|
||||
@@ -474,8 +458,8 @@ void* aaruf_open(const char* filepath)
|
||||
|
||||
if(readBytes != sizeof(DdtHeader))
|
||||
{
|
||||
fprintf(
|
||||
stderr, "libaaruformat: Could not read block header at %" PRIu64 "\n", idxEntries[i].offset);
|
||||
fprintf(stderr, "libaaruformat: Could not read block header at %" PRIu64 "\n",
|
||||
idxEntries[i].offset);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -496,14 +480,14 @@ void* aaruf_open(const char* filepath)
|
||||
case Lzma:
|
||||
lzmaSize = ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
cmpData = (uint8_t*)malloc(lzmaSize);
|
||||
cmpData = (uint8_t *)malloc(lzmaSize);
|
||||
if(cmpData == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate memory for DDT, continuing...\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ctx->userDataDdt = (uint64_t*)malloc(ddtHeader.length);
|
||||
ctx->userDataDdt = (uint64_t *)malloc(ddtHeader.length);
|
||||
if(ctx->userDataDdt == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate memory for DDT, continuing...\n");
|
||||
@@ -532,12 +516,8 @@ void* aaruf_open(const char* filepath)
|
||||
}
|
||||
|
||||
readBytes = ddtHeader.length;
|
||||
errorNo = aaruf_lzma_decode_buffer((uint8_t*)ctx->userDataDdt,
|
||||
&readBytes,
|
||||
cmpData,
|
||||
&lzmaSize,
|
||||
lzmaProperties,
|
||||
LZMA_PROPERTIES_LENGTH);
|
||||
errorNo = aaruf_lzma_decode_buffer((uint8_t *)ctx->userDataDdt, &readBytes, cmpData,
|
||||
&lzmaSize, lzmaProperties, LZMA_PROPERTIES_LENGTH);
|
||||
|
||||
if(errorNo != 0)
|
||||
{
|
||||
@@ -573,12 +553,8 @@ void* aaruf_open(const char* filepath)
|
||||
case None:
|
||||
#ifdef __linux__
|
||||
ctx->mappedMemoryDdtSize = sizeof(uint64_t) * ddtHeader.entries;
|
||||
ctx->userDataDdt = mmap(NULL,
|
||||
ctx->mappedMemoryDdtSize,
|
||||
PROT_READ,
|
||||
MAP_SHARED,
|
||||
fileno(ctx->imageStream),
|
||||
idxEntries[i].offset + sizeof(ddtHeader));
|
||||
ctx->userDataDdt = mmap(NULL, ctx->mappedMemoryDdtSize, PROT_READ, MAP_SHARED,
|
||||
fileno(ctx->imageStream), idxEntries[i].offset + sizeof(ddtHeader));
|
||||
|
||||
if(ctx->userDataDdt == MAP_FAILED)
|
||||
{
|
||||
@@ -589,14 +565,13 @@ void* aaruf_open(const char* filepath)
|
||||
|
||||
ctx->inMemoryDdt = false;
|
||||
break;
|
||||
#else // TODO: Implement
|
||||
#else // TODO: Implement
|
||||
fprintf(stderr, "libaaruformat: Uncompressed DDT not yet implemented...\n");
|
||||
foundUserDataDdt = false;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Found unknown compression type %d, continuing...\n",
|
||||
fprintf(stderr, "libaaruformat: Found unknown compression type %d, continuing...\n",
|
||||
blockHeader.compression);
|
||||
foundUserDataDdt = false;
|
||||
break;
|
||||
@@ -611,14 +586,14 @@ void* aaruf_open(const char* filepath)
|
||||
case Lzma:
|
||||
lzmaSize = ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
cmpData = (uint8_t*)malloc(lzmaSize);
|
||||
cmpData = (uint8_t *)malloc(lzmaSize);
|
||||
if(cmpData == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate memory for DDT, continuing...\n");
|
||||
break;
|
||||
}
|
||||
|
||||
cdDdt = (uint32_t*)malloc(ddtHeader.length);
|
||||
cdDdt = (uint32_t *)malloc(ddtHeader.length);
|
||||
if(cdDdt == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate memory for DDT, continuing...\n");
|
||||
@@ -647,12 +622,8 @@ void* aaruf_open(const char* filepath)
|
||||
}
|
||||
|
||||
readBytes = ddtHeader.length;
|
||||
errorNo = aaruf_lzma_decode_buffer((uint8_t*)cdDdt,
|
||||
&readBytes,
|
||||
cmpData,
|
||||
&lzmaSize,
|
||||
lzmaProperties,
|
||||
LZMA_PROPERTIES_LENGTH);
|
||||
errorNo = aaruf_lzma_decode_buffer((uint8_t *)cdDdt, &readBytes, cmpData, &lzmaSize,
|
||||
lzmaProperties, LZMA_PROPERTIES_LENGTH);
|
||||
|
||||
if(errorNo != 0)
|
||||
{
|
||||
@@ -680,7 +651,8 @@ void* aaruf_open(const char* filepath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(idxEntries[i].dataType == CdSectorPrefixCorrected) ctx->sectorPrefixDdt = cdDdt;
|
||||
if(idxEntries[i].dataType == CdSectorPrefixCorrected)
|
||||
ctx->sectorPrefixDdt = cdDdt;
|
||||
else if(idxEntries[i].dataType == CdSectorSuffixCorrected)
|
||||
ctx->sectorSuffixDdt = cdDdt;
|
||||
else
|
||||
@@ -690,7 +662,7 @@ void* aaruf_open(const char* filepath)
|
||||
|
||||
// TODO: Check CRC
|
||||
case None:
|
||||
cdDdt = (uint32_t*)malloc(ddtHeader.entries * sizeof(uint32_t));
|
||||
cdDdt = (uint32_t *)malloc(ddtHeader.entries * sizeof(uint32_t));
|
||||
|
||||
if(mediaTag == NULL)
|
||||
{
|
||||
@@ -707,7 +679,8 @@ void* aaruf_open(const char* filepath)
|
||||
break;
|
||||
}
|
||||
|
||||
if(idxEntries[i].dataType == CdSectorPrefixCorrected) ctx->sectorPrefixDdt = cdDdt;
|
||||
if(idxEntries[i].dataType == CdSectorPrefixCorrected)
|
||||
ctx->sectorPrefixDdt = cdDdt;
|
||||
else if(idxEntries[i].dataType == CdSectorSuffixCorrected)
|
||||
ctx->sectorSuffixDdt = cdDdt;
|
||||
else
|
||||
@@ -715,8 +688,7 @@ void* aaruf_open(const char* filepath)
|
||||
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Found unknown compression type %d, continuing...\n",
|
||||
fprintf(stderr, "libaaruformat: Found unknown compression type %d, continuing...\n",
|
||||
blockHeader.compression);
|
||||
break;
|
||||
}
|
||||
@@ -735,11 +707,8 @@ void* aaruf_open(const char* filepath)
|
||||
|
||||
if(ctx->geometryBlock.identifier == GeometryBlock)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Geometry set to %d cylinders %d heads %d sectors per track\n",
|
||||
ctx->geometryBlock.cylinders,
|
||||
ctx->geometryBlock.heads,
|
||||
ctx->geometryBlock.sectorsPerTrack);
|
||||
fprintf(stderr, "libaaruformat: Geometry set to %d cylinders %d heads %d sectors per track\n",
|
||||
ctx->geometryBlock.cylinders, ctx->geometryBlock.heads, ctx->geometryBlock.sectorsPerTrack);
|
||||
|
||||
ctx->imageInfo.Cylinders = ctx->geometryBlock.cylinders;
|
||||
ctx->imageInfo.Heads = ctx->geometryBlock.heads;
|
||||
@@ -763,15 +732,14 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->metadataBlockHeader.identifier != idxEntries[i].blockType)
|
||||
{
|
||||
memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader));
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
fprintf(stderr, "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
idxEntries[i].offset);
|
||||
break;
|
||||
}
|
||||
|
||||
ctx->imageInfo.ImageSize += ctx->metadataBlockHeader.blockSize;
|
||||
|
||||
ctx->metadataBlock = (uint8_t*)malloc(ctx->metadataBlockHeader.blockSize);
|
||||
ctx->metadataBlock = (uint8_t *)malloc(ctx->metadataBlockHeader.blockSize);
|
||||
|
||||
if(ctx->metadataBlock == NULL)
|
||||
{
|
||||
@@ -793,9 +761,7 @@ void* aaruf_open(const char* filepath)
|
||||
{
|
||||
ctx->imageInfo.MediaSequence = ctx->metadataBlockHeader.mediaSequence;
|
||||
ctx->imageInfo.LastMediaSequence = ctx->metadataBlockHeader.lastMediaSequence;
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Setting media sequence as %d of %d\n",
|
||||
ctx->imageInfo.MediaSequence,
|
||||
fprintf(stderr, "libaaruformat: Setting media sequence as %d of %d\n", ctx->imageInfo.MediaSequence,
|
||||
ctx->imageInfo.LastMediaSequence);
|
||||
}
|
||||
|
||||
@@ -803,11 +769,10 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.creatorOffset + ctx->metadataBlockHeader.creatorLength <=
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.Creator = (uint8_t*)malloc(ctx->metadataBlockHeader.creatorLength);
|
||||
ctx->imageInfo.Creator = (uint8_t *)malloc(ctx->metadataBlockHeader.creatorLength);
|
||||
if(ctx->imageInfo.Creator != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.Creator,
|
||||
ctx->metadataBlock + ctx->metadataBlockHeader.creatorOffset,
|
||||
memcpy(ctx->imageInfo.Creator, ctx->metadataBlock + ctx->metadataBlockHeader.creatorOffset,
|
||||
ctx->metadataBlockHeader.creatorLength);
|
||||
}
|
||||
}
|
||||
@@ -816,11 +781,10 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.commentsOffset + ctx->metadataBlockHeader.commentsLength <=
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.Comments = (uint8_t*)malloc(ctx->metadataBlockHeader.commentsLength);
|
||||
ctx->imageInfo.Comments = (uint8_t *)malloc(ctx->metadataBlockHeader.commentsLength);
|
||||
if(ctx->imageInfo.Comments != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.Comments,
|
||||
ctx->metadataBlock + ctx->metadataBlockHeader.commentsOffset,
|
||||
memcpy(ctx->imageInfo.Comments, ctx->metadataBlock + ctx->metadataBlockHeader.commentsOffset,
|
||||
ctx->metadataBlockHeader.commentsLength);
|
||||
}
|
||||
}
|
||||
@@ -829,7 +793,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.mediaTitleOffset + ctx->metadataBlockHeader.mediaTitleLength <=
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.MediaTitle = (uint8_t*)malloc(ctx->metadataBlockHeader.mediaTitleLength);
|
||||
ctx->imageInfo.MediaTitle = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaTitleLength);
|
||||
if(ctx->imageInfo.MediaTitle != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.MediaTitle,
|
||||
@@ -844,7 +808,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.MediaManufacturer =
|
||||
(uint8_t*)malloc(ctx->metadataBlockHeader.mediaManufacturerLength);
|
||||
(uint8_t *)malloc(ctx->metadataBlockHeader.mediaManufacturerLength);
|
||||
if(ctx->imageInfo.MediaManufacturer != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.MediaManufacturer,
|
||||
@@ -857,7 +821,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.mediaModelOffset + ctx->metadataBlockHeader.mediaModelLength <=
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.MediaModel = (uint8_t*)malloc(ctx->metadataBlockHeader.mediaModelOffset);
|
||||
ctx->imageInfo.MediaModel = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaModelOffset);
|
||||
if(ctx->imageInfo.MediaModel != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.MediaModel,
|
||||
@@ -872,7 +836,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.MediaSerialNumber =
|
||||
(uint8_t*)malloc(ctx->metadataBlockHeader.mediaSerialNumberLength);
|
||||
(uint8_t *)malloc(ctx->metadataBlockHeader.mediaSerialNumberLength);
|
||||
if(ctx->imageInfo.MediaSerialNumber != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.MediaSerialNumber,
|
||||
@@ -885,7 +849,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.mediaBarcodeOffset + ctx->metadataBlockHeader.mediaBarcodeLength <=
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.MediaBarcode = (uint8_t*)malloc(ctx->metadataBlockHeader.mediaBarcodeLength);
|
||||
ctx->imageInfo.MediaBarcode = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaBarcodeLength);
|
||||
if(ctx->imageInfo.MediaBarcode != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.MediaBarcode,
|
||||
@@ -898,7 +862,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.mediaPartNumberOffset + ctx->metadataBlockHeader.mediaPartNumberLength <=
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.MediaPartNumber = (uint8_t*)malloc(ctx->metadataBlockHeader.mediaPartNumberLength);
|
||||
ctx->imageInfo.MediaPartNumber = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaPartNumberLength);
|
||||
if(ctx->imageInfo.MediaPartNumber != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.MediaPartNumber,
|
||||
@@ -913,7 +877,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.DriveManufacturer =
|
||||
(uint8_t*)malloc(ctx->metadataBlockHeader.driveManufacturerLength);
|
||||
(uint8_t *)malloc(ctx->metadataBlockHeader.driveManufacturerLength);
|
||||
if(ctx->imageInfo.DriveManufacturer != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.DriveManufacturer,
|
||||
@@ -926,7 +890,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.driveModelOffset + ctx->metadataBlockHeader.driveModelLength <=
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.DriveModel = (uint8_t*)malloc(ctx->metadataBlockHeader.driveModelLength);
|
||||
ctx->imageInfo.DriveModel = (uint8_t *)malloc(ctx->metadataBlockHeader.driveModelLength);
|
||||
if(ctx->imageInfo.DriveModel != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.DriveModel,
|
||||
@@ -941,7 +905,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.DriveSerialNumber =
|
||||
(uint8_t*)malloc(ctx->metadataBlockHeader.driveSerialNumberLength);
|
||||
(uint8_t *)malloc(ctx->metadataBlockHeader.driveSerialNumberLength);
|
||||
if(ctx->imageInfo.DriveSerialNumber != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.DriveSerialNumber,
|
||||
@@ -956,7 +920,7 @@ void* aaruf_open(const char* filepath)
|
||||
ctx->metadataBlockHeader.blockSize)
|
||||
{
|
||||
ctx->imageInfo.DriveFirmwareRevision =
|
||||
(uint8_t*)malloc(ctx->metadataBlockHeader.driveFirmwareRevisionLength);
|
||||
(uint8_t *)malloc(ctx->metadataBlockHeader.driveFirmwareRevisionLength);
|
||||
if(ctx->imageInfo.DriveFirmwareRevision != NULL)
|
||||
{
|
||||
memcpy(ctx->imageInfo.DriveFirmwareRevision,
|
||||
@@ -979,14 +943,13 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->tracksHeader.identifier != TracksBlock)
|
||||
{
|
||||
memset(&ctx->tracksHeader, 0, sizeof(TracksHeader));
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
fprintf(stderr, "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
idxEntries[i].offset);
|
||||
}
|
||||
|
||||
ctx->imageInfo.ImageSize += sizeof(TrackEntry) * ctx->tracksHeader.entries;
|
||||
|
||||
ctx->trackEntries = (TrackEntry*)malloc(sizeof(TrackEntry) * ctx->tracksHeader.entries);
|
||||
ctx->trackEntries = (TrackEntry *)malloc(sizeof(TrackEntry) * ctx->tracksHeader.entries);
|
||||
|
||||
if(ctx->trackEntries == NULL)
|
||||
{
|
||||
@@ -1004,8 +967,8 @@ void* aaruf_open(const char* filepath)
|
||||
fprintf(stderr, "libaaruformat: Could not read metadata block, continuing...\n");
|
||||
}
|
||||
|
||||
crc64 =
|
||||
aaruf_crc64_data((const uint8_t*)ctx->trackEntries, ctx->tracksHeader.entries * sizeof(TrackEntry));
|
||||
crc64 = aaruf_crc64_data((const uint8_t *)ctx->trackEntries,
|
||||
ctx->tracksHeader.entries * sizeof(TrackEntry));
|
||||
|
||||
// Due to how C# wrote it, it is effectively reversed
|
||||
if(ctx->header.imageMajorVersion <= AARUF_VERSION) crc64 = bswap_64(crc64);
|
||||
@@ -1015,14 +978,11 @@ void* aaruf_open(const char* filepath)
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64
|
||||
", continuing...\n",
|
||||
crc64,
|
||||
ctx->tracksHeader.crc64);
|
||||
crc64, ctx->tracksHeader.crc64);
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Found %d tracks at position %" PRIu64 ".\n",
|
||||
ctx->tracksHeader.entries,
|
||||
fprintf(stderr, "libaaruformat: Found %d tracks at position %" PRIu64 ".\n", ctx->tracksHeader.entries,
|
||||
idxEntries[i].offset);
|
||||
|
||||
ctx->imageInfo.HasPartitions = true;
|
||||
@@ -1060,14 +1020,13 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->cicmBlockHeader.identifier != CicmBlock)
|
||||
{
|
||||
memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock));
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
fprintf(stderr, "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
idxEntries[i].offset);
|
||||
}
|
||||
|
||||
ctx->imageInfo.ImageSize += ctx->cicmBlockHeader.length;
|
||||
|
||||
ctx->cicmBlock = (uint8_t*)malloc(ctx->cicmBlockHeader.length);
|
||||
ctx->cicmBlock = (uint8_t *)malloc(ctx->cicmBlockHeader.length);
|
||||
|
||||
if(ctx->cicmBlock == NULL)
|
||||
{
|
||||
@@ -1102,12 +1061,11 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->dumpHardwareHeader.identifier != DumpHardwareBlock)
|
||||
{
|
||||
memset(&ctx->dumpHardwareHeader, 0, sizeof(DumpHardwareHeader));
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
fprintf(stderr, "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "\n",
|
||||
idxEntries[i].offset);
|
||||
}
|
||||
|
||||
data = (uint8_t*)malloc(ctx->dumpHardwareHeader.length);
|
||||
data = (uint8_t *)malloc(ctx->dumpHardwareHeader.length);
|
||||
|
||||
if(data == NULL)
|
||||
{
|
||||
@@ -1132,8 +1090,7 @@ void* aaruf_open(const char* filepath)
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64
|
||||
", continuing...\n",
|
||||
crc64,
|
||||
ctx->dumpHardwareHeader.crc64);
|
||||
crc64, ctx->dumpHardwareHeader.crc64);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1141,7 +1098,7 @@ void* aaruf_open(const char* filepath)
|
||||
free(data);
|
||||
fseek(ctx->imageStream, -(long)readBytes, SEEK_CUR);
|
||||
|
||||
ctx->dumpHardwareEntriesWithData = (DumpHardwareEntriesWithData*)malloc(
|
||||
ctx->dumpHardwareEntriesWithData = (DumpHardwareEntriesWithData *)malloc(
|
||||
sizeof(DumpHardwareEntriesWithData) * ctx->dumpHardwareHeader.entries);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData == NULL)
|
||||
@@ -1152,14 +1109,13 @@ void* aaruf_open(const char* filepath)
|
||||
break;
|
||||
}
|
||||
|
||||
memset(ctx->dumpHardwareEntriesWithData,
|
||||
0,
|
||||
memset(ctx->dumpHardwareEntriesWithData, 0,
|
||||
sizeof(DumpHardwareEntriesWithData) * ctx->dumpHardwareHeader.entries);
|
||||
|
||||
for(e = 0; e < ctx->dumpHardwareHeader.entries; e++)
|
||||
{
|
||||
readBytes = fread(
|
||||
&ctx->dumpHardwareEntriesWithData[e].entry, 1, sizeof(DumpHardwareEntry), ctx->imageStream);
|
||||
readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].entry, 1, sizeof(DumpHardwareEntry),
|
||||
ctx->imageStream);
|
||||
|
||||
if(readBytes != sizeof(DumpHardwareEntry))
|
||||
{
|
||||
@@ -1171,24 +1127,22 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength > 0)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e].manufacturer =
|
||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength + 1);
|
||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength + 1);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].manufacturer != NULL)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e]
|
||||
.manufacturer[ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength] = 0;
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].manufacturer,
|
||||
1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength,
|
||||
ctx->imageStream);
|
||||
readBytes =
|
||||
fread(ctx->dumpHardwareEntriesWithData[e].manufacturer, 1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength, ctx->imageStream);
|
||||
|
||||
if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength)
|
||||
{
|
||||
free(ctx->dumpHardwareEntriesWithData[e].manufacturer);
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength = 0;
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Could not read dump hardware block entry manufacturer, "
|
||||
"continuing...\n");
|
||||
fprintf(stderr, "libaaruformat: Could not read dump hardware block entry manufacturer, "
|
||||
"continuing...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1196,16 +1150,14 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->dumpHardwareEntriesWithData[e].entry.modelLength > 0)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e].model =
|
||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.modelLength + 1);
|
||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.modelLength + 1);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].model != NULL)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e]
|
||||
.model[ctx->dumpHardwareEntriesWithData[e].entry.modelLength] = 0;
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].model,
|
||||
1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.modelLength,
|
||||
ctx->imageStream);
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].model, 1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.modelLength, ctx->imageStream);
|
||||
|
||||
if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.modelLength)
|
||||
{
|
||||
@@ -1221,24 +1173,22 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength > 0)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e].revision =
|
||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength + 1);
|
||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength + 1);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].revision != NULL)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e]
|
||||
.revision[ctx->dumpHardwareEntriesWithData[e].entry.revisionLength] = 0;
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].revision,
|
||||
1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.revisionLength,
|
||||
ctx->imageStream);
|
||||
readBytes =
|
||||
fread(ctx->dumpHardwareEntriesWithData[e].revision, 1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.revisionLength, ctx->imageStream);
|
||||
|
||||
if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.revisionLength)
|
||||
{
|
||||
free(ctx->dumpHardwareEntriesWithData[e].revision);
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.revisionLength = 0;
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Could not read dump hardware block entry revision, "
|
||||
"continuing...\n");
|
||||
fprintf(stderr, "libaaruformat: Could not read dump hardware block entry revision, "
|
||||
"continuing...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1246,24 +1196,22 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength > 0)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e].firmware =
|
||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength + 1);
|
||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength + 1);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].firmware != NULL)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e]
|
||||
.firmware[ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength] = 0;
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].firmware,
|
||||
1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength,
|
||||
ctx->imageStream);
|
||||
readBytes =
|
||||
fread(ctx->dumpHardwareEntriesWithData[e].firmware, 1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength, ctx->imageStream);
|
||||
|
||||
if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength)
|
||||
{
|
||||
free(ctx->dumpHardwareEntriesWithData[e].firmware);
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength = 0;
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Could not read dump hardware block entry firmware, "
|
||||
"continuing...\n");
|
||||
fprintf(stderr, "libaaruformat: Could not read dump hardware block entry firmware, "
|
||||
"continuing...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1271,16 +1219,14 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->dumpHardwareEntriesWithData[e].entry.serialLength > 0)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e].serial =
|
||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.serialLength + 1);
|
||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.serialLength + 1);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].serial != NULL)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e]
|
||||
.serial[ctx->dumpHardwareEntriesWithData[e].entry.serialLength] = 0;
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].serial,
|
||||
1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.serialLength,
|
||||
ctx->imageStream);
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].serial, 1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.serialLength, ctx->imageStream);
|
||||
|
||||
if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.serialLength)
|
||||
{
|
||||
@@ -1296,16 +1242,15 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength > 0)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e].softwareName =
|
||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength + 1);
|
||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength + 1);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].softwareName != NULL)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e]
|
||||
.softwareName[ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength] = 0;
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].softwareName,
|
||||
1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength,
|
||||
ctx->imageStream);
|
||||
readBytes =
|
||||
fread(ctx->dumpHardwareEntriesWithData[e].softwareName, 1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength, ctx->imageStream);
|
||||
|
||||
if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength)
|
||||
{
|
||||
@@ -1321,14 +1266,13 @@ void* aaruf_open(const char* filepath)
|
||||
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength > 0)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e].softwareVersion =
|
||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength + 1);
|
||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength + 1);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].softwareVersion != NULL)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e]
|
||||
.softwareVersion[ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength] = 0;
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].softwareVersion,
|
||||
1,
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].softwareVersion, 1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength,
|
||||
ctx->imageStream);
|
||||
|
||||
@@ -1345,15 +1289,14 @@ void* aaruf_open(const char* filepath)
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength > 0)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem = (uint8_t*)malloc(
|
||||
ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem = (uint8_t *)malloc(
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength + 1);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem != NULL)
|
||||
{
|
||||
ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem
|
||||
[ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength] = 0;
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem,
|
||||
1,
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem, 1,
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength,
|
||||
ctx->imageStream);
|
||||
|
||||
@@ -1361,28 +1304,24 @@ void* aaruf_open(const char* filepath)
|
||||
{
|
||||
free(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem);
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength = 0;
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Could not read dump hardware block entry manufacturer, "
|
||||
"continuing...\n");
|
||||
fprintf(stderr, "libaaruformat: Could not read dump hardware block entry manufacturer, "
|
||||
"continuing...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctx->dumpHardwareEntriesWithData[e].extents =
|
||||
(DumpExtent*)malloc(sizeof(DumpExtent) * ctx->dumpHardwareEntriesWithData->entry.extents);
|
||||
(DumpExtent *)malloc(sizeof(DumpExtent) * ctx->dumpHardwareEntriesWithData->entry.extents);
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData[e].extents == NULL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Could not allocate memory for dump hardware block extents, "
|
||||
"continuing...\n");
|
||||
fprintf(stderr, "libaaruformat: Could not allocate memory for dump hardware block extents, "
|
||||
"continuing...\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].extents,
|
||||
sizeof(DumpExtent),
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.extents,
|
||||
ctx->imageStream);
|
||||
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].extents, sizeof(DumpExtent),
|
||||
ctx->dumpHardwareEntriesWithData[e].entry.extents, ctx->imageStream);
|
||||
|
||||
if(readBytes != ctx->dumpHardwareEntriesWithData->entry.extents)
|
||||
{
|
||||
@@ -1408,12 +1347,11 @@ void* aaruf_open(const char* filepath)
|
||||
if(checksum_header.identifier != ChecksumBlock)
|
||||
{
|
||||
memset(&checksum_header, 0, sizeof(ChecksumHeader));
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Incorrect identifier for checksum block at position %" PRIu64 "\n",
|
||||
fprintf(stderr, "libaaruformat: Incorrect identifier for checksum block at position %" PRIu64 "\n",
|
||||
idxEntries[i].offset);
|
||||
}
|
||||
|
||||
data = (uint8_t*)malloc(checksum_header.length);
|
||||
data = (uint8_t *)malloc(checksum_header.length);
|
||||
|
||||
if(data == NULL)
|
||||
{
|
||||
@@ -1435,7 +1373,7 @@ void* aaruf_open(const char* filepath)
|
||||
pos = 0;
|
||||
for(j = 0; j < checksum_header.entries; j++)
|
||||
{
|
||||
checksum_entry = (ChecksumEntry*)(&data[pos]);
|
||||
checksum_entry = (ChecksumEntry *)(&data[pos]);
|
||||
pos += sizeof(ChecksumEntry);
|
||||
|
||||
if(checksum_entry->type == Md5)
|
||||
@@ -1476,9 +1414,7 @@ void* aaruf_open(const char* filepath)
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"libaaruformat: Unhandled block type %4.4s with data type %d is indexed to be at %" PRIu64 "\n",
|
||||
(char*)&idxEntries[i].blockType,
|
||||
idxEntries[i].dataType,
|
||||
idxEntries[i].offset);
|
||||
(char *)&idxEntries[i].blockType, idxEntries[i].dataType, idxEntries[i].offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1512,7 +1448,7 @@ void* aaruf_open(const char* filepath)
|
||||
// TODO: Cache tracks and sessions?
|
||||
|
||||
// Initialize ECC for Compact Disc
|
||||
ctx->eccCdContext = (CdEccContext*)aaruf_ecc_cd_init();
|
||||
ctx->eccCdContext = (CdEccContext *)aaruf_ecc_cd_init();
|
||||
|
||||
ctx->magic = AARU_MAGIC;
|
||||
ctx->libraryMajorVersion = LIBAARUFORMAT_MAJOR_VERSION;
|
||||
|
||||
72
src/read.c
72
src/read.c
@@ -21,10 +21,10 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
int32_t aaruf_read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* length)
|
||||
int32_t aaruf_read_media_tag(void *context, uint8_t *data, int32_t tag, uint32_t *length)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
mediaTagEntry* item;
|
||||
aaruformatContext *ctx;
|
||||
mediaTagEntry *item;
|
||||
|
||||
if(context == NULL) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
@@ -53,19 +53,19 @@ int32_t aaruf_read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t
|
||||
return AARUF_STATUS_OK;
|
||||
}
|
||||
|
||||
int32_t aaruf_read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32_t* length)
|
||||
int32_t aaruf_read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32_t *length)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
aaruformatContext *ctx;
|
||||
uint64_t ddtEntry;
|
||||
uint32_t offsetMask;
|
||||
uint64_t offset;
|
||||
uint64_t blockOffset;
|
||||
BlockHeader* blockHeader;
|
||||
uint8_t* block;
|
||||
BlockHeader *blockHeader;
|
||||
uint8_t *block;
|
||||
size_t readBytes;
|
||||
uint8_t lzmaProperties[LZMA_PROPERTIES_LENGTH];
|
||||
size_t lzmaSize;
|
||||
uint8_t* cmpData;
|
||||
uint8_t *cmpData;
|
||||
int errorNo;
|
||||
|
||||
if(context == NULL) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
@@ -107,7 +107,7 @@ int32_t aaruf_read_sector(void* context, uint64_t sectorAddress, uint8_t* data,
|
||||
add_to_cache_uint64(&ctx->blockHeaderCache, blockOffset, blockHeader);
|
||||
}
|
||||
else
|
||||
fseek(ctx->imageStream, blockOffset + sizeof(BlockHeader), SEEK_SET); // Advance as if reading the header
|
||||
fseek(ctx->imageStream, blockOffset + sizeof(BlockHeader), SEEK_SET); // Advance as if reading the header
|
||||
|
||||
if(data == NULL || *length < blockHeader->sectorSize)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ int32_t aaruf_read_sector(void* context, uint64_t sectorAddress, uint8_t* data,
|
||||
switch(blockHeader->compression)
|
||||
{
|
||||
case None:
|
||||
block = (uint8_t*)malloc(blockHeader->length);
|
||||
block = (uint8_t *)malloc(blockHeader->length);
|
||||
if(block == NULL) return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
readBytes = fread(block, 1, blockHeader->length, ctx->imageStream);
|
||||
@@ -240,7 +240,8 @@ int32_t aaruf_read_sector(void* context, uint64_t sectorAddress, uint8_t* data,
|
||||
free(cmpData);
|
||||
|
||||
break;
|
||||
default: return AARUF_ERROR_UNSUPPORTED_COMPRESSION;
|
||||
default:
|
||||
return AARUF_ERROR_UNSUPPORTED_COMPRESSION;
|
||||
}
|
||||
|
||||
// Add block to cache
|
||||
@@ -251,9 +252,9 @@ int32_t aaruf_read_sector(void* context, uint64_t sectorAddress, uint8_t* data,
|
||||
return AARUF_STATUS_OK;
|
||||
}
|
||||
|
||||
int32_t aaruf_read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress, uint32_t* length, uint8_t track)
|
||||
int32_t aaruf_read_track_sector(void *context, uint8_t *data, uint64_t sectorAddress, uint32_t *length, uint8_t track)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
aaruformatContext *ctx;
|
||||
int i;
|
||||
|
||||
if(context == NULL) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
@@ -276,12 +277,12 @@ int32_t aaruf_read_track_sector(void* context, uint8_t* data, uint64_t sectorAdd
|
||||
return AARUF_ERROR_TRACK_NOT_FOUND;
|
||||
}
|
||||
|
||||
int32_t aaruf_read_sector_long(void* context, uint64_t sectorAddress, uint8_t* data, uint32_t* length)
|
||||
int32_t aaruf_read_sector_long(void *context, uint64_t sectorAddress, uint8_t *data, uint32_t *length)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
aaruformatContext *ctx;
|
||||
uint32_t bareLength;
|
||||
uint32_t tagLength;
|
||||
uint8_t* bareData;
|
||||
uint8_t *bareData;
|
||||
int32_t res;
|
||||
TrackEntry trk;
|
||||
int i;
|
||||
@@ -309,7 +310,7 @@ int32_t aaruf_read_sector_long(void* context, uint64_t sectorAddress, uint8_t* d
|
||||
bareLength = 0;
|
||||
aaruf_read_sector(context, sectorAddress, NULL, &bareLength);
|
||||
|
||||
bareData = (uint8_t*)malloc(bareLength);
|
||||
bareData = (uint8_t *)malloc(bareLength);
|
||||
|
||||
if(bareData == NULL) return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
@@ -338,11 +339,14 @@ int32_t aaruf_read_sector_long(void* context, uint64_t sectorAddress, uint8_t* d
|
||||
switch(trk.type)
|
||||
{
|
||||
case Audio:
|
||||
case Data: memcpy(data, bareData, bareLength); return res;
|
||||
case Data:
|
||||
memcpy(data, bareData, bareLength);
|
||||
return res;
|
||||
case CdMode1:
|
||||
memcpy(data + 16, bareData, 2048);
|
||||
|
||||
if(ctx->sectorPrefix != NULL) memcpy(data, ctx->sectorPrefix + (sectorAddress * 16), 16);
|
||||
if(ctx->sectorPrefix != NULL)
|
||||
memcpy(data, ctx->sectorPrefix + (sectorAddress * 16), 16);
|
||||
else if(ctx->sectorPrefixDdt != NULL)
|
||||
{
|
||||
if((ctx->sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == Correct)
|
||||
@@ -367,7 +371,8 @@ int32_t aaruf_read_sector_long(void* context, uint64_t sectorAddress, uint8_t* d
|
||||
|
||||
if(res != AARUF_STATUS_OK) return res;
|
||||
|
||||
if(ctx->sectorSuffix != NULL) memcpy(data + 2064, ctx->sectorSuffix + sectorAddress * 288, 288);
|
||||
if(ctx->sectorSuffix != NULL)
|
||||
memcpy(data + 2064, ctx->sectorSuffix + sectorAddress * 288, 288);
|
||||
else if(ctx->sectorSuffixDdt != NULL)
|
||||
{
|
||||
if((ctx->sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == Correct)
|
||||
@@ -394,7 +399,8 @@ int32_t aaruf_read_sector_long(void* context, uint64_t sectorAddress, uint8_t* d
|
||||
case CdMode2Formless:
|
||||
case CdMode2Form1:
|
||||
case CdMode2Form2:
|
||||
if(ctx->sectorPrefix != NULL) memcpy(data, ctx->sectorPrefix + sectorAddress * 16, 16);
|
||||
if(ctx->sectorPrefix != NULL)
|
||||
memcpy(data, ctx->sectorPrefix + sectorAddress * 16, 16);
|
||||
else if(ctx->sectorPrefixDdt != NULL)
|
||||
{
|
||||
if((ctx->sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == Correct)
|
||||
@@ -452,7 +458,8 @@ int32_t aaruf_read_sector_long(void* context, uint64_t sectorAddress, uint8_t* d
|
||||
memcpy(data + 16, bareData, 2336);
|
||||
|
||||
return res;
|
||||
default: return AARUF_ERROR_INVALID_TRACK_FORMAT;
|
||||
default:
|
||||
return AARUF_ERROR_INVALID_TRACK_FORMAT;
|
||||
}
|
||||
case BlockMedia:
|
||||
switch(ctx->imageInfo.MediaType)
|
||||
@@ -469,11 +476,18 @@ int32_t aaruf_read_sector_long(void* context, uint64_t sectorAddress, uint8_t* d
|
||||
{
|
||||
case AppleFileWare:
|
||||
case AppleProfile:
|
||||
case AppleWidget: tagLength = 20; break;
|
||||
case AppleWidget:
|
||||
tagLength = 20;
|
||||
break;
|
||||
case AppleSonySS:
|
||||
case AppleSonyDS: tagLength = 12; break;
|
||||
case PriamDataTower: tagLength = 24; break;
|
||||
default: return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
case AppleSonyDS:
|
||||
tagLength = 12;
|
||||
break;
|
||||
case PriamDataTower:
|
||||
tagLength = 24;
|
||||
break;
|
||||
default:
|
||||
return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
}
|
||||
|
||||
bareLength = 512;
|
||||
@@ -498,8 +512,10 @@ int32_t aaruf_read_sector_long(void* context, uint64_t sectorAddress, uint8_t* d
|
||||
free(bareData);
|
||||
|
||||
return res;
|
||||
default: return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
default:
|
||||
return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
}
|
||||
default: return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
default:
|
||||
return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
static void cpuid(int info, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx)
|
||||
static void cpuid(int info, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
unsigned int registers[4];
|
||||
@@ -58,7 +58,7 @@ static void cpuid(int info, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigne
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cpuidex(int info, int count, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx)
|
||||
static void cpuidex(int info, int count, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
unsigned int registers[4];
|
||||
@@ -152,7 +152,7 @@ int have_crypto_apple() { return 0; }
|
||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||
int have_neon()
|
||||
{
|
||||
return 1; // ARMv8-A made it mandatory
|
||||
return 1; // ARMv8-A made it mandatory
|
||||
}
|
||||
|
||||
int have_arm_crc32()
|
||||
|
||||
@@ -34,9 +34,9 @@ static uint8_t b64[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x
|
||||
0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
|
||||
0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F};
|
||||
|
||||
AARU_EXPORT spamsum_ctx* AARU_CALL aaruf_spamsum_init(void)
|
||||
AARU_EXPORT spamsum_ctx *AARU_CALL aaruf_spamsum_init(void)
|
||||
{
|
||||
spamsum_ctx* ctx = (spamsum_ctx*)malloc(sizeof(spamsum_ctx));
|
||||
spamsum_ctx *ctx = (spamsum_ctx *)malloc(sizeof(spamsum_ctx));
|
||||
if(!ctx) return NULL;
|
||||
|
||||
memset(ctx, 0, sizeof(spamsum_ctx));
|
||||
@@ -48,7 +48,7 @@ AARU_EXPORT spamsum_ctx* AARU_CALL aaruf_spamsum_init(void)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
AARU_EXPORT int AARU_CALL aaruf_spamsum_update(spamsum_ctx* ctx, const uint8_t* data, uint32_t len)
|
||||
AARU_EXPORT int AARU_CALL aaruf_spamsum_update(spamsum_ctx *ctx, const uint8_t *data, uint32_t len)
|
||||
{
|
||||
int i;
|
||||
if(!ctx || !data) return -1;
|
||||
@@ -60,16 +60,16 @@ AARU_EXPORT int AARU_CALL aaruf_spamsum_update(spamsum_ctx* ctx, const uint8_t*
|
||||
return 0;
|
||||
}
|
||||
|
||||
AARU_EXPORT void AARU_CALL aaruf_spamsum_free(spamsum_ctx* ctx)
|
||||
AARU_EXPORT void AARU_CALL aaruf_spamsum_free(spamsum_ctx *ctx)
|
||||
{
|
||||
if(ctx) free(ctx);
|
||||
}
|
||||
|
||||
#define ROLL_SUM(ctx) ((ctx)->roll.h1 + (ctx)->roll.h2 + (ctx)->roll.h3)
|
||||
#define SUM_HASH(c, h) (((h)*HASH_PRIME) ^ (c));
|
||||
#define ROLL_SUM(ctx) ((ctx)->roll.h1 + (ctx)->roll.h2 + (ctx)->roll.h3)
|
||||
#define SUM_HASH(c, h) (((h) * HASH_PRIME) ^ (c));
|
||||
#define SSDEEP_BS(index) (MIN_BLOCKSIZE << (index))
|
||||
|
||||
AARU_LOCAL inline void fuzzy_engine_step(spamsum_ctx* ctx, uint8_t c)
|
||||
AARU_LOCAL inline void fuzzy_engine_step(spamsum_ctx *ctx, uint8_t c)
|
||||
{
|
||||
uint32_t i;
|
||||
/* At each character we update the rolling hash and the normal hashes.
|
||||
@@ -122,7 +122,7 @@ AARU_LOCAL inline void fuzzy_engine_step(spamsum_ctx* ctx, uint8_t c)
|
||||
}
|
||||
}
|
||||
|
||||
AARU_LOCAL inline void roll_hash(spamsum_ctx* ctx, uint8_t c)
|
||||
AARU_LOCAL inline void roll_hash(spamsum_ctx *ctx, uint8_t c)
|
||||
{
|
||||
ctx->roll.h2 -= ctx->roll.h1;
|
||||
ctx->roll.h2 += ROLLING_WINDOW * c;
|
||||
@@ -140,7 +140,7 @@ AARU_LOCAL inline void roll_hash(spamsum_ctx* ctx, uint8_t c)
|
||||
ctx->roll.h3 ^= c;
|
||||
}
|
||||
|
||||
AARU_LOCAL inline void fuzzy_try_reduce_blockhash(spamsum_ctx* ctx)
|
||||
AARU_LOCAL inline void fuzzy_try_reduce_blockhash(spamsum_ctx *ctx)
|
||||
{
|
||||
// assert(ctx->bh_start < ctx->bh_end);
|
||||
|
||||
@@ -160,7 +160,7 @@ AARU_LOCAL inline void fuzzy_try_reduce_blockhash(spamsum_ctx* ctx)
|
||||
++ctx->bh_start;
|
||||
}
|
||||
|
||||
AARU_LOCAL inline void fuzzy_try_fork_blockhash(spamsum_ctx* ctx)
|
||||
AARU_LOCAL inline void fuzzy_try_fork_blockhash(spamsum_ctx *ctx)
|
||||
{
|
||||
if(ctx->bh_end >= NUM_BLOCKHASHES) return;
|
||||
|
||||
@@ -176,7 +176,7 @@ AARU_LOCAL inline void fuzzy_try_fork_blockhash(spamsum_ctx* ctx)
|
||||
++ctx->bh_end;
|
||||
}
|
||||
|
||||
AARU_EXPORT int AARU_CALL aaruf_spamsum_final(spamsum_ctx* ctx, uint8_t* result)
|
||||
AARU_EXPORT int AARU_CALL aaruf_spamsum_final(spamsum_ctx *ctx, uint8_t *result)
|
||||
{
|
||||
uint32_t bi = ctx->bh_start;
|
||||
uint32_t h = ROLL_SUM(ctx);
|
||||
@@ -206,7 +206,7 @@ AARU_EXPORT int AARU_CALL aaruf_spamsum_final(spamsum_ctx* ctx, uint8_t* result)
|
||||
|
||||
// assert(!(bi > 0 && ctx->bh[bi].d_len < SPAMSUM_LENGTH / 2));
|
||||
|
||||
int i = snprintf((char*)result, (size_t)remain, "%lu:", (unsigned long)SSDEEP_BS(bi));
|
||||
int i = snprintf((char *)result, (size_t)remain, "%lu:", (unsigned long)SSDEEP_BS(bi));
|
||||
|
||||
if(i <= 0) /* Maybe snprintf has set errno here? */
|
||||
return -1;
|
||||
|
||||
20
src/verify.c
20
src/verify.c
@@ -22,16 +22,16 @@
|
||||
|
||||
#define VERIFY_SIZE 1048576
|
||||
|
||||
int32_t aaruf_verify_image(void* context)
|
||||
int32_t aaruf_verify_image(void *context)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
aaruformatContext *ctx;
|
||||
uint64_t crc64;
|
||||
int i;
|
||||
IndexHeader index_header;
|
||||
IndexEntry* index_entries;
|
||||
IndexEntry *index_entries;
|
||||
size_t read_bytes;
|
||||
void* buffer;
|
||||
crc64_ctx* crc64_context;
|
||||
void *buffer;
|
||||
crc64_ctx *crc64_context;
|
||||
BlockHeader block_header;
|
||||
uint64_t verified_bytes;
|
||||
DdtHeader ddt_header;
|
||||
@@ -81,7 +81,7 @@ int32_t aaruf_verify_image(void* context)
|
||||
return AARUF_ERROR_CANNOT_READ_INDEX;
|
||||
}
|
||||
|
||||
crc64 = aaruf_crc64_data((const uint8_t*)index_entries, sizeof(IndexEntry) * index_header.entries);
|
||||
crc64 = aaruf_crc64_data((const uint8_t *)index_entries, sizeof(IndexEntry) * index_header.entries);
|
||||
|
||||
// Due to how C# wrote it, it is effectively reversed
|
||||
if(ctx->header.imageMajorVersion <= AARUF_VERSION) crc64 = bswap_64(crc64);
|
||||
@@ -104,9 +104,7 @@ int32_t aaruf_verify_image(void* context)
|
||||
|
||||
for(i = 0; i < index_header.entries; i++)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Checking block with type %4.4s at position %" PRIu64 "\n",
|
||||
(char*)&index_entries[i].blockType,
|
||||
fprintf(stderr, "Checking block with type %4.4s at position %" PRIu64 "\n", (char *)&index_entries[i].blockType,
|
||||
index_entries[i].offset);
|
||||
|
||||
fseek(ctx->imageStream, index_entries[i].offset, SEEK_SET);
|
||||
@@ -233,7 +231,9 @@ int32_t aaruf_verify_image(void* context)
|
||||
}
|
||||
|
||||
break;
|
||||
default: fprintf(stderr, "Ignoring block type %4.4s.\n", (char*)&index_entries[i].blockType); break;
|
||||
default:
|
||||
fprintf(stderr, "Ignoring block type %4.4s.\n", (char *)&index_entries[i].blockType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6,19 +6,19 @@ add_subdirectory(lib)
|
||||
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/random
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/flac.flac
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/audio.bin
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/lzma.bin
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/data.bin
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
|
||||
# 'Google_Tests_run' is the target name
|
||||
# 'test1.cpp tests2.cpp' are source files with tests
|
||||
|
||||
@@ -24,7 +24,7 @@ extern "C"
|
||||
#define CRC32_ISO_POLY 0xEDB88320
|
||||
#define CRC32_ISO_SEED 0xFFFFFFFF
|
||||
|
||||
uint32_t crc32_data(const uint8_t* data, uint32_t len)
|
||||
uint32_t crc32_data(const uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint32_t localHashInt = CRC32_ISO_SEED;
|
||||
uint32_t localTable[256];
|
||||
@@ -35,7 +35,8 @@ extern "C"
|
||||
uint32_t entry = (uint32_t)i;
|
||||
|
||||
for(j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1) entry = (entry >> 1) ^ CRC32_ISO_POLY;
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ CRC32_ISO_POLY;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
uint32_t crc32_data(const uint8_t* data, uint32_t len);
|
||||
uint32_t crc32_data(const uint8_t *data, uint32_t len);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // LIBAARUFORMAT_TESTS_CRC32_H_
|
||||
#endif // LIBAARUFORMAT_TESTS_CRC32_H_
|
||||
|
||||
@@ -23,25 +23,25 @@
|
||||
#include "../include/aaruformat.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define EXPECTED_CRC64 0xbf09992cc5ede38e
|
||||
#define EXPECTED_CRC64_15BYTES 0x797F3766FD93975B
|
||||
#define EXPECTED_CRC64_31BYTES 0xCD9201905A7937FD
|
||||
#define EXPECTED_CRC64_63BYTES 0x29F331FC90702BF4
|
||||
#define EXPECTED_CRC64 0xbf09992cc5ede38e
|
||||
#define EXPECTED_CRC64_15BYTES 0x797F3766FD93975B
|
||||
#define EXPECTED_CRC64_31BYTES 0xCD9201905A7937FD
|
||||
#define EXPECTED_CRC64_63BYTES 0x29F331FC90702BF4
|
||||
#define EXPECTED_CRC64_2352BYTES 0x126435DB43477623
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t* buffer_misaligned;
|
||||
static const uint8_t *buffer;
|
||||
static const uint8_t *buffer_misaligned;
|
||||
|
||||
class crc64Fixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
crc64Fixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -50,19 +50,19 @@ class crc64Fixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/random", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1048576);
|
||||
fread((void*)buffer, 1, 1048576, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1048576);
|
||||
fread((void *)buffer, 1, 1048576, file);
|
||||
fclose(file);
|
||||
|
||||
buffer_misaligned = (const uint8_t*)malloc(1048577);
|
||||
memcpy((void*)(buffer_misaligned + 1), buffer, 1048576);
|
||||
buffer_misaligned = (const uint8_t *)malloc(1048577);
|
||||
memcpy((void *)(buffer_misaligned + 1), buffer, 1048576);
|
||||
}
|
||||
|
||||
void TearDown()
|
||||
{
|
||||
free((void*)buffer);
|
||||
free((void*)buffer_misaligned);
|
||||
free((void *)buffer);
|
||||
free((void *)buffer_misaligned);
|
||||
}
|
||||
|
||||
~crc64Fixture()
|
||||
@@ -75,7 +75,7 @@ class crc64Fixture : public ::testing::Test
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto)
|
||||
{
|
||||
crc64_ctx* ctx = aaruf_crc64_init();
|
||||
crc64_ctx *ctx = aaruf_crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
@@ -100,7 +100,7 @@ TEST_F(crc64Fixture, crc64_slicing)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_misaligned)
|
||||
{
|
||||
crc64_ctx* ctx = aaruf_crc64_init();
|
||||
crc64_ctx *ctx = aaruf_crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
@@ -125,7 +125,7 @@ TEST_F(crc64Fixture, crc64_slicing_misaligned)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_15bytes)
|
||||
{
|
||||
crc64_ctx* ctx = aaruf_crc64_init();
|
||||
crc64_ctx *ctx = aaruf_crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
@@ -150,7 +150,7 @@ TEST_F(crc64Fixture, crc64_slicing_15bytes)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_31bytes)
|
||||
{
|
||||
crc64_ctx* ctx = aaruf_crc64_init();
|
||||
crc64_ctx *ctx = aaruf_crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
@@ -175,7 +175,7 @@ TEST_F(crc64Fixture, crc64_slicing_31bytes)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_63bytes)
|
||||
{
|
||||
crc64_ctx* ctx = aaruf_crc64_init();
|
||||
crc64_ctx *ctx = aaruf_crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
@@ -200,7 +200,7 @@ TEST_F(crc64Fixture, crc64_slicing_63bytes)
|
||||
|
||||
TEST_F(crc64Fixture, crc64_auto_2352bytes)
|
||||
{
|
||||
crc64_ctx* ctx = aaruf_crc64_init();
|
||||
crc64_ctx *ctx = aaruf_crc64_init();
|
||||
uint64_t crc;
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
@@ -223,7 +223,7 @@ TEST_F(crc64Fixture, crc64_slicing_2352bytes)
|
||||
EXPECT_EQ(crc, EXPECTED_CRC64_2352BYTES);
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
||||
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
||||
TEST_F(crc64Fixture, crc64_clmul)
|
||||
{
|
||||
|
||||
@@ -28,18 +28,18 @@
|
||||
|
||||
#define EXPECTED_CRC32 0xdfbc99bb
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class flacFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
flacFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -48,13 +48,13 @@ class flacFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/flac.flac", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(6534197);
|
||||
fread((void*)buffer, 1, 6534197, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(6534197);
|
||||
fread((void *)buffer, 1, 6534197, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~flacFixture()
|
||||
{
|
||||
@@ -66,7 +66,7 @@ class flacFixture : public ::testing::Test
|
||||
|
||||
TEST_F(flacFixture, flac)
|
||||
{
|
||||
auto* outBuf = (uint8_t*)malloc(9633792);
|
||||
auto *outBuf = (uint8_t *)malloc(9633792);
|
||||
|
||||
auto decoded = aaruf_flac_decode_redbook_buffer(outBuf, 9633792, buffer, 6534197);
|
||||
|
||||
@@ -86,46 +86,33 @@ TEST_F(flacFixture, flacCompress)
|
||||
uint decmp_len = original_len;
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX * 2];
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
uint32_t original_crc, decmp_crc;
|
||||
const uint8_t* original;
|
||||
uint8_t* cmp_buffer;
|
||||
uint8_t* decmp_buffer;
|
||||
const uint8_t *original;
|
||||
uint8_t *cmp_buffer;
|
||||
uint8_t *decmp_buffer;
|
||||
size_t newSize;
|
||||
|
||||
// Allocate buffers
|
||||
original = (const uint8_t*)malloc(original_len);
|
||||
cmp_buffer = (uint8_t*)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t*)malloc(decmp_len);
|
||||
original = (const uint8_t *)malloc(original_len);
|
||||
cmp_buffer = (uint8_t *)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t *)malloc(decmp_len);
|
||||
|
||||
// Read the file
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/audio.bin", path);
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
fread((void*)original, 1, original_len, file);
|
||||
fread((void *)original, 1, original_len, file);
|
||||
fclose(file);
|
||||
|
||||
// Calculate the CRC
|
||||
original_crc = crc32_data(original, original_len);
|
||||
|
||||
// Compress
|
||||
newSize = aaruf_flac_encode_redbook_buffer(cmp_buffer,
|
||||
cmp_len,
|
||||
original,
|
||||
original_len,
|
||||
4608,
|
||||
1,
|
||||
0,
|
||||
"partial_tukey(0/1.0/1.0)",
|
||||
12,
|
||||
0,
|
||||
1,
|
||||
false,
|
||||
0,
|
||||
8,
|
||||
"Aaru.Compression.Native.Tests",
|
||||
strlen("Aaru.Compression.Native.Tests"));
|
||||
newSize = aaruf_flac_encode_redbook_buffer(
|
||||
cmp_buffer, cmp_len, original, original_len, 4608, 1, 0, "partial_tukey(0/1.0/1.0)", 12, 0, 1, false, 0, 8,
|
||||
"Aaru.Compression.Native.Tests", strlen("Aaru.Compression.Native.Tests"));
|
||||
cmp_len = newSize;
|
||||
|
||||
// Decompress
|
||||
@@ -137,7 +124,7 @@ TEST_F(flacFixture, flacCompress)
|
||||
decmp_crc = crc32_data(decmp_buffer, decmp_len);
|
||||
|
||||
// Free buffers
|
||||
free((void*)original);
|
||||
free((void *)original);
|
||||
free(cmp_buffer);
|
||||
free(decmp_buffer);
|
||||
|
||||
|
||||
@@ -27,18 +27,18 @@
|
||||
|
||||
#define EXPECTED_CRC32 0x954bf76e
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class lzmaFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
lzmaFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -47,13 +47,13 @@ class lzmaFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/lzma.bin", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1200275);
|
||||
fread((void*)buffer, 1, 1200275, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1200275);
|
||||
fread((void *)buffer, 1, 1200275, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~lzmaFixture()
|
||||
{
|
||||
@@ -68,7 +68,7 @@ TEST_F(lzmaFixture, lzma)
|
||||
uint8_t params[] = {0x5D, 0x00, 0x00, 0x00, 0x02};
|
||||
size_t destLen = 8388608;
|
||||
size_t srcLen = 1200275;
|
||||
auto* outBuf = (uint8_t*)malloc(8388608);
|
||||
auto *outBuf = (uint8_t *)malloc(8388608);
|
||||
|
||||
auto err = aaruf_lzma_decode_buffer(outBuf, &destLen, buffer, &srcLen, params, 5);
|
||||
|
||||
@@ -89,34 +89,34 @@ TEST_F(lzmaFixture, lzmaCompress)
|
||||
size_t decmp_len = original_len;
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX * 2];
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
uint32_t original_crc, decmp_crc;
|
||||
const uint8_t* original;
|
||||
uint8_t* cmp_buffer;
|
||||
uint8_t* decmp_buffer;
|
||||
const uint8_t *original;
|
||||
uint8_t *cmp_buffer;
|
||||
uint8_t *decmp_buffer;
|
||||
int err;
|
||||
uint8_t props[5];
|
||||
size_t props_len = 5;
|
||||
|
||||
// Allocate buffers
|
||||
original = (const uint8_t*)malloc(original_len);
|
||||
cmp_buffer = (uint8_t*)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t*)malloc(decmp_len);
|
||||
original = (const uint8_t *)malloc(original_len);
|
||||
cmp_buffer = (uint8_t *)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t *)malloc(decmp_len);
|
||||
|
||||
// Read the file
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
fread((void*)original, 1, original_len, file);
|
||||
fread((void *)original, 1, original_len, file);
|
||||
fclose(file);
|
||||
|
||||
// Calculate the CRC
|
||||
original_crc = crc32_data(original, original_len);
|
||||
|
||||
// Compress
|
||||
err = aaruf_lzma_encode_buffer(
|
||||
cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2, 273, 2);
|
||||
err = aaruf_lzma_encode_buffer(cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2,
|
||||
273, 2);
|
||||
EXPECT_EQ(err, 0);
|
||||
|
||||
// Decompress
|
||||
@@ -128,7 +128,7 @@ TEST_F(lzmaFixture, lzmaCompress)
|
||||
decmp_crc = crc32_data(decmp_buffer, decmp_len);
|
||||
|
||||
// Free buffers
|
||||
free((void*)original);
|
||||
free((void *)original);
|
||||
free(cmp_buffer);
|
||||
free(decmp_buffer);
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
#ifdef AARU_HAS_SHA256
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
unsigned char expected_sha256[SHA256_DIGEST_LENGTH] = {0x4d, 0x1a, 0x6b, 0x8a, 0x54, 0x67, 0x00, 0xc4, 0x8e, 0xda, 0x70,
|
||||
0xd3, 0x39, 0x1c, 0x8f, 0x15, 0x8a, 0x8d, 0x12, 0xb2, 0x38, 0x92,
|
||||
@@ -32,14 +32,14 @@ unsigned char expected_sha256[SHA256_DIGEST_LENGTH] = {0x4d, 0x1a, 0x6b, 0x8a, 0
|
||||
|
||||
class sha256Fixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
sha256Fixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -48,13 +48,13 @@ class sha256Fixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/random", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1048576);
|
||||
fread((void*)buffer, 1, 1048576, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1048576);
|
||||
fread((void *)buffer, 1, 1048576, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~sha256Fixture()
|
||||
{
|
||||
@@ -64,20 +64,20 @@ class sha256Fixture : public ::testing::Test
|
||||
// shared user data
|
||||
};
|
||||
|
||||
#define EXPECT_ARRAY_EQ(reference, actual, element_count) \
|
||||
{ \
|
||||
unsigned char* reference_ = static_cast<unsigned char*>(reference); \
|
||||
unsigned char* actual_ = static_cast<unsigned char*>(actual); \
|
||||
for(int cmp_i = 0; cmp_i < (element_count); cmp_i++) { EXPECT_EQ(reference_[cmp_i], actual_[cmp_i]); } \
|
||||
#define EXPECT_ARRAY_EQ(reference, actual, element_count) \
|
||||
{ \
|
||||
unsigned char *reference_ = static_cast<unsigned char *>(reference); \
|
||||
unsigned char *actual_ = static_cast<unsigned char *>(actual); \
|
||||
for(int cmp_i = 0; cmp_i < (element_count); cmp_i++) { EXPECT_EQ(reference_[cmp_i], actual_[cmp_i]); } \
|
||||
}
|
||||
|
||||
TEST_F(sha256Fixture, sha256)
|
||||
{
|
||||
SHA256_CTX* ctx;
|
||||
SHA256_CTX *ctx;
|
||||
unsigned char hash[SHA256_DIGEST_LENGTH];
|
||||
int ret;
|
||||
|
||||
ctx = static_cast<SHA256_CTX*>(malloc(sizeof(SHA256_CTX)));
|
||||
ctx = static_cast<SHA256_CTX *>(malloc(sizeof(SHA256_CTX)));
|
||||
|
||||
EXPECT_NE(nullptr, ctx);
|
||||
|
||||
|
||||
@@ -23,25 +23,25 @@
|
||||
#include "../include/aaruformat.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define EXPECTED_SPAMSUM "24576:3dvzuAsHTQ16pc7O1Q/gS9qze+Swwn9s6IX:8/TQQpaVqze+JN6IX"
|
||||
#define EXPECTED_SPAMSUM_15BYTES "3:Ac4E9t:Ac4E9t"
|
||||
#define EXPECTED_SPAMSUM_31BYTES "3:Ac4E9E5+S09qn:Ac4E9EgSsq"
|
||||
#define EXPECTED_SPAMSUM_63BYTES "3:Ac4E9E5+S09q2kABV9:Ac4E9EgSs7kW9"
|
||||
#define EXPECTED_SPAMSUM "24576:3dvzuAsHTQ16pc7O1Q/gS9qze+Swwn9s6IX:8/TQQpaVqze+JN6IX"
|
||||
#define EXPECTED_SPAMSUM_15BYTES "3:Ac4E9t:Ac4E9t"
|
||||
#define EXPECTED_SPAMSUM_31BYTES "3:Ac4E9E5+S09qn:Ac4E9EgSsq"
|
||||
#define EXPECTED_SPAMSUM_63BYTES "3:Ac4E9E5+S09q2kABV9:Ac4E9EgSs7kW9"
|
||||
#define EXPECTED_SPAMSUM_2352BYTES "48:pasCLoANDXmjCz1p2OpPm+Gek3xmZfJJ5DD4BacmmlodQMQa/58Z:csK1Nxz7XFGeJS/flHMQu2Z"
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t* buffer_misaligned;
|
||||
static const uint8_t *buffer;
|
||||
static const uint8_t *buffer_misaligned;
|
||||
|
||||
class spamsumFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
spamsumFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -50,19 +50,19 @@ class spamsumFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/random", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1048576);
|
||||
fread((void*)buffer, 1, 1048576, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1048576);
|
||||
fread((void *)buffer, 1, 1048576, file);
|
||||
fclose(file);
|
||||
|
||||
buffer_misaligned = (const uint8_t*)malloc(1048577);
|
||||
memcpy((void*)(buffer_misaligned + 1), buffer, 1048576);
|
||||
buffer_misaligned = (const uint8_t *)malloc(1048577);
|
||||
memcpy((void *)(buffer_misaligned + 1), buffer, 1048576);
|
||||
}
|
||||
|
||||
void TearDown()
|
||||
{
|
||||
free((void*)buffer);
|
||||
free((void*)buffer_misaligned);
|
||||
free((void *)buffer);
|
||||
free((void *)buffer_misaligned);
|
||||
}
|
||||
|
||||
~spamsumFixture()
|
||||
@@ -75,102 +75,102 @@ class spamsumFixture : public ::testing::Test
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto)
|
||||
{
|
||||
spamsum_ctx* ctx = aaruf_spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = aaruf_spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
aaruf_spamsum_update(ctx, buffer, 1048576);
|
||||
aaruf_spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
aaruf_spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
aaruf_spamsum_free(ctx);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_misaligned)
|
||||
{
|
||||
spamsum_ctx* ctx = aaruf_spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = aaruf_spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
aaruf_spamsum_update(ctx, buffer_misaligned + 1, 1048576);
|
||||
aaruf_spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
aaruf_spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
aaruf_spamsum_free(ctx);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_15bytes)
|
||||
{
|
||||
spamsum_ctx* ctx = aaruf_spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = aaruf_spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
aaruf_spamsum_update(ctx, buffer, 15);
|
||||
aaruf_spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
aaruf_spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
aaruf_spamsum_free(ctx);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM_15BYTES);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_31bytes)
|
||||
{
|
||||
spamsum_ctx* ctx = aaruf_spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = aaruf_spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
aaruf_spamsum_update(ctx, buffer, 31);
|
||||
aaruf_spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
aaruf_spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
aaruf_spamsum_free(ctx);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM_31BYTES);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_63bytes)
|
||||
{
|
||||
spamsum_ctx* ctx = aaruf_spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = aaruf_spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
aaruf_spamsum_update(ctx, buffer, 63);
|
||||
aaruf_spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
aaruf_spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
aaruf_spamsum_free(ctx);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM_63BYTES);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
TEST_F(spamsumFixture, spamsum_auto_2352bytes)
|
||||
{
|
||||
spamsum_ctx* ctx = aaruf_spamsum_init();
|
||||
const char* spamsum = (const char*)malloc(FUZZY_MAX_RESULT);
|
||||
spamsum_ctx *ctx = aaruf_spamsum_init();
|
||||
const char *spamsum = (const char *)malloc(FUZZY_MAX_RESULT);
|
||||
|
||||
EXPECT_NE(ctx, nullptr);
|
||||
EXPECT_NE(spamsum, nullptr);
|
||||
|
||||
aaruf_spamsum_update(ctx, buffer, 2352);
|
||||
aaruf_spamsum_final(ctx, (uint8_t*)spamsum);
|
||||
aaruf_spamsum_final(ctx, (uint8_t *)spamsum);
|
||||
aaruf_spamsum_free(ctx);
|
||||
|
||||
EXPECT_STREQ(spamsum, EXPECTED_SPAMSUM_2352BYTES);
|
||||
|
||||
free((void*)spamsum);
|
||||
free((void *)spamsum);
|
||||
}
|
||||
|
||||
@@ -23,22 +23,15 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
int identify(char* path);
|
||||
int info(char* path);
|
||||
char* byte_array_to_hex_string(const unsigned char* array, int array_size);
|
||||
int read(unsigned long long sector_no, char* path);
|
||||
int printhex(unsigned char* array, unsigned int length, int width, bool color);
|
||||
int read_long(unsigned long long sector_no, char* path);
|
||||
int verify(char* path);
|
||||
int verify_sectors(char* path);
|
||||
bool check_cd_sector_channel(CdEccContext* context,
|
||||
uint8_t* sector,
|
||||
bool* unknown,
|
||||
bool* has_edc,
|
||||
bool* edc_correct,
|
||||
bool* has_ecc_p,
|
||||
bool* ecc_p_correct,
|
||||
bool* has_ecc_q,
|
||||
bool* ecc_q_correct);
|
||||
int identify(char *path);
|
||||
int info(char *path);
|
||||
char *byte_array_to_hex_string(const unsigned char *array, int array_size);
|
||||
int read(unsigned long long sector_no, char *path);
|
||||
int printhex(unsigned char *array, unsigned int length, int width, bool color);
|
||||
int read_long(unsigned long long sector_no, char *path);
|
||||
int verify(char *path);
|
||||
int verify_sectors(char *path);
|
||||
bool check_cd_sector_channel(CdEccContext *context, uint8_t *sector, bool *unknown, bool *has_edc, bool *edc_correct,
|
||||
bool *has_ecc_p, bool *ecc_p_correct, bool *has_ecc_q, bool *ecc_q_correct);
|
||||
|
||||
#endif // LIBAARUFORMAT_TOOL_AARUFORMATTOOL_H_
|
||||
#endif // LIBAARUFORMAT_TOOL_AARUFORMATTOOL_H_
|
||||
|
||||
@@ -22,15 +22,8 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
bool check_cd_sector_channel(CdEccContext* context,
|
||||
uint8_t* sector,
|
||||
bool* unknown,
|
||||
bool* has_edc,
|
||||
bool* edc_correct,
|
||||
bool* has_ecc_p,
|
||||
bool* ecc_p_correct,
|
||||
bool* has_ecc_q,
|
||||
bool* ecc_q_correct)
|
||||
bool check_cd_sector_channel(CdEccContext *context, uint8_t *sector, bool *unknown, bool *has_edc, bool *edc_correct,
|
||||
bool *has_ecc_p, bool *ecc_p_correct, bool *has_ecc_q, bool *ecc_q_correct)
|
||||
{
|
||||
int i;
|
||||
uint32_t storedEdc, edc, calculatedEdc;
|
||||
@@ -53,15 +46,12 @@ bool check_cd_sector_channel(CdEccContext* context,
|
||||
return false;
|
||||
}
|
||||
|
||||
if((sector[0x00F] & 0x03) == 0x00) // Mode 0
|
||||
if((sector[0x00F] & 0x03) == 0x00) // Mode 0
|
||||
{
|
||||
for(i = 0x010; i < 0x930; i++)
|
||||
if(sector[i] != 0x00)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Mode 0 sector with error at address: %2X:%2X:%2X.\n",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
fprintf(stderr, "Mode 0 sector with error at address: %2X:%2X:%2X.\n", sector[0x00C], sector[0x00D],
|
||||
sector[0x00E]);
|
||||
return false;
|
||||
}
|
||||
@@ -69,18 +59,15 @@ bool check_cd_sector_channel(CdEccContext* context,
|
||||
return true;
|
||||
}
|
||||
|
||||
if((sector[0x00F] & 0x03) == 0x01) // Mode 1
|
||||
if((sector[0x00F] & 0x03) == 0x01) // Mode 1
|
||||
{
|
||||
if(sector[0x814] != 0x00 ||
|
||||
// reserved (8 bytes)
|
||||
sector[0x815] != 0x00 || sector[0x816] != 0x00 || sector[0x817] != 0x00 || sector[0x818] != 0x00 ||
|
||||
sector[0x819] != 0x00 || sector[0x81A] != 0x00 || sector[0x81B] != 0x00)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Mode 1 with data in reserved bytes at address: %2X:%2X:%2X.\n",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
sector[0x00E]);
|
||||
fprintf(stderr, "Mode 1 with data in reserved bytes at address: %2X:%2X:%2X.\n", sector[0x00C],
|
||||
sector[0x00D], sector[0x00E]);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -91,8 +78,8 @@ bool check_cd_sector_channel(CdEccContext* context,
|
||||
*ecc_p_correct = aaruf_ecc_cd_check(context, sector, sector, 86, 24, 2, 86, sector, 0xC, 0x10, 0x81C);
|
||||
*ecc_q_correct = aaruf_ecc_cd_check(context, sector, sector, 52, 43, 86, 88, sector, 0xC, 0x10, 0x81C + 0xAC);
|
||||
|
||||
storedEdc =
|
||||
(sector[0x813] << 24) + (sector[0x812] << 16) + (sector[0x811] << 8) + sector[0x810]; // TODO: Check casting
|
||||
storedEdc = (sector[0x813] << 24) + (sector[0x812] << 16) + (sector[0x811] << 8) +
|
||||
sector[0x810]; // TODO: Check casting
|
||||
edc = 0;
|
||||
size = 0x810;
|
||||
pos = 0;
|
||||
@@ -103,47 +90,33 @@ bool check_cd_sector_channel(CdEccContext* context,
|
||||
|
||||
if(!*edc_correct)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Mode 1 sector at address: %2X:%2X:%2X, got CRC 0x%8X expected 0x%8X\n",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
sector[0x00E],
|
||||
calculatedEdc,
|
||||
storedEdc);
|
||||
fprintf(stderr, "Mode 1 sector at address: %2X:%2X:%2X, got CRC 0x%8X expected 0x%8X\n", sector[0x00C],
|
||||
sector[0x00D], sector[0x00E], calculatedEdc, storedEdc);
|
||||
}
|
||||
|
||||
if(!*ecc_p_correct)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Mode 1 sector at address: %2X:%2X:%2X, fails ECC P check.\n",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
fprintf(stderr, "Mode 1 sector at address: %2X:%2X:%2X, fails ECC P check.\n", sector[0x00C], sector[0x00D],
|
||||
sector[0x00E]);
|
||||
}
|
||||
|
||||
if(!*ecc_q_correct)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Mode 1 sector at address: %2X:%2X:%2X, fails ECC Q check.\n",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
fprintf(stderr, "Mode 1 sector at address: %2X:%2X:%2X, fails ECC Q check.\n", sector[0x00C], sector[0x00D],
|
||||
sector[0x00E]);
|
||||
}
|
||||
|
||||
return *edc_correct && *ecc_p_correct && *ecc_q_correct;
|
||||
}
|
||||
|
||||
if((sector[0x00F] & 0x03) == 0x02) // Mode 2
|
||||
if((sector[0x00F] & 0x03) == 0x02) // Mode 2
|
||||
{
|
||||
if((sector[0x012] & 0x20) == 0x20) // mode 2 form 2
|
||||
if((sector[0x012] & 0x20) == 0x20) // mode 2 form 2
|
||||
{
|
||||
if(sector[0x010] != sector[0x014] || sector[0x011] != sector[0x015] || sector[0x012] != sector[0x016] ||
|
||||
sector[0x013] != sector[0x017])
|
||||
fprintf(stderr,
|
||||
"Subheader copies differ in mode 2 form 2 sector at address: %2X:%2X:%2X",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
sector[0x00E]);
|
||||
fprintf(stderr, "Subheader copies differ in mode 2 form 2 sector at address: %2X:%2X:%2X",
|
||||
sector[0x00C], sector[0x00D], sector[0x00E]);
|
||||
|
||||
storedEdc = sector[0x91C];
|
||||
|
||||
@@ -162,13 +135,8 @@ bool check_cd_sector_channel(CdEccContext* context,
|
||||
|
||||
if(!*edc_correct)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Mode 2 sector at address: %2X:%2X:%2X, got CRC 0x%8X expected 0x%8X\n",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
sector[0x00E],
|
||||
calculatedEdc,
|
||||
storedEdc);
|
||||
fprintf(stderr, "Mode 2 sector at address: %2X:%2X:%2X, got CRC 0x%8X expected 0x%8X\n", sector[0x00C],
|
||||
sector[0x00D], sector[0x00E], calculatedEdc, storedEdc);
|
||||
}
|
||||
|
||||
return *edc_correct;
|
||||
@@ -179,7 +147,7 @@ bool check_cd_sector_channel(CdEccContext* context,
|
||||
*ecc_q_correct =
|
||||
aaruf_ecc_cd_check(context, zeroaddress, sector, 52, 43, 86, 88, sector, 0, 0x10, 0x81C + 0xAC);
|
||||
|
||||
storedEdc = sector[0x818]; // TODO: Check cast
|
||||
storedEdc = sector[0x818]; // TODO: Check cast
|
||||
edc = 0;
|
||||
size = 0x808;
|
||||
pos = 0x10;
|
||||
@@ -190,41 +158,26 @@ bool check_cd_sector_channel(CdEccContext* context,
|
||||
|
||||
if(!*edc_correct)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Mode 2 sector at address: %2X:%2X:%2X, got CRC 0x%8X expected 0x%8X\n",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
sector[0x00E],
|
||||
calculatedEdc,
|
||||
storedEdc);
|
||||
fprintf(stderr, "Mode 2 sector at address: %2X:%2X:%2X, got CRC 0x%8X expected 0x%8X\n", sector[0x00C],
|
||||
sector[0x00D], sector[0x00E], calculatedEdc, storedEdc);
|
||||
}
|
||||
|
||||
if(!*ecc_p_correct)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Mode 2 sector at address: %2X:%2X:%2X, fails ECC P check.\n",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
fprintf(stderr, "Mode 2 sector at address: %2X:%2X:%2X, fails ECC P check.\n", sector[0x00C], sector[0x00D],
|
||||
sector[0x00E]);
|
||||
}
|
||||
|
||||
if(!*ecc_q_correct)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Mode 2 sector at address: %2X:%2X:%2X, fails ECC Q check.\n",
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
fprintf(stderr, "Mode 2 sector at address: %2X:%2X:%2X, fails ECC Q check.\n", sector[0x00C], sector[0x00D],
|
||||
sector[0x00E]);
|
||||
}
|
||||
|
||||
return *edc_correct && *ecc_p_correct && *ecc_q_correct;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"Unknown mode %d sector at address: %2X:%2X:%2X",
|
||||
sector[0x00F],
|
||||
sector[0x00C],
|
||||
sector[0x00D],
|
||||
fprintf(stderr, "Unknown mode %d sector at address: %2X:%2X:%2X", sector[0x00F], sector[0x00C], sector[0x00D],
|
||||
sector[0x00E]);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
#include "aaruformattool.h"
|
||||
|
||||
char* byte_array_to_hex_string(const unsigned char* array, int array_size)
|
||||
char *byte_array_to_hex_string(const unsigned char *array, int array_size)
|
||||
{
|
||||
char* hex_string = NULL;
|
||||
char *hex_string = NULL;
|
||||
int j;
|
||||
int i;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
int identify(char* path)
|
||||
int identify(char *path)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
229
tool/info.c
229
tool/info.c
@@ -25,14 +25,14 @@
|
||||
|
||||
#include "aaruformattool.h"
|
||||
|
||||
int info(char* path)
|
||||
int info(char *path)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
char* strBuffer;
|
||||
aaruformatContext *ctx;
|
||||
char *strBuffer;
|
||||
UErrorCode u_error_code;
|
||||
uint i, j;
|
||||
mediaTagEntry* mediaTag;
|
||||
mediaTagEntry* tmpMediaTag;
|
||||
mediaTagEntry *mediaTag;
|
||||
mediaTagEntry *tmpMediaTag;
|
||||
|
||||
ctx = aaruf_open(path);
|
||||
|
||||
@@ -43,14 +43,14 @@ int info(char* path)
|
||||
}
|
||||
|
||||
printf("AaruFormat context information:\n");
|
||||
printf("Magic number: %8.8s\n", (char*)&ctx->magic);
|
||||
printf("Magic number: %8.8s\n", (char *)&ctx->magic);
|
||||
printf("Library version: %d.%d\n", ctx->libraryMajorVersion, ctx->libraryMinorVersion);
|
||||
printf("AaruFormat header:\n");
|
||||
printf("\tIdentifier: %8.8s\n", (char*)&ctx->header.identifier);
|
||||
printf("\tIdentifier: %8.8s\n", (char *)&ctx->header.identifier);
|
||||
|
||||
strBuffer = malloc(65);
|
||||
memset(strBuffer, 0, 65);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, 64, (const char*)ctx->header.application, 64, &u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, 64, (const char *)ctx->header.application, 64, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tApplication: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
|
||||
@@ -88,30 +88,23 @@ int info(char* path)
|
||||
if(ctx->sectorPrefixDdt != NULL) printf("Sector suffix DDT has been read to memory.\n");
|
||||
|
||||
if(ctx->geometryBlock.identifier == GeometryBlock)
|
||||
printf("Media has %d cylinders, %d heads and %d sectors per track.\n",
|
||||
ctx->geometryBlock.cylinders,
|
||||
ctx->geometryBlock.heads,
|
||||
ctx->geometryBlock.sectorsPerTrack);
|
||||
printf("Media has %d cylinders, %d heads and %d sectors per track.\n", ctx->geometryBlock.cylinders,
|
||||
ctx->geometryBlock.heads, ctx->geometryBlock.sectorsPerTrack);
|
||||
|
||||
if(ctx->metadataBlockHeader.identifier == MetadataBlock)
|
||||
{
|
||||
printf("Metadata block:\n");
|
||||
if(ctx->metadataBlockHeader.mediaSequence > 0)
|
||||
printf("\tMedia is no. %d in a set of %d media\n",
|
||||
ctx->metadataBlockHeader.mediaSequence,
|
||||
printf("\tMedia is no. %d in a set of %d media\n", ctx->metadataBlockHeader.mediaSequence,
|
||||
ctx->metadataBlockHeader.lastMediaSequence);
|
||||
|
||||
if(ctx->metadataBlockHeader.creatorLength > 0)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.creatorLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.creatorLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.creatorLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.creatorOffset),
|
||||
(int)ctx->metadataBlockHeader.creatorLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.creatorLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.creatorOffset),
|
||||
(int)ctx->metadataBlockHeader.creatorLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -120,13 +113,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.commentsLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.commentsLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.commentsLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.commentsOffset),
|
||||
(int)ctx->metadataBlockHeader.commentsLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.commentsLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.commentsOffset),
|
||||
(int)ctx->metadataBlockHeader.commentsLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -135,13 +124,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.mediaTitleLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.mediaTitleLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.mediaTitleLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaTitleOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaTitleLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.mediaTitleLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaTitleOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaTitleLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -150,13 +135,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.mediaManufacturerLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.mediaManufacturerLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.mediaManufacturerLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaManufacturerOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaManufacturerLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.mediaManufacturerLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaManufacturerOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaManufacturerLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -165,13 +146,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.mediaModelLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.mediaModelLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.mediaModelLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaModelOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaModelLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.mediaModelLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaModelOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaModelLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -180,13 +157,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.mediaSerialNumberLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.mediaSerialNumberLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.mediaSerialNumberLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaSerialNumberOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaSerialNumberLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.mediaSerialNumberLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaSerialNumberOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaSerialNumberLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -195,13 +168,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.mediaBarcodeLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.mediaBarcodeLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.mediaBarcodeLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaBarcodeOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaBarcodeLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.mediaBarcodeLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaBarcodeOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaBarcodeLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -210,13 +179,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.mediaPartNumberLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.mediaPartNumberLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.mediaPartNumberLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaPartNumberOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaPartNumberLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.mediaPartNumberLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.mediaPartNumberOffset),
|
||||
(int)ctx->metadataBlockHeader.mediaPartNumberLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -225,13 +190,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.driveManufacturerLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.driveManufacturerLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.driveManufacturerLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.driveManufacturerOffset),
|
||||
(int)ctx->metadataBlockHeader.driveManufacturerLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.driveManufacturerLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.driveManufacturerOffset),
|
||||
(int)ctx->metadataBlockHeader.driveManufacturerLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -240,13 +201,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.driveModelLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.driveModelLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.driveModelLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.driveModelOffset),
|
||||
(int)ctx->metadataBlockHeader.driveModelLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.driveModelLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.driveModelOffset),
|
||||
(int)ctx->metadataBlockHeader.driveModelLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -255,13 +212,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.driveSerialNumberLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.driveSerialNumberLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.driveSerialNumberLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.driveSerialNumberOffset),
|
||||
(int)ctx->metadataBlockHeader.driveSerialNumberLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.driveSerialNumberLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.driveSerialNumberOffset),
|
||||
(int)ctx->metadataBlockHeader.driveSerialNumberLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -270,13 +223,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->metadataBlockHeader.driveFirmwareRevisionLength + 1);
|
||||
memset(strBuffer, 0, ctx->metadataBlockHeader.driveFirmwareRevisionLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-16LE",
|
||||
strBuffer,
|
||||
(int)ctx->metadataBlockHeader.driveFirmwareRevisionLength,
|
||||
(char*)(ctx->metadataBlock + ctx->metadataBlockHeader.driveFirmwareRevisionOffset),
|
||||
(int)ctx->metadataBlockHeader.driveFirmwareRevisionLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, (int)ctx->metadataBlockHeader.driveFirmwareRevisionLength,
|
||||
(char *)(ctx->metadataBlock + ctx->metadataBlockHeader.driveFirmwareRevisionOffset),
|
||||
(int)ctx->metadataBlockHeader.driveFirmwareRevisionLength, &u_error_code);
|
||||
printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -319,13 +268,10 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.manufacturerLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.manufacturerLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-8",
|
||||
strBuffer,
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.manufacturerLength,
|
||||
(char*)(ctx->dumpHardwareEntriesWithData[i].manufacturer),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.manufacturerLength,
|
||||
&u_error_code);
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].manufacturer),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.manufacturerLength, &u_error_code);
|
||||
printf("\t\tManufacturer: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -334,13 +280,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.modelLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.modelLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-8",
|
||||
strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.modelLength,
|
||||
(char*)(ctx->dumpHardwareEntriesWithData[i].model),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.modelLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer, (int)ctx->dumpHardwareEntriesWithData[i].entry.modelLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].model),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.modelLength, &u_error_code);
|
||||
printf("\t\tModel: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -349,13 +291,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.revisionLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.revisionLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-8",
|
||||
strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.revisionLength,
|
||||
(char*)(ctx->dumpHardwareEntriesWithData[i].revision),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.revisionLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer, (int)ctx->dumpHardwareEntriesWithData[i].entry.revisionLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].revision),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.revisionLength, &u_error_code);
|
||||
printf("\t\tRevision: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -364,13 +302,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-8",
|
||||
strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength,
|
||||
(char*)(ctx->dumpHardwareEntriesWithData[i].firmware),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer, (int)ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].firmware),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength, &u_error_code);
|
||||
printf("\t\tFirmware version: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -379,13 +313,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.serialLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.serialLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-8",
|
||||
strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.serialLength,
|
||||
(char*)(ctx->dumpHardwareEntriesWithData[i].serial),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.serialLength,
|
||||
&u_error_code);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer, (int)ctx->dumpHardwareEntriesWithData[i].entry.serialLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].serial),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.serialLength, &u_error_code);
|
||||
printf("\t\tSerial number: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -394,13 +324,10 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.softwareNameLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.softwareNameLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-8",
|
||||
strBuffer,
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareNameLength,
|
||||
(char*)(ctx->dumpHardwareEntriesWithData[i].softwareName),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareNameLength,
|
||||
&u_error_code);
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].softwareName),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareNameLength, &u_error_code);
|
||||
printf("\t\tSoftware name: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -409,13 +336,10 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.softwareVersionLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.softwareVersionLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-8",
|
||||
strBuffer,
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareVersionLength,
|
||||
(char*)(ctx->dumpHardwareEntriesWithData[i].softwareVersion),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareVersionLength,
|
||||
&u_error_code);
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].softwareVersion),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareVersionLength, &u_error_code);
|
||||
printf("\t\tSoftware version: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -424,11 +348,9 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.softwareOperatingSystemLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.softwareOperatingSystemLength + 1);
|
||||
ucnv_convert(NULL,
|
||||
"UTF-8",
|
||||
strBuffer,
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareOperatingSystemLength,
|
||||
(char*)(ctx->dumpHardwareEntriesWithData[i].softwareOperatingSystem),
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].softwareOperatingSystem),
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareOperatingSystemLength,
|
||||
&u_error_code);
|
||||
printf("\t\tSoftware operating system: %s\n", strBuffer);
|
||||
@@ -474,7 +396,7 @@ int info(char* path)
|
||||
{
|
||||
strBuffer = malloc(65);
|
||||
memset(strBuffer, 0, 65);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, 64, (const char*)ctx->imageInfo.Application, 64, &u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, 64, (const char *)ctx->imageInfo.Application, 64, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tApplication: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
@@ -494,8 +416,7 @@ int info(char* path)
|
||||
printf("\tMedia type: %u\n", ctx->imageInfo.MediaType);
|
||||
|
||||
if(ctx->imageInfo.MediaSequence > 0 || ctx->imageInfo.LastMediaSequence > 0)
|
||||
printf("\tMedia is number %d in a set of %d media\n",
|
||||
ctx->imageInfo.MediaSequence,
|
||||
printf("\tMedia is number %d in a set of %d media\n", ctx->imageInfo.MediaSequence,
|
||||
ctx->imageInfo.LastMediaSequence);
|
||||
|
||||
if(ctx->imageInfo.DriveManufacturer != NULL) printf("\tDrive manufacturer: %s\n", ctx->imageInfo.DriveManufacturer);
|
||||
@@ -506,10 +427,8 @@ int info(char* path)
|
||||
printf("\tDrive firmware revision: %s\n", ctx->imageInfo.DriveFirmwareRevision);
|
||||
printf("\tXML media type: %d\n", ctx->imageInfo.XmlMediaType);
|
||||
if(ctx->imageInfo.Cylinders > 0 || ctx->imageInfo.Heads > 0 || ctx->imageInfo.SectorsPerTrack > 0)
|
||||
printf("\tMedia has %d cylinders, %d heads and %d sectors per track\n",
|
||||
ctx->imageInfo.Cylinders,
|
||||
ctx->imageInfo.Heads,
|
||||
ctx->imageInfo.SectorsPerTrack);
|
||||
printf("\tMedia has %d cylinders, %d heads and %d sectors per track\n", ctx->imageInfo.Cylinders,
|
||||
ctx->imageInfo.Heads, ctx->imageInfo.SectorsPerTrack);
|
||||
|
||||
if(ctx->checksums.hasMd5)
|
||||
{
|
||||
|
||||
@@ -111,7 +111,7 @@ void usage_verify_sectors()
|
||||
printf("\t<filename>\tPath to AaruFormat image to verify.\n");
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
uint64_t sector_no = 0;
|
||||
|
||||
|
||||
@@ -23,4 +23,4 @@
|
||||
#define AARUFORMAT_TOOL_MAJOR_VERSION 1
|
||||
#define AARUFORMAT_TOOL_MINOR_VERSION 0
|
||||
|
||||
#endif // LIBAARUFORMAT_TOOL_MAIN_H_
|
||||
#endif // LIBAARUFORMAT_TOOL_MAIN_H_
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int printhex(unsigned char* array, unsigned int length, int width, bool color)
|
||||
int printhex(unsigned char *array, unsigned int length, int width, bool color)
|
||||
{
|
||||
char length_hex[17];
|
||||
char str[256];
|
||||
|
||||
12
tool/read.c
12
tool/read.c
@@ -24,12 +24,12 @@
|
||||
|
||||
#include "aaruformattool.h"
|
||||
|
||||
int read(unsigned long long sector_no, char* path)
|
||||
int read(unsigned long long sector_no, char *path)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
aaruformatContext *ctx;
|
||||
int32_t res;
|
||||
uint32_t length;
|
||||
uint8_t* data;
|
||||
uint8_t *data;
|
||||
|
||||
ctx = aaruf_open(path);
|
||||
|
||||
@@ -74,12 +74,12 @@ int read(unsigned long long sector_no, char* path)
|
||||
aaruf_close(ctx);
|
||||
}
|
||||
|
||||
int read_long(unsigned long long sector_no, char* path)
|
||||
int read_long(unsigned long long sector_no, char *path)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
aaruformatContext *ctx;
|
||||
int32_t res;
|
||||
uint32_t length;
|
||||
uint8_t* data;
|
||||
uint8_t *data;
|
||||
|
||||
ctx = aaruf_open(path);
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
|
||||
#include "aaruformattool.h"
|
||||
|
||||
int verify(char* path)
|
||||
int verify(char *path)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
aaruformatContext *ctx;
|
||||
uint32_t res;
|
||||
|
||||
ctx = aaruf_open(path);
|
||||
@@ -38,7 +38,8 @@ int verify(char* path)
|
||||
|
||||
res = aaruf_verify_image(ctx);
|
||||
|
||||
if(res == AARUF_STATUS_OK) printf("Image blocks contain no errors.\n");
|
||||
if(res == AARUF_STATUS_OK)
|
||||
printf("Image blocks contain no errors.\n");
|
||||
else if(res == AARUF_ERROR_INVALID_BLOCK_CRC)
|
||||
printf("A block contains an invalid CRC value.\n");
|
||||
else
|
||||
@@ -47,14 +48,14 @@ int verify(char* path)
|
||||
return res;
|
||||
}
|
||||
|
||||
int verify_sectors(char* path)
|
||||
int verify_sectors(char *path)
|
||||
{
|
||||
aaruformatContext* ctx;
|
||||
aaruformatContext *ctx;
|
||||
uint64_t s;
|
||||
uint8_t* buffer;
|
||||
uint8_t *buffer;
|
||||
uint32_t buffer_len = 2352;
|
||||
int32_t res;
|
||||
CdEccContext* cd_ecc_context;
|
||||
CdEccContext *cd_ecc_context;
|
||||
ctx = aaruf_open(path);
|
||||
bool verify_result;
|
||||
bool unknown, has_edc, edc_correct, has_ecc_p, ecc_p_correct, has_ecc_q, ecc_q_correct;
|
||||
@@ -89,15 +90,8 @@ int verify_sectors(char* path)
|
||||
continue;
|
||||
}
|
||||
|
||||
verify_result = check_cd_sector_channel(cd_ecc_context,
|
||||
buffer,
|
||||
&unknown,
|
||||
&has_edc,
|
||||
&edc_correct,
|
||||
&has_ecc_p,
|
||||
&ecc_p_correct,
|
||||
&has_ecc_q,
|
||||
&ecc_q_correct);
|
||||
verify_result = check_cd_sector_channel(cd_ecc_context, buffer, &unknown, &has_edc, &edc_correct, &has_ecc_p,
|
||||
&ecc_p_correct, &has_ecc_q, &ecc_q_correct);
|
||||
|
||||
if(verify_result) continue;
|
||||
|
||||
@@ -118,7 +112,8 @@ int verify_sectors(char* path)
|
||||
any_error = true;
|
||||
}
|
||||
|
||||
if(any_error) printf("\rSome sectors had incorrect checksums.\n");
|
||||
if(any_error)
|
||||
printf("\rSome sectors had incorrect checksums.\n");
|
||||
else
|
||||
printf("\rAll sector checksums are correct.\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user