/* -*- c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 2001, 2002, 2003 Billy Biggs <vektor@dumbterm.net>,
* Håkan Hjort <d95hjort@dtek.chalmers.se>,
* Björn Englund <d4bjorn@dtek.chalmers.se>
*
* Modified for use with MPlayer, changes contained in libdvdread_changes.diff.
* detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h> /* For the timing of dvdcss_title crack. */
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DARWIN__) || defined(__DragonFly__)
#define SYS_BSD 1
#endif
#if defined(__sun)
#include <sys/mnttab.h>
#elif defined(hpux)
#include </usr/conf/h/mnttab.h>
#elif defined(SYS_BSD)
#include <fstab.h>
#elif defined(__linux__) || defined(__CYGWIN__)
#include <mntent.h>
#endif
#include "dvd_reader.h"
#include "dvd_input.h"
#include "dvd_udf.h"
#include "md5.h"
#include "dvdread_internal.h"
#define DEFAULT_UDF_CACHE_LEVEL 0
struct dvd_reader_s {
/* Basic information. */
int isImageFile;
/* Hack for keeping track of the css status.
* 0: no css, 1: perhaps (need init of keys), 2: have done init */
int css_state;
int css_title; /* Last title that we have called dvdinpute_title for. */
/* Information required for an image file. */
dvd_input_t dev;
/* Information required for a directory path drive. */
char *path_root;
/* Filesystem cache */
int udfcache_level; /* 0 - turned off, 1 - on */
void *udfcache;
/* block aligned malloc */
void *align;
/* error message verbosity level */
int verbose;
};
struct dvd_file_s {
/* Basic information. */
dvd_reader_t *dvd;
/* Hack for selecting the right css title. */
int css_title;
/* Information required for an image file. */
uint32_t lb_start;
uint32_t seek_pos;
/* Information required for a directory path drive. */
size_t title_sizes[ 9 ];
dvd_input_t title_devs[ 9 ];
/* Calculated at open-time, size in blocks. */
ssize_t filesize;
};
#define DVDREAD_VERBOSE_DEFAULT 0
int get_verbose(void)
{
char *dvdread_verbose;
int verbose;
dvdread_verbose = getenv("DVDREAD_VERBOSE");
if(dvdread_verbose) {
verbose = (int)strtol(dvdread_verbose, NULL, 0);
} else {
verbose = DVDREAD_VERBOSE_DEFAULT;
}
return verbose;
}
int dvdread_verbose(dvd_reader_t *dvd)
{
return dvd->verbose;
}
dvd_reader_t *device_of_file(dvd_file_t *file)
{
return file->dvd;
}
/**
* Returns the compiled version. (DVDREAD_VERSION as an int)
*/
int DVDVersion(void)
{
return DVDREAD_VERSION;
}
/**
* Set the level of caching on udf
* level = 0 (no caching)
* level = 1 (caching filesystem info)
*/
int DVDUDFCacheLevel(dvd_reader_t *device, int level)
{
struct dvd_reader_s *dev = (struct dvd_reader_s *)device;
if(level > 0) {
level = 1;
} else if(level < 0) {
re
|