--- iat-0.1.3.orig/Makefile.in +++ iat-0.1.3/Makefile.in @@ -90,6 +90,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -112,7 +113,6 @@ STRIP = @STRIP@ VERSION = @VERSION@ ac_ct_CC = @ac_ct_CC@ -ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__include = @am__include@ @@ -123,19 +123,26 @@ bindir = @bindir@ build_alias = @build_alias@ 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@ sysconfdir = @sysconfdir@ --- iat-0.1.3.orig/debian/changelog +++ iat-0.1.3/debian/changelog @@ -0,0 +1,51 @@ +iat (0.1.3-7build1) bionic; urgency=high + + * No change rebuild to pick up -fPIE compiler default + + -- Balint Reczey Tue, 03 Apr 2018 12:28:24 +0000 + +iat (0.1.3-7) unstable; urgency=low + + * My email address has been changed. + + -- Dmitry E. Oboukhov Fri, 30 May 2008 07:53:00 +0400 + +iat (0.1.3-6) unstable; urgency=low + + * Added debian/watch file. + * Bumped control::Standards-Version to 3.7.3. + + -- Dmitry E. Oboukhov Sat, 09 Feb 2008 14:15:42 +0300 + +iat (0.1.3-5) unstable; urgency=low + + * Fix typo in manpage, thanks "A. Costa" + (closes: #422301). + + -- Dmitry E. Oboukhov Sat, 05 May 2007 21:55:51 +0400 + +iat (0.1.3-4) unstable; urgency=low + + * Add man-page patch (closes: #420626). + + -- Dmitry E. Oboukhov Mon, 2 Apr 2007 18:04:35 +0400 + +iat (0.1.3-3) unstable; urgency=low + + * Remove autotools-dev from Build-depends. + * Change package description. + + -- Dmitry E. Oboukhov Sun, 1 Apr 2007 18:55:57 +0400 + +iat (0.1.3-2) unstable; urgency=low + + * Fix parsing command-line parameters thanks Salsan. + + -- Dmitry E. Oboukhov Wed, 28 Mar 2007 16:31:21 +0400 + +iat (0.1.3-1) unstable; urgency=low + + * Initial release (Closes: #414747). + + -- Dmitry E. Oboukhov Tue, 27 Mar 2007 22:49:32 +0400 + --- iat-0.1.3.orig/debian/compat +++ iat-0.1.3/debian/compat @@ -0,0 +1 @@ +5 --- iat-0.1.3.orig/debian/control +++ iat-0.1.3/debian/control @@ -0,0 +1,16 @@ +Source: iat +Section: otherosfs +Priority: extra +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Dmitry E. Oboukhov +Build-Depends: debhelper (>= 5) +Standards-Version: 3.7.3 + +Package: iat +Architecture: any +Depends: ${shlibs:Depends} +Description: Converts many CD-ROM image formats to iso9660 + iat (Iso9660 Analyzer Tool) is a tool for detecting the structure + of many types of CD-ROM image file formats, such as BIN, MDF, PDI, + CDI, NRG, and B5I, and converting them into ISO-9660. + --- iat-0.1.3.orig/debian/copyright +++ iat-0.1.3/debian/copyright @@ -0,0 +1,33 @@ +This package was debianized by Dmitry E. Oboukhov on +Tue, 27 Mar 2007 22:49:32 +0400. + +It was downloaded from http://iat.berlios.de/ + +Upstream Author: Salvatore Santagati + +Copyright: + 2006,2007 Salvatore Santagati + +License: + 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., 51 Franklin St, Fifth Floor, Boston, + MA 02110-1301, USA. + + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2007, Dmitry E. Oboukhov and +is licensed under the GPL, see above. + --- iat-0.1.3.orig/debian/rules +++ iat-0.1.3/debian/rules @@ -0,0 +1,68 @@ +#!/usr/bin/make -f + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +config-stamp: + dh_testdir + ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" 2>&1 | tee $@ + + +build: build-stamp + +build-stamp: config-stamp + dh_testdir + $(MAKE) + touch $@ + +clean: + dh_testdir + dh_testroot + [ ! -f Makefile ] || [ ! -f config.status ] || $(MAKE) distclean + rm -f config-stamp build-stamp +# rm -f src/Makefile.in + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) DESTDIR=$(CURDIR)/debian/iat install + + +binary-indep: build install + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs ChangeLog + dh_installdocs + dh_installexamples + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install --- iat-0.1.3.orig/debian/watch +++ iat-0.1.3/debian/watch @@ -0,0 +1,3 @@ +version=3 +https://developer.berlios.de/project/showfiles.php?group_id=6784 \ + http://(?:.*)iat-(\d+(?:\.\d+){1,3})-src.tar.(?:bz2|gz) --- iat-0.1.3.orig/src/Makefile.am +++ iat-0.1.3/src/Makefile.am @@ -1,3 +1,4 @@ bin_PROGRAMS = iat -iat_SOURCES = iat.c +iat_SOURCES = iat.c +man_MANS = iat.1 AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -Wall --- iat-0.1.3.orig/src/Makefile.in +++ iat-0.1.3/src/Makefile.in @@ -44,7 +44,7 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_iat_OBJECTS = iat.$(OBJEXT) @@ -59,6 +59,9 @@ LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(iat_SOURCES) DIST_SOURCES = $(iat_SOURCES) +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man_MANS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -83,6 +86,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -105,7 +109,6 @@ STRIP = @STRIP@ VERSION = @VERSION@ ac_ct_CC = @ac_ct_CC@ -ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__include = @am__include@ @@ -116,24 +119,32 @@ bindir = @bindir@ build_alias = @build_alias@ 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@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -iat_SOURCES = iat.c +iat_SOURCES = iat.c +man_MANS = iat.1 AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -Wall all: all-am @@ -217,6 +228,51 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` uninstall-info-am: +install-man1: $(man1_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)" + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \ + done +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man1dir)/$$inst"; \ + done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -295,9 +351,9 @@ done check-am: all-am check: check-am -all-am: Makefile $(PROGRAMS) +all-am: Makefile $(PROGRAMS) $(MANS) installdirs: - for dir in "$(DESTDIR)$(bindir)"; do \ + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-am @@ -344,13 +400,13 @@ info-am: -install-data-am: +install-data-am: install-man install-exec-am: install-binPROGRAMS install-info: install-info-am -install-man: +install-man: install-man1 installcheck-am: @@ -371,18 +427,21 @@ ps-am: -uninstall-am: uninstall-binPROGRAMS uninstall-info-am +uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man + +uninstall-man: uninstall-man1 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-exec install-exec-am \ - install-info install-info-am install-man 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 uninstall-binPROGRAMS uninstall-info-am + install-info install-info-am install-man install-man1 \ + 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 uninstall-binPROGRAMS \ + uninstall-info-am uninstall-man uninstall-man1 # 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. --- iat-0.1.3.orig/src/iat.1 +++ iat-0.1.3/src/iat.1 @@ -0,0 +1,47 @@ +.TH iat 1 "Mon Apr 2 17:21:31 MSD 2007" +.SH NAME +.B iat +- converts many CD-ROM image formats to iso9660. +.SH SYNOPSIS +.B iat input_image_file [output_iso_file] +.PP +.B iat -h +.SH DESCRIPTION +.PP +iat (Iso9660 Analyzer Tool) is a tool for detecting the structure +of many types of CD-ROM image file formats, such as BIN, MDF, PDI, +CDI, NRG, and B5I, and converting them into ISO-9660. +.PP +If output file name is not defined, then STDOUT will be used instead. +.SH EXAMPLES +.PP +.B iat my_image.mdf my_new_image.iso +.PP +.RS 3 +- Convert MDF-image to ISO9660. +.RE +.PP +.B iat my_image.bin > my_new_image.iso +.PP +.RS 3 +- Convert BIN-image to ISO9660. +.RE +.PP +.B iat my_image.mdf | cdrecord - +.PP +.RS 3 +- Write CD directly from MDF-format. +.RE +.PP +.B iat -h +.PP +.RS 3 +- The help screen. +.RE +.SH AUTHOR +Salvatore Santagati +.SH SEE ALSO +.B mkisofs +(1), +.B wodim +(1) --- iat-0.1.3.orig/src/iat.c +++ iat-0.1.3/src/iat.c @@ -14,84 +14,99 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ + */ -/* Support Large File */ +/* + * Modified by Dmitry E. Oboukhov + * [+] Use 'getopt' function; + * [+] Use STDOUT as output file (if not defined); + * [*] Fix percent output. + */ + +/* Support Large File */ #define _FILE_OFFSET_BITS 64 +#include #include -#include -#include -#include +#include +#include +#include #include + #define VERSION "0.1.3" #define BLOCK_ISO_CD 2048 -/* Signature for Image ISO-9660 */ -const char ISO_9660_START[] = { - (char) 0x01, - (char) 0x43, - (char) 0x44, - (char) 0x30, - (char) 0x30, - (char) 0x31, - (char) 0x01, - (char) 0x00 -}; - -const char ISO_9660[] = { - (char) 0x02, - (char) 0x43, - (char) 0x44, - (char) 0x30, - (char) 0x30, - (char) 0x31, - (char) 0x01, - (char) 0x00 -}; - -const char ISO_9660_END[] = { - (char) 0xFF, - (char) 0x43, - (char) 0x44, - (char) 0x30, - (char) 0x30, - (char) 0x31, - (char) 0x01, - (char) 0x00 -}; - -/* Signature for RAW image */ -const char SYNC_RAW[12] = { - (char) 0x00, - (char) 0xFF, - (char) 0xFF, - (char) 0xFF, - (char) 0xFF, - (char) 0xFF, - (char) 0xFF, - (char) 0xFF, - (char) 0xFF, - (char) 0xFF, - (char) 0xFF, - (char) 0x00 + +#define OPTIONS_LIST "h" + + +static char *input_file=0, *output_file=0; + +/* Signature for Image ISO-9660 */ +const char ISO_9660_START[] = { + (char) 0x01, + (char) 0x43, + (char) 0x44, + (char) 0x30, + (char) 0x30, + (char) 0x31, + (char) 0x01, + (char) 0x00 +}; + +const char ISO_9660[] = { + (char) 0x02, + (char) 0x43, + (char) 0x44, + (char) 0x30, + (char) 0x30, + (char) 0x31, + (char) 0x01, + (char) 0x00 +}; + +const char ISO_9660_END[] = { + (char) 0xFF, + (char) 0x43, + (char) 0x44, + (char) 0x30, + (char) 0x30, + (char) 0x31, + (char) 0x01, + (char) 0x00 +}; + +/* Signature for RAW image */ +const char SYNC_RAW[12] = { + (char) 0x00, + (char) 0xFF, + (char) 0xFF, + (char) 0xFF, + (char) 0xFF, + (char) 0xFF, + (char) 0xFF, + (char) 0xFF, + (char) 0xFF, + (char) 0xFF, + (char) 0xFF, + (char) 0x00 }; const char SYNC_RAW_2[8] = { - (char) 0x00, - (char) 0x00, - (char) 0x08, - (char) 0x00, - (char) 0x00, - (char) 0x00, - (char) 0x08, - (char) 0x00, + (char) 0x00, + (char) 0x00, + (char) 0x08, + (char) 0x00, + (char) 0x00, + (char) 0x00, + (char) 0x08, + (char) 0x00, }; -long img_size; +long img_size; int img_detect = 2; int img_header = 0; @@ -106,260 +121,321 @@ int previous_percent=-1; void main_percent (int percent_bar) -// Prints a progress bar, takes a percentage as argument. + // Prints a progress bar, takes a percentage as argument. { //int progress_bar, progress_space; - + if (percent_bar==previous_percent) return; // Nothing changed, don't waste CPU cycles. - - printf("%3d%% [:%.*s>%.*s:]\r",percent_bar,percent_bar/5,"====================", - 20-(percent_bar/5)," "); + if (isatty(fileno(stderr))) + { + fprintf(stderr, + "\r%3d%% [:%.*s>%.*s:]", + percent_bar, + percent_bar/5, + "====================", + 20-(percent_bar/5), + " "); + } + else + { + if (previous_percent==-1) fprintf(stderr, "Working "); + if ((percent_bar/5)*5==percent_bar) fprintf(stderr, "."); + } + previous_percent=percent_bar; } -void + void usage () { - - printf ("Web : http://developer.berlios.de/projects/iat\n"); - printf ("Email : salvatore.santagati@gmail.com\n"); - printf ("Irc : irc.freenode.net #ignus\n"); - printf ("Note : What's My Age Again? \n"); - - printf ("Usage :\n"); - printf ("iat OPTIONS[inputfile] OPTIONS[outputfile]\n\n"); -// printf ("OPTIONS\n"); -// printf ("\t-i --iso Generate iso image from bin image\n"); -// printf ("\t-l --log Generate log for debug image\n"); -// printf ("\t-v --verbose Print verbose messages\n"); -// printf ("\t-o --output filename Write output to file\n"); - printf ("\t-h --help Display this notice\n\n"); + fprintf (stderr, "Web : http://developer.berlios.de/projects/iat\n"); + fprintf (stderr, "Email : salvatore.santagati@gmail.com\n"); + fprintf (stderr, "Irc : irc.freenode.net #ignus\n\n"); + + fprintf (stderr, "Usage : "); + fprintf (stderr, "iat input_file [output_file.iso]\n\n"); + fprintf (stderr, "\tIf output file name is not defined, \n" + "\tthen stdout will be used instead.\n"); + // printf ("OPTIONS\n"); + // printf ("\t-i --iso Generate iso image from bin image\n"); + // printf ("\t-l --log Generate log for debug image\n"); + // printf ("\t-v --verbose Print verbose messages\n"); + // printf ("\t-o --output filename Write output to file\n"); + fprintf (stderr, "\nOptions :\n"); + fprintf (stderr, "\t-h Display this notice\n\n"); } int image_convert() { - - long source_length, i; - char buf[2448]; - - - fseek (fsource, 0L, SEEK_END); - source_length = (ftell (fsource) - img_offset) / img_size_sector; - - - fseek (fsource, img_offset, SEEK_SET); - - { - for (i = 0; i < source_length; i++) - - { - main_percent(i*100/source_length); - - fseek (fsource, img_header, SEEK_CUR); - if (fread (buf, sizeof (char), BLOCK_ISO_CD, fsource)); - - else - { - printf ("%s\n", strerror (errno)); - exit (EXIT_FAILURE); - }; - if (fwrite (buf, sizeof (char), BLOCK_ISO_CD, fdest)); - - else - { - printf ("%s\n", strerror (errno)); - exit (EXIT_FAILURE); - }; - fseek (fsource, img_ecc, SEEK_CUR); - } - } - printf ("100%% [:=====================:]\n"); -return 0; + + long source_length, i; + char buf[2448]; + + + fseek (fsource, 0L, SEEK_END); + source_length = (ftell (fsource) - img_offset) / img_size_sector; + + + fseek (fsource, img_offset, SEEK_SET); + + { + for (i = 0; i < source_length; i++) + + { + main_percent(i*100/source_length); + + fseek (fsource, img_header, SEEK_CUR); + if (fread (buf, sizeof (char), BLOCK_ISO_CD, fsource)); + + else + { + fprintf (stderr, "%s\n", strerror (errno)); + exit (EXIT_FAILURE); + }; + if (fwrite (buf, sizeof (char), BLOCK_ISO_CD, fdest)); + + else + { + fprintf (stderr, "%s\n", strerror (errno)); + exit (EXIT_FAILURE); + }; + fseek (fsource, img_ecc, SEEK_CUR); + } + } + if (isatty(fileno(stderr))) + fprintf (stderr, "\rDone \n"); + else + fprintf (stderr, " Done\n"); + return 0; } -int image_detection() +int image_detection() { - char buf[8]; - char raw[12]; - int i; - int block_image_start = 0; - int block_image_end = 0; - int block_image_temp = 0; - int block_image = 0; - int block_image_detect = 0; - int img_header_temp = 0; - int raw_2_check = 0; - int raw_check = 0; - - - fseek(fsource, 0L, SEEK_END); - img_size = (((ftell(fsource))) / 8); - for (i = 0; img_detect == 2; i = i + 1) - { - fseek(fsource, 0L, SEEK_SET); - fseek(fsource, i, SEEK_CUR); - fread(buf, sizeof(char), 8, fsource); - fread(raw, sizeof(char), 12, fsource); - - if (!memcmp(ISO_9660_START, buf, 8)) - { - printf("Detect Signature ISO9660 START at %d\n", i); - if (block_image_start == 0) block_image_start = i ; - } - if (!memcmp(ISO_9660, buf, 8)) - { - printf("Detect Signature ISO9660 at %d\n", i); - if (block_image_end == 0) - { - block_image_end = i; - block_image_temp = block_image_end - block_image_start; - } - - img_detect++; - } if (!memcmp(ISO_9660_END, buf, 8)) - { - printf("Detect Signature ISO9660 END at %d\n", i); - if (block_image_end == 0) - { - block_image_end = i; - block_image_temp = block_image_end - block_image_start; - } - img_detect++; - } - - - if (!memcmp(SYNC_RAW_2, buf, 8)) - { - printf("Detect Signature RAW 2 at %d\n", i); - if (raw_2_check == 0) - { - img_header = img_header + 8; - raw_2_check = 1; - } - - } - if (!memcmp(SYNC_RAW, raw, 12)) - { - printf("Detect Signature RAW at %d\n", i); - if (raw_check == 0) - { - img_header = img_header + 16; - raw_check = 1; - } - - } - - if ((img_size * 8) <= i) - { - img_detect = -1; - printf("Image is broken\n"); - return 0; - } - } - - /* Detect Block structure of image */ - - for (block_image_detect = 1; block_image_detect == 1; block_image_temp =(block_image_temp / 2)) - { - if (block_image_temp >= 2048) - { - switch (block_image_temp) - { - case 2048 : block_image = block_image_temp; - block_image_detect++; - break; - case 2352 : - block_image = block_image_temp; - block_image_detect++; - break; - case 2336 : - block_image = block_image_temp; - block_image_detect++; - break; - case 2448 : - block_image = block_image_temp; - block_image_detect++; - break; - default : - break; - } - - } - - else block_image_detect = -1; - - } - - if (block_image_detect == -1); - else - img_size_sector = block_image; - - /* Size header of image */ - - img_header_temp = block_image_start - block_image * 16; - - if ((img_header_temp == 8) || (img_header_temp == 16) || (img_header_temp == 24)) - { - img_header = img_header_temp; - } - - - /* Size ECC of image */ - - img_ecc = block_image - img_header - BLOCK_ISO_CD; - - - /* Dump of image */ - - img_offset = block_image_start - block_image * 16 - img_header; - - - printf("\n Image offset start at %d", img_offset); - printf("\n Sector header %d bit", img_header); - printf("\n Sector ECC %d bit", img_ecc); - printf("\n Block %d\n", block_image); + char buf[8]; + char raw[12]; + int i; + int block_image_start = 0; + int block_image_end = 0; + int block_image_temp = 0; + int block_image = 0; + int block_image_detect = 0; + int img_header_temp = 0; + int raw_2_check = 0; + int raw_check = 0; + + + fseek(fsource, 0L, SEEK_END); + img_size = (((ftell(fsource))) / 8); + for (i = 0; img_detect == 2; i = i + 1) + { + fseek(fsource, 0L, SEEK_SET); + fseek(fsource, i, SEEK_CUR); + fread(buf, sizeof(char), 8, fsource); + fread(raw, sizeof(char), 12, fsource); + + if (!memcmp(ISO_9660_START, buf, 8)) + { + fprintf(stderr, "Detect Signature ISO9660 START at %d\n", i); + if (block_image_start == 0) block_image_start = i ; + } + if (!memcmp(ISO_9660, buf, 8)) + { + fprintf(stderr, "Detect Signature ISO9660 at %d\n", i); + if (block_image_end == 0) + { + block_image_end = i; + block_image_temp = block_image_end - block_image_start; + } + + img_detect++; + } + + if (!memcmp(ISO_9660_END, buf, 8)) + { + fprintf(stderr, "Detect Signature ISO9660 END at %d\n", i); + if (block_image_end == 0) + { + block_image_end = i; + block_image_temp = block_image_end - block_image_start; + } + img_detect++; + } + + + if (!memcmp(SYNC_RAW_2, buf, 8)) + { + fprintf(stderr, "Detect Signature RAW 2 at %d\n", i); + if (raw_2_check == 0) + { + img_header = img_header + 8; + raw_2_check = 1; + } + + } + if (!memcmp(SYNC_RAW, raw, 12)) + { + fprintf(stderr, "Detect Signature RAW at %d\n", i); + if (raw_check == 0) + { + img_header = img_header + 16; + raw_check = 1; + } + + } + + if ((img_size * 8) <= i) + { + img_detect = -1; + fprintf(stderr, "Image is broken\n"); + return 0; + } + } + + /* Detect Block structure of image */ + + for (block_image_detect = 1; block_image_detect == 1; block_image_temp =(block_image_temp / 2)) + { + if (block_image_temp >= 2048) + { + switch (block_image_temp) + { + case 2048 : block_image = block_image_temp; + block_image_detect++; + break; + case 2352 : + block_image = block_image_temp; + block_image_detect++; + break; + case 2336 : + block_image = block_image_temp; + block_image_detect++; + break; + case 2448 : + block_image = block_image_temp; + block_image_detect++; + break; + default : + break; + } + + } + + else block_image_detect = -1; + + } + + if (block_image_detect == -1); + else + img_size_sector = block_image; + + /* Size header of image */ + + img_header_temp = block_image_start - block_image * 16; + + if ((img_header_temp == 8) || (img_header_temp == 16) || (img_header_temp == 24)) + { + img_header = img_header_temp; + } + + + /* Size ECC of image */ + + img_ecc = block_image - img_header - BLOCK_ISO_CD; + + + /* Dump of image */ + + img_offset = block_image_start - block_image * 16 - img_header; + + + fprintf(stderr, "\n Image offset start at %d", img_offset); + fprintf(stderr, "\n Sector header %d bit", img_header); + fprintf(stderr, "\n Sector ECC %d bit", img_ecc); + fprintf(stderr, "\n Block %d\n", block_image); + + return 1; +} - return 1; - } -int main(int argc, char **argv) +void parse_options(int argc, char ** argv) { + int c; + + for (c=getopt(argc, argv, OPTIONS_LIST); + c!=-1; + c=getopt(argc, argv, OPTIONS_LIST)) + { + switch(c) + { + case 'h': + usage(); + exit(0); + + case '?': + break; + + default: + fprintf (stderr, "?? getopt returned character code 0%o ??\n", c); + + } + } + + if (argc-optind<1 || argc-optind>2) + { + usage(); + exit(EXIT_FAILURE); + } - printf("Iso9660 Analyzer Tool v%s by Salvatore Santagati\n", VERSION); - printf("Licensed under GPL v2 or later\n"); + input_file=argv[optind]; + if (argc-optind==2) output_file=argv[optind+1]; +} - if ((fsource = fopen(argv[1], "rb")) != NULL) - { - if (image_detection() == 0) - printf("This image is not CD IMAGE\n"); - else if (argc > 2) - { - if ((fdest = fopen(argv[2],"wb")) != NULL) - { - image_convert(); - fclose(fdest); - } - else - { - printf("%s\n", strerror(errno)); - usage(); - } - } - - } - else - { - printf("%s\n", strerror(errno)); - usage(); - exit(EXIT_FAILURE); - } - - return 1; - -} +int main(int argc, char **argv) +{ + fprintf(stderr, + "Iso9660 Analyzer Tool v%s by Salvatore Santagati\n", VERSION); + fprintf(stderr, "Licensed under GPL v2 or later\n\n"); + + parse_options(argc, argv); + + if ((fsource = fopen(input_file, "rb")) != NULL) + { + if (image_detection() == 0) + { + fprintf(stderr, "This image is not CD IMAGE\n"); + exit(EXIT_FAILURE); + } + else + { + if (output_file) + { + if (!(fdest = fopen(output_file, "wb"))) + { + fprintf(stderr, "%s\n", strerror(errno)); + usage(); + exit(EXIT_FAILURE); + } + } + else + { + fdest=stdout; + } + image_convert(); + fclose(fdest); + } + } + else + { + fprintf(stderr, "%s\n", strerror(errno)); + usage(); + exit(EXIT_FAILURE); + } + + return 0; +}