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

Diego Biurrun <[email protected]>
Newsgroups gmane.comp.video.videolan.libdvdcss,gmane.comp.video.videolan.libdvdcss.devel
Message-ID <[email protected]>
---
 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

_______________________________________________
libdvdcss-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/libdvdcss-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.