[libdvdnav-devel] Do not hardcode Tag Identifier
Jean-Baptiste Kempf
git at videolan.org
Thu Jul 31 23:55:32 CEST 2014
libdvdread | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Jul 31 03:44:30 2014 +0200| [8999b92630c46435f96bbaad564a2aaf211b2ce9] | committer: Jean-Baptiste Kempf
Do not hardcode Tag Identifier
> http://git.videolan.org/gitweb.cgi/libdvdread.git/?a=commit;h=8999b92630c46435f96bbaad564a2aaf211b2ce9
---
src/dvd_udf.c | 24 ++++++++++++------------
src/dvdread_internal.h | 27 ++++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/src/dvd_udf.c b/src/dvd_udf.c
index 1f72e2c..7302b55 100644
--- a/src/dvd_udf.c
+++ b/src/dvd_udf.c
@@ -531,7 +531,7 @@ static int UDFMapICB( dvd_reader_t *device, struct AD ICB, uint8_t *FileType,
else
UDFDescriptor( LogBlock, &TagID );
- if( TagID == 261 ) {
+ if( TagID == FileEntry ) {
UDFFileEntry( LogBlock, FileType, partition, File );
memcpy(&tmpmap.file, File, sizeof(tmpmap.file));
tmpmap.filetype = *FileType;
@@ -539,7 +539,7 @@ static int UDFMapICB( dvd_reader_t *device, struct AD ICB, uint8_t *FileType,
return 1;
};
} while( ( lbnum <= partition->Start + ICB.Location + ( ICB.Length - 1 )
- / DVD_VIDEO_LB_LEN ) && ( TagID != 261 ) );
+ / DVD_VIDEO_LB_LEN ) && ( TagID != FileEntry ) );
return 0;
}
@@ -606,7 +606,7 @@ static int UDFScanDir( dvd_reader_t *device, struct AD Dir, char *FileName,
while( p < Dir.Length ) {
UDFDescriptor( &cached_dir[ p ], &TagID );
- if( TagID == 257 ) {
+ if( TagID == FileIdentifierDescriptor ) {
p += UDFFileIdentifier( &cached_dir[ p ], &filechar,
filename, &tmpICB );
if(cache_file_info && !in_cache) {
@@ -651,7 +651,7 @@ static int UDFScanDir( dvd_reader_t *device, struct AD Dir, char *FileName,
}
}
UDFDescriptor( &directory[ p ], &TagID );
- if( TagID == 257 ) {
+ if( TagID == FileIdentifierDescriptor ) {
p += UDFFileIdentifier( &directory[ p ], &filechar,
filename, FileICB );
if( !strcasecmp( FileName, filename ) ) {
@@ -690,7 +690,7 @@ static int UDFGetAVDP( dvd_reader_t *device,
} else {
TagID = 0;
}
- if (TagID != 2) {
+ if (TagID != AnchorVolumeDescriptorPointer) {
/* Not an anchor */
if( terminate ) return 0; /* Final try failed */
@@ -764,12 +764,12 @@ static int UDFFindPartition( dvd_reader_t *device, int partnum,
else
UDFDescriptor( LogBlock, &TagID );
- if( ( TagID == 5 ) && ( !part->valid ) ) {
+ if( ( TagID == PartitionDescriptor ) && ( !part->valid ) ) {
/* Partition Descriptor */
UDFPartition( LogBlock, &part->Flags, &part->Number,
part->Contents, &part->Start, &part->Length );
part->valid = ( partnum == part->Number );
- } else if( ( TagID == 6 ) && ( !volvalid ) ) {
+ } else if( ( TagID == LogicalVolumeDescriptor ) && ( !volvalid ) ) {
/* Logical Volume Descriptor */
if( UDFLogVolume( LogBlock, part->VolumeDesc ) ) {
/* TODO: sector size wrong! */
@@ -778,7 +778,7 @@ static int UDFFindPartition( dvd_reader_t *device, int partnum,
}
} while( ( lbnum <= MVDS_location + ( MVDS_length - 1 )
- / DVD_VIDEO_LB_LEN ) && ( TagID != 8 )
+ / DVD_VIDEO_LB_LEN ) && ( TagID != TerminatingDescriptor )
&& ( ( !part->valid ) || ( !volvalid ) ) );
if( ( !part->valid) || ( !volvalid ) ) {
@@ -825,13 +825,13 @@ uint32_t UDFFindFile( dvd_reader_t *device, char *filename,
UDFDescriptor( LogBlock, &TagID );
/* File Set Descriptor */
- if( TagID == 256 ) /* File Set Descriptor */
+ if( TagID == FileSetDescriptor ) /* File Set Descriptor */
UDFLongAD( &LogBlock[ 400 ], &RootICB );
} while( ( lbnum < partition.Start + partition.Length )
- && ( TagID != 8 ) && ( TagID != 256 ) );
+ && ( TagID != TerminatingDescriptor ) && ( TagID != FileSetDescriptor) );
/* Sanity checks. */
- if( TagID != 256 )
+ if( TagID != FileSetDescriptor )
return 0;
if( RootICB.Partition != 0 )
return 0;
@@ -911,7 +911,7 @@ static int UDFGetDescriptor( dvd_reader_t *device, int id,
/* Descriptor */
desc_found = 1;
} while( ( lbnum <= MVDS_location + ( MVDS_length - 1 )
- / DVD_VIDEO_LB_LEN ) && ( TagID != 8 )
+ / DVD_VIDEO_LB_LEN ) && ( TagID != TerminatingDescriptor )
&& ( !desc_found) );
if( !desc_found ) {
diff --git a/src/dvdread_internal.h b/src/dvdread_internal.h
index 7b04638..4efde23 100644
--- a/src/dvdread_internal.h
+++ b/src/dvdread_internal.h
@@ -23,7 +23,7 @@
#include <sys/types.h>
#ifdef _WIN32
-#include <unistd.h>
+# include <unistd.h>
#endif /* _WIN32 */
#include "dvdread/dvd_reader.h"
@@ -35,6 +35,31 @@
__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,
size_t block_count, unsigned char *data, int encrypted);
More information about the libdvdnav-devel
mailing list