static int UDFFileEntry( uint8_t *data, uint8_t *FileType, struct Partition *partition, struct AD *ad ) { uint16_t flags; uint32_t L_EA, L_AD; unsigned int p; UDFICB( &data[ 16 ], FileType, &flags ); /* Init ad for an empty file (i.e. there isn't a AD, L_AD == 0 ) */ ad->Length = GETN4( 60 ); /* Really 8 bytes a 56 */ ad->Flags = 0; ad->Location = 0; /* what should we put here? */ ad->Partition = partition->Number; /* use number of current partition */ L_EA = GETN4( 168 ); L_AD = GETN4( 172 ); if (176 + L_EA + L_AD > DVD_VIDEO_LB_LEN) return 0; p = 176 + L_EA; while( p < 176 + L_EA + L_AD ) { switch( flags & 0x0007 ) { case 0: UDFShortAD( &data[ p ], ad, partition ); p += 8; break; case 1: UDFLongAD( &data[ p ], ad ); p += 16; break; case 2: UDFExtAD( &data[ p ], ad ); p += 20; break; case 3: switch( L_AD ) { case 8: UDFShortAD( &data[ p ], ad, partition ); break; case 16: UDFLongAD( &data[ p ], ad ); break; case 20: UDFExtAD( &data[ p ], ad ); break; } p += L_AD; break; default: p += L_AD; break; } } return 0; }
static int UDFAD( quint8 *ptr, quint32 len, struct FileAD *fad) { struct AD *ad; if (fad->num_AD >= UDF_MAX_AD_CHAINS) return len; ad = &fad->AD_chain[fad->num_AD]; ad->Partition = fad->Partition; ad->Flags = 0; fad->num_AD++; switch( fad->Flags & 0x0007 ) { case 0: UDFShortAD( ptr, ad ); return 8; case 1: UDFLongAD( ptr, ad ); return 16; case 2: UDFExtAD( ptr, ad ); return 20; case 3: switch( len ) { case 8: UDFShortAD( ptr, ad ); break; case 16: UDFLongAD( ptr, ad ); break; case 20: UDFExtAD( ptr, ad ); break; } break; default: break; } return len; }
static int UDFExtFileEntry(uint8_t *data, struct Partition *partition, struct AD *ad) { int nRet = -1; uint8_t FileType; uint16_t TagID; uint16_t flags; uint32_t L_EA, L_AD; unsigned int p; UDFDescriptor( data, &TagID ); if (TagID != 266) { //printf("Not ExtFileEntry!!!\n"); return nRet; } UDFICB( &data[ 16 ], &FileType, &flags ); ad->Length = GETN4( 60 ); /* Really 8 bytes a 56 */ ad->Flags = 0; ad->Location = 0; /* what should we put here? */ ad->Partition = partition->Number; /* use number of current partition */ L_EA = GETN4( 208 ); L_AD = GETN4( 212 ); if (216 + L_EA + L_AD > DVD_VIDEO_LB_LEN) return nRet; p = 216 + L_EA; while( p < 216 + L_EA + L_AD ) { switch( flags & 0x0007 ) { case 0: UDFShortAD( &data[ p ], ad, partition ); p += 8; break; case 1: UDFLongAD( &data[ p ], ad ); p += 16; break; default: p += L_AD; break; } } return nRet; }
static int UDFExtFileEntry( uint8_t *data, uint8_t *FileType, struct Partition *partition, struct AD *ad ) { uint16_t flags; uint32_t L_EA, L_AD; unsigned int p; struct AD temp_ad; int is_init = 0; memset((void *)&temp_ad, 0, sizeof(struct AD)); UDFICB( &data[ 16 ], FileType, &flags ); /* Init ad for an empty file (i.e. there isn't a AD, L_AD == 0 ) */ //ad->Length = GETN4( 60 ); /* Really 8 bytes a 56 */ ad->Length = 0; ad->Flags = 0; ad->Location = 0; /* what should we put here? */ ad->Partition = partition->Number; /* use number of current partition */ L_EA = GETN4( 208 ); L_AD = GETN4( 212 ); if (216 + L_EA + L_AD > DVD_VIDEO_LB_LEN) return 0; p = 216 + L_EA; while( p < 216 + L_EA + L_AD ) { switch( flags & 0x0007 ) { case 0: UDFShortAD( &data[ p ], &temp_ad, partition ); p += 8; break; case 1: UDFLongAD( &data[ p ], &temp_ad ); p += 16; break; case 2: UDFExtAD( &data[ p ], &temp_ad ); p += 20; break; case 3: switch( L_AD ) { case 8: UDFShortAD( &data[ p ], &temp_ad, partition ); break; case 16: UDFLongAD( &data[ p ], &temp_ad ); break; case 20: UDFExtAD( &data[ p ], &temp_ad ); break; } p += L_AD; break; default: p += L_AD; break; } if (is_init == 0) { memcpy((void *)ad, (void *)&temp_ad, sizeof(struct AD)); is_init = 1; } else { // only update file size ad->Length += temp_ad.Length; } } return 0; }