diff --git a/configure b/configure index 6f189f6a..bdc56e60 100644 --- a/configure +++ b/configure @@ -3554,6 +3554,8 @@ ac_config_files="$ac_config_files src/libcdio/iso9660/Makefile" ac_config_files="$ac_config_files src/libcdio/udf/Makefile" +ac_config_files="$ac_config_files src/libcdio/driver/Makefile" + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -4290,6 +4292,7 @@ do "src/syslinux/libinstaller/Makefile") CONFIG_FILES="$CONFIG_FILES src/syslinux/libinstaller/Makefile" ;; "src/libcdio/iso9660/Makefile") CONFIG_FILES="$CONFIG_FILES src/libcdio/iso9660/Makefile" ;; "src/libcdio/udf/Makefile") CONFIG_FILES="$CONFIG_FILES src/libcdio/udf/Makefile" ;; + "src/libcdio/driver/Makefile") CONFIG_FILES="$CONFIG_FILES src/libcdio/driver/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac diff --git a/configure.ac b/configure.ac index e78a4313..f177a2b4 100644 --- a/configure.ac +++ b/configure.ac @@ -91,4 +91,5 @@ AC_CONFIG_FILES([src/syslinux/libfat/Makefile]) AC_CONFIG_FILES([src/syslinux/libinstaller/Makefile]) AC_CONFIG_FILES([src/libcdio/iso9660/Makefile]) AC_CONFIG_FILES([src/libcdio/udf/Makefile]) +AC_CONFIG_FILES([src/libcdio/driver/Makefile]) AC_OUTPUT diff --git a/rufus_2010.sln b/rufus_2010.sln index ade0f68d..f1045f18 100644 --- a/rufus_2010.sln +++ b/rufus_2010.sln @@ -16,6 +16,8 @@ Project("{11411DA5-63FE-49DC-8D5C-CA379B95FF3C}") = "libcdio-iso9660", "src\libc EndProject Project("{11411DA5-63FE-49DC-8D5C-CA379B95FF3C}") = "libcdio-udf", "src\libcdio\udf\.msvc\udf.vcxproj", "{0CEC40A6-A195-4BE5-A88B-0AB00EB142EC}" EndProject +Project("{11411DA5-63FE-49DC-8D5C-CA379B95FF3C}") = "libcdio-driver", "src\libcdio\driver\.msvc\driver.vcxproj", "{FA1B1093-BA86-410A-B7A0-7A54C605F812}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -72,6 +74,14 @@ Global {0CEC40A6-A195-4BE5-A88B-0AB00EB142EC}.Release|Win32.Build.0 = Release|Win32 {0CEC40A6-A195-4BE5-A88B-0AB00EB142EC}.Release|x64.ActiveCfg = Release|x64 {0CEC40A6-A195-4BE5-A88B-0AB00EB142EC}.Release|x64.Build.0 = Release|x64 + {FA1B1093-BA86-410A-B7A0-7A54C605F812}.Debug|Win32.ActiveCfg = Debug|Win32 + {FA1B1093-BA86-410A-B7A0-7A54C605F812}.Debug|Win32.Build.0 = Debug|Win32 + {FA1B1093-BA86-410A-B7A0-7A54C605F812}.Debug|x64.ActiveCfg = Debug|x64 + {FA1B1093-BA86-410A-B7A0-7A54C605F812}.Debug|x64.Build.0 = Debug|x64 + {FA1B1093-BA86-410A-B7A0-7A54C605F812}.Release|Win32.ActiveCfg = Release|Win32 + {FA1B1093-BA86-410A-B7A0-7A54C605F812}.Release|Win32.Build.0 = Release|Win32 + {FA1B1093-BA86-410A-B7A0-7A54C605F812}.Release|x64.ActiveCfg = Release|x64 + {FA1B1093-BA86-410A-B7A0-7A54C605F812}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/.msvc/rufus_2010.vcxproj b/src/.msvc/rufus_2010.vcxproj index 91c14209..8a83b0d8 100644 --- a/src/.msvc/rufus_2010.vcxproj +++ b/src/.msvc/rufus_2010.vcxproj @@ -80,7 +80,7 @@ _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;%(PreprocessorDefinitions) MultiThreadedDebug Level3 - ..\ms-sys\inc;..\syslinux;..\syslinux\libinstaller;..\syslinux\libfat;%(AdditionalIncludeDirectories) + ..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\libcdio;%(AdditionalIncludeDirectories) setupapi.lib;comctl32.lib;%(AdditionalDependencies) @@ -99,7 +99,7 @@ X64 - ..\ms-sys\inc;..\syslinux;..\syslinux\libinstaller;..\syslinux\libfat;%(AdditionalIncludeDirectories) + ..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\libcdio;%(AdditionalIncludeDirectories) _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;%(PreprocessorDefinitions) MultiThreadedDebug Level3 @@ -122,7 +122,7 @@ _CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;%(PreprocessorDefinitions) MultiThreaded Level3 - ..\ms-sys\inc;..\syslinux;..\syslinux\libinstaller;..\syslinux\libfat;%(AdditionalIncludeDirectories) + ..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\libcdio;%(AdditionalIncludeDirectories) setupapi.lib;comctl32.lib;%(AdditionalDependencies) @@ -144,7 +144,7 @@ _CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;%(PreprocessorDefinitions) MultiThreaded Level3 - ..\ms-sys\inc;..\syslinux;..\syslinux\libinstaller;..\syslinux\libfat;%(AdditionalIncludeDirectories) + ..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\libcdio;%(AdditionalIncludeDirectories) setupapi.lib;comctl32.lib;%(AdditionalDependencies) @@ -163,6 +163,7 @@ + @@ -189,6 +190,15 @@ + + {fa1b1093-ba86-410a-b7a0-7a54c605f812} + + + {d4e80f35-2604-40ac-b436-97b052ecb572} + + + {0cec40a6-a195-4be5-a88b-0ab00eb142ec} + {2b1d078d-8eb4-4398-9ca4-23457265a7f6} diff --git a/src/.msvc/rufus_2010.vcxproj.filters b/src/.msvc/rufus_2010.vcxproj.filters index 181eab37..b135c92b 100644 --- a/src/.msvc/rufus_2010.vcxproj.filters +++ b/src/.msvc/rufus_2010.vcxproj.filters @@ -42,6 +42,9 @@ Source Files + + Source Files + diff --git a/src/.msvc/rufus_sources b/src/.msvc/rufus_sources index a94ae3fa..d1119e31 100644 --- a/src/.msvc/rufus_sources +++ b/src/.msvc/rufus_sources @@ -3,7 +3,7 @@ TARGETTYPE=PROGRAM UMTYPE=windows UMENTRY=winmain -INCLUDES=$(DDK_INC_PATH);.\ms-sys\inc;.\syslinux;.\syslinux\libfat;.\syslinux\libinstaller +INCLUDES=$(DDK_INC_PATH);.\ms-sys\inc;.\syslinux\libfat;.\syslinux\libinstaller;.\msvc-missing;.\libcdio C_DEFINES = $(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED !IFNDEF MSC_WARNING_LEVEL @@ -20,7 +20,10 @@ TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \ $(SDK_LIB_PATH)\shell32.lib \ .\ms-sys\ms-sys.lib \ .\syslinux\libfat\libfat.lib \ - .\syslinux\libinstaller\libinstaller.lib + .\syslinux\libinstaller\libinstaller.lib \ + .\libcdio\iso9660\iso9660.lib \ + .\libcdio\udf\udf.lib \ + .\libcdio\driver\driver.lib # http://jpassing.com/2008/02/01/how-to-use-manifests-with-buildexe/ SXS_APPLICATION_MANIFEST=..\common_controls_and_elevation.manifest @@ -29,6 +32,7 @@ SOURCES=rufus.c \ format.c \ stdio.c \ stdlg.c \ + iso.c \ dos.c \ dos_locale.c \ badblocks.c \ diff --git a/src/Makefile.am b/src/Makefile.am index 29e54f34..a9f001f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = ms-sys syslinux/libfat syslinux/libinstaller libcdio/iso9660 libcdio/udf +SUBDIRS = ms-sys syslinux/libfat syslinux/libinstaller libcdio/iso9660 libcdio/udf libcdio/driver noinst_PROGRAMS = rufus @@ -9,8 +9,8 @@ pkg_v_rc_0 = @echo " RC $@"; %_rc.o: %.rc $(pkg_v_rc)$(WINDRES) $(AM_RCFLAGS) -i $< -o $@ -rufus_SOURCES = drive.c dos.c dos_locale.c badblocks.c syslinux.c format.c stdio.c stdlg.c rufus.c -rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller $(AM_CFLAGS) +rufus_SOURCES = drive.c iso.c dos.c dos_locale.c badblocks.c syslinux.c format.c stdio.c stdlg.c rufus.c +rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./libcdio $(AM_CFLAGS) rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows rufus_LDADD = rufus_rc.o ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \ - libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a -lsetupapi -lole32 -lgdi32 + libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 diff --git a/src/Makefile.in b/src/Makefile.in index 0fc6dd75..ec3eb872 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -43,15 +43,16 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) -am_rufus_OBJECTS = rufus-drive.$(OBJEXT) rufus-dos.$(OBJEXT) \ - rufus-dos_locale.$(OBJEXT) rufus-badblocks.$(OBJEXT) \ - rufus-syslinux.$(OBJEXT) rufus-format.$(OBJEXT) \ - rufus-stdio.$(OBJEXT) rufus-stdlg.$(OBJEXT) \ - rufus-rufus.$(OBJEXT) +am_rufus_OBJECTS = rufus-drive.$(OBJEXT) rufus-iso.$(OBJEXT) \ + rufus-dos.$(OBJEXT) rufus-dos_locale.$(OBJEXT) \ + rufus-badblocks.$(OBJEXT) rufus-syslinux.$(OBJEXT) \ + rufus-format.$(OBJEXT) rufus-stdio.$(OBJEXT) \ + rufus-stdlg.$(OBJEXT) rufus-rufus.$(OBJEXT) rufus_OBJECTS = $(am_rufus_OBJECTS) rufus_DEPENDENCIES = rufus_rc.o ms-sys/libmssys.a \ syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \ - libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a + libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a \ + libcdio/driver/libdriver.a rufus_LINK = $(CCLD) $(rufus_CFLAGS) $(CFLAGS) $(rufus_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ @@ -179,15 +180,15 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = ms-sys syslinux/libfat syslinux/libinstaller libcdio/iso9660 libcdio/udf +SUBDIRS = ms-sys syslinux/libfat syslinux/libinstaller libcdio/iso9660 libcdio/udf libcdio/driver pkg_v_rc = $(pkg_v_rc_$(V)) pkg_v_rc_ = $(pkg_v_rc_$(AM_DEFAULT_VERBOSITY)) pkg_v_rc_0 = @echo " RC $@"; -rufus_SOURCES = drive.c dos.c dos_locale.c badblocks.c syslinux.c format.c stdio.c stdlg.c rufus.c -rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller $(AM_CFLAGS) +rufus_SOURCES = drive.c iso.c dos.c dos_locale.c badblocks.c syslinux.c format.c stdio.c stdlg.c rufus.c +rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./libcdio $(AM_CFLAGS) rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows rufus_LDADD = rufus_rc.o ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \ - libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a -lsetupapi -lole32 -lgdi32 + libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 all: all-recursive @@ -252,6 +253,14 @@ rufus-drive.obj: drive.c $(AM_V_CC) @AM_BACKSLASH@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-drive.obj `if test -f 'drive.c'; then $(CYGPATH_W) 'drive.c'; else $(CYGPATH_W) '$(srcdir)/drive.c'; fi` +rufus-iso.o: iso.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-iso.o `test -f 'iso.c' || echo '$(srcdir)/'`iso.c + +rufus-iso.obj: iso.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-iso.obj `if test -f 'iso.c'; then $(CYGPATH_W) 'iso.c'; else $(CYGPATH_W) '$(srcdir)/iso.c'; fi` + rufus-dos.o: dos.c $(AM_V_CC) @AM_BACKSLASH@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-dos.o `test -f 'dos.c' || echo '$(srcdir)/'`dos.c diff --git a/src/iso.c b/src/iso.c new file mode 100644 index 00000000..d590f493 --- /dev/null +++ b/src/iso.c @@ -0,0 +1,128 @@ +/* + * Rufus: The Reliable USB Formatting Utility + * ISO file extraction + * Copyright (c) 2011-2012 Pete Batard + * Based on libcdio's iso-read.c & iso-info.c: + * Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein + * + * 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 3 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, see . + */ + +#include +#include +#include +#include "rufus.h" + +#include +#include + +#define print_vd_info(title, fn) \ + if (fn(p_iso, &psz_str)) { \ + uprintf(title ": %s\n", psz_str); \ + } \ + free(psz_str); \ + psz_str = NULL; + +BOOL ExtractISO(const char* src_iso, const char* dest_dir) +{ + BOOL r = FALSE; + CdioList_t *p_entlist; + CdioListNode_t *p_entnode; + iso9660_t *p_iso; + const char *psz_path="/"; + char *psz_str = NULL; + + + p_iso = iso9660_open(src_iso); + if (p_iso == NULL) { + uprintf("Unable to open ISO image '%s'.\n", src_iso); + goto out1; + } + + /* Show basic CD info from the Primary Volume Descriptor. */ + print_vd_info("Application", iso9660_ifs_get_application_id); + print_vd_info("Preparer ", iso9660_ifs_get_preparer_id); + print_vd_info("Publisher ", iso9660_ifs_get_publisher_id); + print_vd_info("System ", iso9660_ifs_get_system_id); + print_vd_info("Volume ", iso9660_ifs_get_volume_id); + print_vd_info("Volume Set ", iso9660_ifs_get_volumeset_id); + + p_entlist = iso9660_ifs_readdir(p_iso, psz_path); + + /* Iterate over the list of nodes that iso9660_ifs_readdir gives */ + if (p_entlist) { + _CDIO_LIST_FOREACH (p_entnode, p_entlist) { + char filename[4096]; + iso9660_stat_t *p_statbuf = (iso9660_stat_t*) _cdio_list_node_data(p_entnode); + iso9660_name_translate(p_statbuf->filename, filename); + uprintf("%s [LSN %6d] %8u %s%s\n", _STAT_DIR == p_statbuf->type ? "d" : "-", + p_statbuf->lsn, p_statbuf->size, psz_path, filename); + } + _cdio_list_free (p_entlist, true); + } + r = TRUE; + +#if 0 + iso9660_stat_t *statbuf; + FILE* outfd; + uint32_t i; + char file_name[] = "TEST.TST"; + char buf[ISO_BLOCKSIZE]; + + statbuf = iso9660_ifs_stat_translate(p_iso, file_name); + if (statbuf == NULL) { + uprintf("Could not get ISO-9660 file information for file %s.\n", file_name); + goto out2; + } + + if (!(outfd = fopen(file_name, "wb"))) { + uprintf("Could not open %s for writing\n", file_name); + goto out2; + } + + /* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */ + for (i=0; isize; i+=ISO_BLOCKSIZE) { + memset (buf, 0, ISO_BLOCKSIZE); + if (iso9660_iso_seek_read(p_iso, buf, statbuf->lsn + (i / ISO_BLOCKSIZE), 1) != ISO_BLOCKSIZE) { + uprintf("Error reading ISO 9660 file at lsn %lu\n", (long unsigned int) statbuf->lsn + (i / ISO_BLOCKSIZE)); + goto out3; + } + + fwrite(buf, ISO_BLOCKSIZE, 1, outfd); + if (ferror (outfd)) { + uprintf("Error writing file\n"); + goto out3; + } + } + + fflush(outfd); + + /* Make sure the file size has the exact same byte size. Without the + * truncate below, the file will a multiple of ISO_BLOCKSIZE. */ + if (_chsize(_fileno(outfd), statbuf->size) != 0) { + uprintf("Error adjusting file size\n"); + goto out3; + } + + r = TRUE; + +out3: + fclose(outfd); +out2: +#endif + iso9660_close(p_iso); +out1: + + return r; +} diff --git a/src/libcdio/cdio/audio.h b/src/libcdio/cdio/audio.h new file mode 100644 index 00000000..3926f680 --- /dev/null +++ b/src/libcdio/cdio/audio.h @@ -0,0 +1,146 @@ +/* -*- c -*- + Copyright (C) 2005, 2007, 2008 Rocky Bernstein + + 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 3 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, see . +*/ + +/** \file audio.h + * + * \brief The top-level header for CD audio-related libcdio + * calls. These control playing of the CD-ROM through its + * line-out jack. + */ +#ifndef __CDIO_AUDIO_H__ +#define __CDIO_AUDIO_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + /*! This struct is used by the cdio_audio_read_subchannel */ + typedef struct cdio_subchannel_s + { + uint8_t format; + uint8_t audio_status; + uint8_t address: 4; + uint8_t control: 4; + uint8_t track; + uint8_t index; + msf_t abs_addr; + msf_t rel_addr; + } cdio_subchannel_t; + + /*! This struct is used by cdio_audio_get_volume and cdio_audio_set_volume */ + typedef struct cdio_audio_volume_s + { + uint8_t level[4]; + } cdio_audio_volume_t; + + + /*! This struct is used by the CDROMPLAYTRKIND ioctl */ + typedef struct cdio_track_index_s + { + uint8_t i_start_track; /**< start track */ + uint8_t i_start_index; /**< start index */ + uint8_t i_end_track; /**< end track */ + uint8_t i_end_index; /**< end index */ + } cdio_track_index_t; + + /*! + Get volume of an audio CD. + + @param p_cdio the CD object to be acted upon. + @param p_volume place to put the list of volume outputs levels + + p_volume can be NULL in which case we return only whether the driver + has the ability to get the volume or not. + + */ + driver_return_code_t cdio_audio_get_volume (CdIo_t *p_cdio, /*out*/ + cdio_audio_volume_t *p_volume); + + /*! + Return the number of seconds (discarding frame portion) of an MSF + */ + uint32_t cdio_audio_get_msf_seconds(msf_t *p_msf); + + /*! + Pause playing CD through analog output + + @param p_cdio the CD object to be acted upon. + */ + driver_return_code_t cdio_audio_pause (CdIo_t *p_cdio); + + /*! + Playing CD through analog output at the given MSF. + + @param p_cdio the CD object to be acted upon. + @param p_start_msf pointer to staring MSF + @param p_end_msf pointer to ending MSF + */ + driver_return_code_t cdio_audio_play_msf (CdIo_t *p_cdio, + /*in*/msf_t *p_start_msf, + /*in*/ msf_t *p_end_msf); + + /*! + Playing CD through analog output at the desired track and index + + @param p_cdio the CD object to be acted upon. + @param p_track_index location to start/end. + */ + driver_return_code_t cdio_audio_play_track_index + ( CdIo_t *p_cdio, cdio_track_index_t *p_track_index); + + /*! + Get subchannel information. + + @param p_cdio the CD object to be acted upon. + @param p_subchannel place for returned subchannel information + */ + driver_return_code_t cdio_audio_read_subchannel (CdIo_t *p_cdio, + /*out*/ cdio_subchannel_t *p_subchannel); + + /*! + Resume playing an audio CD. + + @param p_cdio the CD object to be acted upon. + + */ + driver_return_code_t cdio_audio_resume (CdIo_t *p_cdio); + + /*! + Set volume of an audio CD. + + @param p_cdio the CD object to be acted upon. + @param p_volume place for returned volume-level information + + */ + driver_return_code_t cdio_audio_set_volume (CdIo_t *p_cdio, /*out*/ + cdio_audio_volume_t *p_volume); + + /*! + Stop playing an audio CD. + + @param p_cdio the CD object to be acted upon. + + */ + driver_return_code_t cdio_audio_stop (CdIo_t *p_cdio); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __CDIO_AUDIO_H__ */ diff --git a/src/libcdio/cdio/cdio.h b/src/libcdio/cdio/cdio.h index 5c53afde..8cb7e176 100644 --- a/src/libcdio/cdio/cdio.h +++ b/src/libcdio/cdio/cdio.h @@ -75,6 +75,6 @@ extern "C" { //#include /* Track-related functions. */ -//#include +#include #endif /* __CDIO_H__ */ diff --git a/src/libcdio/cdio/track.h b/src/libcdio/cdio/track.h new file mode 100644 index 00000000..930e5037 --- /dev/null +++ b/src/libcdio/cdio/track.h @@ -0,0 +1,256 @@ +/* + $Id: track.h,v 1.14 2008/03/25 15:59:09 karl Exp $ + + Copyright (C) 2005, 2006, 2008 Rocky Bernstein + + 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 3 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, see . +*/ + +/** \file track.h + * \brief The top-level header for track-related libcdio calls. + */ +#ifndef __CDIO_TRACK_H__ +#define __CDIO_TRACK_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + /*! Printable tags for track_format_t enumeration. */ + extern const char *track_format2str[6]; + + typedef enum { + TRACK_FORMAT_AUDIO, /**< Audio track, e.g. CD-DA */ + TRACK_FORMAT_CDI, /**< CD-i. How this is different from DATA below? */ + TRACK_FORMAT_XA, /**< Mode2 of some sort */ + TRACK_FORMAT_DATA, /**< Mode1 of some sort */ + TRACK_FORMAT_PSX, /**< Playstation CD. Like audio but only 2336 bytes + * of user data. + */ + TRACK_FORMAT_ERROR /**< Dunno what is, or some other error. */ + } track_format_t; + + typedef enum { + CDIO_TRACK_FLAG_FALSE, + CDIO_TRACK_FLAG_TRUE, + CDIO_TRACK_FLAG_ERROR, + CDIO_TRACK_FLAG_UNKNOWN + } track_flag_t; + + /*! \brief Structure containing attributes associated with a track */ + typedef struct { + track_flag_t preemphasis; /**< Linear preemphasis on an audio track */ + track_flag_t copy_permit; /**< Whether copying is permitted */ + int channels; /**< Number of audio channels, 2, 4. -2 if not + implemented or -1 for error. + */ + } track_flags_t; + + /*! The leadout track is always 0xAA, regardless of # of tracks on + disc, or what value may be used internally. For example although + OS X uses a different value for the lead-out track internally than + given below, programmers should use CDIO_CDROM_LEADOUT_TRACK and + not worry about this. + */ + + /*! An enumeration for some of the CDIO_CDROM_* \#defines below. This + isn't really an enumeration one would really use in a program; it + is to be helpful in debuggers where wants just to refer to the + CDIO_CDROM_* names and get something. + */ + extern enum cdio_track_enums { + CDIO_CDROM_LBA = 0x01, /**< "logical block": first frame is #0 */ + CDIO_CDROM_MSF = 0x02, /**< "minute-second-frame": binary, not + BCD here! */ + CDIO_CDROM_DATA_TRACK = 0x04, + CDIO_CDROM_CDI_TRACK = 0x10, + CDIO_CDROM_XA_TRACK = 0x20, + CDIO_CD_MAX_TRACKS = 99, /**< Largest CD track number */ + CDIO_CDROM_LEADOUT_TRACK = 0xAA, /**< Lead-out track number */ + CDIO_INVALID_TRACK = 0xFF, /**< Constant for invalid track number */ + + } cdio_track_enums; + +#define CDIO_CD_MIN_TRACK_NO 1 /**< Smallest CD track number */ + + /*! track modes (Table 350) + reference: MMC-3 draft revsion - 10g + */ + typedef enum { + AUDIO, /**< 2352 byte block length */ + MODE1, /**< 2048 byte block length */ + MODE1_RAW, /**< 2352 byte block length */ + MODE2, /**< 2336 byte block length */ + MODE2_FORM1, /**< 2048 byte block length */ + MODE2_FORM2, /**< 2324 byte block length */ + MODE2_FORM_MIX, /**< 2336 byte block length */ + MODE2_RAW /**< 2352 byte block length */ + } trackmode_t; + + /*! + Get the number of the first track. + + @return the track number or CDIO_INVALID_TRACK + on error. + */ + track_t cdio_get_first_track_num(const CdIo_t *p_cdio); + + /*! + Return the last track number. + CDIO_INVALID_TRACK is returned on error. + */ + track_t cdio_get_last_track_num (const CdIo_t *p_cdio); + + + /*! Find the track which contains lsn. + CDIO_INVALID_TRACK is returned if the lsn outside of the CD or + if there was some error. + + If the lsn is before the pregap of the first track 0 is returned. + Otherwise we return the track that spans the lsn. + */ + track_t cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn); + + /*! Return number of channels in track: 2 or 4; -2 if not + implemented or -1 for error. + Not meaningful if track is not an audio track. + */ + int cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track); + + /*! Return copy protection status on a track. Is this meaningful + if not an audio track? + */ + track_flag_t cdio_get_track_copy_permit(const CdIo_t *p_cdio, + track_t i_track); + + /*! + Get the format (audio, mode2, mode1) of track. + */ + track_format_t cdio_get_track_format(const CdIo_t *p_cdio, track_t i_track); + + /*! + Return true if we have XA data (green, mode2 form1) or + XA data (green, mode2 form2). That is track begins: + sync - header - subheader + 12 4 - 8 + + FIXME: there's gotta be a better design for this and get_track_format? + */ + bool cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track); + + /*! + Return the ending LSN for track number + i_track in cdio. CDIO_INVALID_LSN is returned on error. + */ + lsn_t cdio_get_track_last_lsn(const CdIo_t *p_cdio, track_t i_track); + + /*! + Get the starting LBA for track number + i_track in p_cdio. Track numbers usually start at something + greater than 0, usually 1. + + The "leadout" track is specified either by + using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1. + + @param p_cdio object to get information from + @param i_track the track number we want the LSN for + @return the starting LBA or CDIO_INVALID_LBA on error. + */ + lba_t cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track); + + /*! + Return the starting LSN for track number + i_track in p_cdio. Track numbers usually start at something + greater than 0, usually 1. + + The "leadout" track is specified either by + using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1. + + @param p_cdio object to get information from + @param i_track the track number we want the LSN for + @return the starting LSN or CDIO_INVALID_LSN on error. + */ + lsn_t cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track); + + /*! + Return the starting LBA for the pregap for track number + i_track in p_cdio. Track numbers usually start at something + greater than 0, usually 1. + + @param p_cdio object to get information from + @param i_track the track number we want the LBA for + @return the starting LBA or CDIO_INVALID_LBA on error. + */ + lba_t cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t i_track); + + /*! + Return the starting LSN for the pregap for track number + i_track in p_cdio. Track numbers usually start at something + greater than 0, usually 1. + + @param p_cdio object to get information from + @param i_track the track number we want the LSN for + @return the starting LSN or CDIO_INVALID_LSN on error. + */ + lsn_t cdio_get_track_pregap_lsn(const CdIo_t *p_cdio, track_t i_track); + + /*! + Get the International Standard Recording Code (ISRC) for track number + i_track in p_cdio. Track numbers usually start at something + greater than 0, usually 1. + + @return the International Standard Recording Code (ISRC) or NULL + if there is none or we don't have the ability to get it. + + Note: string is malloc'd so caller has to free() the returned + string when done with it. + + */ + char * cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track); + + /*! + Return the starting MSF (minutes/secs/frames) for track number + i_track in p_cdio. Track numbers usually start at something + greater than 0, usually 1. + + The "leadout" track is specified either by + using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1. + + @return true if things worked or false if there is no track entry. + */ + bool cdio_get_track_msf(const CdIo_t *p_cdio, track_t i_track, + /*out*/ msf_t *msf); + + /*! Get linear preemphasis status on an audio track + This is not meaningful if not an audio track? + */ + track_flag_t cdio_get_track_preemphasis(const CdIo_t *p_cdio, + track_t i_track); + + /*! + Get the number of sectors between this track an the next. This + includes any pregap sectors before the start of the next track. + Track numbers usually start at something + greater than 0, usually 1. + + @return the number of sectors or 0 if there is an error. + */ + unsigned int cdio_get_track_sec_count(const CdIo_t *p_cdio, track_t i_track); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __CDIO_TRACK_H__ */ + diff --git a/src/libcdio/driver/.msvc/driver.vcxproj b/src/libcdio/driver/.msvc/driver.vcxproj new file mode 100644 index 00000000..e18af166 --- /dev/null +++ b/src/libcdio/driver/.msvc/driver.vcxproj @@ -0,0 +1,177 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + {FA1B1093-BA86-410A-B7A0-7A54C605F812} + Win32Proj + driver + libcdio-driver + + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)x86_32\$(Configuration)\ + $(SolutionDir)x86_32\$(Configuration)\$(ProjectName)\ + $(SolutionDir)x86_32\$(Configuration)\ + $(SolutionDir)x86_32\$(Configuration)\$(ProjectName)\ + $(SolutionDir)x86_64\$(Configuration)\ + $(SolutionDir)x86_64\$(Configuration)\$(ProjectName)\ + $(SolutionDir)x86_64\$(Configuration)\ + $(SolutionDir)x86_64\$(Configuration)\$(ProjectName)\ + false + false + false + false + + + + + + Level3 + Disabled + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) + MultiThreadedDebug + ProgramDatabase + + + Windows + true + + + MachineX86 + + + + + Level3 + + + MaxSpeed + true + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) + MultiThreaded + ProgramDatabase + + + MachineX86 + + + + + + + Level3 + Disabled + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) + MultiThreadedDebug + ProgramDatabase + + + Windows + true + + + MachineX64 + + + + + Level3 + + + MaxSpeed + true + _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) + ..;..\..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) + MultiThreaded + ProgramDatabase + + + Windows + true + true + true + + + MachineX64 + + + + + + \ No newline at end of file diff --git a/src/libcdio/driver/.msvc/driver.vcxproj.filters b/src/libcdio/driver/.msvc/driver.vcxproj.filters new file mode 100644 index 00000000..ed60d36d --- /dev/null +++ b/src/libcdio/driver/.msvc/driver.vcxproj.filters @@ -0,0 +1,56 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/src/libcdio/driver/.msvc/driver_sources b/src/libcdio/driver/.msvc/driver_sources new file mode 100644 index 00000000..1e2dae09 --- /dev/null +++ b/src/libcdio/driver/.msvc/driver_sources @@ -0,0 +1,23 @@ +TARGETNAME=driver +TARGETTYPE=LIBRARY + +INCLUDES=$(DDK_INC_PATH);.;..;..\..\msvc-missing +C_DEFINES=$(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED + +!IFNDEF MSC_WARNING_LEVEL +MSC_WARNING_LEVEL=/W3 +!ENDIF +USE_MSVCRT=1 + +TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \ + $(SDK_LIB_PATH)\user32.lib + +SOURCES=disc.c \ + ds.c \ + logging.c \ + read.c \ + sector.c \ + track.c \ + util.c \ + _cdio_stdio.c \ + _cdio_stream.c \ No newline at end of file diff --git a/src/libcdio/driver/Makefile.am b/src/libcdio/driver/Makefile.am new file mode 100644 index 00000000..76ad4432 --- /dev/null +++ b/src/libcdio/driver/Makefile.am @@ -0,0 +1,3 @@ +noinst_LIBRARIES = libdriver.a +libdriver_a_SOURCES = disc.c ds.c logging.c read.c sector.c track.c util.c _cdio_stdio.c _cdio_stream.c +libdriver_a_CFLAGS = -I. -I.. $(AM_CFLAGS) diff --git a/src/libcdio/driver/Makefile.in b/src/libcdio/driver/Makefile.in new file mode 100644 index 00000000..26ad68c7 --- /dev/null +++ b/src/libcdio/driver/Makefile.in @@ -0,0 +1,467 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = src/libcdio/driver +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +AM_V_AR = $(am__v_AR_$(V)) +am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY)) +am__v_AR_0 = @echo " AR " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +libdriver_a_AR = $(AR) $(ARFLAGS) +libdriver_a_LIBADD = +am_libdriver_a_OBJECTS = libdriver_a-disc.$(OBJEXT) \ + libdriver_a-ds.$(OBJEXT) libdriver_a-logging.$(OBJEXT) \ + libdriver_a-read.$(OBJEXT) libdriver_a-sector.$(OBJEXT) \ + libdriver_a-track.$(OBJEXT) libdriver_a-util.$(OBJEXT) \ + libdriver_a-_cdio_stdio.$(OBJEXT) \ + libdriver_a-_cdio_stream.$(OBJEXT) +libdriver_a_OBJECTS = $(am_libdriver_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = +am__depfiles_maybe = +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(libdriver_a_SOURCES) +ETAGS = etags +CTAGS = ctags +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AM_LDFLAGS = @AM_LDFLAGS@ +AM_RCFLAGS = @AM_RCFLAGS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EXEEXT = @EXEEXT@ +EXESUFFIX = @EXESUFFIX@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +RM = @RM@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@ +WINDRES = @WINDRES@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LIBRARIES = libdriver.a +libdriver_a_SOURCES = disc.c ds.c logging.c read.c sector.c track.c util.c _cdio_stdio.c _cdio_stream.c +libdriver_a_CFLAGS = -I. -I.. $(AM_CFLAGS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign --ignore-deps src/libcdio/driver/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign --ignore-deps src/libcdio/driver/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libdriver.a: $(libdriver_a_OBJECTS) $(libdriver_a_DEPENDENCIES) + $(AM_V_at)-rm -f libdriver.a + $(AM_V_AR)$(libdriver_a_AR) libdriver.a $(libdriver_a_OBJECTS) $(libdriver_a_LIBADD) + $(AM_V_at)$(RANLIB) libdriver.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +.c.o: + $(AM_V_CC) @AM_BACKSLASH@ + $(COMPILE) -c $< + +.c.obj: + $(AM_V_CC) @AM_BACKSLASH@ + $(COMPILE) -c `$(CYGPATH_W) '$<'` + +libdriver_a-disc.o: disc.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-disc.o `test -f 'disc.c' || echo '$(srcdir)/'`disc.c + +libdriver_a-disc.obj: disc.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-disc.obj `if test -f 'disc.c'; then $(CYGPATH_W) 'disc.c'; else $(CYGPATH_W) '$(srcdir)/disc.c'; fi` + +libdriver_a-ds.o: ds.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-ds.o `test -f 'ds.c' || echo '$(srcdir)/'`ds.c + +libdriver_a-ds.obj: ds.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-ds.obj `if test -f 'ds.c'; then $(CYGPATH_W) 'ds.c'; else $(CYGPATH_W) '$(srcdir)/ds.c'; fi` + +libdriver_a-logging.o: logging.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-logging.o `test -f 'logging.c' || echo '$(srcdir)/'`logging.c + +libdriver_a-logging.obj: logging.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-logging.obj `if test -f 'logging.c'; then $(CYGPATH_W) 'logging.c'; else $(CYGPATH_W) '$(srcdir)/logging.c'; fi` + +libdriver_a-read.o: read.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-read.o `test -f 'read.c' || echo '$(srcdir)/'`read.c + +libdriver_a-read.obj: read.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-read.obj `if test -f 'read.c'; then $(CYGPATH_W) 'read.c'; else $(CYGPATH_W) '$(srcdir)/read.c'; fi` + +libdriver_a-sector.o: sector.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-sector.o `test -f 'sector.c' || echo '$(srcdir)/'`sector.c + +libdriver_a-sector.obj: sector.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-sector.obj `if test -f 'sector.c'; then $(CYGPATH_W) 'sector.c'; else $(CYGPATH_W) '$(srcdir)/sector.c'; fi` + +libdriver_a-track.o: track.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-track.o `test -f 'track.c' || echo '$(srcdir)/'`track.c + +libdriver_a-track.obj: track.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-track.obj `if test -f 'track.c'; then $(CYGPATH_W) 'track.c'; else $(CYGPATH_W) '$(srcdir)/track.c'; fi` + +libdriver_a-util.o: util.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c + +libdriver_a-util.obj: util.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi` + +libdriver_a-_cdio_stdio.o: _cdio_stdio.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-_cdio_stdio.o `test -f '_cdio_stdio.c' || echo '$(srcdir)/'`_cdio_stdio.c + +libdriver_a-_cdio_stdio.obj: _cdio_stdio.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-_cdio_stdio.obj `if test -f '_cdio_stdio.c'; then $(CYGPATH_W) '_cdio_stdio.c'; else $(CYGPATH_W) '$(srcdir)/_cdio_stdio.c'; fi` + +libdriver_a-_cdio_stream.o: _cdio_stream.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-_cdio_stream.o `test -f '_cdio_stream.c' || echo '$(srcdir)/'`_cdio_stream.c + +libdriver_a-_cdio_stream.obj: _cdio_stream.c + $(AM_V_CC) @AM_BACKSLASH@ + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdriver_a_CFLAGS) $(CFLAGS) -c -o libdriver_a-_cdio_stream.obj `if test -f '_cdio_stream.c'; then $(CYGPATH_W) '_cdio_stream.c'; else $(CYGPATH_W) '$(srcdir)/_cdio_stream.c'; fi` + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags dvi dvi-am html html-am info \ + info-am install install-am install-data install-data-am \ + install-dvi install-dvi-am install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ + ps ps-am tags uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/libcdio/driver/_cdio_stdio.c b/src/libcdio/driver/_cdio_stdio.c new file mode 100644 index 00000000..2b179b9d --- /dev/null +++ b/src/libcdio/driver/_cdio_stdio.c @@ -0,0 +1,228 @@ +/* + Copyright (C) 2003, 2004, 2005, 2008, 2011 Rocky Bernstein + Copyright (C) 2000 Herbert Valerio Riedel + + 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 3 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, see . +*/ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif /*HAVE_UNISTD_H*/ + +#include +#include + +#include +#include +#include "_cdio_stream.h" +#include "_cdio_stdio.h" + +static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.6 2008/04/22 15:29:11 karl Exp $"; + +#define CDIO_STDIO_BUFSIZE (128*1024) + +typedef struct { + char *pathname; + FILE *fd; + char *fd_buf; + off_t st_size; /* used only for source */ +} _UserData; + +static int +_stdio_open (void *user_data) +{ + _UserData *const ud = user_data; + + if ((ud->fd = fopen (ud->pathname, "rb"))) + { + ud->fd_buf = calloc (1, CDIO_STDIO_BUFSIZE); + setvbuf (ud->fd, ud->fd_buf, _IOFBF, CDIO_STDIO_BUFSIZE); + } + + return (ud->fd == NULL); +} + +static int +_stdio_close(void *user_data) +{ + _UserData *const ud = user_data; + + if (fclose (ud->fd)) + cdio_error ("fclose (): %s", strerror (errno)); + + ud->fd = NULL; + + free (ud->fd_buf); + ud->fd_buf = NULL; + + return 0; +} + +static void +_stdio_free(void *user_data) +{ + _UserData *const ud = user_data; + + if (ud->pathname) + free(ud->pathname); + + if (ud->fd) /* should be NULL anyway... */ + _stdio_close(user_data); + + free(ud); +} + +/*! + Like fseek(3) and in fact may be the same. + + This function sets the file position indicator for the stream + pointed to by stream. The new position, measured in bytes, is obtained + by adding offset bytes to the position specified by whence. If whence + is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to + the start of the file, the current position indicator, or end-of-file, + respectively. A successful call to the fseek function clears the end- + of-file indicator for the stream and undoes any effects of the + ungetc(3) function on the same stream. + + @return upon successful completion, DRIVER_OP_SUCCESS, else, + DRIVER_OP_ERROR is returned and the global variable errno is set to + indicate the error. +*/ +static driver_return_code_t +_stdio_seek(void *p_user_data, long i_offset, int whence) +{ + _UserData *const ud = p_user_data; + + if ( (i_offset=fseek (ud->fd, i_offset, whence)) ) { + cdio_error ("fseek (): %s", strerror (errno)); + } + + return i_offset; +} + +static long int +_stdio_stat(void *p_user_data) +{ + const _UserData *const ud = p_user_data; + + return ud->st_size; +} + +/*! + Like fread(3) and in fact is about the same. + + DESCRIPTION: + The function fread reads nmemb elements of data, each size bytes long, + from the stream pointed to by stream, storing them at the location + given by ptr. + + RETURN VALUE: + return the number of items successfully read or written (i.e., + not the number of characters). If an error occurs, or the + end-of-file is reached, the return value is a short item count + (or zero). + + We do not distinguish between end-of-file and error, and callers + must use feof(3) and ferror(3) to determine which occurred. + */ +static long +_stdio_read(void *user_data, void *buf, long int count) +{ + _UserData *const ud = user_data; + long read_size; + + read_size = fread(buf, 1, count, ud->fd); + + if (read_size != count) + { /* fixme -- ferror/feof */ + if (feof (ud->fd)) + { + cdio_debug ("fread (): EOF encountered"); + clearerr (ud->fd); + } + else if (ferror (ud->fd)) + { + cdio_error ("fread (): %s", strerror (errno)); + clearerr (ud->fd); + } + else + cdio_debug ("fread (): short read and no EOF?!?"); + } + + return read_size; +} + +/*! + Deallocate resources assocaited with obj. After this obj is unusable. +*/ +void +cdio_stdio_destroy(CdioDataSource_t *p_obj) +{ + cdio_stream_destroy(p_obj); +} + +CdioDataSource_t * +cdio_stdio_new(const char pathname[]) +{ + CdioDataSource_t *new_obj = NULL; + cdio_stream_io_functions funcs = { NULL, NULL, NULL, NULL, NULL, NULL }; + _UserData *ud = NULL; + struct _stat statbuf; + + if (_stat (pathname, &statbuf) == -1) + { + cdio_warn ("could not retrieve file info for `%s': %s", + pathname, strerror (errno)); + return NULL; + } + + ud = calloc (1, sizeof (_UserData)); + + ud->pathname = _strdup(pathname); + ud->st_size = statbuf.st_size; /* let's hope it doesn't change... */ + + funcs.open = _stdio_open; + funcs.seek = _stdio_seek; + funcs.stat = _stdio_stat; + funcs.read = _stdio_read; + funcs.close = _stdio_close; + funcs.free = _stdio_free; + + new_obj = cdio_stream_new(ud, &funcs); + + return new_obj; +} + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/libcdio/driver/_cdio_stream.c b/src/libcdio/driver/_cdio_stream.c new file mode 100644 index 00000000..fe2c0c07 --- /dev/null +++ b/src/libcdio/driver/_cdio_stream.c @@ -0,0 +1,223 @@ +/* + Copyright (C) 2005, 2006, 2008, 2011 Rocky Bernstein + Copyright (C) 2000, 2004, 2005 Herbert Valerio Riedel + + 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 3 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, see . +*/ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#include +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif /*HAVE_UNISTD_H*/ + +#include "cdio_assert.h" + +/* #define STREAM_DEBUG */ + +#include +#include +#include "_cdio_stream.h" + +static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.9 2008/04/22 15:29:11 karl Exp $"; + +/* + * DataSource implementations + */ + +struct _CdioDataSource { + void* user_data; + cdio_stream_io_functions op; + int is_open; + long position; +}; + +void +cdio_stream_close(CdioDataSource_t *p_obj) +{ + if (!p_obj) return; + + if (p_obj->is_open) { + cdio_debug ("closed source..."); + p_obj->op.close(p_obj->user_data); + p_obj->is_open = 0; + p_obj->position = 0; + } +} + +void +cdio_stream_destroy(CdioDataSource_t *p_obj) +{ + if (!p_obj) return; + + cdio_stream_close(p_obj); + + p_obj->op.free(p_obj->user_data); + + free(p_obj); +} + +/** + Like 3 fgetpos. + + This function gets the current file position indicator for the stream + pointed to by stream. + + @return unpon successful completion, return value is positive, else, + the global variable errno is set to indicate the error. +*/ +ssize_t +cdio_stream_getpos(CdioDataSource_t* p_obj, /*out*/ ssize_t *i_offset) +{ + if (!p_obj || !p_obj->is_open) return DRIVER_OP_UNINIT; + return *i_offset = p_obj->position; +} + +CdioDataSource_t * +cdio_stream_new(void *user_data, const cdio_stream_io_functions *funcs) +{ + CdioDataSource_t *new_obj; + + new_obj = calloc (1, sizeof (CdioDataSource_t)); + + new_obj->user_data = user_data; + memcpy(&(new_obj->op), funcs, sizeof(cdio_stream_io_functions)); + + return new_obj; +} + +/* + Open if not already open. + Return false if we hit an error. Errno should be set for that error. +*/ +static bool +_cdio_stream_open_if_necessary(CdioDataSource_t *p_obj) +{ + if (!p_obj) return false; + + if (!p_obj->is_open) { + if (p_obj->op.open(p_obj->user_data)) { + cdio_warn ("could not open input stream..."); + return false; + } else { + cdio_debug ("opened source..."); + p_obj->is_open = 1; + p_obj->position = 0; + } + } + return true; +} + +/** + Like fread(3) and in fact may be the same. + + DESCRIPTION: + The function fread reads nmemb elements of data, each size bytes long, + from the stream pointed to by stream, storing them at the location + given by ptr. + + RETURN VALUE: + return the number of items successfully read or written (i.e., + not the number of characters). If an error occurs, or the + end-of-file is reached, the return value is a short item count + (or zero). + + We do not distinguish between end-of-file and error, and callers + must use feof(3) and ferror(3) to determine which occurred. +*/ +ssize_t +cdio_stream_read(CdioDataSource_t* p_obj, void *ptr, long size, long nmemb) +{ + long read_bytes; + + if (!p_obj) return 0; + if (!_cdio_stream_open_if_necessary(p_obj)) return 0; + + read_bytes = (p_obj->op.read)(p_obj->user_data, ptr, size*nmemb); + p_obj->position += read_bytes; + + return read_bytes; +} + +/** + Like 3 fseek and in fact may be the same. + + This function sets the file position indicator for the stream + pointed to by stream. The new position, measured in bytes, is obtained + by adding offset bytes to the position specified by whence. If whence + is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to + the start of the file, the current position indicator, or end-of-file, + respectively. A successful call to the fseek function clears the end- + of-file indicator for the stream and undoes any effects of the + ungetc(3) function on the same stream. + + @return unpon successful completion, return value is positive, else, + the global variable errno is set to indicate the error. +*/ +ssize_t +cdio_stream_seek(CdioDataSource_t* p_obj, ssize_t offset, int whence) +{ + if (!p_obj) return DRIVER_OP_UNINIT; + + if (!_cdio_stream_open_if_necessary(p_obj)) + /* errno is set by _cdio_stream_open_if necessary. */ + return DRIVER_OP_ERROR; + + if (offset < 0) return DRIVER_OP_ERROR; + + if (p_obj->position != offset) { +#ifdef STREAM_DEBUG + cdio_warn("had to reposition DataSource from %ld to %ld!", obj->position, offset); +#endif + p_obj->position = (long)offset; + return p_obj->op.seek(p_obj->user_data, (long)offset, whence); + } + + return 0; +} + +/** + Return whatever size of stream reports, I guess unit size is bytes. + On error return -1; + */ +ssize_t +cdio_stream_stat(CdioDataSource_t *p_obj) +{ + if (!p_obj) return -1; + if (!_cdio_stream_open_if_necessary(p_obj)) return -1; + + return p_obj->op.stat(p_obj->user_data); +} + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/libcdio/driver/cdio_private.h b/src/libcdio/driver/cdio_private.h index cb94483d..c879b6d7 100644 --- a/src/libcdio/driver/cdio_private.h +++ b/src/libcdio/driver/cdio_private.h @@ -27,62 +27,536 @@ #endif #include -#include -#include +#include +//#include +//#include "mmc/mmc_private.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + extern const char * cdio_dirname(const char *fname); + extern const char *cdio_abspath(const char *cwd, const char *fname); + + /* Opaque type */ + typedef struct _CdioDataSource CdioDataSource_t; + +#ifdef __cplusplus +} + +#endif /* __cplusplus */ + +#include "generic.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + typedef struct { + + /*! + Get volume of an audio CD. + + @param p_env the CD object to be acted upon. + + */ + driver_return_code_t (*audio_get_volume) + (void *p_env, /*out*/ cdio_audio_volume_t *p_volume); + + /*! + Pause playing CD through analog output + + @param p_env the CD object to be acted upon. + */ + driver_return_code_t (*audio_pause) (void *p_env); + + /*! + Playing CD through analog output + + @param p_env the CD object to be acted upon. + */ + driver_return_code_t (*audio_play_msf) ( void *p_env, + msf_t *p_start_msf, + msf_t *p_end_msf ); + + /*! + Playing CD through analog output + + @param p_env the CD object to be acted upon. + */ + driver_return_code_t (*audio_play_track_index) + ( void *p_env, cdio_track_index_t *p_track_index ); + + /*! + Get subchannel information. + + @param p_env the CD object to be acted upon. + */ + driver_return_code_t (*audio_read_subchannel) + ( void *p_env, cdio_subchannel_t *subchannel ); + + /*! + Resume playing an audio CD. + + @param p_env the CD object to be acted upon. + + */ + driver_return_code_t (*audio_resume) ( void *p_env ); + + /*! + Set volume of an audio CD. + + @param p_env the CD object to be acted upon. + + */ + driver_return_code_t (*audio_set_volume) + ( void *p_env, cdio_audio_volume_t *p_volume ); + + /*! + Stop playing an audio CD. + + @param p_env the CD object to be acted upon. + + */ + driver_return_code_t (*audio_stop) ( void *p_env ); + + /*! + Eject media in CD drive. If successful, as a side effect we + also free p_env. + + @param p_env the CD object to be acted upon. + If the CD is ejected *p_env is freed and p_env set to NULL. + */ + driver_return_code_t (*eject_media) ( void *p_env ); + + /*! + Release and free resources associated with cd. + */ + void (*free) (void *p_env); + + /*! + Return the value associated with the key "arg". + */ + const char * (*get_arg) (void *p_env, const char key[]); + + /*! + Get the block size for subsequest read requests, via a SCSI MMC + MODE_SENSE 6 command. + */ + int (*get_blocksize) ( void *p_env ); + + /*! + Get cdtext information for a CdIo object. + + @param obj the CD object that may contain CD-TEXT information. + @return the CD-TEXT object or NULL if obj is NULL + or CD-TEXT information does not exist. + */ + cdtext_t * (*get_cdtext) ( void *p_env ); + + /*! + Get raw cdtext information as on the disc for a CdIo object + + @param obj the CD object that may contain CD-TEXT information. + @return pointer to the raw CD-TEXT data or NULL if obj is NULL + or no CD-TEXT information present on the disc. + + free when done and not NULL. + */ + uint8_t * (*get_cdtext_raw) ( void *p_env ); + + /*! + Return an array of device names. if CdIo is NULL (we haven't + initialized a specific device driver), then find a suitable device + driver. + + NULL is returned if we couldn't return a list of devices. + */ + char ** (*get_devices) ( void ); + + /*! + Get the default CD device. + + @return a string containing the default CD device or NULL is + if we couldn't get a default device. + + In some situations of drivers or OS's we can't find a CD device if + there is no media in it and it is possible for this routine to return + NULL even though there may be a hardware CD-ROM. + */ + char * (*get_default_device) ( void ); + + /*! + Return the size of the CD in logical block address (LBA) units. + @return the lsn. On error 0 or CDIO_INVALD_LSN. + */ + lsn_t (*get_disc_last_lsn) ( void *p_env ); + + /*! + Get disc mode associated with cd_obj. + */ + discmode_t (*get_discmode) ( void *p_env ); + + /*! + Return the what kind of device we've got. + + See cd_types.h for a list of bitmasks for the drive type; + */ + void (*get_drive_cap) (const void *p_env, + cdio_drive_read_cap_t *p_read_cap, + cdio_drive_write_cap_t *p_write_cap, + cdio_drive_misc_cap_t *p_misc_cap); + /*! + Return the number of of the first track. + CDIO_INVALID_TRACK is returned on error. + */ + track_t (*get_first_track_num) ( void *p_env ); + + /*! + Get the CD-ROM hardware info via a SCSI MMC INQUIRY command. + False is returned if we had an error getting the information. + */ + bool (*get_hwinfo) + ( const CdIo_t *p_cdio, /* out*/ cdio_hwinfo_t *p_hw_info ); + + /*! Get the LSN of the first track of the last session of + on the CD. + + @param p_cdio the CD object to be acted upon. + @param i_last_session pointer to the session number to be returned. + */ + driver_return_code_t (*get_last_session) + ( void *p_env, /*out*/ lsn_t *i_last_session ); + + /*! + Find out if media has changed since the last call. + @param p_env the CD object to be acted upon. + @return 1 if media has changed since last call, 0 if not. Error + return codes are the same as driver_return_code_t + */ + int (*get_media_changed) ( const void *p_env ); + + /*! + Return the media catalog number MCN from the CD or NULL if + there is none or we don't have the ability to get it. + */ + char * (*get_mcn) ( const void *p_env ); + + /*! + Return the number of tracks in the current medium. + CDIO_INVALID_TRACK is returned on error. + */ + track_t (*get_num_tracks) ( void *p_env ); + + /*! Return number of channels in track: 2 or 4; -2 if not + implemented or -1 for error. + Not meaningful if track is not an audio track. + */ + int (*get_track_channels) ( const void *p_env, track_t i_track ); + + /*! Return 0 if track is copy protected, 1 if not, or -1 for error + or -2 if not implimented (yet). Is this meaningful if not an + audio track? + */ + track_flag_t (*get_track_copy_permit) ( void *p_env, track_t i_track ); + + /*! + Return the starting LBA for track number + i_track in p_env. Tracks numbers start at 1. + The "leadout" track is specified either by + using track_num LEADOUT_TRACK or the total tracks+1. + CDIO_INVALID_LBA is returned on error. + */ + lba_t (*get_track_lba) ( void *p_env, track_t i_track ); + + /*! + Return the starting LBA for the pregap for track number + i_track in p_env. Tracks numbers start at 1. + CDIO_INVALID_LBA is returned on error. + */ + lba_t (*get_track_pregap_lba) ( const void *p_env, track_t i_track ); + + /*! + Return the International Standard Recording Code (ISRC) for track number + i_track in p_cdio. Track numbers start at 1. + + Note: string is malloc'd so caller has to free() the returned + string when done with it. + */ + char * (*get_track_isrc) ( const void *p_env, track_t i_track ); + + /*! + Get format of track. + */ + track_format_t (*get_track_format) ( void *p_env, track_t i_track ); + + /*! + Return true if we have XA data (green, mode2 form1) or + XA data (green, mode2 form2). That is track begins: + sync - header - subheader + 12 4 - 8 + + FIXME: there's gotta be a better design for this and get_track_format? + */ + bool (*get_track_green) ( void *p_env, track_t i_track ); + + /*! + Return the starting MSF (minutes/secs/frames) for track number + i_track in p_env. Tracks numbers start at 1. + The "leadout" track is specified either by + using i_track LEADOUT_TRACK or the total tracks+1. + False is returned on error. + */ + bool (*get_track_msf) ( void *p_env, track_t i_track, msf_t *p_msf ); + + /*! Return 1 if track has pre-emphasis, 0 if not, or -1 for error + or -2 if not implimented (yet). Is this meaningful if not an + audio track? + */ + track_flag_t (*get_track_preemphasis) + ( const void *p_env, track_t i_track ); + + /*! + lseek - reposition read/write file offset + Returns (off_t) -1 on error. + Similar to libc's lseek() + */ + off_t (*lseek) ( void *p_env, off_t offset, int whence ); + + /*! + Reads into buf the next size bytes. + Returns -1 on error. + Similar to libc's read() + */ + ssize_t (*read) ( void *p_env, void *p_buf, size_t i_size ); + + /*! + Reads a single mode2 sector from cd device into buf starting + from lsn. Returns 0 if no error. + */ + int (*read_audio_sectors) ( void *p_env, void *p_buf, lsn_t i_lsn, + unsigned int i_blocks ); + + /*! + Read a data sector + + @param p_env environment to read from + + @param p_buf place to read data into. The caller should make sure + this location can store at least CDIO_CD_FRAMESIZE, + M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending + on the kind of sector getting read. If you don't + know whether you have a Mode 1/2, Form 1/ Form 2/Formless + sector best to reserve space for the maximum, + M2RAW_SECTOR_SIZE. + + @param i_lsn sector to read + @param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE, + M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf. + */ + driver_return_code_t (*read_data_sectors) + ( void *p_env, void *p_buf, lsn_t i_lsn, uint16_t i_blocksize, + uint32_t i_blocks ); + + /*! + Reads a single mode2 sector from cd device into buf starting + from lsn. Returns 0 if no error. + */ + int (*read_mode2_sector) + ( void *p_env, void *p_buf, lsn_t i_lsn, bool b_mode2_form2 ); + + /*! + Reads i_blocks of mode2 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ + int (*read_mode2_sectors) + ( void *p_env, void *p_buf, lsn_t i_lsn, bool b_mode2_form2, + unsigned int i_blocks ); + + /*! + Reads a single mode1 sector from cd device into buf starting + from lsn. Returns 0 if no error. + */ + int (*read_mode1_sector) + ( void *p_env, void *p_buf, lsn_t i_lsn, bool mode1_form2 ); + + /*! + Reads i_blocks of mode1 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ + int (*read_mode1_sectors) + ( void *p_env, void *p_buf, lsn_t i_lsn, bool mode1_form2, + unsigned int i_blocks ); + + bool (*read_toc) ( void *p_env ) ; + + /*! + Run a SCSI MMC command. + + cdio CD structure set by cdio_open(). + i_timeout_ms time in milliseconds we will wait for the command + to complete. + cdb_len number of bytes in cdb (6, 10, or 12). + cdb CDB bytes. All values that are needed should be set on + input. + b_return_data TRUE if the command expects data to be returned in + the buffer + len Size of buffer + buf Buffer for data, both sending and receiving + + Returns 0 if command completed successfully. + */ +// mmc_run_cmd_fn_t run_mmc_cmd; + + /*! + Set the arg "key" with "value" in the source device. + */ + int (*set_arg) ( void *p_env, const char key[], const char value[] ); + + /*! + Set the blocksize for subsequent reads. + */ + driver_return_code_t (*set_blocksize) ( void *p_env, + uint16_t i_blocksize ); + + /*! + Set the drive speed. + + @return 0 if everything went okay, -1 if we had an error. is -2 + returned if this is not implemented for the current driver. + */ + int (*set_speed) ( void *p_env, int i_speed ); + + } cdio_funcs_t; -#define CdioDataSource_t int /*! Implementation of CdIo type */ struct _CdIo { -// driver_id_t driver_id; /**< Particular driver opened. */ -// cdio_funcs_t op; /**< driver-specific routines handling -// implementation*/ + driver_id_t driver_id; /**< Particular driver opened. */ + cdio_funcs_t op; /**< driver-specific routines handling + implementation*/ void *env; /**< environment. Passed to routine above. */ }; - typedef struct { - char *source_name; /**< Name used in open. */ - bool init; /**< True if structure has been initialized */ - bool toc_init; /**< True if TOC read in */ - bool b_cdtext_error; /**< True if trouble reading CD-Text */ - - int ioctls_debugged; /**< for debugging */ - - /* Only one of data_source or fd is used; fd is for CD-ROM - devices and the data_source for stream reading (bincue, nrg, toc, - network). - */ - CdioDataSource_t *data_source; - int fd; /**< File descriptor of device */ - track_t i_first_track; /**< The starting track number. */ - track_t i_tracks; /**< The number of tracks. */ - - uint8_t i_joliet_level; /**< 0 = no Joliet extensions. - 1-3: Joliet level. */ - iso9660_pvd_t pvd; - iso9660_svd_t svd; - CdIo_t *cdio; /**< a way to call general cdio routines. */ -// cdtext_t *cdtext; /**< CD-Text for disc. */ -// track_flags_t track_flags[CDIO_CD_MAX_TRACKS+1]; - - /* Memorized sense reply of the most recent SCSI command. - Recorded by driver implementations of cdio_funcs_t.run_mmc_cmd(). - Read by API function mmc_get_cmd_scsi_sense(). - */ -// unsigned char scsi_mmc_sense[263]; /* See SPC-3 4.5.3 : 252 bytes legal -// but 263 bytes possible */ -// int scsi_mmc_sense_valid; /* Number of valid sense bytes */ - - /* Memorized eventual system specific SCSI address tuple text. - Empty text means that there is no such text defined for the drive. - NULL means that the driver does not support "scsi-tuple". - To be read by cdio_get_arg("scsi-tuple"). - System specific suffixes to the key may demand and eventually - guarantee a further specified format. - E.g. "scsi-tuple-linux" guarantees either "Bus,Host,Channel,Target,Lun", - or empty text, or NULL. No other forms. - */ - char *scsi_tuple; - } generic_img_private_t; + /* This is used in drivers that must keep their own internal + position pointer for doing seeks. Stream-based drivers (like bincue, + nrg, toc, network) would use this. + */ + typedef struct + { + off_t buff_offset; /* buffer offset in disk-image seeks. */ + track_t index; /* Current track index in tocent. */ + lba_t lba; /* Current LBA */ + } internal_position_t; -#endif + CdIo_t * cdio_new (generic_img_private_t *p_env, cdio_funcs_t *p_funcs); + + /* The below structure describes a specific CD Input driver */ + typedef struct + { + driver_id_t id; + unsigned int flags; + const char *name; + const char *describe; + bool (*have_driver) (void); + CdIo_t *(*driver_open) (const char *psz_source_name); + CdIo_t *(*driver_open_am) (const char *psz_source_name, + const char *psz_access_mode); + char *(*get_default_device) (void); + bool (*is_device) (const char *psz_source_name); + char **(*get_devices) (void); + driver_return_code_t (*close_tray) (const char *psz_device); + } CdIo_driver_t; + + /* The below array gives of the drivers that are currently available for + on a particular host. */ + extern CdIo_driver_t CdIo_driver[]; + + /* The last valid entry of Cdio_driver. -1 means uninitialzed. -2 + means some sort of error. + */ + extern int CdIo_last_driver; + + /* The below array gives all drivers that can possibly appear. + on a particular host. */ + extern CdIo_driver_t CdIo_all_drivers[]; + + /*! + Add/allocate a drive to the end of drives. + Use cdio_free_device_list() to free this device_list. + */ + void cdio_add_device_list(char **device_list[], const char *psz_drive, + unsigned int *i_drives); + + driver_return_code_t close_tray_bsdi (const char *psz_drive); + driver_return_code_t close_tray_freebsd (const char *psz_drive); + driver_return_code_t close_tray_linux (const char *psz_drive); + driver_return_code_t close_tray_netbsd (const char *psz_drive); + driver_return_code_t close_tray_os2 (const char *psz_drive); + driver_return_code_t close_tray_osx (const char *psz_drive); + driver_return_code_t close_tray_solaris (const char *psz_drive); + driver_return_code_t close_tray_win32 (const char *psz_drive); + + bool cdio_have_netbsd(void); + CdIo_t * cdio_open_netbsd (const char *psz_source); + char * cdio_get_default_device_netbsd(void); + char **cdio_get_devices_netbsd(void); + /*! Set up CD-ROM for reading using the NetBSD driver. The device_name is + the some sort of device name. + + NULL is returned on error or there is no FreeBSD driver. + + @see cdio_open_cd, cdio_open + */ + CdIo_t * cdio_open_am_netbsd (const char *psz_source, + const char *psz_access_mode); + + /*! DEPRICATED: use cdio_have_driver(). + True if AIX driver is available. */ + bool cdio_have_aix (void); + + /*! DEPRICATED: use cdio_have_driver(). + True if BSDI driver is available. */ + bool cdio_have_bsdi (void); + + /*! DEPRICATED: use cdio_have_driver(). + True if FreeBSD driver is available. */ + bool cdio_have_freebsd (void); + + /*! DEPRICATED: use cdio_have_driver(). + True if GNU/Linux driver is available. */ + bool cdio_have_linux (void); + + /*! DEPRICATED: use cdio_have_driver(). + True if Sun Solaris driver is available. */ + bool cdio_have_solaris (void); + + /*! DEPRICATED: use cdio_have_driver(). + True if IBM OS2 driver is available. */ + bool cdio_have_os2 (void); + + /*! DEPRICATED: use cdio_have_driver(). + True if Apple OSX driver is available. */ + bool cdio_have_osx (void); + + /*! DEPRICATED: use cdio_have_driver(). + True if Microsoft Windows driver is available. */ + bool cdio_have_win32 (void); + + /*! True if Nero driver is available. */ + bool cdio_have_nrg (void); + + /*! True if BIN/CUE driver is available. */ + bool cdio_have_bincue (void); + + /*! True if cdrdao CDRDAO driver is available. */ + bool cdio_have_cdrdao (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __CDIO_PRIVATE_H__ */ diff --git a/src/libcdio/driver/disc.c b/src/libcdio/driver/disc.c new file mode 100644 index 00000000..c5faa287 --- /dev/null +++ b/src/libcdio/driver/disc.c @@ -0,0 +1,168 @@ +/* + Copyright (C) 2003, 2004, 2005, 2008, 2011 + Rocky Bernstein + Copyright (C) 2001 Herbert Valerio Riedel + + 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 3 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, see . +*/ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#include +#include "cdio_private.h" + +/* Must match discmode enumeration */ +const char *discmode2str[] = { + "CD-DA", + "CD-DATA (Mode 1)", + "CD DATA (Mode 2)", + "CD-ROM Mixed", + "DVD-ROM", + "DVD-RAM", + "DVD-R", + "DVD-RW", + "HD DVD ROM", + "HD_DVD RAM", + "HD DVD-R", + "DVD+R", + "DVD+RW", + "DVD+RW DL", + "DVD+R DL", + "Unknown/unclassified DVD", + "No information", + "Error in getting information", + "CD-i" +}; + +/*! + Get cdtext information for a CdIo object . + + @param obj the CD object that may contain CD-TEXT information. + @return the CD-TEXT object or NULL if obj is NULL + or CD-TEXT information does not exist. +*/ +cdtext_t * +cdio_get_cdtext (CdIo *obj) +{ + if (obj == NULL) return NULL; + + if (NULL != obj->op.get_cdtext) { + return obj->op.get_cdtext (obj->env); + } else { + return NULL; + } +} + +/*! + Get binary cdtext information for a CdIo object . + + @param obj the CD object that may contain CD-TEXT information. + @return pointer to allocated memory area holding the raw CD-TEXT + or NULL if obj is NULL or CD-TEXT does not exist. + free() when done. +*/ +uint8_t * +cdio_get_cdtext_raw (CdIo *obj) +{ + if (obj == NULL) return NULL; + + if (NULL != obj->op.get_cdtext_raw) { + return obj->op.get_cdtext_raw (obj->env); + } else { + return NULL; + } +} + +/*! + Get the size of the CD in logical block address (LBA) units. + + @param p_cdio the CD object queried + @return the lsn. On error 0 or CDIO_INVALD_LSN. +*/ +lsn_t +cdio_get_disc_last_lsn(const CdIo_t *p_cdio) +{ + if (!p_cdio) return CDIO_INVALID_LSN; + return p_cdio->op.get_disc_last_lsn (p_cdio->env); +} + +/*! + Get medium associated with cd_obj. +*/ +discmode_t +cdio_get_discmode (CdIo_t *cd_obj) +{ + if (!cd_obj) return CDIO_DISC_MODE_ERROR; + + if (cd_obj->op.get_discmode) { + return cd_obj->op.get_discmode (cd_obj->env); + } else { + return CDIO_DISC_MODE_NO_INFO; + } +} + +/*! + Return a string containing the name of the driver in use. + if CdIo is NULL (we haven't initialized a specific device driver), + then return NULL. +*/ +char * +cdio_get_mcn (const CdIo_t *p_cdio) +{ + if (p_cdio->op.get_mcn) { + return p_cdio->op.get_mcn (p_cdio->env); + } else { + return NULL; + } +} + +bool +cdio_is_discmode_cdrom(discmode_t discmode) +{ + switch (discmode) { + case CDIO_DISC_MODE_CD_DA: + case CDIO_DISC_MODE_CD_DATA: + case CDIO_DISC_MODE_CD_XA: + case CDIO_DISC_MODE_CD_MIXED: + case CDIO_DISC_MODE_NO_INFO: + return true; + default: + return false; + } +} + +bool +cdio_is_discmode_dvd(discmode_t discmode) +{ + switch (discmode) { + case CDIO_DISC_MODE_DVD_ROM: + case CDIO_DISC_MODE_DVD_RAM: + case CDIO_DISC_MODE_DVD_R: + case CDIO_DISC_MODE_DVD_RW: + case CDIO_DISC_MODE_DVD_PR: + case CDIO_DISC_MODE_DVD_PRW: + case CDIO_DISC_MODE_DVD_OTHER: + return true; + default: + return false; + } +} diff --git a/src/libcdio/driver/ds.c b/src/libcdio/driver/ds.c new file mode 100644 index 00000000..0d5bf693 --- /dev/null +++ b/src/libcdio/driver/ds.c @@ -0,0 +1,255 @@ +/* + Copyright (C) 2005, 2008, 2011 Rocky Bernstein + Copyright (C) 2000 Herbert Valerio Riedel + + 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 3 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, see . +*/ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#include +#include + +#include +#include +#include +#include "cdio_assert.h" + +static const char _rcsid[] = "$Id: ds.c,v 1.4 2008/04/22 15:29:12 karl Exp $"; + +struct _CdioList +{ + unsigned length; + + CdioListNode_t *begin; + CdioListNode_t *end; +}; + +struct _CdioListNode +{ + CdioList_t *list; + + CdioListNode_t *next; + + void *data; +}; + +/* impl */ + +CdioList_t * +_cdio_list_new (void) +{ + CdioList_t *p_new_obj = calloc (1, sizeof (CdioList_t)); + + return p_new_obj; +} + +void +_cdio_list_free (CdioList_t *p_list, int free_data) +{ + while (_cdio_list_length (p_list)) + _cdio_list_node_free (_cdio_list_begin (p_list), free_data); + + free (p_list); +} + +unsigned +_cdio_list_length (const CdioList_t *p_list) +{ + cdio_assert (p_list != NULL); + + return p_list->length; +} + +void +_cdio_list_prepend (CdioList_t *p_list, void *p_data) +{ + CdioListNode_t *p_new_node; + + cdio_assert (p_list != NULL); + + p_new_node = calloc (1, sizeof (CdioListNode_t)); + + p_new_node->list = p_list; + p_new_node->next = p_list->begin; + p_new_node->data = p_data; + + p_list->begin = p_new_node; + if (p_list->length == 0) + p_list->end = p_new_node; + + p_list->length++; +} + +void +_cdio_list_append (CdioList_t *p_list, void *p_data) +{ + cdio_assert (p_list != NULL); + + if (p_list->length == 0) + { + _cdio_list_prepend (p_list, p_data); + } + else + { + CdioListNode_t *p_new_node = calloc (1, sizeof (CdioListNode_t)); + + p_new_node->list = p_list; + p_new_node->next = NULL; + p_new_node->data = p_data; + + p_list->end->next = p_new_node; + p_list->end = p_new_node; + + p_list->length++; + } +} + +void +_cdio_list_foreach (CdioList_t *p_list, _cdio_list_iterfunc_t func, + void *p_user_data) +{ + CdioListNode_t *node; + + cdio_assert (p_list != NULL); + cdio_assert (func != 0); + + for (node = _cdio_list_begin (p_list); + node != NULL; + node = _cdio_list_node_next (node)) + func (_cdio_list_node_data (node), p_user_data); +} + +CdioListNode_t * +_cdio_list_find (CdioList_t *p_list, _cdio_list_iterfunc_t cmp_func, + void *p_user_data) +{ + CdioListNode_t *p_node; + + cdio_assert (p_list != NULL); + cdio_assert (cmp_func != 0); + + for (p_node = _cdio_list_begin (p_list); + p_node != NULL; + p_node = _cdio_list_node_next (p_node)) + if (cmp_func (_cdio_list_node_data (p_node), p_user_data)) + break; + + return p_node; +} + +CdioListNode_t * +_cdio_list_begin (const CdioList_t *p_list) +{ + cdio_assert (p_list != NULL); + + return p_list->begin; +} + +CdioListNode_t * +_cdio_list_end (CdioList_t *p_list) +{ + cdio_assert (p_list != NULL); + + return p_list->end; +} + +CdioListNode_t * +_cdio_list_node_next (CdioListNode_t *p_node) +{ + if (p_node) + return p_node->next; + + return NULL; +} + +void +_cdio_list_node_free (CdioListNode_t *p_node, int free_data) +{ + CdioList_t *p_list; + CdioListNode_t *prev_node; + + cdio_assert (p_node != NULL); + + p_list = p_node->list; + + cdio_assert (_cdio_list_length (p_list) > 0); + + if (free_data) + free (_cdio_list_node_data (p_node)); + + if (_cdio_list_length (p_list) == 1) + { + cdio_assert (p_list->begin == p_list->end); + + p_list->end = p_list->begin = NULL; + p_list->length = 0; + free (p_node); + return; + } + + cdio_assert (p_list->begin != p_list->end); + + if (p_list->begin == p_node) + { + p_list->begin = p_node->next; + free (p_node); + p_list->length--; + return; + } + + for (prev_node = p_list->begin; prev_node->next; prev_node = prev_node->next) + if (prev_node->next == p_node) + break; + + cdio_assert (prev_node->next != NULL); + + if (p_list->end == p_node) + p_list->end = prev_node; + + prev_node->next = p_node->next; + + p_list->length--; + + free (p_node); +} + +void * +_cdio_list_node_data (CdioListNode_t *p_node) +{ + if (p_node) + return p_node->data; + + return NULL; +} + +/* eof */ + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ + diff --git a/src/libcdio/driver/generic.h b/src/libcdio/driver/generic.h new file mode 100644 index 00000000..aad93d62 --- /dev/null +++ b/src/libcdio/driver/generic.h @@ -0,0 +1,249 @@ +/* + Copyright (C) 2004, 2005, 2006, 2008, 2009 Rocky Bernstein + + 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 3 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, see . +*/ + +/* Internal routines for CD I/O drivers. */ + + +#ifndef __CDIO_GENERIC_H__ +#define __CDIO_GENERIC_H__ + +#if defined(HAVE_CONFIG_H) && !defined(LIBCDIO_CONFIG_H) +# include "config.h" +#endif + +#include +//#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + /*! + Things common to private device structures. Even though not all + devices may have some of these fields, by listing common ones + we facilitate writing generic routines and even cut-and-paste + code. + */ + typedef struct { + char *source_name; /**< Name used in open. */ + bool init; /**< True if structure has been initialized */ + bool toc_init; /**< True if TOC read in */ + bool b_cdtext_error; /**< True if trouble reading CD-Text */ + + int ioctls_debugged; /**< for debugging */ + + /* Only one of data_source or fd is used; fd is for CD-ROM + devices and the data_source for stream reading (bincue, nrg, toc, + network). + */ + CdioDataSource_t *data_source; + int fd; /**< File descriptor of device */ + track_t i_first_track; /**< The starting track number. */ + track_t i_tracks; /**< The number of tracks. */ + + uint8_t i_joliet_level; /**< 0 = no Joliet extensions. + 1-3: Joliet level. */ + iso9660_pvd_t pvd; + iso9660_svd_t svd; + CdIo_t *cdio; /**< a way to call general cdio routines. */ + cdtext_t *cdtext; /**< CD-Text for disc. */ +// track_flags_t track_flags[CDIO_CD_MAX_TRACKS+1]; + + /* Memorized sense reply of the most recent SCSI command. + Recorded by driver implementations of cdio_funcs_t.run_mmc_cmd(). + Read by API function mmc_get_cmd_scsi_sense(). + */ + unsigned char scsi_mmc_sense[263]; /* See SPC-3 4.5.3 : 252 bytes legal + but 263 bytes possible */ + int scsi_mmc_sense_valid; /* Number of valid sense bytes */ + + /* Memorized eventual system specific SCSI address tuple text. + Empty text means that there is no such text defined for the drive. + NULL means that the driver does not support "scsi-tuple". + To be read by cdio_get_arg("scsi-tuple"). + System specific suffixes to the key may demand and eventually + guarantee a further specified format. + E.g. "scsi-tuple-linux" guarantees either "Bus,Host,Channel,Target,Lun", + or empty text, or NULL. No other forms. + */ + char *scsi_tuple; + } generic_img_private_t; + + /*! + Bogus eject media when there is no ejectable media, e.g. a disk image + We always return 2. Should we also free resources? + */ + driver_return_code_t cdio_generic_unimplemented_eject_media (void *p_env); + + /*! + Set the blocksize for subsequent reads. + + @return -2 since it's not implemented. + */ + driver_return_code_t + cdio_generic_unimplemented_set_blocksize (void *p_user_data, + uint16_t i_blocksize); + + /*! + Set the drive speed. + + @return -2 since it's not implemented. + */ + driver_return_code_t cdio_generic_unimplemented_set_speed (void *p_user_data, + int i_speed); + + /*! + Release and free resources associated with cd. + */ + void cdio_generic_free (void *p_env); + + /*! + Initialize CD device. + */ + bool cdio_generic_init (void *p_env, int open_mode); + + /*! + Reads into buf the next size bytes. + Returns -1 on error. + Is in fact libc's read(). + */ + off_t cdio_generic_lseek (void *p_env, off_t offset, int whence); + + /*! + Reads into buf the next size bytes. + Returns -1 on error. + Is in fact libc's read(). + */ + ssize_t cdio_generic_read (void *p_env, void *p_buf, size_t size); + + /*! + Reads a single form1 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ + int cdio_generic_read_form1_sector (void * user_data, void *data, + lsn_t lsn); + + /*! + Release and free resources associated with stream or disk image. + */ + void cdio_generic_stdio_free (void *env); + + /*! + Return true if source_name could be a device containing a CD-ROM on + Win32 + */ + bool cdio_is_device_win32(const char *source_name); + + /*! + Return true if source_name could be a device containing a CD-ROM on + OS/2 + */ + bool cdio_is_device_os2(const char *source_name); + + + /*! + Return true if source_name could be a device containing a CD-ROM on + most Unix servers with block and character devices. + */ + bool cdio_is_device_generic(const char *source_name); + + + /*! + Like above, but don't give a warning device doesn't exist. + */ + bool cdio_is_device_quiet_generic(const char *source_name); + + /*! + Get cdtext information for a CdIo object . + + @param obj the CD object that may contain CD-TEXT information. + @return the CD-TEXT object or NULL if obj is NULL + or CD-TEXT information does not exist. + */ + cdtext_t *get_cdtext_generic (void *p_user_data); + + /*! + Return the number of of the first track. + CDIO_INVALID_TRACK is returned on error. + */ + track_t get_first_track_num_generic(void *p_user_data); + + /*! + Return the number of tracks in the current medium. + */ + track_t get_num_tracks_generic(void *p_user_data); + + /*! + Get disc type associated with cd object. + */ + discmode_t get_discmode_generic (void *p_user_data ); + + /*! + Same as above but only handles CD cases + */ + discmode_t get_discmode_cd_generic (void *p_user_data ); + + /*! Return number of channels in track: 2 or 4; -2 if not + implemented or -1 for error. + Not meaningful if track is not an audio track. + */ + int get_track_channels_generic(const void *p_user_data, track_t i_track); + + /*! Return 1 if copy is permitted on the track, 0 if not, or -1 for error. + Is this meaningful if not an audio track? + */ + track_flag_t get_track_copy_permit_generic(void *p_user_data, + track_t i_track); + + /*! Return 1 if track has pre-emphasis, 0 if not, or -1 for error. + Is this meaningful if not an audio track? + + pre-emphasis is a non linear frequency response. + */ + track_flag_t get_track_preemphasis_generic(const void *p_user_data, + track_t i_track); + + /*! + Read cdtext information for a CdIo object . + + return true on success, false on error or CD-Text information does + not exist. + */ + uint8_t * read_cdtext_generic (void *p_env); + + void set_track_flags(track_flags_t *p_track_flag, uint8_t flag); + + /*! Read mode 1 or mode2 sectors (using cooked mode). */ + driver_return_code_t read_data_sectors_generic (void *p_user_data, + void *p_buf, lsn_t i_lsn, + uint16_t i_blocksize, + uint32_t i_blocks); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __CDIO_GENERIC_H__ */ + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/libcdio/driver/logging.c b/src/libcdio/driver/logging.c new file mode 100644 index 00000000..3e74639a --- /dev/null +++ b/src/libcdio/driver/logging.c @@ -0,0 +1,146 @@ +/* + Copyright (C) 2003, 2004, 2008, 2011 Rocky Bernstein + Copyright (C) 2000 Herbert Valerio Riedel + + 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 3 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, see . +*/ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#include +#include +#include + +#include +#include "cdio_assert.h" +#include "portable.h" + +static const char _rcsid[] = "$Id: logging.c,v 1.2 2008/04/22 15:29:12 karl Exp $"; + +cdio_log_level_t cdio_loglevel_default = CDIO_LOG_WARN; + +static void +default_cdio_log_handler (cdio_log_level_t level, const char message[]) +{ + switch (level) + { + case CDIO_LOG_ERROR: + if (level >= cdio_loglevel_default) { + fprintf (stderr, "**ERROR: %s\n", message); + fflush (stderr); + } + exit (EXIT_FAILURE); + break; + case CDIO_LOG_DEBUG: + if (level >= cdio_loglevel_default) { + fprintf (stdout, "--DEBUG: %s\n", message); + } + break; + case CDIO_LOG_WARN: + if (level >= cdio_loglevel_default) { + fprintf (stdout, "++ WARN: %s\n", message); + } + break; + case CDIO_LOG_INFO: + if (level >= cdio_loglevel_default) { + fprintf (stdout, " INFO: %s\n", message); + } + break; + case CDIO_LOG_ASSERT: + if (level >= cdio_loglevel_default) { + fprintf (stderr, "!ASSERT: %s\n", message); + fflush (stderr); + } + abort (); + break; + default: + cdio_assert_not_reached (); + break; + } + + fflush (stdout); +} + +static cdio_log_handler_t _handler = default_cdio_log_handler; + +cdio_log_handler_t +cdio_log_set_handler (cdio_log_handler_t new_handler) +{ + cdio_log_handler_t old_handler = _handler; + + _handler = new_handler; + + return old_handler; +} + +static void +cdio_logv (cdio_log_level_t level, const char format[], va_list args) +{ + char buf[1024] = { 0, }; + static int in_recursion = 0; + + if (in_recursion) + cdio_assert_not_reached (); + + in_recursion = 1; + + _vsnprintf(buf, sizeof(buf)-1, format, args); + + _handler(level, buf); + + in_recursion = 0; +} + +void +cdio_log (cdio_log_level_t level, const char format[], ...) +{ + va_list args; + va_start (args, format); + cdio_logv (level, format, args); + va_end (args); +} + +#define CDIO_LOG_TEMPLATE(level, LEVEL) \ +void \ +cdio_ ## level (const char format[], ...) \ +{ \ + va_list args; \ + va_start (args, format); \ + cdio_logv (CDIO_LOG_ ## LEVEL, format, args); \ + va_end (args); \ +} + +CDIO_LOG_TEMPLATE(debug, DEBUG) +CDIO_LOG_TEMPLATE(info, INFO) +CDIO_LOG_TEMPLATE(warn, WARN) +CDIO_LOG_TEMPLATE(error, ERROR) + +#undef CDIO_LOG_TEMPLATE + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/libcdio/driver/portable.h b/src/libcdio/driver/portable.h new file mode 100644 index 00000000..4d593c8c --- /dev/null +++ b/src/libcdio/driver/portable.h @@ -0,0 +1,75 @@ +/* + Copyright (C) 2006, 2008, 2011 Rocky Bernstein + + 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 3 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, see . +*/ + +/* + This file contains definitions to fill in for differences or + deficiencies to OS or compiler irregularities. If this file is + included other routines can be more portable. +*/ + +#ifndef __CDIO_PORTABLE_H__ +#define __CDIO_PORTABLE_H__ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#if !defined(HAVE_FTRUNCATE) +# if defined (_WIN32) +# define ftruncate chsize +# endif +#endif /*HAVE_FTRUNCATE*/ + +#if !defined(HAVE_SNPRINTF) +# if defined (_MSC_VER) +# define snprintf _snprintf +# endif +#endif /*HAVE_SNPRINTF*/ + +#if !defined(HAVE_DRAND48) && defined(HAVE_RAND) +# define drand48() (rand() / (double)RAND_MAX) +#endif + +#ifdef _MSC_VER +# include + +# ifndef S_ISBLK +# define _S_IFBLK 0060000 /* Block Special */ +# define S_ISBLK(x) (x & _S_IFBLK) +# endif + +# ifndef S_ISCHR +# define _S_IFCHR 0020000 /* character special */ +# define S_ISCHR(x) (x & _S_IFCHR) +# endif +#endif /* _MSC_VER */ + +#if defined(HAVE_MEMSET) +# define BZERO(ptr, size) memset(ptr, 0, size) +#elif defined(HAVE_BZERO) +# define BZERO(ptr, size) bzero(ptr, size) +#else +#error You need either memset or bzero +#endif + +#endif /* __CDIO_PORTABLE_H__ */ diff --git a/src/libcdio/driver/read.c b/src/libcdio/driver/read.c new file mode 100644 index 00000000..8eb9ff90 --- /dev/null +++ b/src/libcdio/driver/read.c @@ -0,0 +1,335 @@ +/* + Copyright (C) 2005, 2008, 2011 Rocky Bernstein + + 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 3 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, see . +*/ +/** \file read.h + * + * \brief sector (block, frame)-related libcdio routines. + */ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#include +#include +#include "cdio_private.h" +#include "cdio_assert.h" + +#ifdef HAVE_STRING_H +#include +#endif + +#define check_read_parms(p_cdio, p_buf, i_lsn) \ + if (!p_cdio) return DRIVER_OP_UNINIT; \ + if (!p_buf || CDIO_INVALID_LSN == i_lsn) \ + return DRIVER_OP_ERROR; + +#define check_lsn(i_lsn) \ + check_read_parms(p_cdio, p_buf, i_lsn); \ + { \ + lsn_t end_lsn = \ + cdio_get_track_lsn(p_cdio, CDIO_CDROM_LEADOUT_TRACK); \ + if ( i_lsn > end_lsn ) { \ + cdio_info("Trying to access past end of disk lsn: %ld, end lsn: %ld", \ + (long int) i_lsn, (long int) end_lsn); \ + return DRIVER_OP_ERROR; \ + } \ + } + +#define check_lsn_blocks(i_lsn, i_blocks) \ + check_read_parms(p_cdio, p_buf, i_lsn); \ + { \ + lsn_t end_lsn = \ + cdio_get_track_lsn(p_cdio, CDIO_CDROM_LEADOUT_TRACK); \ + if ( i_lsn > end_lsn ) { \ + cdio_info("Trying to access past end of disk lsn: %ld, end lsn: %ld", \ + (long int) i_lsn, (long int) end_lsn); \ + return DRIVER_OP_ERROR; \ + } \ + /* Care is used in the expression below to be correct with */ \ + /* respect to unsigned integers. */ \ + if ( i_lsn + i_blocks > end_lsn + 1 ) { \ + cdio_info("Request truncated to end disk; lsn: %ld, end lsn: %ld", \ + (long int) i_lsn, (long int) end_lsn); \ + i_blocks = end_lsn - i_lsn + 1; \ + } \ + } + +/*! + lseek - reposition read/write file offset + Returns (off_t) -1 on error. + Similar to (if not the same as) libc's lseek() +*/ +off_t +cdio_lseek (const CdIo_t *p_cdio, off_t offset, int whence) +{ + if (!p_cdio) return DRIVER_OP_UNINIT; + + if (p_cdio->op.lseek) + return (p_cdio->op.lseek) (p_cdio->env, offset, whence); + return DRIVER_OP_UNSUPPORTED; +} + +/*! Reads into buf the next size bytes. Similar to (if not the + same as) libc's read(). This is a "cooked" read, or one handled by + the OS. It probably won't work on audio data. For that use + cdio_read_audio_sector(s). + + @param p_cdio object to read from + @param p_buf place to read data into. The caller should make sure + this location can store at least i_size bytes. + @param i_size number of bytes to read + + @return (ssize_t) -1 on error. +*/ +ssize_t +cdio_read (const CdIo_t *p_cdio, void *p_buf, size_t i_size) +{ + if (!p_cdio) return DRIVER_OP_UNINIT; + + if (p_cdio->op.read) + return (p_cdio->op.read) (p_cdio->env, p_buf, i_size); + return DRIVER_OP_UNSUPPORTED; +} + +/*! + Reads an audio sector from cd device into data starting + from lsn. Returns DRIVER_OP_SUCCESS if no error. +*/ +driver_return_code_t +cdio_read_audio_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn) +{ + check_lsn(i_lsn); + if (p_cdio->op.read_audio_sectors) + return p_cdio->op.read_audio_sectors (p_cdio->env, p_buf, i_lsn, 1); + return DRIVER_OP_UNSUPPORTED; +} + +/*! + Reads audio sectors from cd device into data starting + from lsn. Returns DRIVER_OP_SUCCESS if no error. +*/ +driver_return_code_t +cdio_read_audio_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, + uint32_t i_blocks) +{ + lsn_t _i_blocks = (lsn_t)i_blocks; + check_lsn_blocks(i_lsn, _i_blocks); + + if (0 == i_blocks) return DRIVER_OP_SUCCESS; + + if (p_cdio->op.read_audio_sectors) + return (p_cdio->op.read_audio_sectors) (p_cdio->env, p_buf, i_lsn, + i_blocks); + return DRIVER_OP_UNSUPPORTED; +} + +/*! + Reads an audio sector from cd device into data starting + from lsn. Returns DRIVER_OP_SUCCESS if no error. +*/ +driver_return_code_t +cdio_read_data_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, + uint16_t i_blocksize, uint32_t i_blocks) +{ + check_lsn(i_lsn); + + if (0 == i_blocks) return DRIVER_OP_SUCCESS; + + if (p_cdio->op.read_data_sectors) + return p_cdio->op.read_data_sectors (p_cdio->env, p_buf, i_lsn, + i_blocksize, i_blocks); + return DRIVER_OP_UNSUPPORTED; +} + + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +/*! + Reads a single mode1 form1 or form2 sector from cd device + into data starting from lsn. Returns DRIVER_OP_SUCCESS if no error. + */ +driver_return_code_t +cdio_read_mode1_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, + bool b_form2) +{ + uint32_t size = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ; + + check_lsn(i_lsn); + if (p_cdio->op.read_mode1_sector) { + return p_cdio->op.read_mode1_sector(p_cdio->env, p_buf, i_lsn, b_form2); + } else if (p_cdio->op.lseek && p_cdio->op.read) { + char buf[M2RAW_SECTOR_SIZE] = { 0, }; + if (0 > cdio_lseek(p_cdio, CDIO_CD_FRAMESIZE*i_lsn, SEEK_SET)) + return -1; + if (0 > cdio_read(p_cdio, buf, CDIO_CD_FRAMESIZE)) + return -1; + memcpy (p_buf, buf, size); + return DRIVER_OP_SUCCESS; + } + + return DRIVER_OP_UNSUPPORTED; +} + +/*! + Reads mode 1 sectors + + @param p_cdio object to read from + @param buf place to read data into + @param lsn sector to read + @param b_form2 true for reading mode 1 form 2 sectors or false for + mode 1 form 1 sectors. + @param i_blocks number of sectors to read +*/ +driver_return_code_t +cdio_read_mode1_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, + bool b_form2, uint32_t i_blocks) +{ + lsn_t _i_blocks = (lsn_t)i_blocks; + check_lsn_blocks(i_lsn, _i_blocks); + + if (0 == i_blocks) return DRIVER_OP_SUCCESS; + + if (p_cdio->op.read_mode1_sectors) + return (p_cdio->op.read_mode1_sectors) (p_cdio->env, p_buf, i_lsn, b_form2, + i_blocks); + return DRIVER_OP_UNSUPPORTED; +} + +/*! + Reads a mode 2 sector + + @param p_cdio object to read from + @param buf place to read data into + @param lsn sector to read + @param b_form2 true for reading mode 2 form 2 sectors or false for + mode 2 form 1 sectors. +*/ +driver_return_code_t +cdio_read_mode2_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, + bool b_form2) +{ + check_lsn(i_lsn); + if (p_cdio->op.read_mode2_sector) + return p_cdio->op.read_mode2_sector (p_cdio->env, p_buf, i_lsn, b_form2); + + /* fallback */ + if (p_cdio->op.read_mode2_sectors != NULL) + return cdio_read_mode2_sectors (p_cdio, p_buf, i_lsn, b_form2, 1); + return DRIVER_OP_UNSUPPORTED; +} + +/*! + Reads mode 2 sectors + + @param p_cdio object to read from + @param buf place to read data into + @param lsn sector to read + @param b_form2 true for reading mode2 form 2 sectors or false for + mode 2 form 1 sectors. + @param i_blocks number of sectors to read +*/ +driver_return_code_t +cdio_read_mode2_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, + bool b_form2, uint32_t i_blocks) +{ + lsn_t _i_blocks = (lsn_t)i_blocks; + check_lsn_blocks(i_lsn, _i_blocks); + + if (0 == i_blocks) return DRIVER_OP_SUCCESS; + + if (p_cdio->op.read_mode2_sectors) + return (p_cdio->op.read_mode2_sectors) (p_cdio->env, p_buf, i_lsn, + b_form2, i_blocks); + return DRIVER_OP_UNSUPPORTED; + +} + + +/** The special case of reading a single block is a common one so we + provide a routine for that as a convenience. +*/ +driver_return_code_t +cdio_read_sector(const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, + cdio_read_mode_t read_mode) +{ + return cdio_read_sectors(p_cdio, p_buf, i_lsn, read_mode, 1); +} + +/*! + Reads a number of sectors (AKA blocks). + + @param p_buf place to read data into. The caller should make sure + this location is large enough. See below for size information. + @param read_mode the kind of "mode" to use in reading. + @param i_lsn sector to read + @param i_blocks number of sectors to read + @return DRIVER_OP_SUCCESS (0) if no error, other (negative) enumerations + are returned on error. + + If read_mode is CDIO_MODE_AUDIO, + *p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes. + + If read_mode is CDIO_MODE_DATA, + *p_buf should hold at least i_blocks times either ISO_BLOCKSIZE, + M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of + sector getting read. If you don't know whether you have a Mode 1/2, + Form 1/ Form 2/Formless sector best to reserve space for the maximum + which is M2RAW_SECTOR_SIZE. + + If read_mode is CDIO_MODE_M2F1, + *p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes. + + If read_mode is CDIO_MODE_M2F2, + *p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes. + + +*/ +driver_return_code_t +cdio_read_sectors(const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, + cdio_read_mode_t read_mode, uint32_t i_blocks) +{ + switch(read_mode) { + case CDIO_READ_MODE_AUDIO: + return cdio_read_audio_sectors (p_cdio, p_buf, i_lsn, i_blocks); + case CDIO_READ_MODE_M1F1: + return cdio_read_mode1_sectors (p_cdio, p_buf, i_lsn, false, i_blocks); + case CDIO_READ_MODE_M1F2: + return cdio_read_mode1_sectors (p_cdio, p_buf, i_lsn, true, i_blocks); + case CDIO_READ_MODE_M2F1: + return cdio_read_mode2_sectors (p_cdio, p_buf, i_lsn, false, i_blocks); + case CDIO_READ_MODE_M2F2: + return cdio_read_mode2_sectors (p_cdio, p_buf, i_lsn, true, i_blocks); + } + /* Can't happen. Just to shut up gcc. */ + return DRIVER_OP_ERROR; +} + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/libcdio/driver/sector.c b/src/libcdio/driver/sector.c new file mode 100644 index 00000000..7578856f --- /dev/null +++ b/src/libcdio/driver/sector.c @@ -0,0 +1,273 @@ +/* + Copyright (C) 2004, 2005, 2011 Rocky Bernstein + Copyright (C) 2000 Herbert Valerio Riedel + + 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-1307 USA +*/ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#include +#include +#include +#include "cdio_assert.h" +#include "portable.h" + +#include +#ifdef HAVE_STRING_H +#include +#endif + +#include + +static const char _rcsid[] = "$Id: sector.c,v 1.5 2005/02/06 04:20:25 rocky Exp $"; + +/*! String of bytes used to identify the beginning of a Mode 1 or + Mode 2 sector. */ +const uint8_t CDIO_SECTOR_SYNC_HEADER[CDIO_CD_SYNC_SIZE] = + {0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0}; + +/* Variables to hold debugger-helping enumerations */ +enum cdio_cd_enums; +enum m2_sector_enums; + +lba_t +cdio_lba_to_lsn (lba_t lba) +{ + if (CDIO_INVALID_LBA == lba) return CDIO_INVALID_LSN; + return lba - CDIO_PREGAP_SECTORS; +} + +/* + The below is adapted from cdparanoia code which claims it is + straight from the MMC3 spec. +*/ + +void +cdio_lsn_to_msf (lsn_t lsn, msf_t *msf) +{ + int m, s, f; + + cdio_assert (msf != 0); + + if ( lsn >= -CDIO_PREGAP_SECTORS ){ + m = (lsn + CDIO_PREGAP_SECTORS) / CDIO_CD_FRAMES_PER_MIN; + lsn -= m * CDIO_CD_FRAMES_PER_MIN; + s = (lsn + CDIO_PREGAP_SECTORS) / CDIO_CD_FRAMES_PER_SEC; + lsn -= s * CDIO_CD_FRAMES_PER_SEC; + f = lsn + CDIO_PREGAP_SECTORS; + } else { + m = (lsn + CDIO_CD_MAX_LSN) / CDIO_CD_FRAMES_PER_MIN; + lsn -= m * (CDIO_CD_FRAMES_PER_MIN); + s = (lsn+CDIO_CD_MAX_LSN) / CDIO_CD_FRAMES_PER_SEC; + lsn -= s * CDIO_CD_FRAMES_PER_SEC; + f = lsn + CDIO_CD_MAX_LSN; + } + + if (m > 99) { + cdio_warn ("number of minutes (%d) truncated to 99.", m); + m = 99; + } + + msf->m = cdio_to_bcd8 ((uint8_t)m); + msf->s = cdio_to_bcd8 ((uint8_t)s); + msf->f = cdio_to_bcd8 ((uint8_t)f); +} + +/*! + Convert an LBA into a string representation of the MSF. + \warning cdio_lba_to_msf_str returns new allocated string */ +char * +cdio_lba_to_msf_str (lba_t lba) +{ + + if (CDIO_INVALID_LBA == lba) { + return _strdup("*INVALID"); + } else { + msf_t msf; + msf.m = msf.s = msf.f = 0; + cdio_lba_to_msf (lba, &msf); + return cdio_msf_to_str(&msf); + } +} + +/*! + Convert an LSN into the corresponding LBA. + CDIO_INVALID_LBA is returned if there is an error. +*/ +lba_t +cdio_lsn_to_lba (lsn_t lsn) +{ + if (CDIO_INVALID_LSN == lsn) return CDIO_INVALID_LBA; + return lsn + CDIO_PREGAP_SECTORS; +} + +/*! + Convert an LBA into the corresponding MSF. +*/ +void +cdio_lba_to_msf (lba_t lba, msf_t *msf) +{ + cdio_assert (msf != 0); + cdio_lsn_to_msf(cdio_lba_to_lsn(lba), msf); +} + +/*! + Convert a MSF into the corresponding LBA. + CDIO_INVALID_LBA is returned if there is an error. +*/ +lba_t +cdio_msf_to_lba (const msf_t *msf) +{ + uint32_t lba = 0; + + cdio_assert (msf != 0); + + lba = cdio_from_bcd8 (msf->m); + lba *= CDIO_CD_SECS_PER_MIN; + + lba += cdio_from_bcd8 (msf->s); + lba *= CDIO_CD_FRAMES_PER_SEC; + + lba += cdio_from_bcd8 (msf->f); + + return lba; +} + +/*! + Convert a MSF into the corresponding LSN. + CDIO_INVALID_LSN is returned if there is an error. +*/ +lba_t +cdio_msf_to_lsn (const msf_t *msf) +{ + return cdio_lba_to_lsn(cdio_msf_to_lba (msf)); +} + +/*! + Convert an LBA into a string representation of the MSF. + \warning cdio_lba_to_msf_str returns new allocated string */ +char * +cdio_msf_to_str (const msf_t *msf) +{ + char buf[16]; + + snprintf (buf, sizeof (buf), "%2.2x:%2.2x:%2.2x", msf->m, msf->s, msf->f); + return _strdup (buf); +} + +/*! + Convert a MSF - broken out as 3 integer components into the + corresponding LBA. + CDIO_INVALID_LBA is returned if there is an error. +*/ +lba_t +cdio_msf3_to_lba (unsigned int minutes, unsigned int seconds, + unsigned int frames) +{ + return ((minutes * CDIO_CD_SECS_PER_MIN + seconds) * CDIO_CD_FRAMES_PER_SEC + + frames); +} + +/*! + Convert a string of the form MM:SS:FF into the corresponding LBA. + CDIO_INVALID_LBA is returned if there is an error. +*/ +lba_t +cdio_mmssff_to_lba (const char *psz_mmssff) +{ + int psz_field; + lba_t ret; + char c; + + if (0 == strcmp (psz_mmssff, "0")) + return 0; + + c = *psz_mmssff++; + if(c >= '0' && c <= '9') + psz_field = (c - '0'); + else + return CDIO_INVALID_LBA; + while(':' != (c = *psz_mmssff++)) { + if(c >= '0' && c <= '9') + psz_field = psz_field * 10 + (c - '0'); + else + return CDIO_INVALID_LBA; + } + + ret = cdio_msf3_to_lba (psz_field, 0, 0); + + c = *psz_mmssff++; + if(c >= '0' && c <= '9') + psz_field = (c - '0'); + else + return CDIO_INVALID_LBA; + if(':' != (c = *psz_mmssff++)) { + if(c >= '0' && c <= '9') { + psz_field = psz_field * 10 + (c - '0'); + c = *psz_mmssff++; + if(c != ':') + return CDIO_INVALID_LBA; + } + else + return CDIO_INVALID_LBA; + } + + if(psz_field >= CDIO_CD_SECS_PER_MIN) + return CDIO_INVALID_LBA; + + ret += cdio_msf3_to_lba (0, psz_field, 0); + + c = *psz_mmssff++; + if (isdigit(c)) + psz_field = (c - '0'); + else + return -1; + if('\0' != (c = *psz_mmssff++)) { + if (isdigit(c)) { + psz_field = psz_field * 10 + (c - '0'); + c = *psz_mmssff++; + } + else + return CDIO_INVALID_LBA; + } + + if('\0' != c) + return CDIO_INVALID_LBA; + + if(psz_field >= CDIO_CD_FRAMES_PER_SEC) + return CDIO_INVALID_LBA; + + ret += psz_field; + + return ret; +} + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/libcdio/driver/track.c b/src/libcdio/driver/track.c new file mode 100644 index 00000000..d888d6ad --- /dev/null +++ b/src/libcdio/driver/track.c @@ -0,0 +1,364 @@ +/* + Copyright (C) 2003, 2004, 2005, 2008, 2011 Rocky Bernstein + Copyright (C) 2001 Herbert Valerio Riedel + + 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 3 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, see . +*/ +/*! Track-related routines. */ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#include +#include "cdio_private.h" + +const char *track_format2str[6] = + { + "audio", "CD-i", "XA", "data", "PSX", "error" + }; + +/* Variables to hold debugger-helping enumerations */ +enum cdio_track_enums; + +/*! + Return the number of the first track. + CDIO_INVALID_TRACK is returned on error. +*/ +track_t +cdio_get_first_track_num (const CdIo_t *p_cdio) +{ + if (NULL == p_cdio) return CDIO_INVALID_TRACK; + + if (p_cdio->op.get_first_track_num) { + return p_cdio->op.get_first_track_num (p_cdio->env); + } else { + return CDIO_INVALID_TRACK; + } +} + +/*! + Return the last track number. + CDIO_INVALID_TRACK is returned on error. +*/ +track_t +cdio_get_last_track_num (const CdIo_t *p_cdio) +{ + if (NULL == p_cdio) return CDIO_INVALID_TRACK; + { + const track_t i_first_track = cdio_get_first_track_num(p_cdio); + if ( CDIO_INVALID_TRACK != i_first_track ) { + const track_t i_tracks = cdio_get_num_tracks(p_cdio); + if ( CDIO_INVALID_TRACK != i_tracks ) + return i_first_track + i_tracks - 1; + } + return CDIO_INVALID_TRACK; + } +} + +/*! Return number of channels in track: 2 or 4; -2 if not + implemented or -1 for error. + Not meaningful if track is not an audio track. +*/ +int +cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track) +{ + if (p_cdio->op.get_track_channels) { + return p_cdio->op.get_track_channels (p_cdio->env, i_track); + } else { + return -2; + } +} + +/*! Return copy protection status on a track. Is this meaningful + if not an audio track? +*/ +track_flag_t +cdio_get_track_copy_permit(const CdIo_t *p_cdio, track_t i_track) +{ + if (p_cdio->op.get_track_copy_permit) { + return p_cdio->op.get_track_copy_permit (p_cdio->env, i_track); + } else { + return CDIO_TRACK_FLAG_UNKNOWN; + } +} + +/*! + Get format of track. +*/ +track_format_t +cdio_get_track_format(const CdIo_t *p_cdio, track_t i_track) +{ + if (!p_cdio) return TRACK_FORMAT_ERROR; + + if (p_cdio->op.get_track_format) { + return p_cdio->op.get_track_format (p_cdio->env, i_track); + } else { + return TRACK_FORMAT_ERROR; + } +} +/*! + Return the Joliet level recognized for p_cdio. +*/ +uint8_t +cdio_get_joliet_level(const CdIo_t *p_cdio) +{ + if (!p_cdio) return 0; + { + const generic_img_private_t *p_env + = (generic_img_private_t *) (p_cdio->env); + return p_env->i_joliet_level; + } +} + +/*! + Return the number of tracks in the current medium. + CDIO_INVALID_TRACK is returned on error. +*/ +track_t +cdio_get_num_tracks (const CdIo_t *p_cdio) +{ + if (p_cdio == NULL) return CDIO_INVALID_TRACK; + + if (p_cdio->op.get_num_tracks) { + return p_cdio->op.get_num_tracks (p_cdio->env); + } else { + return CDIO_INVALID_TRACK; + } +} + +/*! Find the track which contans lsn. + CDIO_INVALID_TRACK is returned if the lsn outside of the CD or + if there was some error. + + If the lsn is before the pregap of the first track 0 is returned. + Otherwise we return the track that spans the lsn. +*/ +track_t +cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn) +{ + if (!p_cdio) return CDIO_INVALID_TRACK; + + { + track_t i_low_track = cdio_get_first_track_num(p_cdio); + track_t i_high_track = cdio_get_last_track_num(p_cdio)+1; /* LEADOUT */ + + if (CDIO_INVALID_TRACK == i_low_track + || CDIO_INVALID_TRACK == i_high_track ) return CDIO_INVALID_TRACK; + + if (lsn < cdio_get_track_lsn(p_cdio, i_low_track)) + return 0; /* We're in the pre-gap of first track */ + + if (lsn > cdio_get_track_lsn(p_cdio, i_high_track)) + return CDIO_INVALID_TRACK; /* We're beyond the end. */ + + do { + const track_t i_mid = (i_low_track + i_high_track) / 2; + const lsn_t i_mid_lsn = cdio_get_track_lsn(p_cdio, i_mid); + if (lsn <= i_mid_lsn) i_high_track = i_mid - 1; + if (lsn >= i_mid_lsn) i_low_track = i_mid + 1; + } while ( i_low_track <= i_high_track ); + + return (i_low_track > i_high_track + 1) + ? i_high_track + 1 : i_high_track; + } +} + +/*! + Return true if we have XA data (green, mode2 form1) or + XA data (green, mode2 form2). That is track begins: + sync - header - subheader + 12 4 - 8 + + FIXME: there's gotta be a better design for this and get_track_format? +*/ +bool +cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track) +{ + if (p_cdio == NULL) { + return false; + } + + if (p_cdio->op.get_track_green) { + return p_cdio->op.get_track_green (p_cdio->env, i_track); + } else { + return false; + } +} + +/*! + Return the starting LBA for track number + track_num in cdio. Tracks numbers start at 1. + The "leadout" track is specified either by + using track_num LEADOUT_TRACK or the total tracks+1. + CDIO_INVALID_LBA is returned on error. +*/ +lba_t +cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track) +{ + if (!p_cdio) return CDIO_INVALID_LBA; + + if (p_cdio->op.get_track_lba) { + return p_cdio->op.get_track_lba (p_cdio->env, i_track); + } else { + msf_t msf; + if (p_cdio->op.get_track_msf) + if (cdio_get_track_msf(p_cdio, i_track, &msf)) + return cdio_msf_to_lba(&msf); + return CDIO_INVALID_LBA; + } +} + +/*! + Return the starting LSN for track number + i_track in cdio. Tracks numbers start at 1. + The "leadout" track is specified either by + using i_track LEADOUT_TRACK or the total tracks+1. + CDIO_INVALID_LSN is returned on error. +*/ +lsn_t +cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track) +{ + if (p_cdio == NULL) return CDIO_INVALID_LSN; + + if (p_cdio->op.get_track_lba) { + return cdio_lba_to_lsn(p_cdio->op.get_track_lba (p_cdio->env, i_track)); + } else { + msf_t msf; + if (cdio_get_track_msf(p_cdio, i_track, &msf)) + return cdio_msf_to_lsn(&msf); + return CDIO_INVALID_LSN; + } +} + +/*! + Return the International Standard Recording Code (ISRC) for track number + i_track in p_cdio. Track numbers start at 1. + + Note: string is malloc'd so caller has to free() the returned + string when done with it. +*/ +char * +cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track) +{ + if (p_cdio == NULL) return NULL; + + if (p_cdio->op.get_track_isrc) { + return p_cdio->op.get_track_isrc (p_cdio->env, i_track); + } else { + return NULL; + } +} + +/*! + Return the starting LBA for the pregap for track number + i_track in cdio. Track numbers start at 1. + CDIO_INVALID_LBA is returned on error. +*/ +lba_t +cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t i_track) +{ + if (p_cdio == NULL) return CDIO_INVALID_LBA; + + if (p_cdio->op.get_track_pregap_lba) { + return p_cdio->op.get_track_pregap_lba (p_cdio->env, i_track); + } else { + return CDIO_INVALID_LBA; + } +} + +/*! + Return the starting LSN for the pregap for track number + i_track in cdio. Track numbers start at 1. + CDIO_INVALID_LSN is returned on error. +*/ +lsn_t +cdio_get_track_pregap_lsn(const CdIo_t *p_cdio, track_t i_track) +{ + return cdio_lba_to_lsn(cdio_get_track_pregap_lba(p_cdio, i_track)); +} + +/*! + Return the ending LSN for track number + i_track in cdio. CDIO_INVALID_LSN is returned on error. +*/ +lsn_t +cdio_get_track_last_lsn(const CdIo_t *p_cdio, track_t i_track) +{ + lsn_t lsn = cdio_get_track_lsn(p_cdio, i_track+1); + + if (CDIO_INVALID_LSN == lsn) return CDIO_INVALID_LSN; + /* Safe, we've always the leadout. */ + return lsn - 1; +} + +/*! + Return the starting MSF (minutes/secs/frames) for track number + i_track in cdio. Track numbers start at 1. + The "leadout" track is specified either by + using i_track LEADOUT_TRACK or the total tracks+1. + False is returned if there is no track entry. +*/ +bool +cdio_get_track_msf(const CdIo_t *p_cdio, track_t i_track, /*out*/ msf_t *msf) +{ + if (!p_cdio) return false; + + if (p_cdio->op.get_track_msf) { + return p_cdio->op.get_track_msf (p_cdio->env, i_track, msf); + } else if (p_cdio->op.get_track_lba) { + lba_t lba = p_cdio->op.get_track_lba (p_cdio->env, i_track); + if (lba == CDIO_INVALID_LBA) return false; + cdio_lba_to_msf(lba, msf); + return true; + } else { + return false; + } +} + +/*! Return copy protection status on a track. Is this meaningful + if not an audio track? +*/ +track_flag_t +cdio_get_track_preemphasis(const CdIo *p_cdio, track_t i_track) +{ + if (p_cdio->op.get_track_preemphasis) { + return p_cdio->op.get_track_preemphasis (p_cdio->env, i_track); + } else { + return CDIO_TRACK_FLAG_UNKNOWN; + } +} + +/*! + Return the number of sectors between this track an the next. This + includes any pregap sectors before the start of the next track. + Tracks start at 1. + 0 is returned if there is an error. +*/ +unsigned int +cdio_get_track_sec_count(const CdIo_t *p_cdio, track_t i_track) +{ + const track_t i_tracks = cdio_get_num_tracks(p_cdio); + + if (i_track >=1 && i_track <= i_tracks) + return ( cdio_get_track_lba(p_cdio, i_track+1) + - cdio_get_track_lba(p_cdio, i_track) ); + return 0; +} diff --git a/src/libcdio/driver/util.c b/src/libcdio/driver/util.c new file mode 100644 index 00000000..f835caea --- /dev/null +++ b/src/libcdio/driver/util.c @@ -0,0 +1,166 @@ +/* + Copyright (C) 2003, 2004, 2005, 2008, 2009, 2010, 2011 + Rocky Bernstein + Copyright (C) 2000 Herbert Valerio Riedel + + 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 3 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, see . +*/ + +#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) +# include "config.h" +# define __CDIO_CONFIG_H__ 1 +#else +#ifndef EXTERNAL_LIBCDIO_CONFIG_H +#define EXTERNAL_LIBCDIO_CONFIG_H +#include +#endif +#endif + +#include +#ifdef HAVE_STDLIB_H +#include +#endif +#include + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_INTTYPES_H +#include "inttypes.h" +#endif + +#include "cdio_assert.h" +#include +#include +#include + +size_t +_cdio_strlenv(char **str_array) +{ + size_t n = 0; + + cdio_assert (str_array != NULL); + + while(str_array[n]) + n++; + + return n; +} + +void +_cdio_strfreev(char **strv) +{ + int n; + + cdio_assert (strv != NULL); + + for(n = 0; strv[n]; n++) + free(strv[n]); + + free(strv); +} + +char ** +_cdio_strsplit(const char str[], char delim) /* fixme -- non-reentrant */ +{ + int n; + char **strv = NULL; + char *_str, *p; + char _delim[2] = { 0, 0 }; + + cdio_assert (str != NULL); + + _str = _strdup(str); + _delim[0] = delim; + + cdio_assert (_str != NULL); + + n = 1; + p = _str; + while(*p) + if (*(p++) == delim) + n++; + + strv = calloc (1, sizeof (char *) * (n+1)); + + n = 0; + while((p = strtok(n ? NULL : _str, _delim)) != NULL) + strv[n++] = _strdup(p); + + free(_str); + + return strv; +} + +void * +_cdio_memdup (const void *mem, size_t count) +{ + void *new_mem = NULL; + + if (mem) + { + new_mem = calloc (1, count); + memcpy (new_mem, mem, count); + } + + return new_mem; +} + +char * +_cdio_strdup_upper (const char str[]) +{ + char *new_str = NULL; + + if (str) + { + char *p; + + p = new_str = _strdup (str); + + while (*p) + { + *p = (char)toupper (*p); + p++; + } + } + + return new_str; +} + +uint8_t +cdio_to_bcd8 (uint8_t n) +{ + /*cdio_assert (n < 100);*/ + + return ((n/10)<<4) | (n%10); +} + +uint8_t +cdio_from_bcd8(uint8_t p) +{ + return (0xf & p)+(10*(p >> 4)); +} + +const char *cdio_version_string = CDIO_VERSION; +const unsigned int libcdio_version_num = LIBCDIO_VERSION_NUM; + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/libcdio/iso9660/.msvc/iso9660.vcxproj b/src/libcdio/iso9660/.msvc/iso9660.vcxproj index c09c04cc..6db07bba 100644 --- a/src/libcdio/iso9660/.msvc/iso9660.vcxproj +++ b/src/libcdio/iso9660/.msvc/iso9660.vcxproj @@ -23,9 +23,7 @@ - - - + @@ -97,7 +95,7 @@ Level3 Disabled _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;..\..\driver;..\..\msvc;%(AdditionalIncludeDirectories) + ..;..\..;..\..\driver;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase @@ -117,7 +115,7 @@ MaxSpeed true _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;..\..\driver;..\..\msvc;%(AdditionalIncludeDirectories) + ..;..\..;..\..\driver;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreaded ProgramDatabase @@ -132,7 +130,7 @@ Level3 Disabled _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;..\..\driver;..\..\msvc;%(AdditionalIncludeDirectories) + ..;..\..;..\..\driver;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase @@ -152,7 +150,7 @@ MaxSpeed true _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;..\..\driver;..\..\msvc;%(AdditionalIncludeDirectories) + ..;..\..;..\..\driver;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreaded ProgramDatabase diff --git a/src/libcdio/iso9660/.msvc/iso9660.vcxproj.filters b/src/libcdio/iso9660/.msvc/iso9660.vcxproj.filters index 0ea10f71..fd15c866 100644 --- a/src/libcdio/iso9660/.msvc/iso9660.vcxproj.filters +++ b/src/libcdio/iso9660/.msvc/iso9660.vcxproj.filters @@ -14,9 +14,6 @@ Header Files - - Source Files - Header Files @@ -31,5 +28,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/src/libcdio/iso9660/.msvc/iso9660_sources b/src/libcdio/iso9660/.msvc/iso9660_sources index 3d992a4f..e6aee0a6 100644 --- a/src/libcdio/iso9660/.msvc/iso9660_sources +++ b/src/libcdio/iso9660/.msvc/iso9660_sources @@ -1,7 +1,7 @@ TARGETNAME=iso9660 TARGETTYPE=LIBRARY -INCLUDES=$(DDK_INC_PATH);.;..;..\driver;..\msvc +INCLUDES=$(DDK_INC_PATH);.;..;..\driver;..\..\msvc-missing C_DEFINES=$(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED !IFNDEF MSC_WARNING_LEVEL diff --git a/src/libcdio/iso9660/iso9660.c b/src/libcdio/iso9660/iso9660.c index 117fc8c6..72a67677 100644 --- a/src/libcdio/iso9660/iso9660.c +++ b/src/libcdio/iso9660/iso9660.c @@ -80,13 +80,13 @@ timegm(struct tm *tm) tz = getenv("TZ"); setenv("TZ", "UTC", 1); - tzset(); + _tzset(); ret = mktime(tm); if (tz) setenv("TZ", tz, 1); else unsetenv("TZ"); - tzset(); + _tzset(); return ret; } #endif @@ -1048,7 +1048,7 @@ iso9660_pathname_valid_p (const char pathname[]) if ((p = strrchr (pathname, '/'))) { bool rc; - char *_tmp = strdup (pathname); + char *_tmp = _strdup (pathname); *strrchr (_tmp, '/') = '\0'; @@ -1112,7 +1112,7 @@ iso9660_pathname_isofy (const char pathname[], uint16_t version) _snprintf (tmpbuf, sizeof(tmpbuf), "%s;%d", pathname, version); - return strdup (tmpbuf); + return _strdup (tmpbuf); } /*! @@ -1123,7 +1123,7 @@ char * iso9660_get_application_id(iso9660_pvd_t *p_pvd) { if (NULL==p_pvd) return NULL; - return strdup(strip_trail(p_pvd->application_id, ISO_MAX_APPLICATION_ID)); + return _strdup(strip_trail(p_pvd->application_id, ISO_MAX_APPLICATION_ID)); } #ifdef FIXME @@ -1212,7 +1212,7 @@ char * iso9660_get_preparer_id(const iso9660_pvd_t *pvd) { if (NULL==pvd) return NULL; - return strdup(strip_trail(pvd->preparer_id, ISO_MAX_PREPARER_ID)); + return _strdup(strip_trail(pvd->preparer_id, ISO_MAX_PREPARER_ID)); } /*! @@ -1223,7 +1223,7 @@ char * iso9660_get_publisher_id(const iso9660_pvd_t *pvd) { if (NULL==pvd) return NULL; - return strdup(strip_trail(pvd->publisher_id, ISO_MAX_PUBLISHER_ID)); + return _strdup(strip_trail(pvd->publisher_id, ISO_MAX_PUBLISHER_ID)); } /*! @@ -1234,7 +1234,7 @@ char * iso9660_get_system_id(const iso9660_pvd_t *pvd) { if (NULL==pvd) return NULL; - return strdup(strip_trail(pvd->system_id, ISO_MAX_SYSTEM_ID)); + return _strdup(strip_trail(pvd->system_id, ISO_MAX_SYSTEM_ID)); } /*! @@ -1244,7 +1244,7 @@ char * iso9660_get_volume_id(const iso9660_pvd_t *pvd) { if (NULL == pvd) return NULL; - return strdup(strip_trail(pvd->volume_id, ISO_MAX_VOLUME_ID)); + return _strdup(strip_trail(pvd->volume_id, ISO_MAX_VOLUME_ID)); } /*! @@ -1255,7 +1255,7 @@ char * iso9660_get_volumeset_id(const iso9660_pvd_t *pvd) { if ( NULL == pvd ) return NULL; - return strdup(strip_trail(pvd->volume_set_id, ISO_MAX_VOLUMESET_ID)); + return _strdup(strip_trail(pvd->volume_set_id, ISO_MAX_VOLUMESET_ID)); } diff --git a/src/libcdio/udf/.msvc/udf.vcxproj b/src/libcdio/udf/.msvc/udf.vcxproj index dd1690ab..67a2746f 100644 --- a/src/libcdio/udf/.msvc/udf.vcxproj +++ b/src/libcdio/udf/.msvc/udf.vcxproj @@ -97,7 +97,7 @@ Level3 Disabled _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;..\..\driver;..\..\msvc;%(AdditionalIncludeDirectories) + ..;..\..;..\..\driver;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase @@ -117,7 +117,7 @@ MaxSpeed true _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;..\..\driver;..\..\msvc;%(AdditionalIncludeDirectories) + ..;..\..;..\..\driver;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreaded ProgramDatabase @@ -132,7 +132,7 @@ Level3 Disabled _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;..\..\driver;..\..\msvc;%(AdditionalIncludeDirectories) + ..;..\..;..\..\driver;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase @@ -152,7 +152,7 @@ MaxSpeed true _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;..\..\driver;..\..\msvc;%(AdditionalIncludeDirectories) + ..;..\..;..\..\driver;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreaded ProgramDatabase diff --git a/src/libcdio/udf/.msvc/udf_sources b/src/libcdio/udf/.msvc/udf_sources index 84bfe8ce..da27ab86 100644 --- a/src/libcdio/udf/.msvc/udf_sources +++ b/src/libcdio/udf/.msvc/udf_sources @@ -1,7 +1,7 @@ TARGETNAME=udf TARGETTYPE=LIBRARY -INCLUDES=$(DDK_INC_PATH);.;..;..\driver;..\msvc +INCLUDES=$(DDK_INC_PATH);.;..;..\driver;..\..\msvc-missing C_DEFINES=$(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED !IFNDEF MSC_WARNING_LEVEL diff --git a/src/libcdio/msvc/inttypes.h b/src/msvc-missing/inttypes.h similarity index 93% rename from src/libcdio/msvc/inttypes.h rename to src/msvc-missing/inttypes.h index 9df500d1..1b12139b 100644 --- a/src/libcdio/msvc/inttypes.h +++ b/src/msvc-missing/inttypes.h @@ -23,6 +23,11 @@ #error This header should only be used with Microsoft compilers #endif +/* It's convenient to hijack this header to also define 'inline' on MS environments */ +#ifndef inline +#define inline __inline +#endif + /* 7.8 Format conversion of integer types */ #ifndef _INTTYPES_H_ diff --git a/src/libcdio/msvc/stdint.h b/src/msvc-missing/stdint.h similarity index 100% rename from src/libcdio/msvc/stdint.h rename to src/msvc-missing/stdint.h diff --git a/src/libcdio/msvc/unistd.h b/src/msvc-missing/unistd.h similarity index 100% rename from src/libcdio/msvc/unistd.h rename to src/msvc-missing/unistd.h diff --git a/src/rufus.rc b/src/rufus.rc index cdc6b82f..4d5a882f 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 278 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.0.7.123" +CAPTION "Rufus v1.0.7.124" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,236,50,14 @@ -69,7 +69,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP CONTROL "http://rufus.akeo.ie",IDC_ABOUT_RUFUS_URL, "SysLink",WS_TABSTOP,46,47,114,9 - LTEXT "Version 1.0.7 (Build 123)",IDC_STATIC,46,19,78,8 + LTEXT "Version 1.0.7 (Build 124)",IDC_STATIC,46,19,78,8 PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 @@ -207,8 +207,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,7,123 - PRODUCTVERSION 1,0,7,123 + FILEVERSION 1,0,7,124 + PRODUCTVERSION 1,0,7,124 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -225,13 +225,13 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.0.7.123" + VALUE "FileVersion", "1.0.7.124" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.0.7.123" + VALUE "ProductVersion", "1.0.7.124" END END BLOCK "VarFileInfo" diff --git a/src/syslinux/inttypes.h b/src/syslinux/inttypes.h deleted file mode 100644 index 17a7adde..00000000 --- a/src/syslinux/inttypes.h +++ /dev/null @@ -1,301 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file was original part of the w64 mingw-runtime package. - */ - -/* - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * Modified for libusb/MSVC: Pete Batard - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAIMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Date: 2010-04-02 - */ - -#ifndef _MSC_VER -#error This header should only be used with Microsoft compilers -#endif - -/* 7.8 Format conversion of integer types */ - -#ifndef _INTTYPES_H_ -#define _INTTYPES_H_ - -#include -/* Workaround - TODO: move this include back into source */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - intmax_t quot; - intmax_t rem; - } imaxdiv_t; - - -#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) - -/* 7.8.1 Macros for format specifiers - * - * MS runtime does not yet understand C9x standard "ll" - * length specifier. It appears to treat "ll" as "l". - * The non-standard I64 length specifier causes warning in GCC, - * but understood by MS runtime functions. - */ - -/* fprintf macros for signed types */ -#define PRId8 "d" -#define PRId16 "d" -#define PRId32 "d" -#define PRId64 "I64d" - -#define PRIdLEAST8 "d" -#define PRIdLEAST16 "d" -#define PRIdLEAST32 "d" -#define PRIdLEAST64 "I64d" - -#define PRIdFAST8 "d" -#define PRIdFAST16 "d" -#define PRIdFAST32 "d" -#define PRIdFAST64 "I64d" - -#define PRIdMAX "I64d" - -#define PRIi8 "i" -#define PRIi16 "i" -#define PRIi32 "i" -#define PRIi64 "I64i" - -#define PRIiLEAST8 "i" -#define PRIiLEAST16 "i" -#define PRIiLEAST32 "i" -#define PRIiLEAST64 "I64i" - -#define PRIiFAST8 "i" -#define PRIiFAST16 "i" -#define PRIiFAST32 "i" -#define PRIiFAST64 "I64i" - -#define PRIiMAX "I64i" - -#define PRIo8 "o" -#define PRIo16 "o" -#define PRIo32 "o" -#define PRIo64 "I64o" - -#define PRIoLEAST8 "o" -#define PRIoLEAST16 "o" -#define PRIoLEAST32 "o" -#define PRIoLEAST64 "I64o" - -#define PRIoFAST8 "o" -#define PRIoFAST16 "o" -#define PRIoFAST32 "o" -#define PRIoFAST64 "I64o" - -#define PRIoMAX "I64o" - -/* fprintf macros for unsigned types */ -#define PRIu8 "u" -#define PRIu16 "u" -#define PRIu32 "u" -#define PRIu64 "I64u" - - -#define PRIuLEAST8 "u" -#define PRIuLEAST16 "u" -#define PRIuLEAST32 "u" -#define PRIuLEAST64 "I64u" - -#define PRIuFAST8 "u" -#define PRIuFAST16 "u" -#define PRIuFAST32 "u" -#define PRIuFAST64 "I64u" - -#define PRIuMAX "I64u" - -#define PRIx8 "x" -#define PRIx16 "x" -#define PRIx32 "x" -#define PRIx64 "I64x" - -#define PRIxLEAST8 "x" -#define PRIxLEAST16 "x" -#define PRIxLEAST32 "x" -#define PRIxLEAST64 "I64x" - -#define PRIxFAST8 "x" -#define PRIxFAST16 "x" -#define PRIxFAST32 "x" -#define PRIxFAST64 "I64x" - -#define PRIxMAX "I64x" - -#define PRIX8 "X" -#define PRIX16 "X" -#define PRIX32 "X" -#define PRIX64 "I64X" - -#define PRIXLEAST8 "X" -#define PRIXLEAST16 "X" -#define PRIXLEAST32 "X" -#define PRIXLEAST64 "I64X" - -#define PRIXFAST8 "X" -#define PRIXFAST16 "X" -#define PRIXFAST32 "X" -#define PRIXFAST64 "I64X" - -#define PRIXMAX "I64X" - -/* - * fscanf macros for signed int types - * NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t - * (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have - * no length identifiers - */ - -#define SCNd16 "hd" -#define SCNd32 "d" -#define SCNd64 "I64d" - -#define SCNdLEAST16 "hd" -#define SCNdLEAST32 "d" -#define SCNdLEAST64 "I64d" - -#define SCNdFAST16 "hd" -#define SCNdFAST32 "d" -#define SCNdFAST64 "I64d" - -#define SCNdMAX "I64d" - -#define SCNi16 "hi" -#define SCNi32 "i" -#define SCNi64 "I64i" - -#define SCNiLEAST16 "hi" -#define SCNiLEAST32 "i" -#define SCNiLEAST64 "I64i" - -#define SCNiFAST16 "hi" -#define SCNiFAST32 "i" -#define SCNiFAST64 "I64i" - -#define SCNiMAX "I64i" - -#define SCNo16 "ho" -#define SCNo32 "o" -#define SCNo64 "I64o" - -#define SCNoLEAST16 "ho" -#define SCNoLEAST32 "o" -#define SCNoLEAST64 "I64o" - -#define SCNoFAST16 "ho" -#define SCNoFAST32 "o" -#define SCNoFAST64 "I64o" - -#define SCNoMAX "I64o" - -#define SCNx16 "hx" -#define SCNx32 "x" -#define SCNx64 "I64x" - -#define SCNxLEAST16 "hx" -#define SCNxLEAST32 "x" -#define SCNxLEAST64 "I64x" - -#define SCNxFAST16 "hx" -#define SCNxFAST32 "x" -#define SCNxFAST64 "I64x" - -#define SCNxMAX "I64x" - -/* fscanf macros for unsigned int types */ - -#define SCNu16 "hu" -#define SCNu32 "u" -#define SCNu64 "I64u" - -#define SCNuLEAST16 "hu" -#define SCNuLEAST32 "u" -#define SCNuLEAST64 "I64u" - -#define SCNuFAST16 "hu" -#define SCNuFAST32 "u" -#define SCNuFAST64 "I64u" - -#define SCNuMAX "I64u" - -#ifdef _WIN64 -#define PRIdPTR "I64d" -#define PRIiPTR "I64i" -#define PRIoPTR "I64o" -#define PRIuPTR "I64u" -#define PRIxPTR "I64x" -#define PRIXPTR "I64X" -#define SCNdPTR "I64d" -#define SCNiPTR "I64i" -#define SCNoPTR "I64o" -#define SCNxPTR "I64x" -#define SCNuPTR "I64u" -#else -#define PRIdPTR "d" -#define PRIiPTR "i" -#define PRIoPTR "o" -#define PRIuPTR "u" -#define PRIxPTR "x" -#define PRIXPTR "X" -#define SCNdPTR "d" -#define SCNiPTR "i" -#define SCNoPTR "o" -#define SCNxPTR "x" - #define SCNuPTR "u" -#endif - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -/* - * no length modifier for char types prior to C9x - * MS runtime scanf appears to treat "hh" as "h" - */ - -/* signed char */ -#define SCNd8 "hhd" -#define SCNdLEAST8 "hhd" -#define SCNdFAST8 "hhd" - -#define SCNi8 "hhi" -#define SCNiLEAST8 "hhi" -#define SCNiFAST8 "hhi" - -#define SCNo8 "hho" -#define SCNoLEAST8 "hho" -#define SCNoFAST8 "hho" - -#define SCNx8 "hhx" -#define SCNxLEAST8 "hhx" -#define SCNxFAST8 "hhx" - -/* unsigned char */ -#define SCNu8 "hhu" -#define SCNuLEAST8 "hhu" -#define SCNuFAST8 "hhu" -#endif /* __STDC_VERSION__ >= 199901 */ - -#endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */ - - -#ifdef __cplusplus -} -#endif - -#endif /* ndef _INTTYPES_H */ diff --git a/src/syslinux/libfat/.msvc/libfat.vcxproj b/src/syslinux/libfat/.msvc/libfat.vcxproj index 7262a131..537e845a 100644 --- a/src/syslinux/libfat/.msvc/libfat.vcxproj +++ b/src/syslinux/libfat/.msvc/libfat.vcxproj @@ -97,7 +97,7 @@ Level3 Disabled _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;%(AdditionalIncludeDirectories) + ..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase @@ -117,7 +117,7 @@ MaxSpeed true _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;%(AdditionalIncludeDirectories) + ..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreaded ProgramDatabase @@ -132,7 +132,7 @@ Level3 Disabled _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;%(AdditionalIncludeDirectories) + ..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase @@ -152,7 +152,7 @@ MaxSpeed true _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;%(AdditionalIncludeDirectories) + ..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreaded ProgramDatabase diff --git a/src/syslinux/libfat/.msvc/libfat_sources b/src/syslinux/libfat/.msvc/libfat_sources index 858bf26f..61a1e85c 100644 --- a/src/syslinux/libfat/.msvc/libfat_sources +++ b/src/syslinux/libfat/.msvc/libfat_sources @@ -1,7 +1,7 @@ TARGETNAME=libfat TARGETTYPE=LIBRARY -INCLUDES=$(DDK_INC_PATH);.. +INCLUDES=$(DDK_INC_PATH);..\..\msvc-missing C_DEFINES=$(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED !IFNDEF MSC_WARNING_LEVEL diff --git a/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj b/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj index 4a32c72c..c0f794ff 100644 --- a/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj +++ b/src/syslinux/libinstaller/.msvc/libinstaller.vcxproj @@ -95,7 +95,7 @@ Level3 Disabled _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;%(AdditionalIncludeDirectories) + ..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase @@ -115,7 +115,7 @@ MaxSpeed true _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;%(AdditionalIncludeDirectories) + ..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreaded ProgramDatabase @@ -130,7 +130,7 @@ Level3 Disabled _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;%(AdditionalIncludeDirectories) + ..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreadedDebug ProgramDatabase @@ -150,7 +150,7 @@ MaxSpeed true _CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;ISOLATION_AWARE_ENABLED;_LIB;%(PreprocessorDefinitions) - ..;..\..;%(AdditionalIncludeDirectories) + ..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories) MultiThreaded ProgramDatabase diff --git a/src/syslinux/libinstaller/.msvc/libinstaller_sources b/src/syslinux/libinstaller/.msvc/libinstaller_sources index 0096225d..171bdae9 100644 --- a/src/syslinux/libinstaller/.msvc/libinstaller_sources +++ b/src/syslinux/libinstaller/.msvc/libinstaller_sources @@ -1,7 +1,7 @@ TARGETNAME=libinstaller TARGETTYPE=LIBRARY -INCLUDES=$(DDK_INC_PATH);.. +INCLUDES=$(DDK_INC_PATH);..\..\msvc-missing C_DEFINES=$(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED !IFNDEF MSC_WARNING_LEVEL diff --git a/src/syslinux/stdint.h b/src/syslinux/stdint.h deleted file mode 100644 index 7e0746f8..00000000 --- a/src/syslinux/stdint.h +++ /dev/null @@ -1,262 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file was originally part of the w64 mingw-runtime package. - */ - -/* ISO C9x 7.18 Integer types - * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794) - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * Contributor: Danny Smith - * Modified for libusb/MSVC: Pete Batard - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAIMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Date: 2010-04-02 - */ - -#ifndef _MSC_VER -#error This header should only be used with Microsoft compilers -#endif - -#ifndef _STDINT_H -#define _STDINT_H - -#ifndef _INTPTR_T_DEFINED -#define _INTPTR_T_DEFINED -#ifndef __intptr_t_defined -#define __intptr_t_defined -#undef intptr_t -#ifdef _WIN64 - typedef __int64 intptr_t; -#else - typedef int intptr_t; -#endif /* _WIN64 */ -#endif /* __intptr_t_defined */ -#endif /* _INTPTR_T_DEFINED */ - -#ifndef _UINTPTR_T_DEFINED -#define _UINTPTR_T_DEFINED -#ifndef __uintptr_t_defined -#define __uintptr_t_defined -#undef uintptr_t -#ifdef _WIN64 - typedef unsigned __int64 uintptr_t; -#else - typedef unsigned int uintptr_t; -#endif /* _WIN64 */ -#endif /* __uintptr_t_defined */ -#endif /* _UINTPTR_T_DEFINED */ - -#ifndef _PTRDIFF_T_DEFINED -#define _PTRDIFF_T_DEFINED -#ifndef _PTRDIFF_T_ -#define _PTRDIFF_T_ -#undef ptrdiff_t -#ifdef _WIN64 - typedef __int64 ptrdiff_t; -#else - typedef int ptrdiff_t; -#endif /* _WIN64 */ -#endif /* _PTRDIFF_T_ */ -#endif /* _PTRDIFF_T_DEFINED */ - -#ifndef _WCHAR_T_DEFINED -#define _WCHAR_T_DEFINED -#ifndef __cplusplus - typedef unsigned short wchar_t; -#endif /* C++ */ -#endif /* _WCHAR_T_DEFINED */ - -#ifndef _WCTYPE_T_DEFINED -#define _WCTYPE_T_DEFINED -#ifndef _WINT_T -#define _WINT_T - typedef unsigned short wint_t; - typedef unsigned short wctype_t; -#endif /* _WINT_T */ -#endif /* _WCTYPE_T_DEFINED */ - -/* 7.18.1.1 Exact-width integer types */ -typedef __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; - -/* 7.18.1.2 Minimum-width integer types */ -typedef signed char int_least8_t; -typedef unsigned char uint_least8_t; -typedef short int_least16_t; -typedef unsigned short uint_least16_t; -typedef int int_least32_t; -typedef unsigned uint_least32_t; -typedef __int64 int_least64_t; -typedef unsigned __int64 uint_least64_t; - -/* 7.18.1.3 Fastest minimum-width integer types - * Not actually guaranteed to be fastest for all purposes - * Here we use the exact-width types for 8 and 16-bit ints. - */ -typedef __int8 int_fast8_t; -typedef unsigned __int8 uint_fast8_t; -typedef __int16 int_fast16_t; -typedef unsigned __int16 uint_fast16_t; -typedef __int32 int_fast32_t; -typedef unsigned __int32 uint_fast32_t; -typedef __int64 int_fast64_t; -typedef unsigned __int64 uint_fast64_t; - -/* 7.18.1.5 Greatest-width integer types */ -typedef __int64 intmax_t; -typedef unsigned __int64 uintmax_t; - -/* 7.18.2 Limits of specified-width integer types */ -#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS) - -/* 7.18.2.1 Limits of exact-width integer types */ -#define INT8_MIN (-128) -#define INT16_MIN (-32768) -#define INT32_MIN (-2147483647 - 1) -#define INT64_MIN (-9223372036854775807LL - 1) - -#define INT8_MAX 127 -#define INT16_MAX 32767 -#define INT32_MAX 2147483647 -#define INT64_MAX 9223372036854775807LL - -#define UINT8_MAX 255 -#define UINT16_MAX 65535 -#define UINT32_MAX 0xffffffffU /* 4294967295U */ -#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */ - -/* 7.18.2.2 Limits of minimum-width integer types */ -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST64_MIN INT64_MIN - -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MAX INT64_MAX - -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -/* 7.18.2.3 Limits of fastest minimum-width integer types */ -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST64_MIN INT64_MIN - -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MAX INT64_MAX - -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -/* 7.18.2.4 Limits of integer types capable of holding - object pointers */ -#ifdef _WIN64 -#define INTPTR_MIN INT64_MIN -#define INTPTR_MAX INT64_MAX -#define UINTPTR_MAX UINT64_MAX -#else -#define INTPTR_MIN INT32_MIN -#define INTPTR_MAX INT32_MAX -#define UINTPTR_MAX UINT32_MAX -#endif - -/* 7.18.2.5 Limits of greatest-width integer types */ -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -/* 7.18.3 Limits of other integer types */ -#ifdef _WIN64 -#define PTRDIFF_MIN INT64_MIN -#define PTRDIFF_MAX INT64_MAX -#else -#define PTRDIFF_MIN INT32_MIN -#define PTRDIFF_MAX INT32_MAX -#endif - -#define SIG_ATOMIC_MIN INT32_MIN -#define SIG_ATOMIC_MAX INT32_MAX - -#ifndef SIZE_MAX -#ifdef _WIN64 -#define SIZE_MAX UINT64_MAX -#else -#define SIZE_MAX UINT32_MAX -#endif -#endif - -#ifndef WCHAR_MIN /* also in wchar.h */ -#define WCHAR_MIN 0U -#define WCHAR_MAX 0xffffU -#endif - -/* - * wint_t is unsigned short for compatibility with MS runtime - */ -#define WINT_MIN 0U -#define WINT_MAX 0xffffU - -#endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */ - - -/* 7.18.4 Macros for integer constants */ -#if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS) - -/* 7.18.4.1 Macros for minimum-width integer constants - - Accoding to Douglas Gwyn : - "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC - 9899:1999 as initially published, the expansion was required - to be an integer constant of precisely matching type, which - is impossible to accomplish for the shorter types on most - platforms, because C99 provides no standard way to designate - an integer constant with width less than that of type int. - TC1 changed this to require just an integer constant - *expression* with *promoted* type." - - The trick used here is from Clive D W Feather. -*/ - -#define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val)) -#define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val)) -#define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val)) -/* The 'trick' doesn't work in C89 for long long because, without - suffix, (val) will be evaluated as int, not intmax_t */ -#define INT64_C(val) val##i64 - -#define UINT8_C(val) (val) -#define UINT16_C(val) (val) -#define UINT32_C(val) (val##i32) -#define UINT64_C(val) val##ui64 - -/* 7.18.4.2 Macros for greatest-width integer constants */ -#define INTMAX_C(val) val##i64 -#define UINTMAX_C(val) val##ui64 - -#endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */ - -#endif diff --git a/src/syslinux/unistd.h b/src/syslinux/unistd.h deleted file mode 100644 index 8941b5eb..00000000 --- a/src/syslinux/unistd.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _MSC_VER -#error This header should only be used with Microsoft compilers -#endif - -/* Workaround unisdt.h for MS compilers */ - -#ifndef _UNISTD_H_ -#define _UNISTD_H_ - -/* On MS environments, the inline keyword is available in C++ only */ -#ifndef inline -#define inline __inline -#endif - -/* ssize_t is also not available (copy/paste from MinGW) */ -#ifndef _SSIZE_T_DEFINED -#define _SSIZE_T_DEFINED -#undef ssize_t -#ifdef _WIN64 - typedef __int64 ssize_t; -#else - typedef int ssize_t; -#endif /* _WIN64 */ -#endif /* _SSIZE_T_DEFINED */ - -#endif \ No newline at end of file diff --git a/wdk_build.cmd b/wdk_build.cmd index 46a993e3..062f4c47 100644 --- a/wdk_build.cmd +++ b/wdk_build.cmd @@ -65,7 +65,7 @@ copy .msvc\iso9660_sources sources >NUL 2>&1 %BUILD_CMD% @echo off if errorlevel 1 goto builderror -copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\libfat.lib . >NUL 2>&1 +copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\iso9660.lib . >NUL 2>&1 if EXIST Makefile.hide ren Makefile.hide Makefile if EXIST sources del sources >NUL 2>&1 @@ -80,7 +80,22 @@ copy .msvc\udf_sources sources >NUL 2>&1 %BUILD_CMD% @echo off if errorlevel 1 goto builderror -copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\libfat.lib . >NUL 2>&1 +copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\udf.lib . >NUL 2>&1 + +if EXIST Makefile.hide ren Makefile.hide Makefile +if EXIST sources del sources >NUL 2>&1 + +::# libcdio driver Library +cd ..\driver +if EXIST Makefile ren Makefile Makefile.hide + +copy .msvc\driver_sources sources >NUL 2>&1 + +@echo on +%BUILD_CMD% +@echo off +if errorlevel 1 goto builderror +copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\driver.lib . >NUL 2>&1 if EXIST Makefile.hide ren Makefile.hide Makefile if EXIST sources del sources >NUL 2>&1