From 701bc2cedc39804cfb439ef0479b06e3fe3701ee Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 31 Mar 2019 20:52:06 +0100 Subject: [PATCH] Reformat --- CMakeLists.txt | 3 +- include/dic.h | 1427 +++++++++++++++++------------------ include/dicformat.h | 10 +- include/dicformat/consts.h | 5 +- include/dicformat/context.h | 92 +-- include/dicformat/decls.h | 48 +- include/dicformat/enums.h | 234 +++--- include/dicformat/errors.h | 2 +- include/dicformat/structs.h | 39 +- src/close.c | 12 +- src/crc64.c | 26 +- src/cst.c | 38 +- src/ecc_cd.c | 217 +++--- src/identify.c | 11 +- src/open.c | 335 ++++---- src/read.c | 126 ++-- 16 files changed, 1276 insertions(+), 1349 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ba8b21..a7bd460 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ set(CMAKE_C_STANDARD 99) add_compile_definitions(__STDC_FORMAT_MACROS=1) add_library(dicformat SHARED include/dicformat/consts.h include/dicformat/enums.h include/dic.h include/dicformat.h - include/dicformat/decls.h include/dicformat/structs.h src/identify.c src/open.c include/dicformat/context.h src/close.c include/dicformat/errors.h src/read.c src/crc64.c src/cst.c src/ecc_cd.c src/helpers.c) + include/dicformat/decls.h include/dicformat/structs.h src/identify.c src/open.c include/dicformat/context.h + src/close.c include/dicformat/errors.h src/read.c src/crc64.c src/cst.c src/ecc_cd.c src/helpers.c) include_directories(include include/dicformat) \ No newline at end of file diff --git a/include/dic.h b/include/dic.h index 2acb204..a08e0e5 100644 --- a/include/dic.h +++ b/include/dic.h @@ -43,982 +43,982 @@ // TODO: Generate automatically from C# -/** +/** * Contains an enumeration of all known types of media. */ 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, + 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, + 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, // 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, + 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, + 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, + 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, + HDVMD = 74, /** Versatile Compact Disc High Density */ - VCDHD = 75, + VCDHD = 75, /** Stacked Volumetric Optical Disc */ - SVOD = 76, + SVOD = 76, /** Five Dimensional disc */ - FDDVD = 77, + 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, - LVROM = 83, - MegaLD = 84, + LDROM = 81, + LDROM2 = 82, + LVROM = 83, + MegaLD = 84, // LaserDisc based, types 80 to 89 // MiniDisc based, types 90 to 99 /** Sony Hi-MD */ - HiMD = 90, + HiMD = 90, /** Sony MiniDisc */ - MD = 91, - MDData = 92, - MDData2 = 93, + MD = 91, + MDData = 92, + MDData2 = 93, // MiniDisc based, types 90 to 99 // 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, + 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, + UMD = 118, + PlayStationVitaGameCard = 119, // Sony game media, types 110 to 129 // Microsoft game media, types 130 to 149 /** Microsoft X-box Game Disc */ - XGD = 130, + XGD = 130, /** Microsoft X-box 360 Game Disc */ - XGD2 = 131, + XGD2 = 131, /** Microsoft X-box 360 Game Disc */ - XGD3 = 132, + XGD3 = 132, /** Microsoft X-box One Game Disc */ - XGD4 = 133, + XGD4 = 133, // Microsoft game media, types 130 to 149 // Sega game media, types 150 to 169 /** Sega MegaCD */ - MEGACD = 150, + MEGACD = 150, /** Sega Saturn disc */ - SATURNCD = 151, + SATURNCD = 151, /** Sega/Yamaha Gigabyte Disc */ - GDROM = 152, + GDROM = 152, /** Sega/Yamaha recordable Gigabyte Disc */ - GDR = 153, - SegaCard = 154, - MilCD = 155, + GDR = 153, + SegaCard = 154, + MilCD = 155, // Sega game media, types 150 to 169 // Other game media, types 170 to 179 /** PC-Engine / TurboGrafx cartridge */ - HuCard = 170, + HuCard = 170, /** PC-Engine / TurboGrafx CD */ - SuperCDROM2 = 171, + 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, + AppleFileWare = 186, // Apple standard floppy format // IBM/Microsoft PC floppy formats, types 190 to 209 /** 5.25", SS, DD, 40 tracks, 8 spt, 512 bytes/sector, MFM */ - DOS_525_SS_DD_8 = 190, + DOS_525_SS_DD_8 = 190, /** 5.25", SS, DD, 40 tracks, 9 spt, 512 bytes/sector, MFM */ - DOS_525_SS_DD_9 = 191, + DOS_525_SS_DD_9 = 191, /** 5.25", DS, DD, 40 tracks, 8 spt, 512 bytes/sector, MFM */ - DOS_525_DS_DD_8 = 192, + DOS_525_DS_DD_8 = 192, /** 5.25", DS, DD, 40 tracks, 9 spt, 512 bytes/sector, MFM */ - DOS_525_DS_DD_9 = 193, + 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 - */ - IBM53FD_1024 = 218, + 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 // DEC standard floppy formats, types 220 to 229 /** 8", SS, DD, 77 tracks, 26 spt, 128 bytes/sector, FM */ - RX01 = 220, + RX01 = 220, /** 8", SS, DD, 77 tracks, 26 spt, 256 bytes/sector, FM/MFM */ - RX02 = 221, + RX02 = 221, /** 8", DS, DD, 77 tracks, 26 spt, 256 bytes/sector, FM/MFM */ - RX03 = 222, + RX03 = 222, /** 5.25", SS, DD, 80 tracks, 10 spt, 512 bytes/sector, MFM */ - RX50 = 223, + RX50 = 223, // DEC standard floppy formats, types 220 to 229 // Acorn standard floppy formats, types 230 to 239 /** 5,25", SS, SD, 40 tracks, 10 spt, 256 bytes/sector, FM */ - ACORN_525_SS_SD_40 = 230, + ACORN_525_SS_SD_40 = 230, /** 5,25", SS, SD, 80 tracks, 10 spt, 256 bytes/sector, FM */ - ACORN_525_SS_SD_80 = 231, + ACORN_525_SS_SD_80 = 231, /** 5,25", SS, DD, 40 tracks, 16 spt, 256 bytes/sector, MFM */ - ACORN_525_SS_DD_40 = 232, + ACORN_525_SS_DD_40 = 232, /** 5,25", SS, DD, 80 tracks, 16 spt, 256 bytes/sector, MFM */ - ACORN_525_SS_DD_80 = 233, + 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, + ATARI_35_SS_DD_11 = 245, /** 3,5", DS, DD, 80 tracks, 11 spt, 512 bytes/sector, MFM */ - ATARI_35_DS_DD_11 = 246, + ATARI_35_DS_DD_11 = 246, // Atari standard floppy formats, types 240 to 249 // 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, + CBM_AMIGA_35_DD = 251, /** 3,5", DS, HD, 80 tracks, 22 spt, 512 bytes/sector, MFM (Amiga) */ - CBM_AMIGA_35_HD = 252, + 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, + 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 - /** + /** * 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, /** - * 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 - */ - ECMA_99_15 = 271, /** - * 5,25", DS, DD, 77 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 - */ - ECMA_99_26 = 272, + 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 + */ + ECMA_99_15 = 271, /** + * 5,25", DS, DD, 77 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 + */ + 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, /** - * 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, /** - * 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 - */ - ECMA_69_15 = 277, /** - * 8", DS, DD, 77 tracks, 26 spt, 256 bytes/sector, FM, track 0 side 0 = 26 sectors, 128 bytes/sector, track 0 - * side 1 = 26 sectors, 256 bytes/sector - */ - ECMA_69_26 = 278, /** - * 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, /** - * 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_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, /** + * 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 + */ + ECMA_69_15 = 277, /** + * 8", DS, DD, 77 tracks, 26 spt, 256 bytes/sector, FM, track 0 side 0 = 26 sectors, 128 + * bytes/sector, track 0 side 1 = 26 sectors, 256 bytes/sector + */ + ECMA_69_26 = 278, /** + * 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, /** + * 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, /** 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 /** 5,25", DS, DD, 82 tracks, 10 spt, 512 bytes/sector, MFM */ - FDFORMAT_525_DD = 290, + FDFORMAT_525_DD = 290, /** 5,25", DS, HD, 82 tracks, 17 spt, 512 bytes/sector, MFM */ - FDFORMAT_525_HD = 291, + 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 /** 3.5", DS, DD, 70 tracks, 9 spt, 512 bytes/sector, MFM */ - Apricot_35 = 309, + Apricot_35 = 309, // Apricot ACT standard floppy formats, type 309 // OnStream ADR, types 310 to 319 - ADR2120 = 310, - ADR260 = 311, - ADR30 = 312, - ADR50 = 313, + ADR2120 = 310, + ADR260 = 311, + ADR30 = 312, + ADR50 = 313, // OnStream ADR, types 310 to 319 // Advanced Intelligent Tape, types 320 to 339 - AIT1 = 320, - AIT1Turbo = 321, - AIT2 = 322, - AIT2Turbo = 323, - AIT3 = 324, - AIT3Ex = 325, - AIT3Turbo = 326, - AIT4 = 327, - AIT5 = 328, - AITETurbo = 329, - SAIT1 = 330, - SAIT2 = 331, + AIT1 = 320, + AIT1Turbo = 321, + AIT2 = 322, + AIT2Turbo = 323, + AIT3 = 324, + AIT3Ex = 325, + AIT3Turbo = 326, + AIT4 = 327, + AIT5 = 328, + AITETurbo = 329, + SAIT1 = 330, + SAIT2 = 331, // Advanced Intelligent Tape, types 320 to 339 // Iomega, types 340 to 359 - Bernoulli = 340, - Bernoulli2 = 341, - Ditto = 342, - DittoMax = 343, - Jaz = 344, - Jaz2 = 345, - PocketZip = 346, - REV120 = 347, - REV35 = 348, - REV70 = 349, - ZIP100 = 350, - ZIP250 = 351, - ZIP750 = 352, + Bernoulli = 340, + Bernoulli2 = 341, + Ditto = 342, + DittoMax = 343, + Jaz = 344, + Jaz2 = 345, + PocketZip = 346, + REV120 = 347, + REV35 = 348, + REV70 = 349, + ZIP100 = 350, + ZIP250 = 351, + ZIP750 = 352, // Iomega, types 340 to 359 // Audio or video media, types 360 to 369 - CompactCassette = 360, - Data8 = 361, - MiniDV = 362, + CompactCassette = 360, + 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 - CFast = 370, - CompactFlash = 371, - CompactFlashType2 = 372, + CFast = 370, + CompactFlash = 371, + CompactFlashType2 = 372, // CompactFlash Association, types 370 to 379 // Digital Audio Tape / Digital Data Storage, types 380 to 389 - DigitalAudioTape = 380, - DAT160 = 381, - DAT320 = 382, - DAT72 = 383, - DDS1 = 384, - DDS2 = 385, - DDS3 = 386, - DDS4 = 387, + DigitalAudioTape = 380, + DAT160 = 381, + DAT320 = 382, + DAT72 = 383, + DDS1 = 384, + DDS2 = 385, + DDS3 = 386, + DDS4 = 387, // Digital Audio Tape / Digital Data Storage, types 380 to 389 // DEC, types 390 to 399 - CompactTapeI = 390, - CompactTapeII = 391, - DECtapeII = 392, - DLTtapeIII = 393, - DLTtapeIIIxt = 394, - DLTtapeIV = 395, - DLTtapeS4 = 396, - SDLT1 = 397, - SDLT2 = 398, - VStapeI = 399, + CompactTapeI = 390, + CompactTapeII = 391, + DECtapeII = 392, + DLTtapeIII = 393, + DLTtapeIIIxt = 394, + DLTtapeIV = 395, + DLTtapeS4 = 396, + SDLT1 = 397, + SDLT2 = 398, + VStapeI = 399, // DEC, types 390 to 399 // Exatape, types 400 to 419 - Exatape15m = 400, - Exatape22m = 401, - Exatape22mAME = 402, - Exatape28m = 403, - Exatape40m = 404, - Exatape45m = 405, - Exatape54m = 406, - Exatape75m = 407, - Exatape76m = 408, - Exatape80m = 409, - Exatape106m = 410, - Exatape160mXL = 411, - Exatape112m = 412, - Exatape125m = 413, - Exatape150m = 414, - Exatape170m = 415, - Exatape225m = 416, + Exatape15m = 400, + Exatape22m = 401, + Exatape22mAME = 402, + Exatape28m = 403, + Exatape40m = 404, + Exatape45m = 405, + Exatape54m = 406, + Exatape75m = 407, + Exatape76m = 408, + Exatape80m = 409, + Exatape106m = 410, + Exatape160mXL = 411, + Exatape112m = 412, + Exatape125m = 413, + Exatape150m = 414, + Exatape170m = 415, + Exatape225m = 416, // Exatape, types 400 to 419 // PCMCIA / ExpressCard, types 420 to 429 - ExpressCard34 = 420, - ExpressCard54 = 421, - PCCardTypeI = 422, - PCCardTypeII = 423, - PCCardTypeIII = 424, - PCCardTypeIV = 425, + ExpressCard34 = 420, + ExpressCard54 = 421, + PCCardTypeI = 422, + PCCardTypeII = 423, + PCCardTypeIII = 424, + PCCardTypeIV = 425, // PCMCIA / ExpressCard, types 420 to 429 // SyQuest, types 430 to 449 - EZ135 = 430, - EZ230 = 431, - Quest = 432, - SparQ = 433, - SQ100 = 434, - SQ200 = 435, - SQ300 = 436, - SQ310 = 437, - SQ327 = 438, - SQ400 = 439, - SQ800 = 440, - SQ1500 = 441, - SQ2000 = 442, - SyJet = 443, + EZ135 = 430, + EZ230 = 431, + Quest = 432, + SparQ = 433, + SQ100 = 434, + SQ200 = 435, + SQ300 = 436, + SQ310 = 437, + SQ327 = 438, + SQ400 = 439, + SQ800 = 440, + SQ1500 = 441, + SQ2000 = 442, + SyJet = 443, // SyQuest, types 430 to 449 // Nintendo, types 450 to 469 - FamicomGamePak = 450, - GameBoyAdvanceGamePak = 451, - GameBoyGamePak = 452, + FamicomGamePak = 450, + 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 - IBM3470 = 470, - IBM3480 = 471, - IBM3490 = 472, - IBM3490E = 473, - IBM3592 = 474, + IBM3470 = 470, + IBM3480 = 471, + IBM3490 = 472, + IBM3490E = 473, + IBM3592 = 474, // IBM Tapes, types 470 to 479 // LTO Ultrium, types 480 to 509 - LTO = 480, - LTO2 = 481, - LTO3 = 482, - LTO3WORM = 483, - LTO4 = 484, - LTO4WORM = 485, - LTO5 = 486, - LTO5WORM = 487, - LTO6 = 488, - LTO6WORM = 489, - LTO7 = 490, - LTO7WORM = 491, + LTO = 480, + LTO2 = 481, + LTO3 = 482, + LTO3WORM = 483, + LTO4 = 484, + LTO4WORM = 485, + LTO5 = 486, + LTO5WORM = 487, + LTO6 = 488, + LTO6WORM = 489, + LTO7 = 490, + LTO7WORM = 491, // LTO Ultrium, types 480 to 509 // MemoryStick, types 510 to 519 - MemoryStick = 510, - MemoryStickDuo = 511, - MemoryStickMicro = 512, - MemoryStickPro = 513, - MemoryStickProDuo = 514, + MemoryStick = 510, + MemoryStickDuo = 511, + MemoryStickMicro = 512, + MemoryStickPro = 513, + MemoryStickProDuo = 514, // MemoryStick, types 510 to 519 // SecureDigital, types 520 to 529 - microSD = 520, - miniSD = 521, - SecureDigital = 522, + microSD = 520, + miniSD = 521, + SecureDigital = 522, // SecureDigital, types 520 to 529 // MultiMediaCard, types 530 to 539 - MMC = 530, - MMCmicro = 531, - RSMMC = 532, - MMCplus = 533, - MMCmobile = 534, + MMC = 530, + MMCmicro = 531, + RSMMC = 532, + MMCplus = 533, + MMCmobile = 534, // MultiMediaCard, types 530 to 539 // SLR, types 540 to 569 - MLR1 = 540, - MLR1SL = 541, - MLR3 = 542, - SLR1 = 543, - SLR2 = 544, - SLR3 = 545, - SLR32 = 546, - SLR32SL = 547, - SLR4 = 548, - SLR5 = 549, - SLR5SL = 550, - SLR6 = 551, - SLRtape7 = 552, - SLRtape7SL = 553, - SLRtape24 = 554, - SLRtape24SL = 555, - SLRtape40 = 556, - SLRtape50 = 557, - SLRtape60 = 558, - SLRtape75 = 559, - SLRtape100 = 560, - SLRtape140 = 561, + MLR1 = 540, + MLR1SL = 541, + MLR3 = 542, + SLR1 = 543, + SLR2 = 544, + SLR3 = 545, + SLR32 = 546, + SLR32SL = 547, + SLR4 = 548, + SLR5 = 549, + SLR5SL = 550, + SLR6 = 551, + SLRtape7 = 552, + SLRtape7SL = 553, + SLRtape24 = 554, + SLRtape24SL = 555, + SLRtape40 = 556, + SLRtape50 = 557, + SLRtape60 = 558, + SLRtape75 = 559, + SLRtape100 = 560, + SLRtape140 = 561, // SLR, types 540 to 569 // QIC, types 570 to 589 - QIC11 = 570, - QIC120 = 571, - QIC1350 = 572, - QIC150 = 573, - QIC24 = 574, - QIC3010 = 575, - QIC3020 = 576, - QIC3080 = 577, - QIC3095 = 578, - QIC320 = 579, - QIC40 = 580, - QIC525 = 581, - QIC80 = 582, + QIC11 = 570, + QIC120 = 571, + QIC1350 = 572, + QIC150 = 573, + QIC24 = 574, + QIC3010 = 575, + QIC3020 = 576, + QIC3080 = 577, + QIC3095 = 578, + QIC320 = 579, + QIC40 = 580, + QIC525 = 581, + QIC80 = 582, // QIC, types 570 to 589 // StorageTek tapes, types 590 to 609 - STK4480 = 590, - STK4490 = 591, - STK9490 = 592, - T9840A = 593, - T9840B = 594, - T9840C = 595, - T9840D = 596, - T9940A = 597, - T9940B = 598, - T10000A = 599, - T10000B = 600, - T10000C = 601, - T10000D = 602, + STK4480 = 590, + STK4490 = 591, + STK9490 = 592, + T9840A = 593, + T9840B = 594, + T9840C = 595, + T9840D = 596, + T9940A = 597, + T9940B = 598, + T10000A = 599, + T10000B = 600, + T10000C = 601, + T10000D = 602, // StorageTek tapes, types 590 to 609 // Travan, types 610 to 619 - Travan = 610, - Travan1Ex = 611, - Travan3 = 612, - Travan3Ex = 613, - Travan4 = 614, - Travan5 = 615, - Travan7 = 616, + Travan = 610, + Travan1Ex = 611, + Travan3 = 612, + Travan3Ex = 613, + Travan4 = 614, + Travan5 = 615, + Travan7 = 616, // Travan, types 610 to 619 // VXA, types 620 to 629 - VXA1 = 620, - VXA2 = 621, - VXA3 = 622, + VXA1 = 620, + VXA2 = 621, + VXA3 = 622, // VXA, types 620 to 629 // 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, + 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, + 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 - BeeCard = 670, - Borsu = 671, - DataStore = 672, - DIR = 673, - DST = 674, - DTF = 675, - DTF2 = 676, - Flextra3020 = 677, - Flextra3225 = 678, - HiTC1 = 679, - HiTC2 = 680, - LT1 = 681, - MiniCard = 872, - Orb = 683, - Orb5 = 684, - SmartMedia = 685, - xD = 686, - XQD = 687, - DataPlay = 688, + BeeCard = 670, + Borsu = 671, + DataStore = 672, + DIR = 673, + DST = 674, + DTF = 675, + DTF2 = 676, + Flextra3020 = 677, + Flextra3225 = 678, + HiTC1 = 679, + HiTC2 = 680, + LT1 = 681, + MiniCard = 872, + Orb = 683, + Orb5 = 684, + SmartMedia = 685, + xD = 686, + XQD = 687, + DataPlay = 688, // Miscellaneous, types 670 to 689 // Apple specific media, types 690 to 699 - AppleProfile = 690, - AppleWidget = 691, - AppleHD20 = 692, - PriamDataTower = 693, - Pippin = 694, + AppleProfile = 690, + AppleWidget = 691, + AppleHD20 = 692, + PriamDataTower = 693, + Pippin = 694, // Apple specific media, types 690 to 699 // DEC hard disks, types 700 to 729 - /** + /** * 2382 cylinders, 4 tracks/cylinder, 42 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, * 204890112 bytes */ - RA60 = 700, /** - * 546 cylinders, 14 tracks/cylinder, 31 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 121325568 bytes - */ - RA80 = 701, /** - * 1248 cylinders, 14 tracks/cylinder, 51 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 456228864 bytes - */ - RA81 = 702, /** - * 302 cylinders, 4 tracks/cylinder, 42 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 25976832 - * bytes - */ - RC25 = 703, /** - * 615 cylinders, 4 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 21411840 - * bytes - */ - RD31 = 704, /** - * 820 cylinders, 6 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 42823680 - * bytes - */ - RD32 = 705, /** - * 306 cylinders, 4 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 10653696 - * bytes - */ - RD51 = 706, /** - * 480 cylinders, 7 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 30965760 - * bytes - */ - RD52 = 707, /** - * 1024 cylinders, 7 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 75497472 bytes - */ - RD53 = 708, /** - * 1225 cylinders, 8 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 159936000 bytes - */ - RD54 = 709, /** - * 411 cylinders, 3 tracks/cylinder, 22 sectors/track, 256 words/sector, 16 bits/word, 512 bytes/sector, 13888512 - * bytes - */ - RK06 = 710, /** - * 411 cylinders, 3 tracks/cylinder, 20 sectors/track, 256 words/sector, 18 bits/word, 576 bytes/sector, 14204160 - * bytes - */ - RK06_18 = 711, /** - * 815 cylinders, 3 tracks/cylinder, 22 sectors/track, 256 words/sector, 16 bits/word, 512 bytes/sector, 27540480 - * bytes - */ - RK07 = 712, /** - * 815 cylinders, 3 tracks/cylinder, 20 sectors/track, 256 words/sector, 18 bits/word, 576 bytes/sector, 28166400 - * bytes - */ - RK07_18 = 713, /** - * 823 cylinders, 5 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 67420160 - * bytes - */ - RM02 = 714, /** - * 823 cylinders, 5 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, 67420160 - * bytes - */ - RM03 = 715, /** - * 823 cylinders, 19 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 256196608 bytes - */ - RM05 = 716, /** - * 203 cylinders, 10 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 22865920 bytes - */ - RP02 = 717, /** - * 203 cylinders, 10 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, - * 23385600 bytes - */ - RP02_18 = 718, /** - * 400 cylinders, 10 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 45056000 bytes - */ - RP03 = 719, /** - * 400 cylinders, 10 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, - * 46080000 bytes - */ - RP03_18 = 720, /** - * 411 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 87960576 bytes - */ - RP04 = 721, /** - * 411 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, - * 89959680 bytes - */ - RP04_18 = 722, /** - * 411 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 87960576 bytes - */ - RP05 = 723, /** - * 411 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, - * 89959680 bytes - */ - RP05_18 = 724, /** - * 815 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 bytes/sector, - * 174423040 bytes - */ - RP06 = 725, /** - * 815 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 bytes/sector, - * 178387200 bytes - */ - RP06_18 = 726, + RA60 = 700, /** + * 546 cylinders, 14 tracks/cylinder, 31 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 121325568 bytes + */ + RA80 = 701, /** + * 1248 cylinders, 14 tracks/cylinder, 51 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 456228864 bytes + */ + RA81 = 702, /** + * 302 cylinders, 4 tracks/cylinder, 42 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 25976832 bytes + */ + RC25 = 703, /** + * 615 cylinders, 4 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 21411840 bytes + */ + RD31 = 704, /** + * 820 cylinders, 6 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 42823680 bytes + */ + RD32 = 705, /** + * 306 cylinders, 4 tracks/cylinder, 17 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 10653696 bytes + */ + RD51 = 706, /** + * 480 cylinders, 7 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 30965760 bytes + */ + RD52 = 707, /** + * 1024 cylinders, 7 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 75497472 bytes + */ + RD53 = 708, /** + * 1225 cylinders, 8 tracks/cylinder, 18 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 159936000 bytes + */ + RD54 = 709, /** + * 411 cylinders, 3 tracks/cylinder, 22 sectors/track, 256 words/sector, 16 bits/word, 512 + * bytes/sector, 13888512 bytes + */ + RK06 = 710, /** + * 411 cylinders, 3 tracks/cylinder, 20 sectors/track, 256 words/sector, 18 bits/word, 576 + * bytes/sector, 14204160 bytes + */ + RK06_18 = 711, /** + * 815 cylinders, 3 tracks/cylinder, 22 sectors/track, 256 words/sector, 16 bits/word, 512 + * bytes/sector, 27540480 bytes + */ + RK07 = 712, /** + * 815 cylinders, 3 tracks/cylinder, 20 sectors/track, 256 words/sector, 18 bits/word, 576 + * bytes/sector, 28166400 bytes + */ + RK07_18 = 713, /** + * 823 cylinders, 5 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 67420160 bytes + */ + RM02 = 714, /** + * 823 cylinders, 5 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 67420160 bytes + */ + RM03 = 715, /** + * 823 cylinders, 19 tracks/cylinder, 32 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 256196608 bytes + */ + RM05 = 716, /** + * 203 cylinders, 10 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 22865920 bytes + */ + RP02 = 717, /** + * 203 cylinders, 10 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 + * bytes/sector, 23385600 bytes + */ + RP02_18 = 718, /** + * 400 cylinders, 10 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 45056000 bytes + */ + RP03 = 719, /** + * 400 cylinders, 10 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 + * bytes/sector, 46080000 bytes + */ + RP03_18 = 720, /** + * 411 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 87960576 bytes + */ + RP04 = 721, /** + * 411 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 + * bytes/sector, 89959680 bytes + */ + RP04_18 = 722, /** + * 411 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 87960576 bytes + */ + RP05 = 723, /** + * 411 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 + * bytes/sector, 89959680 bytes + */ + RP05_18 = 724, /** + * 815 cylinders, 19 tracks/cylinder, 22 sectors/track, 128 words/sector, 32 bits/word, 512 + * bytes/sector, 174423040 bytes + */ + RP06 = 725, /** + * 815 cylinders, 19 tracks/cylinder, 20 sectors/track, 128 words/sector, 36 bits/word, 576 + * bytes/sector, 178387200 bytes + */ + RP06_18 = 726, // DEC hard disks, types 700 to 729 // Imation, types 730 to 739 - LS120 = 730, - LS240 = 731, - FD32MB = 732, - RDX = 733, + LS120 = 730, + LS240 = 731, + FD32MB = 732, + RDX = 733, /** Imation 320Gb RDX */ - RDX320 = 734, + RDX320 = 734, // Imation, types 730 to 739 // VideoNow, types 740 to 749 - VideoNow = 740, - VideoNowColor = 741, - VideoNowXp = 742 + VideoNow = 740, + VideoNowColor = 741, + VideoNowXp = 742 // } MediaType; -/** +/** * Contains information about a dump image and its contents */ 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 */ @@ -1026,51 +1026,51 @@ typedef struct ImageInfo /** Size of sectors contained in the image */ uint32_t SectorSize; /** Media tags contained by the image */ - //List ReadableMediaTags; + // List ReadableMediaTags; /** Sector tags contained by the image */ - //List ReadableSectorTags; + // List 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; @@ -1080,109 +1080,108 @@ typedef struct ImageInfo uint32_t SectorsPerTrack; } ImageInfo; -/** +/** * Metadata present for each sector (aka, "tag"). */ typedef enum { - AppleSectorTag = 0,/** Apple's GCR sector tags, 12 bytes */ - CdSectorSync = 1, /** Sync frame from CD sector, 12 bytes */ - CdSectorHeader = 2, /** CD sector header, 4 bytes */ - CdSectorSubHeader = 3, /** CD mode 2 sector subheader */ - CdSectorEdc = 4, /** CD sector EDC, 4 bytes */ - CdSectorEccP = 5, /** CD sector ECC P, 172 bytes */ - CdSectorEccQ = 6, /** CD sector ECC Q, 104 bytes */ - CdSectorEcc = 7, /** CD sector ECC (P and Q), 276 bytes */ - CdSectorSubchannelDic = 8, /** CD sector subchannel, 96 bytes */ - CdTrackIsrc = 9, /** CD track ISRC, string, 12 bytes */ - CdTrackText = 10,/** CD track text, string, 13 bytes */ + AppleSectorTag = 0, /** Apple's GCR sector tags, 12 bytes */ + CdSectorSync = 1, /** Sync frame from CD sector, 12 bytes */ + CdSectorHeader = 2, /** CD sector header, 4 bytes */ + CdSectorSubHeader = 3, /** CD mode 2 sector subheader */ + CdSectorEdc = 4, /** CD sector EDC, 4 bytes */ + CdSectorEccP = 5, /** CD sector ECC P, 172 bytes */ + CdSectorEccQ = 6, /** CD sector ECC Q, 104 bytes */ + CdSectorEcc = 7, /** CD sector ECC (P and Q), 276 bytes */ + CdSectorSubchannelDic = 8, /** CD sector subchannel, 96 bytes */ + CdTrackIsrc = 9, /** CD track ISRC, string, 12 bytes */ + CdTrackText = 10, /** CD track text, string, 13 bytes */ CdTrackFlags = 11, /** CD track flags, 1 byte */ DvdCmi = 12, /** DVD sector copyright information */ - FloppyAddressMark = 13,/** Floppy address mark (contents depend on underlying floppy format) */ + FloppyAddressMark = 13, /** Floppy address mark (contents depend on underlying floppy format) */ MaxSectorTag = FloppyAddressMark } SectorTagType; -/* +/* * Metadata present for each media. */ typedef enum { /* CD table of contents */ - CD_TOC = 0, /* CD session information */ - CD_SessionInfo = 1, /* CD full table of contents */ - CD_FullTOC = 2, /* CD PMA */ - CD_PMA = 3, /* CD Adress-Time-In-Pregroove */ - CD_ATIP = 4, /* CD-Text */ - CD_TEXT = 5, /* CD Media Catalogue Number */ - CD_MCN = 6, /* DVD/HD DVD Physical Format Information */ - DVD_PFI = 7, /* DVD Lead-in Copyright Management Information */ - DVD_CMI = 8, /* DVD disc key */ - DVD_DiscKey = 9, /* DVD/HD DVD Burst Cutting Area */ - DVD_BCA = 10, /* DVD/HD DVD Lead-in Disc Manufacturer Information */ - DVD_DMI = 11, /* Media identifier */ - DVD_MediaIdentifier = 12, /* Media key block */ - DVD_MKB = 13, /* DVD-RAM/HD DVD-RAM DDS information */ - DVDRAM_DDS = 14, /* DVD-RAM/HD DVD-RAM Medium status */ - DVDRAM_MediumStatus = 15, /* DVD-RAM/HD DVD-RAM Spare area information */ - DVDRAM_SpareArea = 16, /* DVD-R/-RW/HD DVD-R RMD in last border-out */ - DVDR_RMD = 17, /* Pre-recorded information from DVD-R/-RW lead-in */ - DVDR_PreRecordedInfo = 18, /* DVD-R/-RW/HD DVD-R media identifier */ - DVDR_MediaIdentifier = 19, /* DVD-R/-RW/HD DVD-R physical format information */ - DVDR_PFI = 20, /* ADIP information */ - DVD_ADIP = 21, /* HD DVD Lead-in copyright protection information */ - HDDVD_CPI = 22, /* HD DVD-R Medium Status */ - HDDVD_MediumStatus = 23, /* DVD+/-R DL Layer capacity */ - DVDDL_LayerCapacity = 24, /* DVD-R DL Middle Zone start address */ - DVDDL_MiddleZoneAddress = 25, /* DVD-R DL Jump Interval Size */ - DVDDL_JumpIntervalSize = 26, /* DVD-R DL Start LBA of the manual layer jump */ - DVDDL_ManualLayerJumpLBA = 27, /* Blu-ray Disc Information */ - BD_DI = 28, /* Blu-ray Burst Cutting Area */ - BD_BCA = 29, /* Blu-ray Disc Definition Structure */ - BD_DDS = 30, /* Blu-ray Cartridge Status */ - BD_CartridgeStatus = 31, /* Blu-ray Status of Spare Area */ - BD_SpareArea = 32, /* AACS volume identifier */ - AACS_VolumeIdentifier = 33, /* AACS pre-recorded media serial number */ - AACS_SerialNumber = 34, /* AACS media identifier */ - AACS_MediaIdentifier = 35, /* Lead-in AACS media key block */ - AACS_MKB = 36, /* AACS data keys */ - AACS_DataKeys = 37, /* LBA extents flagged for bus encryption by AACS */ - AACS_LBAExtents = 38, /* CPRM media key block in Lead-in */ - AACS_CPRM_MKB = 39, /* Recognized layer formats in hybrid discs */ - Hybrid_RecognizedLayers = 40, /* Disc write protection status */ - MMC_WriteProtection = 41, /* Disc standard information */ - MMC_DiscInformation = 42, /* Disc track resources information */ - MMC_TrackResourcesInformation = 43, /* BD-R Pseudo-overwrite information */ - MMC_POWResourcesInformation = 44, /* SCSI INQUIRY response */ - SCSI_INQUIRY = 45, /* SCSI MODE PAGE 2Ah */ - SCSI_MODEPAGE_2A = 46, /* ATA IDENTIFY DEVICE response */ - ATA_IDENTIFY = 47, /* ATA IDENTIFY PACKET DEVICE response */ - ATAPI_IDENTIFY = 48, /* PCMCIA/CardBus Card Information Structure */ - PCMCIA_CIS = 49, /* SecureDigital CID */ - SD_CID = 50, /* SecureDigital CSD */ - SD_CSD = 51, /* SecureDigital SCR */ - SD_SCR = 52, /* SecureDigital OCR */ - SD_OCR = 53, /* MultiMediaCard CID */ - MMC_CID = 54, /* MultiMediaCard CSD */ - MMC_CSD = 55, /* MultiMediaCard OCR */ - MMC_OCR = 56, /* MultiMediaCard Extended CSD */ - MMC_ExtendedCSD = 57, /* Xbox Security Sector */ - Xbox_SecuritySector = 58, /* - * 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 + CD_TOC = 0, /* CD session information */ + CD_SessionInfo = 1, /* CD full table of contents */ + CD_FullTOC = 2, /* CD PMA */ + CD_PMA = 3, /* CD Adress-Time-In-Pregroove */ + CD_ATIP = 4, /* CD-Text */ + CD_TEXT = 5, /* CD Media Catalogue Number */ + CD_MCN = 6, /* DVD/HD DVD Physical Format Information */ + DVD_PFI = 7, /* DVD Lead-in Copyright Management Information */ + DVD_CMI = 8, /* DVD disc key */ + DVD_DiscKey = 9, /* DVD/HD DVD Burst Cutting Area */ + DVD_BCA = 10, /* DVD/HD DVD Lead-in Disc Manufacturer Information */ + DVD_DMI = 11, /* Media identifier */ + DVD_MediaIdentifier = 12, /* Media key block */ + DVD_MKB = 13, /* DVD-RAM/HD DVD-RAM DDS information */ + DVDRAM_DDS = 14, /* DVD-RAM/HD DVD-RAM Medium status */ + DVDRAM_MediumStatus = 15, /* DVD-RAM/HD DVD-RAM Spare area information */ + DVDRAM_SpareArea = 16, /* DVD-R/-RW/HD DVD-R RMD in last border-out */ + DVDR_RMD = 17, /* Pre-recorded information from DVD-R/-RW lead-in */ + DVDR_PreRecordedInfo = 18, /* DVD-R/-RW/HD DVD-R media identifier */ + DVDR_MediaIdentifier = 19, /* DVD-R/-RW/HD DVD-R physical format information */ + DVDR_PFI = 20, /* ADIP information */ + DVD_ADIP = 21, /* HD DVD Lead-in copyright protection information */ + HDDVD_CPI = 22, /* HD DVD-R Medium Status */ + HDDVD_MediumStatus = 23, /* DVD+/-R DL Layer capacity */ + DVDDL_LayerCapacity = 24, /* DVD-R DL Middle Zone start address */ + DVDDL_MiddleZoneAddress = 25, /* DVD-R DL Jump Interval Size */ + DVDDL_JumpIntervalSize = 26, /* DVD-R DL Start LBA of the manual layer jump */ + DVDDL_ManualLayerJumpLBA = 27, /* Blu-ray Disc Information */ + BD_DI = 28, /* Blu-ray Burst Cutting Area */ + BD_BCA = 29, /* Blu-ray Disc Definition Structure */ + BD_DDS = 30, /* Blu-ray Cartridge Status */ + BD_CartridgeStatus = 31, /* Blu-ray Status of Spare Area */ + BD_SpareArea = 32, /* AACS volume identifier */ + AACS_VolumeIdentifier = 33, /* AACS pre-recorded media serial number */ + AACS_SerialNumber = 34, /* AACS media identifier */ + AACS_MediaIdentifier = 35, /* Lead-in AACS media key block */ + AACS_MKB = 36, /* AACS data keys */ + AACS_DataKeys = 37, /* LBA extents flagged for bus encryption by AACS */ + AACS_LBAExtents = 38, /* CPRM media key block in Lead-in */ + AACS_CPRM_MKB = 39, /* Recognized layer formats in hybrid discs */ + Hybrid_RecognizedLayers = 40, /* Disc write protection status */ + MMC_WriteProtection = 41, /* Disc standard information */ + MMC_DiscInformation = 42, /* Disc track resources information */ + MMC_TrackResourcesInformation = 43, /* BD-R Pseudo-overwrite information */ + MMC_POWResourcesInformation = 44, /* SCSI INQUIRY response */ + SCSI_INQUIRY = 45, /* SCSI MODE PAGE 2Ah */ + SCSI_MODEPAGE_2A = 46, /* ATA IDENTIFY DEVICE response */ + ATA_IDENTIFY = 47, /* ATA IDENTIFY PACKET DEVICE response */ + ATAPI_IDENTIFY = 48, /* PCMCIA/CardBus Card Information Structure */ + PCMCIA_CIS = 49, /* SecureDigital CID */ + SD_CID = 50, /* SecureDigital CSD */ + SD_CSD = 51, /* SecureDigital SCR */ + SD_SCR = 52, /* SecureDigital OCR */ + SD_OCR = 53, /* MultiMediaCard CID */ + MMC_CID = 54, /* MultiMediaCard CSD */ + MMC_CSD = 55, /* MultiMediaCard OCR */ + MMC_OCR = 56, /* MultiMediaCard Extended CSD */ + MMC_ExtendedCSD = 57, /* Xbox Security Sector */ + Xbox_SecuritySector = 58, /* + * 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 } MediaTagType; - -#endif //LIBDICFORMAT_DIC_H +#endif // LIBDICFORMAT_DIC_H #pragma clang diagnostic pop \ No newline at end of file diff --git a/include/dicformat.h b/include/dicformat.h index 582213b..112f095 100644 --- a/include/dicformat.h +++ b/include/dicformat.h @@ -36,11 +36,11 @@ #define LIBDICFORMAT_MAJOR_VERSION 1 #define LIBDICFORMAT_MINOR_VERSION 0 -#include "dicformat/errors.h" #include "dicformat/consts.h" -#include "dicformat/enums.h" -#include "dicformat/decls.h" -#include "dicformat/structs.h" #include "dicformat/context.h" +#include "dicformat/decls.h" +#include "dicformat/enums.h" +#include "dicformat/errors.h" +#include "dicformat/structs.h" -#endif //LIBDICFORMAT_DICFORMAT_H +#endif // LIBDICFORMAT_DICFORMAT_H diff --git a/include/dicformat/consts.h b/include/dicformat/consts.h index 28d024c..f5bbbb6 100644 --- a/include/dicformat/consts.h +++ b/include/dicformat/consts.h @@ -37,7 +37,8 @@ /** Magic identidier = "DICMFMT". */ #define DIC_MAGIC 0x544D52464D434944 -/** 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. */ +/** 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 DICF_VERSION 1 /** Maximum read cache size, 256MiB. */ #define MAX_CACHE_SIZE 256 * 1024 * 1024 @@ -59,6 +60,6 @@ #define CRC64_ECMA_POLY 0xC96C5795D7870F42 #define CRC64_ECMA_SEED 0xFFFFFFFFFFFFFFFF -#endif //LIBDICFORMAT_CONSTS_H +#endif // LIBDICFORMAT_CONSTS_H #pragma clang diagnostic pop \ No newline at end of file diff --git a/include/dicformat/context.h b/include/dicformat/context.h index fe325f8..2c50786 100644 --- a/include/dicformat/context.h +++ b/include/dicformat/context.h @@ -32,68 +32,68 @@ #ifndef LIBDICFORMAT_CONTEXT_H #define LIBDICFORMAT_CONTEXT_H +#include #include #include -#include typedef struct dicformatContext { - uint64_t magic; - uint8_t libraryMajorVersion; - uint8_t libraryMinorVersion; - FILE *imageStream; - DicHeader header; - struct dataLinkedList *mediaTagsHead; - struct dataLinkedList *mediaTagsTail; - 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; - size_t mappedMemoryDdtSize; - uint32_t *sectorPrefixDdt; - uint32_t *sectorSuffixDdt; - GeometryBlockHeader geometryBlock; - MetadataBlockHeader metadataBlockHeader; - uint8_t *metadataBlock; - TracksHeader tracksHeader; - TrackEntry *trackEntries; - CicmMetadataBlock cicmBlockHeader; - uint8_t *cicmBlock; - DumpHardwareHeader dumpHardwareHeader; + uint64_t magic; + uint8_t libraryMajorVersion; + uint8_t libraryMinorVersion; + FILE * imageStream; + DicHeader header; + struct dataLinkedList * mediaTagsHead; + struct dataLinkedList * mediaTagsTail; + 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; + size_t mappedMemoryDdtSize; + uint32_t * sectorPrefixDdt; + uint32_t * sectorSuffixDdt; + GeometryBlockHeader geometryBlock; + MetadataBlockHeader metadataBlockHeader; + uint8_t * metadataBlock; + TracksHeader tracksHeader; + TrackEntry * trackEntries; + CicmMetadataBlock cicmBlockHeader; + uint8_t * cicmBlock; + DumpHardwareHeader dumpHardwareHeader; struct DumpHardwareEntriesWithData *dumpHardwareEntriesWithData; - struct ImageInfo imageInfo; - CdEccContext *eccCdContext; - uint8_t numberOfDataTracks; - TrackEntry *dataTracks; - bool *readableSectorTags; + struct ImageInfo imageInfo; + CdEccContext * eccCdContext; + uint8_t numberOfDataTracks; + TrackEntry * dataTracks; + bool * readableSectorTags; } dicformatContext; typedef struct dataLinkedList { struct dataLinkedList *previous; struct dataLinkedList *next; - uint8_t *data; - int32_t type; - uint32_t length; + uint8_t * data; + int32_t type; + uint32_t length; } dataLinkedList; typedef struct DumpHardwareEntriesWithData { - DumpHardwareEntry entry; + 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; + 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) @@ -106,4 +106,4 @@ typedef struct DumpExtent #pragma pack(pop) -#endif //LIBDICFORMAT_CONTEXT_H +#endif // LIBDICFORMAT_CONTEXT_H diff --git a/include/dicformat/decls.h b/include/dicformat/decls.h index 83d0676..182e5ff 100644 --- a/include/dicformat/decls.h +++ b/include/dicformat/decls.h @@ -33,9 +33,9 @@ #ifndef LIBDICFORMAT_DECLS_H #define LIBDICFORMAT_DECLS_H +#include #include #include -#include int identify(const char *filename); @@ -71,37 +71,37 @@ bool ecc_cd_is_suffix_correct(void *context, const uint8_t *sector); bool ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector); -bool ecc_cd_check(void *context, +bool 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, + 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); + int32_t addressOffset, + int32_t dataOffset, + int32_t eccOffset); -void ecc_cd_write(void *context, +void 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); + 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 ecc_cd_write_sector(void *context, +void 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); + uint8_t * ecc, + int32_t addressOffset, + int32_t dataOffset, + int32_t eccOffset); void cd_lba_to_msf(int64_t pos, uint8_t *minute, uint8_t *second, uint8_t *frame); @@ -117,4 +117,4 @@ int32_t GetMediaTagTypeForDataType(int32_t type); int32_t GetXmlMediaType(int32_t type); -#endif //LIBDICFORMAT_DECLS_H +#endif // LIBDICFORMAT_DECLS_H diff --git a/include/dicformat/enums.h b/include/dicformat/enums.h index 15096ac..3b305b7 100644 --- a/include/dicformat/enums.h +++ b/include/dicformat/enums.h @@ -7,211 +7,215 @@ typedef enum { /** Not compressed */ - None = 0, /** LZMA */ - Lzma = 1, /** FLAC */ - Flac = 2, /** LZMA in Claunia Subchannel Transform processed data */ - LzmaClauniaSubchannelTransform = 3 + None = 0, /** LZMA */ + Lzma = 1, /** FLAC */ + Flac = 2, /** LZMA in Claunia Subchannel Transform processed data */ + LzmaClauniaSubchannelTransform = 3 } CompressionType; /** List of known data types */ 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, + 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, + 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 { - Invalid = 0, Md5 = 1, Sha1 = 2, Sha256 = 3, SpamSum = 4 + Invalid = 0, + Md5 = 1, + Sha1 = 2, + Sha256 = 3, + SpamSum = 4 } ChecksumAlgorithm; typedef enum @@ -227,12 +231,12 @@ typedef enum typedef enum { /** Audio track */ - Audio = 0, /** Data track (not any of the below defined ones) */ - Data = 1, /** Data track, compact disc mode 1 */ - CdMode1 = 2, /** Data track, compact disc mode 2, formless */ - CdMode2Formless = 3, /** Data track, compact disc mode 2, form 1 */ - CdMode2Form1 = 4, /** Data track, compact disc mode 2, form 2 */ - CdMode2Form2 = 5 + Audio = 0, /** Data track (not any of the below defined ones) */ + Data = 1, /** Data track, compact disc mode 1 */ + CdMode1 = 2, /** Data track, compact disc mode 2, formless */ + CdMode2Formless = 3, /** Data track, compact disc mode 2, form 1 */ + CdMode2Form1 = 4, /** Data track, compact disc mode 2, form 2 */ + CdMode2Form2 = 5 } TrackType; typedef enum @@ -248,19 +252,19 @@ typedef enum /** * Purely optical discs */ - OpticalDisc = 0, /** - * Media that is physically block-based or abstracted like that + OpticalDisc = 0, /** + * Media that is physically block-based or abstracted like that - */ - 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 +*/ + 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 } XmlMediaType; -#endif //LIBDICFORMAT_ENUMS_H +#endif // LIBDICFORMAT_ENUMS_H #pragma clang diagnostic pop \ No newline at end of file diff --git a/include/dicformat/errors.h b/include/dicformat/errors.h index 4ce9e7b..9d8a274 100644 --- a/include/dicformat/errors.h +++ b/include/dicformat/errors.h @@ -27,4 +27,4 @@ #define DICF_STATUS_SECTOR_WITH_ERRORS 2 #define DICF_STATUS_SECTOR_DELETED 3 -#endif //LIBDICFORMAT_ERRORS_H +#endif // LIBDICFORMAT_ERRORS_H diff --git a/include/dicformat/structs.h b/include/dicformat/structs.h index 8941e79..09c98ac 100644 --- a/include/dicformat/structs.h +++ b/include/dicformat/structs.h @@ -37,34 +37,35 @@ #pragma pack(push, 1) -#include -#include -#include #include "enums.h" +#include +#include +#include + /**Header, at start of file */ typedef struct DicHeader { /**Header identifier, */ 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; } DicHeader; /**Header for a deduplication table. Table follows it */ @@ -77,7 +78,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 */ @@ -151,9 +152,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 */ @@ -291,14 +292,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; @@ -312,14 +313,14 @@ typedef struct Crc64Context typedef struct CdEccContext { - bool initedEdc; - uint8_t *eccBTable; - uint8_t *eccFTable; + bool initedEdc; + uint8_t * eccBTable; + uint8_t * eccFTable; uint32_t *edcTable; } CdEccContext; #pragma pack(pop) -#endif //LIBDICFORMAT_STRUCTS_H +#endif // LIBDICFORMAT_STRUCTS_H #pragma clang diagnostic pop \ No newline at end of file diff --git a/src/close.c b/src/close.c index 0c2bbb2..ef1d50a 100644 --- a/src/close.c +++ b/src/close.c @@ -30,10 +30,10 @@ // Copyright © 2011-2019 Natalia Portillo // ****************************************************************************/ -#include #include -#include #include +#include +#include #include int close(void *context) @@ -54,8 +54,7 @@ int close(void *context) } // This may do nothing if imageStream is NULL, but as the behaviour is undefined, better sure than sorry - if(ctx->imageStream != NULL) - fclose(ctx->imageStream); + if(ctx->imageStream != NULL) fclose(ctx->imageStream); free(ctx->sectorPrefix); free(ctx->sectorPrefixCorrected); @@ -82,10 +81,7 @@ int close(void *context) free(ctx->mediaTagsHead); } - if(!ctx->inMemoryDdt) - { - munmap(ctx->userDataDdt, ctx->mappedMemoryDdtSize); - } + if(!ctx->inMemoryDdt) { munmap(ctx->userDataDdt, ctx->mappedMemoryDdtSize); } free(ctx->sectorPrefixDdt); free(ctx->sectorSuffixDdt); diff --git a/src/crc64.c b/src/crc64.c index af268e4..f915777 100644 --- a/src/crc64.c +++ b/src/crc64.c @@ -30,10 +30,10 @@ // Copyright © 2011-2019 Natalia Portillo // ****************************************************************************/ -#include -#include -#include #include +#include +#include +#include void *crc64_init(uint64_t polynomial, uint64_t seed) { @@ -41,8 +41,7 @@ void *crc64_init(uint64_t polynomial, uint64_t seed) ctx = malloc(sizeof(Crc64Context)); - if(ctx == NULL) - return NULL; + if(ctx == NULL) return NULL; memset(ctx, 1, sizeof(Crc64Context)); @@ -52,7 +51,7 @@ void *crc64_init(uint64_t polynomial, uint64_t seed) for(int i = 0; i < 256; i++) { uint64_t entry = (uint64_t)i; - for(int j = 0; j < 8; j++) + for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (entry >> 1) ^ polynomial; else @@ -64,18 +63,13 @@ void *crc64_init(uint64_t polynomial, uint64_t seed) return ctx; } -void *crc64_init_ecma(void) -{ - return crc64_init(CRC64_ECMA_POLY, CRC64_ECMA_SEED); -} - +void *crc64_init_ecma(void) { return crc64_init(CRC64_ECMA_POLY, CRC64_ECMA_SEED); } void crc64_update(void *context, const uint8_t *data, size_t len) { Crc64Context *ctx = context; - for(size_t i = 0; i < len; i++) - ctx->hashInt = (ctx->hashInt >> 8) ^ ctx->table[data[i] ^ (ctx->hashInt & 0xFF)]; + for(size_t i = 0; i < len; i++) ctx->hashInt = (ctx->hashInt >> 8) ^ ctx->table[data[i] ^ (ctx->hashInt & 0xFF)]; } uint64_t crc64_final(void *context) @@ -93,7 +87,7 @@ uint64_t crc64_data(const uint8_t *data, size_t len, uint64_t polynomial, uint64 for(int i = 0; i < 256; i++) { uint64_t entry = (uint64_t)i; - for(int j = 0; j < 8; j++) + for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (entry >> 1) ^ polynomial; else @@ -102,8 +96,7 @@ uint64_t crc64_data(const uint8_t *data, size_t len, uint64_t polynomial, uint64 table[i] = entry; } - for(size_t i = 0; i < len; i++) - hashInt = (hashInt >> 8) ^ table[data[i] ^ (hashInt & 0xFF)]; + for(size_t i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ (hashInt & 0xFF)]; return hashInt ^ seed; } @@ -112,4 +105,3 @@ uint64_t crc64_data_ecma(const uint8_t *data, size_t len) { return crc64_data(data, len, CRC64_ECMA_POLY, CRC64_ECMA_SEED); } - diff --git a/src/cst.c b/src/cst.c index 65039a2..51d4d68 100644 --- a/src/cst.c +++ b/src/cst.c @@ -30,24 +30,23 @@ // Copyright © 2011-2019 Natalia Portillo // ****************************************************************************/ -#include -#include #include +#include +#include #include int32_t 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; - size_t rStart; - size_t sStart; - size_t tStart; - size_t uStart; - size_t vStart; - size_t wStart; + size_t qStart; + size_t rStart; + size_t sStart; + size_t tStart; + size_t uStart; + size_t vStart; + size_t wStart; - if(interleaved == NULL || sequential == NULL) - return DICF_ERROR_BUFFER_TOO_SMALL; + if(interleaved == NULL || sequential == NULL) return DICF_ERROR_BUFFER_TOO_SMALL; p = malloc(length / 8); q = malloc(length / 8); @@ -172,16 +171,15 @@ int32_t cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t le int32_t 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; - size_t rStart; - size_t sStart; - size_t tStart; - size_t uStart; - size_t vStart; - size_t wStart; + size_t qStart; + size_t rStart; + size_t sStart; + size_t tStart; + size_t uStart; + size_t vStart; + size_t wStart; - if(interleaved == NULL || sequential == NULL) - return DICF_ERROR_BUFFER_TOO_SMALL; + if(interleaved == NULL || sequential == NULL) return DICF_ERROR_BUFFER_TOO_SMALL; p = malloc(length / 8); q = malloc(length / 8); diff --git a/src/ecc_cd.c b/src/ecc_cd.c index 1622d19..64dade0 100644 --- a/src/ecc_cd.c +++ b/src/ecc_cd.c @@ -31,21 +31,20 @@ // ECC algorithm from ECM(c) 2002-2011 Neill Corlett // ****************************************************************************/ -#include -#include -#include -#include #include +#include +#include +#include +#include void *ecc_cd_init() { CdEccContext *context; - uint32_t edc, i, j; + uint32_t edc, i, j; context = (CdEccContext *)malloc(sizeof(CdEccContext)); - if(context == NULL) - return NULL; + if(context == NULL) return NULL; context->eccFTable = (uint8_t *)malloc(sizeof(uint8_t) * 256); @@ -75,12 +74,11 @@ void *ecc_cd_init() for(i = 0; i < 256; i++) { - edc = i; - j = (uint32_t)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); + edc = i; + j = (uint32_t)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); context->eccFTable[i] = (uint8_t)j; context->eccBTable[i ^ j] = (uint8_t)i; - for(j = 0; j < 8; j++) - edc = (edc >> 1) ^ ((edc & 1) > 0 ? 0xD8018001 : 0); + for(j = 0; j < 8; j++) edc = (edc >> 1) ^ ((edc & 1) > 0 ? 0xD8018001 : 0); context->edcTable[i] = edc; } @@ -92,42 +90,32 @@ void *ecc_cd_init() bool ecc_cd_is_suffix_correct(void *context, const uint8_t *sector) { CdEccContext *ctx; - uint32_t storedEdc, edc, calculatedEdc; - int size, pos; + uint32_t storedEdc, edc, calculatedEdc; + int size, pos; - if(context == NULL || sector == NULL) - return false; + if(context == NULL || sector == NULL) return false; ctx = (CdEccContext *)context; - if(!ctx->initedEdc) - return false; + if(!ctx->initedEdc) return false; 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) + sector[0x815] != 0x00 || sector[0x816] != 0x00 || sector[0x817] != 0x00 || sector[0x818] != 0x00 || + sector[0x819] != 0x00 || sector[0x81A] != 0x00 || sector[0x81B] != 0x00) return false; bool correctEccP = ecc_cd_check(context, sector, sector, 86, 24, 2, 86, sector, 0xC, 0x10, 0x81C); - if(!correctEccP) - return false; + if(!correctEccP) return false; - bool correctEccQ = ecc_cd_check(context, sector, sector, 52, 43, 86, 88, sector, 0xC, 0x10, 0x81C + 0xAC); - if(!correctEccQ) - return false; + bool correctEccQ = ecc_cd_check(context, sector, sector, 52, 43, 86, 88, sector, 0xC, 0x10, 0x81C + 0xAC); + if(!correctEccQ) return false; - storedEdc = sector[0x810]; // TODO: Check casting - edc = 0; - size = 0x810; - pos = 0; - for(; size > 0; size--) - edc = (edc >> 8) ^ ctx->edcTable[(edc ^ sector[pos++]) & 0xFF]; + storedEdc = sector[0x810]; // TODO: Check casting + edc = 0; + size = 0x810; + pos = 0; + for(; size > 0; size--) edc = (edc >> 8) ^ ctx->edcTable[(edc ^ sector[pos++]) & 0xFF]; calculatedEdc = edc; return calculatedEdc == storedEdc; @@ -136,115 +124,102 @@ bool ecc_cd_is_suffix_correct(void *context, const uint8_t *sector) bool ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector) { CdEccContext *ctx; - uint32_t storedEdc, edc, calculatedEdc; - int size, pos; - uint8_t zeroaddress[4]; + uint32_t storedEdc, edc, calculatedEdc; + int size, pos; + uint8_t zeroaddress[4]; - if(context == NULL || sector == NULL) - return false; + if(context == NULL || sector == NULL) return false; ctx = (CdEccContext *)context; - if(!ctx->initedEdc) - return false; + if(!ctx->initedEdc) return false; memset(&zeroaddress, 4, sizeof(uint8_t)); bool correctEccP = ecc_cd_check(context, zeroaddress, sector, 86, 24, 2, 86, sector, 0, 0x10, 0x81C); - if(!correctEccP) - return false; + if(!correctEccP) return false; - bool - correctEccQ = - ecc_cd_check(context, zeroaddress, sector, 52, 43, 86, 88, sector, 0, 0x10, 0x81C + 0xAC); - if(!correctEccQ) - return false; + bool correctEccQ = ecc_cd_check(context, zeroaddress, sector, 52, 43, 86, 88, sector, 0, 0x10, 0x81C + 0xAC); + if(!correctEccQ) return false; - storedEdc = sector[0x818]; // TODO: Check cast - edc = 0; - size = 0x808; - pos = 0x10; - for(; size > 0; size--) - edc = (edc >> 8) ^ ctx->edcTable[(edc ^ sector[pos++]) & 0xFF]; + storedEdc = sector[0x818]; // TODO: Check cast + edc = 0; + size = 0x808; + pos = 0x10; + for(; size > 0; size--) edc = (edc >> 8) ^ ctx->edcTable[(edc ^ sector[pos++]) & 0xFF]; calculatedEdc = edc; return calculatedEdc == storedEdc; } -bool ecc_cd_check(void *context, +bool 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, + 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) + int32_t addressOffset, + int32_t dataOffset, + int32_t eccOffset) { CdEccContext *ctx; - uint32_t size, major, idx, minor; - uint8_t eccA, eccB, temp; + uint32_t size, major, idx, minor; + uint8_t eccA, eccB, temp; - if(context == NULL || address == NULL || data == NULL || ecc == NULL) - return false; + if(context == NULL || address == NULL || data == NULL || ecc == NULL) return false; ctx = (CdEccContext *)context; - if(!ctx->initedEdc) - return false; + if(!ctx->initedEdc) return false; - size = majorCount * minorCount; + size = majorCount * minorCount; for(major = 0; major < majorCount; major++) { - idx = (major >> 1) * majorMult + (major & 1); - eccA = 0; - eccB = 0; + idx = (major >> 1) * majorMult + (major & 1); + eccA = 0; + eccB = 0; for(minor = 0; minor < minorCount; minor++) { temp = idx < 4 ? address[idx + addressOffset] : data[idx + dataOffset - 4]; idx += minorInc; - if(idx >= size) - idx -= size; + if(idx >= size) idx -= size; eccA ^= temp; eccB ^= temp; eccA = ctx->eccFTable[eccA]; } eccA = ctx->eccBTable[ctx->eccFTable[eccA] ^ eccB]; - if(ecc[major + eccOffset] != eccA || ecc[major + majorCount + eccOffset] != (eccA ^ eccB)) - return false; + if(ecc[major + eccOffset] != eccA || ecc[major + majorCount + eccOffset] != (eccA ^ eccB)) return false; } return true; } -void ecc_cd_write(void *context, +void 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) + 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; - uint32_t size, major, idx, minor; - uint8_t eccA, eccB, temp; + uint32_t size, major, idx, minor; + uint8_t eccA, eccB, temp; - if(context == NULL || address == NULL || data == NULL || ecc == NULL) - return; + if(context == NULL || address == NULL || data == NULL || ecc == NULL) return; ctx = (CdEccContext *)context; - if(!ctx->initedEdc) - return; + if(!ctx->initedEdc) return; - size = majorCount * minorCount; + size = majorCount * minorCount; for(major = 0; major < majorCount; major++) { idx = (major >> 1) * majorMult + (major & 1); @@ -255,28 +230,27 @@ void ecc_cd_write(void *context, { temp = idx < 4 ? address[idx + addressOffset] : data[idx + dataOffset - 4]; idx += minorInc; - if(idx >= size) - idx -= size; + if(idx >= size) idx -= size; eccA ^= temp; eccB ^= temp; eccA = ctx->eccFTable[eccA]; } - eccA = ctx->eccBTable[ctx->eccFTable[eccA] ^ eccB]; + eccA = ctx->eccBTable[ctx->eccFTable[eccA] ^ eccB]; ecc[major + eccOffset] = eccA; ecc[major + majorCount + eccOffset] = (eccA ^ eccB); } } -void ecc_cd_write_sector(void *context, +void 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) + uint8_t * ecc, + int32_t addressOffset, + int32_t dataOffset, + int32_t eccOffset) { - ecc_cd_write(context, address, data, 86, 24, 2, 86, ecc, addressOffset, dataOffset, eccOffset); // P + ecc_cd_write(context, address, data, 86, 24, 2, 86, ecc, addressOffset, dataOffset, eccOffset); // P ecc_cd_write(context, address, data, 52, 43, 86, 88, ecc, addressOffset, dataOffset, eccOffset + 0xAC); // Q } @@ -287,14 +261,13 @@ void cd_lba_to_msf(int64_t pos, uint8_t *minute, uint8_t *second, uint8_t *frame *frame = (uint8_t)((pos + 150) % 75); } - void ecc_cd_reconstruct_prefix(uint8_t *sector, // must point to a full 2352-byte sector - uint8_t type, int64_t lba) + uint8_t type, + int64_t lba) { uint8_t minute, second, frame; - if(sector == NULL) - return; + if(sector == NULL) return; // // Sync @@ -345,34 +318,36 @@ void ecc_cd_reconstruct_prefix(uint8_t *sector, // must point to a full 2352-byt } } -void ecc_cd_reconstruct(void *context, uint8_t *sector, // must point to a full 2352-byte sector - uint8_t type) +void 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; - if(context == NULL || sector == NULL) - return; + if(context == NULL || sector == NULL) return; ctx = (CdEccContext *)context; - if(!ctx->initedEdc) - return; + if(!ctx->initedEdc) return; switch(type) { // // Compute EDC // - case CdMode1:computedEdc = edc_cd_compute(context, 0, sector, 0x810, 0); + case CdMode1: + computedEdc = edc_cd_compute(context, 0, sector, 0x810, 0); memcpy(sector + 0x810, &computedEdc, 4); break; - case CdMode2Form1:computedEdc = edc_cd_compute(context, 0, sector, 0x808, 0x10); + case CdMode2Form1: + computedEdc = edc_cd_compute(context, 0, sector, 0x808, 0x10); memcpy(sector + 0x818, &computedEdc, 4); break; - case CdMode2Form2:computedEdc = edc_cd_compute(context, 0, sector, 0x91C, 0x10); + case CdMode2Form2: + computedEdc = edc_cd_compute(context, 0, sector, 0x91C, 0x10); memcpy(sector + 0x92C, &computedEdc, 4); break; default: return; @@ -399,8 +374,7 @@ void ecc_cd_reconstruct(void *context, uint8_t *sector, // must point to a full sector[0x81B] = 0x00; ecc_cd_write_sector(context, sector, sector, sector, 0xC, 0x10, 0x81C); break; - case CdMode2Form1:ecc_cd_write_sector(context, zeroaddress, sector, sector, 0, 0x10, 0x81C); - break; + case CdMode2Form1: ecc_cd_write_sector(context, zeroaddress, sector, sector, 0, 0x10, 0x81C); break; default: return; } @@ -413,16 +387,13 @@ uint32_t edc_cd_compute(void *context, uint32_t edc, const uint8_t *src, int siz { CdEccContext *ctx; - if(context == NULL || src == NULL) - return 0; + if(context == NULL || src == NULL) return 0; ctx = (CdEccContext *)context; - if(!ctx->initedEdc) - return 0; + if(!ctx->initedEdc) return 0; - for(; size > 0; size--) - edc = (edc >> 8) ^ ctx->edcTable[(edc ^ src[pos++]) & 0xFF]; + for(; size > 0; size--) edc = (edc >> 8) ^ ctx->edcTable[(edc ^ src[pos++]) & 0xFF]; return edc; } diff --git a/src/identify.c b/src/identify.c index 3002f1f..bba0051 100644 --- a/src/identify.c +++ b/src/identify.c @@ -30,9 +30,9 @@ // Copyright © 2011-2019 Natalia Portillo // ****************************************************************************/ +#include #include #include -#include //! Identifies a file as dicformat, using path /*! @@ -47,8 +47,7 @@ int identify(const char *filename) stream = fopen(filename, "rb"); - if(stream == NULL) - return errno; + if(stream == NULL) return errno; int ret = identifyStream(stream); @@ -72,11 +71,9 @@ int identifyStream(FILE *imageStream) size_t ret = fread(&header, sizeof(DicHeader), 1, imageStream); - if(ret < sizeof(DicHeader)) - return 0; + if(ret < sizeof(DicHeader)) return 0; - if(header.identifier == DIC_MAGIC && header.imageMajorVersion <= DICF_VERSION) - return 100; + if(header.identifier == DIC_MAGIC && header.imageMajorVersion <= DICF_VERSION) return 100; return 0; } \ No newline at end of file diff --git a/src/open.c b/src/open.c index 184e79a..1d57e1d 100644 --- a/src/open.c +++ b/src/open.c @@ -30,32 +30,31 @@ // Copyright © 2011-2019 Natalia Portillo // ****************************************************************************/ -#include #include -#include #include #include +#include +#include #include #include void *open(const char *filepath) { dicformatContext *ctx; - int errorNo; - size_t readBytes; - long pos; - IndexHeader idxHeader; - IndexEntry *idxEntries; - uint8_t *data; - uint32_t *cdDdt; - uint64_t crc64; - uint8_t temp8u; + int errorNo; + size_t readBytes; + long pos; + IndexHeader idxHeader; + IndexEntry * idxEntries; + uint8_t * data; + uint32_t * cdDdt; + uint64_t crc64; + uint8_t temp8u; ctx = (dicformatContext *)malloc(sizeof(dicformatContext)); memset(ctx, 0, sizeof(dicformatContext)); - if(ctx == NULL) - return NULL; + if(ctx == NULL) return NULL; ctx->imageStream = fopen(filepath, "rb"); @@ -159,7 +158,8 @@ void *open(const char *filepath) return NULL; } - fprintf(stderr, "libdicformat: Index at %"PRIu64" contains %d entries", ctx->header.indexOffset, idxHeader.entries); + fprintf( + stderr, "libdicformat: Index at %" PRIu64 " contains %d entries", ctx->header.indexOffset, idxHeader.entries); idxEntries = (IndexEntry *)malloc(sizeof(IndexEntry) * idxHeader.entries); @@ -186,13 +186,14 @@ void *open(const char *filepath) for(int i = 0; i < idxHeader.entries; i++) { - fprintf(stderr, "libdicformat: Block type %4.4s with data type %4.4s is indexed to be at %"PRIu64"", + fprintf(stderr, + "libdicformat: Block type %4.4s with data type %4.4s is indexed to be at %" PRIu64 "", (char *)&idxEntries[i].blockType, (char *)&idxEntries[i].dataType, idxEntries[i].offset); } - bool foundUserDataDdt = false; + bool foundUserDataDdt = false; ctx->imageInfo.ImageSize = 0; for(int i = 0; i < idxHeader.entries; i++) { @@ -201,7 +202,7 @@ void *open(const char *filepath) if(pos < 0 || ftell(ctx->imageStream) != idxEntries[i].offset) { fprintf(stderr, - "libdicformat: Could not seek to %"PRIu64" as indicated by index entry %d, continuing...", + "libdicformat: Could not seek to %" PRIu64 " as indicated by index entry %d, continuing...", idxEntries[i].offset, i); @@ -215,14 +216,13 @@ void *open(const char *filepath) { case DataBlock: // NOP block, skip - if(idxEntries[i].dataType == NoData) - break; + if(idxEntries[i].dataType == NoData) break; readBytes = fread(&blockHeader, sizeof(BlockHeader), 1, ctx->imageStream); if(readBytes != sizeof(BlockHeader)) { - fprintf(stderr, "libdicformat: Could not read block header at %"PRIu64"", idxEntries[i].offset); + fprintf(stderr, "libdicformat: Could not read block header at %" PRIu64 "", idxEntries[i].offset); break; } @@ -241,7 +241,7 @@ void *open(const char *filepath) if(blockHeader.identifier != idxEntries[i].blockType) { fprintf(stderr, - "libdicformat: Incorrect identifier for data block at position %"PRIu64"", + "libdicformat: Incorrect identifier for data block at position %" PRIu64 "", idxEntries[i].offset); break; } @@ -249,14 +249,16 @@ void *open(const char *filepath) if(blockHeader.type != idxEntries[i].dataType) { fprintf(stderr, - "libdicformat: Expected block with data type %4.4s at position %"PRIu64" but found data type %4.4s", + "libdicformat: Expected block with data type %4.4s at position %" PRIu64 + " but found data type %4.4s", (char *)&idxEntries[i].blockType, idxEntries[i].offset, (char *)&blockHeader.type); break; } - fprintf(stderr, "libdicformat: Found data block with type %4.4s at position %"PRIu64"", + fprintf(stderr, + "libdicformat: Found data block with type %4.4s at position %" PRIu64 "", (char *)&idxEntries[i].blockType, idxEntries[i].offset); @@ -290,7 +292,8 @@ void *open(const char *filepath) if(crc64 != blockHeader.crc64) { fprintf(stderr, - "libdicformat: Incorrect CRC found: 0x%"PRIx64" found, expected 0x%"PRIx64", continuing...", + "libdicformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64 + ", continuing...", crc64, blockHeader.crc64); break; @@ -303,10 +306,7 @@ void *open(const char *filepath) { case CdSectorPrefix: case CdSectorPrefixCorrected: - if(idxEntries[i].dataType == CdSectorPrefixCorrected) - { - ctx->sectorPrefixCorrected = data; - } + if(idxEntries[i].dataType == CdSectorPrefixCorrected) { ctx->sectorPrefixCorrected = data; } else ctx->sectorPrefix = data; @@ -327,16 +327,17 @@ void *open(const char *filepath) ctx->readableSectorTags[CdSectorEccQ] = true; ctx->readableSectorTags[CdSectorEdc] = true; break; - case CdSectorSubchannel:ctx->sectorSubchannel = data; + case CdSectorSubchannel: + ctx->sectorSubchannel = data; ctx->readableSectorTags[CdSectorSubchannel] = true; break; case AppleProfileTag: case AppleSonyTag: - case PriamDataTowerTag:ctx->sectorSubchannel = data; + case PriamDataTowerTag: + ctx->sectorSubchannel = data; ctx->readableSectorTags[AppleSectorTag] = true; break; - case CompactDiscMode2Subheader:ctx->mode2Subheaders = data; - break; + case CompactDiscMode2Subheader: ctx->mode2Subheaders = data; break; default: if(ctx->mediaTagsHead != NULL) { @@ -359,8 +360,7 @@ void *open(const char *filepath) // If we mediaTag is NULL means we have arrived the end of the list without finding a duplicate // or the list was empty - if(mediaTag != NULL) - break; + if(mediaTag != NULL) break; mediaTag = (dataLinkedList *)malloc(sizeof(dataLinkedList)); @@ -375,10 +375,7 @@ void *open(const char *filepath) mediaTag->data = data; mediaTag->length = blockHeader.length; - if(ctx->mediaTagsHead == NULL) - { - ctx->mediaTagsHead = mediaTag; - } + if(ctx->mediaTagsHead == NULL) { ctx->mediaTagsHead = mediaTag; } else { mediaTag->previous = ctx->mediaTagsTail; @@ -391,11 +388,12 @@ void *open(const char *filepath) } break; - case DeDuplicationTable:readBytes = fread(&ddtHeader, sizeof(DdtHeader), 1, ctx->imageStream); + case DeDuplicationTable: + readBytes = fread(&ddtHeader, sizeof(DdtHeader), 1, ctx->imageStream); if(readBytes != sizeof(DdtHeader)) { - fprintf(stderr, "libdicformat: Could not read block header at %"PRIu64"", idxEntries[i].offset); + fprintf(stderr, "libdicformat: Could not read block header at %" PRIu64 "", idxEntries[i].offset); break; } @@ -412,14 +410,14 @@ void *open(const char *filepath) // Check for DDT compression switch(ddtHeader.compression) { - case None: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)); + case None: + 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)); if(ctx->userDataDdt == MAP_FAILED) { @@ -436,7 +434,6 @@ void *open(const char *filepath) blockHeader.compression); foundUserDataDdt = false; break; - } } else if(idxEntries[i].dataType == CdSectorPrefixCorrected || @@ -444,7 +441,8 @@ void *open(const char *filepath) { switch(ddtHeader.compression) { - case None:cdDdt = (uint32_t *)malloc(ddtHeader.entries * sizeof(uint32_t)); + case None: + cdDdt = (uint32_t *)malloc(ddtHeader.entries * sizeof(uint32_t)); if(mediaTag == NULL) { @@ -478,7 +476,8 @@ void *open(const char *filepath) } break; // Logical geometry block. It doesn't have a CRC coz, well, it's not so important - case GeometryBlock:readBytes = fread(&ctx->geometryBlock, sizeof(GeometryBlockHeader), 1, ctx->imageStream); + case GeometryBlock: + readBytes = fread(&ctx->geometryBlock, sizeof(GeometryBlockHeader), 1, ctx->imageStream); if(readBytes != sizeof(GeometryBlockHeader)) { @@ -504,11 +503,8 @@ void *open(const char *filepath) break; // Metadata block - case MetadataBlock: readBytes = - fread(&ctx->metadataBlockHeader, - sizeof(MetadataBlockHeader), - 1, - ctx->imageStream); + case MetadataBlock: + readBytes = fread(&ctx->metadataBlockHeader, sizeof(MetadataBlockHeader), 1, ctx->imageStream); if(readBytes != sizeof(MetadataBlockHeader)) { @@ -521,7 +517,7 @@ void *open(const char *filepath) { memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader)); fprintf(stderr, - "libdicformat: Incorrect identifier for data block at position %"PRIu64"", + "libdicformat: Incorrect identifier for data block at position %" PRIu64 "", idxEntries[i].offset); break; } @@ -558,7 +554,7 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.creatorLength > 0 && ctx->metadataBlockHeader.creatorOffset + ctx->metadataBlockHeader.creatorLength <= - ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.blockSize) { ctx->imageInfo.Creator = (uint8_t *)malloc(ctx->metadataBlockHeader.creatorLength); if(ctx->imageInfo.Creator != NULL) @@ -571,7 +567,7 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.commentsLength > 0 && ctx->metadataBlockHeader.commentsOffset + ctx->metadataBlockHeader.commentsLength <= - ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.blockSize) { ctx->imageInfo.Comments = (uint8_t *)malloc(ctx->metadataBlockHeader.commentsLength); if(ctx->imageInfo.Comments != NULL) @@ -584,7 +580,7 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.mediaTitleLength > 0 && ctx->metadataBlockHeader.mediaTitleOffset + ctx->metadataBlockHeader.mediaTitleLength <= - ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.blockSize) { ctx->imageInfo.MediaTitle = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaTitleLength); if(ctx->imageInfo.MediaTitle != NULL) @@ -597,10 +593,11 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.mediaManufacturerLength > 0 && ctx->metadataBlockHeader.mediaManufacturerOffset + - ctx->metadataBlockHeader.mediaManufacturerLength <= ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.mediaManufacturerLength <= + 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, @@ -611,7 +608,7 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.mediaModelLength > 0 && ctx->metadataBlockHeader.mediaModelOffset + ctx->metadataBlockHeader.mediaModelLength <= - ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.blockSize) { ctx->imageInfo.MediaModel = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaModelOffset); if(ctx->imageInfo.MediaModel != NULL) @@ -624,10 +621,11 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.mediaSerialNumberLength > 0 && ctx->metadataBlockHeader.mediaSerialNumberOffset + - ctx->metadataBlockHeader.mediaSerialNumberLength <= ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.mediaSerialNumberLength <= + 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, @@ -638,7 +636,7 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.mediaBarcodeLength > 0 && ctx->metadataBlockHeader.mediaBarcodeOffset + ctx->metadataBlockHeader.mediaBarcodeLength <= - ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.blockSize) { ctx->imageInfo.MediaBarcode = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaBarcodeLength); if(ctx->imageInfo.MediaBarcode != NULL) @@ -651,7 +649,7 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.mediaPartNumberLength > 0 && ctx->metadataBlockHeader.mediaPartNumberOffset + ctx->metadataBlockHeader.mediaPartNumberLength <= - ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.blockSize) { ctx->imageInfo.MediaPartNumber = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaPartNumberLength); if(ctx->imageInfo.MediaPartNumber != NULL) @@ -664,10 +662,11 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.driveManufacturerLength > 0 && ctx->metadataBlockHeader.driveManufacturerOffset + - ctx->metadataBlockHeader.driveManufacturerLength <= ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.driveManufacturerLength <= + 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, @@ -678,7 +677,7 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.driveModelLength > 0 && ctx->metadataBlockHeader.driveModelOffset + ctx->metadataBlockHeader.driveModelLength <= - ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.blockSize) { ctx->imageInfo.DriveModel = (uint8_t *)malloc(ctx->metadataBlockHeader.driveModelLength); if(ctx->imageInfo.DriveModel != NULL) @@ -691,10 +690,11 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.driveSerialNumberLength > 0 && ctx->metadataBlockHeader.driveSerialNumberOffset + - ctx->metadataBlockHeader.driveSerialNumberLength <= ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.driveSerialNumberLength <= + 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, @@ -705,10 +705,11 @@ void *open(const char *filepath) if(ctx->metadataBlockHeader.driveManufacturerLength > 0 && ctx->metadataBlockHeader.driveFirmwareRevisionOffset + - ctx->metadataBlockHeader.driveManufacturerLength <= ctx->metadataBlockHeader.blockSize) + ctx->metadataBlockHeader.driveManufacturerLength <= + 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, @@ -718,7 +719,8 @@ void *open(const char *filepath) } break; - case TracksBlock: readBytes = fread(&ctx->tracksHeader, sizeof(TracksHeader), 1, ctx->imageStream); + case TracksBlock: + readBytes = fread(&ctx->tracksHeader, sizeof(TracksHeader), 1, ctx->imageStream); if(readBytes != sizeof(TracksHeader)) { @@ -731,7 +733,7 @@ void *open(const char *filepath) { memset(&ctx->tracksHeader, 0, sizeof(TracksHeader)); fprintf(stderr, - "libdicformat: Incorrect identifier for data block at position %"PRIu64"", + "libdicformat: Incorrect identifier for data block at position %" PRIu64 "", idxEntries[i].offset); } @@ -756,19 +758,19 @@ void *open(const char *filepath) } crc64 = - crc64_data_ecma((const uint8_t *)ctx->trackEntries, - ctx->tracksHeader.entries * sizeof(TrackEntry)); + crc64_data_ecma((const uint8_t *)ctx->trackEntries, ctx->tracksHeader.entries * sizeof(TrackEntry)); if(crc64 != ctx->tracksHeader.crc64) { fprintf(stderr, - "libdicformat: Incorrect CRC found: 0x%"PRIx64" found, expected 0x%"PRIx64", continuing...", + "libdicformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64 + ", continuing...", crc64, ctx->tracksHeader.crc64); break; } fprintf(stderr, - "libdicformat: Found %d tracks at position %"PRIu64".", + "libdicformat: Found %d tracks at position %" PRIu64 ".", ctx->tracksHeader.entries, idxEntries[i].offset); @@ -788,25 +790,23 @@ void *open(const char *filepath) { ctx->dataTracks = (TrackEntry *)malloc(sizeof(TrackEntry) * temp8u); - if(ctx->dataTracks == NULL) - break; + if(ctx->dataTracks == NULL) break; ctx->numberOfDataTracks = temp8u; for(i = 0, temp8u = 0; i < ctx->tracksHeader.entries; i++) { - if(ctx->trackEntries[i].sequence > 99) - continue; + if(ctx->trackEntries[i].sequence > 99) continue; - memcpy(&ctx->dataTracks[ctx->trackEntries[i].sequence], - &ctx->trackEntries[i], - sizeof(TrackEntry)); + memcpy( + &ctx->dataTracks[ctx->trackEntries[i].sequence], &ctx->trackEntries[i], sizeof(TrackEntry)); } } break; // CICM XML metadata block - case CicmBlock:readBytes = fread(&ctx->cicmBlockHeader, sizeof(CicmMetadataBlock), 1, ctx->imageStream); + case CicmBlock: + readBytes = fread(&ctx->cicmBlockHeader, sizeof(CicmMetadataBlock), 1, ctx->imageStream); if(readBytes != sizeof(CicmMetadataBlock)) { @@ -819,7 +819,7 @@ void *open(const char *filepath) { memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock)); fprintf(stderr, - "libdicformat: Incorrect identifier for data block at position %"PRIu64"", + "libdicformat: Incorrect identifier for data block at position %" PRIu64 "", idxEntries[i].offset); } @@ -844,14 +844,11 @@ void *open(const char *filepath) fprintf(stderr, "libdicformat: Could not read CICM XML metadata block, continuing..."); } - fprintf(stderr, "libdicformat: Found CICM XML metadata block %"PRIu64".", idxEntries[i].offset); + fprintf(stderr, "libdicformat: Found CICM XML metadata block %" PRIu64 ".", idxEntries[i].offset); break; // Dump hardware block - case DumpHardwareBlock: readBytes = - fread(&ctx->dumpHardwareHeader, - sizeof(DumpHardwareHeader), - 1, - ctx->imageStream); + case DumpHardwareBlock: + readBytes = fread(&ctx->dumpHardwareHeader, sizeof(DumpHardwareHeader), 1, ctx->imageStream); if(readBytes != sizeof(DumpHardwareHeader)) { @@ -864,7 +861,7 @@ void *open(const char *filepath) { memset(&ctx->dumpHardwareHeader, 0, sizeof(DumpHardwareHeader)); fprintf(stderr, - "libdicformat: Incorrect identifier for data block at position %"PRIu64"", + "libdicformat: Incorrect identifier for data block at position %" PRIu64 "", idxEntries[i].offset); } @@ -880,7 +877,8 @@ void *open(const char *filepath) { free(data); fprintf(stderr, - "libdicformat: Incorrect CRC found: 0x%"PRIx64" found, expected 0x%"PRIx64", continuing...", + "libdicformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64 + ", continuing...", crc64, ctx->dumpHardwareHeader.crc64); break; @@ -891,9 +889,8 @@ void *open(const char *filepath) fseek(ctx->imageStream, -readBytes, SEEK_CUR); } - ctx->dumpHardwareEntriesWithData = - (DumpHardwareEntriesWithData *)malloc(sizeof(DumpHardwareEntriesWithData) * - ctx->dumpHardwareHeader.entries); + ctx->dumpHardwareEntriesWithData = (DumpHardwareEntriesWithData *)malloc( + sizeof(DumpHardwareEntriesWithData) * ctx->dumpHardwareHeader.entries); if(ctx->dumpHardwareEntriesWithData == NULL) { @@ -908,11 +905,8 @@ void *open(const char *filepath) for(uint16_t e = 0; e < ctx->dumpHardwareHeader.entries; e++) { - readBytes = - fread(&ctx->dumpHardwareEntriesWithData[e].entry, - sizeof(DumpHardwareEntry), - 1, - ctx->imageStream); + readBytes = fread( + &ctx->dumpHardwareEntriesWithData[e].entry, sizeof(DumpHardwareEntry), 1, ctx->imageStream); if(readBytes != sizeof(DumpHardwareEntry)) { @@ -924,22 +918,22 @@ void *open(const char *filepath) if(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength > 0) { ctx->dumpHardwareEntriesWithData[e].manufacturer = - (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength); + (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength); if(ctx->dumpHardwareEntriesWithData[e].manufacturer != NULL) { - readBytes = - fread(&ctx->dumpHardwareEntriesWithData[e].manufacturer, - ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength, - 1, - ctx->imageStream); + readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].manufacturer, + ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength, + 1, + ctx->imageStream); if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength) { free(ctx->dumpHardwareEntriesWithData[e].manufacturer); ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength = 0; fprintf(stderr, - "libdicformat: Could not read dump hardware block entry manufacturer, continuing..."); + "libdicformat: Could not read dump hardware block entry manufacturer, " + "continuing..."); } } } @@ -947,15 +941,14 @@ void *open(const char *filepath) if(ctx->dumpHardwareEntriesWithData[e].entry.modelLength > 0) { ctx->dumpHardwareEntriesWithData[e].model = - (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.modelLength); + (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.modelLength); if(ctx->dumpHardwareEntriesWithData[e].model != NULL) { - readBytes = - fread(&ctx->dumpHardwareEntriesWithData[e].model, - ctx->dumpHardwareEntriesWithData[e].entry.modelLength, - 1, - ctx->imageStream); + readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].model, + ctx->dumpHardwareEntriesWithData[e].entry.modelLength, + 1, + ctx->imageStream); if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.modelLength) { @@ -970,22 +963,22 @@ void *open(const char *filepath) if(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength > 0) { ctx->dumpHardwareEntriesWithData[e].revision = - (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength); + (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength); if(ctx->dumpHardwareEntriesWithData[e].revision != NULL) { - readBytes = - fread(&ctx->dumpHardwareEntriesWithData[e].revision, - ctx->dumpHardwareEntriesWithData[e].entry.revisionLength, - 1, - ctx->imageStream); + readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].revision, + ctx->dumpHardwareEntriesWithData[e].entry.revisionLength, + 1, + ctx->imageStream); if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.revisionLength) { free(ctx->dumpHardwareEntriesWithData[e].revision); ctx->dumpHardwareEntriesWithData[e].entry.revisionLength = 0; - fprintf(stderr, - "libdicformat: Could not read dump hardware block entry revision, continuing..."); + fprintf( + stderr, + "libdicformat: Could not read dump hardware block entry revision, continuing..."); } } } @@ -993,22 +986,22 @@ void *open(const char *filepath) if(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength > 0) { ctx->dumpHardwareEntriesWithData[e].firmware = - (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength); + (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength); if(ctx->dumpHardwareEntriesWithData[e].firmware != NULL) { - readBytes = - fread(&ctx->dumpHardwareEntriesWithData[e].firmware, - ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength, - 1, - ctx->imageStream); + readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].firmware, + ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength, + 1, + ctx->imageStream); if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength) { free(ctx->dumpHardwareEntriesWithData[e].firmware); ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength = 0; - fprintf(stderr, - "libdicformat: Could not read dump hardware block entry firmware, continuing..."); + fprintf( + stderr, + "libdicformat: Could not read dump hardware block entry firmware, continuing..."); } } } @@ -1016,15 +1009,14 @@ void *open(const char *filepath) if(ctx->dumpHardwareEntriesWithData[e].entry.serialLength > 0) { ctx->dumpHardwareEntriesWithData[e].serial = - (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.serialLength); + (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.serialLength); if(ctx->dumpHardwareEntriesWithData[e].serial != NULL) { - readBytes = - fread(&ctx->dumpHardwareEntriesWithData[e].serial, - ctx->dumpHardwareEntriesWithData[e].entry.serialLength, - 1, - ctx->imageStream); + readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].serial, + ctx->dumpHardwareEntriesWithData[e].entry.serialLength, + 1, + ctx->imageStream); if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.serialLength) { @@ -1039,22 +1031,22 @@ void *open(const char *filepath) if(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength > 0) { ctx->dumpHardwareEntriesWithData[e].softwareName = - (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength); + (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength); if(ctx->dumpHardwareEntriesWithData[e].softwareName != NULL) { - readBytes = - fread(&ctx->dumpHardwareEntriesWithData[e].softwareName, - ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength, - 1, - ctx->imageStream); + readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].softwareName, + ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength, + 1, + ctx->imageStream); if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength) { free(ctx->dumpHardwareEntriesWithData[e].softwareName); ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength = 0; fprintf(stderr, - "libdicformat: Could not read dump hardware block entry software name, continuing..."); + "libdicformat: Could not read dump hardware block entry software name, " + "continuing..."); } } } @@ -1062,22 +1054,22 @@ void *open(const char *filepath) if(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength > 0) { ctx->dumpHardwareEntriesWithData[e].softwareVersion = - (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength); + (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength); if(ctx->dumpHardwareEntriesWithData[e].softwareVersion != NULL) { - readBytes = - fread(&ctx->dumpHardwareEntriesWithData[e].softwareVersion, - ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength, - 1, - ctx->imageStream); + readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].softwareVersion, + ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength, + 1, + ctx->imageStream); if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength) { free(ctx->dumpHardwareEntriesWithData[e].softwareVersion); ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength = 0; fprintf(stderr, - "libdicformat: Could not read dump hardware block entry software version, continuing..."); + "libdicformat: Could not read dump hardware block entry software version, " + "continuing..."); } } } @@ -1085,42 +1077,41 @@ void *open(const char *filepath) if(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength > 0) { ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem = - (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry - .softwareOperatingSystemLength); + (uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength); if(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem != NULL) { - readBytes = - fread(&ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem, - ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength, - 1, - ctx->imageStream); + readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem, + ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength, + 1, + ctx->imageStream); if(readBytes != ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength) { free(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem); ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength = 0; fprintf(stderr, - "libdicformat: Could not read dump hardware block entry manufacturer, continuing..."); + "libdicformat: Could not read dump hardware block entry manufacturer, " + "continuing..."); } } } 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, - "libdicformat: Could not allocate memory for dump hardware block extents, continuing..."); + fprintf( + stderr, + "libdicformat: Could not allocate memory for dump hardware block extents, continuing..."); 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 != sizeof(DumpExtent) * ctx->dumpHardwareEntriesWithData->entry.extents) { @@ -1135,7 +1126,7 @@ void *open(const char *filepath) break; default: fprintf(stderr, - "libdicformat: Unhandled block type %4.4s with data type %4.4s is indexed to be at %"PRIu64"", + "libdicformat: Unhandled block type %4.4s with data type %4.4s is indexed to be at %" PRIu64 "", (char *)&idxEntries[i].blockType, (char *)&idxEntries[i].dataType, idxEntries[i].offset); @@ -1156,7 +1147,7 @@ void *open(const char *filepath) ctx->imageInfo.LastModificationTime = ctx->header.lastWrittenTime; ctx->imageInfo.XmlMediaType = GetXmlMediaType(ctx->header.mediaType); - if(ctx->geometryBlock.identifier != GeometryBlock/* && ctx->imageInfo.XmlMediaType == XmlMediaType.BlockMedia*/) + if(ctx->geometryBlock.identifier != GeometryBlock && ctx->imageInfo.XmlMediaType == BlockMedia) { ctx->imageInfo.Cylinders = (uint32_t)(ctx->imageInfo.Sectors / 16 / 63); ctx->imageInfo.Heads = 16; diff --git a/src/read.c b/src/read.c index 02bb112..6e0f9c1 100644 --- a/src/read.c +++ b/src/read.c @@ -37,16 +37,14 @@ int32_t read_media_tag(void *context, uint8_t *data, int32_t tag, uint32_t *length) { dicformatContext *ctx; - dataLinkedList *item; + dataLinkedList * item; - if(context == NULL) - return DICF_ERROR_NOT_DICFORMAT; + if(context == NULL) return DICF_ERROR_NOT_DICFORMAT; ctx = context; // Not a libdicformat context - if(ctx->magic != DIC_MAGIC) - return DICF_ERROR_NOT_DICFORMAT; + if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT; item = ctx->mediaTagsHead; @@ -74,25 +72,22 @@ int32_t read_media_tag(void *context, uint8_t *data, int32_t tag, uint32_t *leng int32_t read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32_t *length) { dicformatContext *ctx; - uint64_t ddtEntry; - uint32_t offsetMask; - uint64_t offset; - uint64_t blockOffset; - BlockHeader blockHeader; - uint8_t *block; - size_t readBytes; + uint64_t ddtEntry; + uint32_t offsetMask; + uint64_t offset; + uint64_t blockOffset; + BlockHeader blockHeader; + uint8_t * block; + size_t readBytes; - if(context == NULL) - return DICF_ERROR_NOT_DICFORMAT; + if(context == NULL) return DICF_ERROR_NOT_DICFORMAT; ctx = context; // Not a libdicformat context - if(ctx->magic != DIC_MAGIC) - return DICF_ERROR_NOT_DICFORMAT; + if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT; - if(sectorAddress > ctx->imageInfo.Sectors - 1) - return DICF_ERROR_SECTOR_OUT_OF_BOUNDS; + if(sectorAddress > ctx->imageInfo.Sectors - 1) return DICF_ERROR_SECTOR_OUT_OF_BOUNDS; ddtEntry = ctx->userDataDdt[sectorAddress]; offsetMask = (uint32_t)((1 << ctx->shift) - 1); @@ -114,8 +109,7 @@ int32_t read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32 fseek(ctx->imageStream, blockOffset, SEEK_SET); readBytes = fread(&blockHeader, sizeof(BlockHeader), 1, ctx->imageStream); - if(readBytes != sizeof(BlockHeader)) - return DICF_ERROR_CANNOT_READ_HEADER; + if(readBytes != sizeof(BlockHeader)) return DICF_ERROR_CANNOT_READ_HEADER; if(data == NULL || *length < blockHeader.sectorSize) { @@ -126,9 +120,9 @@ int32_t read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32 // Decompress block switch(blockHeader.compression) { - case None:block = (uint8_t *)malloc(blockHeader.length); - if(block == NULL) - return DICF_ERROR_NOT_ENOUGH_MEMORY; + case None: + block = (uint8_t *)malloc(blockHeader.length); + if(block == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY; readBytes = fread(block, blockHeader.length, 1, ctx->imageStream); @@ -139,7 +133,7 @@ int32_t read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32 } break; - default:return DICF_ERROR_UNSUPPORTED_COMPRESSION; + default: return DICF_ERROR_UNSUPPORTED_COMPRESSION; } // Check if cache needs to be emptied @@ -157,26 +151,21 @@ int32_t read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32 int32_t read_track_sector(void *context, uint8_t *data, uint64_t sectorAddress, uint32_t *length, uint8_t track) { dicformatContext *ctx; - int i; + int i; - if(context == NULL) - return DICF_ERROR_NOT_DICFORMAT; + if(context == NULL) return DICF_ERROR_NOT_DICFORMAT; ctx = context; // Not a libdicformat context - if(ctx->magic != DIC_MAGIC) - return DICF_ERROR_NOT_DICFORMAT; + if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT; - if(ctx->imageInfo.XmlMediaType != OpticalDisc) - return DICF_ERROR_INCORRECT_MEDIA_TYPE; + if(ctx->imageInfo.XmlMediaType != OpticalDisc) return DICF_ERROR_INCORRECT_MEDIA_TYPE; for(i = 0; i < ctx->numberOfDataTracks; i++) { if(ctx->dataTracks[i].sequence == track) - { - return read_sector(context, ctx->dataTracks[i].start + sectorAddress, data, length); - } + { return read_sector(context, ctx->dataTracks[i].start + sectorAddress, data, length); } } return DICF_ERROR_TRACK_NOT_FOUND; @@ -185,22 +174,20 @@ int32_t read_track_sector(void *context, uint8_t *data, uint64_t sectorAddress, int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, uint32_t *length) { dicformatContext *ctx; - uint32_t bareLength; - uint32_t tagLength; - uint8_t *bareData; - int32_t res; - TrackEntry trk; - int i; - bool trkFound; + uint32_t bareLength; + uint32_t tagLength; + uint8_t * bareData; + int32_t res; + TrackEntry trk; + int i; + bool trkFound; - if(context == NULL) - return DICF_ERROR_NOT_DICFORMAT; + if(context == NULL) return DICF_ERROR_NOT_DICFORMAT; ctx = context; // Not a libdicformat context - if(ctx->magic != DIC_MAGIC) - return DICF_ERROR_NOT_DICFORMAT; + if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT; switch(ctx->imageInfo.XmlMediaType) { @@ -219,13 +206,11 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u bareData = (uint8_t *)malloc(bareLength); - if(bareData == NULL) - return DICF_ERROR_NOT_ENOUGH_MEMORY; + if(bareData == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY; res = read_sector(context, sectorAddress, bareData, &bareLength); - if(res < DICF_STATUS_OK) - return res; + if(res < DICF_STATUS_OK) return res; trkFound = false; @@ -239,15 +224,14 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u } } - if(!trkFound) - return DICF_ERROR_TRACK_NOT_FOUND; + if(!trkFound) return DICF_ERROR_TRACK_NOT_FOUND; switch(trk.type) { case Audio: - case Data:memcpy(bareData, data, bareLength); - return res; - case CdMode1:memcpy(bareData, data + 16, 2048); + case Data: memcpy(bareData, data, bareLength); return res; + case CdMode1: + memcpy(bareData, data + 16, 2048); if(ctx->sectorPrefix != NULL) memcpy(data, ctx->sectorPrefix + (sectorAddress * 16), 16); @@ -266,7 +250,7 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u { memcpy(data, ctx->sectorPrefixCorrected + - ((ctx->sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16, + ((ctx->sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16, 16); } } @@ -279,7 +263,6 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u { if((ctx->sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == Correct) { - ecc_cd_reconstruct(ctx->eccCdContext, data, trk.type); res = DICF_STATUS_OK; } @@ -291,7 +274,7 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u { memcpy(data + 2064, ctx->sectorSuffixCorrected + - ((ctx->sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288, + ((ctx->sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288, 288); } } @@ -319,7 +302,7 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u { memcpy(data, ctx->sectorPrefixCorrected + - ((ctx->sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16, + ((ctx->sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16, 16); } } @@ -352,7 +335,7 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u memcpy(data + 16, bareData, 2336); return res; - default:return DICF_ERROR_INVALID_TRACK_FORMAT; + default: return DICF_ERROR_INVALID_TRACK_FORMAT; } case BlockMedia: switch(ctx->imageInfo.MediaType) @@ -363,21 +346,17 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u case AppleSonyDS: case AppleWidget: case PriamDataTower: - if(ctx->sectorSubchannel == NULL) - return read_sector(context, sectorAddress, data, length); + if(ctx->sectorSubchannel == NULL) return read_sector(context, sectorAddress, data, length); switch(ctx->imageInfo.MediaType) { 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 DICF_ERROR_INCORRECT_MEDIA_TYPE; + case AppleSonyDS: tagLength = 12; break; + case PriamDataTower: tagLength = 24; break; + default: return DICF_ERROR_INCORRECT_MEDIA_TYPE; } bareLength = 512; @@ -390,13 +369,11 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u bareData = malloc(bareLength); - if(bareData == NULL) - return DICF_ERROR_NOT_ENOUGH_MEMORY; + if(bareData == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY; res = read_sector(context, sectorAddress, bareData, &bareLength); - if(bareLength != 512) - return res; + if(bareLength != 512) return res; memcpy(data, ctx->sectorSubchannel + sectorAddress * tagLength, tagLength); memcpy(data, bareData, 512); @@ -404,9 +381,8 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u free(bareData); return res; - default:return DICF_ERROR_INCORRECT_MEDIA_TYPE; - + default: return DICF_ERROR_INCORRECT_MEDIA_TYPE; } - default:return DICF_ERROR_INCORRECT_MEDIA_TYPE; + default: return DICF_ERROR_INCORRECT_MEDIA_TYPE; } } \ No newline at end of file