Mercurial > libdvdread4.hg
annotate dvd_reader.c @ 68:3748dde919dd src
Clean up error paths.
Clean up the error paths of the function using goto.
author | erik |
---|---|
date | Sat, 13 Aug 2011 17:28:40 +0000 |
parents | d16d554fa215 |
children | 1b8797855771 |
rev | line source |
---|---|
3 | 1 /* |
2 * Copyright (C) 2001-2004 Billy Biggs <vektor@dumbterm.net>, | |
22 | 3 * Håkan Hjort <d95hjort@dtek.chalmers.se>, |
4 * Björn Englund <d4bjorn@dtek.chalmers.se> | |
3 | 5 * |
21
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
6 * This file is part of libdvdread. |
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
7 * |
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
8 * libdvdread is free software; you can redistribute it and/or modify |
3 | 9 * it under the terms of the GNU General Public License as published by |
21
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
11 * (at your option) any later version. |
3 | 12 * |
21
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
13 * libdvdread is distributed in the hope that it will be useful, |
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
16 * GNU General Public License for more details. |
3 | 17 * |
21
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
18 * You should have received a copy of the GNU General Public License along |
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
19 * with libdvdread; if not, write to the Free Software Foundation, Inc., |
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
3 | 21 */ |
22 | |
23 #include <sys/types.h> | |
24 #include <sys/stat.h> | |
25 #include <sys/time.h> /* For the timing of dvdcss_title crack. */ | |
26 #include <fcntl.h> | |
27 #include <stdlib.h> | |
28 #include <stdio.h> | |
29 #include <errno.h> | |
30 #include <string.h> | |
52
645a8b52b951
in OS/2 Use DVDOpenImageFile() only if it is a drive; patch by komh chollian net
nicodvb
parents:
50
diff
changeset
|
31 #include <ctype.h> |
3 | 32 #include <unistd.h> |
33 #include <limits.h> | |
34 #include <dirent.h> | |
35 | |
36 /* misc win32 helpers */ | |
37 #ifdef WIN32 | |
6
e5663591d13c
gettimeofday() doesn't exist in windows, but recent mingw32 runtime
nicodvb
parents:
3
diff
changeset
|
38 #ifndef HAVE_GETTIMEOFDAY |
3 | 39 /* replacement gettimeofday implementation */ |
40 #include <sys/timeb.h> | |
41 static inline int _private_gettimeofday( struct timeval *tv, void *tz ) | |
42 { | |
43 struct timeb t; | |
44 ftime( &t ); | |
45 tv->tv_sec = t.time; | |
46 tv->tv_usec = t.millitm * 1000; | |
47 return 0; | |
48 } | |
49 #define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ)) | |
6
e5663591d13c
gettimeofday() doesn't exist in windows, but recent mingw32 runtime
nicodvb
parents:
3
diff
changeset
|
50 #endif |
3 | 51 #include <io.h> /* read() */ |
52 #define lseek64 _lseeki64 | |
53 #endif | |
20 | 54 |
36
79c9b639bf9d
Use __APPLE__ instead of __DARWIN__ in preprocessor check.
diego
parents:
35
diff
changeset
|
55 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__APPLE__) |
3 | 56 #define SYS_BSD 1 |
57 #endif | |
58 | |
59 #if defined(__sun) | |
60 #include <sys/mnttab.h> | |
61 #elif defined(SYS_BSD) | |
62 #include <fstab.h> | |
63 #elif defined(__linux__) | |
64 #include <mntent.h> | |
66 | 65 #include <paths.h> |
3 | 66 #endif |
67 | |
33
c743d79f187b
Move installed headers into dvdread directory to make them easier to
reimar
parents:
30
diff
changeset
|
68 #include "dvdread/dvd_udf.h" |
3 | 69 #include "dvd_input.h" |
33
c743d79f187b
Move installed headers into dvdread directory to make them easier to
reimar
parents:
30
diff
changeset
|
70 #include "dvdread/dvd_reader.h" |
3 | 71 #include "md5.h" |
72 | |
73 #define DEFAULT_UDF_CACHE_LEVEL 1 | |
74 | |
75 struct dvd_reader_s { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
76 /* Basic information. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
77 int isImageFile; |
20 | 78 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
79 /* Hack for keeping track of the css status. |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
80 * 0: no css, 1: perhaps (need init of keys), 2: have done init */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
81 int css_state; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
82 int css_title; /* Last title that we have called dvdinpute_title for. */ |
3 | 83 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
84 /* Information required for an image file. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
85 dvd_input_t dev; |
3 | 86 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
87 /* Information required for a directory path drive. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
88 char *path_root; |
20 | 89 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
90 /* Filesystem cache */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
91 int udfcache_level; /* 0 - turned off, 1 - on */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
92 void *udfcache; |
3 | 93 }; |
94 | |
95 #define TITLES_MAX 9 | |
96 | |
97 struct dvd_file_s { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
98 /* Basic information. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
99 dvd_reader_t *dvd; |
20 | 100 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
101 /* Hack for selecting the right css title. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
102 int css_title; |
3 | 103 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
104 /* Information required for an image file. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
105 uint32_t lb_start; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
106 uint32_t seek_pos; |
3 | 107 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
108 /* Information required for a directory path drive. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
109 size_t title_sizes[ TITLES_MAX ]; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
110 dvd_input_t title_devs[ TITLES_MAX ]; |
3 | 111 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
112 /* Calculated at open-time, size in blocks. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
113 ssize_t filesize; |
3 | 114 }; |
115 | |
116 int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number, | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
117 size_t block_count, unsigned char *data, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
118 int encrypted ); |
3 | 119 |
120 /** | |
121 * Set the level of caching on udf | |
122 * level = 0 (no caching) | |
123 * level = 1 (caching filesystem info) | |
124 */ | |
125 int DVDUDFCacheLevel(dvd_reader_t *device, int level) | |
126 { | |
127 struct dvd_reader_s *dev = (struct dvd_reader_s *)device; | |
20 | 128 |
3 | 129 if(level > 0) { |
130 level = 1; | |
131 } else if(level < 0) { | |
132 return dev->udfcache_level; | |
133 } | |
134 | |
135 dev->udfcache_level = level; | |
20 | 136 |
3 | 137 return level; |
138 } | |
139 | |
140 void *GetUDFCacheHandle(dvd_reader_t *device) | |
141 { | |
142 struct dvd_reader_s *dev = (struct dvd_reader_s *)device; | |
20 | 143 |
3 | 144 return dev->udfcache; |
145 } | |
146 | |
147 void SetUDFCacheHandle(dvd_reader_t *device, void *cache) | |
148 { | |
149 struct dvd_reader_s *dev = (struct dvd_reader_s *)device; | |
150 | |
151 dev->udfcache = cache; | |
152 } | |
153 | |
154 | |
155 | |
156 /* Loop over all titles and call dvdcss_title to crack the keys. */ | |
157 static int initAllCSSKeys( dvd_reader_t *dvd ) | |
158 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
159 struct timeval all_s, all_e; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
160 struct timeval t_s, t_e; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
161 char filename[ MAX_UDF_FILE_NAME_LEN ]; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
162 uint32_t start, len; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
163 int title; |
20 | 164 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
165 char *nokeys_str = getenv("DVDREAD_NOKEYS"); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
166 if(nokeys_str != NULL) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
167 return 0; |
20 | 168 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
169 fprintf( stderr, "\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
170 fprintf( stderr, "libdvdread: Attempting to retrieve all CSS keys\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
171 fprintf( stderr, "libdvdread: This can take a _long_ time, " |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
172 "please be patient\n\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
173 gettimeofday(&all_s, NULL); |
20 | 174 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
175 for( title = 0; title < 100; title++ ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
176 gettimeofday( &t_s, NULL ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
177 if( title == 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
178 sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
179 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
180 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 0 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
181 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
182 start = UDFFindFile( dvd, filename, &len ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
183 if( start != 0 && len != 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
184 /* Perform CSS key cracking for this title. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
185 fprintf( stderr, "libdvdread: Get key for %s at 0x%08x\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
186 filename, start ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
187 if( dvdinput_title( dvd->dev, (int)start ) < 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
188 fprintf( stderr, "libdvdread: Error cracking CSS key for %s (0x%08x)\n", filename, start); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
189 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
190 gettimeofday( &t_e, NULL ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
191 fprintf( stderr, "libdvdread: Elapsed time %ld\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
192 (long int) t_e.tv_sec - t_s.tv_sec ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
193 } |
20 | 194 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
195 if( title == 0 ) continue; |
20 | 196 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
197 gettimeofday( &t_s, NULL ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
198 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 1 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
199 start = UDFFindFile( dvd, filename, &len ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
200 if( start == 0 || len == 0 ) break; |
20 | 201 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
202 /* Perform CSS key cracking for this title. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
203 fprintf( stderr, "libdvdread: Get key for %s at 0x%08x\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
204 filename, start ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
205 if( dvdinput_title( dvd->dev, (int)start ) < 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
206 fprintf( stderr, "libdvdread: Error cracking CSS key for %s (0x%08x)!!\n", filename, start); |
3 | 207 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
208 gettimeofday( &t_e, NULL ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
209 fprintf( stderr, "libdvdread: Elapsed time %ld\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
210 (long int) t_e.tv_sec - t_s.tv_sec ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
211 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
212 title--; |
20 | 213 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
214 fprintf( stderr, "libdvdread: Found %d VTS's\n", title ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
215 gettimeofday(&all_e, NULL); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
216 fprintf( stderr, "libdvdread: Elapsed time %ld\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
217 (long int) all_e.tv_sec - all_s.tv_sec ); |
20 | 218 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
219 return 0; |
3 | 220 } |
221 | |
222 | |
223 | |
224 /** | |
225 * Open a DVD image or block device file. | |
226 */ | |
227 static dvd_reader_t *DVDOpenImageFile( const char *location, int have_css ) | |
228 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
229 dvd_reader_t *dvd; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
230 dvd_input_t dev; |
20 | 231 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
232 dev = dvdinput_open( location ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
233 if( !dev ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
234 fprintf( stderr, "libdvdread: Can't open %s for reading\n", location ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
235 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
236 } |
3 | 237 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
238 dvd = (dvd_reader_t *) malloc( sizeof( dvd_reader_t ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
239 if( !dvd ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
240 dvdinput_close(dev); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
241 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
242 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
243 dvd->isImageFile = 1; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
244 dvd->dev = dev; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
245 dvd->path_root = NULL; |
20 | 246 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
247 dvd->udfcache_level = DEFAULT_UDF_CACHE_LEVEL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
248 dvd->udfcache = NULL; |
3 | 249 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
250 if( have_css ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
251 /* Only if DVDCSS_METHOD = title, a bit if it's disc or if |
35 | 252 * DVDCSS_METHOD = key but region mismatch. Unfortunately we |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
253 * don't have that information. */ |
20 | 254 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
255 dvd->css_state = 1; /* Need key init. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
256 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
257 dvd->css_title = 0; |
20 | 258 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
259 return dvd; |
3 | 260 } |
261 | |
262 static dvd_reader_t *DVDOpenPath( const char *path_root ) | |
263 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
264 dvd_reader_t *dvd; |
3 | 265 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
266 dvd = (dvd_reader_t *) malloc( sizeof( dvd_reader_t ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
267 if( !dvd ) return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
268 dvd->isImageFile = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
269 dvd->dev = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
270 dvd->path_root = strdup( path_root ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
271 if(!dvd->path_root) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
272 free(dvd); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
273 return 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
274 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
275 dvd->udfcache_level = DEFAULT_UDF_CACHE_LEVEL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
276 dvd->udfcache = NULL; |
3 | 277 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
278 dvd->css_state = 0; /* Only used in the UDF path */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
279 dvd->css_title = 0; /* Only matters in the UDF path */ |
20 | 280 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
281 return dvd; |
3 | 282 } |
283 | |
284 #if defined(__sun) | |
285 /* /dev/rdsk/c0t6d0s0 (link to /devices/...) | |
286 /vol/dev/rdsk/c0t6d0/?? | |
287 /vol/rdsk/<name> */ | |
288 static char *sun_block2char( const char *path ) | |
289 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
290 char *new_path; |
3 | 291 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
292 /* Must contain "/dsk/" */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
293 if( !strstr( path, "/dsk/" ) ) return (char *) strdup( path ); |
3 | 294 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
295 /* Replace "/dsk/" with "/rdsk/" */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
296 new_path = malloc( strlen(path) + 2 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
297 strcpy( new_path, path ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
298 strcpy( strstr( new_path, "/dsk/" ), "" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
299 strcat( new_path, "/rdsk/" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
300 strcat( new_path, strstr( path, "/dsk/" ) + strlen( "/dsk/" ) ); |
3 | 301 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
302 return new_path; |
3 | 303 } |
304 #endif | |
305 | |
306 #if defined(SYS_BSD) | |
35 | 307 /* FreeBSD /dev/(r)(a)cd0c (a is for atapi), recommended to _not_ use r |
45 | 308 update: FreeBSD and DragonFly no longer uses the prefix so don't add it. |
3 | 309 OpenBSD /dev/rcd0c, it needs to be the raw device |
310 NetBSD /dev/rcd0[d|c|..] d for x86, c (for non x86), perhaps others | |
311 Darwin /dev/rdisk0, it needs to be the raw device | |
45 | 312 BSD/OS /dev/sr0c (if not mounted) or /dev/rsr0c ('c' any letter will do) |
313 returns a string allocated with strdup. It should be freed when no longer | |
314 used. */ | |
3 | 315 static char *bsd_block2char( const char *path ) |
316 { | |
45 | 317 #if defined(__FreeBSD__) || defined(__DragonFly__) |
318 return (char *) strdup( path ); | |
319 #else | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
320 char *new_path; |
3 | 321 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
322 /* If it doesn't start with "/dev/" or does start with "/dev/r" exit */ |
57
4554518224d7
Fix the test of whether disk names should be raw devices
erik
parents:
56
diff
changeset
|
323 if( strncmp( path, "/dev/", 5 ) || !strncmp( path, "/dev/r", 6 ) ) |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
324 return (char *) strdup( path ); |
3 | 325 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
326 /* Replace "/dev/" with "/dev/r" */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
327 new_path = malloc( strlen(path) + 2 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
328 strcpy( new_path, "/dev/r" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
329 strcat( new_path, path + strlen( "/dev/" ) ); |
3 | 330 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
331 return new_path; |
45 | 332 #endif /* __FreeBSD__ || __DragonFly__ */ |
3 | 333 } |
334 #endif | |
335 | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
336 |
3 | 337 dvd_reader_t *DVDOpen( const char *ppath ) |
338 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
339 struct stat fileinfo; |
47 | 340 int ret, have_css, retval, cdir = -1; |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
341 dvd_reader_t *ret_val = NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
342 char *dev_name = NULL; |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
343 char *path = NULL, *new_path = NULL, *path_copy = NULL; |
3 | 344 |
53
f7e7938944e9
As for win32 strip off the trailing \ if it is not a drive
nicodvb
parents:
52
diff
changeset
|
345 #if defined(_WIN32) || defined(__OS2__) |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
346 int len; |
3 | 347 #endif |
348 | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
349 if( ppath == NULL ) |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
350 goto DVDOpen_error; |
3 | 351 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
352 path = strdup(ppath); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
353 if( path == NULL ) |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
354 goto DVDOpen_error; |
20 | 355 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
356 /* Try to open libdvdcss or fall back to standard functions */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
357 have_css = dvdinput_setup(); |
3 | 358 |
53
f7e7938944e9
As for win32 strip off the trailing \ if it is not a drive
nicodvb
parents:
52
diff
changeset
|
359 #if defined(_WIN32) || defined(__OS2__) |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
360 /* Strip off the trailing \ if it is not a drive */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
361 len = strlen(path); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
362 if ((len > 1) && |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
363 (path[len - 1] == '\\') && |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
364 (path[len - 2] != ':')) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
365 { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
366 path[len-1] = '\0'; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
367 } |
3 | 368 #endif |
20 | 369 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
370 ret = stat( path, &fileinfo ); |
3 | 371 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
372 if( ret < 0 ) { |
3 | 373 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
374 /* maybe "host:port" url? try opening it with acCeSS library */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
375 if( strchr(path,':') ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
376 ret_val = DVDOpenImageFile( path, have_css ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
377 free(path); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
378 return ret_val; |
3 | 379 } |
380 | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
381 /* If we can't stat the file, give up */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
382 fprintf( stderr, "libdvdread: Can't stat %s\n", path ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
383 perror(""); |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
384 goto DVDOpen_error; |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
385 } |
3 | 386 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
387 /* First check if this is a block/char device or a file*/ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
388 if( S_ISBLK( fileinfo.st_mode ) || |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
389 S_ISCHR( fileinfo.st_mode ) || |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
390 S_ISREG( fileinfo.st_mode ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
391 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
392 /** |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
393 * Block devices and regular files are assumed to be DVD-Video images. |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
394 */ |
45 | 395 dvd_reader_t *dvd = NULL; |
3 | 396 #if defined(__sun) |
45 | 397 dev_name = sun_block2char( path ); |
3 | 398 #elif defined(SYS_BSD) |
45 | 399 dev_name = bsd_block2char( path ); |
3 | 400 #else |
45 | 401 dev_name = strdup( path ); |
3 | 402 #endif |
45 | 403 dvd = DVDOpenImageFile( dev_name, have_css ); |
404 free( dev_name ); | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
405 free(path); |
45 | 406 return dvd; |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
407 } else if( S_ISDIR( fileinfo.st_mode ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
408 dvd_reader_t *auth_drive = 0; |
3 | 409 #if defined(SYS_BSD) |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
410 struct fstab* fe; |
3 | 411 #elif defined(__sun) || defined(__linux__) |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
412 FILE *mntfile; |
3 | 413 #endif |
414 | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
415 /* XXX: We should scream real loud here. */ |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
416 if( !(path_copy = strdup( path ) ) ) |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
417 goto DVDOpen_error; |
3 | 418 |
419 #ifndef WIN32 /* don't have fchdir, and getcwd( NULL, ... ) is strange */ | |
420 /* Also WIN32 does not have symlinks, so we don't need this bit of code. */ | |
421 | |
35 | 422 /* Resolve any symlinks and get the absolute dir name. */ |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
423 { |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
424 if( ( cdir = open( ".", O_RDONLY ) ) >= 0 ) { |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
425 if( chdir( path_copy ) == -1 ) { |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
426 goto DVDOpen_error; |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
427 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
428 new_path = malloc(PATH_MAX+1); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
429 if(!new_path) { |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
430 goto DVDOpen_error; |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
431 } |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
432 if( getcwd( new_path, PATH_MAX ) == NULL ) { |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
433 goto DVDOpen_error; |
26 | 434 } |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
435 retval = fchdir( cdir ); |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
436 close( cdir ); |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
437 cdir = -1; |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
438 if( retval == -1 ) { |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
439 goto DVDOpen_error; |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
440 } |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
441 path_copy = new_path; |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
442 new_path = NULL; |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
443 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
444 } |
20 | 445 #endif |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
446 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
447 /** |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
448 * If we're being asked to open a directory, check if that directory |
35 | 449 * is the mount point for a DVD-ROM which we can use instead. |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
450 */ |
3 | 451 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
452 if( strlen( path_copy ) > 1 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
453 if( path_copy[ strlen( path_copy ) - 1 ] == '/' ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
454 path_copy[ strlen( path_copy ) - 1 ] = '\0'; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
455 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
456 } |
3 | 457 |
54
de60b270bd83
as for win32 check for \video_ts as /video_ts in OS/2; patch by komh chollian net
nicodvb
parents:
53
diff
changeset
|
458 #if defined(_WIN32) || defined(__OS2__) |
50
60720f86d145
in _WIN32 do a sanity check against \video_ts in addition to /video_ts, because both paths are admitted; patch by John Stebbins from Handbrake
nicodvb
parents:
47
diff
changeset
|
459 if(strlen(path_copy) > TITLES_MAX) { |
60720f86d145
in _WIN32 do a sanity check against \video_ts in addition to /video_ts, because both paths are admitted; patch by John Stebbins from Handbrake
nicodvb
parents:
47
diff
changeset
|
460 if(!strcasecmp(&(path_copy[strlen( path_copy ) - TITLES_MAX]), |
60720f86d145
in _WIN32 do a sanity check against \video_ts in addition to /video_ts, because both paths are admitted; patch by John Stebbins from Handbrake
nicodvb
parents:
47
diff
changeset
|
461 "\\video_ts")) |
60720f86d145
in _WIN32 do a sanity check against \video_ts in addition to /video_ts, because both paths are admitted; patch by John Stebbins from Handbrake
nicodvb
parents:
47
diff
changeset
|
462 path_copy[strlen(path_copy) - (TITLES_MAX-1)] = '\0'; |
60720f86d145
in _WIN32 do a sanity check against \video_ts in addition to /video_ts, because both paths are admitted; patch by John Stebbins from Handbrake
nicodvb
parents:
47
diff
changeset
|
463 } |
60720f86d145
in _WIN32 do a sanity check against \video_ts in addition to /video_ts, because both paths are admitted; patch by John Stebbins from Handbrake
nicodvb
parents:
47
diff
changeset
|
464 #endif |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
465 if( strlen( path_copy ) > TITLES_MAX ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
466 if( !strcasecmp( &(path_copy[ strlen( path_copy ) - TITLES_MAX ]), |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
467 "/video_ts" ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
468 path_copy[ strlen( path_copy ) - TITLES_MAX ] = '\0'; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
469 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
470 } |
20 | 471 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
472 if(path_copy[0] == '\0') { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
473 path_copy[0] = '/'; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
474 path_copy[1] = '\0'; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
475 } |
3 | 476 |
477 #if defined(SYS_BSD) | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
478 if( ( fe = getfsfile( path_copy ) ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
479 dev_name = bsd_block2char( fe->fs_spec ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
480 fprintf( stderr, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
481 "libdvdread: Attempting to use device %s" |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
482 " mounted on %s for CSS authentication\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
483 dev_name, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
484 fe->fs_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
485 auth_drive = DVDOpenImageFile( dev_name, have_css ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
486 } |
3 | 487 #elif defined(__sun) |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
488 mntfile = fopen( MNTTAB, "r" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
489 if( mntfile ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
490 struct mnttab mp; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
491 int res; |
3 | 492 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
493 while( ( res = getmntent( mntfile, &mp ) ) != -1 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
494 if( res == 0 && !strcmp( mp.mnt_mountp, path_copy ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
495 dev_name = sun_block2char( mp.mnt_special ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
496 fprintf( stderr, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
497 "libdvdread: Attempting to use device %s" |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
498 " mounted on %s for CSS authentication\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
499 dev_name, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
500 mp.mnt_mountp ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
501 auth_drive = DVDOpenImageFile( dev_name, have_css ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
502 break; |
26 | 503 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
504 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
505 fclose( mntfile ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
506 } |
3 | 507 #elif defined(__linux__) |
66 | 508 mntfile = fopen( _PATH_MOUNTED, "r" ); |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
509 if( mntfile ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
510 struct mntent *me; |
20 | 511 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
512 while( ( me = getmntent( mntfile ) ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
513 if( !strcmp( me->mnt_dir, path_copy ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
514 fprintf( stderr, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
515 "libdvdread: Attempting to use device %s" |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
516 " mounted on %s for CSS authentication\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
517 me->mnt_fsname, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
518 me->mnt_dir ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
519 auth_drive = DVDOpenImageFile( me->mnt_fsname, have_css ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
520 dev_name = strdup(me->mnt_fsname); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
521 break; |
26 | 522 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
523 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
524 fclose( mntfile ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
525 } |
41
ef679522d00f
replaced conditional checks on MSC with _WIN32 to permit MINGW to mount and decrypt images; patch by John Stebbins (stebbing jetheaddev com)
nicodvb
parents:
38
diff
changeset
|
526 #elif defined(_WIN32) || defined(__OS2__) |
52
645a8b52b951
in OS/2 Use DVDOpenImageFile() only if it is a drive; patch by komh chollian net
nicodvb
parents:
50
diff
changeset
|
527 #ifdef __OS2__ |
645a8b52b951
in OS/2 Use DVDOpenImageFile() only if it is a drive; patch by komh chollian net
nicodvb
parents:
50
diff
changeset
|
528 /* Use DVDOpenImageFile() only if it is a drive */ |
56
af0a1be87264
in DVDOPen() use isalpha() rather than checking the first char of the device against 'A'..'Z'
nicodvb
parents:
55
diff
changeset
|
529 if(isalpha(path[0]) && path[1] == ':' && |
52
645a8b52b951
in OS/2 Use DVDOpenImageFile() only if it is a drive; patch by komh chollian net
nicodvb
parents:
50
diff
changeset
|
530 ( !path[2] || |
645a8b52b951
in OS/2 Use DVDOpenImageFile() only if it is a drive; patch by komh chollian net
nicodvb
parents:
50
diff
changeset
|
531 ((path[2] == '\\' || path[2] == '/') && !path[3]))) |
645a8b52b951
in OS/2 Use DVDOpenImageFile() only if it is a drive; patch by komh chollian net
nicodvb
parents:
50
diff
changeset
|
532 #endif |
3 | 533 auth_drive = DVDOpenImageFile( path, have_css ); |
534 #endif | |
535 | |
41
ef679522d00f
replaced conditional checks on MSC with _WIN32 to permit MINGW to mount and decrypt images; patch by John Stebbins (stebbing jetheaddev com)
nicodvb
parents:
38
diff
changeset
|
536 #if !defined(_WIN32) && !defined(__OS2__) |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
537 if( !dev_name ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
538 fprintf( stderr, "libdvdread: Couldn't find device name.\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
539 } else if( !auth_drive ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
540 fprintf( stderr, "libdvdread: Device %s inaccessible, " |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
541 "CSS authentication not available.\n", dev_name ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
542 } |
3 | 543 #else |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
544 if( !auth_drive ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
545 fprintf( stderr, "libdvdread: Device %s inaccessible, " |
55
950bb037bedb
in OS2 and WIN32 when CSS is not available print the correct message using path rather than dev_name; patch by komh chollium net
nicodvb
parents:
54
diff
changeset
|
546 "CSS authentication not available.\n", path ); |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
547 } |
3 | 548 #endif |
549 | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
550 free( dev_name ); |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
551 dev_name = NULL; |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
552 free( path_copy ); |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
553 path_copy = NULL; |
3 | 554 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
555 /** |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
556 * If we've opened a drive, just use that. |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
557 */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
558 if( auth_drive ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
559 free(path); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
560 return auth_drive; |
3 | 561 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
562 /** |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
563 * Otherwise, we now try to open the directory tree instead. |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
564 */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
565 ret_val = DVDOpenPath( path ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
566 free( path ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
567 return ret_val; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
568 } |
3 | 569 |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
570 DVDOpen_error: |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
571 /* If it's none of the above, screw it. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
572 fprintf( stderr, "libdvdread: Could not open %s\n", path ); |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
573 if( path != NULL ) |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
574 free( path ); |
37
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
575 if ( path_copy != NULL ) |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
576 free( path_copy ); |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
577 if ( cdir >= 0 ) |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
578 close( cdir ); |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
579 if ( new_path != NULL ) |
a57cd30a83bb
modified DVDOpen() to use a unified DVDOpen_error label; patch by Erik Hovland
nicodvb
parents:
36
diff
changeset
|
580 free( new_path ); |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
581 return NULL; |
3 | 582 } |
583 | |
584 void DVDClose( dvd_reader_t *dvd ) | |
585 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
586 if( dvd ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
587 if( dvd->dev ) dvdinput_close( dvd->dev ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
588 if( dvd->path_root ) free( dvd->path_root ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
589 if( dvd->udfcache ) FreeUDFCache( dvd->udfcache ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
590 free( dvd ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
591 } |
3 | 592 } |
593 | |
594 /** | |
595 * Open an unencrypted file on a DVD image file. | |
596 */ | |
597 static dvd_file_t *DVDOpenFileUDF( dvd_reader_t *dvd, char *filename ) | |
598 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
599 uint32_t start, len; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
600 dvd_file_t *dvd_file; |
3 | 601 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
602 start = UDFFindFile( dvd, filename, &len ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
603 if( !start ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
604 fprintf( stderr, "libdvdnav:DVDOpenFileUDF:UDFFindFile %s failed\n", filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
605 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
606 } |
3 | 607 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
608 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
609 if( !dvd_file ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
610 fprintf( stderr, "libdvdnav:DVDOpenFileUDF:malloc failed\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
611 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
612 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
613 dvd_file->dvd = dvd; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
614 dvd_file->lb_start = start; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
615 dvd_file->seek_pos = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
616 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
617 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
618 dvd_file->filesize = len / DVD_VIDEO_LB_LEN; |
3 | 619 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
620 return dvd_file; |
3 | 621 } |
622 | |
623 /** | |
624 * Searches for <file> in directory <path>, ignoring case. | |
625 * Returns 0 and full filename in <filename>. | |
626 * or -1 on file not found. | |
627 * or -2 on path not found. | |
628 */ | |
20 | 629 static int findDirFile( const char *path, const char *file, char *filename ) |
3 | 630 { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
631 DIR *dir; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
632 struct dirent *ent; |
3 | 633 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
634 dir = opendir( path ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
635 if( !dir ) return -2; |
3 | 636 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
637 while( ( ent = readdir( dir ) ) != NULL ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
638 if( !strcasecmp( ent->d_name, file ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
639 sprintf( filename, "%s%s%s", path, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
640 ( ( path[ strlen( path ) - 1 ] == '/' ) ? "" : "/" ), |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
641 ent->d_name ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
642 closedir(dir); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
643 return 0; |
3 | 644 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
645 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
646 closedir(dir); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
647 return -1; |
3 | 648 } |
649 | |
650 static int findDVDFile( dvd_reader_t *dvd, const char *file, char *filename ) | |
651 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
652 char video_path[ PATH_MAX + 1 ]; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
653 const char *nodirfile; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
654 int ret; |
3 | 655 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
656 /* Strip off the directory for our search */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
657 if( !strncasecmp( "/VIDEO_TS/", file, 10 ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
658 nodirfile = &(file[ 10 ]); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
659 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
660 nodirfile = file; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
661 } |
3 | 662 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
663 ret = findDirFile( dvd->path_root, nodirfile, filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
664 if( ret < 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
665 /* Try also with adding the path, just in case. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
666 sprintf( video_path, "%s/VIDEO_TS/", dvd->path_root ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
667 ret = findDirFile( video_path, nodirfile, filename ); |
3 | 668 if( ret < 0 ) { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
669 /* Try with the path, but in lower case. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
670 sprintf( video_path, "%s/video_ts/", dvd->path_root ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
671 ret = findDirFile( video_path, nodirfile, filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
672 if( ret < 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
673 return 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
674 } |
3 | 675 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
676 } |
3 | 677 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
678 return 1; |
3 | 679 } |
680 | |
681 /** | |
682 * Open an unencrypted file from a DVD directory tree. | |
683 */ | |
684 static dvd_file_t *DVDOpenFilePath( dvd_reader_t *dvd, char *filename ) | |
685 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
686 char full_path[ PATH_MAX + 1 ]; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
687 dvd_file_t *dvd_file; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
688 struct stat fileinfo; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
689 dvd_input_t dev; |
3 | 690 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
691 /* Get the full path of the file. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
692 if( !findDVDFile( dvd, filename, full_path ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
693 fprintf( stderr, "libdvdnav:DVDOpenFilePath:findDVDFile %s failed\n", filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
694 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
695 } |
3 | 696 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
697 dev = dvdinput_open( full_path ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
698 if( !dev ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
699 fprintf( stderr, "libdvdnav:DVDOpenFilePath:dvdinput_open %s failed\n", full_path ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
700 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
701 } |
3 | 702 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
703 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
704 if( !dvd_file ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
705 fprintf( stderr, "libdvdnav:DVDOpenFilePath:dvd_file malloc failed\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
706 dvdinput_close(dev); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
707 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
708 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
709 dvd_file->dvd = dvd; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
710 dvd_file->lb_start = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
711 dvd_file->seek_pos = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
712 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
713 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
714 dvd_file->filesize = 0; |
3 | 715 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
716 if( stat( full_path, &fileinfo ) < 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
717 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
718 free( dvd_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
719 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
720 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
721 dvd_file->title_sizes[ 0 ] = fileinfo.st_size / DVD_VIDEO_LB_LEN; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
722 dvd_file->title_devs[ 0 ] = dev; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
723 dvd_file->filesize = dvd_file->title_sizes[ 0 ]; |
3 | 724 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
725 return dvd_file; |
3 | 726 } |
727 | |
728 static dvd_file_t *DVDOpenVOBUDF( dvd_reader_t *dvd, int title, int menu ) | |
729 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
730 char filename[ MAX_UDF_FILE_NAME_LEN ]; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
731 uint32_t start, len; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
732 dvd_file_t *dvd_file; |
3 | 733 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
734 if( title == 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
735 sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
736 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
737 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
738 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
739 start = UDFFindFile( dvd, filename, &len ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
740 if( start == 0 ) return NULL; |
3 | 741 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
742 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
743 if( !dvd_file ) return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
744 dvd_file->dvd = dvd; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
745 /*Hack*/ dvd_file->css_title = title << 1 | menu; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
746 dvd_file->lb_start = start; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
747 dvd_file->seek_pos = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
748 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
749 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
750 dvd_file->filesize = len / DVD_VIDEO_LB_LEN; |
3 | 751 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
752 /* Calculate the complete file size for every file in the VOBS */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
753 if( !menu ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
754 int cur; |
3 | 755 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
756 for( cur = 2; cur < 10; cur++ ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
757 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
758 if( !UDFFindFile( dvd, filename, &len ) ) break; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
759 dvd_file->filesize += len / DVD_VIDEO_LB_LEN; |
3 | 760 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
761 } |
20 | 762 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
763 if( dvd->css_state == 1 /* Need key init */ ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
764 initAllCSSKeys( dvd ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
765 dvd->css_state = 2; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
766 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
767 /* |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
768 if( dvdinput_title( dvd_file->dvd->dev, (int)start ) < 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
769 fprintf( stderr, "libdvdread: Error cracking CSS key for %s\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
770 filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
771 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
772 */ |
20 | 773 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
774 return dvd_file; |
3 | 775 } |
776 | |
777 static dvd_file_t *DVDOpenVOBPath( dvd_reader_t *dvd, int title, int menu ) | |
778 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
779 char filename[ MAX_UDF_FILE_NAME_LEN ]; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
780 char full_path[ PATH_MAX + 1 ]; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
781 struct stat fileinfo; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
782 dvd_file_t *dvd_file; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
783 int i; |
3 | 784 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
785 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
786 if( !dvd_file ) return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
787 dvd_file->dvd = dvd; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
788 /*Hack*/ dvd_file->css_title = title << 1 | menu; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
789 dvd_file->lb_start = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
790 dvd_file->seek_pos = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
791 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
792 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
793 dvd_file->filesize = 0; |
3 | 794 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
795 if( menu ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
796 dvd_input_t dev; |
3 | 797 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
798 if( title == 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
799 sprintf( filename, "VIDEO_TS.VOB" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
800 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
801 sprintf( filename, "VTS_%02i_0.VOB", title ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
802 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
803 if( !findDVDFile( dvd, filename, full_path ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
804 free( dvd_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
805 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
806 } |
3 | 807 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
808 dev = dvdinput_open( full_path ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
809 if( dev == NULL ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
810 free( dvd_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
811 return NULL; |
3 | 812 } |
813 | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
814 if( stat( full_path, &fileinfo ) < 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
815 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
816 dvdinput_close(dev); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
817 free( dvd_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
818 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
819 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
820 dvd_file->title_sizes[ 0 ] = fileinfo.st_size / DVD_VIDEO_LB_LEN; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
821 dvd_file->title_devs[ 0 ] = dev; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
822 dvdinput_title( dvd_file->title_devs[0], 0); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
823 dvd_file->filesize = dvd_file->title_sizes[ 0 ]; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
824 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
825 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
826 for( i = 0; i < TITLES_MAX; ++i ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
827 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
828 sprintf( filename, "VTS_%02i_%i.VOB", title, i + 1 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
829 if( !findDVDFile( dvd, filename, full_path ) ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
830 break; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
831 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
832 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
833 if( stat( full_path, &fileinfo ) < 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
834 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
835 break; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
836 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
837 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
838 dvd_file->title_sizes[ i ] = fileinfo.st_size / DVD_VIDEO_LB_LEN; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
839 dvd_file->title_devs[ i ] = dvdinput_open( full_path ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
840 dvdinput_title( dvd_file->title_devs[ i ], 0 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
841 dvd_file->filesize += dvd_file->title_sizes[ i ]; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
842 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
843 if( !dvd_file->title_devs[ 0 ] ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
844 free( dvd_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
845 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
846 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
847 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
848 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
849 return dvd_file; |
3 | 850 } |
851 | |
20 | 852 dvd_file_t *DVDOpenFile( dvd_reader_t *dvd, int titlenum, |
26 | 853 dvd_read_domain_t domain ) |
3 | 854 { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
855 char filename[ MAX_UDF_FILE_NAME_LEN ]; |
20 | 856 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
857 /* Check arguments. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
858 if( dvd == NULL || titlenum < 0 ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
859 return NULL; |
3 | 860 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
861 switch( domain ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
862 case DVD_READ_INFO_FILE: |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
863 if( titlenum == 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
864 sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
865 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
866 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
867 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
868 break; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
869 case DVD_READ_INFO_BACKUP_FILE: |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
870 if( titlenum == 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
871 sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
872 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
873 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum ); |
3 | 874 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
875 break; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
876 case DVD_READ_MENU_VOBS: |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
877 if( dvd->isImageFile ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
878 return DVDOpenVOBUDF( dvd, titlenum, 1 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
879 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
880 return DVDOpenVOBPath( dvd, titlenum, 1 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
881 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
882 break; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
883 case DVD_READ_TITLE_VOBS: |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
884 if( titlenum == 0 ) return 0; |
3 | 885 if( dvd->isImageFile ) { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
886 return DVDOpenVOBUDF( dvd, titlenum, 0 ); |
3 | 887 } else { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
888 return DVDOpenVOBPath( dvd, titlenum, 0 ); |
3 | 889 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
890 break; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
891 default: |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
892 fprintf( stderr, "libdvdread: Invalid domain for file open.\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
893 return NULL; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
894 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
895 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
896 if( dvd->isImageFile ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
897 return DVDOpenFileUDF( dvd, filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
898 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
899 return DVDOpenFilePath( dvd, filename ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
900 } |
3 | 901 } |
902 | |
903 void DVDCloseFile( dvd_file_t *dvd_file ) | |
904 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
905 int i; |
3 | 906 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
907 if( dvd_file ) { |
42 | 908 if( !dvd_file->dvd->isImageFile ) { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
909 for( i = 0; i < TITLES_MAX; ++i ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
910 if( dvd_file->title_devs[ i ] ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
911 dvdinput_close( dvd_file->title_devs[i] ); |
3 | 912 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
913 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
914 } |
3 | 915 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
916 free( dvd_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
917 dvd_file = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
918 } |
3 | 919 } |
920 | |
44 | 921 static int DVDFileStatVOBUDF( dvd_reader_t *dvd, int title, |
922 int menu, dvd_stat_t *statbuf ) | |
923 { | |
924 char filename[ MAX_UDF_FILE_NAME_LEN ]; | |
925 uint32_t size; | |
926 off_t tot_size; | |
927 off_t parts_size[ 9 ]; | |
928 int nr_parts = 0; | |
929 int n; | |
930 | |
931 if( title == 0 ) | |
932 sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" ); | |
933 else | |
934 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 ); | |
935 | |
936 if( !UDFFindFile( dvd, filename, &size ) ) | |
937 return -1; | |
938 | |
939 tot_size = size; | |
940 nr_parts = 1; | |
941 parts_size[ 0 ] = size; | |
942 | |
943 if( !menu ) { | |
944 int cur; | |
945 | |
946 for( cur = 2; cur < 10; cur++ ) { | |
947 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur ); | |
948 if( !UDFFindFile( dvd, filename, &size ) ) | |
949 break; | |
950 | |
951 parts_size[ nr_parts ] = size; | |
952 tot_size += size; | |
953 nr_parts++; | |
954 } | |
955 } | |
956 | |
957 statbuf->size = tot_size; | |
958 statbuf->nr_parts = nr_parts; | |
959 for( n = 0; n < nr_parts; n++ ) | |
960 statbuf->parts_size[ n ] = parts_size[ n ]; | |
961 | |
962 return 0; | |
963 } | |
964 | |
965 | |
966 static int DVDFileStatVOBPath( dvd_reader_t *dvd, int title, | |
967 int menu, dvd_stat_t *statbuf ) | |
968 { | |
969 char filename[ MAX_UDF_FILE_NAME_LEN ]; | |
970 char full_path[ PATH_MAX + 1 ]; | |
971 struct stat fileinfo; | |
972 off_t tot_size; | |
973 off_t parts_size[ 9 ]; | |
974 int nr_parts = 0; | |
975 int n; | |
976 | |
977 if( title == 0 ) | |
978 sprintf( filename, "VIDEO_TS.VOB" ); | |
979 else | |
980 sprintf( filename, "VTS_%02d_%d.VOB", title, menu ? 0 : 1 ); | |
981 | |
982 if( !findDVDFile( dvd, filename, full_path ) ) | |
983 return -1; | |
984 | |
985 if( stat( full_path, &fileinfo ) < 0 ) { | |
986 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); | |
987 return -1; | |
988 } | |
989 | |
990 tot_size = fileinfo.st_size; | |
991 nr_parts = 1; | |
992 parts_size[ 0 ] = fileinfo.st_size; | |
993 | |
994 if( !menu ) { | |
995 int cur; | |
996 for( cur = 2; cur < 10; cur++ ) { | |
997 sprintf( filename, "VTS_%02d_%d.VOB", title, cur ); | |
998 if( !findDVDFile( dvd, filename, full_path ) ) | |
999 break; | |
1000 | |
1001 if( stat( full_path, &fileinfo ) < 0 ) { | |
1002 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); | |
1003 break; | |
1004 } | |
1005 | |
1006 parts_size[ nr_parts ] = fileinfo.st_size; | |
1007 tot_size += parts_size[ nr_parts ]; | |
1008 nr_parts++; | |
1009 } | |
1010 } | |
1011 | |
1012 statbuf->size = tot_size; | |
1013 statbuf->nr_parts = nr_parts; | |
1014 for( n = 0; n < nr_parts; n++ ) | |
1015 statbuf->parts_size[ n ] = parts_size[ n ]; | |
1016 | |
1017 return 0; | |
1018 } | |
1019 | |
1020 | |
1021 int DVDFileStat( dvd_reader_t *dvd, int titlenum, | |
1022 dvd_read_domain_t domain, dvd_stat_t *statbuf ) | |
1023 { | |
1024 char filename[ MAX_UDF_FILE_NAME_LEN ]; | |
1025 char full_path[ PATH_MAX + 1 ]; | |
1026 struct stat fileinfo; | |
1027 uint32_t size; | |
1028 | |
1029 /* Check arguments. */ | |
1030 if( dvd == NULL || titlenum < 0 ) { | |
1031 errno = EINVAL; | |
1032 return -1; | |
1033 } | |
1034 | |
1035 switch( domain ) { | |
1036 case DVD_READ_INFO_FILE: | |
1037 if( titlenum == 0 ) | |
1038 sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" ); | |
1039 else | |
1040 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum ); | |
1041 | |
1042 break; | |
1043 case DVD_READ_INFO_BACKUP_FILE: | |
1044 if( titlenum == 0 ) | |
1045 sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" ); | |
1046 else | |
1047 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum ); | |
1048 | |
1049 break; | |
1050 case DVD_READ_MENU_VOBS: | |
1051 if( dvd->isImageFile ) | |
1052 return DVDFileStatVOBUDF( dvd, titlenum, 1, statbuf ); | |
1053 else | |
1054 return DVDFileStatVOBPath( dvd, titlenum, 1, statbuf ); | |
1055 | |
1056 break; | |
1057 case DVD_READ_TITLE_VOBS: | |
1058 if( titlenum == 0 ) | |
1059 return -1; | |
1060 | |
1061 if( dvd->isImageFile ) | |
1062 return DVDFileStatVOBUDF( dvd, titlenum, 0, statbuf ); | |
1063 else | |
1064 return DVDFileStatVOBPath( dvd, titlenum, 0, statbuf ); | |
1065 | |
1066 break; | |
1067 default: | |
1068 fprintf( stderr, "libdvdread: Invalid domain for file stat.\n" ); | |
1069 errno = EINVAL; | |
1070 return -1; | |
1071 } | |
1072 | |
1073 if( dvd->isImageFile ) { | |
1074 if( UDFFindFile( dvd, filename, &size ) ) { | |
1075 statbuf->size = size; | |
1076 statbuf->nr_parts = 1; | |
1077 statbuf->parts_size[ 0 ] = size; | |
1078 return 0; | |
1079 } | |
1080 } else { | |
1081 if( findDVDFile( dvd, filename, full_path ) ) { | |
1082 if( stat( full_path, &fileinfo ) < 0 ) | |
1083 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); | |
1084 else { | |
1085 statbuf->size = fileinfo.st_size; | |
1086 statbuf->nr_parts = 1; | |
1087 statbuf->parts_size[ 0 ] = statbuf->size; | |
1088 return 0; | |
1089 } | |
1090 } | |
1091 } | |
1092 return -1; | |
1093 } | |
1094 | |
3 | 1095 /* Internal, but used from dvd_udf.c */ |
1096 int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number, | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1097 size_t block_count, unsigned char *data, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1098 int encrypted ) |
3 | 1099 { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1100 int ret; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1101 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1102 if( !device->dev ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1103 fprintf( stderr, "libdvdread: Fatal error in block read.\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1104 return 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1105 } |
3 | 1106 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1107 ret = dvdinput_seek( device->dev, (int) lb_number ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1108 if( ret != (int) lb_number ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1109 fprintf( stderr, "libdvdread: Can't seek to block %u\n", lb_number ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1110 return 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1111 } |
3 | 1112 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1113 ret = dvdinput_read( device->dev, (char *) data, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1114 (int) block_count, encrypted ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1115 return ret; |
3 | 1116 } |
1117 | |
1118 /* This is using a single input and starting from 'dvd_file->lb_start' offset. | |
1119 * | |
1120 * Reads 'block_count' blocks from 'dvd_file' at block offset 'offset' | |
1121 * into the buffer located at 'data' and if 'encrypted' is set | |
1122 * descramble the data if it's encrypted. Returning either an | |
1123 * negative error or the number of blocks read. */ | |
1124 static int DVDReadBlocksUDF( dvd_file_t *dvd_file, uint32_t offset, | |
26 | 1125 size_t block_count, unsigned char *data, |
1126 int encrypted ) | |
3 | 1127 { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1128 return UDFReadBlocksRaw( dvd_file->dvd, dvd_file->lb_start + offset, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1129 block_count, data, encrypted ); |
3 | 1130 } |
1131 | |
1132 /* This is using possibly several inputs and starting from an offset of '0'. | |
1133 * | |
1134 * Reads 'block_count' blocks from 'dvd_file' at block offset 'offset' | |
1135 * into the buffer located at 'data' and if 'encrypted' is set | |
1136 * descramble the data if it's encrypted. Returning either an | |
1137 * negative error or the number of blocks read. */ | |
1138 static int DVDReadBlocksPath( dvd_file_t *dvd_file, unsigned int offset, | |
26 | 1139 size_t block_count, unsigned char *data, |
1140 int encrypted ) | |
3 | 1141 { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1142 int i; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1143 int ret, ret2, off; |
3 | 1144 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1145 ret = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1146 ret2 = 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1147 for( i = 0; i < TITLES_MAX; ++i ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1148 if( !dvd_file->title_sizes[ i ] ) return 0; /* Past end of file */ |
3 | 1149 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1150 if( offset < dvd_file->title_sizes[ i ] ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1151 if( ( offset + block_count ) <= dvd_file->title_sizes[ i ] ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1152 off = dvdinput_seek( dvd_file->title_devs[ i ], (int)offset ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1153 if( off < 0 || off != (int)offset ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1154 fprintf( stderr, "libdvdread: Can't seek to block %d\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1155 offset ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1156 return off < 0 ? off : 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1157 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1158 ret = dvdinput_read( dvd_file->title_devs[ i ], data, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1159 (int)block_count, encrypted ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1160 break; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1161 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1162 size_t part1_size = dvd_file->title_sizes[ i ] - offset; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1163 /* FIXME: Really needs to be a while loop. |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1164 * (This is only true if you try and read >1GB at a time) */ |
20 | 1165 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1166 /* Read part 1 */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1167 off = dvdinput_seek( dvd_file->title_devs[ i ], (int)offset ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1168 if( off < 0 || off != (int)offset ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1169 fprintf( stderr, "libdvdread: Can't seek to block %d\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1170 offset ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1171 return off < 0 ? off : 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1172 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1173 ret = dvdinput_read( dvd_file->title_devs[ i ], data, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1174 (int)part1_size, encrypted ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1175 if( ret < 0 ) return ret; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1176 /* FIXME: This is wrong if i is the last file in the set. |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1177 * also error from this read will not show in ret. */ |
20 | 1178 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1179 /* Does the next part exist? If not then return now. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1180 if( i + 1 >= TITLES_MAX || !dvd_file->title_devs[ i + 1 ] ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1181 return ret; |
3 | 1182 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1183 /* Read part 2 */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1184 off = dvdinput_seek( dvd_file->title_devs[ i + 1 ], 0 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1185 if( off < 0 || off != 0 ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1186 fprintf( stderr, "libdvdread: Can't seek to block %d\n", |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1187 0 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1188 return off < 0 ? off : 0; |
3 | 1189 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1190 ret2 = dvdinput_read( dvd_file->title_devs[ i + 1 ], |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1191 data + ( part1_size |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1192 * (int64_t)DVD_VIDEO_LB_LEN ), |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1193 (int)(block_count - part1_size), |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1194 encrypted ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1195 if( ret2 < 0 ) return ret2; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1196 break; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1197 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1198 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1199 offset -= dvd_file->title_sizes[ i ]; |
3 | 1200 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1201 } |
3 | 1202 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1203 return ret + ret2; |
3 | 1204 } |
1205 | |
1206 /* This is broken reading more than 2Gb at a time is ssize_t is 32-bit. */ | |
20 | 1207 ssize_t DVDReadBlocks( dvd_file_t *dvd_file, int offset, |
26 | 1208 size_t block_count, unsigned char *data ) |
3 | 1209 { |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1210 int ret; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1211 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1212 /* Check arguments. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1213 if( dvd_file == NULL || offset < 0 || data == NULL ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1214 return -1; |
20 | 1215 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1216 /* Hack, and it will still fail for multiple opens in a threaded app ! */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1217 if( dvd_file->dvd->css_title != dvd_file->css_title ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1218 dvd_file->dvd->css_title = dvd_file->css_title; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1219 if( dvd_file->dvd->isImageFile ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1220 dvdinput_title( dvd_file->dvd->dev, (int)dvd_file->lb_start ); |
3 | 1221 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1222 /* Here each vobu has it's own dvdcss handle, so no need to update |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1223 else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1224 dvdinput_title( dvd_file->title_devs[ 0 ], (int)dvd_file->lb_start ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1225 }*/ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1226 } |
20 | 1227 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1228 if( dvd_file->dvd->isImageFile ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1229 ret = DVDReadBlocksUDF( dvd_file, (uint32_t)offset, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1230 block_count, data, DVDINPUT_READ_DECRYPT ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1231 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1232 ret = DVDReadBlocksPath( dvd_file, (unsigned int)offset, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1233 block_count, data, DVDINPUT_READ_DECRYPT ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1234 } |
20 | 1235 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1236 return (ssize_t)ret; |
3 | 1237 } |
1238 | |
1239 int32_t DVDFileSeek( dvd_file_t *dvd_file, int32_t offset ) | |
1240 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1241 /* Check arguments. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1242 if( dvd_file == NULL || offset < 0 ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1243 return -1; |
20 | 1244 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1245 if( offset > dvd_file->filesize * DVD_VIDEO_LB_LEN ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1246 return -1; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1247 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1248 dvd_file->seek_pos = (uint32_t) offset; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1249 return offset; |
3 | 1250 } |
1251 | |
1252 int DVDFileSeekForce(dvd_file_t *dvd_file, int offset, int force_size) | |
1253 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1254 /* Check arguments. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1255 if( dvd_file == NULL || offset <= 0 ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1256 return -1; |
3 | 1257 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1258 if( dvd_file->dvd->isImageFile ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1259 if( force_size < 0 ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1260 force_size = (offset - 1) / DVD_VIDEO_LB_LEN + 1; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1261 if( dvd_file->filesize < force_size ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1262 dvd_file->filesize = force_size; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1263 fprintf(stderr, "libdvdread: Ignored size of file indicated in UDF.\n"); |
3 | 1264 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1265 } |
3 | 1266 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1267 if( offset > dvd_file->filesize * DVD_VIDEO_LB_LEN ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1268 return -1; |
3 | 1269 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1270 dvd_file->seek_pos = (uint32_t) offset; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1271 return offset; |
3 | 1272 } |
1273 | |
1274 ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size ) | |
1275 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1276 unsigned char *secbuf_base, *secbuf; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1277 unsigned int numsec, seek_sector, seek_byte; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1278 int ret; |
20 | 1279 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1280 /* Check arguments. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1281 if( dvd_file == NULL || data == NULL ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1282 return -1; |
3 | 1283 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1284 seek_sector = dvd_file->seek_pos / DVD_VIDEO_LB_LEN; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1285 seek_byte = dvd_file->seek_pos % DVD_VIDEO_LB_LEN; |
3 | 1286 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1287 numsec = ( ( seek_byte + byte_size ) / DVD_VIDEO_LB_LEN ) + |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1288 ( ( ( seek_byte + byte_size ) % DVD_VIDEO_LB_LEN ) ? 1 : 0 ); |
20 | 1289 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1290 secbuf_base = (unsigned char *) malloc( numsec * DVD_VIDEO_LB_LEN + 2048 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1291 secbuf = (unsigned char *)(((uintptr_t)secbuf_base & ~((uintptr_t)2047)) + 2048); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1292 if( !secbuf_base ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1293 fprintf( stderr, "libdvdread: Can't allocate memory " |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1294 "for file read!\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1295 return 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1296 } |
20 | 1297 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1298 if( dvd_file->dvd->isImageFile ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1299 ret = DVDReadBlocksUDF( dvd_file, (uint32_t) seek_sector, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1300 (size_t) numsec, secbuf, DVDINPUT_NOFLAGS ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1301 } else { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1302 ret = DVDReadBlocksPath( dvd_file, seek_sector, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1303 (size_t) numsec, secbuf, DVDINPUT_NOFLAGS ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1304 } |
3 | 1305 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1306 if( ret != (int) numsec ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1307 free( secbuf_base ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1308 return ret < 0 ? ret : 0; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1309 } |
3 | 1310 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1311 memcpy( data, &(secbuf[ seek_byte ]), byte_size ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1312 free( secbuf_base ); |
3 | 1313 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1314 DVDFileSeekForce(dvd_file, dvd_file->seek_pos + byte_size, -1); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1315 return byte_size; |
3 | 1316 } |
1317 | |
1318 ssize_t DVDFileSize( dvd_file_t *dvd_file ) | |
1319 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1320 /* Check arguments. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1321 if( dvd_file == NULL ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1322 return -1; |
20 | 1323 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1324 return dvd_file->filesize; |
3 | 1325 } |
1326 | |
1327 int DVDDiscID( dvd_reader_t *dvd, unsigned char *discid ) | |
1328 { | |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1329 struct md5_ctx ctx; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1330 int title; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1331 int nr_of_files = 0; |
3 | 1332 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1333 /* Check arguments. */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1334 if( dvd == NULL || discid == NULL ) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1335 return 0; |
20 | 1336 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1337 /* Go through the first 10 IFO:s, in order, |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1338 * and md5sum them, i.e VIDEO_TS.IFO and VTS_0?_0.IFO */ |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1339 md5_init_ctx( &ctx ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1340 for( title = 0; title < 10; title++ ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1341 dvd_file_t *dvd_file = DVDOpenFile( dvd, title, DVD_READ_INFO_FILE ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1342 if( dvd_file != NULL ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1343 ssize_t bytes_read; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1344 size_t file_size = dvd_file->filesize * DVD_VIDEO_LB_LEN; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1345 char *buffer_base = malloc( file_size + 2048 ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1346 char *buffer = (char *)(((uintptr_t)buffer_base & ~((uintptr_t)2047)) + 2048); |
20 | 1347 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1348 if( buffer_base == NULL ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1349 DVDCloseFile( dvd_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1350 fprintf( stderr, "libdvdread: DVDDiscId, failed to " |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1351 "allocate memory for file read!\n" ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1352 return -1; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1353 } |
20 | 1354 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1355 bytes_read = DVDReadBytes( dvd_file, buffer, file_size ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1356 if( bytes_read != file_size ) { |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1357 fprintf( stderr, "libdvdread: DVDDiscId read returned %zd bytes" |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1358 ", wanted %zd\n", bytes_read, file_size ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1359 DVDCloseFile( dvd_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1360 free( buffer_base ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1361 return -1; |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1362 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1363 |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1364 md5_process_bytes( buffer, file_size, &ctx ); |
20 | 1365 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1366 DVDCloseFile( dvd_file ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1367 free( buffer_base ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1368 nr_of_files++; |
3 | 1369 } |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1370 } |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1371 md5_finish_ctx( &ctx, discid ); |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1372 if(!nr_of_files) |
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1373 return -1; |
20 | 1374 |
27
98951f8ec89c
cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents:
26
diff
changeset
|
1375 return 0; |
3 | 1376 } |
1377 | |
1378 | |
1379 int DVDISOVolumeInfo( dvd_reader_t *dvd, | |
26 | 1380 char *volid, unsigned int volid_size, |
1381 unsigned char *volsetid, unsigned int volsetid_size ) | |
3 | 1382 { |
1383 unsigned char *buffer, *buffer_base; | |
1384 int ret; | |
1385 | |
1386 /* Check arguments. */ | |
1387 if( dvd == NULL ) | |
1388 return 0; | |
20 | 1389 |
3 | 1390 if( dvd->dev == NULL ) { |
1391 /* No block access, so no ISO... */ | |
1392 return -1; | |
1393 } | |
20 | 1394 |
3 | 1395 buffer_base = malloc( DVD_VIDEO_LB_LEN + 2048 ); |
1396 buffer = (unsigned char *)(((uintptr_t)buffer_base & ~((uintptr_t)2047)) + 2048); | |
1397 | |
1398 if( buffer_base == NULL ) { | |
1399 fprintf( stderr, "libdvdread: DVDISOVolumeInfo, failed to " | |
26 | 1400 "allocate memory for file read!\n" ); |
3 | 1401 return -1; |
1402 } | |
1403 | |
1404 ret = UDFReadBlocksRaw( dvd, 16, 1, buffer, 0 ); | |
1405 if( ret != 1 ) { | |
1406 fprintf( stderr, "libdvdread: DVDISOVolumeInfo, failed to " | |
26 | 1407 "read ISO9660 Primary Volume Descriptor!\n" ); |
3 | 1408 free( buffer_base ); |
1409 return -1; | |
1410 } | |
20 | 1411 |
3 | 1412 if( (volid != NULL) && (volid_size > 0) ) { |
1413 unsigned int n; | |
1414 for(n = 0; n < 32; n++) { | |
1415 if(buffer[40+n] == 0x20) { | |
26 | 1416 break; |
3 | 1417 } |
1418 } | |
20 | 1419 |
3 | 1420 if(volid_size > n+1) { |
1421 volid_size = n+1; | |
1422 } | |
1423 | |
1424 memcpy(volid, &buffer[40], volid_size-1); | |
1425 volid[volid_size-1] = '\0'; | |
1426 } | |
20 | 1427 |
3 | 1428 if( (volsetid != NULL) && (volsetid_size > 0) ) { |
1429 if(volsetid_size > 128) { | |
1430 volsetid_size = 128; | |
1431 } | |
1432 memcpy(volsetid, &buffer[190], volsetid_size); | |
1433 } | |
1434 free( buffer_base ); | |
1435 return 0; | |
1436 } | |
1437 | |
1438 | |
1439 int DVDUDFVolumeInfo( dvd_reader_t *dvd, | |
26 | 1440 char *volid, unsigned int volid_size, |
1441 unsigned char *volsetid, unsigned int volsetid_size ) | |
3 | 1442 { |
1443 int ret; | |
1444 /* Check arguments. */ | |
1445 if( dvd == NULL ) | |
1446 return -1; | |
20 | 1447 |
3 | 1448 if( dvd->dev == NULL ) { |
1449 /* No block access, so no UDF VolumeSet Identifier */ | |
1450 return -1; | |
1451 } | |
20 | 1452 |
3 | 1453 if( (volid != NULL) && (volid_size > 0) ) { |
1454 ret = UDFGetVolumeIdentifier(dvd, volid, volid_size); | |
1455 if(!ret) { | |
1456 return -1; | |
1457 } | |
1458 } | |
1459 if( (volsetid != NULL) && (volsetid_size > 0) ) { | |
1460 ret = UDFGetVolumeSetIdentifier(dvd, volsetid, volsetid_size); | |
1461 if(!ret) { | |
1462 return -1; | |
1463 } | |
1464 } | |
20 | 1465 |
1466 return 0; | |
3 | 1467 } |