changeset 45:3307493f20c5 src

Add *BSD porting bits from 0.9.7 Both version 0.9.6 and 0.9.7 had some porting code put in for the *BSDs. This code is untested by me, but I bet the OpenSolaris and *BSD folk would love to have it.
author erik
date Wed, 02 Sep 2009 01:44:16 +0000
parents 92b4694792da
children 4f40782ab5fc
files dvd_reader.c
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/dvd_reader.c	Wed Sep 02 01:43:21 2009 +0000
+++ b/dvd_reader.c	Wed Sep 02 01:44:16 2009 +0000
@@ -309,12 +309,18 @@
 
 #if defined(SYS_BSD)
 /* FreeBSD /dev/(r)(a)cd0c (a is for atapi), recommended to _not_ use r
+   update: FreeBSD and DragonFly no longer uses the prefix so don't add it.
    OpenBSD /dev/rcd0c, it needs to be the raw device
    NetBSD  /dev/rcd0[d|c|..] d for x86, c (for non x86), perhaps others
    Darwin  /dev/rdisk0,  it needs to be the raw device
-   BSD/OS  /dev/sr0c (if not mounted) or /dev/rsr0c ('c' any letter will do) */
+   BSD/OS  /dev/sr0c (if not mounted) or /dev/rsr0c ('c' any letter will do)
+   returns a string allocated with strdup. It should be freed when no longer
+   used. */
 static char *bsd_block2char( const char *path )
 {
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+  return (char *) strdup( path );
+#else
   char *new_path;
 
   /* If it doesn't start with "/dev/" or does start with "/dev/r" exit */
@@ -327,6 +333,7 @@
   strcat( new_path, path + strlen( "/dev/" ) );
 
   return new_path;
+#endif /* __FreeBSD__ || __DragonFly__ */
 }
 #endif
 
@@ -389,17 +396,18 @@
     /**
      * Block devices and regular files are assumed to be DVD-Video images.
      */
+    dvd_reader_t *dvd = NULL;
 #if defined(__sun)
-    ret_val = DVDOpenImageFile( sun_block2char( path ), have_css );
+    dev_name = sun_block2char( path );
 #elif defined(SYS_BSD)
-    ret_val = DVDOpenImageFile( bsd_block2char( path ), have_css );
+    dev_name = bsd_block2char( path );
 #else
-    ret_val = DVDOpenImageFile( path, have_css );
+    dev_name = strdup( path );
 #endif
-
+    dvd = DVDOpenImageFile( dev_name, have_css );
+    free( dev_name );
     free(path);
-    return ret_val;
-
+    return dvd;
   } else if( S_ISDIR( fileinfo.st_mode ) ) {
     dvd_reader_t *auth_drive = 0;
 #if defined(SYS_BSD)