diff -ur libdvdnav/Makefile.am libdvdnav.new/Makefile.am
--- libdvdnav/Makefile.am	2004-10-26 18:26:07.000000000 +0100
+++ libdvdnav.new/Makefile.am	2005-11-28 16:19:13.343750000 +0000
@@ -2,7 +2,7 @@
 
 AUTOMAKE_OPTIONS = 1.3
 
-SUBDIRS = src examples doc misc m4
+SUBDIRS = src misc m4
 
 EXTRA_DIST = autogen.sh \
 	     AUTHORS \
diff -ur libdvdnav/src/dvdnav.c libdvdnav.new/src/dvdnav.c
--- libdvdnav/src/dvdnav.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/dvdnav.c	2005-11-28 16:19:13.328125000 +0000
@@ -31,7 +31,6 @@
 
 #include "dvdnav_internal.h"
 #include "read_cache.h"
-#include "nav_read.h"
 
 #include <stdlib.h>
 #include <stdio.h>
diff -ur libdvdnav/src/dvdnav.h libdvdnav.new/src/dvdnav.h
--- libdvdnav/src/dvdnav.h	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/dvdnav.h	2005-11-28 16:19:13.328125000 +0000
@@ -33,16 +33,19 @@
 extern "C" {
 #endif
 
+#include <inttypes.h>
+
+#include <dvdread/dvd_reader.h>
+#include <dvdread/nav_types.h>
+#include <dvdread/nav_read.h>
+#include <dvdread/ifo_types.h> /* For vm_cmd_t */
+
 #ifdef DVDNAV_COMPILE
 #  include "dvdnav_events.h"
 #  include "dvd_types.h"
-#  include "dvd_reader.h"
-#  include "ifo_types.h" /* For vm_cmd_t */
 #else
 #  include <dvdnav/dvdnav_events.h>
 #  include <dvdnav/dvd_types.h>
-#  include <dvdnav/dvd_reader.h>
-#  include <dvdnav/ifo_types.h> /* For vm_cmd_t */
 #endif
 
 
diff -ur libdvdnav/src/dvdnav_events.h libdvdnav.new/src/dvdnav_events.h
--- libdvdnav/src/dvdnav_events.h	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/dvdnav_events.h	2005-11-28 16:19:13.328125000 +0000
@@ -28,10 +28,6 @@
 #ifndef DVDNAV_EVENTS_H_INCLUDED
 #define DVDNAV_EVENTS_H_INCLUDED
 
-#include "ifo_types.h"
-#include "dvd_reader.h"
-#include "nav_types.h"
-
 
 /*
  * DVDNAV_BLOCK_OK
diff -ur libdvdnav/src/dvdread/Makefile.am libdvdnav.new/src/dvdread/Makefile.am
--- libdvdnav/src/dvdread/Makefile.am	2004-05-19 19:31:11.000000000 +0100
+++ libdvdnav.new/src/dvdread/Makefile.am	2005-12-01 22:26:05.078125000 +0000
@@ -1,10 +1,10 @@
 include $(top_srcdir)/misc/Makefile.common
 
-includedir = ${prefix}/include/dvdnav
+includedir = ${prefix}/include/dvdread
 
 AM_CPPFLAGS = -DDVDNAV_COMPILE -I$(top_srcdir)/src/vm
 
-noinst_LTLIBRARIES = libdvdread.la
+lib_LTLIBRARIES = libdvdread.la
 
 libdvdread_la_SOURCES = dvd_reader.c nav_read.c ifo_read.c \
 	dvd_input.c dvd_udf.c md5.c nav_print.c ifo_print.c \
diff -ur libdvdnav/src/dvdread/bswap.h libdvdnav.new/src/dvdread/bswap.h
--- libdvdnav/src/dvdread/bswap.h	2004-01-11 21:43:13.000000000 +0000
+++ libdvdnav.new/src/dvdread/bswap.h	2005-12-01 21:55:20.328125000 +0000
@@ -65,7 +65,7 @@
  * functionality! 
  */
 
-#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__CYGWIN__)
+#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__CYGWIN__) || defined(__BEOS__)
 #define B2N_16(x) \
  x = ((((x) & 0xff00) >> 8) | \
       (((x) & 0x00ff) << 8))
@@ -75,14 +75,14 @@
       (((x) & 0x0000ff00) <<  8) | \
       (((x) & 0x000000ff) << 24))
 #define B2N_64(x) \
- x = ((((x) & 0xff00000000000000) >> 56) | \
-      (((x) & 0x00ff000000000000) >> 40) | \
-      (((x) & 0x0000ff0000000000) >> 24) | \
-      (((x) & 0x000000ff00000000) >>  8) | \
-      (((x) & 0x00000000ff000000) <<  8) | \
-      (((x) & 0x0000000000ff0000) << 24) | \
-      (((x) & 0x000000000000ff00) << 40) | \
-      (((x) & 0x00000000000000ff) << 56))
+ x = ((((x) & 0xff00000000000000LL) >> 56) | \
+      (((x) & 0x00ff000000000000LL) >> 40) | \
+      (((x) & 0x0000ff0000000000LL) >> 24) | \
+      (((x) & 0x000000ff00000000LL) >>  8) | \
+      (((x) & 0x00000000ff000000LL) <<  8) | \
+      (((x) & 0x0000000000ff0000LL) << 24) | \
+      (((x) & 0x000000000000ff00LL) << 40) | \
+      (((x) & 0x00000000000000ffLL) << 56))
 
 #else
 
diff -ur libdvdnav/src/dvdread/dvd_input.c libdvdnav.new/src/dvdread/dvd_input.c
--- libdvdnav/src/dvdread/dvd_input.c	2004-04-09 13:15:26.000000000 +0100
+++ libdvdnav.new/src/dvdread/dvd_input.c	2005-11-30 23:07:47.140625000 +0000
@@ -21,12 +21,24 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+
+#if defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#elif defined(HAVE_STDINT_H)
+#include <stdint.h>
+#endif
+
 #include <fcntl.h>
 #include <unistd.h>
 
 #include "dvd_reader.h"
 #include "dvd_input.h"
 
+#ifdef WIN32
+#   define lseek _lseeki64
+#   undef off_t
+#   define off_t int64_t
+#endif
 
 /* The function pointers that is the exported interface of this file. */
 dvd_input_t (*dvdinput_open)  (const char *);
diff -ur libdvdnav/src/dvdread/dvd_reader.c libdvdnav.new/src/dvdread/dvd_reader.c
--- libdvdnav/src/dvdread/dvd_reader.c	2004-09-12 16:18:16.000000000 +0100
+++ libdvdnav.new/src/dvdread/dvd_reader.c	2005-12-01 22:19:07.750000000 +0000
@@ -347,9 +347,7 @@
 	}
 #endif
     
-    ret = stat( path, &fileinfo );
-
-    if( ret < 0 ) {
+    if( *path && (ret = stat( path, &fileinfo ) < 0) ) {
 
         /* maybe "host:port" url? try opening it with acCeSS library */
         if( strchr(path,':') ) {
@@ -366,7 +364,7 @@
     }
 
     /* First check if this is a block/char device or a file*/
-    if( S_ISBLK( fileinfo.st_mode ) || 
+    if( !*path || S_ISBLK( fileinfo.st_mode ) || 
 	S_ISCHR( fileinfo.st_mode ) || 
 	S_ISREG( fileinfo.st_mode ) ) {
 
@@ -404,14 +402,15 @@
 
 	/* Resolve any symlinks and get the absolut dir name. */
 	{
+		char *current_path;
 	    char *new_path;
-	    int cdir = open( ".", O_RDONLY );
-	    
-	    if( cdir >= 0 ) {
+	   
+		current_path = getcwd( NULL, PATH_MAX );
+		if( current_path ) {
 		chdir( path_copy );
 		new_path = getcwd( NULL, PATH_MAX );
-		fchdir( cdir );
-		close( cdir );
+		chdir( current_path );
+		free( current_path );
 		if( new_path ) {
 		    free( path_copy );
 		    path_copy = new_path;
@@ -586,10 +585,12 @@
             sprintf( filename, "%s%s%s", path,
                      ( ( path[ strlen( path ) - 1 ] == '/' ) ? "" : "/" ),
                      ent->d_name );
+            closedir( dir );
             return 0;
         }
     }
 
+    closedir( dir );
     return -1;
 }
 
diff -ur libdvdnav/src/highlight.c libdvdnav.new/src/highlight.c
--- libdvdnav/src/highlight.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/highlight.c	2005-11-28 16:19:13.343750000 +0000
@@ -26,7 +26,6 @@
 #endif
 
 #include <assert.h>
-#include "nav_types.h"
 #include "dvdnav_internal.h"
 
 /*
diff -ur libdvdnav/src/remap.c libdvdnav.new/src/remap.c
--- libdvdnav/src/remap.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/remap.c	2005-11-28 16:19:13.343750000 +0000
@@ -189,7 +189,11 @@
     remap_t *map;
 
     /* Build the map filename */
-    home = getenv("HOME"); assert(home);
+    home = getenv("HOME");
+    if (!home) {
+	fprintf(MSG_OUT, "libdvdnav: Unable to find map for title '%s'\n", title);
+	return NULL;
+    }
     strncpy(fname, home, sizeof(fname));
     strncat(fname, "/.dvdnav/", sizeof(fname));
     strncat(fname, title, sizeof(fname));
diff -ur libdvdnav/src/vm/decoder.c libdvdnav.new/src/vm/decoder.c
--- libdvdnav/src/vm/decoder.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/vm/decoder.c	2005-11-28 16:19:13.343750000 +0000
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <inttypes.h>
 #include <string.h>  /* For memset */
-#include "ifo_types.h" /* vm_cmd_t */
 
 #include "dvdnav_internal.h"
 
diff -ur libdvdnav/src/vm/decoder.h libdvdnav.new/src/vm/decoder.h
--- libdvdnav/src/vm/decoder.h	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/vm/decoder.h	2005-11-28 16:19:13.343750000 +0000
@@ -28,7 +28,7 @@
 #include <inttypes.h>
 #include <sys/time.h>
 
-#include "ifo_types.h" /*  vm_cmd_t */
+#include <dvdread/ifo_types.h> /*  vm_cmd_t */
 #include "dvdnav_internal.h"
 
 /* link command types */
diff -ur libdvdnav/src/vm/vm.c libdvdnav.new/src/vm/vm.c
--- libdvdnav/src/vm/vm.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/vm/vm.c	2005-11-28 16:19:13.343750000 +0000
@@ -38,13 +38,17 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include "ifo_types.h"
-#include "ifo_read.h"
+/* from dvdread */
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
 
 #include "dvdnav_internal.h"
 
 #ifdef _MSC_VER
 #include <io.h>   /* read() */
+#elif defined(WIN32)
+#   define lseek _lseeki64
+#   define off_t int64_t
 #endif /* _MSC_VER */
 
 /*
--- libdvdnav/misc/dvdnav-config.in	2003-04-27 02:26:17.000000000 +0100
+++ libdvdnav.new/misc/dvdnav-config.in	2005-12-02 09:29:48.265625000 +0000
@@ -76,5 +76,5 @@
 fi
 
 if test "$echo_libs" = "yes"; then
-      echo -L@libdir@ -ldvdnav @THREAD_LIBS@
+      echo -L@libdir@ -ldvdnav -ldvdread @THREAD_LIBS@
 fi      
--- libdvdnav/configure.ac	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/configure.ac	2005-12-02 15:23:13.921875000 +0000
@@ -138,7 +138,7 @@
     THREAD_CFLAGS="-I/usr/local/include -D_THREAD_SAFE"
     CFLAGS="$THREAD_CFLAGS $CFLAGS"
     ;;
-  *mingw32* | *cygwin*)
+  *mingw32* | *cygwin* | *beos*)
     ;;
   *)
     AC_CHECK_LIB(pthread, pthread_create,
@@ -149,26 +149,63 @@
 AC_SUBST(THREAD_LIBS)
 AC_SUBST(THREAD_CFLAGS)
 
+link_dvdcss=no
+dvdcss_path=""
 dnl ---------------------------------------------
-dnl dynamic linker
+dnl dvdcss checking
 dnl ---------------------------------------------
-case $host in
-  *mingw32*)
-    CFLAGS="-idirafter \$(top_srcdir)/msvc/include $CFLAGS"
-    LDFLAGS="-no-undefined $LDFLAGS"
-    ;;
-  *cygwin*)
-    LDFLAGS="-no-undefined $LDFLAGS"
-    ;;
-  *)
-    AC_CHECK_LIB(c, dlopen,
-	         DYNAMIC_LD_LIBS="",
-	         AC_CHECK_LIB(dl, dlopen,
-             	              DYNAMIC_LD_LIBS="-ldl",
-	                      AC_MSG_ERROR(dynamic linker needed)))
-    AC_SUBST(DYNAMIC_LD_LIBS)
-    ;;
-esac
+AC_ARG_WITH( [libdvdcss],
+    [ --with-libdvdcss[=PATH]    force linking against libdvdcss],
+    [if test x"$withval" != xno; then
+       link_dvdcss=yes
+     fi
+     if test x"$withval" != xyes; then
+       dvdcss_path=$withval
+     fi])
+
+if test x"$link_dvdcss" != xyes; then
+dnl dlopen libdvdcss
+  AC_CHECK_FUNC( dlopen,
+    [DL_LIBS="" ].
+    AC_CHECK_LIB( dl, dlopen,
+      [DL_LIBS=-ld ],
+      AC_MSG_ERROR(You need libdl (dlopen))
+    )
+  )
+else
+dnl link with libdvdcss
+  if test -z "$dvdcss_path"; then
+    AC_CHECK_LIB(dvdcss, dvdcss_interface_2,
+      [ CSS_LIBS=-ldvdcss ],
+      AC_MSG_ERROR(You need libdvdcss.so.2 or later)
+    )
+    AC_CHECK_HEADERS(dvdcss/dvdcss.h,
+      [ ],
+      AC_MSG_ERROR(You need libdvdcss (dvdcss.h))
+    )
+  else
+    saved_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -L$dvdcss_path/lib"
+    AC_CHECK_LIB(dvdcss, dvdcss_interface_2,
+      [ CSS_LIBS="-L$dvdcss_path/lib -R$dvdcss_path/lib -ldvdcss"
+        CSS_CFLAGS=-I$dvdcss_path/include ],
+      AC_MSG_ERROR(You need libdvdcss.so.2 or later)
+    )
+    CFLAGS=$saved_CFLAGS
+    dnl -w added to shutup GCC3.1's cpp warning about -I/usr/local
+    saved_CPPFLAGS=$CPPFLAGS
+    CPPFLAGS="-w $CPPFLAGS -I$dvdcss_path/include"
+    AC_CHECK_HEADERS(dvdcss/dvdcss.h,
+      [ ],
+      AC_MSG_ERROR(You need libdvdcss (dvdcss.h))
+    )
+    CPPFLAGS=$saved_CPPFLAGS
+  fi
+fi
+
+AC_SUBST(DL_LIBS)
+AC_SUBST(CSS_LIBS)
+AC_SUBST(CSS_CFLAGS)
 
 dnl ---------------------------------------------
 dnl cflags
--- libdvdnav/src/dvdnav_internal.h	2005-02-11 12:25:11.000000000 +0000
+++ libdvdnav.new/src/dvdnav_internal.h	2005-12-02 15:29:35.250000000 +0000
@@ -59,6 +59,15 @@
 #include <io.h> /* read() */
 #define lseek64 _lseeki64
 
+#elif defined(__BEOS__)
+
+#include <OS.h>
+typedef sem_id pthread_mutex_t;
+#define pthread_mutex_init(a, b) (*a) = create_sem( 1,"" )
+#define pthread_mutex_lock(a)    acquire_sem( *a )
+#define pthread_mutex_unlock(a)  release_sem( *a )
+#define pthread_mutex_destroy(a) delete_sem( *a )
+
 #else
 
 #include <pthread.h>
--- libdvdnav/examples/Makefile.am	2004-01-11 21:43:12.000000000 +0000
+++ libdvdnav.new/examples/Makefile.am	2005-12-02 15:24:58.671875000 +0000
@@ -7,7 +7,7 @@
 noinst_PROGRAMS = menus
 
 menus_SOURCES = menus.c
-menus_LDFLAGS = -L$(top_srcdir)/src/
+menus_LDFLAGS = -L$(top_srcdir)/src/ $(CSS_LIBS)
 menus_LDADD   = $(DVDNAV_LIB)
 
 $(DVDNAV_LIB):
