[Mplayer-cvslog] CVS: main unrarlib.c,NONE,1.1 unrarlib.h,NONE,1.1 Makefile,1.214,1.215 configure,1.568,1.569 vobsub.c,1.19,1.20

Kim Minh Kaplan CVS kmkaplan at mplayerhq.hu
Fri Sep 20 03:26:53 CEST 2002


Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv5896

Modified Files:
	Makefile configure vobsub.c 
Added Files:
	unrarlib.c unrarlib.h 
Log Message:
Automatic unrar of vobsub.  Does not work with rar v3


--- NEW FILE ---
/* ***************************************************************************
 **
 **  This file is part of the UniquE RAR File Library.
 **
 **  Copyright (C) 2000-2002 by Christian Scheurer (www.ChristianScheurer.ch)
 **  UNIX port copyright (c) 2000-2002 by Johannes Winkelmann (jw at tks6.net)
 **
 **  The contents of this file are subject to the UniquE RAR File Library
 **  License (the "unrarlib-license.txt"). You may not use this file except
 **  in compliance with the License. You may obtain a copy of the License
 **  at http://www.unrarlib.org/license.html.
 **  Software distributed under the License is distributed on an "AS IS"
 **  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied warranty.
 **
 **  Alternatively, the contents of this file may be used under the terms
 **  of the GNU General Public License Version 2 or later (the "GPL"), in
 **  which case the provisions of the GPL are applicable instead of those
 **  above. If you wish to allow use of your version of this file only
 **  under the terms of the GPL and not to allow others to use your version
[...2677 lines suppressed...]

  if((fp = fopen(log_file_name, APPENDTEXT)) != NULL) /* append to logfile  */

  {
    fprintf(fp, " %8u ms (line %u in %s):\n              - %s\n",
            (unsigned int)(GetTickCount() - debug_start_time),
            sourceline, sourcefile, text);
    fclose(fp);
  }
}

/* ------------------------------------------------------------------------ */
#endif
/* **************************************************************************
 ****************************************************************************
 ****************************************************************************
 ************************************************************************** */


/* end of file urarlib.c */

--- NEW FILE ---
/* ***************************************************************************
 **
 **  This file is part of the UniquE RAR File Library.
 **
 **  Copyright (C) 2000-2002 by Christian Scheurer (www.ChristianScheurer.ch)
 **  UNIX port copyright (c) 2000-2002 by Johannes Winkelmann (jw at tks6.net)
 **
 **  The contents of this file are subject to the UniquE RAR File Library
 **  License (the "unrarlib-license.txt"). You may not use this file except
 **  in compliance with the License. You may obtain a copy of the License
 **  at http://www.unrarlib.org/license.html.
 **  Software distributed under the License is distributed on an "AS IS"
 **  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied warranty.
 **
 **  Alternatively, the contents of this file may be used under the terms
 **  of the GNU General Public License Version 2 or later (the "GPL"), in
 **  which case the provisions of the GPL are applicable instead of those
 **  above. If you wish to allow use of your version of this file only
 **  under the terms of the GPL and not to allow others to use your version
 **  of this file under the terms of the UniquE RAR File Library License,
 **  indicate your decision by deleting the provisions above and replace
 **  them with the notice and other provisions required by the GPL. If you
 **  do not delete the provisions above, a recipient may use your version
 **  of this file under the terms of the GPL or the UniquE RAR File Library
 **  License.
 **
 ************************************************************************** */

/* include file for the "UniquE RAR File Library"  */
/* (C) 2000-2002 by Christian Scheurer aka. UniquE */
/* multi-OS version (Win32, Linux and SUN)         */

#ifndef __URARLIB_H
#define __URARLIB_H

