14861
|
1 --- bsdi_ioctl.c 2003-03-10 00:34:10.000000000 +0100
|
|
2 +++ bsdi_ioctl.c 2005-03-01 07:41:41.000000000 +0100
|
|
3 @@ -694,7 +698,7 @@
|
|
4 struct cdrom_tocentry entry;
|
|
5 int ret, i;
|
|
6
|
|
7 - bzero(tracks, sizeof (*tracks));
|
|
8 + memset(tracks, 0, sizeof (*tracks));
|
|
9 ret = cdrom_ioctl(fd, CDROMREADTOCHDR, &header);
|
|
10 /*
|
|
11 * This whole business is a crock anyhow so we don't bother distinguishing
|
|
12 --- common.h 2003-06-13 19:33:35.000000000 +0200
|
|
13 +++ common.h 2005-03-01 07:41:41.000000000 +0100
|
|
14 @@ -27,21 +30,10 @@
|
|
15 /*****************************************************************************
|
|
16 * Basic types definitions
|
|
17 *****************************************************************************/
|
|
18 -#if defined( HAVE_STDINT_H )
|
|
19 -# include <stdint.h>
|
|
20 -#elif defined( HAVE_INTTYPES_H )
|
|
21 -# include <inttypes.h>
|
|
22 -#elif defined( SYS_CYGWIN )
|
|
23 -# include <sys/types.h>
|
|
24 - /* Cygwin only defines half of these... */
|
|
25 - typedef u_int8_t uint8_t;
|
|
26 - typedef u_int32_t uint32_t;
|
|
27 -#else
|
|
28 - /* Fallback types (very x86-centric, sorry) */
|
|
29 - typedef unsigned char uint8_t;
|
|
30 - typedef signed char int8_t;
|
|
31 - typedef unsigned int uint32_t;
|
|
32 - typedef signed int int32_t;
|
|
33 +#include <inttypes.h>
|
|
34 +
|
|
35 +#ifdef __CYGWIN__
|
|
36 +#define SYS_CYGWIN
|
|
37 #endif
|
|
38
|
|
39 #if defined( WIN32 )
|
|
40 --- css.c 2003-07-29 01:37:06.000000000 +0200
|
|
41 +++ css.c 2005-03-01 07:41:41.000000000 +0100
|
|
42 @@ -40,19 +43,11 @@
|
|
43 #include <string.h>
|
|
44 #include <sys/types.h>
|
|
45 #include <sys/stat.h>
|
|
46 -#ifdef HAVE_SYS_PARAM_H
|
|
47 -# include <sys/param.h>
|
|
48 -#endif
|
|
49 -#ifdef HAVE_UNISTD_H
|
|
50 -# include <unistd.h>
|
|
51 -#endif
|
|
52 #include <fcntl.h>
|
|
53 +#include <unistd.h>
|
|
54 +#include <limits.h>
|
|
55
|
|
56 -#ifdef HAVE_LIMITS_H
|
|
57 -# include <limits.h>
|
|
58 -#endif
|
|
59 -
|
|
60 -#include "dvdcss/dvdcss.h"
|
|
61 +#include "dvdcss.h"
|
|
62
|
|
63 #include "common.h"
|
|
64 #include "css.h"
|
|
65 --- device.c 2003-07-29 01:37:06.000000000 +0200
|
|
66 +++ device.c 2005-03-01 07:41:41.000000000 +0100
|
|
67 @@ -33,18 +36,9 @@
|
|
68 #include <string.h>
|
|
69 #include <sys/types.h>
|
|
70 #include <sys/stat.h>
|
|
71 -#ifdef HAVE_SYS_PARAM_H
|
|
72 -# include <sys/param.h>
|
|
73 -#endif
|
|
74 #include <fcntl.h>
|
|
75 -
|
|
76 -#ifdef HAVE_UNISTD_H
|
|
77 -# include <unistd.h>
|
|
78 -#endif
|
|
79 -
|
|
80 -#ifdef HAVE_LIMITS_H
|
|
81 -# include <limits.h>
|
|
82 -#endif
|
|
83 +#include <unistd.h>
|
|
84 +#include <limits.h>
|
|
85
|
|
86 #if defined( WIN32 ) && !defined( SYS_CYGWIN )
|
|
87 # include <io.h> /* read() */
|
|
88 @@ -52,7 +46,7 @@
|
|
89 # include <sys/uio.h> /* struct iovec */
|
|
90 #endif
|
|
91
|
|
92 -#include "dvdcss/dvdcss.h"
|
|
93 +#include "dvdcss.h"
|
|
94
|
|
95 #include "common.h"
|
|
96 #include "css.h"
|
|
97 @@ -143,8 +137,11 @@
|
|
98 _dvdcss_debug( dvdcss, psz_debug );
|
|
99
|
|
100 #if defined( WIN32 )
|
|
101 - /* If device is not "X:", we are actually opening a file. */
|
|
102 - dvdcss->b_file = !psz_device[0] || psz_device[1] != ':' || psz_device[2];
|
|
103 + dvdcss->b_file = 1;
|
|
104 + /* If device is "X:" or "X:\", we are not actually opening a file. */
|
|
105 + if (psz_device[0] && psz_device[1] == ':' &&
|
|
106 + (!psz_device[2] || (psz_device[2] == '\\' && !psz_device[3])))
|
|
107 + dvdcss->b_file = 0;
|
|
108
|
|
109 /* Initialize readv temporary buffer */
|
|
110 dvdcss->p_readv_buffer = NULL;
|
|
111 --- error.c 2003-03-10 01:15:31.000000000 +0100
|
|
112 +++ error.c 2005-03-01 07:41:41.000000000 +0100
|
|
113 @@ -25,16 +28,9 @@
|
|
114
|
|
115 #include <stdio.h>
|
|
116 #include <stdlib.h>
|
|
117 +#include <limits.h>
|
|
118
|
|
119 -#ifdef HAVE_SYS_PARAM_H
|
|
120 -# include <sys/param.h>
|
|
121 -#endif
|
|
122 -
|
|
123 -#ifdef HAVE_LIMITS_H
|
|
124 -# include <limits.h>
|
|
125 -#endif
|
|
126 -
|
|
127 -#include "dvdcss/dvdcss.h"
|
|
128 +#include "dvdcss.h"
|
|
129
|
|
130 #include "common.h"
|
|
131 #include "css.h"
|
|
132 --- ioctl.c 2003-03-10 00:34:10.000000000 +0100
|
|
133 +++ ioctl.c 2005-03-01 07:41:41.000000000 +0100
|
|
134 @@ -76,6 +79,7 @@
|
|
135 # include <sys/scsi.h>
|
|
136 #endif
|
|
137 #ifdef SOLARIS_USCSI
|
|
138 +# include <dlfcn.h>
|
|
139 # include <unistd.h>
|
|
140 # include <stropts.h>
|
|
141 # include <sys/scsi/scsi_types.h>
|
|
142 @@ -112,6 +116,7 @@
|
|
143 *****************************************************************************/
|
|
144 #if defined( SOLARIS_USCSI )
|
|
145 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type );
|
|
146 +static int SolarisSendUSCSI( int fd, struct uscsi_cmd *p_sc );
|
|
147 #endif
|
|
148
|
|
149 /*****************************************************************************
|
|
150 @@ -192,7 +197,7 @@
|
|
151 rs_cdb.cdb_opaque[ 6 ] = i_layer;
|
|
152 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_COPYRIGHT;
|
|
153
|
|
154 - i_ret = ioctl(i_fd, USCSICMD, &sc);
|
|
155 + i_ret = SolarisSendUSCSI(i_fd, &sc);
|
|
156
|
|
157 if( i_ret < 0 || sc.uscsi_status ) {
|
|
158 i_ret = -1;
|
|
159 @@ -351,7 +356,7 @@
|
|
160 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY;
|
|
161 rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6;
|
|
162
|
|
163 - i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
164 + i_ret = SolarisSendUSCSI( i_fd, &sc );
|
|
165
|
|
166 if( i_ret < 0 || sc.uscsi_status )
|
|
167 {
|
|
168 @@ -513,7 +518,7 @@
|
|
169 rs_cdb.cdb_opaque[ 5 ] = ( i_pos ) & 0xff;
|
|
170 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
|
|
171
|
|
172 - i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
173 + i_ret = SolarisSendUSCSI( i_fd, &sc );
|
|
174
|
|
175 if( i_ret < 0 || sc.uscsi_status )
|
|
176 {
|
|
177 @@ -665,7 +670,7 @@
|
|
178
|
|
179 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
|
|
180
|
|
181 - i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
182 + i_ret = SolarisSendUSCSI( i_fd, &sc );
|
|
183
|
|
184 if( i_ret < 0 || sc.uscsi_status )
|
|
185 {
|
|
186 @@ -787,7 +792,7 @@
|
|
187
|
|
188 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
|
|
189
|
|
190 - i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
191 + i_ret = SolarisSendUSCSI( i_fd, &sc );
|
|
192
|
|
193 if( i_ret < 0 || sc.uscsi_status )
|
|
194 {
|
|
195 @@ -921,7 +926,7 @@
|
|
196
|
|
197 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF;
|
|
198
|
|
199 - i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
200 + i_ret = SolarisSendUSCSI( i_fd, &sc );
|
|
201
|
|
202 if( i_ret < 0 || sc.uscsi_status )
|
|
203 {
|
|
204 @@ -1054,7 +1059,7 @@
|
|
205
|
|
206 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
|
|
207
|
|
208 - i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
209 + i_ret = SolarisSendUSCSI( i_fd, &sc );
|
|
210
|
|
211 if( i_ret < 0 || sc.uscsi_status )
|
|
212 {
|
|
213 @@ -1175,7 +1180,7 @@
|
|
214
|
|
215 rs_cdb.cdb_opaque[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
|
|
216
|
|
217 - i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
218 + i_ret = SolarisSendUSCSI( i_fd, &sc );
|
|
219
|
|
220 if( i_ret < 0 || sc.uscsi_status )
|
|
221 {
|
|
222 @@ -1299,7 +1304,7 @@
|
|
223 p_buffer[ 1 ] = 0xe;
|
|
224 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
|
|
225
|
|
226 - if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
|
|
227 + if( SolarisSendUSCSI( i_fd, &sc ) < 0 || sc.uscsi_status )
|
|
228 {
|
|
229 return -1;
|
|
230 }
|
|
231 @@ -1436,7 +1441,7 @@
|
|
232 p_buffer[ 1 ] = 0xa;
|
|
233 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
|
|
234
|
|
235 - if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
|
|
236 + if( SolarisSendUSCSI( i_fd, &sc ) < 0 || sc.uscsi_status )
|
|
237 {
|
|
238 return -1;
|
|
239 }
|
|
240 @@ -1578,7 +1583,7 @@
|
|
241
|
|
242 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_RPC;
|
|
243
|
|
244 - i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
245 + i_ret = SolarisSendUSCSI( i_fd, &sc );
|
|
246
|
|
247 if( i_ret < 0 || sc.uscsi_status )
|
|
248 {
|
|
249 @@ -1728,7 +1733,7 @@
|
|
250 p_buffer[ 1 ] = 6;
|
|
251 p_buffer[ 4 ] = i_pdrc;
|
|
252
|
|
253 - i_ret = ioctl( i_fd, USCSICMD, &sc );
|
|
254 + i_ret = SolarisSendUSCSI( i_fd, &sc );
|
|
255
|
|
256 if( i_ret < 0 || sc.uscsi_status )
|
|
257 {
|
|
258 @@ -1901,6 +1906,54 @@
|
|
259
|
|
260 USCSI_TIMEOUT( p_sc, 15 );
|
|
261 }
|
|
262 +
|
|
263 +/*****************************************************************************
|
|
264 + * SolarisSendUSCSI: send a USCSICMD structure to the Solaris kernel
|
|
265 + * for execution
|
|
266 + *****************************************************************************
|
|
267 + * When available, this function uses the function smedia_uscsi_cmd()
|
|
268 + * from solaris' libsmedia library (solaris 9 or newer) to execute the
|
|
269 + * USCSI command. smedia_uscsi_cmd() allows USCSI commands for
|
|
270 + * non-root users on removable media devices on solaris 9; sending the
|
|
271 + * USCSI command directly to the device using the USCSICMD ioctl fails
|
|
272 + * with an EPERM error on solaris 9.
|
|
273 + *
|
|
274 + * The code will fall back to the USCSICMD ioctl method, when
|
|
275 + * libsmedia.so is not available or does not export the
|
|
276 + * smedia_uscsi_cmd() function (on solaris releases upto and including
|
|
277 + * solaris 8). Fortunatelly, on these old releases non-root users are
|
|
278 + * allowed to perform USCSICMD ioctls on removable media devices.
|
|
279 + *****************************************************************************/
|
|
280 +static int SolarisSendUSCSI( int i_fd, struct uscsi_cmd *p_sc ) {
|
|
281 + void *sm_hdl;
|
|
282 + static int initialized;
|
|
283 + static void* (*sm_get_handle)(int32_t);
|
|
284 + static int (*sm_release_handle)(void*);
|
|
285 + static int (*sm_uscsi_cmd)(void*, struct uscsi_cmd *);
|
|
286 +
|
|
287 + if (!initialized)
|
|
288 + {
|
|
289 + void *smedia_lib;
|
|
290 +
|
|
291 + smedia_lib = dlopen("libsmedia.so", RTLD_NOW);
|
|
292 + if (smedia_lib) {
|
|
293 + sm_get_handle = dlsym(smedia_lib, "smedia_get_handle");
|
|
294 + sm_release_handle = dlsym(smedia_lib, "smedia_release_handle");
|
|
295 + sm_uscsi_cmd = dlsym(smedia_lib, "smedia_uscsi_cmd");
|
|
296 + }
|
|
297 + initialized = 1;
|
|
298 + }
|
|
299 +
|
|
300 + if (sm_get_handle && sm_uscsi_cmd && sm_release_handle
|
|
301 + && (sm_hdl = sm_get_handle(i_fd)))
|
|
302 + {
|
|
303 + int i_ret = sm_uscsi_cmd(sm_hdl, p_sc);
|
|
304 + sm_release_handle(sm_hdl);
|
|
305 + return i_ret;
|
|
306 + }
|
|
307 +
|
|
308 + return ioctl( i_fd, USCSICMD, p_sc );
|
|
309 +}
|
|
310 #endif
|
|
311
|
|
312 #if defined( WIN32 )
|
|
313 --- libdvdcss.c 2003-06-22 16:08:53.000000000 +0200
|
|
314 +++ libdvdcss.c 2005-03-01 07:41:41.000000000 +0100
|
|
315 @@ -22,7 +25,7 @@
|
|
316 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
|
317 */
|
|
318
|
|
319 -/**
|
|
320 +/*
|
|
321 * \mainpage libdvdcss developer documentation
|
|
322 *
|
|
323 * \section intro Introduction
|
|
324 @@ -87,10 +90,7 @@
|
|
325 * values. This will speed up descrambling of DVDs which are in the
|
|
326 * cache. The DVDCSS_CACHE directory is created if it does not exist,
|
|
327 * and a subdirectory is created named after the DVD's title or
|
|
328 - * manufacturing date. If DVDCSS_CACHE is not set or is empty, \e libdvdcss
|
|
329 - * will use the default value which is "${HOME}/.dvdcss/" under Unix and
|
|
330 - * "C:\Documents and Settings\$USER\Application Data\dvdcss\" under Win32.
|
|
331 - * The special value "off" disables caching.
|
|
332 + * manufacturing date.
|
|
333 */
|
|
334
|
|
335 /*
|
|
336 @@ -103,28 +103,12 @@
|
|
337 #include <string.h>
|
|
338 #include <sys/types.h>
|
|
339 #include <sys/stat.h>
|
|
340 -#ifdef HAVE_SYS_PARAM_H
|
|
341 -# include <sys/param.h>
|
|
342 -#endif
|
|
343 -#ifdef HAVE_PWD_H
|
|
344 -# include <pwd.h>
|
|
345 -#endif
|
|
346 #include <fcntl.h>
|
|
347 #include <errno.h>
|
|
348 +#include <unistd.h>
|
|
349 +#include <limits.h>
|
|
350
|
|
351 -#ifdef HAVE_UNISTD_H
|
|
352 -# include <unistd.h>
|
|
353 -#endif
|
|
354 -
|
|
355 -#ifdef HAVE_LIMITS_H
|
|
356 -# include <limits.h>
|
|
357 -#endif
|
|
358 -
|
|
359 -#ifdef HAVE_DIRECT_H
|
|
360 -# include <direct.h>
|
|
361 -#endif
|
|
362 -
|
|
363 -#include "dvdcss/dvdcss.h"
|
|
364 +#include "dvdcss.h"
|
|
365
|
|
366 #include "common.h"
|
|
367 #include "css.h"
|
|
368 @@ -132,6 +116,12 @@
|
|
369 #include "ioctl.h"
|
|
370 #include "device.h"
|
|
371
|
|
372 +#ifndef HAVE_MPLAYER
|
|
373 + #include "get_path.c"
|
|
374 +#else
|
|
375 + extern char * get_path( char * filename );
|
|
376 +#endif
|
|
377 +
|
|
378 /**
|
|
379 * \brief Symbol for version checks.
|
|
380 *
|
|
381 @@ -234,87 +224,11 @@
|
|
382 }
|
|
383
|
|
384 /*
|
|
385 - * If DVDCSS_CACHE was not set, try to guess a default value
|
|
386 - */
|
|
387 - if( psz_cache == NULL || psz_cache[0] == '\0' )
|
|
388 - {
|
|
389 -#ifdef HAVE_DIRECT_H
|
|
390 - typedef HRESULT( WINAPI *SHGETFOLDERPATH )
|
|
391 - ( HWND, int, HANDLE, DWORD, LPTSTR );
|
|
392 -
|
|
393 -# define CSIDL_FLAG_CREATE 0x8000
|
|
394 -# define CSIDL_APPDATA 0x1A
|
|
395 -# define SHGFP_TYPE_CURRENT 0
|
|
396 -
|
|
397 - char psz_home[MAX_PATH];
|
|
398 - HINSTANCE p_dll;
|
|
399 - SHGETFOLDERPATH p_getpath;
|
|
400 -
|
|
401 - *psz_home = '\0';
|
|
402 -
|
|
403 - /* Load the shfolder dll to retrieve SHGetFolderPath */
|
|
404 - p_dll = LoadLibrary( "shfolder.dll" );
|
|
405 - if( p_dll )
|
|
406 - {
|
|
407 - p_getpath = (void*)GetProcAddress( p_dll, "SHGetFolderPathA" );
|
|
408 - if( p_getpath )
|
|
409 - {
|
|
410 - /* Get the "Application Data" folder for the current user */
|
|
411 - if( p_getpath( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
|
|
412 - NULL, SHGFP_TYPE_CURRENT, psz_home ) == S_OK )
|
|
413 - {
|
|
414 - FreeLibrary( p_dll );
|
|
415 - }
|
|
416 - else
|
|
417 - {
|
|
418 - *psz_home = '\0';
|
|
419 - }
|
|
420 - }
|
|
421 - FreeLibrary( p_dll );
|
|
422 - }
|
|
423 -
|
|
424 - /* Cache our keys in
|
|
425 - * C:\Documents and Settings\$USER\Application Data\dvdcss\ */
|
|
426 - if( *psz_home )
|
|
427 - {
|
|
428 - snprintf( psz_buffer, PATH_MAX, "%s/dvdcss", psz_home );
|
|
429 - psz_buffer[PATH_MAX-1] = '\0';
|
|
430 - psz_cache = psz_buffer;
|
|
431 - }
|
|
432 -#else
|
|
433 - char *psz_home = NULL;
|
|
434 -# ifdef HAVE_PWD_H
|
|
435 - struct passwd *p_pwd;
|
|
436 -
|
|
437 - /* Try looking in password file for home dir. */
|
|
438 - p_pwd = getpwuid(getuid());
|
|
439 - if( p_pwd )
|
|
440 - {
|
|
441 - psz_home = p_pwd->pw_dir;
|
|
442 - }
|
|
443 -# endif
|
|
444 -
|
|
445 - if( psz_home == NULL )
|
|
446 - {
|
|
447 - psz_home = getenv( "HOME" );
|
|
448 - }
|
|
449 -
|
|
450 - /* Cache our keys in ${HOME}/.dvdcss/ */
|
|
451 - if( psz_home )
|
|
452 - {
|
|
453 - snprintf( psz_buffer, PATH_MAX, "%s/.dvdcss", psz_home );
|
|
454 - psz_buffer[PATH_MAX-1] = '\0';
|
|
455 - psz_cache = psz_buffer;
|
|
456 - }
|
|
457 -#endif
|
|
458 - }
|
|
459 -
|
|
460 - /*
|
|
461 * Find cache dir from the DVDCSS_CACHE environment variable
|
|
462 */
|
|
463 if( psz_cache != NULL )
|
|
464 {
|
|
465 - if( psz_cache[0] == '\0' || !strcmp( psz_cache, "off" ) )
|
|
466 + if( psz_cache[0] == '\0' )
|
|
467 {
|
|
468 psz_cache = NULL;
|
|
469 }
|
|
470 @@ -325,6 +239,7 @@
|
|
471 psz_cache = NULL;
|
|
472 }
|
|
473 }
|
|
474 + else psz_cache = get_path( "DVDKeys" );
|
|
475
|
|
476 /*
|
|
477 * Open device
|
|
478 @@ -465,9 +380,10 @@
|
|
479 dvdcss->psz_cachefile[0] = '\0';
|
|
480 goto nocache;
|
|
481 }
|
|
482 + i += sprintf( dvdcss->psz_cachefile + i, "/");
|
|
483
|
|
484 - i += sprintf( dvdcss->psz_cachefile + i, "/%s#%s", psz_title,
|
|
485 - psz_serial );
|
|
486 +// i += sprintf( dvdcss->psz_cachefile + i, "/%s", psz_data );
|
|
487 + i += sprintf( dvdcss->psz_cachefile + i, "/%s#%s", psz_title, psz_serial );
|
|
488 #if !defined( WIN32 ) || defined( SYS_CYGWIN )
|
|
489 i_ret = mkdir( dvdcss->psz_cachefile, 0755 );
|
|
490 #else
|
|
491 --- dvdcss/dvdcss.h 2003-04-18 20:05:36.000000000 +0200
|
|
492 +++ dvdcss.h 2005-03-01 07:41:41.000000000 +0100
|
|
493 @@ -67,6 +70,8 @@
|
|
494 */
|
|
495 extern dvdcss_t dvdcss_open ( char *psz_target );
|
|
496 extern int dvdcss_close ( dvdcss_t );
|
|
497 +extern int dvdcss_title ( dvdcss_t,
|
|
498 + int i_block );
|
|
499 extern int dvdcss_seek ( dvdcss_t,
|
|
500 int i_blocks,
|
|
501 int i_flags );
|