1 /*****************************************************************************
2 * dvd_udf.c: udf filesystem tools.
4 * Mainly used to find asolute logical block adress of *.ifo files
5 *****************************************************************************
6 * Copyright (C) 1998-2001 VideoLAN
7 * $Id: dvd_udf.c,v 1.1 2001/02/15 21:03:27 stef Exp $
9 * Author: Stéphane Borel <stef@via.ecp.fr>
12 * - dvdudf by Christian Wolff <scarabaeus@convergence.de>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
27 *****************************************************************************/
37 #include <netinet/in.h>
41 #include "input_dvd.h"
46 typedef struct partition_s
49 u8 pi_volume_desc[128];
70 /*****************************************************************************
71 * UDFDecode: decode udf data that is unicode encoded
72 *****************************************************************************/
73 static int UDFDecode( u8 * pi_data, int i_len, char * psz_target )
78 if( !( pi_data[0] & 0x18 ) )
86 /* ignore MSB of unicode16 */
91 psz_target[i++] = pi_data[p+=2];
98 psz_target[i++] = pi_data[p++];
107 /*****************************************************************************
108 * UDFInit: some check and initialization in udf filesystem
109 *****************************************************************************/
110 int UDFInit( u8 * pi_data, udf_t * p_udf )
112 u32i lbsize,MT_L,N_PM;
114 UDFDecode( &pi_data[84], 128, p_udf->psz_volume_desc );
115 lbsize = GETN4(212); // should be 2048
116 MT_L = GETN4(264); // should be 6
117 N_PM = GETN4(268); // should be 1
119 if( lbsize != DVD_LB_SIZE )
127 /*****************************************************************************
129 *****************************************************************************/
130 int UDFFileEntry (uint8_t *data, uint8_t *FileType, struct AD *ad)
137 UDFICB(&data[16],&filetype,&flags);
138 FileType[0]=filetype;
143 while (p<176+L_EA+L_AD) {
144 switch (flags&0x07) {
146 UDFAD (&data[p], ad, UDFADshort);
150 UDFAD (&data[p], ad, UDFADlong);
153 case 2: UDFAD (&data[p], ad, UDFADext);
159 UDFAD (&data[p], ad, UDFADshort);
162 UDFAD (&data[p], ad, UDFADlong);
165 UDFAD (&data[p], ad, UDFADext);
177 /*****************************************************************************
179 *****************************************************************************/
180 int UDFFileIdentifier (uint8_t *data, uint8_t *FileCharacteristics, char *FileName, struct AD *FileICB)
185 FileCharacteristics[0]=GETN1(18);
187 UDFAD(&data[20],FileICB,UDFADlong);
191 _Unicodedecode (&data[38+L_IU],L_FI,FileName);
195 return 4*((38+L_FI+L_IU+3)/4);