#ifdef __cplusplus
extern "C"
{
#endif


/* ************************************************************************ */
/* ************************************************************************ */
/* **                                                                    ** */
/* **   CONFIGURATION of the UniquE RAR FileLib                          ** */
/* **   ==> you may change the setting for the lib HERE!                 ** */
/* **                                                                    ** */
/* ************************************************************************ */
/* ************************************************************************ */


#define _DEBUG_LOG                          /* generate debug messages      */

#define _DO_CRC32_CHECK                     /* perform cyclical redundancy  */
                                            /* check (CRC32) - disable this */
                                            /* for a little speed-up        */
/*#define _USE_ASM*/                            /*
                                             * enable assembly extensions
                                             * x86 cpus.
                                             */

/*#define _USE_MEMORY_TO_MEMORY_DECOMPRESSION*/ /* read file from memory or a   */
                                            /* resource instead of reading  */
                                            /* from a file. NOTE: you wont't*/
                                            /*  be able to decompress from  */
                                            /*  file if you enable this     */
                                            /*  option!                     */


#ifdef WIN32                                /* autodetect Win32 and Linux   */
#define _WIN_32                             /* Win32 with VisualC           */
#define _DEBUG_LOG_FILE "C:\\temp\\debug_unrar.txt" /* log file path        */
#else
#define _UNIX                               /* Linux or Unix with GCC       */
#define _DEBUG_LOG_FILE "/tmp/debug_unrar.txt" /* log file path             */
/*#define NON_INTEL_BYTE_ORDER*/               /* GCC on motorola systems    */

#endif

/* ------------------------------------------------------------------------ */



/* -- global type definitions --------------------------------------------- */

#ifdef NON_INTEL_BYTE_ORDER
#ifdef _USE_ASM
#warning Disabling assembly because NON_INTEL_BYTE_ORDER is set
#undef _USE_ASM
#endif
#endif

#ifdef _WIN_32
typedef unsigned char    UBYTE;             /* WIN32 definitions            */
typedef unsigned short   UWORD;
typedef unsigned long    UDWORD;
#endif

#ifdef _UNIX                                /* LINUX/UNIX definitions       */
typedef unsigned char    UBYTE;
typedef unsigned short   UWORD;
typedef unsigned long    UDWORD;
#endif


/* This structure is used for listing archive content                       */
struct RAR20_archive_entry                  /* These infos about files are  */
{                                           /* stored in RAR v2.0 archives  */
  char   *Name;
  UWORD  NameSize;
  UDWORD PackSize;
  UDWORD UnpSize;
  UBYTE  HostOS;                            /* MSDOS=0,OS2=1,WIN32=2,UNIX=3 */
  UDWORD FileCRC;
  UDWORD FileTime;
  UBYTE  UnpVer;
  UBYTE  Method;
  UDWORD FileAttr;
};

typedef struct  archivelist                 /* used to list archives        */
{
  struct RAR20_archive_entry item;
  struct archivelist         *next;
} ArchiveList_struct;


#ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION
typedef struct  memory_file                 /* used to decompress files in  */
{                                           /* memory                       */
  void                       *data;         /* pointer to the file data     */
  unsigned long              size;          /* total size of the file data  */
  unsigned long              offset;        /* offset within "memory-file"  */
} MemoryFile;
#endif

/* -- global functions ---------------------------------------------------- */

/* urarlib_get:
 * decompresses and decrypt data from a RAR file to a buffer in system memory.
 *
 *   input: *output         pointer to an empty char*. This pointer will show
 *                          to the extracted data
 *          *size           shows where to write the size of the decompressed
 *                          file
 *                          (**NOTE: URARLib _does_ memory allocation etc.!**)
 *          *filename       pointer to string containing the file to decompress
 *          *rarfile        pointer to a string with the full name and path of
 *                          the RAR file or pointer to a RAR file in memory if
 *                          memory-to-memory decompression is active.
 *          *libpassword    pointer to a string with the password used to
 *                          en-/decrypt the RAR
 *   output: int            returns TRUE on success or FALSE on error
 *                          (FALSE=0, TRUE=1)
 */

extern int urarlib_get(void  *output,
                       unsigned long *size,
                       char *filename,
                       void *rarfile,
                       char *libpassword);



/* urarlib_list:
 * list the content of a RAR archive.
 *
 *   input: *rarfile        pointer to a string with the full name and path of
 *                          the RAR file or pointer to a RAR file in memory if
 *                          memory-to-memory decompression is active.
 *          *list           pointer to an ArchiveList_struct that can be
 *                          filled with details about the archive
 *                          to the extracted data
 *   output: int            number of files/directories within archive
 */

extern int urarlib_list(void *rarfile, ArchiveList_struct *list);


/* urarlib_freelist:
 * (after the suggestion and code of Duy Nguyen, Sean O'Blarney
 * and Johannes Winkelmann who independently wrote a patch)
 * free the memory of a ArchiveList_struct created by urarlib_list.
 *
 *    input: *list          pointer to an ArchiveList_struct
 *    output: -
 */

extern void urarlib_freelist(ArchiveList_struct *list);

/* ------------------------------------------------------------------------ */



#ifdef __cplusplus
};
#endif

