Commit 8999b926 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Do not hardcode Tag Identifier

parent 64dfc537
...@@ -531,7 +531,7 @@ static int UDFMapICB( dvd_reader_t *device, struct AD ICB, uint8_t *FileType, ...@@ -531,7 +531,7 @@ static int UDFMapICB( dvd_reader_t *device, struct AD ICB, uint8_t *FileType,
else else
UDFDescriptor( LogBlock, &TagID ); UDFDescriptor( LogBlock, &TagID );
if( TagID == 261 ) { if( TagID == FileEntry ) {
UDFFileEntry( LogBlock, FileType, partition, File ); UDFFileEntry( LogBlock, FileType, partition, File );
memcpy(&tmpmap.file, File, sizeof(tmpmap.file)); memcpy(&tmpmap.file, File, sizeof(tmpmap.file));
tmpmap.filetype = *FileType; tmpmap.filetype = *FileType;
...@@ -539,7 +539,7 @@ static int UDFMapICB( dvd_reader_t *device, struct AD ICB, uint8_t *FileType, ...@@ -539,7 +539,7 @@ static int UDFMapICB( dvd_reader_t *device, struct AD ICB, uint8_t *FileType,
return 1; return 1;
}; };
} while( ( lbnum <= partition->Start + ICB.Location + ( ICB.Length - 1 ) } while( ( lbnum <= partition->Start + ICB.Location + ( ICB.Length - 1 )
/ DVD_VIDEO_LB_LEN ) && ( TagID != 261 ) ); / DVD_VIDEO_LB_LEN ) && ( TagID != FileEntry ) );
return 0; return 0;
} }
...@@ -606,7 +606,7 @@ static int UDFScanDir( dvd_reader_t *device, struct AD Dir, char *FileName, ...@@ -606,7 +606,7 @@ static int UDFScanDir( dvd_reader_t *device, struct AD Dir, char *FileName,
while( p < Dir.Length ) { while( p < Dir.Length ) {
UDFDescriptor( &cached_dir[ p ], &TagID ); UDFDescriptor( &cached_dir[ p ], &TagID );
if( TagID == 257 ) { if( TagID == FileIdentifierDescriptor ) {
p += UDFFileIdentifier( &cached_dir[ p ], &filechar, p += UDFFileIdentifier( &cached_dir[ p ], &filechar,
filename, &tmpICB ); filename, &tmpICB );
if(cache_file_info && !in_cache) { if(cache_file_info && !in_cache) {
...@@ -651,7 +651,7 @@ static int UDFScanDir( dvd_reader_t *device, struct AD Dir, char *FileName, ...@@ -651,7 +651,7 @@ static int UDFScanDir( dvd_reader_t *device, struct AD Dir, char *FileName,
} }
} }
UDFDescriptor( &directory[ p ], &TagID ); UDFDescriptor( &directory[ p ], &TagID );
if( TagID == 257 ) { if( TagID == FileIdentifierDescriptor ) {
p += UDFFileIdentifier( &directory[ p ], &filechar, p += UDFFileIdentifier( &directory[ p ], &filechar,
filename, FileICB ); filename, FileICB );
if( !strcasecmp( FileName, filename ) ) { if( !strcasecmp( FileName, filename ) ) {
...@@ -690,7 +690,7 @@ static int UDFGetAVDP( dvd_reader_t *device, ...@@ -690,7 +690,7 @@ static int UDFGetAVDP( dvd_reader_t *device,
} else { } else {
TagID = 0; TagID = 0;
} }
if (TagID != 2) { if (TagID != AnchorVolumeDescriptorPointer) {
/* Not an anchor */ /* Not an anchor */
if( terminate ) return 0; /* Final try failed */ if( terminate ) return 0; /* Final try failed */
...@@ -764,12 +764,12 @@ static int UDFFindPartition( dvd_reader_t *device, int partnum, ...@@ -764,12 +764,12 @@ static int UDFFindPartition( dvd_reader_t *device, int partnum,
else else
UDFDescriptor( LogBlock, &TagID ); UDFDescriptor( LogBlock, &TagID );
if( ( TagID == 5 ) && ( !part->valid ) ) { if( ( TagID == PartitionDescriptor ) && ( !part->valid ) ) {
/* Partition Descriptor */ /* Partition Descriptor */
UDFPartition( LogBlock, &part->Flags, &part->Number, UDFPartition( LogBlock, &part->Flags, &part->Number,
part->Contents, &part->Start, &part->Length ); part->Contents, &part->Start, &part->Length );
part->valid = ( partnum == part->Number ); part->valid = ( partnum == part->Number );
} else if( ( TagID == 6 ) && ( !volvalid ) ) { } else if( ( TagID == LogicalVolumeDescriptor ) && ( !volvalid ) ) {
/* Logical Volume Descriptor */ /* Logical Volume Descriptor */
if( UDFLogVolume( LogBlock, part->VolumeDesc ) ) { if( UDFLogVolume( LogBlock, part->VolumeDesc ) ) {
/* TODO: sector size wrong! */ /* TODO: sector size wrong! */
...@@ -778,7 +778,7 @@ static int UDFFindPartition( dvd_reader_t *device, int partnum, ...@@ -778,7 +778,7 @@ static int UDFFindPartition( dvd_reader_t *device, int partnum,
} }
} while( ( lbnum <= MVDS_location + ( MVDS_length - 1 ) } while( ( lbnum <= MVDS_location + ( MVDS_length - 1 )
/ DVD_VIDEO_LB_LEN ) && ( TagID != 8 ) / DVD_VIDEO_LB_LEN ) && ( TagID != TerminatingDescriptor )
&& ( ( !part->valid ) || ( !volvalid ) ) ); && ( ( !part->valid ) || ( !volvalid ) ) );
if( ( !part->valid) || ( !volvalid ) ) { if( ( !part->valid) || ( !volvalid ) ) {
...@@ -825,13 +825,13 @@ uint32_t UDFFindFile( dvd_reader_t *device, char *filename, ...@@ -825,13 +825,13 @@ uint32_t UDFFindFile( dvd_reader_t *device, char *filename,
UDFDescriptor( LogBlock, &TagID ); UDFDescriptor( LogBlock, &TagID );
/* File Set Descriptor */ /* File Set Descriptor */
if( TagID == 256 ) /* File Set Descriptor */ if( TagID == FileSetDescriptor ) /* File Set Descriptor */
UDFLongAD( &LogBlock[ 400 ], &RootICB ); UDFLongAD( &LogBlock[ 400 ], &RootICB );
} while( ( lbnum < partition.Start + partition.Length ) } while( ( lbnum < partition.Start + partition.Length )
&& ( TagID != 8 ) && ( TagID != 256 ) ); && ( TagID != TerminatingDescriptor ) && ( TagID != FileSetDescriptor) );
/* Sanity checks. */ /* Sanity checks. */
if( TagID != 256 ) if( TagID != FileSetDescriptor )
return 0; return 0;
if( RootICB.Partition != 0 ) if( RootICB.Partition != 0 )
return 0; return 0;
...@@ -911,7 +911,7 @@ static int UDFGetDescriptor( dvd_reader_t *device, int id, ...@@ -911,7 +911,7 @@ static int UDFGetDescriptor( dvd_reader_t *device, int id,
/* Descriptor */ /* Descriptor */
desc_found = 1; desc_found = 1;
} while( ( lbnum <= MVDS_location + ( MVDS_length - 1 ) } while( ( lbnum <= MVDS_location + ( MVDS_length - 1 )
/ DVD_VIDEO_LB_LEN ) && ( TagID != 8 ) / DVD_VIDEO_LB_LEN ) && ( TagID != TerminatingDescriptor )
&& ( !desc_found) ); && ( !desc_found) );
if( !desc_found ) { if( !desc_found ) {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <sys/types.h> #include <sys/types.h>
#ifdef _WIN32 #ifdef _WIN32
#include <unistd.h> # include <unistd.h>
#endif /* _WIN32 */ #endif /* _WIN32 */
#include "dvdread/dvd_reader.h" #include "dvdread/dvd_reader.h"
...@@ -35,6 +35,31 @@ ...@@ -35,6 +35,31 @@
__FILE__, __LINE__, # arg ); \ __FILE__, __LINE__, # arg ); \
} }
enum TagIdentifier {
/* ECMA 167 3/7.2.1 */
PrimaryVolumeDescriptor = 1,
AnchorVolumeDescriptorPointer = 2,
VolumeDescriptorPointer = 3,
ImplementationUseVolumeDescriptor = 4,
PartitionDescriptor = 5,
LogicalVolumeDescriptor = 6,
UnallocatedSpaceDescriptor = 7,
TerminatingDescriptor = 8,
LogicalVolumeIntegrityDescriptor = 9,
/* ECMA 167 4/7.2.1 */
FileSetDescriptor = 256,
FileIdentifierDescriptor = 257,
AllocationExtentDescriptor = 258,
IndirectEntry = 259,
TerminalEntry = 260,
FileEntry = 261,
ExtendedAttributeHeaderDescriptor = 262,
UnallocatedSpaceEntry = 263,
SpaceBitmapDescriptor = 264,
PartitionIntegrityEntry = 265,
ExtendedFileEntry = 266,
};
int InternalUDFReadBlocksRaw(const dvd_reader_t *device, uint32_t lb_number, int InternalUDFReadBlocksRaw(const dvd_reader_t *device, uint32_t lb_number,
size_t block_count, unsigned char *data, int encrypted); size_t block_count, unsigned char *data, int encrypted);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment