[PATCH] libdvdread BeOS port + bugfix
Eric Petit <[email protected]> Sat, 12 Mar 2005 10:37:23 +0100
| Newsgroups | gmane.comp.video.ogle.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi there, Here is a patch for libdvdread againt current CVS. Most of the changes are compile fixes for BeOS 5 (I've actually been using a patched libdvdread for years in the BeOS port of VLC, and I realize now that BeOS has never been "officially" supported). The changes are: - dvdread/bswap.h: define B2N_16/B2N_32/B2N_64 on BeOS - dvdread/dvd_reader.c, DVDOpen(): make the symlink resolution without fchdir() since BeOS doesn't have it, but it has a working chdir() and getcwd() - dvdread/dvd_reader.c, findDirFile(): added the missing closedir() call. I figured it was missing when I got "Too many open files" errors after many calls to libdvdread - dvdread/ifo_types.h: checking for inttypes.h and stdint.h with UINT8_MAX/UINT16_MAX/INT32_MAX is only reliable with recent systems since those aren't required before C99 (and BeOS doesn't define them). I would check for _INTTYPES_H_ / _INTTYPES_H / _STDINT_H_ / _STDINT_H instead, although I can't guarantee it is fully reliable either (it works at least with Linux, OS X, BeOS and MinGW) -- Eric Petit <[email protected]>
libdvdread-20050312.patch
(application/octet-stream, 2.2 KB)
diff -ru libdvdread-orig/dvdread/bswap.h libdvdread/dvdread/bswap.h
--- libdvdread-orig/dvdread/bswap.h Wed Jun 18 13:35:03 2003
+++ libdvdread/dvdread/bswap.h Sat Mar 12 09:13:16 2005
@@ -75,7 +75,7 @@
* functionality!
*/
-#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32)
+#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__BEOS__)
#define B2N_16(x) \
x = ((((x) & 0xff00) >> 8) | \
(((x) & 0x00ff) << 8))
diff -ru libdvdread-orig/dvdread/dvd_reader.c libdvdread/dvdread/dvd_reader.c
--- libdvdread-orig/dvdread/dvd_reader.c Tue Aug 5 12:44:11 2003
+++ libdvdread/dvdread/dvd_reader.c Sat Mar 12 09:24:55 2005
@@ -364,17 +364,17 @@
/* XXX: We should scream real loud here. */
if( !(path_copy = strdup( path ) ) ) return 0;
-#ifndef WIN32 /* don't have fchdir, and getcwd( NULL, ... ) is strange */
+#ifndef WIN32 /* getcwd( NULL, ... ) is strange */
/* 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;
@@ -528,10 +528,12 @@
sprintf( filename, "%s%s%s", path,
( ( path[ strlen( path ) - 1 ] == '/' ) ? "" : "/" ),
ent->d_name );
+ closedir( dir );
return 0;
}
}
+ closedir( dir );
return -1;
}
diff -ru libdvdread-orig/dvdread/ifo_types.h libdvdread/dvdread/ifo_types.h
--- libdvdread-orig/dvdread/ifo_types.h Thu Apr 15 22:33:52 2004
+++ libdvdread/dvdread/ifo_types.h Sat Mar 12 09:31:12 2005
@@ -22,7 +22,7 @@
#include <dvdread/dvd_reader.h>
-#if !defined(UINT8_MAX) || !defined(UINT16_MAX) || !defined(INT32_MAX)
+#if !defined(_INTTYPES_H_) && !defined(_INTTYPES_H) && !defined(_STDINT_H_) && !defined(_STDINT_H)
#error "Must include <inttypes.h> or <stdint.h> before any libdvdread header."
#endif