#endif


Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.214
retrieving revision 1.215
diff -u -r1.214 -r1.215
--- Makefile	9 Sep 2002 11:47:54 -0000	1.214
+++ Makefile	20 Sep 2002 01:26:38 -0000	1.215
@@ -55,6 +55,10 @@
 PARTS += Gui
 endif
 
+ifeq ($(UNRARLIB),yes)
+SRCS_COMMON += unrarlib.c
+endif
+
 ifneq ($(W32_LIB),)
 PARTS += loader loader/dshow
 endif

Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.568
retrieving revision 1.569
diff -u -r1.568 -r1.569
--- configure	17 Sep 2002 19:47:55 -0000	1.568
+++ configure	20 Sep 2002 01:26:39 -0000	1.569
@@ -149,6 +149,7 @@
   --disable-css          Disable old-style libcss DVD support [autodetect]
   --disable-cdparanoia   Disable cdparanoia support [autodetect]
   --enable-freetype      Enable freetype2 font rendering support [disabled]
+  --disable-unrarlib     Disable Unique RAR File Library [enabled]
 
 Codecs:
   --enable-gif		 enable gif89a output support [autodetect]
@@ -965,6 +966,7 @@
 _sunaudio=auto
 _alsa=auto
 _fastmemcpy=yes
+_unrarlib=yes
 _win32=auto
 _dshow=yes
 _select=yes
@@ -1159,6 +1161,8 @@
   --disable-big-endian) _big_endian=no  ;;
   --enable-freetype)    _freetype=yes   ;;
   --disable-freetype)   _freetype=no    ;;
+  --enable-unralib)	_unrarlib=yes	;;
+  --disable-unrarlib)	_unrarlib=no	;;
 
   --enable-dga) _dga=auto ;; # as we don't know if it's 1 or 2
   --enable-dga=*) _dga=`echo $ac_option | cut -d '=' -f 2` ;;
@@ -3960,6 +3964,13 @@
 fi
 echores "$_fastmemcpy"
 
+echocheck "UniquE RAR File Library"
+if test "$_unrarlib" = yes ; then
+    _def_unrarlib='#define USE_UNRARLIB 1'
+else
+    _def_unrarlib='#undef USE_UNRARLIB'
+fi
+echores "$_unrarlib"
 
 echocheck "TV interface"
 if test "$_tv" = yes ; then
@@ -4343,6 +4354,8 @@
 
 OPENDIVX = $_opendivx
 
+UNRARLIB = $_unrarlib
+
 PNG = $_mkf_png
 JPEG = $_mkf_jpg
 GIF = $_mkf_gif
@@ -4658,6 +4671,9 @@
 
 /* Use 3dnow/mmxext/sse/mmx optimized fast memcpy() [maybe buggy... signal 4]*/
 $_def_fastmemcpy
+
+/* Use unrarlib for Vobsubs */
+$_def_unrarlib
 
 /* gui support, please do not edit this option */
 $_def_gui

