[libdvdcss-devel] [PATCH 23/47] dvd_region: Use dvdcss_open() instead of plain open() to access DVD drives

Diego Biurrun diego at biurrun.de
Wed Oct 29 21:33:23 CET 2014


---
 test/dvd_region.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/test/dvd_region.c b/test/dvd_region.c
index 1488dab..3cbfe3f 100644
--- a/test/dvd_region.c
+++ b/test/dvd_region.c
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "common.h"
 #include "ioctl.h"
+#include "libdvdcss.h"
 #include "ioctl.c"
 
 #define DEFAULT_DEVICE "/dev/dvd"
@@ -226,7 +227,8 @@ static void usage(void)
 int main(int argc, char *argv[])
 {
   char device_name[FILENAME_MAX], c, set, region = 0;
-  int fd, ret;
+  int ret;
+  dvdcss_t dvdcss;
 
   strcpy(device_name, DEFAULT_DEVICE);
   set = 0;
@@ -257,21 +259,18 @@ int main(int argc, char *argv[])
     return -1;
   }
 
-  /* TODO: use dvdcss_open instead of open */
-
-  if( (fd = open(device_name, O_RDONLY | O_NONBLOCK)) < 0 ) {
-    perror("open");
+  if( !(dvdcss = dvdcss_open(device_name)) ) {
     usage();
     return 1;
   }
 
   {
     int copyright;
-    ret = ioctl_ReadCopyright( fd, 0, &copyright );
+    ret = ioctl_ReadCopyright( dvdcss->i_fd, 0, &copyright );
     printf( "ret %d, copyright %d\n", ret, copyright );
   }
 
-  if( (ret = print_region(fd)) < 0 )
+  if( (ret = print_region(dvdcss->i_fd)) < 0 )
     return ret;
 
   if( set ) {
@@ -280,7 +279,7 @@ int main(int argc, char *argv[])
       exit(0);
     }
 
-    if( (ret = set_region(fd, region)) < 0 )
+    if( (ret = set_region(dvdcss->i_fd, region)) < 0 )
       return ret;
   }
 
-- 
1.9.1



More information about the libdvdcss-devel mailing list