Index: vobsub.c
===================================================================
RCS file: /cvsroot/mplayer/main/vobsub.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- vobsub.c	16 Sep 2002 15:31:34 -0000	1.19
+++ vobsub.c	20 Sep 2002 01:26:39 -0000	1.20
@@ -2,10 +2,10 @@
  * Some code freely inspired from VobSub <URL:http://vobsub.edensrising.com>,
  * with kind permission from Gabest <gabest at freemail.hu>
  */
-/* #define HAVE_GETLINE */
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -21,6 +21,9 @@
 #include "libvo/video_out.h"
 #include "spudec.h"
 #include "mp_msg.h"
+#ifdef USE_UNRARLIB
+#include "unrarlib.h"
+#endif
 
 #define MIN(a, b)	((a)<(b)?(a):(b))
 #define MAX(a, b)	((a)>(b)?(a):(b))
@@ -29,13 +32,172 @@
 
 extern int verbose;
 
-#ifdef HAVE_GETLINE
-extern ssize_t getline(char **, size_t *, FILE *);
+/**********************************************************************
+ * RAR stream handling
+ * The RAR file must have the same basename as the file to open
+ * See <URL:http://www.unrarlib.org/>
+ **********************************************************************/
+#ifdef USE_UNRARLIB
+typedef struct {
+    FILE *file;
+    unsigned char *data;
+    unsigned long size;
+    unsigned long pos;
+} rar_stream_t;
+static rar_stream_t *
+rar_open(const char *const filename, const char *const mode)
+{
+    rar_stream_t *stream;
+    /* unrarlib can only read */
+    if (strcmp("r", mode) && strcmp("rb", mode)) {
+	errno = EINVAL;
+	return NULL;
+    }
+    stream = malloc(sizeof(rar_stream_t));
+    if (stream == NULL)
+	return NULL;
+    /* first try normal access */
+    stream->file = fopen(filename, mode);
+    if (stream->file == NULL) {
+	char *rar_filename;
+	char *p;
+	int rc;
+	/* Guess the RAR archive filename */
+	rar_filename = NULL;
+	p = strrchr(filename, '.');
+	if (p) {
+	    ptrdiff_t l = p - filename;
+	    rar_filename = malloc(l + 5);
+	    if (rar_filename == NULL) {
+		free(stream);
+		return NULL;
+	    }
+	    strncpy(rar_filename, filename, l);
+	    strcpy(rar_filename + l, ".rar");
+	}
+	else {
+	    rar_filename = malloc(strlen(filename) + 5);
+	    if (rar_filename == NULL) {
+		free(stream);
+		return NULL;
+	    }
+	    strcpy(rar_filename, filename);
+	    strcat(rar_filename, ".rar");
+	}
+	rc = urarlib_get(&stream->data, &stream->size, (char*) filename, rar_filename, "");
+	free(rar_filename);
+	if (!rc) {
+	    free(stream);
+	    return NULL;
+	}
+	stream->pos = 0;
+    }
+    return stream;
+}
+
+static int
+rar_close(rar_stream_t *stream)
+{
+    if (stream->file)
+	return fclose(stream->file);
+    free(stream->data);
+    return 0;
+}
+
+static int
+rar_eof(rar_stream_t *stream)
+{
+    if (stream->file)
+	return feof(stream->file);
+    return stream->pos >= stream->size;
+}
+
+static long
+rar_tell(rar_stream_t *stream)
+{
+    if (stream->file)
+	return ftell(stream->file);
+    return stream->pos;
+}
+
+static int
+rar_seek(rar_stream_t *stream, long offset, int whence)
+{
+    if (stream->file)
+	return fseek(stream->file, offset, whence);
+    switch (whence) {
+    case SEEK_SET:
+	if (offset < 0) {
+	    errno = EINVAL;
+	    return -1;
+	}
+	stream->pos = offset;
+	break;
+    case SEEK_CUR:
+	if (offset < 0 && stream->pos < (unsigned long) -offset) {
+	    errno = EINVAL;
+	    return -1;
+	}
+	stream->pos += offset;
+	break;
+    case SEEK_END:
+	if (offset < 0 && stream->size < (unsigned long) -offset) {
+	    errno = EINVAL;
+	    return -1;
+	}
+	stream->pos = stream->size + offset;
+	break;
+    default:
+	errno = EINVAL;
+	return -1;
+    }
+    return 0;
+}
+
+static int
+rar_getc(rar_stream_t *stream)
+{
+    if (stream->file)
+	return getc(stream->file);
+    if (rar_eof(stream))
+	return EOF;
+    return stream->data[stream->pos++];
+}
+
+static size_t
+rar_read(void *ptr, size_t size, size_t nmemb, rar_stream_t *stream)
+{
+    size_t res;
+    unsigned long remain;
+    if (stream->file)
+	return fread(ptr, size, nmemb, stream->file);
+    if (rar_eof(stream))
+	return 0;
+    res = size * nmemb;
+    remain = stream->size - stream->pos;
+    if (res > remain)
+	res = remain / size * size;
+    memcpy(ptr, stream->data + stream->pos, res);
+    stream->pos += res;
+    res /= size;
+    return res;
+}
+
 #else
-/* FIXME This should go into a general purpose library or even a
-   separate file. */
+typedef FILE rar_stream_t;
+#define rar_open	fopen
+#define rar_close	fclose
+#define rar_eof		feof
+#define rar_tell	ftell
+#define rar_seek	fseek
+#define rar_getc	getc
+#define rar_read	fread
+#endif
+
+/**********************************************************************/
+
 static ssize_t
-getline (char **lineptr, size_t *n, FILE *stream)
+getline(char **lineptr, size_t *n, rar_stream_t *stream)
 {
     size_t res = 0;
     int c;
@@ -54,7 +216,7 @@
     if (*lineptr == NULL || *n == 0)
 	return -1;
 
-    for (c = fgetc(stream); c != EOF; c = fgetc(stream)) {
+    for (c = rar_getc(stream); c != EOF; c = rar_getc(stream)) {
 	if (res + 1 >= *n) {
 	    char *tmp = realloc(*lineptr, *n * 2);
 	    if (tmp == NULL)
@@ -73,14 +235,13 @@
     (*lineptr)[res] = 0;
     return res;
 }
-#endif
 
 /**********************************************************************
  * MPEG parsing
  **********************************************************************/
 
 typedef struct {
-    FILE *stream;
+    rar_stream_t *stream;
     unsigned int pts;
     int aid;
     unsigned char *packet;
@@ -99,7 +260,7 @@
 	res->packet = NULL;
 	res->packet_size = 0;
 	res->packet_reserve = 0;
-	res->stream = fopen(filename, "r");
+	res->stream = rar_open(filename, "r");
 	err = res->stream == NULL;
 	if (err)
 	    perror("fopen Vobsub file failed");
@@ -115,20 +276,20 @@
     if (mpeg->packet)
 	free(mpeg->packet);
     if (mpeg->stream)
-	fclose(mpeg->stream);
+	rar_close(mpeg->stream);
     free(mpeg);
 }
 
 static int
 mpeg_eof(mpeg_t *mpeg)
 {
-    return feof(mpeg->stream);
+    return rar_eof(mpeg->stream);
 }
 
 static off_t
 mpeg_tell(mpeg_t *mpeg)
 {
-    return ftell(mpeg->stream);
+    return rar_tell(mpeg->stream);
 }
 
 static int
@@ -142,10 +303,10 @@
 
     mpeg->aid = -1;
     mpeg->packet_size = 0;
-    if (fread(buf, 4, 1, mpeg->stream) != 1)
+    if (rar_read(buf, 4, 1, mpeg->stream) != 1)
 	return -1;
     while (memcmp(buf, wanted, sizeof(wanted)) != 0) {
-	c = getc(mpeg->stream);
+	c = rar_getc(mpeg->stream);
 	if (c < 0)
 	    return -1;
 	memmove(buf, buf + 1, 3);
@@ -155,7 +316,7 @@
     case 0xb9:			/* System End Code */
 	break;
     case 0xba:			/* Packet start code */
-	c = getc(mpeg->stream);
+	c = rar_getc(mpeg->stream);
 	if (c < 0)
 	    return -1;
 	if ((c & 0xc0) == 0x40)
@@ -167,28 +328,28 @@
 	    return -1;
 	}
 	if (version == 4) {
-	    if (fseek(mpeg->stream, 9, SEEK_CUR))
+	    if (rar_seek(mpeg->stream, 9, SEEK_CUR))
 		return -1;
 	}
 	else if (version == 2) {
-	    if (fseek(mpeg->stream, 7, SEEK_CUR))
+	    if (rar_seek(mpeg->stream, 7, SEEK_CUR))
 		return -1;
 	}
 	else
 	    abort();
 	break;
     case 0xbd:			/* packet */
-	if (fread(buf, 2, 1, mpeg->stream) != 1)
+	if (rar_read(buf, 2, 1, mpeg->stream) != 1)
 	    return -1;
 	len = buf[0] << 8 | buf[1];
 	idx = mpeg_tell(mpeg);
-	c = getc(mpeg->stream);
+	c = rar_getc(mpeg->stream);
 	if (c < 0)
 	    return -1;
 	if ((c & 0xC0) == 0x40) { /* skip STD scale & size */
-	    if (getc(mpeg->stream) < 0)
+	    if (rar_getc(mpeg->stream) < 0)
 		return -1;
-	    c = getc(mpeg->stream);
+	    c = rar_getc(mpeg->stream);
 	    if (c < 0)
 		return -1;
 	}
@@ -202,11 +363,11 @@
 	}
 	else if ((c & 0xc0) == 0x80) { /* System-2 (.VOB) stream */
 	    unsigned int pts_flags, hdrlen, dataidx;
-	    c = getc(mpeg->stream);
+	    c = rar_getc(mpeg->stream);
 	    if (c < 0)
 		return -1;
 	    pts_flags = c;
-	    c = getc(mpeg->stream);
+	    c = rar_getc(mpeg->stream);
 	    if (c < 0)
 		return -1;
 	    hdrlen = c;
@@ -217,7 +378,7 @@
 		return -1;
 	    }
 	    if ((pts_flags & 0xc0) == 0x80) {
-		if (fread(buf, 5, 1, mpeg->stream) != 1)
+		if (rar_read(buf, 5, 1, mpeg->stream) != 1)
 		    return -1;
 		if (!(((buf[0] & 0xf0) == 0x20) && (buf[0] & 1) && (buf[2] & 1) &&  (buf[4] & 1))) {
 		    mp_msg(MSGT_VOBSUB,MSGL_ERR, "vobsub PTS error: 0x%02x %02x%02x %02x%02x \n",
@@ -232,8 +393,8 @@
 		/* what's this? */
 		/* abort(); */
 	    }
-	    fseek(mpeg->stream, dataidx, SEEK_SET);
-	    mpeg->aid = getc(mpeg->stream);
+	    rar_seek(mpeg->stream, dataidx, SEEK_SET);
+	    mpeg->aid = rar_getc(mpeg->stream);
 	    if (mpeg->aid < 0) {
 		mp_msg(MSGT_VOBSUB,MSGL_ERR, "Bogus aid %d\n", mpeg->aid);
 		return -1;
@@ -252,7 +413,7 @@
 		mpeg->packet_size = 0;
 		return -1;
 	    }
-	    if (fread(mpeg->packet, mpeg->packet_size, 1, mpeg->stream) != 1) {
+	    if (rar_read(mpeg->packet, mpeg->packet_size, 1, mpeg->stream) != 1) {
 		mp_msg(MSGT_VOBSUB,MSGL_ERR,"fread failure");
 		mpeg->packet_size = 0;
 		return -1;
@@ -261,19 +422,19 @@
 	}
 	break;
     case 0xbe:			/* Padding */
-	if (fread(buf, 2, 1, mpeg->stream) != 1)
+	if (rar_read(buf, 2, 1, mpeg->stream) != 1)
 	    return -1;
 	len = buf[0] << 8 | buf[1];
-	if (len > 0 && fseek(mpeg->stream, len, SEEK_CUR))
+	if (len > 0 && rar_seek(mpeg->stream, len, SEEK_CUR))
 	    return -1;
 	break;
     default:
 	if (0xc0 <= buf[3] && buf[3] < 0xf0) {
 	    /* MPEG audio or video */
-	    if (fread(buf, 2, 1, mpeg->stream) != 1)
+	    if (rar_read(buf, 2, 1, mpeg->stream) != 1)
 		return -1;
 	    len = buf[0] << 8 | buf[1];
-	    if (len > 0 && fseek(mpeg->stream, len, SEEK_CUR))
+	    if (len > 0 && rar_seek(mpeg->stream, len, SEEK_CUR))
 		return -1;
 		
 	}
@@ -725,7 +886,7 @@
 }
 
 static int
-vobsub_parse_one_line(vobsub_t *vob, FILE *fd)
+vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd)
 {
     ssize_t line_size;
     int res = -1;
@@ -775,7 +936,7 @@
 {
     vobsub_t *vob = (vobsub_t*)this;
     int res = -1;
-    FILE *fd = fopen(name, "rb");
+    rar_stream_t *fd = rar_open(name, "rb");
     if (fd == NULL) {
         if (force)
 	    mp_msg(MSGT_VOBSUB,MSGL_ERR, "Can't open IFO file");
@@ -783,7 +944,7 @@
 	// parse IFO header
 	unsigned char block[0x800];
 	const char *const ifo_magic = "DVDVIDEO-VTS";
-	if (fread(block, sizeof(block), 1, fd) != 1) {
+	if (rar_read(block, sizeof(block), 1, fd) != 1) {
 	    if (force)
 		mp_msg(MSGT_VOBSUB,MSGL_ERR, "Can't read IFO header");
 	} else if (memcmp(block, ifo_magic, strlen(ifo_magic) + 1))
@@ -818,8 +979,8 @@
 		langid[1] = tmp[1];
 		langid[2] = 0;
 	    }
-	    if (fseek(fd, pgci_sector * sizeof(block), SEEK_SET)
-		|| fread(block, sizeof(block), 1, fd) != 1)
+	    if (rar_seek(fd, pgci_sector * sizeof(block), SEEK_SET)
+		|| rar_read(block, sizeof(block), 1, fd) != 1)
 		mp_msg(MSGT_VOBSUB,MSGL_ERR, "Can't read IFO PGCI");
 	    else {
 		unsigned long idx;
@@ -834,7 +995,7 @@
 		res = 0;
 	    }
 	}
-	fclose(fd);
+	rar_close(fd);
     }
     return res;
 }
@@ -857,7 +1018,7 @@
 	vob->delay = 0;
 	buf = malloc((strlen(name) + 5) * sizeof(char));
 	if (buf) {
-	    FILE *fd;
+	    rar_stream_t *fd;
 	    mpeg_t *mpg;
 	    /* read in the info file */
 	    if(!ifo) {
@@ -869,7 +1030,7 @@
 	    /* read in the index */
 	    strcpy(buf, name);
 	    strcat(buf, ".idx");
-	    fd = fopen(buf, "rb");
+	    fd = rar_open(buf, "rb");
 	    if (fd == NULL) {
 		if(force)
 		  mp_msg(MSGT_VOBSUB,MSGL_ERR,"VobSub: Can't open IDX file");
@@ -881,7 +1042,7 @@
 	    } else {
 		while (vobsub_parse_one_line(vob, fd) >= 0)
 		    /* NOOP */ ;
-		fclose(fd);
+		rar_close(fd);
 	    }
 	    /* if no palette in .idx then use custom colors */
 	    if ((vob->custom == 0)&&(vob->have_palette!=1))




More information about the MPlayer-cvslog mailing list