diff --git a/libisoburn/branches/ZeroOneFour/AUTHORS b/libisoburn/branches/ZeroOneFour/AUTHORS new file mode 100644 index 00000000..0547ea18 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/AUTHORS @@ -0,0 +1,3 @@ +Thomas Schmitt +Vreixo Formoso Lopes + diff --git a/libisoburn/branches/ZeroOneFour/CONTRIBUTORS b/libisoburn/branches/ZeroOneFour/CONTRIBUTORS new file mode 100644 index 00000000..e69de29b diff --git a/libisoburn/branches/ZeroOneFour/COPYING b/libisoburn/branches/ZeroOneFour/COPYING new file mode 100644 index 00000000..5a965fbc --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/COPYING @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/libisoburn/branches/ZeroOneFour/COPYRIGHT b/libisoburn/branches/ZeroOneFour/COPYRIGHT new file mode 100644 index 00000000..208ccb7e --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/COPYRIGHT @@ -0,0 +1,22 @@ +Mario Danic , +Vreixo Formoso +Thomas Schmitt +libisoburn is Copyright (C) 2007-2008 Vreixo Formoso, Thomas Schmitt +xorriso is Copyright (C) 2007-2008 Thomas Schmitt +libisofs (if included) is Copyright (C) 2007-2008 Vreixo Formoso, Mario Danic +libburn (if included) is Copyright (C) 2002-2006 Derek Foreman, Ben Jansens + and Copyright (C) 2006-2008 Mario Danic, Thomas Schmitt + + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + 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 diff --git a/libisoburn/branches/ZeroOneFour/INSTALL b/libisoburn/branches/ZeroOneFour/INSTALL new file mode 100644 index 00000000..a6580e5a --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/INSTALL @@ -0,0 +1,237 @@ + +See file README for libisoburn and xorriso specific installation instructions. +This file here is rather a manual for advanced usage of ./configure + +------------------------------------------------------------------- + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/libisoburn/branches/ZeroOneFour/Makefile.am b/libisoburn/branches/ZeroOneFour/Makefile.am new file mode 100644 index 00000000..e1b4711a --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/Makefile.am @@ -0,0 +1,131 @@ +pkgconfigdir=$(libdir)/pkgconfig +libincludedir=$(includedir)/libisoburn + +lib_LTLIBRARIES = libisoburn/libisoburn.la + +## ========================================================================= ## + +# Build libraries +libisoburn_libisoburn_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +libisoburn_libisoburn_la_SOURCES = \ + libisoburn/burn_wrap.c \ + libisoburn/data_source.c \ + libisoburn/isoburn.c \ + libisoburn/isoburn.h \ + libisoburn/isofs_wrap.c \ + libisoburn/libisoburn.h \ + version.h +libisoburn_libisoburn_la_LIBADD = \ + -lisofs \ + -lburn +libinclude_HEADERS = \ + libisoburn/libisoburn.h + +## ========================================================================= ## + + +# This is the reference application of libisoburn. See man xorriso/xorriso.1 +# +bin_PROGRAMS = \ + xorriso/xorriso + +xorriso_xorriso_CPPFLAGS = -Ilibisoburn +xorriso_xorriso_CFLAGS = -DXorriso_with_maiN -DXorriso_with_regeX $(READLINE_DEF) +xorriso_xorriso_LDADD = libisoburn/libisoburn.la -lisofs -lburn $(THREAD_LIBS) +xorriso_xorriso_SOURCES = \ + xorriso/xorriso.h \ + xorriso/xorriso_private.h \ + xorriso/xorriso.c \ + xorriso/xorrisoburn.h \ + xorriso/xorrisoburn.c \ + xorriso/xorriso_timestamp.h + + +## Build test applications +noinst_PROGRAMS = \ + test/compare_file + +# A program to compare two files in mirrored trees in mounted filesystems +# To compare tree /media/dvd and /original/dir : +# find /media/dvd -exec test/compare_file '{}' /media/dvd /original/dir ';' +# +test_compare_file_CPPFLAGS = +test_compare_file_CFLAGS = +test_compare_file_LDADD = +test_compare_file_SOURCES = test/compare_file.c + +# ts A80110 - A80210 : we need as minimal demo something better than test.c +# test/test + +# test_test_CPPFLAGS = -Ilibisofs -Ilibburn -Ilibisoburn +# test_test_LDADD = $(libisoburn_libisoburn_la_OBJECTS) $(THREAD_LIBS) -lburn -lisofs +# test_test_SOURCES = test/test.c + + +## ========================================================================= ## + +## Build documentation (You need Doxygen for this to work) +webhost = http://libburn-api.pykix.org +webpath = / +docdir = $(DESTDIR)$(prefix)/share/doc/$(PACKAGE)-$(VERSION) + +doc: doc/html + +doc/html: doc/doxygen.conf + if [ -f ./doc/doc.lock ]; then \ + $(RM) -r doc/html; \ + doxygen doc/doxygen.conf; \ + fi + +doc-upload: doc/html + scp -r $ + and Thomas Schmitt +Integrated sub project of libburnia-project.org. +Copyright (C) 2006-2008 Vreixo Formoso, Thomas Schmitt. +Provided under GPL version 2. +------------------------------------------------------------------------------ + +libisoburn is a frontend for libraries libburn and libisofs which enables +creation and expansion of ISO-9660 filesystems on all CD/DVD media supported +by libburn. This includes media like DVD+RW, which do not support multi-session +management on media level and even plain disk files or block devices. + +The price for that is thorough specialization on data files in ISO-9660 +filesystem images. So libisoburn is not suitable for audio (CD-DA) or any +other CD layout which does not entirely consist of ISO-9660 sessions. + +Currently it is only supported on Linux with kernels >= 2.4. + +By using this software you agree to the disclaimer at the end of this text: +"... without even the implied warranty ..." + + + Compilation, First Glimpse, Installation + +Dynamic library and compile time header requirements for libisoburn-0.1.3 : +- libburn.so.4 , version libburn-0.4.2 or higher +- libisofs.so.6 , version libisofs-0.6.3 or higher +libisoburn and xorriso will not start with libraries which are older than their +headers seen at compile time. So compile in the oldest possible installation +setup unless you have reason to enforce a newer bug fix level. + +Obtain libisoburn-0.1.3.tar.gz, take it to a directory of your choice and do: + + tar xzf libisoburn-0.1.3.tar.gz + cd libisoburn-0.1.3 + +Within that directory execute: + + ./configure --prefix=/usr + make + +Then become superuser and execute + make install +which will make available libisoburn.so.1 . + +For the API concepts and calls see + ./libisoburn/libisoburn.h +as well as + /usr/lib/libisofs/libisofs.h + /usr/lib/libburn/libburn.h + + + xorriso + +libisoburn includes a command line and dialog application named xorriso, +which offers a substantial part of libisoburn features to shell scripts and +users. Its file xorriso/README describes a standlone tarball as first +preference for xorriso installation. +The installation described here produces a dynamically linked xorriso binary +as described in chapter "libisoburn" at the end of that text. + +After installation documentation is available via + man xorriso + + + Drives and Disk File Objects + +The user of libisoburn applications needs rw-permission for the CD/DVD burner +devices which shall be used. +A list of rw-accessible drives can be obtained by + xorriso -devices +resp. by libburn API call + burn_drive_scan() + + +A possible source of problems are hald or other automounters. +If you can spot a process "hald-addon-storage" with the address of +your desired drive, then consider to kill it. + +If you cannot get rid of the automounter that easily, try whether it helps +to always load the drive tray manually before starting a write run of +xorriso. Wait until the drive light is off. +Better try to unmount an eventually mounted media before a write run. + + +Besides true optical drives, libisoburn can also address disk files as input or +output drives. The addresses of the disk files have to be preceded by "stdio:". +Like: + "stdio:/tmp/pseudo_drive" + + + Testing + +We are quite sure that libisofs produces accurate representations of the disk +files. This opinion is founded on a lot of test burns and checks by a little +test program which compares files from the mounted image with the orignals +on disk. It uses the normal POSIX filesystem calls, i.e. no libburnia stuff. + +This program is not installed systemwide but stays in the installation +directory of the xorriso tarball as test/compare_file . Usually it is +run as -exec payload of a find command. It demands at least three arguments: +The path of the first file to compare, the prefix1 to be cut off from path +and the prefix2 which gets prepended afterwards to obtain the path of the +second file to compare. +As further argument there can be -no_ctime which suppresses the comparison +of ctime date stamps. +The exit value is 0 if no difference was detected, non-0 else. + +Example: After + xorriso ... -pathspecs on -add /=/original/dir -- + mount /media/dvd + cd test +compare tree /media/dvd with tree /original/dir : + find /original/dir -exec ./compare_file '{}' /original/dir /media/dvd ';' \ + | less +and vice versa: + find /media/dvd -exec ./compare_file '{}' /media/dvd /original/dir ';' \ + | less + + +------------------------------------------------------------------------------ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + 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 + +------------------------------------------------------------------------------ +Based on and sub project of: +libburnia-project.org +By Mario Danic , + Vreixo Formoso + Thomas Schmitt +Copyright (C) 2006-2008 Mario Danic, Vreixo Formoso, Thomas Schmitt. + +libburnia-project.org is inspired by and in other components still containing +parts of old +Libburn. By Derek Foreman and + Ben Jansens +Copyright (C) 2002-2006 Derek Foreman and Ben Jansens + diff --git a/libisoburn/branches/ZeroOneFour/TODO b/libisoburn/branches/ZeroOneFour/TODO new file mode 100644 index 00000000..23e3b643 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/TODO @@ -0,0 +1,11 @@ +[Task] Figure out how to use "Requires" in pc.in (libisoburn and libisofs would benefit) +[Task] Figure out the usage of Libs.private (used in libburn) +[Task] Improve build system +[Task] Investigate build system, so other libburnia components can benefit +[Task] Write Doxygen files +[Task] Explain to Thomas & Vreixo about NEWS importance (all libburnia components + will benefit +[Task] Write a document about ABI & API +[Task] Create following targets for make: Src, Indent, Docs, Test, All [Any other suggestions?) + +All those tasks are currently assigned to Mario. diff --git a/libisoburn/branches/ZeroOneFour/acinclude.m4 b/libisoburn/branches/ZeroOneFour/acinclude.m4 new file mode 100644 index 00000000..861847bb --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/acinclude.m4 @@ -0,0 +1,22 @@ +AC_DEFUN([TARGET_SHIZZLE], +[ + ARCH="" + + AC_MSG_CHECKING([target operating system]) + + case $target in + *-*-linux*) + ARCH=linux + LIBBURN_ARCH_LIBS= + ;; + *-*-freebsd*) + ARCH=freebsd + LIBBURN_ARCH_LIBS=-lcam + ;; + *) + AC_ERROR([You are attempting to compile for an unsupported platform]) + ;; + esac + + AC_MSG_RESULT([$ARCH]) +]) diff --git a/libisoburn/branches/ZeroOneFour/bootstrap b/libisoburn/branches/ZeroOneFour/bootstrap new file mode 100755 index 00000000..3583d1c7 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/bootstrap @@ -0,0 +1,7 @@ +#!/bin/sh -x + +aclocal +libtoolize --copy --force +autoconf +automake --foreign --add-missing --copy --include-deps + diff --git a/libisoburn/branches/ZeroOneFour/configure.ac b/libisoburn/branches/ZeroOneFour/configure.ac new file mode 100644 index 00000000..602b9400 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/configure.ac @@ -0,0 +1,125 @@ +AC_INIT([libisoburn], [0.1.3], [http://libburnia-project.org]) +AC_PREREQ([2.50]) +dnl AC_CONFIG_HEADER([config.h]) + +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +AM_INIT_AUTOMAKE([subdir-objects]) + +dnl The API version codes are now defined in libisoburn/libisoburn.h +dnl #define isoburn_header_version_* +dnl configure.ac only rules the libtool revision numbering about +dnl LT_CURREN, LT_AGE, LT_REVISION where SONAME becomes LT_CURRENT - LT_AGE +dnl +dnl These three are only copies to provide libtool with unused LT_RELEASE +ISOBURN_MAJOR_VERSION=0 +ISOBURN_MINOR_VERSION=1 +ISOBURN_MICRO_VERSION=3 +dnl ISOBURN_VERSION=$ISOBURN_MAJOR_VERSION.$ISOBURN_MINOR_VERSION.$ISOBURN_MICRO_VERSION + +AC_SUBST(ISOBURN_MAJOR_VERSION) +AC_SUBST(ISOBURN_MINOR_VERSION) +AC_SUBST(ISOBURN_MICRO_VERSION) +dnl AC_SUBST(ISOBURN_VERSION) + +dnl Libtool versioning +dnl Generate libisoburn.so.1.x.y +dnl SONAME will become LT_CURRENT - LT_AGE +dnl +dnl ts A80215 +dnl This is the development version after stable release libisoburn.so.1.1.0 +dnl LT_CURRENT++, LT_AGE++ has happened meanwhile. +dnl +dnl SONAME = 3 - 2 = 1 . Library name = libburn.so.1.2.0 +LT_RELEASE=$ISOBURN_MAJOR_VERSION.$ISOBURN_MINOR_VERSION +LT_CURRENT=3 +LT_AGE=2 +LT_REVISION=0 +LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE` + +AC_SUBST(LT_RELEASE) +AC_SUBST(LT_CURRENT) +AC_SUBST(LT_REVISION) +AC_SUBST(LT_AGE) +AC_SUBST(LT_CURRENT_MINUS_AGE) + +AC_PREFIX_DEFAULT([/usr/local]) +test "$prefix" = "NONE" && prefix=$ac_default_prefix + +AM_MAINTAINER_MODE + +AM_PROG_CC_C_O +AC_C_CONST +AC_C_INLINE +AC_C_BIGENDIAN + +dnl Large file support +AC_SYS_LARGEFILE +AC_FUNC_FSEEKO +AC_CHECK_FUNC([fseeko]) +if test ! $ac_cv_func_fseeko; then + AC_ERROR([Libburn requires largefile support.]) +fi + +AC_PROG_LIBTOOL +AC_SUBST(LIBTOOL_DEPS) +LIBTOOL="$LIBTOOL --silent" + +AC_PROG_INSTALL + +AC_CHECK_HEADERS() + +THREAD_LIBS=-lpthread +AC_SUBST(THREAD_LIBS) + +TARGET_SHIZZLE +AC_SUBST(ARCH) +AC_SUBST(LIBBURN_ARCH_LIBS) + + +dnl Check whether there is readline-devel and readline-runtime. +dnl If not, erase this macro which would enable use of readline(),add_history() +READLINE_DEF="-DXorriso_with_readlinE" +dnl The empty yes case obviously causes -lreadline to be linked +AC_CHECK_HEADER(readline/readline.h, AC_CHECK_LIB(readline, readline, , READLINE_DEF= ), READLINE_DEF= ) +dnl The X= in the yes case prevents that -lreadline gets linked twice +AC_CHECK_HEADER(readline/history.h, AC_CHECK_LIB(readline, add_history, X= , READLINE_DEF= ), READLINE_DEF= ) +AC_SUBST(READLINE_DEF) + + +AC_CHECK_HEADER(libburn/libburn.h) +AC_CHECK_HEADER(libisofs/libisofs.h) + +dnl Check for proper library versions +LIBBURN_REQUIRED=0.4.2 +LIBISOFS_REQUIRED=0.6.2 +PKG_CHECK_MODULES(LIBBURN, libburn-1 >= $LIBBURN_REQUIRED) +PKG_CHECK_MODULES(LIBISOFS, libisofs-1 >= $LIBISOFS_REQUIRED) + +dnl Add compiler-specific flags + +dnl See if the user wants aggressive optimizations of the code +AC_ARG_ENABLE(debug, +[ --enable-debug Disable aggressive optimizations [default=yes]], + , enable_debug=yes) +if test x$enable_debug != xyes; then + if test x$GCC = xyes; then + CFLAGS="$CFLAGS -O3" + CFLAGS="$CFLAGS -fexpensive-optimizations" + fi + CFLAGS="$CFLAGS -DNDEBUG" +else + if test x$GCC = xyes; then + CFLAGS="$CFLAGS -g -pedantic -Wall" + fi + CFLAGS="$CFLAGS -DDEBUG" +fi + +AC_CONFIG_FILES([ + Makefile + doc/doxygen.conf + version.h + libisoburn-1.pc + ]) +AC_OUTPUT diff --git a/libisoburn/branches/ZeroOneFour/doc/doxygen.conf.in b/libisoburn/branches/ZeroOneFour/doc/doxygen.conf.in new file mode 100644 index 00000000..e36d6010 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/doc/doxygen.conf.in @@ -0,0 +1,1300 @@ +# Doxyfile 1.5.3 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file that +# follow. The default is UTF-8 which is also the encoding used for all text before +# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into +# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of +# possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = @PACKAGE_NAME@ + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = @PACKAGE_VERSION@ + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, +# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, +# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, +# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = @top_srcdir@ + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = YES + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = YES + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to +# include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be extracted +# and appear in the documentation as a namespace called 'anonymous_namespace{file}', +# where file will be replaced with the base name of the file that contains the anonymous +# namespace. By default anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text " + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = libburn \ + doc \ + test + +# This tag can be used to specify the character encoding of the source files that +# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default +# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. +# See http://www.gnu.org/software/libiconv for the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py + +FILE_PATTERNS = libburn.h \ + comments \ + libburner.c + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the output. +# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, +# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = test + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH +# then you must also enable this option. If you don't then doxygen will produce +# a warning and turn it on anyway + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = OB \ + OTK \ + _ + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = doc/html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 200 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = letter + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = DOXYGEN + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to +# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to +# specify the directory where the mscgen tool resides. If left empty the tool is assumed to +# be found in the default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = NO + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the number +# of direct children of the root node in a graph is already larger than +# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/libisoburn/branches/ZeroOneFour/libisoburn-1.pc.in b/libisoburn/branches/ZeroOneFour/libisoburn-1.pc.in new file mode 100644 index 00000000..7fae3f90 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/libisoburn-1.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libisoburn +Description: Multi-session filesystem extension to libisofs, libburn. +Version: @VERSION@ +Requires: +Libs: -L${libdir} -lisoburn +Cflags: -I${includedir}/libisoburn + diff --git a/libisoburn/branches/ZeroOneFour/libisoburn/burn_wrap.c b/libisoburn/branches/ZeroOneFour/libisoburn/burn_wrap.c new file mode 100644 index 00000000..abe00807 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/libisoburn/burn_wrap.c @@ -0,0 +1,900 @@ + +/* + cc -g -c \ + -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE \ + burn_wrap.c +*/ +/* libburn wrappers for libisoburn + + Copyright 2007 Thomas Schmitt, +*/ + +/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo +#define Hardcoded_cd_rW 1 +#define Hardcoded_cd_rw_c1 12999 +#define Hardcoded_cd_rw_nwA 152660 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + + +#ifndef Xorriso_standalonE + +#include + +#include + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" + +#endif /* Xorriso_standalonE */ + + +#include "libisoburn.h" +#include "isoburn.h" + + +/* The global list of isoburn objects. Usually there is only one. */ +extern struct isoburn *isoburn_list_start; /* in isoburn.c */ + + +int isoburn_initialize(char msg[1024], int flag) +{ + int major, minor, micro, bad_match= 0; + + +/* First two ugly compile time checks for header version compatibility. + If everthing matches, then they produce no C code. In case of mismatch, + intentionally faulty C code will be inserted. +*/ + +#ifdef iso_lib_header_version_major +/* The minimum requirement of libisoburn towards the libisofs header + at compile time is defined in libisoburn/libisoburn.h : + isoburn_libisofs_req_major + isoburn_libisofs_req_minor + isoburn_libisofs_req_micro + It gets compared against the version macros in libisofs/libisofs.h : + iso_lib_header_version_major + iso_lib_header_version_minor + iso_lib_header_version_micro + If the header is too old then the following code shall cause failure of + cdrskin compilation rather than to allow production of a program with + unpredictable bugs or memory corruption. + The compiler messages supposed to appear in this case are: + error: 'LIBISOFS_MISCONFIGURATION' undeclared (first use in this function) + error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisofs_dot_h_TOO_OLD__SEE_libisoburn_dot_h_and_burn_wrap_dot_h' undeclared (first use in this function) + error: 'LIBISOFS_MISCONFIGURATION_' undeclared (first use in this function) +*/ +/* The indendation is an advise of man gcc to help old compilers ignoring */ + #if isoburn_libisofs_req_major > iso_lib_header_version_major + #define Isoburn_libisofs_dot_h_too_olD 1 + #endif + #if isoburn_libisofs_req_major == iso_lib_header_version_major && isoburn_libisofs_req_minor > iso_lib_header_version_minor + #define Isoburn_libisofs_dot_h_too_olD 1 + #endif + #if isoburn_libisofs_req_minor == iso_lib_header_version_minor && isoburn_libisofs_req_micro > iso_lib_header_version_micro + #define Isoburn_libisofs_dot_h_too_olD 1 + #endif + +#ifdef Isoburn_libisofs_dot_h_too_olD +LIBISOFS_MISCONFIGURATION = 0; +INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisofs_dot_h_TOO_OLD__SEE_libisoburn_dot_h_and_burn_wrap_dot_h = 0; +LIBISOFS_MISCONFIGURATION_ = 0; +#endif + +#endif /* iso_lib_header_version_major */ + +/* The minimum requirement of libisoburn towards the libburn header + at compile time is defined in libisoburn/libisoburn.h : + isoburn_libburn_req_major + isoburn_libburn_req_minor + isoburn_libburn_req_micro + It gets compared against the version macros in libburn/libburn.h : + burn_header_version_major + burn_header_version_minor + burn_header_version_micro + If the header is too old then the following code shall cause failure of + cdrskin compilation rather than to allow production of a program with + unpredictable bugs or memory corruption. + The compiler messages supposed to appear in this case are: + error: 'LIBBURN_MISCONFIGURATION' undeclared (first use in this function) + error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libburn_dot_h_TOO_OLD__SEE_libisoburn_dot_h_and_burn_wrap_dot_h' undeclared (first use in this function) + error: 'LIBBURN_MISCONFIGURATION_' undeclared (first use in this function) +*/ + +/* The indendation is an advise of man gcc to help old compilers ignoring */ + #if isoburn_libburn_req_major > burn_header_version_major + #define Isoburn_libburn_dot_h_too_olD 1 + #endif + #if isoburn_libburn_req_major == burn_header_version_major && isoburn_libburn_req_minor > burn_header_version_minor + #define Isoburn_libburn_dot_h_too_olD 1 + #endif + #if isoburn_libburn_req_minor == burn_header_version_minor && isoburn_libburn_req_micro > burn_header_version_micro + #define Isoburn_libburn_dot_h_too_olD 1 + #endif + +#ifdef Isoburn_libburn_dot_h_too_olD +LIBBURN_MISCONFIGURATION = 0; +INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libburn_dot_h_TOO_OLD__SEE_libisoburn_dot_h_and_burn_wrap_dot_h = 0; +LIBBURN_MISCONFIGURATION_ = 0; +#endif + +/* End of ugly compile time tests (scroll up for explanation) */ + + + + msg[0]= 0; + if(iso_init()<0) { + sprintf(msg+strlen(msg), "Cannot initialize libisofs\n"); + return(0); + } + iso_lib_version(&major, &minor, µ); + sprintf(msg+strlen(msg), "libisofs-%d.%d.%d ", major, minor, micro); +#ifdef iso_lib_header_version_major + if(iso_lib_is_compatible(iso_lib_header_version_major, + iso_lib_header_version_minor, + iso_lib_header_version_micro)) { + sprintf(msg+strlen(msg), "ok, "); + } else { + sprintf(msg+strlen(msg),"- TOO OLD -, need at least libisofs-%d.%d.%d ,\n", + iso_lib_header_version_major, iso_lib_header_version_minor, + iso_lib_header_version_micro); + bad_match= 1; + } +#else + if(iso_lib_is_compatible(isoburn_libisofs_req_major, + isoburn_libisofs_req_minor, + isoburn_libisofs_req_micro)) { + sprintf(msg+strlen(msg), "suspicious, "); + } else { + sprintf(msg+strlen(msg),"- TOO OLD -, need at least libisofs-%d.%d.%d ,\n", + isoburn_libisofs_req_major, isoburn_libisofs_req_minor, + isoburn_libisofs_req_micro); + bad_match= 1; + } +#endif /* ! iso_lib_header_version_major */ + + if(!burn_initialize()) { + sprintf(msg+strlen(msg), "Cannot initialize libburn\n"); + return(0); + } + burn_version(&major, &minor, µ); + sprintf(msg+strlen(msg), "libburn-%d.%d.%d ", major, minor, micro); + if(major > burn_header_version_major + || (major == burn_header_version_major + && (minor > burn_header_version_minor + || (minor == burn_header_version_minor + && micro >= burn_header_version_micro)))) { + sprintf(msg+strlen(msg), "ok, "); + } else { + sprintf(msg+strlen(msg), "- TOO OLD -, need at least libburn-%d.%d.%d ,\n", + burn_header_version_major, burn_header_version_minor, + burn_header_version_micro); + bad_match= 1; + } + + isoburn_version(&major, &minor, µ); + sprintf(msg+strlen(msg), "for libisoburn-%d.%d.%d", major, minor, micro); + if(bad_match) + return(0); + + isoburn_destroy_all(&isoburn_list_start, 0); /* isoburn_list_start= NULL */ + return(1); +} + + +/* API @since 0.1.0 */ +int isoburn_libisofs_req(int *major, int *minor, int *micro) +{ + *major= iso_lib_header_version_major; + *minor= iso_lib_header_version_minor; + *micro= iso_lib_header_version_micro; + return(1); +} + + +/* API @since 0.1.0 */ +int isoburn_libburn_req(int *major, int *minor, int *micro) +{ + *major= burn_header_version_major; + *minor= burn_header_version_minor; + *micro= burn_header_version_micro; + return(1); +} + + +/** Examine the media and sets appropriate emulation if needed. + @param flag bit0= pretent blank on overwriteable media +*/ +static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d, + int flag) +{ + int ret, lba, nwa; + struct burn_multi_caps *caps= NULL; + + ret= burn_disc_get_multi_caps(d, BURN_WRITE_NONE, &caps, 0); + if(ret<0) /* == 0 is read-only media, but it is too early to reject it here */ + goto ex; + ret= isoburn_new(o, 0); + if(ret<=0) + goto ex; + (*o)->drive= d; + +#ifdef Hardcoded_cd_rW + /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ + caps->start_adr= 0; + (*o)->fabricated_disc_status= BURN_DISC_APPENDABLE; +#endif + + if(caps->start_adr) { /* set emulation to overwriteable */ + (*o)->emulation_mode= 1; + + if(flag&1) { + (*o)->nwa= 0; + (*o)->fabricated_disc_status= BURN_DISC_BLANK; + } else { + ret= isoburn_start_emulation(*o, 0); + if(ret<=0) { + (*o)->emulation_mode= -1; + goto ex; + } + } + } else { + + /* >>> recognize unsuitable media (but allow read-only media) */; + +#ifdef Hardcoded_cd_rW + (*o)->nwa= Hardcoded_cd_rw_nwA; +#else + ret= burn_disc_track_lba_nwa(d, NULL, 0, &lba, &nwa); + if(ret>0) + (*o)->nwa= nwa; +#endif + + } + ret= 1; +ex: + if(caps!=NULL) + burn_disc_free_multi_caps(&caps); + return(ret); +} + + +/** + @param flag bit0= load + bit1= regard overwriteable media as blank + bit2= if the drive is a regular disk file: truncate it to + the write start address +*/ +int isoburn_drive_aquire(struct burn_drive_info *drive_infos[], + char *adr, int flag) +{ + int ret, conv_ret, drive_grabbed= 0; + char libburn_drive_adr[BURN_DRIVE_ADR_LEN]; + struct isoburn *o= NULL; + char msg[BURN_MSGS_MESSAGE_LEN+4096]; + + conv_ret= burn_drive_convert_fs_adr(adr, libburn_drive_adr); + if(conv_ret<=0) { + sprintf(msg, "Unsuitable drive address: '%s'\n",adr); + msg[BURN_MSGS_MESSAGE_LEN-1]= 0; + burn_msgs_submit(0x00060000, msg, 0, "FAILURE", NULL); + ret= 0; goto ex; + } + + ret= burn_drive_scan_and_grab(drive_infos, libburn_drive_adr, flag&1); + if(ret<=0) + goto ex; + drive_grabbed= 1; + ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive, !!(flag&2)); + if(ret<=0) + goto ex; + + if(flag&4) { + ret= isoburn_find_emulator(&o, (*drive_infos)[0].drive, 0); + if(ret>0 && o!=NULL) + o->truncate= 1; + } + + ret= 1; +ex: + if(ret<=0) { + if(drive_grabbed) + burn_drive_release((*drive_infos)[0].drive, 0); + isoburn_destroy(&o, 0); + } + return(ret); +} + + +int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], + char *adr, int load) +{ + int ret; + + ret= isoburn_drive_aquire(drive_infos, adr, !!load); + return(ret); +} + + +int isoburn_drive_grab(struct burn_drive *drive, int load) +{ + int ret; + struct isoburn *o= NULL; + + ret= burn_drive_grab(drive, load); + if(ret<=0) + goto ex; + ret= isoburn_welcome_media(&o, drive, 0); + if(ret<=0) + goto ex; + + ret= 1; +ex: + if(ret<=0) + isoburn_destroy(&o,0); + return(ret); +} + + +/** Retrieve media emulation and eventual isoburn emulator of drive. + @return -1 unsuitable media, 0 generic media, 1 emulated media. +*/ +int isoburn_find_emulator(struct isoburn **pt, + struct burn_drive *drive, int flag) +{ + int ret; + + ret= isoburn_find_by_drive(pt, drive, 0); + if(ret<=0) + return(0); + if((*pt)->emulation_mode==-1) { + burn_msgs_submit(0x00060000, + "Unsuitable drive and media state", 0, "FAILURE", NULL); + return(-1); + } + if((*pt)->emulation_mode==0) + return(0); + return(1); +} + + +enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, drive, 0); + if(ret<0) + return(BURN_DISC_UNSUITABLE); + if(o!=NULL) + if(o->fabricated_disc_status!=BURN_DISC_UNREADY) + return(o->fabricated_disc_status); + if(ret==0) + return(burn_disc_get_status(drive)); + + /* emulated status */ + if(o->emulation_mode==-1) + return(BURN_DISC_UNSUITABLE); + if(o->nwa>0) + return(BURN_DISC_APPENDABLE); + return(BURN_DISC_BLANK); +} + + +int isoburn_disc_erasable(struct burn_drive *d) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret>0) + if(o->emulation_mode==1) + return(1); + return burn_disc_erasable(d); +} + + +void isoburn_disc_erase(struct burn_drive *drive, int fast) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, drive, 0); + if(ret>0) { + if(o->emulation_mode==-1) { + /* To cause a negative reply with burn_drive_wrote_well() */ + burn_drive_cancel(drive); + return; + } + if(o->emulation_mode>0) { + ret= isoburn_invalidate_iso(o, 0); + if(ret<=0) + burn_drive_cancel(drive); + return; + } + } + burn_disc_erase(drive, fast); +} + + +off_t isoburn_disc_available_space(struct burn_drive *d, + struct burn_write_opts *opts) +{ + int ret; + struct isoburn *o; + struct burn_write_opts *eff_opts= NULL, *local_opts= NULL; + off_t avail; + + eff_opts= opts; + ret= isoburn_find_emulator(&o, d, 0); + if(ret>0 && o!=NULL) + if(o->emulation_mode!=0) { + local_opts= burn_write_opts_new(d); + eff_opts= local_opts; + burn_write_opts_set_start_byte(eff_opts, ((off_t) o->nwa) * (off_t) 2048); + } + avail= burn_disc_available_space(d, eff_opts); + if(local_opts!=NULL) + burn_write_opts_free(local_opts); + local_opts= NULL; + return(avail); +} + + +int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba) +{ + int ret; + struct isoburn *o; + +#ifdef Hardcoded_cd_rW + /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ + *start_lba= Hardcoded_cd_rw_c1; + return(1); +#endif + + if(isoburn_disc_get_status(d)!=BURN_DISC_APPENDABLE && + isoburn_disc_get_status(d)!=BURN_DISC_FULL) { + burn_msgs_submit(0x00060000, + "Media contains no recognizable data", 0, "SORRY",NULL); + return(0); + } + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(0); + if(ret>0) if(o->emulation_mode>0) { + *start_lba= 0; + return(1); + } + return(burn_disc_get_msc1(d, start_lba)); +} + + +int isoburn_disc_track_lba_nwa(struct burn_drive *d, + struct burn_write_opts *opts, + int trackno, int *lba, int *nwa) +{ + int ret; + struct isoburn *o; + +#ifdef Hardcoded_cd_rW + /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ + *lba= Hardcoded_cd_rw_c1; + *nwa= Hardcoded_cd_rw_nwA; + return(1); +#endif + + *nwa= *lba= 0; + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(0); + if(ret>0) if(o->emulation_mode>0) { + *lba= 0; + *nwa= o->nwa; + return(1); + } + if(burn_drive_get_drive_role(d) != 1) + return(1); + return(burn_disc_track_lba_nwa(d, opts, trackno, lba, nwa)); +} + + +void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc) +{ + int ret; + off_t nwa= 0; + struct isoburn *o; + struct burn_drive *drive; + char reasons[BURN_REASONS_LEN],msg[160+BURN_REASONS_LEN]; + char adr[BURN_DRIVE_ADR_LEN]; + enum burn_write_types write_type; + struct stat stbuf; + + drive= burn_write_opts_get_drive(opts); + ret= isoburn_find_emulator(&o, drive, 0); + if(ret<0) + return; + if(o!=NULL) { + o->wrote_well= -1; + if(o->emulation_mode!=0) { + burn_write_opts_set_multi(opts, 0); + if(o->emulation_mode>0 && o->nwa >= 0) { + burn_write_opts_set_start_byte(opts, ((off_t) o->nwa) * (off_t) 2048); + nwa= o->nwa; + } + } + } + + write_type= burn_write_opts_auto_write_type(opts, disc, reasons, 0); + if (write_type == BURN_WRITE_NONE) { + sprintf(msg, "Failed to find a suitable write mode:\n%s", reasons); + burn_msgs_submit(0x00060000, msg, 0, "FAILURE", NULL); + if(o!=NULL) + o->wrote_well= 0; + /* To cause a negative reply with burn_drive_wrote_well() */ + burn_drive_cancel(drive); + return; + } + +/* + sprintf(reasons, "%d", (int) write_type); + fprintf(stderr, "isoburn_EXPERIMENTAL: write_type = %s\n", + (write_type == BURN_WRITE_SAO ? "SAO" : + (write_type == BURN_WRITE_TAO ? "TAO" : reasons))); +*/ + +#ifdef Hardcoded_cd_rW + /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ + fprintf(stderr, "Setting write address to LBA %d\n", Hardcoded_cd_rw_nwA); + burn_write_opts_set_start_byte(opts, + ((off_t) Hardcoded_cd_rw_nwA) * (off_t) 2048); +#endif + + if(o->truncate) { + ret= burn_drive_get_drive_role(drive); + if(ret==2) { + ret= burn_drive_d_get_adr(drive, adr); + if(ret>0) { + ret= lstat(adr, &stbuf); + if(ret!=-1) + if(S_ISREG(stbuf.st_mode)) + truncate(adr, nwa * (off_t) 2048); + } + } + } + + burn_disc_write(opts, disc); +} + + +void isoburn_drive_release(struct burn_drive *drive, int eject) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, drive, 0); + if(ret<0) + return; + if(o!=NULL) { + isoburn_destroy(&o, 0); + } + burn_drive_release(drive, eject); +} + + +void isoburn_finish(void) +{ + isoburn_destroy_all(&isoburn_list_start, 0); + burn_finish(); + iso_finish(); +} + + +int isoburn_needs_emulation(struct burn_drive *drive) +{ + int ret; + struct isoburn *o; + enum burn_disc_status s; + + s= isoburn_disc_get_status(drive); + if(s!=BURN_DISC_BLANK && s!=BURN_DISC_APPENDABLE) + return(-1); + ret= isoburn_find_emulator(&o, drive, 0); + if(ret<0) + return(-1); + if(ret>0) + if(o->emulation_mode>0) + return(1); + return(0); +} + + +int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag) +{ + int ret; + struct burn_drive *drive = o->drive; + struct burn_multi_caps *caps= NULL; + + ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0); + if(ret<=0) + goto ex; + if(!caps->start_adr) { + burn_msgs_submit(0x00060000, + "Cannot set start byte address with this type of media", + 0, "FAILURE", NULL); + {ret= 0; goto ex;} + } + o->min_start_byte= value; + if(value % caps->start_alignment) + value+= caps->start_alignment - (value % caps->start_alignment); + o->nwa= value/2048; + /* If suitable for alignment, round up to full 16 sector addresses */ + if((o->nwa%16) && ((16*2048) % caps->start_alignment)==0 ) + o->nwa+= 16 - (o->nwa%16); + ret= 1; +ex: + if(caps!=NULL) + burn_disc_free_multi_caps(&caps); + return(ret); +} + + +int isoburn_get_min_start_byte(struct burn_drive *d, off_t *start_byte, + int flag) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + if(ret==0) + return(0); + *start_byte= o->min_start_byte; + if(o->min_start_byte<=0) + return(0); + return(1); +} + + +int isoburn_drive_wrote_well(struct burn_drive *d) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + if(o!=NULL) + if(o->wrote_well>=0) + return(o->wrote_well); + ret= burn_drive_wrote_well(d); + return ret; +} + + +int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes, + char **status_text) +{ + int ret; + struct isoburn *o; +#ifdef Libisoburn_no_fifO + size_t hsize= 0, hfree_bytes= 0; +#endif + + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + +#ifdef Libisoburn_no_fifO + if(o==NULL) + return(-1); + if(o->iso_source==NULL) + return(-1); + ret= iso_ring_buffer_get_status(o->iso_source, &hsize, &hfree_bytes); + if(hsize > 1024*1024*1024) + *size= 1024*1024*1024; + else + *size= hsize; + if(hfree_bytes > 1024*1024*1024) + *free_bytes= 1024*1024*1024; + else + *free_bytes= hfree_bytes; + *status_text= ""; + if(ret==0) + *status_text= "standby"; + else if(ret==1) + *status_text= "active"; + else if(ret==2) + *status_text= "ending"; + else if(ret==3) + *status_text= "failing"; + else if(ret==4) + *status_text= "unused"; + else if(ret==5) + *status_text= "abandoned"; + else if(ret==6) + *status_text= "ended"; + else if(ret==7) + *status_text= "aborted"; +#else + if(o==NULL) + return(0); + if(o->fifo==NULL) + return(0); + ret= burn_fifo_inquire_status(o->fifo, size, free_bytes, status_text); +#endif /* ! Libisoburn_no_fifO */ + + return(ret); +} + + +#define Libisoburn_on_libisofs_after_0_6_2 yes + +/* >>> todo: throw out the copies of libdax_msgs entrails */ + +/* <<< to be replaced by libburn-0.4.3 API call burn_sev_to_text(). + This is a copy of libdax_msgs__sev_to_text() which is not exposed + by the API of of libburn-0.4.2 . As soon as xorriso gets based on + libburn-0.4.4 this redundancy is to be removed. + It is safe, nevertheless, because the severity codes are eternal. +*/ +#define LIBDAX_MSGS_SEV_ALL 0x00000000 +#define LIBDAX_MSGS_SEV_ERRFILE 0x08000000 +#define LIBDAX_MSGS_SEV_DEBUG 0x10000000 +#define LIBDAX_MSGS_SEV_UPDATE 0x20000000 +#define LIBDAX_MSGS_SEV_NOTE 0x30000000 +#define LIBDAX_MSGS_SEV_HINT 0x40000000 +#define LIBDAX_MSGS_SEV_WARNING 0x50000000 +#define LIBDAX_MSGS_SEV_SORRY 0x60000000 +#define LIBDAX_MSGS_SEV_MISHAP 0x64000000 +#define LIBDAX_MSGS_SEV_FAILURE 0x68000000 +#define LIBDAX_MSGS_SEV_FATAL 0x70000000 +#define LIBDAX_MSGS_SEV_ABORT 0x71000000 +#define LIBDAX_MSGS_SEV_NEVER 0x7fffffff + +/* @param flag bit0= -reserved- + bit1= this is a libburn severity +*/ +int isoburn__sev_to_text(int severity, char **severity_name, + int flag) +{ +#ifdef Libisoburn_on_libisofs_after_0_6_2 + int ret; +#else +#ifdef Libisoburn_on__libburn_after_0_4_2 + int ret; +#endif +#endif + +#ifdef Libisoburn_on_libisofs_after_0_6_2 + ret= iso_sev_to_text(severity, severity_name); + if(ret>0) + return(ret); +#endif /* Libisoburn_on_libisofs_after_0_6_2 */ +#ifdef Libisoburn_on__libburn_after_0_4_2 + ret= burn_sev_to_text(severity, severity_name, 0); + if(ret>0) + return(ret); +#endif + + if(flag&1) { + *severity_name= "NEVER\nABORT\nFATAL\nFAILURE\nSORRY\nWARNING\nHINT\nNOTE\nUPDATE\nDEBUG\nERRFILE\nALL"; + return(1); + } + *severity_name= ""; + if(severity>=LIBDAX_MSGS_SEV_NEVER) + *severity_name= "NEVER"; + else if(severity>=LIBDAX_MSGS_SEV_ABORT) + *severity_name= "ABORT"; + else if(severity>=LIBDAX_MSGS_SEV_FATAL) + *severity_name= "FATAL"; + else if(severity>=LIBDAX_MSGS_SEV_FAILURE) + *severity_name= "FAILURE"; + else if(severity>=LIBDAX_MSGS_SEV_MISHAP) + *severity_name= "MISHAP"; + else if(severity>=LIBDAX_MSGS_SEV_SORRY) + *severity_name= "SORRY"; + else if(severity>=LIBDAX_MSGS_SEV_WARNING) + *severity_name= "WARNING"; + else if(severity>=LIBDAX_MSGS_SEV_HINT) + *severity_name= "HINT"; + else if(severity>=LIBDAX_MSGS_SEV_NOTE) + *severity_name= "NOTE"; + else if(severity>=LIBDAX_MSGS_SEV_UPDATE) + *severity_name= "UPDATE"; + else if(severity>=LIBDAX_MSGS_SEV_DEBUG) + *severity_name= "DEBUG"; + else if(severity>=LIBDAX_MSGS_SEV_ERRFILE) + *severity_name= "ERRFILE"; + else if(severity>=LIBDAX_MSGS_SEV_ALL) + *severity_name= "ALL"; + else { + *severity_name= ""; + return(0); + } + return(1); +} + + +int isoburn__text_to_sev(char *severity_name, int *severity_number, int flag) +{ + int ret= 1; + +#ifdef Libisoburn_on_libisofs_after_0_6_2 + ret= iso_text_to_sev(severity_name, severity_number); + if(ret>0) + return(ret); +#endif /* Libisoburn_on_libisofs_after_0_6_2 */ + +#ifndef Libisoburn_on__libburn_after_0_4_2 + if(severity_name[0]==0) + *severity_number= 0; + else if(strcmp(severity_name, "MISHAP")==0) + *severity_number= LIBDAX_MSGS_SEV_MISHAP; + else if(strcmp(severity_name, "ERRFILE")==0) + *severity_number= LIBDAX_MSGS_SEV_ERRFILE; + else +#endif /* ! Libisoburn_on__libburn_after_0_4_2 */ + + ret= burn_text_to_sev(severity_name, severity_number, 0); + return(ret); +} + + +int isoburn_report_iso_error(int iso_error_code, char msg_text[], int os_errno, + char min_severity[], int flag) +{ + int error_code, iso_sev, min_sev, ret; + char *sev_text_pt, *msg_text_pt= NULL; + + error_code= iso_error_get_code(iso_error_code); + if(error_code < 0x00030000 || error_code >= 0x00040000) + error_code= (error_code & 0xffff) | 0x00050000; + + if(iso_error_code<0) + msg_text_pt= (char *) iso_error_to_msg(iso_error_code); + if(msg_text_pt==NULL) + msg_text_pt= msg_text; + iso_sev= iso_error_get_severity(iso_error_code); + sev_text_pt= min_severity; + +#ifdef Libisoburn_on_libisofs_after_0_6_2 + + isoburn__text_to_sev(min_severity, &min_sev, 0); + if(min_sev < iso_sev) + isoburn__sev_to_text(iso_sev, &sev_text_pt, 0); + ret= iso_msgs_submit(error_code, msg_text_pt, os_errno, sev_text_pt, 0); + +#else + + burn_text_to_sev(min_severity, &min_sev, 0); + + /* <<< Tunnel MISHAP through libburn which knows no MISHAP + with libburn-0.4.4 this is not necessary */ + if(iso_sev==LIBDAX_MSGS_SEV_MISHAP) { + iso_sev= LIBDAX_MSGS_SEV_SORRY; + error_code= 0x0005ff73; + } else if(iso_sev==LIBDAX_MSGS_SEV_ERRFILE) { /* same with ERRFILE */ + iso_sev= LIBDAX_MSGS_SEV_DEBUG; + error_code= 0x00051001; + } + if(min_sev < iso_sev) + isoburn__sev_to_text(iso_sev, &sev_text_pt, 0); + ret= burn_msgs_submit(error_code, msg_text_pt, os_errno, sev_text_pt, NULL); + +#endif /* ! Libisoburn_on_libisofs_after_0_6_2 */ + + return(ret); +} + diff --git a/libisoburn/branches/ZeroOneFour/libisoburn/data_source.c b/libisoburn/branches/ZeroOneFour/libisoburn/data_source.c new file mode 100644 index 00000000..540385fb --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/libisoburn/data_source.c @@ -0,0 +1,353 @@ +/* + data source for libisoburn. + + Copyright 2007 Vreixo Formoso Lopes +*/ + +#include +#include + +#include + + +#ifndef Xorriso_standalonE + +#include + +#include + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" + +#endif /* Xorriso_standalonE */ + + +#include "isoburn.h" + + +/* Powers of 2 only ! Less than 16 makes not much sense. */ +#define Libisoburn_tile_blockS 32 + +/* Undef to get to older single tile version +*/ +#define Libisoburn_cache_tileS 32 + +/* Debugging only: This reports cache loads on stderr. +#define Libisoburn_read_cache_reporT 1 +*/ + + +/* Cached reading of image tree data */ + +#ifdef Libisoburn_cache_tileS + +/* Multi tile: 32 * 64 kB */ + +struct isoburn_cache_tile { + char cache_data[Libisoburn_tile_blockS * 2048]; + uint32_t cache_lba; + uint32_t last_error_lba; + uint32_t last_aligned_error_lba; + int cache_hits; + int age; +}; + +struct isoburn_cached_drive { + struct burn_drive *drive; + struct isoburn_cache_tile tiles[Libisoburn_cache_tileS]; + int current_age; +}; + +#define Libisoburn_max_agE 2000000000 + +static int ds_inc_age(struct isoburn_cached_drive *icd, int idx, int flag); + + +int ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer) +{ + int ret, i, oldest, oldest_age; + struct burn_drive *d; + off_t count; + uint32_t aligned_lba; + char msg[80]; + struct isoburn_cache_tile *tiles; + struct isoburn_cached_drive *icd; + + if(src == NULL || buffer == NULL) + return -1; + + icd = (struct isoburn_cached_drive *) src->data; + d = (struct burn_drive*) icd->drive; + tiles = (struct isoburn_cache_tile *) icd->tiles; + + aligned_lba= lba & ~(Libisoburn_tile_blockS - 1); + + for(i=0; i 0) + return 1; + tiles[oldest].last_error_lba = lba; + sprintf(msg, "ds_read_block(%lu) returns -1", (unsigned long) lba); + burn_msgs_submit(0x00060000, msg, 0, "DEBUG", NULL); + return -1; + } + +#ifdef Libisoburn_read_cache_reporT + fprintf(stderr, "Tile %2.2d : After %3d hits, new load from %8x , count= %d\n", + oldest, tiles[oldest].cache_hits, aligned_lba, (int) count); +#endif + + tiles[oldest].cache_lba= aligned_lba; + tiles[oldest].cache_hits= 1; + ds_inc_age(icd, oldest, 0); + + memcpy(buffer, tiles[oldest].cache_data + (lba - aligned_lba) * 2048, 2048); + count= 2048; + + return 1; +} + + +static int ds_open(IsoDataSource *src) +{ + /* nothing to do, device is always grabbed */ + return 1; +} + +static int ds_close(IsoDataSource *src) +{ + /* nothing to do, device is always grabbed */ + return 1; +} + +static void ds_free_data(IsoDataSource *src) +{ + /* nothing to do */; + if(src->data != NULL) + free(src->data); + src->data= NULL; +} + +IsoDataSource *isoburn_data_source_new(struct burn_drive *d) +{ + IsoDataSource *ret; + struct isoburn_cached_drive *icd= NULL; + int i; + + if (d==NULL) + return NULL; + ret = malloc(sizeof(IsoDataSource)); + icd = calloc(1,sizeof(struct isoburn_cached_drive)); + if (ret == NULL || icd == NULL) + return NULL; + ret->refcount = 1; + ret->read_block = ds_read_block; + ret->open = ds_open; + ret->close = ds_close; + ret->free_data = ds_free_data; + ret->data = icd; + icd->drive = d; + icd->current_age= 0; + for(i= 0; itiles[i].cache_lba = 0xffffffff; + icd->tiles[i].cache_hits = 0; + icd->tiles[i].last_error_lba = 0xffffffff; + icd->tiles[i].last_aligned_error_lba = 0xffffffff; + icd->tiles[i].age= 0; + } + return ret; +} + + +static int ds_inc_age(struct isoburn_cached_drive *icd, int idx, int flag) +{ + int i; + + (icd->current_age)++; + if(icd->current_age>=Libisoburn_max_agE) { /* reset all ages (allow waste) */ + for(i= 0; itiles)[i].age= 0; + icd->current_age= 1; + } + (icd->tiles)[idx].age= icd->current_age; + return(1); +} + + +#else /* Libisoburn_cache_tileS */ + + +/* Single tile 128 kB */ + + +struct isoburn_cached_drive { + struct burn_drive *drive; + + char cache_data[Libisoburn_tile_blockS * 2048]; + uint32_t cache_lba; + uint32_t last_error_lba; + uint32_t last_aligned_error_lba; + int cache_hits; +}; + + +/* Debugging only: This reports cache loads on stderr. +#define Libisoburn_read_cache_reporT 1 +*/ + +int +ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer) +{ + int ret; + struct burn_drive *d; + off_t count; + uint32_t aligned_lba; + char msg[80]; + + struct isoburn_cached_drive *icd; + + if(src == NULL || buffer == NULL) + return -1; + + icd = (struct isoburn_cached_drive *) src->data; + d = (struct burn_drive*) icd->drive; + + aligned_lba= lba & ~(Libisoburn_tile_blockS - 1); + if(aligned_lba == icd->cache_lba && icd->cache_lba != 0xffffffff) { + (icd->cache_hits)++; + memcpy(buffer, icd->cache_data + (lba - aligned_lba) * 2048, 2048); + count= 2048; + return 1; + } + + icd->cache_lba= 0xffffffff; /* invalidate cache */ + if(icd->last_aligned_error_lba == aligned_lba) { + ret = 0; + } else { + ret = burn_read_data(d, (off_t) aligned_lba * (off_t) 2048, + (char *) icd->cache_data, + Libisoburn_tile_blockS * 2048, &count, 0); + } + if (ret <= 0 ) { + icd->last_aligned_error_lba = aligned_lba; + + /* Read-ahead failure ? Try to read 2048 directly. */ + if(icd->last_error_lba == lba) + ret = 0; + else + ret = burn_read_data(d, (off_t) lba * (off_t) 2048, (char *) buffer, + 2048, &count, 0); + if (ret > 0) + return 1; + icd->last_error_lba = lba; + sprintf(msg, "ds_read_block(%lu) returns -1", (unsigned long) lba); + burn_msgs_submit(0x00060000, msg, 0, "DEBUG", NULL); + return -1; + } + +#ifdef Libisoburn_read_cache_reporT + fprintf(stderr, "After %3d hits, new load from %8x , count= %d\n", + icd->cache_hits, aligned_lba, (int) count); +#endif + + icd->cache_lba= aligned_lba; + icd->cache_hits= 1; + memcpy(buffer, icd->cache_data + (lba - aligned_lba) * 2048, 2048); + count= 2048; + + return 1; +} + + +static int +ds_open(IsoDataSource *src) +{ + /* nothing to do, device is always grabbed */ + return 1; +} + +static int +ds_close(IsoDataSource *src) +{ + /* nothing to do, device is always grabbed */ + return 1; +} + +static void +ds_free_data(IsoDataSource *src) +{ + /* nothing to do */; + if(src->data != NULL) + free(src->data); + src->data= NULL; +} + +IsoDataSource * +isoburn_data_source_new(struct burn_drive *d) +{ + IsoDataSource *ret; + struct isoburn_cached_drive *icd= NULL; + + if (d==NULL) + return NULL; + ret = malloc(sizeof(IsoDataSource)); + icd = calloc(1,sizeof(struct isoburn_cached_drive)); + if (ret == NULL || icd == NULL) + return NULL; + ret->refcount = 1; + ret->read_block = ds_read_block; + ret->open = ds_open; + ret->close = ds_close; + ret->free_data = ds_free_data; + ret->data = icd; + icd->drive = d; + icd->cache_lba = 0xffffffff; + icd->cache_hits = 0; + icd->last_error_lba = 0xffffffff; + icd->last_aligned_error_lba = 0xffffffff; + return ret; +} + +#endif /* ! Libisoburn_cache_tileS */ + diff --git a/libisoburn/branches/ZeroOneFour/libisoburn/isoburn.c b/libisoburn/branches/ZeroOneFour/libisoburn/isoburn.c new file mode 100644 index 00000000..3af7a1f6 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/libisoburn/isoburn.c @@ -0,0 +1,849 @@ + +/* + cc -g -c isoburn.c +*/ + +/* + Class core of libisoburn. + + Copyright 2007 Vreixo Formoso Lopes + and Thomas Schmitt +*/ + +/* ( derived from stub generated by CgeN on Sat, 01 Sep 2007 12:04:36 GMT ) */ + +#include +#include +#include +#include +#include +#include + +#ifndef Xorriso_standalonE + +#include + +#include + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" + +#endif /* Xorriso_standalonE */ + + +#include "libisoburn.h" + +#include "isoburn.h" + +/* No more: version numbers out of configure.ac + major.minor.micro now comes from libisoburn.h +#include "../version.h" +*/ + +/* -------------------------- isoburn ----------------------- */ + + +/* The global list of isoburn objects. Usually there is only one. + >>> we are not ready for multiple control threads yet. See >>> mutex . + Multiple burns under one control thread should work. +*/ +struct isoburn *isoburn_list_start= NULL; + + +int isoburn_new(struct isoburn **objpt, int flag) +{ + struct isoburn *o; + int i, ret; + + *objpt= o= (struct isoburn *) malloc(sizeof(struct isoburn)); + if(o==NULL) { + burn_msgs_submit(0x00060000, + "Cannot allocate memory for isoburn control object", + 0, "FATAL", NULL); + return(-1); + } + + o->drive= NULL; + o->emulation_mode= 0; + o->min_start_byte= 0; + o->nwa= 0; + o->truncate= 0; + +#ifdef Libisoburn_no_fifO + o->iso_source= NULL; +#else + o->fifo= NULL; +#endif + + o->wrote_well= -1; + o->fabricated_disc_status= BURN_DISC_UNREADY; + for(i=0;i<65536;i++) + o->target_iso_head[i]= 0; + o->image= NULL; + o->read_pacifier= NULL; + o->read_pacifier_handle= NULL; + o->prev= NULL; + o->next= NULL; + ret= iso_image_new("ISOIMAGE", &o->image); + if(ret<0) { + isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0); + goto failed; + } + isoburn_link(o, isoburn_list_start, 1); + return(1); +failed:; + isoburn_destroy(objpt, 0); + return(-1); +} + + +int isoburn_destroy(struct isoburn **objpt, int flag) +{ + struct isoburn *o; + + o= *objpt; + if(o==NULL) + return(0); + + /* >>> mutex */ + + if(o==isoburn_list_start) + isoburn_list_start= o->next; + if(o->prev!=NULL) + o->prev->next= o->next; + if(o->next!=NULL) + o->next->prev= o->prev; + + /* >>> end mutex */ + + if(o->image!=NULL) + iso_image_unref(o->image); + +#ifdef Libisoburn_no_fifO + if(o->iso_source!=NULL) + burn_source_free(o->iso_source); +#else + if(o->fifo!=NULL) + burn_source_free(o->fifo); +#endif /* ! Libisoburn_no_fifO */ + + + free((char *) o); + *objpt= NULL; + return(1); +} + + +int isoburn_destroy_all(struct isoburn **objpt, int flag) +{ + struct isoburn *o,*n; + + o= *objpt; + if(o==NULL) + return(0); + for(;o->prev!=NULL;o= o->prev); + for(;o!=NULL;o= n) { + n= o->next; + isoburn_destroy(&o,0); + } + *objpt= NULL; + return(1); +} + + +int isoburn_get_target_image(struct isoburn *o, IsoImage **pt, int flag) +{ + *pt= o->image; + return(1); +} + + +int isoburn_get_prev(struct isoburn *o, struct isoburn **pt, int flag) +{ + *pt= o->prev; + return(1); +} + + +int isoburn_get_next(struct isoburn *o, struct isoburn **pt, int flag) +{ + *pt= o->next; + return(1); +} + + +int isoburn_link(struct isoburn *o, struct isoburn *link, int flag) +/* + bit0= insert as link->prev rather than as link->next +*/ +{ + + /* >>> mutex */ + + if(isoburn_list_start==NULL || + (isoburn_list_start==link && (flag&1))) + isoburn_list_start= o; + if(o->prev!=NULL) + o->prev->next= o->next; + if(o->next!=NULL) + o->next->prev= o->prev; + o->prev= o->next= NULL; + if(link==NULL) + return(1); + if(flag&1) { + o->next= link; + o->prev= link->prev; + if(o->prev!=NULL) + o->prev->next= o; + link->prev= o; + } else { + o->prev= link; + o->next= link->next; + if(o->next!=NULL) + o->next->prev= o; + link->next= o; + } + + /* >>> end mutex */ + + return(1); +} + + +int isoburn_count(struct isoburn *o, int flag) +/* flag: bit1= count from start of list */ +{ + int counter= 0; + + if(flag&2) + for(;o->prev!=NULL;o= o->prev); + for(;o!=NULL;o= o->next) + counter++; + return(counter); +} + + +int isoburn_by_idx(struct isoburn *o, int idx, struct isoburn **pt, int flag) +/* flag: bit0= fetch first (idx<0) or last (idx>0) item in list + bit1= address from start of list */ +{ + int i,abs_idx; + struct isoburn *npt; + + if(flag&2) + for(;o->prev!=NULL;o= o->prev); + abs_idx= (idx>0?idx:-idx); + *pt= o; + for(i= 0;(i0) + npt= o->next; + else + npt= o->prev; + if(npt==NULL && (flag&1)) + break; + *pt= npt; + } + return(*pt!=NULL); +} + + +int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag) +{ + struct isoburn *o; + + *pt= NULL; + for(o= isoburn_list_start;o!=NULL;o= o->next) + if(o->drive==d) { + *pt= o; + return(1); + } + return(0); +} + +static +int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc, + struct isoburn_imgen_opts *opts, int new_img) +{ + struct burn_source *wsrc; + struct burn_session *session; + struct burn_track *track; + struct isoburn *o; + IsoWriteOpts *wopts= NULL; + enum burn_disc_status state; + int ret, fifo_chunks; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0 || o==NULL) + {ret= -1; goto ex;} + o->wrote_well= 0; /* early end will be registered as failure */ + + state = isoburn_disc_get_status(d); + if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE + && (state != BURN_DISC_FULL || ! new_img)) { + /* unsuitable status */ + burn_msgs_submit(0x00060000, "Unsuitable media state", 0, "FAILURE", NULL); + {ret= -2; goto ex;} + } + + fifo_chunks= 32; + if(opts->fifo_size >= 64*1024 && opts->fifo_size <= 1024.0 * 1024.0 * 1024.0){ + fifo_chunks= opts->fifo_size/2048; + if(fifo_chunks*2048 < opts->fifo_size) + fifo_chunks++; + } + + ret = iso_write_opts_new(&wopts, 0); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create iso_write_opts", 0, "FATAL",0); + goto ex; + } + iso_write_opts_set_iso_level(wopts, opts->level); + iso_write_opts_set_rockridge(wopts, opts->rockridge); + iso_write_opts_set_joliet(wopts, opts->joliet); + iso_write_opts_set_iso1999(wopts, opts->iso1999); + iso_write_opts_set_omit_version_numbers(wopts, opts->omit_version_numbers); + iso_write_opts_set_allow_deep_paths(wopts, opts->allow_deep_paths); + iso_write_opts_set_allow_longer_paths(wopts, opts->allow_longer_paths); + iso_write_opts_set_max_37_char_filenames(wopts, opts->max_37_char_filenames); + iso_write_opts_set_no_force_dots(wopts, opts->no_force_dots); + iso_write_opts_set_allow_lowercase(wopts, opts->allow_lowercase); + iso_write_opts_set_allow_full_ascii(wopts, opts->allow_full_ascii); + iso_write_opts_set_relaxed_vol_atts(wopts, 1); + iso_write_opts_set_joliet_longer_paths(wopts, opts->joliet_longer_paths); + iso_write_opts_set_sort_files(wopts, opts->sort_files); + iso_write_opts_set_replace_mode(wopts, opts->replace_dir_mode, + opts->replace_file_mode, opts->replace_uid, opts->replace_gid); + iso_write_opts_set_default_dir_mode(wopts, opts->dir_mode); + iso_write_opts_set_default_file_mode(wopts, opts->file_mode); + iso_write_opts_set_default_uid(wopts, opts->uid); + iso_write_opts_set_default_gid(wopts, opts->gid); + iso_write_opts_set_output_charset(wopts, opts->output_charset); +#ifdef Libisoburn_no_fifO + iso_write_opts_set_fifo_size(wopts, fifo_chunks); +#endif /* Libisoburn_no_fifO */ + + if (new_img) { + iso_write_opts_set_ms_block(wopts, 0); + opts->effective_lba= 0; + iso_write_opts_set_appendable(wopts, 0); + iso_write_opts_set_overwrite_buf(wopts, NULL); + } else { + int lba, nwa; + ret = isoburn_disc_track_lba_nwa(d, NULL, 0, &lba, &nwa); + if (ret != 1) { + burn_msgs_submit(0x00060000, "Cannot determine next writeable address", 0, + "FAILURE", NULL); + {ret= -3; goto ex;} + } + if (nwa == 0 && state == BURN_DISC_APPENDABLE) { + /* invalid nwa */ + burn_msgs_submit(0x00060000, "Encountered 0 as next writeable address", 0, + "FAILURE", NULL); + {ret= -4; goto ex;} + } + iso_write_opts_set_ms_block(wopts, nwa); + opts->effective_lba= nwa; + iso_write_opts_set_appendable(wopts, 1); + iso_write_opts_set_overwrite_buf(wopts, o->target_iso_head); + } + + ret = iso_image_create_burn_source(o->image, wopts, &wsrc); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create burn source", 0, "FAILURE", 0); + {ret= -1; goto ex;} + } + + /* TODO check return values for failure. propertly clean-up on error */ + +#ifdef Libisoburn_no_fifO + o->iso_source= wsrc; +#else + o->fifo = burn_fifo_source_new(wsrc, 2048, fifo_chunks, 0); + burn_source_free(wsrc); + if (o->fifo == NULL) { + burn_msgs_submit(0x00060000, "Cannot attach fifo", 0, "FATAL", NULL); + {ret= -1; goto ex;} + } +#endif /* ! Libisoburn_no_fifO */ + + *disc = burn_disc_create(); + session = burn_session_create(); + burn_disc_add_session(*disc, session, BURN_POS_END); + track = burn_track_create(); + +#ifdef Libisoburn_no_fifO + burn_track_set_source(track, o->iso_source); +#else + burn_track_set_source(track, o->fifo); +#endif /* ! Libisoburn_no_fifO */ + + burn_session_add_track(session, track, BURN_POS_END); + + /* give up local references */ + burn_track_free(track); + burn_session_free(session); + + o->wrote_well= -1; /* neutral */ + ret= 1; +ex: + if(wopts!=NULL) + {iso_write_opts_free(wopts); wopts= NULL;} + return ret; +} + +int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc, + struct isoburn_imgen_opts *opts) +{ + return isoburn_prepare_disc_aux(d, disc, opts, 0); +} + +int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc, + struct isoburn_imgen_opts *opts, + struct burn_drive *out_drive) +{ + int ret; + struct isoburn *in_o, *out_o; + + ret= isoburn_prepare_disc_aux(d, disc, opts, 1); + if (ret<=0) + return ret; + +#ifdef Libisoburn_no_fifO + /* Hand over source reference for optional fifo status inquiry */ + if(out_drive==NULL) + return 1; + ret= isoburn_find_emulator(&out_o, out_drive, 0); + if(ret<0 || out_o==NULL) + return 1; + ret= isoburn_find_emulator(&in_o, d, 0); + if(ret<0 || in_o==NULL) + return 1; /* then without fifo status inquiry */ + if(out_o->iso_source!=NULL) + burn_source_free(out_o->iso_source); + out_o->iso_source= in_o->iso_source; + in_o->iso_source= NULL; +#endif /* Libisoburn_no_fifO */ + + return 1; +} + + +/* API @since 0.1.0 + @param flag bit0= this is a regular end, not an abort + give up source reference +*/ +int isoburn_cancel_prepared_write(struct burn_drive *d, + struct burn_drive *output_drive, int flag) +{ + int ret; + struct isoburn *o= NULL; + + if(output_drive!=NULL) { + ret= isoburn_find_emulator(&o, output_drive, 0); + if(ret<0 || o==NULL) + o= NULL; + else if(o->iso_source==NULL) + o= NULL; + } + if(o==NULL) { + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + if(o==NULL) + return(0); + if(o->iso_source==NULL) + return(0); + } + if(o->iso_source->read!=NULL) + return(0); + if(o->iso_source->version<1) + return(0); + o->iso_source->cancel(o->iso_source); + burn_source_free(o->iso_source); + o->iso_source= NULL; + return(1); +} + + +/* API @since 0.1.0 */ +int isoburn_sync_after_write(struct burn_drive *d, + struct burn_drive *output_drive, int flag) +{ + return isoburn_cancel_prepared_write(d, output_drive, 1); +} + + +void isoburn_version(int *major, int *minor, int *micro) +{ + *major= isoburn_header_version_major; + *minor= isoburn_header_version_minor; + *micro= isoburn_header_version_micro; + +/* No more: values from version.h generated from version.h.in and + macro values defined in configure.ac + + *major = ISOBURN_MAJOR_VERSION; + *minor = ISOBURN_MINOR_VERSION; + *micro = ISOBURN_MICRO_VERSION; +*/ +} + + +int isoburn_is_compatible(int major, int minor, int micro, int flag) +{ + int own_major, own_minor, own_micro; + + isoburn_version(&own_major, &own_minor, &own_micro); + return(own_major > major || + (own_major == major && (own_minor > minor || + (own_minor == minor && own_micro >= micro)))); +} + + +/* ----------------------------------------------------------------------- */ +/* + Options for image reading. +*/ +/* ----------------------------------------------------------------------- */ + + +int isoburn_ropt_new(struct isoburn_read_opts **new_o, int flag) +{ + struct isoburn_read_opts *o; + + o= (*new_o)= calloc(1, sizeof(struct isoburn_read_opts)); + if(o==NULL) { + burn_msgs_submit(0x00060000, "Cannot allocate memory for read options", + 0, "FATAL", NULL); + return(-1); + } + o->norock= 0; + o->nojoliet= 0; + o->noiso1999= 1; + o->preferjoliet= 0; + o->uid= geteuid(); + o->gid= getegid(); + o->mode= 0444; + o->dirmode= 0555; + o->input_charset= NULL; + o->hasRR= 0; + o->hasJoliet= 0; + o->hasIso1999= 0; + o->hasElTorito= 0; + o->size= 0; + o->pretend_blank= 1; + return(1); +} + + +int isoburn_ropt_destroy(struct isoburn_read_opts **o, int flag) +{ + if(*o==NULL) + return(0); + free(*o); + *o= NULL; + return(1); +} + + +int isoburn_ropt_set_extensions(struct isoburn_read_opts *o, int ext) +{ + o->norock= !!(ext&1); + o->nojoliet= !!(ext&2); + o->noiso1999= !!(ext&4); + o->preferjoliet= !!(ext&8); + o->pretend_blank= !!(ext&16); + return(1); +} + + +int isoburn_ropt_get_extensions(struct isoburn_read_opts *o, int *ext) +{ + *ext= (!!o->norock) | ((!!o->nojoliet)<<1) | ((!!o->noiso1999)<<2) | + ((!!o->preferjoliet)<<3) | ((!!o->pretend_blank)<<4); + return(1); +} + + +int isoburn_ropt_set_default_perms(struct isoburn_read_opts *o, + uid_t uid, gid_t gid, mode_t mode) +{ + mode_t dirmode; + + o->uid= uid; + o->gid= gid; + o->mode= mode; + dirmode= mode; + if(dirmode & S_IRUSR) + dirmode|= S_IXUSR; + if(dirmode & S_IRGRP) + dirmode|= S_IXGRP; + if(dirmode & S_IROTH) + dirmode|= S_IXOTH; + o->dirmode= dirmode; + return(1); +} + + +int isoburn_ropt_get_default_perms(struct isoburn_read_opts *o, + uid_t *uid, gid_t *gid, mode_t *mode) +{ + *uid= o->uid; + *gid= o->gid; + *mode= o->mode; + return(1); +} + + +int isoburn_ropt_set_default_dirperms(struct isoburn_read_opts *o, + mode_t mode) +{ + o->dirmode= mode; + return(1); +} + + +int isoburn_ropt_get_default_dirperms(struct isoburn_read_opts *o, + mode_t *mode) +{ + *mode= o->dirmode; + return(1); +} + + +int isoburn_ropt_set_input_charset(struct isoburn_read_opts *o, + char *input_charset) +{ + o->input_charset= input_charset; + return(1); +} + + +int isoburn_igopt_get_in_charset(struct isoburn_read_opts *o, + char **input_charset) +{ + *input_charset= o->input_charset; + return(1); +} + + +int isoburn_ropt_get_size_what(struct isoburn_read_opts *o, + uint32_t *size, int *has_what) +{ + *size= o->size; + *has_what= (!!o->hasRR) | ((!!o->hasJoliet)<<1) | + ((!!o->hasIso1999)<<2) | ((!!o->hasElTorito)<<3); + return(1); +} + + +/* ----------------------------------------------------------------------- */ +/* + Options for image generation by libisofs and image transport to libburn. +*/ +/* ----------------------------------------------------------------------- */ + + +int isoburn_igopt_new(struct isoburn_imgen_opts **new_o, int flag) +{ + struct isoburn_imgen_opts *o; + + o= (*new_o)= calloc(1, sizeof(struct isoburn_imgen_opts)); + if(o==NULL) { + burn_msgs_submit(0x00060000, + "Cannot allocate memory for image generation options", + 0, "FATAL", NULL); + return(-1); + } + o->level= 2; + o->rockridge= 1; + o->joliet= 0; + o->iso1999= 0; + o->omit_version_numbers= 0; + o->allow_deep_paths= 1; + o->allow_longer_paths= 0; + o->max_37_char_filenames= 0; + o->no_force_dots= 0; + o->allow_lowercase= 0; + o->allow_full_ascii= 0; + o->joliet_longer_paths= 0; + o->sort_files= 0; + o->replace_dir_mode= 0; + o->replace_file_mode= 0; + o->replace_uid= 0; + o->replace_gid= 0; + o->dir_mode= 0555; + o->file_mode= 0444; + o->uid= 0; + o->gid= 0; + o->output_charset= 0; + o->fifo_size= 4*1024*1024; + o->effective_lba= -1; + return(1); +} + + +int isoburn_igopt_destroy(struct isoburn_imgen_opts **o, int flag) +{ + if(*o==NULL) + return(0); + free(*o); + *o= NULL; + return(1); +} + + +int isoburn_igopt_set_level(struct isoburn_imgen_opts *o, int level) +{ + o->level= level; + return(1); +} + + +int isoburn_igopt_get_level(struct isoburn_imgen_opts *o, int *level) +{ + *level= o->level; + return(1); +} + + +int isoburn_igopt_set_extensions(struct isoburn_imgen_opts *o, int ext) +{ + o->rockridge= !!(ext&1); + o->joliet= !!(ext&2); + o->iso1999= !!(ext&4); + return(1); +} + + +int isoburn_igopt_get_extensions(struct isoburn_imgen_opts *o, int *ext) +{ + *ext= (!!o->rockridge) | ((!!o->joliet)<<1) | ((!!o->iso1999)<<2); + return(1); +} + + +int isoburn_igopt_set_relaxed(struct isoburn_imgen_opts *o, int relax) +{ + o->omit_version_numbers= !!(relax&1); + o->allow_deep_paths= !!(relax&2); + o->allow_longer_paths= !!(relax&4); + o->max_37_char_filenames= !!(relax&8); + o->no_force_dots= !!(relax&16); + o->allow_lowercase= !!(relax&32); + o->allow_full_ascii= !!(relax&64); + o->joliet_longer_paths= !!(relax&128); + return(1); +} + + +int isoburn_igopt_get_relaxed(struct isoburn_imgen_opts *o, int *relax) +{ + *relax= (!!o->omit_version_numbers) | ((!!o->allow_deep_paths)<<1) | + ((!!o->allow_longer_paths)<<2) | ((!!o->max_37_char_filenames)<<3) | + ((!!o->no_force_dots)<<4) | ((!!o->allow_lowercase)<<5) | + ((!!o->allow_full_ascii)<<6) | ((!!o->joliet_longer_paths)<<7); + return(1); +} + + +int isoburn_igopt_set_sort_files(struct isoburn_imgen_opts *o, int value) +{ + o->sort_files= !!(value&1); + return(1); +} + + +int isoburn_igopt_get_sort_files(struct isoburn_imgen_opts *o, int *value) +{ + *value= !!o->sort_files; + return(1); +} + + +int isoburn_igopt_set_over_mode(struct isoburn_imgen_opts *o, + int replace_dir_mode, int replace_file_mode, + mode_t dir_mode, mode_t file_mode) +{ + o->replace_dir_mode= replace_dir_mode%3; + o->replace_file_mode= replace_file_mode%3; + o->dir_mode= dir_mode; + o->file_mode= file_mode; + return(1); +} + + +int isoburn_igopt_get_over_mode(struct isoburn_imgen_opts *o, + int *replace_dir_mode, int *replace_file_mode, + mode_t *dir_mode, mode_t *file_mode) +{ + *replace_dir_mode= o->replace_dir_mode%3; + *replace_file_mode= o->replace_file_mode%3; + *dir_mode= o->dir_mode; + *file_mode= o->file_mode; + return(1); +} + + +int isoburn_igopt_set_over_ugid(struct isoburn_imgen_opts *o, + int replace_uid, int replace_gid, + uid_t uid, gid_t gid) +{ + o->replace_uid= replace_uid%3; + o->replace_gid= replace_gid%3; + o->uid= uid; + o->gid= gid; + return(1); +} + +int isoburn_igopt_get_over_ugid(struct isoburn_imgen_opts *o, + int *replace_uid, int *replace_gid, + uid_t *uid, gid_t *gid) +{ + *replace_uid= o->replace_uid%3; + *replace_gid= o->replace_gid%3; + *uid= o->uid; + *gid= o->gid; + return(1); +} + + +int isoburn_igopt_set_out_charset(struct isoburn_imgen_opts *o, + char *output_charset) +{ + o->output_charset= output_charset; + return(1); +} + + +int isoburn_igopt_get_out_charset(struct isoburn_imgen_opts *o, + char **output_charset) +{ + *output_charset= o->output_charset; + return(1); +} + + +int isoburn_igopt_set_fifo_size(struct isoburn_imgen_opts *o, int fifo_size) +{ + o->fifo_size= fifo_size; + return(1); +} + + +int isoburn_igopt_get_fifo_size(struct isoburn_imgen_opts *o, int *fifo_size) +{ + *fifo_size= o->fifo_size; + return(1); +} + + +int isoburn_igopt_get_effective_lba(struct isoburn_imgen_opts *o, int *lba) +{ + *lba= o->effective_lba; + return(1); +} + + diff --git a/libisoburn/branches/ZeroOneFour/libisoburn/isoburn.h b/libisoburn/branches/ZeroOneFour/libisoburn/isoburn.h new file mode 100644 index 00000000..e22ee55c --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/libisoburn/isoburn.h @@ -0,0 +1,332 @@ + +/* + Class struct of libisoburn. + + Copyright 2007 Vreixo Formoso Lopes + and Thomas Schmitt +*/ + +#ifndef Isoburn_includeD +#define Isoburn_includeD + + +/* <<< transition macro */ +#define Libisoburn_no_fifO 1 + + +/* for uint8_t */ +#include + + +struct isoburn { + + + /* The libburn drive to which this isoburn object is related + Most isoburn calls will use a burn_drive as object handle */ + struct burn_drive *drive; + + /* -1= inappropriate media state detected + 0= libburn multi-session media, resp. undecided yet + 1= random access media */ + int emulation_mode; + + /* Although rarely used, libburn can operate on several + drives simultaneously. */ + struct isoburn *prev; + struct isoburn *next; + + + /* Start address as given by image examination (bytes, not blocks) */ + off_t min_start_byte; + + /* Aligned start address to be used for processing (counted in blocks) */ + int nwa; + + /* Truncate to .nwa an eventual regular file serving as output drive */ + int truncate; + + /* Eventual freely fabricated isoburn_disc_get_status(). + BURN_DISC_UNREADY means that this variable is disabled + and normally emulated status is in effect. + */ + enum burn_disc_status fabricated_disc_status; + +#ifndef Libisoburn_no_fifO + /* The fifo which is installed between track and libisofs burn_source + */ + struct burn_source *fifo; +#endif /* ! Libisoburn_no_fifO */ + + /* Indicator wether the most recent burn run worked : + -1 = undetermined, ask libburn , 0 = failure , 1 = success + To be inquired by isoburn_drive_wrote_well() + */ + int wrote_well; + + + /* Buffered ISO head from media (should that become part of + ecma119_read_opts ?) */ + uint8_t target_iso_head[65536]; + + /* Libisofs image context */ + IsoImage *image; + +#ifdef Libisoburn_no_fifO + /* The burn source which transfers data from libisofs to libburn. + It has its own fifo. + */ + struct burn_source *iso_source; +#endif /* Libisoburn_no_fifO */ + + /* For iso_tree_set_report_callback() */ + int (*read_pacifier)(IsoImage*, IsoFileSource*); + + /* For iso_image_attach_data() */ + void *read_pacifier_handle; + +}; + + +/* Creation and disposal function */ +int isoburn_new(struct isoburn **objpt, int flag); +int isoburn_destroy(struct isoburn **objpt, int flag); + +/* Eventual readers for public attributes */ +/* ( put into separate .h file then ) */ +int isoburn_get_emulation_mode(struct isoburn *o, int *pt, int flag); +int isoburn_get_target_volset(struct isoburn *o, IsoImage **pt, int flag); + +/* List management */ +int isoburn_get_prev(struct isoburn *o, struct isoburn **pt, int flag); +int isoburn_get_next(struct isoburn *o, struct isoburn **pt, int flag); +int isoburn_destroy_all(struct isoburn **objpt, int flag); +int isoburn_link(struct isoburn *o, struct isoburn *link, int flag); +int isoburn_count(struct isoburn *o, int flag); +int isoburn_by_idx(struct isoburn *o, int idx, struct isoburn **pt, int flag); +int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag); + + +/* Non API inner interfaces */ + +/* Submit a libisofs error to the libburn messenger. An application message + reader shall recognize the error code range and attribute it to the + libisofs message channel to which one cannot submit via API. + @param iso_error_code return value <= 0 from a libisofs API call. + @param default_msg_text is to be put out if iso_error_code leads to no + error message + @param os_errno operating system errno, submit 0 if none is known + @param min_severity minimum severity, might be be increased if libisofs + error severity surpasses min_severity. + @param flag Bitfield, submit 0 for now +*/ +int isoburn_report_iso_error(int iso_error_code, char default_msg_text[], + int os_errno, char min_severity[], int flag); + +/* Calls from burn_wrap.c into isofs_wrap.c */ + +int isoburn_start_emulation(struct isoburn *o, int flag); +int isoburn_invalidate_iso(struct isoburn *o, int flag); + + +/* Calls from isofs_wrap.c into burn_wrap.c */ + +/** Get an eventual isoburn object which is wrapped around the drive. + @param pt Eventually returns a pointer to the found object. + It is allowed to become NULL if return value is -1 or 0. + In this case, the drive is a genuine libburn drive + with no emulation activated by isoburn. + @param drive The drive to be searched for + @param flag unused yet + @return -1 unsuitable media, 0 generic media, 1 emulated media. +*/ +int isoburn_find_emulator(struct isoburn **pt, + struct burn_drive *drive, int flag); + + +/** Set the start address for an emulated add-on session. The value will + be rounded up to the alignment necessary for the media. The aligned + value will be divided by 2048 and then put into o->nwa . + @param o The isoburn object to be programmed. + @param value The start address in bytes + @param flag unused yet + @return <=0 is failure , >0 success +*/ +int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag); + +/** Get a data source suitable for read from a drive using burn_read_data() + function. + @param d drive to read from. Must be grabbed. + @return the data source, NULL on error. Must be freed with libisofs + iso_data_source_unref() function. Note: this doesn't release + the drive. +*/ +IsoDataSource * +isoburn_data_source_new(struct burn_drive *d); + + +/** + * Options for image reading. + (Comments here may be outdated. API getter/setter function descriptions + may override the descriptions here. Any difference is supposed to be a + minor correction only.) + */ +struct isoburn_read_opts { + unsigned int norock:1; /*< Do not read Rock Ridge extensions */ + unsigned int nojoliet:1; /*< Do not read Joliet extensions */ + unsigned int noiso1999:1; /*< Do not read ISO 9660:1999 enhanced tree */ + unsigned int preferjoliet:1; + /*< When both Joliet and RR extensions are present, the RR + * tree is used. If you prefer using Joliet, set this to 1. */ + uid_t uid; /**< Default uid when no RR */ + gid_t gid; /**< Default uid when no RR */ + mode_t mode; /**< Default mode when no RR (only permissions) */ + mode_t dirmode; /**< Default mode for directories + when no RR (only permissions) */ + + /** + * Input charset for RR file names. NULL to use default locale charset. + */ + char *input_charset; + + /* modified by the function isoburn_read_image */ + unsigned int hasRR:1; /*< It will be set to 1 if RR extensions are present, + to 0 if not. */ + unsigned int hasJoliet:1; /*< It will be set to 1 if Joliet extensions are + present, to 0 if not. */ + + /** + * It will be set to 1 if the image is an ISO 9660:1999, i.e. it has + * a version 2 Enhanced Volume Descriptor. + */ + unsigned int hasIso1999:1; + + /** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/ + unsigned int hasElTorito:1; + + uint32_t size; /**< Will be filled with the size (in 2048 byte block) of + * the image, as reported in the PVM. */ + unsigned int pretend_blank:1; /* always create empty image */ +}; + + +/** + * Options for image generation by libisofs and image transport to libburn. + (Comments here may be outdated. API getter/setter function descriptions + may override the descriptions here. Any difference is supposed to be a + minor correction only.) + */ +struct isoburn_imgen_opts { + + /* Options for image generation */ + + int level; /**< ISO level to write at. */ + + /** Which extensions to support. */ + unsigned int rockridge :1; + unsigned int joliet :1; + unsigned int iso1999 :1; + + /* relaxed constraints */ + + /* + * Relaxed constraints. Setting any of these to 1 break the specifications, + * but it is supposed to work on most moderns systems. Use with caution. + */ + + /** + * Omit the version number (";1") at the end of the ISO-9660 identifiers. + * Version numbers are usually not used. + */ + unsigned int omit_version_numbers :1; + + /** + * Allow ISO-9660 directory hierarchy to be deeper than 8 levels. + */ + unsigned int allow_deep_paths :1; + + /** + * Allow path in the ISO-9660 tree to have more than 255 characters. + */ + unsigned int allow_longer_paths :1; + + /** + * Allow a single file or directory hierarchy to have up to 37 characters. + * This is larger than the 31 characters allowed by ISO level 2, and the + * extra space is taken from the version number, so this also forces + * omit_version_numbers. + */ + unsigned int max_37_char_filenames :1; + + /** + * ISO-9660 forces filenames to have a ".", that separates file name from + * extension. libisofs adds it if original filename doesn't has one. Set + * this to 1 to prevent this behavior + */ + unsigned int no_force_dots :1; + + /** + * Allow lowercase characters in ISO-9660 filenames. By default, only + * uppercase characters, numbers and a few other characters are allowed. + */ + unsigned int allow_lowercase :1; + + /** + * Allow all ASCII characters to be appear on an ISO-9660 filename. Note + * that "/" and "\0" characters are never allowed, even in RR names. + */ + unsigned int allow_full_ascii :1; + + /** + * Allow paths in the Joliet tree to have more than 240 characters. + */ + unsigned int joliet_longer_paths :1; + + unsigned int sort_files:1; + /**< If files should be sorted based on their weight. */ + + /** + * The following options set the default values for files and directory + * permissions, gid and uid. All these take one of three values: 0, 1 or 2. + * If 0, the corresponding attribute will be kept as set in the IsoNode. + * Unless you have changed it, it corresponds to the value on disc, so it + * is suitable for backup purposes. If set to 1, the corresponding attrib. + * will be changed by a default suitable value. Finally, if you set it to + * 2, the attrib. will be changed with the value specified in the options + * below. Note that for mode attributes, only the permissions are set, the + * file type remains unchanged. + */ + unsigned int replace_dir_mode :2; + unsigned int replace_file_mode :2; + unsigned int replace_uid :2; + unsigned int replace_gid :2; + + mode_t dir_mode; /** Mode to use on dirs when replace_dir_mode == 2. */ + mode_t file_mode; /** Mode to use on files when replace_file_mode == 2. */ + uid_t uid; /** uid to use when replace_uid == 2. */ + gid_t gid; /** gid to use when replace_gid == 2. */ + + char *output_charset; /**< NULL to use default charset */ + + + /* Options for image transport */ + + /** The number of bytes to be used for the fifo which decouples libisofs + and libburn for better throughput and for reducing the risk of + interrupting signals hitting the libburn thread which operates the + MMC drive. + The size will be rounded up to the next full 2048. + Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway). + */ + int fifo_size; + + + /** Output value: Block address of session start as evaluatedfrom media + and other options by libisoburn and libburn. + If <0 : Invalid + If >=0: Valid block number. Block size is always 2 KiB. + */ + int effective_lba; +}; + +#endif /* Isoburn_includeD */ + diff --git a/libisoburn/branches/ZeroOneFour/libisoburn/isofs_wrap.c b/libisoburn/branches/ZeroOneFour/libisoburn/isofs_wrap.c new file mode 100644 index 00000000..4ee8c765 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/libisoburn/isofs_wrap.c @@ -0,0 +1,398 @@ + +/* + cc -g -c isofs_wrap.c +*/ + +/* + libisofs related functions of libisoburn. + + Copyright 2007 Vreixo Formoso Lopes + Thomas Schmitt +*/ + +#include +#include + +#ifndef Xorriso_standalonE + +#include + +#include + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" + +#endif /* Xorriso_standalonE */ + + +#include "isoburn.h" +#include "libisoburn.h" + +#define BP(a,b) [(b) - (a) + 1] + +struct ecma119_pri_vol_desc +{ + uint8_t vol_desc_type BP(1, 1); + uint8_t std_identifier BP(2, 6); + uint8_t vol_desc_version BP(7, 7); + uint8_t unused1 BP(8, 8); + uint8_t system_id BP(9, 40); + uint8_t volume_id BP(41, 72); + uint8_t unused2 BP(73, 80); + uint8_t vol_space_size BP(81, 88); + uint8_t unused3 BP(89, 120); + uint8_t vol_set_size BP(121, 124); + uint8_t vol_seq_number BP(125, 128); + uint8_t block_size BP(129, 132); + uint8_t path_table_size BP(133, 140); + uint8_t l_path_table_pos BP(141, 144); + uint8_t opt_l_path_table_pos BP(145, 148); + uint8_t m_path_table_pos BP(149, 152); + uint8_t opt_m_path_table_pos BP(153, 156); + uint8_t root_dir_record BP(157, 190); + uint8_t vol_set_id BP(191, 318); + uint8_t publisher_id BP(319, 446); + uint8_t data_prep_id BP(447, 574); + uint8_t application_id BP(575, 702); + uint8_t copyright_file_id BP(703, 739); + uint8_t abstract_file_id BP(740, 776); + uint8_t bibliographic_file_id BP(777, 813); + uint8_t vol_creation_time BP(814, 830); + uint8_t vol_modification_time BP(831, 847); + uint8_t vol_expiration_time BP(848, 864); + uint8_t vol_effective_time BP(865, 881); + uint8_t file_structure_version BP(882, 882); + uint8_t reserved1 BP(883, 883); + uint8_t app_use BP(884, 1395); + uint8_t reserved2 BP(1396, 2048); +}; + +static +uint32_t iso_read_lsb(const uint8_t *buf, int bytes) +{ + int i; + uint32_t ret = 0; + + for (i=0; iimage); + return o->image; +} + + +static void isoburn_idle_free_function(void *ignored) +{ + return; +} + + +/* API function. See libisoburn.h +*/ +int isoburn_read_image(struct burn_drive *d, + struct isoburn_read_opts *read_opts, + IsoImage **image) +{ + int ret, int_num; + IsoReadOpts *ropts= NULL; + IsoReadImageFeatures *features= NULL; + uint32_t ms_block; + + enum burn_disc_status status= BURN_DISC_BLANK; + IsoDataSource *ds= NULL; + struct isoburn *o= NULL; + + if(read_opts==NULL) { + burn_msgs_submit(0x00060000, + "Program error: isoburn_read_image: read_opts==NULL", + 0, "FATAL", NULL); + return(-1); + } + if(d != NULL) { + ret = isoburn_find_emulator(&o, d, 0); + if (ret < 0 || o == NULL) + return 0; + status = isoburn_disc_get_status(d); + } + if (d == NULL || status == BURN_DISC_BLANK || read_opts->pretend_blank) { + + /* + * Blank disc, we create a new image without files. + */ + + if (d == NULL) { + /* New empty image without relation to a drive */ + if (image==NULL) { + burn_msgs_submit(0x00060000, + "Program error: isoburn_read_image: image==NULL", + 0, "FATAL", NULL); + return -1; + } + /* create a new image */ + ret = iso_image_new("ISOIMAGE", image); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0); + return ret; + } + } else { + /* Blank new image for the drive */ + iso_image_unref(o->image); + ret = iso_image_new("ISOIMAGE", &o->image); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0); + return ret; + } + if (image) { + *image = o->image; + iso_image_ref(*image); /*protects object from premature free*/ + } + } + return 1; + } + + if (status != BURN_DISC_APPENDABLE && status != BURN_DISC_FULL) { + burn_msgs_submit(0x00060000, + "Program error: isoburn_read_image: incorrect disc status", + 0, "FATAL", NULL); + return -4; + } + + memset((char *) &ropts, 0, sizeof(ropts)); + + ret = isoburn_disc_get_msc1(d, &int_num); + if (ret <= 0) + return -2; + ms_block= int_num; + + /* create the data source */ + ret = iso_read_opts_new(&ropts, 0); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create write opts", 0, "FATAL", 0); + return ret; + } + /* Important: do not return until iso_read_opts_free() */ + iso_read_opts_set_start_block(ropts, ms_block); + iso_read_opts_set_no_rockridge(ropts, read_opts->norock); + iso_read_opts_set_no_joliet(ropts, read_opts->nojoliet); + iso_read_opts_set_no_iso1999(ropts, read_opts->noiso1999); + iso_read_opts_set_preferjoliet(ropts, read_opts->preferjoliet); + iso_read_opts_set_default_permissions(ropts, + read_opts->mode, read_opts->dirmode); + iso_read_opts_set_default_uid(ropts, read_opts->uid); + iso_read_opts_set_default_gid(ropts, read_opts->gid); + iso_read_opts_set_input_charset(ropts, read_opts->input_charset); + ds = isoburn_data_source_new(d); + iso_image_attach_data(o->image, o->read_pacifier_handle, + isoburn_idle_free_function); + if(o->read_pacifier_handle==NULL) + iso_tree_set_report_callback(o->image, NULL); + else + iso_tree_set_report_callback(o->image, o->read_pacifier); + ret = iso_image_import(o->image, ds, ropts, &features); + iso_tree_set_report_callback(o->image, NULL); + iso_read_opts_free(ropts); + iso_data_source_unref(ds); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot import image", 0, "FAILURE", 0); + return ret; + } + /* Important: do not return until free(features) */ + if (image!=NULL) { + *image = o->image; + iso_image_ref(*image); /*protects object from premature free*/ + } + read_opts->hasRR = iso_read_image_features_has_rockridge(features); + read_opts->hasJoliet = iso_read_image_features_has_joliet(features); + read_opts->hasIso1999 = iso_read_image_features_has_iso1999(features); + read_opts->hasElTorito = iso_read_image_features_has_eltorito(features); + read_opts->size = iso_read_image_features_get_size(features); + +#ifdef NIX + read_opts->hasRR = features->hasRR; + read_opts->hasJoliet = features->hasJoliet; + read_opts->hasIso1999 = features->hasIso1999; + read_opts->hasElTorito = features->hasElTorito; + read_opts->size = features->size; +#endif + + iso_read_image_features_destroy(features); + return 1; +} + + +/* API function. See libisoburn.h +*/ +int isoburn_attach_image(struct burn_drive *d, IsoImage *image) +{ + int ret; + struct isoburn *o; + + if (image == NULL) { + burn_msgs_submit(0x00060000, + "Program error: isoburn_attach_image: image==NULL", + 0, "FATAL", NULL); + return -1; + } + ret = isoburn_find_emulator(&o, d, 0); + if (ret < 0 || o == NULL) + return 0; + if(o->image != NULL) + iso_image_unref(o->image); + o->image = image; + return(1); +} + + +/* API function. See libisoburn.h +*/ +int isoburn_activate_session(struct burn_drive *drive) +{ + int ret; + struct isoburn *o; + + ret = isoburn_find_emulator(&o, drive, 0); + if (ret < 0) + return -1; + + if (o->emulation_mode != 1) + return 1; /* don't need to activate session */ + + if (o->fabricated_disc_status != BURN_DISC_APPENDABLE) + return 1; + + ret = burn_random_access_write(drive, 0, (char*)o->target_iso_head, + 32*2048, 1); + + return ret; +} + + +/** Initialize the emulation of multi-session on random access media. + The need for emulation is confirmed already. + @param o A freshly created isoburn object. isoburn_create_data_source() was + already called, nevertheless. + @return <=0 error , 1 = success +*/ +int isoburn_start_emulation(struct isoburn *o, int flag) +{ + int ret, i; + off_t data_count; + struct burn_drive *drive; + struct ecma119_pri_vol_desc *pvm; + + if(o==NULL) { + burn_msgs_submit(0x00060000, + "Program error: isoburn_start_emulation: o==NULL", + 0, "FATAL", NULL); + return -1; + } + + drive= o->drive; + + /* we can assume 0 as start block for image */ + /* TODO what about ms? where we validate valid iso image in ms disc? */ + ret = burn_read_data(drive, (off_t) 0, (char*)o->target_iso_head, + sizeof(o->target_iso_head), &data_count, 2); + + /* an error means an empty disc */ + if (ret <= 0) { + o->fabricated_disc_status= BURN_DISC_BLANK; + return 1; + } + + /* check first 64K. If 0's, the disc is treated as a blank disc, and thus + overwritten without extra check. */ + i = sizeof(o->target_iso_head); + while (i && !o->target_iso_head[i-1]) + --i; + + if (!i) { + o->fabricated_disc_status= BURN_DISC_BLANK; + return 1; + } + + pvm = (struct ecma119_pri_vol_desc *)(o->target_iso_head + 16 * 2048); + + if (!strncmp((char*)pvm->std_identifier, "CD001", 5)) { + off_t size; + + /* sanity check */ + if (pvm->vol_desc_type[0] != 1 || pvm->vol_desc_version[0] != 1 + || pvm->file_structure_version[0] != 1 ) { + /* TODO for now I treat this as a full disc */ + o->fabricated_disc_status= BURN_DISC_FULL; + return 1; + } + + /* ok, PVM found, set size */ + size = (off_t) iso_read_lsb(pvm->vol_space_size, 4); + size *= (off_t) 2048; /* block size in bytes */ + isoburn_set_start_byte(o, size, 0); + o->fabricated_disc_status= BURN_DISC_APPENDABLE; + } else if (!strncmp((char*)pvm->std_identifier, "CDXX1", 5)) { + + /* empty image */ + isoburn_set_start_byte(o, (off_t) 0, 0); + o->fabricated_disc_status= BURN_DISC_BLANK; + } else { + /* treat any disc in an unknown format as full */ + o->fabricated_disc_status= BURN_DISC_FULL; + } + return 1; +} + + +/** Alters and writes the first 64 kB of a "media" to invalidate + an ISO image. (It shall stay restorable by skilled humans, though). + The result shall especially keep libisoburn from accepting the media + image as ISO filesystem. + @param o A fully activated isoburn object. isoburn_start_emulation() + was already called. + @return <=0 error , 1 = success +*/ +int isoburn_invalidate_iso(struct isoburn *o, int flag) +{ + /* + * replace CD001 with CDXX1 in PVM. + * I think this is enought for invalidating an iso image + */ + strncpy((char*)o->target_iso_head + 16 * 2048 + 1, "CDXX1", 5); + return isoburn_activate_session(o->drive); +} + + +/* API @since 0.1.0 */ +int isoburn_set_read_pacifier(struct burn_drive *drive, + int (*read_pacifier)(IsoImage*, IsoFileSource*), + void *read_handle) +{ + int ret; + struct isoburn *o; + + ret = isoburn_find_emulator(&o, drive, 0); + if(ret < 0 || o == NULL) + return -1; + o->read_pacifier_handle= read_handle; + o->read_pacifier= read_pacifier; + return(1); +} + diff --git a/libisoburn/branches/ZeroOneFour/libisoburn/libisoburn.h b/libisoburn/branches/ZeroOneFour/libisoburn/libisoburn.h new file mode 100644 index 00000000..d41fbc18 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/libisoburn/libisoburn.h @@ -0,0 +1,1066 @@ + +/* + API definition of libisoburn. + + Copyright 2007-2008 Vreixo Formoso Lopes + and Thomas Schmitt +*/ + +/** Overview + +libisoburn is a frontend for libraries libburn and libisofs which enables +creation and expansion of ISO-9660 filesystems on all CD/DVD media supported +by libburn. This includes media like DVD+RW, which do not support multi-session +management on media level and even plain disk files or block devices. + +The price for that is thorough specialization on data files in ISO-9660 +filesystem images. So libisoburn is not suitable for audio (CD-DA) or any +other CD layout which does not entirely consist of ISO-9660 sessions. + + + Connector functions + +libisofs and libburn do not depend on each other but share some interfaces +by which they can cooperate. +libisoburn establishes the connection between both modules by creating the +necessary interface objects and attaching them to the right places. + + + Wrapper functions + +The priciple of this frontend is that you may use any call of libisofs or +libburn unless it has a isoburn_*() wrapper listed in the following function +documentation. + +E.g. call isoburn_initialize() rather than iso_init(); burn_initialize(); +and call isoburn_drive_scan_and_grab() rather than burn_drive_scan_and_grab(). +But you may call burn_disc_get_profile() directly if you want to display +the media type. + +The wrappers will transparently provide the necessary emulations which +are appropriate for particular target drives and media states. +To learn about them you have to read both API descriptions: the one of +the wrapper and the one of the underlying libburn or libisofs call. + +Macros BURN_* and functions burn_*() are documented in +Macros ISO_* and functions iso_*() are documented in + + + Usage model + +There may be an input drive and an output drive. Either of them may be missing +with the consequence that no reading resp. writing is possible. +Both drive roles can be fulfilled by the same drive. + +Input can be a random access readable libburn drive: + optical media, regular files, block devices. +Output can be any writeable libburn drive: + writeable optical media in burner, writeable file objects (no directories). + +libburn demands rw-permissions to drive device file resp. file object. + +If the input drive provides a suitable ISO RockRidge image, then its tree +may be loaded into memory and can then be manipulated by libisofs API calls. +The loading is done by isoburn_read_image() under control of +struct isoburn_read_opts which the application obtains from libisoburn +and manipulates by the family of isoburn_ropt_set_*() functions. + +Writing of result images is controlled by libisofs related parameters +in a struct isoburn_imgen_opts which the application obtains from libisoburn +and manipulates by the family of isoburn_igopt_set_*() functions. + +All multi-session aspects are handled by libisoburn according to these +settings. The application does not have to analyze media state and write +job parameters. It rather states its desires which libisoburn tries to +fulfill, or else will refuse to start the write run. + + + Setup for Growing or Modifying + +The connector function family offers two alternative API calls for performing +the setup for two alternative image generation strategies. + +Growing: +If input and output drive is the same, then isoburn_prepare_disc() is to +be used. It will lead to an add-on session on appendable or overwriteable +media with existing ISO image. With blank media it will produce a first +session. + +Modifying: +If the output drive is not the input drive, then it has to bear blank media +or overwriteable without a valid ISO image. To prepare for such an image +generation run, use isoburn_prepare_new_image(). The run will copy file data +from an eventual input drive with valid image, add any newly introduced data +from the local filesystem, and produce a first session on output media. + +After either of these setups, some peripheral libburn drive parameter settings +like burn_write_opts_set_simulate(), burn_write_opts_set_multi(), + burn_drive_set_speed(), burn_write_opts_set_underrun_proof() should be made. +Do not set the write mode. It will be chosen by libisoburn so it matches job +and media state. + + Writing the image + +Then one may start image generation and write threads by isoburn_disc_write(). +Progress may be watched at the output drive by burn_drive_get_status() and +isoburn_get_fifo_status(). + +At some time, the output drive will be BURN_DRIVE_IDLE indicating that +writing has ended. +One should inquire isoburn_drive_wrote_well() to learn about overall success. + +Finally one must call isoburn_activate_session() which will complete any +eventual multi-session emulation. + +*/ + + + /* API functions */ + + +/** Initialize libisoburn, libisofs and libburn. + Wrapper for : iso_init() and burn_initialize() + @since 0.1.0 + @param msg A character array for eventual messages (e.g. with errors) + @param flag Bitfield for control purposes (unused yet, submit 0) + @return 1 indicates success, 0 is failure +*/ +int isoburn_initialize(char msg[1024], int flag); + + +/** Check whether all features of header file libisoburn.h from the given + major.minor.micro revision triple can be delivered by the library version + which is performing this call. + An application of libisoburn can easily memorize the version of the + libisofs.h header in its own code. Immediately after isoburn_initialize() + it should simply do this check: + if (! isoburn_is_compatible(isoburn_header_version_major, + isoburn_header_version_minor, + isoburn_header_version_micro, 0)) + ...refuse to start the program with this dynamic library version... + @since 0.1.0 + @param major obtained at build time + @param minor obtained at build time + @param micro obtained at build time + @param flag Bitfield for control purposes. Unused yet. Submit 0. + @return 1= library can work for caller + 0= library is not usable in some aspects. Caller must restrict + itself to an earlier API version or must not use this libray + at all. +*/ +int isoburn_is_compatible(int major, int minor, int micro, int flag); + + +/** Obtain the three release version numbers of the library. These are the + numbers encountered by the application when linking with libisoburn, + i.e. possibly not before run time. + Better do not base the fundamental compatibility decision of an application + on these numbers. For a reliable check use isoburn_is_compatible(). + @since 0.1.0 + @param major The maturity version (0 for now, as we are still learning) + @param minor The development goal version. + @param micro The development step version. This has an additional meaning: + + Pare numbers indicate a version with frozen API. I.e. you can + rely on the same set of features to be present in all + published releases with that major.minor.micro combination. + Features of a pare release will stay available and ABI + compatible as long as the SONAME of libisoburn stays "1". + Currently there are no plans to ever change the SONAME. + + Odd numbers indicate that API upgrades are in progress. + I.e. new features might be already present or they might + be still missing. Newly introduced features may be changed + incompatibly or even be revoked before release of a pare + version. + So micro revisions {1,3,5,7,9} should never be used for + dynamic linking unless the proper library match can be + guaranteed by external circumstances. + + @return 1 success, <=0 might in future become an error indication +*/ +void isoburn_version(int *major, int *minor, int *micro); + + +/** The minimum version of libisofs to be used with this version of libisoburn + at compile time. + @since 0.1.0 +*/ +#define isoburn_libisofs_req_major 0 +#define isoburn_libisofs_req_minor 6 +#define isoburn_libisofs_req_micro 3 + +/** The minimum version of libburn to be used with this version of libisoburn + at compile time. + @since 0.1.0 +*/ +#define isoburn_libburn_req_major 0 +#define isoburn_libburn_req_minor 4 +#define isoburn_libburn_req_micro 4 + + +/** The minimum version of libisofs to be used with this version of libisoburn + at runtime. This is checked already in isoburn_initialize() which will + refuse on outdated version. So this call is for information purposes after + successful startup only. + @since 0.1.0 + @param major isoburn_libisofs_req_major as seen at build time + @param minor as seen at build time + @param micro as seen at build time + @return 1 success, <=0 might in future become an error indication +*/ +int isoburn_libisofs_req(int *major, int *minor, int *micro); + + +/** The minimum version of libburn to be used with this version of libisoburn + at runtime. This is checked already in isoburn_initialize() which will + refuse on outdated version. So this call is for information purposes after + successful startup only. + @since 0.1.0 + @param major isoburn_libburn_req_major as seen at build time + @param minor as seen at build time + @param micro as seen at build time + @return 1 success, <=0 might in future become an error indication +*/ +int isoburn_libburn_req(int *major, int *minor, int *micro); + + +/** These three release version numbers tell the revision of this header file + and of the API it describes. They are memorized by applications at build + time. + @since 0.1.0 +*/ +#define isoburn_header_version_major 0 +#define isoburn_header_version_minor 1 +#define isoburn_header_version_micro 3 +/** Note: + Above version numbers are also recorded in configure.ac because libtool + wants them as parameters at build time. + For the library compatibility check, ISOBURN_*_VERSION in configure.ac + are not decisive. Only the three numbers here do matter. +*/ +/** Usage discussion: + +Some developers of the libburnia project have differing +opinions how to ensure the compatibility of libaries +and applications. + +It is about whether to use at compile time and at runtime +the version numbers isoburn_header_version_* provided here. +Thomas Schmitt advises to use them. +Vreixo Formoso advises to use other means. + +At compile time: + +Vreixo Formoso advises to leave proper version matching +to properly programmed checks in the the application's +build system, which will eventually refuse compilation. + +Thomas Schmitt advises to use the macros defined here +for comparison with the application's requirements of +library revisions and to eventually break compilation. + +Both advises are combinable. I.e. be master of your +build system and have #if checks in the source code +of your application, nevertheless. + +At runtime (via *_is_compatible()): + +Vreixo Formoso advises to compare the application's +requirements of library revisions with the runtime +library. This is to allow runtime libraries which are +young enough for the application but too old for +the lib*.h files seen at compile time. + +Thomas Schmitt advises to compare the header +revisions defined here with the runtime library. +This is to enforce a strictly monotonous chain +of revisions from app to header to library, +at the cost of excluding some older libraries. + +These two advises are mutually exclusive. + +----------------------------------------------------- + +For an implementation of the Thomas Schmitt approach, +see libisoburn/burn_wrap.c : isoburn_initialize() +This connects libisoburn as "application" with libisofs +as "library". + +The compatible part of Vreixo Formoso's approach is implemented +in configure.ac LIBBURN_REQUIRED, LIBISOFS_REQUIRED. +In isoburn_initialize() it would rather test by + iso_lib_is_compatible(isoburn_libisofs_req_major,... +than by + iso_lib_is_compatible(iso_lib_header_version_major,... +and would leave out the ugly compile time traps. + +*/ + + +/** Aquire a target drive by its filesystem path resp. libburn persistent + address. + Wrapper for: burn_drive_scan_and_grab() + @since 0.1.0 + @param drive_infos On success returns a one element array with the drive + (cdrom/burner). Thus use with driveno 0 only. On failure + the array has no valid elements at all. + The returned array should be freed via burn_drive_info_free() + when the drive is no longer needed. + @param adr The persistent address of the desired drive. + @param load 1 attempt to load the disc tray. 0 no attempt,rather failure. + @return 1 = success , 0 = drive not found , <0 = other error +*/ +int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], + char* adr, int load); + + +/** Aquire a target drive by its filesystem path resp. libburn persistent + address. This is a modern successor of isoburn_drive_scan_and_grab(). + Wrapper for: burn_drive_scan_and_grab() + @since 0.1.2 + @param drive_infos On success returns a one element array with the drive + (cdrom/burner). Thus use with driveno 0 only. On failure + the array has no valid elements at all. + The returned array should be freed via burn_drive_info_free() + when the drive is no longer needed. + @param adr The persistent address of the desired drive. + @param flag bit0= attempt to load the disc tray. + Else: failure if not loaded. + bit1= regard overwriteable media as blank + bit2= if the drive is a regular disk file: truncate it to + the write start address + @return 1 = success , 0 = drive not found , <0 = other error +*/ +int isoburn_drive_aquire(struct burn_drive_info *drive_infos[], + char* adr, int flag); + + +/** Aquire a drive from the burn_drive_info[] array which was obtained by + a previous call of burn_drive_scan(). + Wrapper for: burn_drive_grab() + @since 0.1.0 + @param drive The drive to grab. E.g. drive_infos[1].drive . + @param load 1 attempt to load the disc tray. 0 no attempt, rather failure. + @return 1 success, <=0 failure +*/ +int isoburn_drive_grab(struct burn_drive *drive, int load); + + +/** Inquire the media status. Expect the whole spectrum of libburn BURN_DISC_* + with multi-session media. Emulated states with random access media are + BURN_DISC_BLANK and BURN_DISC_APPENDABLE. + Wrapper for: burn_disc_get_status() + @since 0.1.0 + @param drive The drive to inquire. + @return The status of the drive, or what kind of disc is in it. + Note: BURN_DISC_UNGRABBED indicates wrong API usage +*/ +enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive); + + +/** Tells whether the media can be treated by isoburn_disc_erase(). + Wrapper for: burn_disc_erasable() + @since 0.1.0 + @param drive The drive to inquire. + @return 0=not erasable , else erasable +*/ +int isoburn_disc_erasable(struct burn_drive *d); + + +/** Mark the media as blank. With multi-session media this will call + burn_disc_erase(). With random access media, an eventual ISO-9660 + filesystem will get invalidated by altering its start blocks on media. + In case of success, the media is in status BURN_DISC_BLANK afterwards. + Wrapper for: burn_disc_erase() + @since 0.1.0 + @param drive The drive with the media to erase. + @param fast 1=fast erase, 0=thorough erase + With DVD-RW, fast erase yields media incapable of multi-session. +*/ +void isoburn_disc_erase(struct burn_drive *drive, int fast); + + +/* ----------------------------------------------------------------------- */ +/* + + Options for image reading. + + An application shall create an option set object by isoburn_ropt_new(), + program it by isoburn_ropt_set_*(), use it with isoburn_read_image(), + and finally delete it by isoburn_ropt_destroy(). + +*/ +/* ----------------------------------------------------------------------- */ + +struct isoburn_read_opts; + +/** Produces a set of image read options, initialized with default values. + @since 0.1.0 + @param o the newly created option set object + @param flag Bitfield for control purposes. Submit 0 for now. + @return 1=ok , <0 = failure +*/ +int isoburn_ropt_new(struct isoburn_read_opts **o, int flag); + + +/** Deletes an option set which was created by isoburn_ropt_new(). + @since 0.1.0 + @param o The option set to work on + @param flag Bitfield for control purposes. Submit 0 for now. + @return 1= **o destroyed , 0= *o was already NULL (harmless) +*/ +int isoburn_ropt_destroy(struct isoburn_read_opts **o, int flag); + + +/** Which existing ISO 9660 extensions in the image to read or not to read. + Whether to read the content of an existing image at all. + The bits can be combined by | resp. inquired by &. + @since 0.1.0 + @param ext Bitfield: + bit0= norock + Do not read Rock Ridge extensions + bit1= nojoliet + Do not read Joliet extensions + bit2= noiso1999 + Do not read ISO 9660:1999 enhanced tree + bit3= preferjoliet + When both Joliet and RR extensions are present, the RR + tree is used. If you prefer using Joliet, set this to 1. + bit4= pretend_blank + Always create empty image.Ignore any image on input drive. + @return 1 success, <=0 failure +*/ +#define isoburn_ropt_norock 1 +#define isoburn_ropt_nojoliet 2 +#define isoburn_ropt_noiso1999 4 +#define isoburn_ropt_preferjoliet 8 +#define isoburn_ropt_pretend_blank 16 +int isoburn_ropt_set_extensions(struct isoburn_read_opts *o, int ext); +int isoburn_ropt_get_extensions(struct isoburn_read_opts *o, int *ext); + + +/** Default attributes to use if no RockRidge extension gets loaded. + @since 0.1.0 + @param o The option set to work on + @param uid user id number (see /etc/passwd) + @param gid group id number (see /etc/group) + @param mode permissions (not file type) as of man 2 stat. + With directories, r-permissions will automatically imply + x-permissions. See isoburn_ropt_set_default_dirperms() below. + @return 1 success, <=0 failure +*/ +int isoburn_ropt_set_default_perms(struct isoburn_read_opts *o, + uid_t uid, gid_t gid, mode_t mode); +int isoburn_ropt_get_default_perms(struct isoburn_read_opts *o, + uid_t *uid, gid_t *gid, mode_t *mode); + +/** Default attributes to use on directories if no RockRidge extension + gets loaded. + Above call isoburn_ropt_set_default_perms() automatically adds + x-permissions to r-permissions for directories. This call here may + be done afterwards to set independend permissions for directories, + especially to override the automatically added x-permissions. + @since 0.1.0 + @param o The option set to work on + @param mode permissions (not file type) as of man 2 stat. + @return 1 success, <=0 failure +*/ +int isoburn_ropt_set_default_dirperms(struct isoburn_read_opts *o, + mode_t mode); +int isoburn_ropt_get_default_dirperms(struct isoburn_read_opts *o, + mode_t *mode); + + + +/** Set the character set for reading RR file names from ISO images. + @since 0.1.0 + @param o The option set to work on + @param input_charset Set this to NULL to use the default locale charset. + For selecting a particular character set, submit its + name, e.g. as listed by program iconv -l. + Example: "UTF-8". + @return 1 success, <=0 failure +*/ +int isoburn_ropt_set_input_charset(struct isoburn_read_opts *o, + char *input_charset); +int isoburn_ropt_get_input_charset(struct isoburn_read_opts *o, + char **input_charset); + + +/** After calling function isoburn_read_image() there are informations + available in the option set. + This info can be obtained as bits in parameter has_what. Like: + joliet_available = (has_what & isoburn_ropt_has_joliet); + @since 0.1.0 + @param o The option set to work on + @param size Number of image data blocks, 2048 bytes each. + @param has_what Bitfield: + bit0= has_rockridge + RockRidge extension info is available (POSIX filesystem) + bit1= has_joliet + Joliet extension info is available (suitable for MS-Windows) + bit2= has_iso1999 + ISO version 2 Enhanced Volume Descriptor is available. + This is rather exotic. + bit3= has_el_torito + El-Torito boot record is present + @return 1 success, <=0 failure +*/ +#define isoburn_ropt_has_rockridge 1 +#define isoburn_ropt_has_joliet 2 +#define isoburn_ropt_has_iso1999 4 +#define isoburn_ropt_has_el_torito 8 +int isoburn_ropt_get_size_what(struct isoburn_read_opts *o, + uint32_t *size, int *has_what); + + +/* ----------------------------------------------------------------------- */ +/* End of Options for image reading */ +/* ----------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------- */ +/* + + Options for image generation by libisofs and image transport to libburn. + + An application shall create an option set by isoburn_igopt_new(), + program it by isoburn_igopt_set_*(), use it with either + isoburn_prepare_new_image() or isoburn_prepare_disc(), and finally delete + it by isoburn_igopt_destroy(). + +*/ +/* ----------------------------------------------------------------------- */ + +struct isoburn_imgen_opts; + +/** Produces a set of generation and transfer options, initialized with default + values. + @since 0.1.0 + @param o the newly created option set object + @param flag Bitfield for control purposes. Submit 0 for now. + @return 1=ok , <0 = failure +*/ +int isoburn_igopt_new(struct isoburn_imgen_opts **o, int flag); + + +/** Deletes an option set which was created by isoburn_igopt_new(). + @since 0.1.0 + @param o The option set to give up + @param flag Bitfield for control purposes. Submit 0 for now. + @return 1= **o destroyed , 0= *o was already NULL (harmless) +*/ +int isoburn_igopt_destroy(struct isoburn_imgen_opts **o, int flag); + + +/** ISO level to write at. + @since 0.1.0 + @param o The option set to work on + @param level is a term of the ISO 9660 standard. It should be one of: + 1= filenames restricted to form 8.3 + 2= filenames allowed up to 31 characters + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_level(struct isoburn_imgen_opts *o, int level); +int isoburn_igopt_get_level(struct isoburn_imgen_opts *o, int *level); + + +/** Which extensions to support. + @since 0.1.0 + @param o The option set to work on + @param ext Bitfield: + bit0= rockridge + Rock Ridge extensions add POSIX file attributes like + owner, group, access permissions, long filenames. Very + advisable if the designed audience has Unix style systems. + bit1= joliet + Longer filenames for Windows systems. + Weaker than RockRidge, but also readable with Linux. + bit2= iso1999 + This is rather exotic. Better do not surprise the readers. + @return 1 success, <=0 failure +*/ +#define isoburn_igopt_rockridge 1 +#define isoburn_igopt_joliet 2 +#define isoburn_igopt_iso1999 4 +int isoburn_igopt_set_extensions(struct isoburn_imgen_opts *o, int ext); +int isoburn_igopt_get_extensions(struct isoburn_imgen_opts *o, int *ext); + +/** Relaxed constraints. Setting any of the bits to 1 break the specifications, + but it is supposed to work on most moderns systems. Use with caution. + @since 0.1.0 + @param o The option set to work on + @param relax Bitfield: + bit0= omit_version_numbers + Omit the version number (";1") at the end of the + ISO-9660 identifiers. Version numbers are usually + not used. + bit1= allow_deep_paths + Allow ISO-9660 directory hierarchy to be deeper + than 8 levels. + bit2= allow_longer_paths + Allow path in the ISO-9660 tree to have more than + 255 characters. + bit3= max_37_char_filenames + Allow a single file or directory hierarchy to have + up to 37 characters. This is larger than the 31 + characters allowed by ISO level 2, and the extra space + is taken from the version number, so this also forces + omit_version_numbers. + bit4= no_force_dots + ISO-9660 forces filenames to have a ".", that separates + file name from extension. libisofs adds it if original + filename has none. Set this to 1 to prevent this + behavior. + bit5= allow_lowercase + Allow lowercase characters in ISO-9660 filenames. + By default, only uppercase characters, numbers and + a few other characters are allowed. + bit6= allow_full_ascii + Allow all ASCII characters to be appear on an ISO-9660 + filename. Note * that "/" and "\0" characters are never + allowed, even in RR names. + bit7= joliet_longer_paths + Allow paths in the Joliet tree to have more than + 240 characters. + @return 1 success, <=0 failure +*/ +#define isoburn_igopt_omit_version_numbers 1 +#define isoburn_igopt_allow_deep_paths 2 +#define isoburn_igopt_allow_longer_paths 4 +#define isoburn_igopt_max_37_char_filenames 8 +#define isoburn_igopt_no_force_dots 16 +#define isoburn_igopt_allow_lowercase 32 +#define isoburn_igopt_allow_full_ascii 64 +#define isoburn_igopt_joliet_longer_paths 128 +int isoburn_igopt_set_relaxed(struct isoburn_imgen_opts *o, int relax); +int isoburn_igopt_get_relaxed(struct isoburn_imgen_opts *o, int *relax); + + +/** Whether and how files should be sorted. + @since 0.1.0 + @param o The option set to work on + @param value Bitfield: bit0= sort_files_by_weight + files should be sorted based on their weight. + Weight is attributed to files in the image + by libisofs call iso_node_set_sort_weight(). + @return 1 success, <=0 failure +*/ +#define isoburn_igopt_sort_files_by_weight 1 +int isoburn_igopt_set_sort_files(struct isoburn_imgen_opts *o, int value); +int isoburn_igopt_get_sort_files(struct isoburn_imgen_opts *o, int *value); + + +/** Set the override values for files and directory permissions. + The parameters replace_* these take one of three values: 0, 1 or 2. + If 0, the corresponding attribute will be kept as set in the IsoNode + at the time of image generation. + If set to 1, the corresponding attrib. will be changed by a default + suitable value. + With value 2, the attrib. will be changed with the value specified + in the corresponding *_mode options. Note that only the permissions + are set, the file type remains unchanged. + @since 0.1.0 + @param o The option set to work on + @param replace_dir_mode whether and how to override directories + @param replace_file_mode whether and how to override files of other type + @param dir_mode Mode to use on dirs with replace_dir_mode == 2. + @param file_mode; Mode to use on files with replace_file_mode == 2. + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_over_mode(struct isoburn_imgen_opts *o, + int replace_dir_mode, int replace_file_mode, + mode_t dir_mode, mode_t file_mode); +int isoburn_igopt_get_over_mode(struct isoburn_imgen_opts *o, + int *replace_dir_mode, int *replace_file_mode, + mode_t *dir_mode, mode_t *file_mode); + +/** Set the override values values for group id and user id. + The rules are like with above overriding of mode values. replace_* controls + whether and how. The other two parameters provide values for eventual use. + @since 0.1.0 + @param o The option set to work on + @param replace_uid whether and how to override user ids + @param replace_gid whether and how to override group ids + @param uid User id to use with replace_uid == 2. + @param gid Group id to use on files with replace_gid == 2. + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_over_ugid(struct isoburn_imgen_opts *o, + int replace_uid, int replace_gid, + uid_t uid, gid_t gid); +int isoburn_igopt_get_over_ugid(struct isoburn_imgen_opts *o, + int *replace_uid, int *replace_gid, + uid_t *uid, gid_t *gid); + +/** Set the charcter set to use for representing filenames in the image. + @since 0.1.0 + @param o The option set to work on + @param output_charset Set this to NULL to use the default output charset. + For selecting a particular character set, submit its + name, e.g. as listed by program iconv -l. + Example: "UTF-8". + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_out_charset(struct isoburn_imgen_opts *o, + char *output_charset); +int isoburn_igopt_get_out_charset(struct isoburn_imgen_opts *o, + char **output_charset); + + +/** The number of bytes to be used for the fifo which decouples libisofs + and libburn for better throughput and for reducing the risk of + interrupting signals hitting the libburn thread which operates the + MMC drive. + The size will be rounded up to the next full 2048. + Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway). + @since 0.1.0 + @param o The option set to work on + @param fifo_size Number of bytes to use + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_fifo_size(struct isoburn_imgen_opts *o, int fifo_size); +int isoburn_igopt_get_fifo_size(struct isoburn_imgen_opts *o, int *fifo_size); + + +/** Obtain after image preparation the block address where the session will + start on media. + This value cannot be set by the application but only be inquired. + @since 0.1.4 + @param o The option set to work on + @param lba The block number of the session start on media. + <0 means that no address has been determined yet. + @return 1 success, <=0 failure +*/ +int isoburn_igopt_get_effective_lba(struct isoburn_imgen_opts *o, int *lba); + + +/* ----------------------------------------------------------------------- */ +/* End of Options for image generation */ +/* ----------------------------------------------------------------------- */ + + +/** Get the image attached to a drive, if any. + @since 0.1.0 + @param d The drive to inquire + @return A reference to attached image, or NULL if the drive has no image + attached. This reference needs to be released via iso_image_unref() + when it is not longer needed. +*/ +IsoImage *isoburn_get_attached_image(struct burn_drive *d); + + +/** Load the ISO filesystem directory tree from the media in the given drive. + This will give libisoburn the base on which it can let libisofs perform + image growing or image modification. The loaded volset gets attached + to the drive object and handed out to the application. + Not a wrapper, but peculiar to libisoburn. + @since 0.1.0 + @param d The drive which holds an existing ISO filesystem or blank media. + d is allowed to be NULL which produces an empty ISO image. In + this case one has to call before writing isoburn_attach_volset() + with the volset from this call and with the intended output + drive. + @param read_opts The read options which can be chosen by the application + @param image the image read, if the disc is blank it will have no files. + This reference needs to be released via iso_image_unref() when + it is not longer needed. The drive, if not NULL, will hold an + own reference which it will release when it gets a new volset + or when it gets released via isoburn_drive_release(). + You can pass NULL if you already have a reference or you plan to + obtain it later with isoburn_get_attached_image(). Of course, if + you haven't specified a valid drive (i.e., if d == NULL), this + parameter can't be NULL. + @return <=0 error , 1 = success +*/ +int isoburn_read_image(struct burn_drive *d, + struct isoburn_read_opts *read_opts, + IsoImage **image); + +/** Set a callback function for producing pacifier messages during the lengthy + process of image reading. The callback function and the application handle + are stored until they are needed for the underlying call to libisofs. + Other than with libisofs the handle is managed entirely by the application. + An idle .free() function is exposed to libisofs. The handle has to stay + valid until isoburn_read_image() is done. It has to be detached by + isoburn_set_read_pacifier(drive, NULL, NULL); + before it may be removed from memory. + @since 0.1.0 + @param drive The drive which will be used with isoburn_read_image() + It has to be aquired by an isoburn_* wrapper call. + @param read_pacifier The callback function + @param app_handle The app handle which the callback function can obtain + via iso_image_get_attached_data() from its IsoImage* + @return 1 success, <=0 failure +*/ +int isoburn_set_read_pacifier(struct burn_drive *drive, + int (*read_pacifier)(IsoImage*, IsoFileSource*), + void *app_handle); + + +/** Set the IsoImage to be used with a drive. This eventually releases + the reference to the old IsoImage attached to the drive. + Caution: Use with care. It hardly makes sense to replace an image that + reflects a valid ISO image on media. + This call is rather intended for writing a newly created and populated + image to blank media. The use case in xorriso is to let an image survive + the change or demise of the outdev target drive. + @since 0.1.0 + @param d The drive which shall be write target of the volset. + @param image The image that represents the image to be written. + This image pointer MUST already be a valid reference suitable + for iso_image_unref(). + It may have been obtained by appropriate libisofs calls or by + isoburn_read_image() with d==NULL. + @return <=0 error , 1 = success +*/ +int isoburn_attach_image(struct burn_drive *d, IsoImage *image); + + +/** Return the best possible estimation of the currently available capacity of + the media. This might depend on particular write option settings and on + drive state. + An eventual start address for emulated multi-session will be subtracted + from the capacity estimation given by burn_disc_available_space(). + Negative results get defaulted to 0. + Wrapper for: burn_disc_available_space() + @since 0.1.0 + @param d The drive to query. + @param o If not NULL: write parameters to be set on drive before query + @return number of most probably available free bytes +*/ +off_t isoburn_disc_available_space(struct burn_drive *d, + struct burn_write_opts *o); + + +/** Obtain the start block number of the most recent session on media. In + case of random access media this will always be 0. Succesfull return is + not a guarantee that there is a ISO-9660 image at all. The call will fail, + nevertheless,if isoburn_disc_get_status() returns not BURN_DISC_APPENDABLE. + Wrapper for: burn_disc_get_msc1() + @since 0.1.0 + @param d The drive to inquire + @param start_lba Contains on success the start address in 2048 byte blocks + @return <=0 error , 1 = success +*/ +int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba); + + +/** Use this with trackno==0 to obtain the predicted start block number of the + new session. The interesting number is returned in parameter nwa. + Wrapper for: burn_disc_track_lba_nwa() + @since 0.1.0 + @param d The drive to inquire + @param o If not NULL: write parameters to be set on drive before query + @param trackno Submit 0. + @param lba return value: start lba + @param nwa return value: Next Writeable Address + @return 1=nwa is valid , 0=nwa is not valid , -1=error +*/ +int isoburn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o, + int trackno, int *lba, int *nwa); + + +/** Obtain the size which was attributed to an emulated appendable on actually + overwriteable media. This value is supposed to be <= 2048 * nwa as of + isoburn_disc_track_lba_nwa(). + @since 0.1.0 + @param drive The drive holding the media. + @param start_byte The reply value counted in bytes, not in sectors. + @param flag Unused yet. Submit 0. + @return 1=stat_byte is valid, 0=not an emulated appendable, -1=error +*/ +int isoburn_get_min_start_byte(struct burn_drive *d, off_t *start_byte, + int flag); + + +/** Create a disc object for writing the new session from the created or loaded + iso_volset which has been manipulated via libisofs, to the same media from + where the image was eventually loaded. This struct burn_disc is ready for + use by a subsequent call to isoburn_disc_write(). + After this asynchronous writing has ended and the drive is BURN_DRIVE_IDLE + again, the burn_disc object has to be disposed by burn_disc_free(). + @since 0.1.0 + @param drive The combined source and target drive, grabbed with + isoburn_drive_scan_and_grab(). . + @param disc Returns the newly created burn_disc object. + @param opts Image generation options, see isoburn_igopt_*() + @return <=0 error , 1 = success +*/ +int isoburn_prepare_disc(struct burn_drive *drive, struct burn_disc **disc, + struct isoburn_imgen_opts *opts); + + +/** Create a disc object for producing a new image from a previous image + plus the changes made by user. The generated burn_disc is suitable + to be written to any grabbed libburn drive with blank writeable media. + But you must not use the same drive for input and output, because data + will be read from the source drive while at the same time the target + drive is already writing. + The resulting burn_disc object has to be disposed when all its writing + is done and the drive is BURN_DRIVE_IDLE again after asynchronous + burn_disc_write(). + @since 0.1.0 + @param in_drive The input drive,grabbed with isoburn_drive_scan_and_grab(). + @param disc Returns the newly created burn_disc object. + @param opts Options for image generation and data transport to media. + @param out_drive The libburn drive which shall be write target. + If the drive was grabbed via libisoburn then it can later + access the libisofs source fifo via + isoburn_get_fifo_status(). + Mere libburn drives cannot obtain this info. + In that case out_drive may be NULL, as well. + @return <=0 error , 1 = success +*/ +int isoburn_prepare_new_image(struct burn_drive *in_drive, + struct burn_disc **disc, + struct isoburn_imgen_opts *opts, + struct burn_drive *out_drive); + +/** @since 0.1.0 + Revoke isoburn_prepare_new_image() or isoburn_prepare_disc() instead of + running isoburn_disc_write(). + libisofs reserves resources and maybe already starts generating the + image stream when one of above two calls is performed. It is mandatory to + either run isoburn_disc_write() or to revoke the preparations by the + call described here. + @since 0.1.0 + @param input_drive The drive resp. in_drive which was used with the + preparation call. + @param output_drive The out_drive used with isoburn_prepare_new_image(), + NULL if none. + @param flag Bitfield, submit 0 for now. + bit0= -reserved for internal use- + @return <0 error, 0= no pending preparations detectable, 1 = canceled +*/ +int isoburn_cancel_prepared_write(struct burn_drive *input_drive, + struct burn_drive *output_drive, int flag); + + +/** Start writing of the new session. + This call is asynchrounous. I.e. it returns quite soon and the progress has + to be watched by a loop with call burn_drive_get_status() until + BURN_DRIVE_IDLE is returned. + Wrapper for: burn_disc_write() + @since 0.1.0 + @param o Options which control the burn process. See burnwrite_opts_*() + in libburn.h. + @param disc Disc object created either by isoburn_prepare_disc() or by + isoburn_prepare_new_image(). +*/ +void isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc); + + +/** Inquire state and fill parameters of the fifo which is attached to + the emerging track. This should be done in the pacifier loop while + isoburn_disc_write() or burn_disc_write() are active. + This works only with drives obtained by isoburn_drive_scan_and_grab() + or isoburn_drive_grab(). If isoburn_prepare_new_image() was used, then + parameter out_drive must have announced the track output drive. + Hint: If only burn_write_opts and not burn_drive is known, then the drive + can be obtained by burn_write_opts_get_drive(). + @since 0.1.0 + @parm d The drive to which the track with the fifo gets burned. + @param size The total size of the fifo + @param free_bytes The current free capacity of the fifo + @param status_text Returns a pointer to a constant text, see below + @return <0 reply invalid, >=0 fifo status code: + bit0+1=input status, bit2=consumption status, i.e: + 0="standby" : data processing not started yet + 1="active" : input and consumption are active + 2="ending" : input has ended without error + 3="failing" : input had error and ended, + 4="unused" : ( consumption has ended before processing start ) + 5="abandoned" : consumption has ended prematurely + 6="ended" : consumption has ended without input error + 7="aborted" : consumption has ended after input error +*/ +int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes, + char **status_text); + + +/** Inquire whether the most recent write run was successful. + Wrapper for: burn_drive_wrote_well() + @since 0.1.0 + @param d The drive to inquire + @return 1=burn seems to have went well, 0=burn failed +*/ +int isoburn_drive_wrote_well(struct burn_drive *d); + + +/** Call this after isoburn_disc_write has finished and burn_drive_wrote_well() + indicates success. It will eventually complete the emulation of + multi-session functionality, if needed at all. Let libisoburn decide. + Not a wrapper, but peculiar to libisoburn. + @since 0.1.0 + @param d The output drive to which the session was written + @return 1 success , <=0 failure +*/ +int isoburn_activate_session(struct burn_drive *drive); + + +/** @since 0.1.0 + Wait after normal end of operations until libisofs ended all write + threads and freed resource reservations. + This call is not mandatory. But without it, messages from the ending + threads might appear after the application ended its write procedure. + @since 0.1.0 + @param input_drive The drive resp. in_drive which was used with the + preparation call. + @param output_drive The out_drive used with isoburn_prepare_new_image(), + NULL if none. + @param flag Bitfield, submit 0 for now. + @return <=0 error , 1 = success +*/ +int isoburn_sync_after_write(struct burn_drive *input_drive, + struct burn_drive *output_drive, int flag); + + +#if 0 +/* >>> NOT YET IMPLEMENTED <<< */ +/** Write a new session to a disc. + This is a synchronous call equivalent to isoburn_prepare_disc + + isoburn_disc_write + isoburn_activate_session + @param pacifier_func If not NULL: a function to produce appeasing messages. + See burn_abort_pacifier() in libburn.h for an example. +*/ +/* TODO implement this */ +int isoburn_perform_write(struct burn_write_opts *o, + int (*pacifier_func)(void *handle, int patience, + int elapsed)); +#endif /* 0 */ + + +/** Release an aquired drive. + Wrapper for: burn_drive_release() + @since 0.1.0 + @param drive The drive to be released + @param eject 1= eject media from drive , 0= do not eject +*/ +void isoburn_drive_release(struct burn_drive *drive, int eject); + + +/** Shutdown all three libraries. + Wrapper for : iso_finish() and burn_finish(). + @since 0.1.0 +*/ +void isoburn_finish(void); + + +/* + The following calls are for expert applications only. + An application should have a special reason to use them. +*/ + + +/** Inquire wether the media needs emulation or would be suitable for + generic multi-session via libburn. + @since 0.1.0 + @param d The drive to inquire + @return 0 is generic multi-session + 1 is emulated multi-session + -1 is not suitable for isoburn +*/ +int isoburn_needs_emulation(struct burn_drive *drive); + + diff --git a/libisoburn/branches/ZeroOneFour/test/compare_file.c b/libisoburn/branches/ZeroOneFour/test/compare_file.c new file mode 100644 index 00000000..2d460f54 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/test/compare_file.c @@ -0,0 +1,275 @@ +/* + Compare two copies of a file object in as many aspects as i can imagine + to make sense. (E.g.: comparing atime makes no sense.) + + To compare tree /media/dvd and /original/dir : + find /media/dvd -exec compare_file '{}' /media/dvd /original/dir ';' + + Copyright 2008 Thomas Schmitt, + + Provided under GPL version 2. + + + cc -g -o compare_file compare_file.c +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* @param flag bit0= single letters */ +char *Ftypetxt(mode_t st_mode, int flag) +{ + if(flag&1) + goto single_letters; + if(S_ISDIR(st_mode)) + return("directory"); + else if(S_ISREG(st_mode)) + return("regular_file"); + else if(S_ISLNK(st_mode)) + return("symbolic_link"); + else if(S_ISBLK(st_mode)) + return("block_device"); + else if(S_ISCHR(st_mode)) + return("char_device"); + else if(S_ISFIFO(st_mode)) + return("name_pipe"); + else if(S_ISSOCK(st_mode)) + return("unix_socket"); + return("unknown"); +single_letters:; + if(S_ISDIR(st_mode)) + return("d"); + else if(S_ISREG(st_mode)) + return("-"); + else if(S_ISLNK(st_mode)) + return("l"); + else if(S_ISBLK(st_mode)) + return("b"); + else if(S_ISCHR(st_mode)) + return("c"); + else if(S_ISFIFO(st_mode)) + return("p"); + else if(S_ISSOCK(st_mode)) + return("s"); + return("?"); +} + + +char *Ftimetxt(time_t t, char timetext[40], int flag) +{ + char *rpt; + struct tm tms, *tmpt; + static char months[12][4]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + + tmpt= localtime_r(&t, &tms); + rpt= timetext; + rpt[0]= 0; + if(tmpt==0) + sprintf(rpt+strlen(rpt), "%12.f", (double) t); + else if(time(NULL)-t < 180*86400 && time(NULL)-t >= 0) + sprintf(rpt+strlen(rpt), "%3s %2d %2.2d:%2.2d", + months[tms.tm_mon], tms.tm_mday, tms.tm_hour, tms.tm_min); + else + sprintf(rpt+strlen(rpt), "%3s %2d %4.4d", + months[tms.tm_mon], tms.tm_mday, 1900+tms.tm_year); + return(timetext); +} + + +/* @param flag bit0= compare atime + bit1= compare ctime +*/ +int Compare_2_files(char *adr1, char *adr2, char *adrc, int flag) +{ + struct stat s1, s2; + int ret, differs= 0, r1, r2, fd1= -1, fd2= -1, i, done; + char buf1[4096], buf2[4096], a[4096], ttx1[40], ttx2[40]; + off_t r1count= 0, r2count= 0, diffcount= 0, first_diff= -1; + + ret= lstat(adr1, &s1); + if(ret==-1) { + printf("? %s : cannot lstat() : %s\n", adr1, strerror(errno)); + return(0); + } + strcpy(a, Ftypetxt(s1.st_mode, 1)); + strcat(a, " "); + if(adrc[0]) + strcat(a, adrc); + else + strcat(a, "."); + + ret= lstat(adr2, &s2); + if(ret==-1) { + printf("? %s : cannot lstat() : %s\n", adr2, strerror(errno)); + return(0); + } + + /* Attributes */ + if(s1.st_mode != s2.st_mode) { + if((s1.st_mode&~S_IFMT)!=(s2.st_mode&~S_IFMT)) + printf("%s : st_mode : %7.7o <> %7.7o\n", a, s1.st_mode, s2.st_mode); + if((s1.st_mode&S_IFMT)!=(s2.st_mode&S_IFMT)) + printf("%s : type : %s <> %s\n", + a, Ftypetxt(s1.st_mode, 0), Ftypetxt(s2.st_mode, 0)); + differs= 1; + } + if(s1.st_uid != s2.st_uid) { + printf("%s : st_uid : %d <> %d\n", a, s1.st_uid, s2.st_uid); + differs= 1; + } + if(s1.st_gid != s2.st_gid) { + printf("%s : st_gid : %d <> %d\n", a, s1.st_gid, s2.st_gid); + differs= 1; + } + if((S_ISCHR(s1.st_mode) && S_ISCHR(s2.st_mode)) || + (S_ISBLK(s1.st_mode) && S_ISBLK(s2.st_mode))) { + if(s1.st_rdev != s2.st_rdev) { + printf("%s : %s st_rdev : %lu <> %lu\n", a, + (S_ISCHR(s1.st_mode) ? "S_IFCHR" : "S_IFBLK"), + (unsigned long) s1.st_rdev, (unsigned long) s1.st_rdev); + differs= 1; + } + } + if(S_ISREG(s2.st_mode) && s1.st_size != s2.st_size) { + printf("%s : st_size : %.f <> %.f diff= %.f\n", + a, (double) s1.st_size, (double) s2.st_size, + ((double) s1.st_size) - (double) s2.st_size); + differs= 1; + } + if(s1.st_mtime != s2.st_mtime) { + printf("%s : st_mtime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_mtime, ttx1, 0), + Ftimetxt(s2.st_mtime, ttx2, 0), + ((double) s1.st_mtime) - (double) s2.st_mtime); + differs= 1; + } + if(flag&1) { + if(s1.st_atime != s2.st_atime) { + printf("%s : st_atime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_atime, ttx1, 0), + Ftimetxt(s2.st_atime, ttx2, 0), + ((double) s1.st_atime) - (double) s2.st_atime); + differs= 1; + } + } + if(flag&2) { + if(s1.st_ctime != s2.st_ctime) { + printf("%s : st_ctime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_ctime, ttx1, 0), + Ftimetxt(s2.st_ctime, ttx2, 0), + ((double) s1.st_ctime) - (double) s2.st_ctime); + differs= 1; + } + } + if(S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)) { + fd1= open(adr1, O_RDONLY); + if(fd1==-1) { + printf("- %s : cannot open() : %s\n", adr1, strerror(errno)); + return(0); + } + fd2= open(adr2, O_RDONLY); + if(fd2==-1) { + printf("- %s : cannot open() : %s\n", adr2, strerror(errno)); + close(fd1); + return(0); + } + + /* Content */ + done= 0; + while(!done) { + r1= read(fd1, buf1, sizeof(buf1)); + r2= read(fd2, buf2, sizeof(buf2)); + if((r1==EOF && r2==EOF) || (r1==0 && r2==0)) + break; + if(r1==EOF || r1==0) { + if(r1==EOF) + r1= 0; + if(s1.st_size > r1count + r1) + printf("- %s : early EOF after %.f bytes\n", adr1, (double) r1count); + differs= 1; + } + r1count+= r1; + if(r2==EOF || r2 r2count + r2) + printf("- %s : early EOF after %.f bytes\n", adr2, (double) r2count); + differs= 1; + done= 1; + } + if(r2>r1) { + if(s1.st_size > r1count + r1) + printf("- %s : early EOF after %.f bytes\n", adr1, (double) r1count); + differs= 1; + done= 1; + } + r2count+= r2; + if(r1>r2) + r1= r2; + for(i= 0; i0 || r1count!=r2count) { + if(first_diff<0) + first_diff= (r1count>r2count ? r2count : r1count); + printf("%s : %s : differs by at least %.f bytes. First at %.f\n", a, + (s1.st_mtime==s2.st_mtime ? "CONTENT":"content"), + (double) (diffcount + abs(r1count-r2count)), (double) first_diff); + differs= 1; + } + } + if(fd1!=-1) + close(fd1); + if(fd2!=-1) + close(fd2); + return(!differs); +} + + +int main(int argc, char **argv) +{ + int ret, i, with_ctime= 1; + char adr1[4096], adr2[4096], adrc[4096]; + + if(argc<4) { + fprintf(stderr, "usage: %s path prefix1 prefix2\n", argv[0]); + exit(2); + } + for(i= 4; i + and Thomas Schmitt +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include "../src/libisoburn.h" + +const char * const optstring = "JRh"; +extern char *optarg; +extern int optind; + + +/** Activates the usage of function graft_point() rather than + plain iso_tree_radd_dir() from libisofs +*/ +#define With_graft_poinT 1 + + +static int graft_point(struct iso_volume *volume, const char *disk_path, + const char *img_path, struct iso_tree_radd_dir_behavior *behav) +{ + char path[4096], *apt, *npt; + struct iso_tree_node_dir *dir; + struct iso_tree_node *node; + int done= 0, is_dir= 0; + struct stat stbuf; + + strncpy(path, img_path, sizeof(path)-1); + path[sizeof(path)-1]= 0; + apt= npt= path; + + if(lstat(disk_path, &stbuf) == -1) { + fprintf(stderr, "Cannot determine attributes of '%s' : %s (%d)\n", + disk_path, (errno > 0 ? strerror(errno) : "unknown error"), errno); + return(0); + } + if(S_ISDIR(stbuf.st_mode)) + is_dir= 1; + else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) { + fprintf(stderr, "File object '%s' is of non-supported file type\n", + disk_path); + return(0); + } + + dir= iso_volume_get_root(volume); + if(dir==NULL) { + fprintf(stderr, "While grafting '%s' : no root node available\n", img_path); + return(0); + } + for(npt= apt; !done; apt= npt+1) { + npt= strchr(apt, '/'); + if(npt==NULL) { + npt= apt+strlen(apt); + done= 1; + } else + *npt= 0; + if(*apt==0) { + *apt= '/'; + apt++; + continue; + } + node= iso_tree_volume_path_to_node(volume,path); + if(node!=NULL) { + if(iso_tree_node_get_type(node)!=LIBISO_NODE_DIR) { + fprintf(stderr, "While grafting '%s' : '%s' is not a directory\n", + img_path, path); + return(0); + } + dir= (struct iso_tree_node_dir *) node; + } else { + dir= iso_tree_add_dir(dir, apt); + if(dir==NULL) { + fprintf(stderr, "While grafting '%s' : could not insert '%s'\n", + img_path, path); + return(0); + } + } + if(done) { + if(is_dir) { + iso_tree_radd_dir(dir, disk_path, behav); + } else { + node= iso_tree_add_node(dir, disk_path); + if(node == NULL) { + fprintf(stderr, "While grafting '%s'='%s' : libisofs_errno = %d\n", + img_path, disk_path, libisofs_errno); + } + } + } else + *npt= '/'; + } + fprintf(stderr, "NOTE: added %s '%s'='%s'\n", (is_dir ? "directory" : "node"), + img_path, disk_path); + return(1); +} + + +static +void usage() +{ + printf("test [OPTIONS] DRIVE DIRECTORY\n"); +} + +static +void help() +{ + printf( +"Options:\n" +" -J Add Joliet support\n" +" -R Add Rock Ridge support\n" +" -h Print this message\n" +); +} + +int main(int argc, char **argv) +{ + struct burn_drive_info *drives; + struct iso_volset *volset; + struct burn_drive *drive; + struct burn_disc *disc; + enum burn_disc_status state; + struct isoburn_read_opts ropts; + struct isoburn_source_opts sopts; + int c; + struct iso_tree_radd_dir_behavior behav = {0,0,0}; + int flags=0; + int ret=0, i; + int size, free_bytes; + char *status_text; + + while ((c = getopt(argc, argv, optstring)) != -1) { + switch(c) { + case 'h': + usage(); + help(); + exit(0); + break; + case 'J': + flags |= ECMA119_JOLIET; + break; + case 'R': + flags |= ECMA119_ROCKRIDGE; + break; + case '?': + usage(); + exit(1); + break; + } + } + + if (argc < optind + 1) { + fprintf(stderr, "Please supply device name\n"); + usage(); + exit(1); + } + if (argc < optind + 2) { + fprintf(stderr, "Please supply directory to add to disc\n"); + usage(); + exit(1); + } + + + if (!isoburn_initialize()) { + fprintf(stderr, "Can't init libisoburn\n"); + exit(1); + } + + /* TODO change this. maybe we can add wrapp in libisoburn */ + iso_msgs_set_severities("NEVER", "DEBUG", "libisofs : "); + burn_msgs_set_severities("NEVER", "DEBUG", "libburn : "); + burn_set_signal_handling("libisoburn/test/test : ", NULL, 0); + + printf("Growing drive %s\n", argv[optind]); + + if (isoburn_drive_scan_and_grab(&drives, argv[optind], 1) <= 0) { + fprintf(stderr, + "Can't open device. Are you sure it is a valid drive?\n"); + exit(1); + } + drive = drives[0].drive; + + /* check for invalid state */ + state = isoburn_disc_get_status(drive); + if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) { + fprintf(stderr, "Unsuitable disc status\n"); + goto exit_cleanup; + } + + /* fill read opts */ + memset(&ropts, sizeof(ropts), 0); + ropts.norock = 0; + ropts.nojoliet = 0; + ropts.preferjoliet = 0; + ropts.uid = 0; + ropts.gid = 0; + ropts.mode = 0555; + ropts.pretend_blank= 0; + + if (isoburn_read_volset(drive, &ropts, &volset) <= 0) { + fprintf(stderr, "Can't read volset\n"); + goto exit_cleanup; + } + + +#ifdef With_graft_poinT + for (i = optind + 1; i < argc; i++) { + if (graft_point(iso_volset_get_volume(volset, 0), + argv[i], argv[i], &behav) <= 0) { + fprintf(stderr, "Canot graft '%s'\n", argv[optind+1]); + goto exit_cleanup; + } + } + +#else + struct iso_tree_node_dir *root; + root = iso_volume_get_root(iso_volset_get_volume(volset, 0)); + /* add a new dir */ + iso_tree_radd_dir(root, argv[optind+1], &behav); +#endif /* ! With_graft_poinT */ + + + sopts.level = 2; + sopts.flags = flags; + sopts.relaxed_constraints = 0; + sopts.copy_eltorito = 1; + sopts.no_cache_inodes = 0; + sopts.sort_files = 1; + sopts.default_mode = 0; + sopts.replace_dir_mode = 0; + sopts.replace_file_mode = 0; + sopts.replace_uid = 0; + sopts.replace_gid = 0; + sopts.dir_mode = 0555; + sopts.file_mode = 0444; + sopts.gid = 0; + sopts.uid = 0; + sopts.input_charset = NULL; + sopts.ouput_charset = NULL; + + if (isoburn_prepare_disc(drive, &disc, &sopts) <= 0) { + fprintf(stderr, "Can't prepare disc\n"); + goto volset_cleanup; + } + + /* a. write the new image */ + printf("Adding new data...\n"); + { + struct burn_write_opts *burn_options; + struct burn_progress progress; + + burn_options = burn_write_opts_new(drive); + burn_drive_set_speed(drive, 0, 0); + burn_write_opts_set_underrun_proof(burn_options, 1); + + /* ok, write the new track */ + isoburn_disc_write(burn_options, disc); + burn_write_opts_free(burn_options); + + while (burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING) + usleep(100002); + + while (burn_drive_get_status(drive, &progress) + != BURN_DRIVE_IDLE) { + + printf("Writing: sector %d of %d", + progress.sector, progress.sectors); + ret = isoburn_get_fifo_status(drive, &size, + &free_bytes, &status_text); + if (ret > 0 ) + printf(" [fifo %s, %2d%% fill]", status_text, + (int) (100.0 - 100.0 * + ((double) free_bytes) / + (double) size)); + printf("\n"); + sleep(1); + } + } + + /* b. write the new vol desc */ + printf("Writing the new vol desc...\n"); + if (isoburn_activate_session(drive) <= 0) { + fprintf(stderr, "Ups, new vol desc write failed\n"); + } + + ret= 0; +volset_cleanup:; +/* + iso_volset_free(volset); +*/ + +exit_cleanup:; + isoburn_drive_release(drive, 0); + isoburn_finish(); + + exit(ret); +} + diff --git a/libisoburn/branches/ZeroOneFour/version.h.in b/libisoburn/branches/ZeroOneFour/version.h.in new file mode 100644 index 00000000..cf529233 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/version.h.in @@ -0,0 +1,6 @@ + +/* <<< this file is on its way out +#define ISOBURN_MAJOR_VERSION @ISOBURN_MAJOR_VERSION@ +#define ISOBURN_MINOR_VERSION @ISOBURN_MINOR_VERSION@ +#define ISOBURN_MICRO_VERSION @ISOBURN_MICRO_VERSION@ +*/ diff --git a/libisoburn/branches/ZeroOneFour/xorriso/README b/libisoburn/branches/ZeroOneFour/xorriso/README new file mode 100644 index 00000000..5963be24 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/README @@ -0,0 +1,205 @@ +------------------------------------------------------------------------------ + libburnia-project.org scdbackup.sourceforge.net/xorriso_eng.html +------------------------------------------------------------------------------ +xorriso. By Thomas Schmitt +Integrated sub project of libburnia-project.org but also published via: +http://scdbackup.sourceforge.net/xorriso_eng.html +http://scdbackup.sourceforge.net/xorriso-0.1.3.tar.gz +Copyright (C) 2006-2008 Thomas Schmitt, provided under GPL version 2. +------------------------------------------------------------------------------ + + +xorriso is a program which maps file objects from POSIX compliant +filesystems into Rock Ridge enhanced ISO 9660 filesystems and allows +session-wise manipulation of such filesystems. It can load the management +information of existing ISO images and it writes the session results to +optical media or to filesystem objects. + +Currently it is only supported on Linux with kernels >= 2.4. + +A special property of xorriso is that it needs neither an external ISO 9660 +formatter program nor an external burn program for CD or DVD but rather +incorporates the libraries of libburnia-project.org . + +By using this software you agree to the disclaimer at the end of this text: +"... without even the implied warranty ..." + + + Compilation, First Glimpse, Installation + +The most simple way to get xorriso from source code is the xorriso standalone +tarball. + +Prerequisites: +The tarball contains anything that is needed except libc and libpthread. +libreadline and the readline-dev headers will make dialog mode more convenient, +but are not mandatory. + +Obtain xorriso-0.1.3.tar.gz, take it to a directory of your choice and do: + + tar xzf xorriso-0.1.3.tar.gz + cd xorriso-0.1.3 + +Within that directory execute: + + ./configure --prefix=/usr + make + +This will produce a binary named + ./xorriso/xorriso + +which you may strip to reduce it in size + strip ./xorriso/xorriso + +You may copy or move it to a directory where it can be found by the shell, +you may execute xorriso at the place where it was built, or you may execute +as superuser: + make install + +For general concepts, options and usage examples see + man 1 xorriso + +This man page is part of the tarball as + xorriso/xorriso.1 +You may get a first glimpse by + man ./xorriso/xorriso.1 + +It gets installed with "make install" but may also be placed manually in the +./man1 directory below one of the directories mentioned in environment +variable $MANPATH. + + + Drives and Disk File Objects + +The user of xorriso needs rw-permission for the CD burner device. +A list of rw-accessible drives can be obtained by + + xorriso -devices + +CD devices which offer no rw-permission are invisible to normal users. +The superuser should be able to see any usable drive and then set the +permissions as needed. + +The output of xorriso -devices might look like + +0 -dev '/dev/sr0' rwrw-- : 'TSSTcorp' 'CDDVDW SH-S203B' +1 -dev '/dev/hda' rwrw-- : 'HL-DT-ST' 'DVD-ROM GDR8162B' + +Full and insecure enabling of both for everybody would look like + chmod a+rw /dev/sr0 /dev/hda +This is equivalent to the traditional setup chmod a+x,u+s cdrecord. + +I strongly discourage to run xorriso with setuid root or via sudo ! +It is not checked for the necessary degree of hacker safety. + +Consider to put all authorized users into group "floppy", to chgrp the +device file to that group and to disallow w-access to others. + + +A possible source of problems are hald or other automounters. +If you can spot a process "hald-addon-storage" with the address of +your desired drive, then consider to kill it. + +If you cannot get rid of the automounter that easily, try whether it helps +to always load the drive tray manually before starting a write run of +xorriso. Wait until the drive light is off. +Better try to unmount an eventually mounted media before a write run. + + +Besides true optical drives, xorriso can also address disk files as input or +output drives. The addresses of the disk files have to be preceded by "stdio:". +Like: + xorriso -dev stdio:/tmp/pseudo_drive ...more arguments... + + + Testing + +We are quite sure that libisofs produces accurate representations of the disk +files. This opinion is founded on a lot of test burns and checks by a little +test program which compares files from the mounted image with the orignals +on disk. It uses the normal POSIX filesystem calls, i.e. no libburnia stuff. + +This program is not installed systemwide but stays in the installation +directory of the xorriso tarball as test/compare_file . Usually it is +run as -exec payload of a find command. It demands at least three arguments: +The path of the first file to compare, the prefix1 to be cut off from path +and the prefix2 which gets prepended afterwards to obtain the path of the +second file to compare. +As further argument there can be -no_ctime which suppresses the comparison +of ctime date stamps. +The exit value is 0 if no difference was detected, non-0 else. + +Example: After + xorriso ... -pathspecs on -add /=/original/dir -- -commit_eject all + mount /media/dvd + cd test +compare tree /media/dvd with tree /original/dir : + find /original/dir -exec ./compare_file '{}' /original/dir /media/dvd ';' \ + | less +and vice versa: + find /media/dvd -exec ./compare_file '{}' /media/dvd /original/dir ';' \ + | less + + + libisoburn + +xorriso is based on libisofs which does ISO 9600 filesystem aspects and on +libburn which does the input and output aspects. Parts of this foundation +are accessed via libisoburn, which is closely related to xorriso. + +libisoburn provides two services: +- Encapsulation of coordination between libisofs and libburn. +- Emulation of ISO 9660 multi-session on overwriteable media + or random access files. + +The sourcecode of all three libraries is included in the xorriso standalone +tarball. It is compiled with xorriso and linked statically. +But you may as well get and install releases of libburn and libisofs, in order +to be able to install a release of libisoburn which produces libisoburn.so.1 +and a matching dynamically linked xorriso binary. +This binary is leaner but depends on properly installed libraries of suitable +revision. + +WARNING: There is no libisoburn-0.1.2 suitable for dynamic linking because +libisoburn-0.1.1 uses features of libisofs-0.6.3 of which the API/ABI is +not decared frozen yet. + +Dynamic library and compile time header requirements for libisoburn-0.1.3 : +- libburn.so.4 , version libburn-0.4.2 or higher +- libisofs.so.6 , version libisofs-0.6.3 or higher +libisoburn and xorriso will not start with libraries which are older than their +headers seen at compile time. So compile in the oldest possible installation +setup unless you have reason to enforce a newer bug fix level. + +Standalone xorriso has less runtime dependencies and can be moved more freely. + + +------------------------------------------------------------------------------ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + 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 + +------------------------------------------------------------------------------ +Based on and sub project of: +libburnia-project.org +By Mario Danic , + Vreixo Formoso + Thomas Schmitt +Copyright (C) 2006-2008 Mario Danic, Vreixo Formoso, Thomas Schmitt. + +libburnia-project.org is inspired by and in other components still containing +parts of old +Libburn. By Derek Foreman and + Ben Jansens +Copyright (C) 2002-2006 Derek Foreman and Ben Jansens + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/changelog.txt b/libisoburn/branches/ZeroOneFour/xorriso/changelog.txt new file mode 100644 index 00000000..6f0fc82f --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/changelog.txt @@ -0,0 +1,2144 @@ +------------------------------------------------------------------------------ + libburnia-project.org libisoburn , xorriso +------------------------------------------------------------------------------ + +------------------------------------------------------------------------------ + Changelog +------------------------------------------------------------------------------ + + +1 Sep 2007 [983] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +libisoburn/isofs_wrap.c +Initial content of libisoburn + +1 Sep 2007 [985] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +Should have used copy+paste when writing Vreixos name + +5 Sep 2007 [990] +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Implemented use of stdio-pseudo-drives + +5 Sep 2007 [993] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Changes in plans as discussed up to Sep 5 2007 + +5 Sep 2007 [994] +libisoburn/libisoburn.h +Updated explanations about the usage principles of libisoburn + +6 Sep 2007 [998] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Updated to state of discussion + +9 Sep 2007 [1025] +libisoburn/burn_wrap.c +New wrapper isoburn_disc_erasable() declares ISO DVD-RAM, DVD+RW erasable + +10 Sep 2007 [1027] +libisoburn/libisoburn.h +New wrapper isoburn_disc_erasable() declares ISO DVD-RAM, DVD+RW erasable + +11 Sep 2007 [1029] +libisoburn/burn_wrap.c +libisoburn/isoburn.h +New inner function isoburn_set_start_byte() + +12 Sep 2007 [1031] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +Removed isoburn_write_opts_set_start_byte() + +13 Sep 2007 [1043] +libisoburn/burn_wrap.c +Took into respect fabricated_disc_status + +21 Sep 2007 [1092] +Makefile.am +Removed libburn file addresses + +22 Sep 2007 [1093] ++ doc/doxygen.conf.in +Added file demanded by build system + +22 Sep 2007 [1094] +src/burn_wrap.c +Prevented SIGSEGV in isoburn_drive_scan_and_grab() + +22 Sep 2007 [1095] +src/burn_wrap.c +Enabled treatment==2 in isoburn_drive_scan_and_grab() + +22 Sep 2007 [1099] +src/burn_wrap.c +Made use of burn_msgs_submit() for error messages + +23 Sep 2007 [1102] +src/burn_wrap.c +Removed all references to isoburn.treatment from burn_wrap.c + +23 Sep 2007 [1105] +src/burn_wrap.c +Called isoburn_create_data_source() and isoburn_free_data_source() + +28 Sep 2007 [1129] libisofs +libisofs/libiso_msgs.h +Removed apostrophes which my compiler does not like + +29 Sep 2007 [1133] +src/burn_wrap.c +Added optional code for a pseudo CD-RW to test the code for MMC multi-session + +29 Sep 2007 [1134] +src/burn_wrap.c +Released drive in case welcome_media fails + +1 Oct 2007 [1141] +src/burn_wrap.c +Allowed isoburn_disc_get_msc1() for closed media + +2 Oct 2007 [1149] +test/test.c +Function graft_point(),some general polishing, call of iso_volset_free disabled + +8 Oct 2007 [1169] +src/libisoburn.h +src/isoburn.h +src/isoburn.c +src/burn_wrap.c +Introduced fifo reference into isoburn object + +8 Oct 2007 [1170] +test/test.c +Several directories and files in one session, added display of fifo + +12 Oct 2007 [1171] ++ test/xorriso.h ++ test/xorriso.c ++ test/xorriso.txt +The stub of new application xorriso + +12 Oct 2007 [1172] ++ test/compile_xorriso.sh ++ test/make_timestamp.sh ++ test/xorriso_timestamp.h +A build facility to circumvent autotools during development + +12 Oct 2007 [1173] +test/xorriso.c +Introduced version and build timestamps, library headers + +13 Oct 2007 [1174] +test/xorriso.c ++ test/changelog.txt +Made -dialog and -options_from_file work + +2007.10.13.141503 [1175] +test/xorriso.c +Implemented -speed and enlarged -status list + +2007.10.13.152252 [1176] +test/xorriso.c +test/xorriso.txt +Implemented xorriso setter level of -fs, -gid, -uid + +2007.10.14.110003 [1177] +test/xorriso.c +Implemented setter level of -abort_on, fixed bugs about -f,-no_rc,startup files + +2007.10.14.122456 [1178] +test/xorriso.c ++ test/xorriso_private.h ++ test/xorrisoburn.h ++ test/xorrisoburn.c +Began to implement interface to our libraries + +2007.10.15.152705 [1183] +test/xorriso.h +test/xorriso.c +test/xorriso_private.h +test/xorrisoburn.h +test/xorrisoburn.c +Implemented -dev, -add, -commit + +2007.10.15.160303 [1184] +test/xorriso.c +Made -end give up drives + +2007.10.15.203554 [1185] +test/xorriso.c +Some safety precautions against malicious input, enabled -cdx, -cdi for -add + +2007.10.15.203714 [1186] +test/xorrisoburn.c +Corrected image path bug with -add of regular files, and -add /=/some/dir + +2007.10.15.224005 [1187] +test/xorriso.c +test/xorrisoburn.c +Implemented -rollback + +2007.10.16.210911 [1188] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Worked on failure severities, message system, program abort decision + +2007.10.17.130041 [1190] [1191 +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Worked on failure severities, message system, program abort decision + +2007.10.17.130311 [1192] +src/isofs_wrap.c +Told burn_read_data() to stay silent on non-existent drive or read error + +2007.10.17.150142 [1193] +test/xorriso.c +test/xorrisoburn.c +Reinstated the distinction of message sources, respected '#' in dialog + +2007.10.17.165352 [1194] +test/xorriso.c +Prepended a "-" to any input line if missing + +2007.10.17.183024 [1195] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Implemented core of option -toc + +2007.10.17.200241 [1196] +test/xorrisoburn.c +Continued work with -toc + +2007.10.17.213852 [1197] +test/compile_xorriso.sh +Forgot to make off_t 64 bit + +2007.10.17.214228 [1198] +src/libisoburn.h +src/burn_wrap.c +test/xorrisoburn.c +Rounding up fabricated nwa to full 32k addresses, API call for exact image size + +2007.10.17.215809 [1199] +test/xorriso.c +Activated -ban_stdio_write + +2007.10.17.224924 [1200] +test/xorrisoburn.c +Fixed obvious bug with -J. (Still wondering wether it works) + +2007.10.17.225039 [1201] +test/xorriso.c +Fixed bug with -speed. + +2007.10.17.225837 [1202] +test/xorriso.c +Fixed bug with -prompt. Fixed bug with # comments. (of rev 1194) + +18 Oct 2007 [1203] +test/changelog.txt +Updated changelog and todo list + +2007.10.18.144841 [1205] +src/isofs_wrap.c +test/xorrisoburn.c +isoburn_read_volset() now hands out an official volset reference + +2007.10.18.171415 [1206] +test/xorriso.c +test/xorriso.txt +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -devices + +2007.10.18.183200 [1207] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -tell_media_space + +2007.10.18.185731 [1208] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +Fixed a SIGSEGV with xorriso -version run + +2007.10.18.221756 [1211] +test/xorrisoburn.c +src/libisoburn.h +Took care of disposal of burn_disc ovbject + +18 Oct 2007 [1212] +test/test.c +Silenced compile warning + +2007.10.18.225654 [1213] +src/isofs_wrap.c +test/xorriso.c +test/xorrisoburn.c +Fixed a SIGSEGV with empty drive + +2007.10.19.140031 [1218] +test/xorrisoburn.c +Made reports with -add normal infos (formerly NOTE events) + +2007.10.19.151339 [1219] +test/xorriso.c +test/xorrisoburn.c +test/xorriso.txt +Implemented -print-size + +2007.10.19.164957 [1220] +test/xorriso_private.h +test/xorriso.c +test/xorriso.h +test/xorrisoburn.c +test/xorriso.txt +Implemented verbosity control by option -report_about + +2007.10.19.173547 [1221] +test/xorriso.c +test/xorrisoburn.c +test/xorriso.txt +Implemented option -eject + +2007.10.19.204155 [1222] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -blank + +2007.10.20.170731 [1223] +src/burn_wrap.c +Directed write mode failure message to libburn queue, repaired wrote_well + +2007.10.20.171046 [1224] +test/xorrisoburn.c +test/xorriso_private.h +test/xorriso.c +Implemented options -format and -blank deformat, -close and closed media + +20 Oct 2007 [1225] +test/xorriso.txt ++ test/xorriso.1 +test/changelog.txt +Splitted think text from emerging man page, formatted man page + +2007.10.20.194918 [1226] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Completed -tell_media_space, checked space before burn, failed -end exits >0 + +20 Oct 2007 [1227] +test/xorriso.1 +Polished man page + +2007.10.21.094818 [1228] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented -rm and -rm_r + +2007.10.21.105228 [1229] +src/data_source.c +Silenced compiler warning about C++ style comment + +2007.10.21.124315 [1230] +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +Began to implement -ls and -ls_l, enhanced -cdi, not done yet + +2007.10.21.151124 [1231] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +Hopefully completed -cd alias -cdi + +2007.10.21.185248 [1232] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Hopefully completed -cdx + +2007.10.21.213303 [1233] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented sorting of -ls by node name, implemented leaf name search patterns + +2007.10.22.211928 [1237] +test/xorrisoburn.c +test/xorriso.1 +Implemented file size and mtime for -ls_l + +2007.10.23.122349 [1238] +src/libisoburn.h +src/isoburn.c +Added fifo_size to struct isoburn_source_opts + +2007.10.23.122753 [1239] +test/xorrisoburn.c +test/xorriso.c +test/xorriso.1 +Made use of isoburn_source_opts.fifo_size + +2007.10.24.100156 [1244] +test/xorriso.c +test/xorrisoburn.c +Normalized paths to target and source before adding or removing from image + +2007.10.24.105424 [1245] +test/xorriso.c +test/xorriso.h +Implemented option -path-list + +2007.10.24.175337 [1247] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Made -cd useable with no image loaded + +2007.10.27.224148 [1257] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented option -mv + +2007.10.27.230512 [1258] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Bug fixes with option -mv + +2007.10.28.125501 [1260] +test/xorriso.c +test/xorrisoburn.c +Prevented some interesting pitfalls with -mv + +2007.10.28.165516 [1261] +test/xorriso.c +test/xorriso.1 +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -mkdir + +2007.10.28.174550 [1262] +test/xorriso.c +Warning of wildcards in paths + +28 Oct 2007 [1263] +test/xorriso.1 +Updated man page about -path-list + +2007.10.29.213920 [1273] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Structured patterns for options -ls and -ls_l + +2007.10.30.214242 [1274] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +test/compile_xorriso.sh +Multiple structured patterns, changed option -ls from single to multi args + +2007.10.31.103338 [1275] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented new option -temp_mem_limit + +2007.10.31.165413 [1276] +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +Gave simple -ls an implemention with minimal memory consumption + +31 Oct 2007 [1277] +test/xorriso.1 +Overhauled info paragraphs of man page + +2007.10.31.175916 [1278] +test/xorriso_private.h +Overhauled comments in struct XorrisO + +31 Oct 2007 [1279] +test/changelog.txt +Updating changelog + +2007.11.01.111351 [1280] +test/xorrisoburn.c +Got rid of bad pacifier text at end of CD writing + +2007.11.01.191106 [1281] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +test/xorriso.1 +Implemented option -du + +2007.11.02.143549 [1282] +test/xorrisoburn.h +test/xorrisoburn.c +Clearer status messages after reading new volume and after burning + +2007.11.02.143658 [1283] +test/xorriso.c +Made -abort_on and -report_about complain with bad severity names + +2007.11.02.184705 [1284] +test/xorrisoburn.c +test/xorriso.1 +Polished write success message and man page + +2007.11.06.163305 [1285] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented -overwrite control + +2007.11.06.163929 [1286] +src/libisoburn.h +Corrected a typo in a comment + +2007.11.06.164029 [1287] +src/isoburn.c +Closed memory leak by freeing session and track in isoburn_prepare_disc_aux() + +2007.11.07.123744 [1288] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented option -reassure + +2007.11.07.150157 [1289] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented option -rmdir + +2007.11.07.191915 [1290] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -chmod (does not get written into image, though) + +2007.11.07.225624 [1291] +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +Implemented options -chown and -chgrp (not written into image, though) + +2007.11.08.144451 [1292] +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +test/xorriso.1 +Implemented option -alter_date, corrected write problem with mode and ownership + +2007.11.08.145016 [1293] +test/xorriso_private.h +Forgotten source file for rev 1292 + +8 Nov 2007 [1294] +test/xorriso.1 +Enhanced man page text for options -chmod, -chown, -chgrp + +2007.11.08.160302 [1295] +test/xorriso.c +Fixed bug with -chmod go=r + +2007.11.08.161215 [1296] +test/xorriso.c +test/xorrisoburn.c +Enlarged string size limit of Text_shellsafe() + +2007.11.09.193142 [1297] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +New option -iso_rr_pattern, influencing several options with multiple args + +2007.11.11.112321 [1298] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +Gave problem handling finer granularity within loops + +11 Nov 2007 [1299] +test/xorriso.1 +Clarified man page + +2007.11.11.154453 [1300] +test/xorriso.c +Added missing commit to normal end of program + +11 Nov 2007 [1301] +test/xorriso.1 +Added some examples to man page + +2007.11.14.142904 [1302] +src/libisoburn.h +src/isofs_wrap.c +src/isoburn.c +test/test.c +New API call isoburn_attach_volset(), changes with isoburn_read_volset() + +2007.11.14.143119 [1303] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented options -outdev and -indev + +2007.11.14.175446 [1304] +test/xorriso.c +Corrected premature abort bug with misspelled command words + +14 Nov 2007 [1305] +test/xorriso.1 +Polished xorriso man page + +14 Nov 2007 [1306] +test/changelog.txt +Updated xorriso changelog + +2007.11.26.192113 [1311] +test/xorriso.c +test/xorrisoburn.c +Reacted on warnings on a 64 bit system + +2007.12.04.074340 [1314] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented -disk_pattern, -lsx, ls_lx, -dux, -du_lx + +2007.12.04.205919 [1315] +test/xorrisoburn.c +test/xorriso_private.h +test/xorriso.c +Removed some redundancy of disk_pattern and iso_rr_pattern matching + +4 Dec 2007 [1316] +test/xorriso.1 +Polished man page + +2007.12.05.090438 [1317] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +Option -f-off as counterpart of option -f + +2007.12.05.143632 [1318] +test/xorriso.c +Made dashes at options optional + +5 Dec 2007 [1319] +test/xorriso.1 +Overhauled description of media types, states and expansion methods + +2007.12.06.150102 [1320] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +Changed -f, -f-off to -follow, -graft-points, -graf-points-off to -pathspecs + +6 Dec 2007 [1321] +test/xorriso.1 +Removed references to option -graft-points + +2007.12.06.192437 [1322] +test/xorriso.c +Corrected warning function about wildcards + +8 Dec 2007 [1326] +test/xorriso.1 +Explained result pager + +2007.12.08.175117 [1327] +test/xorriso.c +test/xorriso_private.h +test/xorrisoburn.c +Removed more code redundancies and fd leak with Xorriso_obtain_pattern_files_x() + +2007.12.15.162039 [1328] +test/compile_xorriso.sh +Added -O0 to -g to get better gdb behavior on my new system + +2007.12.15.183022 [1329] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented option -follow + +2007.12.16.103456 [1330] +test/xorriso.c +test/xorriso.1 +Added link hop limit to option -follow + +2007.12.16.122626 [1331] +test/xorrisoburn.c +Added copying of attributes from symbolic link into image + +2007.12.16.144615 [1332] +test/xorrisoburn.c +Removed waste of time in Xorriso_show_du_subs() + +2007.12.18.175924 [1333] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Changed options -ls* to -lsd*, introduced new family of -ls* without d + +2007.12.20.111338 [1334] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Changed -du_s* into -dus* + +2007.12.21.131538 [1335] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented option -find alias -findi + +2007.12.21.132017 [1336] +test/xorriso.c +test/xorriso.1 +Corrected documentation about -find + +2007.12.22.143803 [1337] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented option -findx + +2007.12.24.161107 [1339] +test/xorriso.c +Repaired options -dus and -dusx + +24 Dec 2007 [1340] +test/changelog.txt +Updated changelog + +2007.12.25.160100 [1341] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +Implemented option -cpr + +2007.12.26.160040 [1342] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Changed option -J to -joliet "on"|"off", implemented option -volid + +2007.12.28.132741 [1343] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +Made leaner the local memory of recursive functions (because of ulimit -s) + +2007.12.30.190138 [1344] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented -find option -exec echo, chown, chgrp, chmod, alter_date, lsdl + +2007.12.30.203336 [1345] +test/xorriso.c +Corrected superuser behavior of Sfile_lookup_permissions() + +2007.12.31.095229 [1346] +test/xorriso.c +test/xorrisoburn.c +Repaired some bugs in -find and -findx + +2007.12.31.135237 [1347] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +Implemented options -chown_r, -chgrp_r, -chmod_r, -alter_date_r + +2007.12.31.135330 [1348] +test/xorrisoburn.c +Repaired a bug in -find + +2008.01.01.123118 [1349] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented -find actions chown_r, chgrp_r, chmod_r, alter_date_r, find + +2008.01.02.175011 [1350] +test/xorriso.c +test/xorriso.1 +Implemented -find test -type + +2008.01.09.175418 [1351] +test/xorrisoburn.c +Corrections made during porting to nglibisofs + +2008.01.10.114451 [1352] ++ test/ng_xorrisoburn.h ++ test/ng_xorrisoburn.c +test/compile_xorriso.sh +Begin of porting to next generation libisofs + +2008.01.10.151924 [1353] +Makefile.am ++ ng_src ++ ng_src/libisoburn.h ++ ng_src/isoburn.h ++ ng_src/isoburn.c ++ ng_src/isofs_wrap.c ++ ng_src/data_source.c ++ ng_src/burn_wrap.c +Begin of porting to next generation libisofs + +2008.01.10.152353 [1354] +test/ng_xorrisoburn.c +test/compile_xorriso.sh +Made compile_xorriso.sh -nglibisofs work on ./ng_src + +2008.01.10.154948 [1355] +test/ng_xorrisoburn.c +test/compile_xorriso.sh +Made compile_xorriso.sh -oglibisofs work on ./og_src + +2008.01.11.133319 [1356] +test/compile_xorriso.sh +Adapted to existence of nglibisofs eltorito.o + +2008.01.11.133631 [1357] +test/xorriso.c +test/ng_xorrisoburn.c +test/xorrisoburn.c +Removed old and new bugs + +2008.01.11.174733 [1358] +test/xorriso.c +test/ng_xorrisoburn.c +test/xorrisoburn.c +Tracing the different behavior of isoburn_read_image() + +2008.01.11.175423 [1359] +test/ng_xorrisoburn.c +ng_src/isoburn.c +ng_src/libisoburn.h +Changed isoburn_source_opts.ouput_charset to output_charset + +2008.01.11.212545 [1361] +ng_src/isofs_wrap.c +Made initialization of iso_read_opts safer + +13 Jan 2008 [1364] ++ og_src +- src src/burn_wrap.c +- src/isoburn.c +- src/isoburn.h +- src/data_source.c +- src/isofs_wrap.c +- src/libisoburn.h ++ og_src/burn_wrap.c ++ og_src/isoburn.c ++ og_src/isoburn.h ++ og_src/data_source.c ++ og_src/isofs_wrap.c ++ og_src/libisoburn.h +Moved src to og_src and installed symbolic link instead + +13 Jan 2008 [1365] +ng_src/isofs_wrap.c +Changes about blanking loaded image + +2008.01.13.224929 [1366] +test/ng_xorrisoburn.c +Allowed all filetypes as input, silenced debug during image read + +14 Jan 2008 [1367] +test/compile_xorriso.sh +Added forgotten source module + +14 Jan 2006 [1368] +ng_src/libisoburn.h +ng_src/isoburn.c +New members in isoburn_source_opts + +2008.01.14.163814 [1369] +test/ng_xorrisoburn.c +Closed memory leak, adapted to new members in isoburn_source_opts + +2008.01.14.164628 [1370] +test/ng_xorrisoburn.c +Repaired memory hog and a freshly introduced bug + +2008.01.14.190220 [1371] +test/xorriso.c +test/ng_xorrisoburn.c +test/xorriso.1 +Removed some bugs and made adaptions to nglibisofs + +2008.01.14.224645 [1372] +test/xorriso_private.h +test/xorriso.c +test/ng_xorrisoburn.h +test/ng_xorrisoburn.c +test/xorriso.1 +Made improvements around volume id + +2008.01.15.174409 [1373] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/ng_xorrisoburn.h +test/ng_xorrisoburn.c +test/xorrisoburn.h +test/xorrisoburn.c +Made improvements about pattern matching .., closed small memory leaks + +2008.01.15.204057 [1374] +test/xorriso.c +test/ng_xorrisoburn.h +test/ng_xorrisoburn.c +test/xorrisoburn.h +test/xorrisoburn.c +Closed a small memory leak + +2008.01.15.211511 [1375] +test/ng_xorrisoburn.c +Added a forgotten iso_dir_iter_free() + +2008.01.16.132909 [1376] +ng_src/isofs_wrap.c +Repaired bug about MMC multi-session image loading + +2008.01.16.141631 [1378] +ng_src/isoburn.c +Changed default name of initial image to ISOIMAGE + +16 Jan 2008 [1378] +libisoburn.pc.in +Set correct name of library + +2008.01.16.200942 [1379] +test/xorriso.c +test/ng_xorrisoburn.c +Adaption to Xorriso_standalonE, some consequences from compiler warnings + +16 Jan 2008 [1380] ++ test/make_xorriso_standalone.sh ++ test/xorriso_makefile_am.txt ++ test/configure_ac.txt ++ test/xorriso_pc_in.txt +A sketch of a xorriso source standalone release generator + +16 Jan 2008 [1381] +test/configure_ac.txt +test/xorriso_makefile_am.txt +Added a test for readline.h and eventually enabled use of libreadline + +2008.01.17.145135 [1382] +test/ng_xorrisoburn.c +Silenced -pedantic compiler warnings about type punning + +17 Jan 2008 [1385] +test/make_xorriso_standalone.sh +Silenced most compiler warnings of libisofs in xorriso-standalone + +17 Jan 2008 [1386] ++ test/README +Began a README file for xorriso + +18 Jan 2008 [1387] +test/make_xorriso_standalone.sh +test/README ++ test/xorriso_eng.html +Worked on documentation + +2008.01.18.101933 [1388] +test/xorriso.c +Changed -report_about default to "UPDATE" + +18 Jan 2008 [1389] +test/xorriso.1 +test/make_xorriso_standalone.sh ++ test/convert_man_to_html.sh +Made a generator for HTML man page + +2008.01.19.090417 [1390] +ng_src/libisoburn.h +ng_src/isoburn.c +ng_src/isofs_wrap.c +test/ng_xorrisoburn.c +test/compile_xorriso.sh +test/xorriso_makefile_am.txt +Adaptions to revision 241 of nglibisofs + +2008.01.19.090546 [1391] +test/xorriso.c +Added startup message. Removed helptext sentence about unimplemented options + +19 Jan 2008 [1392] +test/xorriso_eng.html +test/make_xorriso_standalone.sh +Producing a bootstrapped xorriso standalone tarball + +19 Jan 2008 [1393] +test/README +test/xorriso.1 +test/xorriso_eng.html +Some polishing of xorriso documentation + +2008.01.19.162244 [1394] +test/xorriso.c +test/ng_xorrisoburn.c +Small corrections with version number and write counter report + +19 Jan 2008 [1395] +test/changelog.txt +Updated SVN copy of changelog + +2008.01.20.102946 [1397] +ng_src/burn_wrap.c +ng_src/data_source.c +ng_src/isoburn.c +ng_src/isofs_wrap.c +Made forgotten adaption to Xorriso_standalonE + +2008.01.20.131050 [1398] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/ng_xorrisoburn.c +test/xorriso.1 +Made -outdev stdio:/dev/fd/1 safe for single session runs + +2008.01.20.200254 [1399] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorriso.1 +New option -add_plainly + +2008.01.21.221939 [1400] +test/xorriso.c +test/xorriso.1 +Rejected unsuitable addresses "stdio:" , "stdio:/", "stdio:-", "stdio:." + +22 Jan 2008 [1401] ++ test/compare_file.c +Program which compares two files in different trees. Attributes and content. + +22 Jan 2008 [1402] +test/configure_ac.txt +Copied test for tm.tm_gmtim from libisofs configure.ac + +22 Jan 2008 [1403] +test/compare_file.c +Prepended type indication letter to report lines + +2008.01.22.224321 [1404] +test/ng_xorrisoburn.c +Better attributes with directories + +2008.01.23.195855 [] +ng_src/burn_wrap.c +test/ng_xorrisoburn.c +Adapted to libisofs revision 261 + +24 Jan 2008 [1410] +test/make_xorriso_standalone.sh +Removed remover of C++ comment lines + +2008.01.24.202206 [1411] +ng_src/isoburn.c +ng_src/burn_wrap.c +ng_src/isoburn.h +Gave up use of libburn fifo. Attached -fs and pacifier to libisofs fifo. + +2008.01.25.150902 [1413] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +New option -rollback_end + +25 Jan 2008 [1414] +test/compare_file.c +Fixed bug about file content comparison. + +25 Jan 2008 [1415] +test/compare_file.c +Better handling of various content difference situations + +2008.01.25.175353 [1416] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +test/ng_xorrisoburn.c +New option -commit_eject + +2008.01.26.002011 [1417] +- og_src/libisoburn.h +- og_src/isoburn.h +- og_src/isoburn.c +- og_src/isofs_wrap.c +- og_src/burn_wrap.c +- og_src/data_source.c +- og_src/ ++ libisoburn/ +- ng_src/libisoburn.h +- ng_src/isoburn.h +- ng_src/isoburn.c +- ng_src/isofs_wrap.c +- ng_src/burn_wrap.c +- ng_src/data_source.c ++ libisoburn/libisoburn.h ++ libisoburn/isoburn.h +*+ libisoburn/isoburn.c +*+ libisoburn/isofs_wrap.c +*+ libisoburn/burn_wrap.c +*+ libisoburn/data_source.c ++ xorriso/ +- test/README +- test/changelog.txt +- test/compare_file.c +- test/compile_xorriso.sh +- test/configure_ac.txt +- test/convert_man_to_html.sh +- test/make_timestamp.sh +- test/make_xorriso_standalone.sh +- test/ng_xorrisoburn.c +- test/ng_xorrisoburn.h +- test/xorriso.1 +- test/xorriso.c +- test/xorriso.h +- test/xorriso_eng.html +- test/xorriso_makefile_am.txt +- test/xorriso_pc_in.txt +- test/xorriso_private.h +- test/xorriso_timestamp.h +- test/xorrisoburn.c +- test/xorrisoburn.h ++ xorriso/README ++ xorriso/changelog.txt ++ xorriso/compare_file.c +*+ xorriso/compile_xorriso.sh ++ xorriso/configure_ac.txt +*+ xorriso/convert_man_to_html.sh +*+ xorriso/make_timestamp.sh +*+ xorriso/make_xorriso_standalone.sh ++ xorriso/xorriso.1 +*+ xorriso/xorriso.c ++ xorriso/xorriso.h ++ xorriso/xorriso_eng.html ++ xorriso/xorriso_makefile_am.txt ++ xorriso/xorriso_pc_in.txt ++ xorriso/xorriso_private.h ++ xorriso/xorriso_timestamp.h +*+ xorriso/xorrisoburn.c ++ xorriso/xorrisoburn.h +Makefile.am +Gave up adapter to old libisofs. Renaming libisoburn and xorriso dirs. + +2008.01.26.113604 [1418] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +INCOMPATIBLE API CHANGE: isoburn_initialize(char msg[1024], int flag) + +2008.01.26.120534 [1419] +libisoburn/libisoburn.h +configure.ac +version.h.in +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Introduced versioning (still pre-release) and new API function isoburn_version() + +2008.01.26.140005 [1423] +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_eng.html +Adapted standalone tarball to version functions + +2008.01.26.142130 [1424] +xorriso/xorriso.c +Set program revision to 0.0.1 (previous 0.1.0 was too early) + +2008.01.26.171156 [1425] +libisoburn/libisoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +INCOMPATIBLE API CHANGE: isoburn_prepare_new_image() now gets output drive + +2008.01.27.174454 [1434] +xorriso/xorriso.c +xorriso/xorriso.1 +Changed meaning of -add relative/path + +2008.01.28.105404 [1435] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Made use of iso_set_abort_severity() with option -abort_on + +2008.01.28.140149 [1436] +libisoburn/libisoburn.h +Updated API introduction and marked API instabilities for mending (soon) + +2008.01.28.171915 [1437] +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +xorriso/xorrisoburn.c +xorriso/compile_xorriso.sh +xorriso/make_xorriso_standalone.sh +Adapted to libisofs revison 294 + +2008.01.28.235717 [1438] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +Changed struct isoburn_source_opts to opaque handle struct isoburn_imgen_opts + +2008.01.29.125956 [1439] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +Changed struct isoburn_read_opts to opaque handle + +2008.01.29.184356 [1440] +configure.ac +version.h.in +libisoburn/libisoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +xorriso/configure_ac.txt +New API call isoburn_is_compatible() + +29 Jan 2008 [1441] +libisoburn/libisoburn.h +Some API documentation enhancements + +2008.01.29.211543 [1443] +libisoburn/burn_wrap.c +Made use of newest libburn version features + +2008.01.31.152131 [1449] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +xorriso/make_xorriso_standalone.sh +Adapted to libisofs revision 313 + +2008.01.31.214647 [1450] +xorriso/xorrisoburn.h +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/make_xorriso_standalone.sh +Compile time and runtime checks for library compatibility + +2008.02.01.195817 [1455] +configure.ac +Makefile.am +- libisoburn.pc.in ++ libisoburn-1.pc.in +xorriso/README +Enabled build of dynamically linked xorriso, joined -1.pc club + +2008.02.01.200153 [1456] +xorriso/xorriso_makefile_am.txt +Corrected some false paths in xorriso-standalone Makefile.am + +2008.02.02.131049 [1457] +configure.ac +Added version checks for libburn and libisofs (by Vreixo) + +2008.02.02.131903 [1458] +xorriso/xorriso.h +xorriso/xorriso.c +Added argument to option -commit_eject + +2 Feb 2008 [1459] +xorriso/xorriso_eng.html +Updated to current state of development + +2008.02.02.181200 [1460] +xorriso/xorrisoburn.c +Compile time check of libisoburn. Enforced minimum track size of 300 sectors. + +2008.02.03.131525 [1466] +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +libisoburn/isofs_wrap.c +xorriso/xorrisoburn.c +Made use of ISO_ERR_SEV() and ISO_ERR_PRIO() + +2008.02.03.155704 [1467] +libisoburn/isofs_wrap.c +Adapted to libisofs revisio 328 + +2008.02.03.164038 [1468] +libisoburn/libisoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +New API call isoburn_cancel_prepared_write() + +2008.02.03.164916 [1469] +xorriso/xorrisoburn.c +Reacted on compiler warning + +2008.02.03.181259 [1470] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Made -abort_on and -report_about preemptive if given as dashed start arguments + +2008.02.04.093106 [1471] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Adapted to libisofs revision 332 + +2008.02.04.154405 [1472] +libisoburn/libisoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +New API call isoburn_sync_after_write() + +2008.02.04.184038 [1475] +libisoburn/libisoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +libisoburn/isofs_wrap.c +xorriso/xorrisoburn.c +Inserted problem messages where libisoburn API produces own failures + +2008.02.04.214133 [1476] +libisoburn/libisoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +Added parameter to new API calls isoburn_cancel_prepared_write, isoburn_sync_after_write + +2008.02.05.162621 [1477] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -padding + +2008.02.05.175733 [1478] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +Implemented reassure for -rollback, -rollback_end, -end, -commit, -commit_eject + +2008.02.05.191456 [1479] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +Implemented reassure for -blank, -format, -dev, -indev, -devices + +2008.02.06.131028 [1480] +xorriso/xorriso.c +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +Now loading libraries before -version, pacifier for -add + +2008.02.06.153709 [1481] +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorriso.1 +xorriso/xorrisoburn.c +Rectified SORRY,FAILURE,FATAL classification + +2008.02.06.183423 [1484] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Adapted to libisofs revision 337 + +2008.02.06.183557 [1485] +xorriso/xorriso.c +Removed some unused code + +2009.02.06.184008 [1486] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Added a missing 0 digit + +2008.02.06.214426 [1487] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +xorriso/xorrisoburn.c +Pacifier for isoburn_read_image() + +2008.02.07.074248 [1489] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso_private.h +Added final message to image read pacifier + +2008.02.07.154947 [1490] +libisoburn/data_source.c +Implemented a primitive single tile cache for image reading + +2008.02.07.211424 [1491] +libisoburn/data_source.c +Stuffed memory leak with read cache. Economized on error retries. + +8 Feb 2008 [1494] +- xorriso/compare_file. ++ test/compare_file.c +- ng_src +Cleaning up remainings of move to ng_src + +8 Feb 2008 [1495] +test/compare_file.c +Fixed an endless cycle with early EOF + +2008.02.08.102122 [1496] +xorriso/xorriso_makefile_am.txt +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/README +Added test/compare_file.c to xorriso-standalone tarball + +2008.02.08.173928 [1497] +2008.02.08.174126 [1498] +libisoburn/data_source.c +Renamed macro which controls read caching + +2008.02.08.175152 [1499] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Protecting volume ids from getting overwritten by predecessor + +2008.02.08.195627 [1500] +xorriso/xorriso.c +Warning of -volid which are not ECMA 119 compliant + +2008.02.08.215113 [1501] +xorriso/xorriso.h +xorriso/xorriso.c +Silenced misleading toc messages with -commit_eject "in" + +2008.02.09.092805 [1502] +libisoburn/libisoburn.h +libisoburn/isoburn.c +Adapted to libisofs revision 346 + +2008.02.09.100750 [1503] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +New API function isoburn_disc_available_space() fixes bug with DVD+RW capacity + +10 Feb 2008 [1504] +xorriso/README +Some adjustments in description of compare_file and libisoburn + +2008.02.10.122020 [1505] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Fixed bugs about -mv /im/age . -cdx / -cpr di/sk im/age -- -cpr di/sk . -- + +2008.02.10.130852 [1506] +Makefile.am +Added build of test/compare_file as noinst binary + +2008.02.10.135822 [1507] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Better handling of not-yet-existing -cd + +2008.02.11.094742 [1509] +xorriso/xorriso_private.h +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Discarding, keeping or patching boot images from existing ISO images + +2008.02.11.112917 [1510] +xorriso/xorrisoburn.c +Corrected message about isolinux patch option + +2008.02.11.113235 [1511] +xorriso/xorriso.h +xorriso/xorriso.c +Final UPDATE message after grafting in files from disk + +2008.02.11.135418 [1512] +xorriso/xorriso_private.h +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +New option -return_with + +2008.02.11.150123 [1513] +xorriso/xorrisoburn.c +isoburn_igopt_allow_full_ascii for -bootimage any keep + +2008.02.11.150700 [1514] +xorriso/xorriso.c +xorriso/xorriso.1 +Clarifications about -volid rules + +11 Feb 2008 [1515] +xorriso/README +Adjustments about libisoburn and xorriso dynamic dependencies, compare_file + +2008.02.11.162406 [1516] +xorriso/xorrisoburn.c +xorriso/xorriso.c +Changed failure to find a file for removal from FAILURE to SORRY + +2008.02.11.174517 [1517] +xorriso/xorriso.c +Corrected a bug about -status -return_with + +2008.02.11.194807 [1519] +libisoburn/burn_wrap.c +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New severity MISHAP + +2008.02.11.213918 [1520] +xorriso/xorrisoburn.c +Mapping in burn runs -abort_on MISHAP to SORRY + +2008.02.12.215327 [1521] +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +Improved MISHAP - SORRY mapping and tunneling + +2008.02.14.084342 [1525] ++ README ++ COPYING ++ COPYRIGHT ++ INSTALL +libisoburn/libisoburn.h +Completing documentation + +2008.02.14.101916 [1526] +Makefile.am +Adjusted EXTRA_DIST list of files + +2008.02.14.120557 [1527] +xorriso/xorrisoburn.c +Made a final abort check before burning begins + +2008.02.14.175623 [1528] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Imprinting version of xorriso and libraries into ISO preparer_id + +2008.02.14.182351 [1529] +xorriso/xorrisoburn.c +Made preparer_id more safe against oversize + +14 Feb 2008 [1530] +xorriso/xorriso.1 +Polished man page + +14 Feb 2008 [1531] +xorriso/changelog.txt +Updated changelog + +2008.02.15.100001 [branch 1533] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/compile_xorriso.sh +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Made version number leap to 0.1.0 + +15 Feb 2008 [branch 1534] +xorriso/changelog.txt +Documented initial release and timestamp + +15 Feb 2008 [1536] +configure.ac +Increased libisofs requirement to 0.6.2 + +----------------------------- release - xorriso-0.1.0.pl00 - 2008.02.15.100001 +* Operates on an existing ISO image or creates a new one. +* Copies files from filesystem into the ISO image. +* Renames or deletes file objects in the ISO image. +* Changes file properties in the ISO image. +* Can write result as completely new image to optical media + or filesystem objects. +* Can write result as add-on session to appendable + multi-session media, to overwriteable media, + to regular files, and to block devices. +* Scans for optical drives, blanks re-useable optical media. +* Reads its instructions from command line arguments, dialog, and batch files. +* Provides navigation commands for interactive ISO image manipulation. +* Adjustable thresholds for abort, exit value, and problem reporting. + + +2008.02.15.211836 [1537] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/compile_xorriso.sh +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.1.1 + +15 Feb 2008 [1538] +COPYRIGHT +Corrected according to content of libisofs/COPYRIGHT + +2008.02.15.212030 [1539] +xorriso/xorriso.c +Changed pacifier text for 0 nodes read from blank image + +------------------------------------ cycle - xorriso-0.1.1 - 2008.02.15.212030 + +15 Feb 2008 [1540] +xorriso/changelog.txt +Updated changelog + +16 Feb 2008 [1543] +xorriso/xorriso.1 +Adjusted CREDITS text + +2008.02.16.202533 [1544] +xorriso/xorriso_private.h +xorriso/xorrisoburn.c +Transfering properties from disk to implicit directories in image path + +2008.02.16.211549 [1545] +xorriso/xorriso_eng.html +xorriso/changelog.txt +Mentioned better directory attribute copying + +------------------------------------ cycle - xorriso-0.1.1 - 2008.02.16.211549 +* Improved attribute transfer from disk for implicit target directories + +2008.02.18.210343 [1546] +xorriso/xorriso.c +Bug fix: -report_about higher than NOTE did not report at all + +19 Feb 2008 [1547] +test/compare_file.c +Improved report format + +2008.02.19.184432 [1548] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -as cdrecord emulates a narrow set of cdrecord gestures + +2008.02.19.212322 [1549] +xorriso/xorriso.c +xorriso/xorriso_private.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Improved -as cdrecord + +20 Feb 2008 [1550] +test/compare_file.c +Revoked inflation of file type characters to words + +2008.02.20.234726 [1551] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -as mkisofs emulates a narrow set of mkisofs gestures + +------------------------------------ cycle - xorriso-0.1.1 - 2008.02.21.090014 +* Bug fix: -report_about HINT or higher did not report at all +* Bug fix: speed=number without unit or media type letter was always CD speed +* Bug fix: it was possible to write to appendable media which was not -indev +* New option -as "cdrecord" emulates a narrow set of cdrecord gestures +* New option -as "mkisofs" emulates a narrow set of mkisofs gestures + +2008.02.21.090014 [1552] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +New option -publisher + +2008.02.21.185203 [1553] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Implemented a more reasonable solution for drive truncation with regular files + +2008.02.21.204613 [1558] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Introduced new severity ERRFILE + +2008.02.21.211101 [1559] +xorriso/xorriso.c +Updated -help text + +2008.02.22.114917 [1561] +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +Producing ERRFILE messages where appropriate + +2008.02.23.101619 [1568] +libisoburn/libisoburn.h +Changed libisofs requirements to 0.6.3 + +2008.02.23.101619 [1569] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Testwise implementation of libisofs.0.6.3 features + +2008.02.23.101619 [1570] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorriso.1 +New option -errfile_log + +2008.02.23.102903 [1571] +xorriso/configure_ac.txt +Made libisofs version leap in xorriso-standalone + +2008.02.23.113902 [1572] +xorriso/xorriso.h +xorriso/xorriso.c +Directed -as mkisofs -print-size to real stdout + +2008.02.23.125537 [1573] +xorriso/xorrisoburn.c +Various bugs and deviations around -as mkisofs -print-size + +2008.02.23.131825 [1574] +xorriso/xorrisoburn.c +Wrong description text + +2008.02.25.090001 [ZeroOneZero-pl01 1576 1577] +libisoburn/burn_wrap.c +xorriso/xorriso_timestamp.h +Safety cap for ABI usage bug towards libisofs >= 0.6.2 + +2008.02.25.174229 [1579] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Adapted to libisofs 362 from Vreixo bzr + +2008.02.25.204402 [1580] +xorriso/xorriso.c +Adaptions of -as mkisofs and -as cdrecord to enable full use by scdbackup + +25 Feb 2008 [1581] +xorriso/changelog.txt +Updated changelog + +------------------------------------ cycle - xorriso-0.1.1 - 2008.02.25.204402 +* New option -publisher +* New option -errfile_log + + +26 Feb 2008 [1582] +test/compare_file.c +Avoided to read content of non-regular files + +2008.02.26.213437 [1583] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -compare + +2008.02.27.185744 [1584] +xorriso/xorriso.c +Installed pacifier for data reading + +2008.02.28.132656 [1587] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Added new action "compare" to -find + +28 Feb 2008 [1588] +xorriso/xorriso_eng.html +Mentioned capability to write DVD+R/DL. + +2008.02.28.212210 [1589] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +New option -compare_r + +28 Feb 2008 [1590] +xorriso/xorriso.1 +New option -compare_r, new -findx -exec in_iso, -exec no_in_iso + +28 Feb 2008 [1591] +test/compare_file.c +Micro bug fix ported from xorriso + +2008.02.28.215343 [1592] +xorriso/xorriso.c +Better handling of disk to iso address mapping during compare runs + +2008.02.29.200510 [1593] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -update (not yet completed) + +2008.03.01.151219 [1594] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option update_r, -find actions "update" and "add_missing" (not yet completed) + +2008.03.02.172751 [1596] +xorriso/xorrisoburn.c +Made -update_r and -find -exec update safe against IsoDirIter pitfalls + +2008.03.02.201455 [1597] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Made IsoDirIter workaround obey -temp_mem_limit + +4 Mar 2008 [libisofs_thomas 1599 1600] +Switch to Vreixo development branch 378 + +2008.03.04.174107 [1601] +xorriso/make_xorriso_standalone.sh +xorriso/xorriso_makefile_am.txt +Adapted to libisofs Vreixo 378 + +2008.03.04.180738 [1602] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Improvements about -update_r and -compare_r + +2008.03.05.125118 [1603] +xorriso/xorrisoburn.c +Bug fix: -follow param did not work for symbolic links + +------------------------------------ cycle - xorriso-0.1.1 - 2008.03.05.125118 +* Support for DVD+R/DL media +* Bug fix: -follow param did not work for adding non-directory symbolic links + + +2008.03.05.173329 [1604] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Made -compare* and -update* obey -follow links (-follow mount still not correct) + +5 Mar 2008 [1605] +xorriso/xorriso.1 +Some man page clarification + +2008.03.06.114233 [1606] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -find actions "rm" and "rm_r", silenced comparison results with -update* + +2008.03.06.174724 [1608] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Fixed bug about non existing disk_path with -update_r + +7 Mar 2008 [1609] +xorriso/xorriso_eng.html +Re-arranged development download part + +2008.03.07.075325 [1610] +xorriso/xorriso.c +xorriso/xorrisoburn.c +New -findx -type "m" for active mount points + +2008.03.07.182411 [1611] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -findx -exec action "empty_iso_dir", workaround for ticket 132 + +2008.03.07.220442 [1612] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Made -update_r and -compare_r obey disabling of -follow "mount" + +8 Mar 2008 [libisofs_thomas 1613] +Switch to Vreixo development branch 383 + +2008.03.08.104231 [1614] +xorriso/xorrisoburn.c +Adapted to iso_tree_add_new_node() + +8 Mar 2008 [1615] +xorriso/xorriso.1 +Example use case for -update_r "Incremental backup of a few directory trees" + +------------------------------------ cycle - xorriso-0.1.1 - 2008.03.08.122747 +* Bug fix: It was not possible to -add /THIS=a /b=THIS +* New options -compare, -compare_r and according -find -exec action +* New options -update, -update_r and according -find -exec action +* New -find actions "rm", "rm_r", new -findx -type "m" -exec "empty_iso_dir" + + +2008.03.09.142200 [1616] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -cut_out + +9 Mar 2008 [libisofs_thomas 1617] +Switch to Vreixo development branch 386 + +2008.03.09.211041 [1618] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Some polishing about -cut_out + +2008.03.11.113444 [1619] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Sketched split file scheme with partno,totalparts,offset,count,totalsize + +11 Mar 2008 [1620] +xorriso/xorriso.1 +Updated description of -cut_out + +------------------------------------ cycle - xorriso-0.1.1 - 2008.03.11.113444 +* New option -cut_out + + +2008.03.12.100001 [XorrisoZeroOneTwo 1626] +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to xorriso-0.1.2 + +------------------------------------ cycle - xorriso-0.1.2 - 2008.03. +* Bug fix: -report_about HINT or higher did not report at all +* Bug fix: speed=number without unit or media type letter was always CD speed +* Bug fix: it was possible to write to appendable media which was not -indev +* Bug fix: -follow param did not work for adding non-directory symbolic links +* Bug fix: It was not possible to -add /THIS=a /b=THIS +* Improved attribute transfer from disk for implicit target directories +* New option -as "cdrecord" emulates a narrow set of cdrecord gestures +* New option -as "mkisofs" emulates a narrow set of mkisofs gestures +* New option -publisher +* New option -errfile_log +* Support for DVD+R/DL media +* New options -compare, -compare_r and according -find -exec action +* New options -update, -update_r and according -find -exec action +* New -find actions "rm", "rm_r", new -findx -type "m" -exec "empty_iso_dir" +* New option -cut_out + + +2008.03.12.130605 [1627] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.1.3 + +------------------------------------ cycle - xorriso-0.1.3 - 2008.03.12.130605 + +12 Mar 2008 [XorrisoZeroOneTwo ] [] +xorriso/changelog.txt +Document changes and release timestamp + +=============================================================================== + TODO +=============================================================================== + +------------------------------------------------- bugs + +------------------------------------------------- important + +- improved read performance: +> libisoburn/data_source.c: ds_read_block() + - multi-tile cache for image data reading + +- pacifier for -compare_r : try read pacifier without newline + +------------------------------------------------- development + +- report LBA of session start after writing, have LBA log file +- evaluate possibility of emulated session table on overwriteables + + +- mkisofs,cdrecord multi session + +- -restore +??? -compare_l -update_l /disk_path_start iso_rr_path_start path[s] -- +??? backup area shaping with -yes -not for -compare_r and -update_r ? + +- Make use of iso_tree_add_new_node() in Xorriso_tree_graft_node() + + +> Relative addressing and pattern matching : + iso_rr_pattern on + cd /u/FERTIG + lsd nonexist/.. + +- regularly do valgrind check for memory leaks + +- ??? http://scan.coverity.com/faq.html + +- ??? curb depth of tree traversal recursion + +- make xorrisoburn.c leaner + +- eject a not yet aquired device (e.g. after modifying commit) + +- -cd[ix] and pattern + +- memory curb for image model + +??? semicolon as alias of -- ? + +> Make transactional the tree deletions meant for replacing + +- Introduce an interrupt key for dialog + +-------------------------------------------- jump to libburn 0.4.4 + +- make use of burn_sev_to_text() in libisoburn and xorriso + +- If iso_msgs_submit() : use it in isoburn_report_iso_error() + + +=============================================================================== + This is the dirty end of the todo list. + The recent changelog entries are above the headline "TODO". +=============================================================================== diff --git a/libisoburn/branches/ZeroOneFour/xorriso/compile_xorriso.sh b/libisoburn/branches/ZeroOneFour/xorriso/compile_xorriso.sh new file mode 100755 index 00000000..85732da9 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/compile_xorriso.sh @@ -0,0 +1,155 @@ +#!/bin/sh + +# compile_xorriso.sh +# Copyright 2005 - 2008 Thomas Schmitt, scdbackup@gmx.net, GPL +# +# Not intended for general use in production installations ! +# Rather use: ./bootstrap ; ./configure ; make +# +# This is a development tool which expects a special setup of directories. +# It is to be executed in a common parent of the directories given with +# $isofs $isoburn $burn $xorr + +isofs=./nglibisofs-develop/libisofs +burn=./libburn-develop/libburn +isoburn=./libisoburn-develop/libisoburn +xorr=./libisoburn-develop/xorriso + +debug_opts="-O2" +def_opts= +largefile_opts="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1" +do_strip=0 +static_opts= +warn_opts="-Wall" +nglibisofs=1 + +for i in "$@" +do + if test "$i" = "-do_diet" + then + def_opts="$def_opts -DXorriso_no_helP" + warn_opts= + elif test "$i" = "-do_strip" + then + do_strip=1 + elif test "$i" = "-g" + then + debug_opts="-g -O0" + elif test "$i" = "-help" -o "$i" = "--help" -o "$i" = "-h" + then + echo \ + "$xorr/compile_xorriso.sh : to be executed above top level directories" + echo "Options:" + echo " -do_diet produce capability reduced lean version." + echo " -do_strip apply program strip to compiled programs." + echo " -g produce debuggable programm." + echo " -static compile with cc option -static." + exit 0 + elif test "$i" = "-static" + then + static_opts="-static" + fi +done + +libisofs= +libisofs="$libisofs $isofs"/buffer.o +libisofs="$libisofs $isofs"/builder.o +libisofs="$libisofs $isofs"/data_source.o +libisofs="$libisofs $isofs"/ecma119.o +libisofs="$libisofs $isofs"/ecma119_tree.o +libisofs="$libisofs $isofs"/eltorito.o +libisofs="$libisofs $isofs"/filesrc.o +libisofs="$libisofs $isofs"/fs_image.o +libisofs="$libisofs $isofs"/fs_local.o +libisofs="$libisofs $isofs"/fsource.o +libisofs="$libisofs $isofs"/image.o +libisofs="$libisofs $isofs"/iso1999.o +libisofs="$libisofs $isofs"/joliet.o +libisofs="$libisofs $isofs"/libiso_msgs.o +libisofs="$libisofs $isofs"/messages.o +libisofs="$libisofs $isofs"/node.o +libisofs="$libisofs $isofs"/rockridge.o +libisofs="$libisofs $isofs"/rockridge_read.o +libisofs="$libisofs $isofs"/stream.o +libisofs="$libisofs $isofs"/tree.o +libisofs="$libisofs $isofs"/util.o +libisofs="$libisofs $isofs"/util_htable.o +libisofs="$libisofs $isofs"/util_rbtree.o + +timestamp="$(date -u '+%Y.%m.%d.%H%M%S')" +echo "Version timestamp : $(sed -e 's/#define Xorriso_timestamP "//' -e 's/"$//' "$xorr"/xorriso_timestamp.h)" +echo "Build timestamp : $timestamp" + +echo "compiling program $xorr/xorriso.c $static_opts $debug_opts $def_opts" +cc -I. -DXorriso_with_maiN -DXorriso_with_regeX -DXorriso_with_readlinE \ + $warn_opts \ + $static_opts \ + $debug_opts \ + $def_opts \ + $largefile_opts \ + \ + -DXorriso_build_timestamP='"'"$timestamp"'"' \ + \ + -o "$xorr"/xorriso \ + \ + "$xorr"/xorriso.c \ + \ + "$xorr"/xorrisoburn.c \ + \ + "$burn"/async.o \ + "$burn"/debug.o \ + "$burn"/drive.o \ + "$burn"/file.o \ + "$burn"/init.o \ + "$burn"/options.o \ + "$burn"/source.o \ + "$burn"/structure.o \ + \ + "$burn"/sg.o \ + "$burn"/write.o \ + "$burn"/read.o \ + "$burn"/libdax_audioxtr.o \ + "$burn"/libdax_msgs.o \ + "$burn"/cleanup.o \ + \ + "$burn"/mmc.o \ + "$burn"/sbc.o \ + "$burn"/spc.o \ + "$burn"/util.o \ + \ + "$burn"/sector.o \ + "$burn"/toc.o \ + \ + "$burn"/crc.o \ + "$burn"/lec.o \ + \ + "$isoburn"/isoburn.o \ + "$isoburn"/burn_wrap.o \ + "$isoburn"/data_source.o \ + "$isoburn"/isofs_wrap.o \ + \ + $libisofs \ + \ + -lreadline \ + \ + -lpthread + + ret=$? + if test "$ret" = 0 + then + dummy=dummy + else + echo >&2 + echo "+++ FATAL : Compilation of xorriso failed" >&2 + echo >&2 + exit 1 + fi + + +if test "$do_strip" = 1 +then + echo "stripping result $xorr/xorriso" + strip "$xorr"/xorriso +fi + +echo 'done.' diff --git a/libisoburn/branches/ZeroOneFour/xorriso/configure_ac.txt b/libisoburn/branches/ZeroOneFour/xorriso/configure_ac.txt new file mode 100644 index 00000000..07e06508 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/configure_ac.txt @@ -0,0 +1,114 @@ +AC_INIT([xorriso], [0.1.3], [http://libburnia-project.org]) +AC_PREREQ([2.50]) +dnl AC_CONFIG_HEADER([config.h]) + +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +AM_INIT_AUTOMAKE([subdir-objects]) + +BURN_MAJOR_VERSION=0 +BURN_MINOR_VERSION=4 +BURN_MICRO_VERSION=5 +AC_SUBST(BURN_MAJOR_VERSION) +AC_SUBST(BURN_MINOR_VERSION) +AC_SUBST(BURN_MICRO_VERSION) + +LIBISOFS_MAJOR_VERSION=0 +LIBISOFS_MINOR_VERSION=6 +LIBISOFS_MICRO_VERSION=4 +AC_SUBST(LIBISOFS_MAJOR_VERSION) +AC_SUBST(LIBISOFS_MINOR_VERSION) +AC_SUBST(LIBISOFS_MICRO_VERSION) + +dnl The API version codes are defined in libisoburn/libisoburn.h +dnl #define isoburn_header_version_* + + +AC_PREFIX_DEFAULT([/usr/local]) +test "$prefix" = "NONE" && prefix=$ac_default_prefix + +AM_MAINTAINER_MODE + +AM_PROG_CC_C_O +AC_C_CONST +AC_C_INLINE +AC_C_BIGENDIAN + +dnl Large file support +AC_SYS_LARGEFILE +AC_FUNC_FSEEKO +AC_CHECK_FUNC([fseeko]) +if test ! $ac_cv_func_fseeko; then + AC_ERROR([Libburn requires largefile support.]) +fi + +AC_PROG_LIBTOOL +AC_SUBST(LIBTOOL_DEPS) +LIBTOOL="$LIBTOOL --silent" + +AC_PROG_INSTALL + +AC_CHECK_HEADERS() + +AC_CHECK_MEMBER([struct tm.tm_gmtoff], + [AC_DEFINE(HAVE_TM_GMTOFF, 1, + [Define this if tm structure includes a tm_gmtoff entry.])], + , + [#include ]) + +dnl Check if non standard timegm() function is available +AC_CHECK_DECL([timegm], + [AC_DEFINE(HAVE_TIMEGM, 1, [Define this if timegm function is available])], + , + [#include ]) + +dnl Check if non standard eaccess() function is available +AC_CHECK_DECL([eaccess], + [AC_DEFINE(HAVE_EACCESS, 1, [Define this if eaccess function is available])], + , + [#include ]) + +THREAD_LIBS=-lpthread +AC_SUBST(THREAD_LIBS) + +TARGET_SHIZZLE +AC_SUBST(ARCH) +AC_SUBST(LIBBURN_ARCH_LIBS) + +dnl Add compiler-specific flags + +dnl See if the user wants aggressive optimizations of the code +AC_ARG_ENABLE(debug, +[ --enable-debug Disable aggressive optimizations [default=yes]], + , enable_debug=yes) +if test x$enable_debug != xyes; then + if test x$GCC = xyes; then + CFLAGS="$CFLAGS -O3" + CFLAGS="$CFLAGS -fexpensive-optimizations" + fi + CFLAGS="$CFLAGS -DNDEBUG" +else + if test x$GCC = xyes; then + CFLAGS="$CFLAGS -g -pedantic -Wall" + fi + CFLAGS="$CFLAGS -DDEBUG" +fi + + +dnl Check whether there is readline-devel and readline-runtime. +dnl If not, erase this macro which would enable use of readline(),add_history() +READLINE_DEF="-DXorriso_with_readlinE" +dnl The empty yes case obviously causes -lreadline to be linked +AC_CHECK_HEADER(readline/readline.h, AC_CHECK_LIB(readline, readline, , READLINE_DEF= ), READLINE_DEF= ) +dnl The X= in the yes case prevents that -lreadline gets linked twice +AC_CHECK_HEADER(readline/history.h, AC_CHECK_LIB(readline, add_history, X= , READLINE_DEF= ), READLINE_DEF= ) +AC_SUBST(READLINE_DEF) + + +AC_CONFIG_FILES([ + Makefile + version.h + xorriso.pc + ]) +AC_OUTPUT diff --git a/libisoburn/branches/ZeroOneFour/xorriso/convert_man_to_html.sh b/libisoburn/branches/ZeroOneFour/xorriso/convert_man_to_html.sh new file mode 100755 index 00000000..f73f24aa --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/convert_man_to_html.sh @@ -0,0 +1,107 @@ +#!/bin/sh + +# +# convert_man_to_html.sh - ts A80118 +# +# Generates a HTML version of man page xorriso.1 +# +# To be executed in the libisoburn toplevel directory (eg. ./libisoburn-0.1.0) +# + +# set -x + +man_dir=$(pwd)"/xorriso" +export MANPATH="$man_dir" +manpage="xorriso" +raw_html=$(pwd)/"xorriso/raw_man_1_xorriso.html" +htmlpage=$(pwd)/"xorriso/man_1_xorriso.html" + +if test -r "$man_dir"/"$manpage".1 +then + dummy=dummy +else + echo "Cannot find readable man page source $1" >&2 + exit 1 +fi + +if test -e "$man_dir"/man1 +then + dummy=dummy +else + ln -s . "$man_dir"/man1 +fi + +if test "$1" = "-work_as_filter" +then + +# set -x + + sed \ + -e 's///' \ + -e 's///' \ + -e 's/XORRISO<\/title>/<title>man 1 xorriso<\/title>/' \ + -e 's/<h1 align=center>XORRISO<\/h1>/<h1 align=center>man 1 xorriso<\/h1>/' \ + -e 's/<body>/<body BGCOLOR="#F5DEB3" TEXT=#000000 LINK=#0000A0 VLINK=#800000>/' \ + -e 's/<b>Overview of features:<\/b>/\ <BR><b>Overview of features:<\/b>/' \ + -e 's/<b>General information paragraphs:<\/b>/\ <BR><b>General information paragraphs:<\/b>/' \ + -e 's/have a look at section EXAMPLES/have a look at section <A HREF="#EXAMPLES">EXAMPLES<\/A>/' \ + -e 's/<b>Session model:<\/b>/\ <BR><b>Session model:<\/b>/' \ + -e 's/<b>Media types and states:<\/b>/\ <BR><b>Media types and states:<\/b>/' \ + -e 's/<b>Creating, Growing, Modifying:<\/b>/\ <BR><b>Creating, Growing, Modifying:<\/b>/' \ + -e 's/<b>Libburn drives:<\/b>/\ <BR><b>Libburn drives:<\/b>/' \ + -e 's/^-dev /\ \ -dev /' \ + -e 's/^-devices /\ \ -devices /' \ + -e 's/<b>Rock Ridge, POSIX, X\/Open:<\/b>/\ <BR><b>Rock Ridge, POSIX, X\/Open:<\/b>/' \ + -e 's/<b>Command processing:<\/b>/\ <BR><b>Command processing:<\/b>/' \ + -e 's/<b>Dialog, Readline, Result pager:<\/b>/\ <BR><b>Dialog, Readline, Result pager:<\/b>/' \ + -e 's/<b>Aquiring source and target drive:<\/b>/\ <BR><b>Aquiring source and target drive:<\/b><BR>\ <BR>/' \ + -e 's/<b>Data manipulations:<\/b>/\ <BR><b>Data manipulations:<\/b><BR>\ <BR>/' \ + -e 's/^<p><b>−iso_rr_pattern/<p>\ <BR><b>\−iso_rr_pattern/' \ + -e 's/EXAMPLES):<br>/<A HREF="#EXAMPLES">EXAMPLES<\/A>):<br>/' \ + -e 's/<b>Writing the result:<\/b>/\ <BR><b>Writing the result:<\/b><BR>/' \ + -e 's/^-find \/ /\ \ -find \/ /' \ + -e 's/<b>Settings for data insertion:<\/b>/\ <BR><b>Settings for data insertion:<\/b><BR>\ <BR>/' \ + -e 's/^$<\/b> ln -s/\ \ $<\/b> ln -s/' \ + -e 's/<b>Settings for result writing:<\/b>/\ <BR><b>Settings for result writing:<\/b><BR>\ <BR>/' \ + -e 's/^706k = 706kB/\ \ 706k = 706kB/' \ + -e 's/^5540k = 5540kB/\ \ 5540k = 5540kB/' \ + -e 's/<b>Exception processing:<\/b>/\ <BR><b>Exception processing:<\/b><BR>\ <BR>/' \ + -e 's/<b>Dialog mode control:<\/b>/\ <BR><b>Dialog mode control:<\/b><BR>\ <BR>/' \ + -e 's/<b>Drive and media related inquiry actions:<\/b>/\ <BR><b>Drive and media related inquiry actions:<\/b><BR>\ <BR>/' \ + -e 's/<b>Navigation in ISO image/\ <BR><b>Navigation in ISO image/' \ + -e 's/^filesystem:<\/b>/filesystem:<\/b><BR>\ <BR>/' \ + -e 's/<b>Scripting, dialog and/\ <BR><b>Scripting, dialog and/' \ + -e 's/^features:<\/b>/features:<\/b><BR>\ <BR>/' \ + -e 's/<b>Support for frontend/\ <BR><b>Support for frontend/' \ + -e 's/^listening at stdout:<\/b>/listening at stdout:<\/b><BR>\ <BR>/' \ + -e 's/xorriso -outdev \/dev\/sr2 \\ -blank fast \\ -pathspecs on/xorriso -outdev \/dev\/sr2 -blank fast -pathspecs on/' \ + -e 's/\\ -add \\ \/sounds=\/home\/me\/sounds \\ \/pictures \\ -- \\ -rm_r \\/ -add \/sounds=\/home\/me\/sounds \/pictures -- -rm_r /' \ + -e 's/\/sounds\/indecent \\ \’\/pictures\/\*private\*\’ \\/\/sounds\/indecent \’\/pictures\/*private*\’ /' \ + -e 's/\/pictures\/confidential \\ -- \\ -add \\/\/pictures\/confidential -- -add/' \ + -e 's/xorriso -dev \/dev\/sr2 \\ -rm_r \/sounds -- \\ -mv \\/xorriso -dev \/dev\/sr2 -rm_r \/sounds -- -mv /' \ + -e 's/\/pictures\/confidential \\ \/pictures\/restricted \\ -- \\ -chmod/\/pictures\/confidential \/pictures\/restricted -- -chmod/' \ + -e 's/go-rwx \/pictures\/restricted -- \\ -pathsspecs on \\ -add \\/go-rwx \/pictures\/restricted -- -pathsspecs on -add /' \ + -e 's/\/sounds=\/home\/me\/prepared_for_dvd\/sounds_dummy /\/sounds=\/home\/me\/prepared_for_dvd\/sounds_dummy/' \ + -e 's/\/movies=\/home\/me\/prepared_for_dvd\/movies \\ -- \\ -commit/\/movies=\/home\/me\/prepared_for_dvd\/movies -- -commit/' \ + -e 's/xorriso -indev \/dev\/sr2 \\ -rm_r \/sounds -- \\/xorriso -indev \/dev\/sr2 -rm_r \/sounds -- /' \ + -e 's/-outdev \/dev\/sr0 -blank fast \\ -commit -eject all/-outdev \/dev\/sr0 -blank fast -commit -eject all/' \ + -e 's/See section FILES/See section <A HREF="#FILES">FILES<\/A>/' \ + -e 's/See section EXAMPLES/See section <A HREF="#EXAMPLES">EXAMPLES<\/A>/' \ + -e 's/<\/body>/<BR><HR><FONT SIZE=-1><CENTER>(HTML generated from '"$manpage"'.1 on '"$(date)"' by '$(basename "$0")' )<\/CENTER><\/FONT><\/body>/' \ + <"$2" >"$htmlpage" + + set +x + + chmod u+rw,go+r,go-w "$htmlpage" + echo "Emerged file:" + ls -lL "$htmlpage" + +else + + export BROWSER='cp "%s" '"$raw_html" + man -H "$manpage" + "$0" -work_as_filter "$raw_html" + rm "$raw_html" + rm "$man_dir"/man1 + +fi diff --git a/libisoburn/branches/ZeroOneFour/xorriso/make_timestamp.sh b/libisoburn/branches/ZeroOneFour/xorriso/make_timestamp.sh new file mode 100755 index 00000000..d6cfcb57 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/make_timestamp.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Create version timestamp xorriso/xorriso_timestamp.h +# to be executed within ./libisoburn-develop + +timestamp="$(date -u '+%Y.%m.%d.%H%M%S')" +echo "Version timestamp : $timestamp" +echo '#define Xorriso_timestamP "'"$timestamp"'"' >xorriso/xorriso_timestamp.h + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/make_xorriso_standalone.sh b/libisoburn/branches/ZeroOneFour/xorriso/make_xorriso_standalone.sh new file mode 100755 index 00000000..8760be67 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/make_xorriso_standalone.sh @@ -0,0 +1,235 @@ +#!/bin/sh + +# make_xorriso_standalone.sh +# Copyright 2008 Thomas Schmitt, scdbackup@gmx.net, GPL +# +# Not intended for general use in production installations ! +# +# This is a development tool which expects a special setup of directories. +# It is to be executed in a common parent of the directories +# nglibisofs-develop libburn-develop libisoburn-develop +# +# Creates a standalone tree for building xorriso +# from the contents of a unified libburnia development tree. +# +# The ./bootstrap script gets applied and a source tarball +# is made. +# +# From that tree can be build a binary xorriso/xorriso +# which at runtime depends only on libc and libpthread. +# Execute in $lone_dir : +# +# ./configure && make +# + +current_dir=$(pwd) +lone_dir="$current_dir"/"xorriso-standalone" + +xorriso_rev=0.1.3 +# For unstable uploads: +xorriso_pl="" +# For stable releases: +# xorriso_pl=".pl00" + +with_bootstrap_tarball=1 + +create_dir() { + if mkdir "$1" + then + dummy=dummy + else + echo "Failed to create : $1" >&2 + exit 1 + fi +} + +goto_dir() { + if cd "$1" + then + dummy=dummy + else + echo "Failed to cd $1" >&2 + exit 1 + fi +} + +copy_files() { + if cp "$@" + then + dummy=dummy + else + echo "Failed to : cp " "$@" >&2 + exit 1 + fi +} + +if test -e "$lone_dir" +then + echo "Already existing : $lone_dir" >&2 + exit 1 +fi + + +# Top level directory + +goto_dir "$current_dir"/libisoburn-develop + +create_dir "$lone_dir" + +copy_files \ + AUTHORS \ + CONTRIBUTORS \ + COPYRIGHT \ + COPYING \ + INSTALL \ + acinclude.m4 \ + aclocal.m4 \ + bootstrap \ + compile \ + config.guess \ + config.status \ + config.sub \ + depcomp \ + install-sh \ + libtool \ + ltmain.sh \ + missing \ + mkinstalldirs \ + version.h.in \ + \ + "$lone_dir" + +copy_files xorriso/configure_ac.txt "$lone_dir"/configure.ac + +copy_files xorriso/xorriso_makefile_am.txt "$lone_dir"/Makefile.am + +copy_files xorriso/xorriso_pc_in.txt "$lone_dir"/xorriso.pc.in + +copy_files xorriso/README "$lone_dir"/README + +# echo "See end of xorriso/changelog.txt" >"$lone_dir"/TODO + + +# libisoburn + +create_dir "$lone_dir"/libisoburn +copy_files \ + libisoburn/*.[ch] \ + "$lone_dir"/libisoburn + +xorriso/convert_man_to_html.sh + +create_dir "$lone_dir"/xorriso +copy_files \ + xorriso/xorrisoburn.[ch] \ + xorriso/xorriso.[ch1] \ + xorriso/xorriso_private.h \ + xorriso/xorriso_timestamp.h \ + xorriso/changelog.txt \ + xorriso/xorriso_eng.html \ + xorriso/man_1_xorriso.html \ + "$lone_dir"/xorriso + +create_dir "$lone_dir"/test +copy_files \ + test/compare_file.c \ + "$lone_dir"/test/compare_file.c + + +# nglibisofs + +create_dir "$lone_dir"/libisofs +create_dir "$lone_dir"/libisofs/filters +goto_dir "$current_dir"/nglibisofs-develop +copy_files libisofs/*.[ch] "$lone_dir"/libisofs +copy_files libisofs/filters/*.[ch] "$lone_dir"/libisofs/filters +copy_files COPYRIGHT "$lone_dir"/libisofs + +# To get a common version.h +cat version.h.in >> "$lone_dir"/version.h.in + + +# <<< obsoleted patchings + +if test 1 = 0 +then + +# Change GNU macro name to POSIX name +sed -e 's/FNM_FILE_NAME/FNM_PATHNAME/g' \ + <libisofs/tree.c >"$lone_dir"/libisofs/tree.c + +# Filter out the semi-illegal TODO comments +( cd "$lone_dir"/libisofs && grep '^[[:space:]]*//' *.[ch] | less ) +echo "Is it ok delete all shown //-lines ?" +read yesno +if test "$yesno" = "y" -o "$yesno" = "1" +then + for i in "$lone_dir"/libisofs/*.[ch] + do + # first copy attributes + cp "$i" "$lone_dir"/libisofs/tmpfile + # now filter away // lines + grep -v '^[[:space:]]*//' <"$i" >"$lone_dir"/libisofs/tmpfile && \ + mv "$lone_dir"/libisofs/tmpfile "$i" + done +fi +echo "Remaining // lines:" +( cd "$lone_dir"/libisofs && grep '//' *.[ch] ) + +fi + + + +# libburn + +create_dir "$lone_dir"/libburn +goto_dir "$current_dir"/libburn-develop +copy_files libburn/*.[ch] "$lone_dir"/libburn +copy_files COPYRIGHT "$lone_dir"/libburn + + +# To get a common version.h +cat version.h.in >> "$lone_dir"/version.h.in + + +# tarball + +if test "$with_bootstrap_tarball" = 1 +then + +tarball_dir="$current_dir"/xorriso-"$xorriso_rev" +mv "$lone_dir" "$tarball_dir" + +goto_dir "$tarball_dir" + +./bootstrap + +# Remove unneeded temporary data from ./bootstrap +rm -r ./autom4te.cache + +# Repair non-portable shell code output of ./bootstrap +( + cd "$compile_dir" || exit 1 + sed -e 's/^for ac_header in$/test -z 1 \&\& for ac_header in dummy/' \ + < ./configure > ./configure-repaired + if test "$?" = 0 + then + echo "$0: Empty 'for ac_header in' found in configure." >&2 + fi + mv ./configure-repaired ./configure + chmod a+rx,go-w,u+w ./configure +) + +cd "$current_dir" +tar czf ./xorriso-"$xorriso_rev""$xorriso_pl".tar.gz $(basename "$tarball_dir") + +ls -l $(pwd)/xorriso-"$xorriso_rev""$xorriso_pl".tar.gz + +mv "$tarball_dir" "$lone_dir" + +fi + +echo "Done" +echo "HINT: Now build xorriso/xorriso by:" +echo " cd '$lone_dir' && ./configure && make" +echo diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorriso.1 b/libisoburn/branches/ZeroOneFour/xorriso/xorriso.1 new file mode 100644 index 00000000..771c1f1f --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorriso.1 @@ -0,0 +1,1947 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH XORRISO 1 "April, 3, 2008" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp <n> insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +xorriso - creates, loads, manipulates and writes ISO 9660 filesystem images +with Rock Ridge extensions. +.SH SYNOPSIS +.B xorriso +.RI [ settings | actions ] +.br +.SH DESCRIPTION +.PP +.B xorriso +is a program which maps file objects from POSIX compliant +filesystems into Rock Ridge enhanced ISO 9660 filesystems and allows +session-wise manipulation of such filesystems. It can load the management +information of existing ISO images and it writes the session results to +optical media or to filesystem objects. +.PP +A special property of xorriso is that it needs neither an external ISO 9660 +formatter program nor an external burn program for CD or DVD but rather +incorporates the libraries of libburnia-project.org . +.SS +.B Overview of features: +.br +Operates on an existing ISO image or creates a new one. +.br +Copies files from filesystem into the ISO image. +.br +Renames or deletes file objects in the ISO image. +.br +Changes file properties in the ISO image. +.br +Updates ISO subtrees incrementally to match given disk subtrees. +.br +Can write result as completely new image to optical media or +filesystem objects. +.br +Can write result as add-on session to appendable multi-session media, +to overwriteable media, to regular files, and to block devices. +.br +Scans for optical drives, blanks re-useable optical media. +.br +Reads its instructions from command line arguments, dialog, and batch files. +.br +Provides navigation commands for interactive ISO image manipulation. +.br +Adjustable thresholds for abort, exit value, and problem reporting. +.SS +.B General information paragraphs: +.br +Session model +.br +Media types and states +.br +Creating, Growing, Modifying +.br +Libburn drives +.br +Rock Ridge, POSIX, X/Open +.br +Command processing +.br +Dialog, Readline, Result pager +.sp 1 +Maybe you first want to have a look at section EXAMPLES near the end of +this text before reading the next few hundred lines of background information. +.SS +.B Session model: +.br +Unlike other filesystems, ISO 9660 is not intended for read-write operation but +rather for being generated in a single sweep and being written to media as a +.B session. +.br +The data content of the session is called filesystem +.B image. +.PP +The written image in its session can then be mounted by the operating system +for being used read-only. Linux is able to mount ISO images from block devices, +which may represent optical media, other media or via a loop device even +from regular disk files. +.PP +This session usage model has been extended on CD media by the concept of +.B multi-session , +which allows to add information to the CD and gives the mount programs +of the operating systems the addresses of the entry points of each +session. The mount programs recognize block devices which represent +CD media and will by default mount the image in the last session. +.br +This session usually contains an updated directory tree for the whole media +which governs the data contents in all recorded sessions. +So in the view of the mount program all sessions of a particular media +together form a single filesystem image. +.br +Adding a session to an existing ISO image is in this text referred as +\fBgrowing\fR. +.br +The multi-session model of the MMC standard does not apply to all media +types. But program growisofs by Andy Polyakov showed how to extend this +functionality to overwriteable media or disk files which carry valid ISO 9660 +filesystems. This expansion method is referred as emulated growing. +.PP +xorriso provides both ways of growing as well as an own method named +\fBmodifying\fR which produces a completely new ISO image from the old +one and the modifications. See paragraph Creating, Growing, Modifying below. +.PP +xorriso adopts the concept of multi-session by loading an eventual image +directory tree, allowing to manipulate it by several actions, and to write +the new image to the target media. +.br +The first session of a xorriso run begins by the definition of the input +drive with the eventual ISO image or by the definition of an output drive. +The session ends by command -commit which triggers writing. A -commit is +done automatically when the program ends regularly. +.PP +After -commit a new session begins with the freshly written one as input. +A new input drive can only be chosen as long as the loaded ISO image was +not altered. Pending alteration can be revoked by command -rollback. +.PP +Writing a session to the target is supposed to be very expensive in terms of +time and of consumed space on appendable or write-once media. Therefore all +intended manipulations of a particular ISO image should be done in a single +session. +.br +In some special situations (e.g. in a file-to-file situation) it can be +useful to store intermediate states and to continue with image manipulations. +.SS +.B Media types and states: +There are two families of media in the MMC standard: +.br +\fBMulti-session\fR media are CD-R, CD-RW, DVD-R, DVD+R, DVD+R/DL, and +unformatted DVD-RW. These media provide a table of content which +describes their existing sessions. +.br +\fBOverwriteable\fR media are DVD-RAM, DVD+RW, and formatted DVD-RW. +They allow random write access but do not provide information about their +session history. +.br +DVD-RW media can be formatted by -format full. +They can be made unformatted by -blank deformat. +.br +Emulated drives are handled as overwriteable media if they are random +read-write accessible. If they are only sequentially writeable then +they are handled as blank multi-session media. +.PP +These media can assume several states in which they offer different +capabilities. +.br +\fBBlank\fR media can be written from scratch. They contain no ISO image +suitable for xorriso. +.br +Blank is the state of newly purchased optical media. +With used CD-RW and DVD-RW it can be achieved by action -blank "fast". +Overwriteable media are considered blank unless they contain an ISO image +suitable for xorriso. Action -blank "fast" can be used to invalidate the image +on overwriteable media. +.br +\fBAppendable\fR media accept further sessions. Either they are MMC +multi-session media in appendable state, or they are overwriteable media +which contain an ISO image suitable for xorriso. +.br +Appendable is the state after writing a session with option -close off. +.br +\fBClosed\fR media cannot be written. They may contain an ISO image suitable +for xorriso. +.br +Closed is the state of DVD-ROM media and of multi-session media which were +written with option -close on. If the drive is incapable of writing it will +probably show any media as closed CD-ROM resp. DVD-ROM. +.br +Overwriteable media assume this state only in such read-only drives. +.SS +.B Creating, Growing, Modifying: +.br +A new empty ISO image gets \fBcreated\fR +if there is no input drive with a valid +ISO 9660 image plus Rock Ridge extensions when the first time an output drive +is defined. This is achieved by option -dev on blank media or by option -outdev +on media in any state. +.br +The new empty image can be populated with directories and files. +Before it can be written, the media in the output drive must get into +blank state if it was not blank already. +.PP +If there is a input drive with a valid ISO image, then this image gets loaded +as foundation for manipulations and extension. The constellation of input +and output drive determines which of two write methods will be used. +They have quite different capabilities and constraints. +.PP +The method of \fBgrowing\fR adds new data to the existing media. These +data comprise of eventual new file content and they override the existing +ISO 9660 + Rock Ridge directory tree. It is possible to hide files from +previous sessions but they still exist on media and with many types of +optical media it is quite easy to recover them by mounting older sessions. +.br +Growing is achieved by option -dev. +.PP +The write method of \fBmodifying\fR produces compact filesystem +images with no outdated files or directory trees. Modifying can write its +images to target media which are completely unsuitable for multi-session +operations. E.g. fast blanked DVD-RW, named pipes, character devices, sockets. +On the other hand modified sessions cannot be written to appendable media +but to blank media only. +.br +Modifying takes place whenever input drive and output drive are not the same. +This is achieved by options -indev and -outdev. +.br +So for this method one needs either two optical drives or has to work with +filesystem objects as source and/or target media. +.SS +.B Libburn drives: +.br +Input drive, i.e. source of an existing or empty ISO image, can be any random +access readable libburn drive: optical media with readable data, +blank optical media, regular files, block devices. +.br +Rock Ridge info must be present in existing ISO images and it will be generated +by the program unconditionally. +.PP +Output drive, i.e. target for writing, can be any libburn drive. +Some drive types do not support the method of growing but only the method +of modifying. They all are suitable for newly created images. +.br +All drive file objects have to offer rw-permission to the user of xorriso. +Even those which will not be useable for reading an ISO image. +.PP +MMC compliant (i.e. optical) drives on Linux usually get addressed by +the path of their block device or of their generic character device. E.g. +.br + -dev /dev/sr0 +.br + -dev /dev/hdc +.br + -dev /dev/sg2 +.br +Get a list of accessible drives by command +.br + -devices +.br +It might be necessary to do this as +.B superuser +in order to see all drives and to then allow rw-access for the intended users. +Consider to bundle the authorized users in a group like old "floppy". +.PP +Filesystem objects of nearly any type can be addressed by prefix "stdio:" and +their path in the filesystem. E.g.: +.br + -dev stdio:/tmp/pseudo_drive +.br +If path leads to a regular file or to a block device then the emulated drive +is random access readable and can be used for the method of growing if it +already contains a valid ISO 9660 image. Any other file type is not readable +via "stdio:" and can only be used as target for the method of modifying. +Non existing paths in existing directories are handled as empty regular files. +.PP +A very special kind of pseudo drive are open file descriptors. They are +depicted by "stdio:/dev/fd/" and descriptor number (see man 2 open). +.br +Addresses "-" or "stdio:/dev/fd/1" depict standard output, which normally is +the output channel for result texts. +To prevent a fatal intermingling of ISO image and text messages, all result +texts get redirected to stderr if -*dev "-" or "stdio:/dev/fd/1" is among +the start arguments of the program. +.br +Standard output is currently suitable for creating a single new session +per program run without dialog. Use in other situations is discouraged +and several restrictions apply: +.br +It is not allowed to use standard output as pseudo drive if it was not +among the start arguments. Do not try to fool this ban via backdoor addresses +to stdout. +.br +If stdout is used as drive, then -use_readline is permanently disabled. +Use of backdoors will cause severe memory and/or terminal corruption. +.PP +Be aware that especially the superuser can write into any accessible file or +device by using its path with the "stdio:" prefix. Addresses without prefix +"stdio:" will only work if they lead to a MMC drive. +.br +One may use option +.B -ban_stdio_write +to surely prevent this risk and to allow only MMC drives. +.SS +.B Rock Ridge, POSIX, X/Open: +.br +.B Rock Ridge +is the name of a set of additional informations which enhance +an ISO 9660 filesystem so that it can represent a POSIX compliant filesystem +with ownership, access permissions, symbolic links, and other attributes. +.PP +This is what xorriso uses for a decent representation of the disk files +within the ISO image. Rock Ridge information is produced with any xorriso +image and xorriso will load for manipulation only Rock Ridge enhanced images. +.PP +xorriso is not named "porriso" because POSIX only guarantees 14 characters +of filename length. It is the X/Open System Interface standard XSI which +demands a file name length of up to 255 characters and paths of up to 1024 +characters. Rock Ridge fulfills this demand. +.SS +.B Command processing: +.br +Commands are either actions or settings. They consist of a command word, +followed by zero or more parameter words. If the list of parameter words +is of variable length (indicated by "[...]" or "[***]") then it has to be +terminated by either the word "--" or the end of argument list or an end of +an input line. +It is not an error if "--" appears after the parameters of a command +with a fixed list length. +.PP +.B Pattern expansion +is a property of some particular commands and not a general +feature. It gets controlled by commands -iso_rr_pattern and -disk_pattern. +Commands which eventually use pattern expansion all have variable argument +lists which are marked in this man page by "[***]" rather than "[...]". +.br +Some other commands perform pattern matching unconditionally. +.PP +Command and parameter words are either read from program arguments, where one +argument is one word, or from input lines where words are recognized similar +to the quotation rules of a shell parser. +.br +xorriso is not a shell, although it might appear so on first glimpse. +Be aware that the interaction of quotation marks and pattern symbols like "*" +differs from the usual shell parsers. In xorriso, a quotation mark does not +make a pattern symbol literal. +.PP +When the program begins then it first looks for argument -no_rc. If this is +not present then it looks for its startup files and +eventually reads their content as command input lines. Then it interprets +the program arguments as commands and parameters and finally it enters +dialog mode if command -dialog "on" was executed up to then. +.PP +The program ends either by command -end, or by the end of program arguments +if not dialog was enabled up to that moment, or by a problem +event which triggers the threshold of command -abort_on. +.SS +.B Dialog, Readline, Result pager: +.br +Dialog mode prompts for an input line, parses it into words, and performs +them as commands with their parameters. It provides assisting services +to make dialog more comfortable. +.PP +Readline is an enhancement for the input line. You may know it already from +the bash shell. Whether it is available in xorriso depends on the availability +of package readline-dev at the time when xorriso was built from its sourcecode. +.br +It allows to move the cursor over the text in the line by help of the +Leftward and the Rightward arrow key. +Text may be inserted at the cursor position. The Delete key removes the +character under the cursor. Upward and Downward arrow keys navigate through +the history of previous input lines. +.br +See man readline for more info about libreadline. +.PP +Option -page activates a builtin result text pager which may be convenient in +dialog. After an action has put out the given number of terminal lines, +the pager prompts the user for a line of input. +.br +An empty line lets xorriso resume work until the next page is put out. +.br +The single character "@" disables paging for the current action. +.br +"@@@", "x", "q", "X", or "Q" urge the current action to abort and suppress +further result output. +.br +Any other line will be interpreted as new dialog line. The current action +is urged to abort. Afterwards, the input line is executed. +.PP +Some actions apply paging to their info output, too. +.br +The urge to abort may or may not be obeyed by the current action. All actions +try to abort as soon as possible. +.br +.SH OPTIONS +.br +All command words are shown with a leading dash although this dash is not +mandatory for the option to be recognized. There may be future emulation +modes, where dashes may become mandatory in order to distinguish options +from file addresses. +.TP +.B Aquiring source and target drive: +.TP +\fB\-dev\fR address +Set input and output drive to the same address and load an eventual ISO image. +If there is no ISO image then create a blank one. +Set the image expansion method to growing. +.br +This is only allowed as long as no changes are pending in the currently +loaded ISO image. Eventually one has to perform -commit or -rollback first. +Violation yields a FAILURE event. +.br +Special address string "-" means standard output, to which several restrictions +apply. See above paragraph "Libburn drives". +.br +An empty address string "" gives up the current device +without aquiring a new one. +.TP +\fB\-indev\fR address +Set input drive and load eventual ISO image. If the new input drive differs +from -outdev then switch from growing to modifying. The same rules and +restrictions apply as with -dev. +.TP +\fB\-outdev\fR address +Set output drive and if it differs from the input drive then switch from +growing to modifying. Unlike -dev and -indev this action does not load a +new ISO image. So it can be performed even if there are pending changes. +.br +-outdev can be performed without previous -dev or -indev. In that case an +empty ISO image with no changes pending is created. It can either be populated +by help of -add or it can be discarded silently if -dev or -indev are +performed afterwards. +.br +Special address string "-" means standard output, to which several restrictions +apply. See above paragraph "Libburn drives". +.br +An empty address string "" gives up the current output drive +without aquiring a new one. No writing is possible without an output drive. +.TP +\fB\-ban_stdio_write\fR +Allow for writing only the usage of MMC optical drives. Disallow +to write the result into files of nearly arbitrary type. +Once set, this command cannot be revoked. +.TP +.B Data manipulations: +.PP +The following commands expect file addresses of two kinds: +.br +.B disk_path +is a path to an object in the local filesystem tree. +.br +.B iso_rr_path +is the Rock Ridge name of a file object in the ISO image. (Do not +confuse with the lowlevel ISO 9660 names visible if Rock Ridge gets ignored.) +.PP +Note that in the ISO image you are as powerful as the superuser. Access +permissions of the existing files in the image do not apply to your write +operations. They are intended to be in effect with the read-only mounted image. +.PP +If the iso_rr_path of a newly inserted file leads to an existing +file object in the ISO image, then the following collision handling +happens: +.br +If both objects are directories then they get merged by recursively inserting +the subobjects from filesystem into ISO image. +If other file types collide then the setting of command +.B \-overwrite +decides. +.br +Renaming of files has similar collision handling, but directories can only +be replaced, not merged. Directories can hardly collide on renaming because +of the shell-like behavior of -mv: if a file object hits an existing directory +then it gets inserted rather than trying to replace that directory. +Nevertheless, the overwriting rules apply if an operation of xorriso +ever attempts to do such a replacement. +.PP +The commands in this section alter the ISO image and not the local filesystem. +.TP +\fB\-iso_rr_pattern\fR "on"|"ls"|"off" +Set the pattern expansion mode for the iso_rr_path arguments of several +commands which support this feature. +.br +.B Pattern expansion +converts a list of pattern words into a list of existing file addresses. +Eventual unmatched pattern words appear themselves in that result list, though. +.br +Pattern matching supports the usual shell parser wildcards '*' '?' '[xyz]' +and respects '/' as separator which may only be matched literally. +.br +Setting "off" disables this feature for all commands which are marked in this +man page by "iso_rr_path [***]" or "iso_rr_pattern [***]". +.br +Setting "on" enables it for all those commands. +.br +Setting "ls" enables it only for those which are marked by +"iso_rr_pattern [***]". +.br +Default is "on". +.TP +\fB\-disk_pattern\fR "on"|"ls"|"off" +Set the pattern expansion mode for the disk_path arguments of several +commands which support this feature. +.br +Setting "off" disables this feature for all commands which are marked in this +man page by "disk_path [***]" or "disk_pattern [***]". +.br +Setting "on" enables it for all those commands. +.br +Setting "ls" enables it only for those which are marked by +"disk_pattern [***]". +.br +Default is "ls". +.TP +\fB\-add\fR pathspec [...] | disk_path [***] +Insert the given files or directory trees from filesystem +into the ISO image. +.br +If -pathspecs is set to "on" then pattern expansion is always disabled and +character '=' has a special meaning. It eventually separates the ISO image path +from the disk path: +.br +iso_rr_path=disk_path +.br +The separator '=' can be escaped by '\\'. +If iso_rr_path does not begin with '/' then -cd is prepended. +If disk_path does not begin with '/' then -cdx is prepended. +.br +If no '=' is given then the word is used as both, iso_rr_path and disk path. +If in this case the word does not begin with '/' then -cdx is prepended to +the disk_path and -cd is prepended to the iso_rr_path. +.br +If -pathspecs is set to "off" then eventual -disk_pattern expansion applies. +The resulting words are used as both, iso_rr_path and disk path. Eventually +-cdx gets prepended to disk_path and -cd to iso_rr_path. +.TP +\fB\-add_plainly\fR mode +If set to mode "unknown" then any command word that does not begin with "-" and +is not recognized as known command will be subject to a virtual -add command. +I.e. it will be used as pathspec or as disk_path and added to the image. +Eventually -disk_pattern expansion applies to disk_paths. +.br +Mode "dashed" is similar to "unknown" but also adds unrecognized command +words even if they begin with "-". +.br +Mode "any" announces that all further words are to be added as pathspecs +or disk_paths. This does not work in dialog mode. +.br +Mode "none" is the default. It prevents any words from being understood +as files to add, if they are not parameters to appropriate commands. +.TP +\fB\-path_list\fR disk_path +Like -add but read the parameter words from file disk_path +or standard input if disk_path is "-". +The list must contain exactly one pathspec resp. disk_path pattern per line. +.TP +\fB\-cpr\fR disk_path [***] iso_rr_path +Insert the given files or directory trees from filesystem +into the ISO image. +.br +The rules for generating the ISO addresses are similar as with +shell command cp -r. Nevertheless, directories of the iso_rr_path +are created if necessary. Especially a not yet existing iso_rr_path +will be handled as directory if multiple disk_paths are present. +The leafnames of the multiple disk_paths will be grafted under that +directory as would be done with an existing directory. +.br +If a single disk_path is present then a non-existing iso_rr_path will +get the same type as the disk_path. +.br +If a disk_path does not begin with '/' then -cdx is prepended. +If the iso_rr_path does not begin with '/' then -cd is prepended. +.TP +\fB\-update\fR disk_path iso_rr_path +Compare file object disk_path with file object iso_rr_path. If they do not +match, then perform the necessary image manipulations to make iso_rr_path +a matching copy of disk_path. This comparison will imply lengthy content +reading before a decision is made. On the other hand it strives for the +smallest possible amount of add-on data which is needed to achieve the +matching copy. +.TP +\fB\-update_r\fR disk_path iso_rr_path +Like -update but working recursively. I.e. all file objects below both +addresses get compared whether they have counterparts below the other address +and whether both counterparts match. If there is a mismatch then the necessary +update manipulation is done. +.br +Note that the comparison result may depend on option -follow. Its setting +should always be the same as with the first adding of disk_path as iso_rr_path. +.br +If iso_rr_path does not exist yet, then it gets added. If disk_path does not +exist, then iso_rr_path gets deleted. +.br +-update_r is also a convenient compromise between -add addressing and -cp_r +addressing: Its semantics is similar to -add and thus avoids the pitfalls +inherited from cp -r behavior. Its syntax resembles cp, though. +.TP +\fB\-cut_out\fR disk_path byte_offset byte_count iso_rr_path +Map a byte interval of a regular disk file into a regular file in the ISO +image. +This may be necessary if the disk file is larger than a single media, or if +it exceeds the traditional limit of 2 GiB - 1 for old operating systems, +or the limit of 4 GiB - 1 for newer ones. +.br +A clumsy remedy for this limit is to backup file pieces and to concatenate +them at restore time. A well tested chopping size is 2047m. +It is permissible to request a higher byte_count than available. The +resulting file will be truncated to the correct size of a final piece. +To request a byte_offset higher than available yields no file in +the ISO image but a SORRY event. +E.g: +.br + -cut_out /my/disk/file 0 2047m \\ +.br + /file/part_1_of_3_at_0_with_2047m_of_5753194821 \\ +.br + -cut_out /my/disk/file 2047m 2047m \\ +.br + /file/part_2_of_3_at_2047m_with_2047m_of_5753194821 \\ +.br + -cut_out /my/disk/file 4094m 2047m \\ +.br + /file/part_3_of_3_at_4094m_with_2047m_of_5753194821 +.br +-cut_out is coordinated with -compare* and -update* if the names of the +part files follow a convention by which xorriso is able to recognize +file parts and process them accordingly: +.br +A disk file gets mapped to an ISO directory containing its split parts +as regular files. The parts have names which describe the splitting +by 5 numbers which are separated by some non-numerical text: +.br +part_number, total_parts, byte_offset, byte_count, disk_file_size +.br +Scaling characters like "m" or "k" are taken into respect and may +serve as separators as well. All digits are interpreted as decimal, +even if leading zeros are present. +.br +Not all parts have to be present on the same media. But those parts +which are present have to sit in the same directory. No other files +are allowed in there. Parts have to be disjoint. Their numbers have +to be plausible. E.g. byte_count must be valid as -cut_out argument +and it must be the same with all parts. +.br +If the disk file grows enough to need new parts then those get added +to the directory if it already contains all parts of the old disk file. +If not all parts are present, then only those present parts will +be updated. +.TP +\fB\-rm\fR iso_rr_path [***] +Delete the given files from the ISO image. +.br +Note: This does not free any space on the -indev media, even if +the deletion is committed to that same media. +.br +The image size will shrink if the image is written to a different +media in modification mode. +.TP +\fB\-rm_r\fR iso_rr_path [***] +Delete the given files or directory trees from the ISO image. +See also the note with option -rm. +.TP +\fB\-mv\fR iso_rr_path [***] iso_rr_path +Rename the given file objects in the ISO tree to the last +argument in the list. Use the same rules as with shell command mv. +.br +If pattern expansion is enabled and if the last argument contains wildcard +characters then it must match exactly one existing file address, or else the +command fails with a FAILURE event. +.TP +\fB\-chown\fR uid iso_rr_path [***] +Set ownership of file objects in the ISO image. uid may either be a decimal +number or the name of a user known to the operating system. +.TP +\fB\-chown_r\fR uid iso_rr_path [***] +Like -chown but affecting all files below eventual directories. +.TP +\fB\-chgrp\fR gid iso_rr_path [***] +Set group attribute of file objects in the ISO image. gid may either be a +decimal number or the name of a group known to the operating system. +.TP +\fB\-chgrp_r\fR gid iso_rr_path [***] +Like -chgrp but affecting all files below eventual directories. +.TP +\fB\-chmod\fR mode iso_rr_path [***] +Equivalent to shell command chmod in the ISO image. +mode is either an octal number beginning with "0" or a comma separated +list of statements of the form [ugoa]*[+-=][rwxst]* . +.br +Like: go-rwx,u+rwx . +.br +.B Personalities: +u=user, g=group, o=others, a=all +.br +.B Operators: ++ adds given permissions, - revokes given permissions, += revokes all old permissions and then adds the given ones. +.br +.B Permissions: +r=read, w=write, x=execute|inspect, s=setuid|setgid, t=sticky bit +.br +For octal numbers see man 2 stat. +.TP +\fB\-chmod_r\fR mode iso_rr_path [***] +Like -chmod but affecting all files below eventual directories. +.TP +\fB\-alter_date\fR type timestring iso_rr_path [***] +Alter the date entries of a file in the ISO image. type is +one of "a", "m", "b" for access time, modification time, +both times. +.br +timestring may be in the following formats +(see also section EXAMPLES): +.br +As expected by program date: + MMDDhhmm[[CC]YY][.ss]] +.br +As produced by program date: + [Day] MMM DD hh:mm:ss [TZON] YYYY +.br +Relative times counted from current clock time: + +|-Number["s"|"h"|"d"|"w"|"m"|"y"] +.br +where "s" means seconds, "h" hours, "d" days, "w" weeks, "m"=30d, +"y"=365.25d plus 1d added to multiplication result. +.br +Absolute seconds counted from Jan 1 1970: + =Number +.br +xorriso's own timestamps: + YYYY.MM.DD[.hh[mm[ss]]] +.br +scdbackup timestamps: + YYMMDD[.hhmm[ss]] +.br +where "A0" is year 2000, "B0" is 2010, etc. +.TP +\fB\-alter_date_r\fR type timestring iso_rr_path [***] +Like -alter_date but affecting all files below eventual directories. +.TP +\fB\-find\fR iso_rr_path [-name pattern] [-type t] [-exec action [params]] -- +A very restricted substitute for shell command find in the ISO image. +It performs an action on matching file objects at or below iso_rr_path. +.br +Optional -name pattern is not expanded but used for comparison with +the particular file names of the eventual directory tree underneath +iso_rr_path. If no -name pattern is given, then any file name matches. +.br +The optional -type test restricts matching to files of the given type: +"block", "char", "dir", "pipe", "file", "link", "socket", +"Xotic" which eventually matches what is not matched by the other types. +.br +Only the first letter is interpreted. E.g.: -find / -type d +.br +If a file matches then the action is performed. Default action is "echo", +i.e. to print the address of the found file. Other actions are certain +xorriso commands which get performed on the found files. These commands +may have specific parameters. See also their particular descriptions. +.br +"chown" and "chown_r" change the ownership and get the user id as param. E.g.: +.br + -find / -exec chown thomas -- +.br +"chgrp" and "chgrp_r" change the group attribute and get the group id as param. +E.g.: +.br + -find / name 'news*' -type d -exec chgrp_r staff -- +.br +"chmod" and "chmod_r" change access permissions and get a mode string as param. +E.g.: +.br + -find / -exec chmod a-w,a+r -- +.br +"alter_date" and "alter_date_r" change the timestamps. +They get a type character and a timestring as params. +E.g.: +.br + -find / -exec alter_date "m" "Dec 30 19:34:12 2007" -- +.br +"lsdl" prints file information like shell command ls -dl. +E.g.: +.br + -find / -exec lsdl -- +.br +"compare" performs command -compare with the found file address as iso_rr_path +and the corresponding file address below its argument disk_path_start. For this +the iso_rr_path of the -find command gets replaced by the disk_path_start. +E.g.: +.br + -find / -exec compare /home/thomas -- +.br +"update" performs command -update with the found file address as iso_rr_path. +The corresponding file address is determined like with above "compare". +.br +E.g.: +.br + -find / -exec update /home/thomas -- +.br +"rm" removes the found iso_rr_path from the image if it is not a directory with +files in it. I.e. this "rm" includes "rmdir". +.br +E.g.: +.br + -find / -name *.doc -exec rm -- +.br +"rm_r" removes the found iso_rr_path from the image, including whole directory +trees. +.br +E.g.: +.br + -find /uh/oh -name *private* -exec rm_r -- +.br +"find" performs another run of -find on the matching file address. It accepts +the same params as -find, except iso_rr_path. +E.g.: +.br + -find / -name '???' -type d -exec find -name '[abc]*' -exec chmod a-w,a+r -- +.br +If not used as last command in the line then the argument list +needs to get terminated by "--". +.TP +\fB\-mkdir\fR iso_rr_path [...] +Create empty directories if they do not exist yet. +Existence as directory generates a WARNING event, existence as +other file causes a FAILURE event. +.TP +\fB\-rmdir\fR iso_rr_path [***] +Delete empty directories. +.TP +\fB\-\-\fR +.br +Mark end of particular action argument list. +.TP +\fB\-rollback\fR +Discard the manipulated ISO image and reload it from -indev. +.TP +\fB\-rollback_end\fR +Discard the manipulated ISO image. End program without loading a new image. +.TP +.B Writing the result: +(see also paragraph about settings below) +.TP +\fB\-commit\fR +Perform the write operation. Afterwards eventually make the +-outdev the new -dev and load the image from there. +Switch from eventual modifiying mode to growing mode. +(A subsequent -outdev will activate modification mode.) +-commit is performed automatically at end of program if there +are uncommitted manipulations pending. +So, to perform a final write operation with no new -dev +and no new loading of image, rather execute option -end. +To suppress a final write, execute -rollback -end. +To eject outdev after write without new loading of image, use -commit_eject. +.br + +Writing can last quite a while. It is not unnormal with several +types of media that there is no progress visible for the first +few minutes or that the drive gnaws on the media for a few +minutes after all data have been transmitted. +xorriso and the drives are in a client-server relationship. +The drives have much freedom about what to do with the media. +Some combinations of drives and media simply do not work, +despite the promises by their vendors. +If writing fails - or even the drive gets stuck and you need +to reboot - then try other media or another drive. The reason +for such failure is hardly ever in the code of the various +burn programs but you may well try some of those listed below +under SEE ALSO. +.TP +\fB\-eject\fR "in"|"out"|"all" +Eject the media in -indev, resp. -outdev, resp. both drives. +Note: It is not possible yet to effectively eject disk files. +.TP +\fB\-commit_eject\fR "in"|"out"|"all"|"none" +Combined -commit and -eject. When writing has finished do not make +-outdev the new -dev, and load no ISO image. Rather eject +-indev and/or -outdev. Eventually give up any non-ejected drive. +.TP +\fB\-blank\fR mode +Blank media resp. invalidate ISO image on media if not -dummy +is activated. +.br +This affects only the -outdev not the -indev. +If both drives are the same and if the ISO image was altered +then this command leads to a FAILURE event. +Defined modes are: + fast, all, deformat, deformat_quickest +.br +"fast" and "all" make CD-RW and unformatted DVD-RW re-usable, +or invalidate overwriteable ISO images. +"deformat" converts overwriteable DVD-RW into unformatted ones. +"deformat_quickest" is a faster way to deformat or blank DVD-RW +but produces media which are only suitable for a single session. +xorriso will write onto them only if option -close is set to "on". +.br +The progress reports issued by some drives while blanking are +quite unrealistic. Do not conclude success or failure from the +reported percentages. Blanking was successful if no SORRY event or +worse occured. +.TP +\fB\-format\fR mode +Convert unformatted DVD-RW into overwriteable ones, +"de-ice" DVD+RW. +For now, mode should be the word "full". +.br +This action has no effect on media if -dummy is activated. +.br +Be warned that re-formatting DVD+RW is considered to be risky +to the media's health. DVD+RW get formatted as far as needed +during writing, but an entirely formatted media might be better +readable in some DVD players. +.br +On the other hand unreliable DVD+RW can sometimes be repaired by +re-formatting. +.br + +The progress reports issued by some drives while formatting are +quite unrealistic. Do not conclude success or failure from the +reported percentages. Formatting was successful if no SORRY event +or worse occured. +.TP +.B Settings for data insertion: +.TP +\fB\-follow\fR occasion[:occasion[...]] +Enable or disable resolution of symbolic links and mountpoints under +disk_paths. This applies to actions -add, -du*x, -ls*x, -findx, +and to -disk_pattern expansion. +.br +There are two kinds of follow decisison to be made: +.br +"link" is the hop from a symbolic link to its target file object. +If enabled then symbolic links are handled as their target file objects, +else symbolic links are handled as themselves. +.br +"mount" is the hop from one filesystem to another subordinate filesystem. +If enabled then mountpoint directories are handled as any other directory, +else mountpoints are handled as empty directories if they are encountered in +directory tree traversals. +.br +Less general than above occasions: +.br +"pattern" is mount and link hopping, but only during -disk_pattern expansion. +.br +"param" is link hopping for parameter words (after eventual pattern expansion). +If enabled then -ls*x will show the link targets rather than the links +themselves. -du*x, -findx, and -add will process the link targets but not +follow links in an eventual directory tree below the targets (unless "link" +is enabled). +.br +Occasions can be combined in a colon separated list. All occasions +mentioned in the list will then lead to a positive follow decision. +.br +"off" prevents any positive follow decision. Use it if no other occasion +applies. +.br +Shortcuts: +.br +"default" is equivalent to "pattern:mount:limit=100". +.br +"on" always decides positive. Equivalent to "link:mount". +.br + +Not an occasion but an optional setting is: +.br +"limit="<number> which sets the maximum number of link hops. +A link hop consists of a sequence of symbolic links and a final target +of different type. Nevertheless those hops can loop. Example: +.br + \fB$\fR ln -s .. uploop +.br +Link hopping has a builtin loop detection which stops hopping at the first +repetition of a link target. Then the repeated link is handled as itself +and not as its target. +Regrettably one can construct link networks which +cause exponential workload before their loops get detected. +The number given with "limit=" can curb this workload at the risk of truncating +an intentional sequence of link hops. +.TP +\fB\-pathspecs\fR "on"|"off" +Control parameter interpretation with xorriso actions -add and -path_list. +.br +"on" enables pathspecs of the form +.B target=source +like with program mkisofs -graft-points. +It also disables -disk_pattern expansion for command -add. +.br +"off" disables pathspecs of the form target=source +and eventually enables -disk_pattern expansion. +.TP +\fB\-overwrite\fR "on"|"nondir"|"off" +Allow or disallow to overwrite existing files in the +ISO image by files with the same user defined name. +.br +With setting "off", name collisions cause FAILURE events. +With setting "nondir", only directories are protected by such events, other +existing file types get treated with -rm before the new file gets added. +Setting "on" allows automatic -rm_r. I.e. a non-directory can replace an +existing directory and all its subordinates. +.TP +\fB\-split_size\fR number["k"|"m"] +Set the threshold for automatic splitting of regular files. Such splitting +maps a large disk file onto a ISO directory with several part files in it. +This is necessary if the size of the disk file exceeds 4 GiB - 1. +Older operating systems can handle files only if they are smaller than 2 GiB. +See also option -cut_out for more information about file parts. +.br +Default is 0 which will exclude files >= 4 GiB by a FAILURE event. +A well tested -split_size is 2047m. Sizes of 4 GiB or more are not permissible. +.TP +.B Settings for result writing: +.TP +Rock Ridge info will be generated by the program unconditionally. +.TP +\fB\-joliet\fR "on"|"off" +If enabled by "on", generate Joliet info additional to Rock Ridge info. +.TP +\fB\-volid\fR text +Specifies the volume ID. xorriso accepts any text up to 32 characters, +but according to rarely obeyed specs stricter rules apply: +.br +ECMA 119 demands character set [A-Z0-9_]. Like: "IMAGE_23" +.br +Joliet allows 16 UCS-2 characters. Like: "Windows name" +.br +Be aware that the volume id might get used automatically as name of the +mount point when the media is inserted into a playful computer system. +.br +If an ISO image gets loaded while the volume ID is set to default "ISOIMAGE" +or to "", then the volume ID of the loaded image will become the effective +volume id for the next write run. But as soon as command -volid is performed +afterwards, this pending id is overridden by the new setting. +.br +Consider this when setting -volid "ISOIMAGE" before executing -dev, -indev, +or -rollback. +If you insist in -volid "ISOIMAGE", set it again after those commands. +.TP +\fB\-uid\fR uid +User id to be used for all files when the new ISO tree gets written to media. +.TP +\fB\-gid\fR gid +Group id to be used for all files when the new ISO tree gets written to media. +.TP +\fB\-speed\fR number[k|m|c|d] +Set the burn speed. Default is 0 = maximum speed. +Speed can be given in media dependent numbers or as a +desired throughput per second in MMC compliant kB (= 1000) +or MB (= 1000 kB). Media x-speed factor can be set explicity +by "c" for CD and "d" for DVD. Example speeds: +.br + 706k = 706kB/s = 4c = 4xCD +.br + 5540k = 5540kB/s = 4d = 4xDVD +.br +If there is no hint about the speed unit attached, then the +media in the -outdev will decide. Default unit is CD = 176.4k. +.br +MMC drives usually activate their own idea of speed and take +the speed value given by the burn program only as upper limit +for their own decision. +.TP +\fB\-dummy\fR "on"|"off" +If "on" simulate burning or refuse with FAILURE event if +no simulation is possible, do neither blank nor format. +.TP +\fB-fs\fR number["k"|"m"] +Set the size of the fifo buffer which smoothens the data +stream from ISO image generation to media burning. Default +is 4 MiB, minimum 64 kiB, maximum 1 GiB. +The number may be followed by letter "k" or "m" +which means unit is kiB (= 1024) or MiB (= 1024 kiB). +.TP +\fB\-close\fR "on"|"off" +If "on" then mark the written media as not appendable +any more (if possible at all with the given type of target media). +.br +This is the contrary of cdrecord, wodim, cdrskin option -multi, +and is one aspect of growisofs option -dvd-compat. +.TP +\fB\-padding\fR number["k"|"m"] +Append the given number of extra bytes to the image stream. +This is a traditional remedy for a traditional bug in block +device read drivers. Needed only for CD recordings in TAO mode. +Since one can hardly predict on what media an image might end up, +xorriso adds the traditional 300k of padding by default to all images. +.br +For images which will never get to a CD it is safe to use -padding 0 . +.TP +\fB\-boot_image\fR "any"|"isolinux" "discard"|"keep"|"patch" +Defines the handling of an eventual boot image (El-Torito) which has been read +from an existing ISO image. All types ("any") can be discarded or kept +unaltered. The latter makes only sense if the format of the boot image is +relocatable without content changes. +.br +The boot image type "isolinux" can be kept unaltered (not advisable), or +discarded, or it can be patched to match its relocation. In the latter case +the resulting ISO image is bootable if the boot image was really complying +to the isolinux standard. +.br +Creation of new boot images is not yet possible. +.br +CAUTION: +This is an expert option. xorriso is not an expert yet. +It cannot recognize the inner form of boot images. +So the user has already to know about the particular needs of the +bootimage which is present on the input media. +Most safe is the default: "any" "discard". +.TP +.B Exception processing: +.PP +Since the tasks of xorriso are manifold and prone to external influence, there +may arise the need for xorriso to report and handle problem events. +.br +Those events get classified when they are detected by one of the software +modules and forwarded to reporting and evaluation modules which decide about +reactions. Event classes are sorted by severity: +.br +"NEVER" The upper end of the severity spectrum. +.br +"ABORT" The program is being aborted and on its way to end. +.br +"FATAL" The main purpose of the run failed +or an important resource failed unexpectedly. +.br +"FAILURE" An important part of the job could not be performed. +.br +"MISHAP" A FAILURE which can be tolerated during ISO image generation. +.br +"SORRY" A less important part of the job could not be performed. +.br +"WARNING" A situation is suspicious of being not intended by the user. +.br +"HINT" A proposal to the user how to achieve better results. +.br +"NOTE" A harmless information about noteworthy circumstances. +.br +"UPDATE" A pacifier message during long running operations. +.br +"DEBUG" A message which would only interest the program developers. +.br +"ALL" The lower end of the severity spectrum. +.TP +\fB\-abort_on\fR severity +Set the severity threshold for events to abort the program. +.br +Useful: "NEVER", "ABORT", "FATAL", "FAILURE" , "MISHAP", "SORRY" +.br +It may become necessary to abort the program anyway, despite +the setting by this option. Expect not many "ABORT" events to +be ignorable. +.br +A special property of this option is that it works preemptive if given as +program start argument. I.e. the first -abort_on setting among the +start arguments is in effect already when the first operations of xorriso +begin. Only "-abort_on" with dash "-" is recognized that way. +.TP +\fB\-return_with\fR severity exit_value +Set the threshold and exit_value to be returned at program end if no abort +has happened. This is to allow xorriso to go on after problems but to get +a failure indicating exit value from the program, nevertheless. +Useful is a value lower than the -abort_on threshold, down to "WARNING". +.br +exit_value may be either 0 (indicating success to the starter of the program) +or a number between 32 and 63. Some other exit_values are used by xorriso if +it decides to abort the program run: +.br +1=abort due to external signal +.br +2=no program arguments given +.br +3=creation of xorriso main object failed +.br +4=failure to start libburnia-project.org libraries +.br +5=program abort during argument processing +.br +6=program abort during dialog processing +.TP +\fB\-report_about\fR severity +Set the threshold for events to be reported. +.br +Useful: "SORRY", "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL" +.br +Regardless what is set by -report_about, messages get always reported if they +reach the severity threshold of -abort_on . +.br +Event messages are sent to the info channel "I" which is usually stderr +but may be influenced by command -pkt_output. +Info messages which belong to no event get attributed severity "NOTE". +.br +A special property of this option is that the first -report_about setting +among the start arguments is in effect already when the first operations +of xorriso begin. Only "-report_about" with dash "-" is recognized that way. +.TP +.B Dialog mode control: +.TP +\fB\-dialog\fR "on"|"off" +Enable or disable to enter dialog mode after all arguments +are processed. In dialog mode input lines get prompted via +readline or from stdin. +.TP +\fB\-page\fR length width +Describe terminal to the text pager. See also above, paragraph Result pager. +.br +If parameter length is nonzero then the user gets prompted after that +number of terminal lines. Zero length disables paging. +.br +Parameter width is the number of characters per terminal line. It is used +to compute the number of terminal lines which get occupied by an output line. +A usual terminal width is 80. +.TP +\fB\-use_readline\fR "on"|"off" +If "on" then use readline for dialog. Else use plain stdin. +.br +See also above, paragraph Dialog, Readline, Result pager. +.TP +\fB\-reassure\fR "on"|"tree"|"off" +If "on" then ask the user for "y" or "n": +.br +before deleting or overwriting any file in the ISO image, +.br +before rolling back pending image changes, +.br +before committing image changes to media, +.br +before changing the input drive, +.br +before blanking or formatting media, +.br +before ending the program. +.br +With setting "tree" the reassuring prompt will appear for an eventual +directory only once and not for each file in its whole subtree. +.br +Setting "off" silently kills any kind of image file object resp. performs +above irrevocable actions. +.br +To really produce user prompts, option -dialog needs to be set to "on". +Note that the prompt does not appear in situations where file removal +is forbidden by option -overwrite. -reassure only imposes an additional +curb for removing existing file objects. +.br +Be aware that file objects get deleted from the ISO image immediately +after confirmation. They are gone even if the running command gets aborted +and its desired effect gets revoked. In case of severe mess-up, consider to +use -rollback to revoke the whole session. +.TP +.B Drive and media related inquiry actions: +.TP +\fB\-toc\fR +.br +Show media specific table of content. This is the media +structure, not the ISO image directory tree. In case of +overwriteable media holding a valid ISO image, a single +session gets fabricated from the ISO image size info. +.br +A drive which is incapable of writing may show any media as CD-ROM or DVD-ROM +with only one or two sessions on it. The last of these sessions is supposed +to be the most recent real session then. +.TP +\fB\-devices\fR +Show list of available MMC drives with the addresses of +their libburn standard device files. +.br +This is only possible when no ISO image changes are pending. +After this option was executed, there is no drive current +and no image loaded. Eventually one has to aquire a drive again. +.br +In order to be visible, a device has to offer rw-permissions +with its libburn standard device file. Thus it might be only the +.B superuser +who is able to see all drives. +.br +Drives which are occupied by other processes get not shown. +.TP +\fB\-print-size\fR +Print the foreseeable consumption of 2048 byte blocks +by next -commit. This can last a while as a -commit gets +prepared and only in last moment is revoked by this option. +.TP +\fB\-tell_media_space\fR +Print available space on output media and the free space after +subtracting already foreseeable consumption by next -commit. +.TP +.B Navigation in ISO image and disk filesystem: +.TP +\fB\-cd\fR iso_rr_path +Change the current working directory in the emerging ISO +image as it is at the moment. This is prepended to iso_rr_paths +which do not begin with '/'. +.br +It is possible to set the working directory to a path which does not exist +yet in the ISO image. The necessary parent directories will be created when +the first file object is inserted into that virtual directory. +Use -mkdir if you want to enforce the existence of the directory already at +first insertion. +.TP +\fB\-cdx\fR disk_path +Change the current working directory on filesystem. +To be prepended to disk_paths which do not begin with '/'. +.TP +\fB\-pwd\fR +.br +Tell the current working directory in the ISO image. +.TP +\fB\-pwdx\fR +.br +Tell the current working directory on local filesystem. +.TP +\fB\-ls\fR iso_rr_pattern [***] +List files in the ISO image which match shell patterns +(i.e. with wildcards '*' '?' '[a-z]'). +If a pattern does not begin with '/' then it is compared with addresses +relative to -cd, the current working directory in the ISO image. +.br +Directories are listed by their content rather than as single file item. +.br +Pattern expansion may be disabled by command -iso_rr_pattern. +.TP +\fB\-lsd\fR iso_rr_pattern [***] +Like -ls but listing directories as themselves and not by their content. +This resembles shell command ls -d. +.TP +\fB\-lsl\fR iso_rr_pattern [***] +Like -ls but also list some of the file attributes. +Output format resembles shell command ls -ln. +.TP +\fB\-lsdl\fR iso_rr_pattern [***] +Like -lsd but also list some of the file attributes. +Output format resembles shell command ls -dln. +.TP +\fB\-lsx\fR disk_pattern [***] +List files on local filesystem which match shell patterns. Patterns which do +not begin with '/' are used relative to -cdx, the current working directory in +the local filesystem. +.br +Directories are listed by their content rather than as single file item. +.br +Pattern expansion may be disabled by command -disk_pattern. +.TP +\fB\-lsdx\fR disk_pattern [***] +Like -lsx but listing directories as themselves and not by their content. +This resembles shell command ls -d. +.TP +\fB\-lslx\fR disk_pattern [***] +Like -lsx but also listing some of the file attributes. +Output format resembles shell command ls -ln. +.TP +\fB\-lsdlx\fR disk_pattern [***] +Like -lsdx but also listing some of the file attributes. +Output format resembles shell command ls -dln. +.TP +\fB\-du\fR iso_rr_pattern [***] +Recursively list size of directories and files in the ISO image +which match one of the patterns. +similar to shell command du -k. +.TP +\fB\-dus\fR iso_rr_pattern [***] +List size of directories and files in the ISO image +which match one of the patterns. +Similar to shell command du -sk. +.TP +\fB\-dux\fR disk_pattern [***] +Recursively list size of directories and files in the local filesystem +which match one of the patterns, similar to shell command du -k. +.TP +\fB\-dusx\fR disk_pattern [***] +List size of directories and files in the local filesystem +which match one of the patterns. +Similar to shell command du -sk. +.TP +\fB\-findx\fR disk_path [-name pattern] [-type t] [-exec action [params]] -- +Like -find but operating on local filesystem and not on the ISO image. +This is subject to the settings of -follow. +.br +Find accepts the same -type arguments as -find. Additionally it recognizes +type "mountpoint" (or "m"). It matches subdirectories which reside on a +different device than their parent. It never matches the disk_path +given as start address for -findx. +.br +-findx accepts the -exec actions as does -find. But except the following few +actions it will allways perform action "echo". +.br +"in_iso" iso_rr_path_start reports the path if its counterpart exist in +the ISO image. For this the disk_path of the -find command gets replaced +by iso_rr_path_start. E.g.: +.br + -findx /home -exec in_iso / +.br +"not_in_iso" iso_rr_path_start reports the path if its counterpart does +not exist in the ISO image. The report format is the same as with command +-compare. +E.g. +.br + -findx /home/thomas -exec not_in_iso /thomas_on_cd +.br +"add_missing" iso_rr_path_start adds the counterpart if it does not yet +exist in the ISO image. +E.g. +.br + -findx /home/thomas -exec add_missing /thomas_on_cd +.br +"is_full_in_iso" iso_rr_path_start reports if the counterpart in the ISO image +contains files. To be used with -type "m" to report mount points. +.br +"empty_iso_dir" iso_rr_path_start deletes all files from the counterpart +in the ISO image. To be used with -type "m" to truncate mount points. +.TP +\fB\-compare\fR disk_path iso_rr_path +Compare attributes and eventual data file content of a fileobject in the +local filesystem with a file object in the ISO image. The iso_rr_path may +well point to an image file object which is not yet committed, i.e. of which +the data content still resides in the local filesystem. Such data content is +prone to externally caused changes. +.br +If iso_rr_path is empty then disk_path is used as path in the ISO image too. +.br +Differing attributes are reported in detail, differing content is summarized. +Both to the result channel. In case of no differences no result lines are +emitted. +.TP +\fB\-compare_r\fR disk_path iso_rr_path +Like -compare but working recursively. I.e. all file objects below both +addresses get compared whether they have counterparts below the other address +and whether both counterparts match. +.TP +.B Command compatibility emulations: +.PP +Writing of ISO 9660 on CD is traditionally done by program mkisofs +as ISO 9660 image producer and cdrecord as burn program. +xorriso does not strive for their comprehensive emulation. +Nevertheless it is ready to perform some of its core tasks under control +of commands which in said programs trigger comparable actions. +The scope is for now only a single first data track to be written to blank or +overwriteable media. If possible the media will get closed afterwards. +Multi-session is yet only possible via xorriso's own commands. +.TP +\fB\-as\fR personality option [options] -- +.br +Performs its variable length option list as sparse emulation of the program +depicted by the personality word. This is only allowed if no image changes +are pending. The input drive is given up. +.br + +Personality "\fBmkisofs\fR" accepts the options listed with: +.br + -as mkisofs -help -- +.br +Among them: -R (always on), -J, -graft-points, -o, -path-list, -print-size, -V, +-v, -version, pathspecs as with xorriso -add. A lot of options are not +supported and lead to failure of the mkisofs emulation. Some are ignored, +but better do not rely on this tolerance. +.br +-graft-points is equivalent to -pathspecs on. Note that pathspecs without "=" +are interpreted differently than with xorriso option -add. Directories get +merged with the root directory of the ISO image, other filetypes get mapped +into that root directory. +.br +Other than with the "cdrecord" personality there is no automatic -commit at +the end of a "mkisofs" option list. Verbosity settings -v (= "UPDATE") and +-quiet (= "SORRY") persist. The output file, eventually chosen with -o, +persists until things happen like -commit, -rollback, -dev, or end of xorriso. +.br +If no output file was chosen before or during a "mkisofs" option list, then +standard output (-outdev "-") will get into effect before pathspecs get +added. If -o points to a regular file, then it will be truncated to 0 bytes +when finally writing begins. This truncation does not happen if the drive +is chosen by xorriso options before or after -as mkisofs. +Directories and symbolic links are no valid -o targets. +.br +Writing to stdout is possible only if -as "mkisofs" was among the start +arguments or if other start arguments pointed the output drive to +standard output. +.br +Personalites "\fBgenisoimage\fR" and "\fBgenisofs\fR" +are aliases for "mkisofs". +.br + +Personality "\fBcdrecord\fR" accepts the options listed with: +.br + -as cdrecord -help -- +.br +Among them: -v, dev=, speed=, blank=, fs=, -eject, -atip, padsize=, +track source file path or "-" for standard input as track source. +.br +It ignores most other options of cdrecord and cdrskin but refuses on +-audio, -scanbus, -multi, -msinfo, --grow_overwriteable_iso, +and on blanking modes unknown to xorriso. +.br +dev= must be given as xorriso device address. Adresses like 0,0,0 or ATA:1,1,0 +are not supported. +.br +If a track source is given, then an automatic -commit happens at the end of +the "cdrecord" option list. +.br +A much more elaborate libburn based cdrecord emulator is the program cdrskin. +.br +Personalites "\fBwodim\fR" and "\fBcdrskin\fR" are aliases for "cdrecord". +.TP +.B Scripting, dialog and program control features: +.TP +\fB\-no_rc\fR +.br +Only if used as first command line argument this option +prevents reading and interpretation of eventual startup +files. See section FILES below. +.TP +\fB\-options_from_file\fR fileaddress +Reads lines from fileaddress and executes them as dialog lines. +.TP +\fB\-help\fR +.br +Print helptext. +.TP +\fB\-version\fR +Print program name and version. +.TP +\fB\-history\fR textline +Copy textline into libreadline history. +.TP +\fB\-status\fR [mode|filter] +Print the current settings of xorriso. +Modes: +.br + short... print only important or altered settings +.br + long ... print all settings including defaults +.br + long_history like long plus history lines +.br +Filters begin with '-' and are compared literally against the +output lines of -status:long_history. A line is put out only +if its start matches the filter text. No wildcards. +.TP +\fB\-status_history_max\fR number +Set maximum number of history lines to be reported with -status "long_history". +.TP +\fB\-temp_mem_limit\fR number["k"|"m"] +Set the maximum size of temporary memory to be used for image dependent +buffering. Currently this applies to pattern expansion only. +.br +Default is 16m = 16 MiB, minimum 64k = 64 kiB, maximum 1024m = 1 GiB. +.TP +\fB\-print\fR text +Print a text to result channel. +.TP +\fB\-prompt\fR text +Show text at beginning of output line and +wait for the user to hit the Enter key +resp. to send a line via stdin. +.TP +\fB\-errfile_log\fR mode path|channel +.br +If problem events are related to input files from the filesystem, then their +disk_paths can be logged to a file or to output channels R or I. +.br +Mode can either be "plain" or "marked". The latter causes marker lines which +give the time of log start, burn session start, burn session end, log end +or program end. In mode "plain", only the file paths are logged. +.br +If path is "-" or "-R" then the log is directed to the result channel. +Path "-I" directs it to the info message channel. Any text that does not +begin with "-" is used as path for a file to append the log lines. +.br +Problematic files can be recorded multiple times during one program run. +If the program run aborts then the list might not be complete because +some input file arguments might not have been processed at all. +.br +The errfile paths are transported as messages of very low priority "ERRFILE". +This transport becomes visible with -report_about "ALL". +.TP +\fB\-session_log\fR path +If path is not empty it gives the address of a plain text file where +a log record gets appended after each session. This log can be used to +determine the start_lba of a session for mount option sbsector= from +date or volume id. With non-multi-session media this is currently the only +way to obtain this parameter. +.br +Record format is: timestamp start_lba size volume-id +.br +The first three items are single words, the rest of the line is the volume id. +.TP +\fB\-end\fR +.br +End program immediately +.TP +\fB#\fR any text +In dialog or file execution mode only and only as first +non-whitespace in line: +Do not execute the line but eventually store it in history. +.TP +.B Support for frontend programs talking into stdin and listening at stdout: +.TP +\fB\-pkt_output\fR "on"|"off" +Consolidate text output on stdout and classify each +line by a channel indicator: +.br + 'R:' for result lines, +.br + 'I:' for notes and error messages, +.br + 'M:' for -mark texts. +.br +Next is a decimal number of which only bit 0 has a meaning for now. +0 means no newline at end of payload, 1 means that the newline character at +the end of the output line belongs to the payload. After another colon follows +the payload text. +.br +Example: +.br + I:1: enter option and arguments : +.TP +\fB\-logfile\fR channel fileaddress +Copy output of a channel to the given file. +.TP +\fB\-mark\fR text +If text is not empty it will get put out each time an +action has been completed. +.TP +\fB\-prog\fR text +Use text as this program's name in subsequent messages +.TP +\fB\-prog_help\fR text +Use text as this program's name and perform -help. +.br +.SH EXAMPLES +.SS +.B Overview of examples: +As superuser learn about available drives +.br +Blank media and compose a new ISO image as batch run +.br +A dialog session doing about the same +.br +Manipulating an existing ISO image on the same media +.br +Copy modified ISO image from one media to another +.br +Write a ISO image into a pipe (single-session only) +.br +Perform a single session run as of cdrtools traditions +.br +Adjust thresholds for verbosity, exit value and program abort +.br +Examples of input timestrings +.br +Incremental backup of a few directory trees +.SS +.B As superuser learn about available drives +Consider to give rw permissions to those users or groups +which shall be able to use the drives with xorriso. +.br +\fB$\fR xorriso -devices +.br +0 -dev '/dev/sr0' rwrw-- : '_NEC ' 'DVD_RW ND-4570A' +.br +1 -dev '/dev/sr1' rwrw-- : 'HL-DT-ST' 'DVDRAM GSA-4082B' +.br +2 -dev '/dev/sr2' rwrw-- : 'PHILIPS ' 'SPD3300L' +.SS +.B Blank media and compose a new ISO image as batch run +Aquire drive /dev/sr2, blank media resp. invalidate existing ISO image. +Add the files from hard disk directories /home/me/sounds and /pictures. +Omit some unwanted stuff by removing it from the image directory tree. +Re-add some wanted stuff. +.br +Because no -dialog "on" is given, the program will then end by committing the +session to media. +.br +\fB$\fR xorriso -outdev /dev/sr2 \\ +.br + -blank fast \\ +.br + -pathspecs on \\ +.br + -add \\ +.br + /sounds=/home/me/sounds \\ +.br + /pictures \\ +.br + -- \\ +.br + -rm_r \\ +.br + /sounds/indecent \\ +.br + '/pictures/*private*' \\ +.br + /pictures/confidential \\ +.br + -- \\ +.br + -add \\ +.br + /pictures/confidential/work* +.br +Note that '/pictures/*private*' is a pattern for iso_rr_paths +while /pictures/confidential/work* gets expanded by the shell +with addresses from the hard disk. +.SS +.B A dialog session doing about the same +.br +-pathspecs is already given as start argument. The other activities +are done as dialog input. The pager gets set to 20 lines of 80 characters. +.br +The drive is aquired by option -dev rather than -outdev in order to see +the message about its current content. By option -blank this content is +made ready for being overwritten and the loaded ISO image is made empty. +.br +In order to be able to eject the media, the session needs to be committed +explicitely. +.br +.B $ xorriso -pathspecs on -dialog on -page 20 80 +.br +enter option and arguments : +.br +.B \-dev /dev/sr2 +.br +enter option and arguments : +.br +.B \-blank fast +.br +enter option and arguments : +.br +.B \-add /sounds=/home/me/sounds /pictures +.br +enter option and arguments : +.br +.B \-rm_r /sounds/indecent /pictures/*private* /pictures/confidential +.br +enter option and arguments : +.br +.B \-add /pictures/confidential/office /pictures/confidential/factory +.br +enter option and arguments : +.br +.B \-du / +.br +enter option and arguments : +.br +.B \-commit -eject all -end +.br +.SS +.B Manipulating an existing ISO image on the same media +Load image from drive. +Remove (i.e. hide) directory /sounds and its subordinates. +Rename directory /pictures/confidential to /pictures/restricted. +Change access permissions of directory /pictures/restricted. +Add new directory trees /sounds and /movies. Burn to the same media and eject. +.br +\fB$\fR xorriso -dev /dev/sr2 \\ +.br + -rm_r /sounds -- \\ +.br + -mv \\ +.br + /pictures/confidential \\ +.br + /pictures/restricted \\ +.br + -- \\ +.br + -chmod go-rwx /pictures/restricted -- \\ +.br + -pathsspecs on \\ +.br + -add \\ +.br + /sounds=/home/me/prepared_for_dvd/sounds_dummy \\ +.br + /movies=/home/me/prepared_for_dvd/movies \\ +.br + -- \\ +.br + -commit -eject all +.SS +.B Copy modified ISO image from one media to another +Load image from input drive. Do the same manipulations as in the previous +example. Aquire output drive and blank it. Burn the modified image as +first and only session to the output drive. +.br +\fB$\fR xorriso -indev /dev/sr2 \\ +.br + -rm_r /sounds -- \\ +.br + ... +.br + -outdev /dev/sr0 -blank fast \\ +.br + -commit -eject all +.SS +.B Write a ISO image into a pipe (single-session only) +\fB$\fR xorriso -outdev - \\ +.br + ... +.br + | gzip >image.iso.gz +.SS +.B Perform a single session run as of cdrtools traditions +This shall illustrate how xorriso can act in either role. +Between both processes there can be performed arbitrary transportation +or filtering. +.br +\fB$\fR xorriso -as mkisofs -J -R /home/prepared_for_iso/tree | \\ +.br + xorriso -as cdrecord -v dev=/dev/sr0 blank=fast -eject - +.SS +.B Adjust thresholds for verbosity, exit value and program abort +Be quite verbous, exit 32 if severity "FAILURE" was encountered, +do not abort prematurely but forcibly go on until the end of commands. +.br +\fB$\fR xorriso ... \\ +.br + -report_about UPDATE \\ +.br + -return_with FAILURE 32 \\ +.br + -abort_on NEVER \\ +.br + ... +.SS +.B Examples of input timestrings +.br +As printed by program date: +.B 'Thu Nov 8 14:51:13 CET 2007' +.br +The same without ignored parts: +.B 'Nov 8 14:51:13 2007' +.br +The same as expected by date: +.B 110814512007.13 +.br +Four weeks in the future: +.B +4w +.br +The current time: +.B +0 +.br +Three hours ago: +.B \-3h +.br +Seconds since Jan 1 1970: +.B =1194531416 +.SS +.B Incremental backup of a few directory trees +This does the following to directories /open_source_project and /personal_mail +in the ISO image: +create them if not existing yet, +compare them with their disk counterparts, +add disk file objects which are missing yet, +overwrite those which are different on disk, +and delete those which have vanished on disk. +.br +\fB$\fR xorriso -dev /dev/sr0 \\ +.br + -update_r /home/thomas/open_source_projects /open_source_projects \\ +.br + -update_r /home/thomas/personal_mail /personal_mail \\ +.br + -commit_eject all +.br +To be used several times on the same media, whenever an update of +the two disk trees to the media is desired. Begin with blank media and start +a new blank media when the run fails due to lack of remaining space on +the old one. +.br +This makes most sense with backups on non-erasable media like CD-R, +DVD-R, DVD+R if the full backup leaves substantial remaining capacity +on media and if the expected changes are much smaller than the full backup. +An update run will probably save no time but last longer than a full backup. +.br +With \fBmount\fR option \fB"sbsector="\fR it is possible to access the session +trees which represent the older backup versions. Multi-session media can tell +the sbsector by xorriso option -toc, as "data lba:". For other media one +may set before writing a suitable path for xorriso option -session_log where +the sbsector number gets recorded as the second word in each line. +.br +With CD media, Linux mount accepts session numbers directly by its option +"session=". +.br +\fBDo not write more than about 50 sessions\fR to one multi-session media. +Theoretical limits are higher but in practice the media deteriorate more early. +It might also be that your operating system has a session limit with mount. +Always have a blank media ready to perform a full backup in case the update +attempt fails. An overview of sessions is given by option -toc. +.br +Sessions on multi-session media are separated by several MB of unused blocks. +So with small sessions the payload capacity can become substantially lower +than the overall media capacity. If the remaining space on media does not +suffice for the next gap, the drive is supposed to close the media +automatically. +.br +\fBBetter do not use your youngest backup for -update_r\fR. +Have at least two media which you use alternatingly. So only older backups +get endangered by the new write operation, while the newest backup is +stored safely on a different media. +.br +If you have enough re-useable media for a round-robin scheme then better do +full backups with blank media each time. Blanking can be achieved by +either a separate run: +.br +\fB$\fR xorriso -outdev /dev/sr0 -blank fast -eject all +.br +or in the update run by using option -blank "fast" before option -update_r. +.br +.SH FILES +.SS +.B Startup files: +.br +If not -no_rc is given as the first argument then xorriso attempts on startup +to read and execute lines from the following files: +.br + /etc/default/xorriso +.br + /etc/opt/xorriso/rc +.br + /etc/xorriso/xorriso.conf +.br + $HOME/.xorrisorc +.br +The files are read in the sequence given above, but none of them is required +for xorriso to function properly. +.br +.SH SEE ALSO +.TP +For mounting xorriso generated ISO 9660 images +.br +.BR mount(8) +.TP +Libreadline, a comfortable input line facility +.BR readline(3) +.TP +Other programs which produce ISO 9660 images +.br +.BR mkisofs(8), +.BR genisoimage(8) +.TP +Other programs which burn sessions to optical media +.BR growisofs(1), +.BR cdrecord(1), +.BR wodim(1), +.BR cdrskin(1) +.br +.SH AUTHOR +Thomas Schmitt <scdbackup@gmx.net> +.br +for libburnia-project.org +.SH CREDITS +xorriso is in part based on work by Vreixo Formoso who provides libisofs +together with Mario Danic who also leads the libburnia team. +Thanks to Andy Polyakov who invented emulated growing, +to Derek Foreman and Ben Jansens who once founded libburn. +.br +Compliments towards Joerg Schilling whose cdrtools served me for ten years. + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorriso.c b/libisoburn/branches/ZeroOneFour/xorriso/xorriso.c new file mode 100644 index 00000000..67bc3aef --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorriso.c @@ -0,0 +1,10941 @@ + +/* + + ( cd .. ; libisoburn-develop/xorriso/compile_xorriso.sh -g ) + +or + + cc -g -DXorriso_with_maiN -DXorriso_with_regeX -DXorriso_with_readlinE \ + -DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \ + -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ + -o xorriso/xorriso \ + xorriso/xorriso.c xorriso/xorrisoburn.c \ + -lpthread -lreadline -lburn -lisofs -lisoburn + +or + + cc -g -DXorriso_with_regeX -DXorriso_with_readlinE \ + -DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \ + -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ + -c \ + xorriso/xorriso.c xorriso/xorrisoburn.c + +*/ + +/* Command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2008 Thomas Schmitt, <scdbackup@gmx.net> + + Initial code of this program was derived from program src/askme.c out + of scdbackup-0.8.8, Copyright 2007 Thomas Schmitt, BSD-License. + + Provided under GPL version 2, with the announcement that this might + get changed in future. I would prefer BSD or a modified LGPL with no + option to choose any kind of future GPL version. + (This announcement affects only future releases of xorriso. + If you obtain a copy licensed as "GPL version 2" then this license is + not revocable for that particular copy, of course.) + + + Overview of xorriso architecture: + + libburn provides the ability to read and write data. + + libisofs interprets and manipulates ISO 9660 directory trees. It generates + the output stream which is handed over to libburn. + + libisoburn encapsulates the connectivity issues between libburn and + libisofs. It also enables multi-session emulation on overwritable media + and random access file objects. + xorriso is intended as reference application of libisoburn. + + xorrisoburn.[ch] encapsulate any usage of the libraries by xorriso. + + xorriso.h exposes the public functions of xorriso which are intended + to be used by programs which link with xorriso.o. These functions are + direct equivalents of the xorriso interpreter commands. + There is also the API for handling event messages. + + xorriso_private.h is not to be included by other software. It encapsulates + the inner interfaces of xorriso. + + xorriso.c provides the command interpreter as described in xorriso.1. + It performs any activity that does not demand a reference to a symbol + of the library APIs. This includes: + - Interpretation of user input from arguments, dialog, and scripting. + - Output of result text and event messages. + - POSIX filesystem operations. + - Public functions which perform the particular xorriso commands. + - The main() function, if enabled by #define Xorriso_with_maiN. + +*/ + + +#include <ctype.h> +#include <sys/types.h> +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <sys/wait.h> +#include <dirent.h> +#include <time.h> +#include <utime.h> +#include <pwd.h> +#include <grp.h> + +/* eventually, this is done in xorriso_private.h : #include <regex.h> */ + +#ifdef Xorriso_with_readlinE +#ifdef Xorriso_with_old_readlinE +#include <readline.h> +#include <history.h> +#else /* Xorriso_with_old_readlinE */ +#include <readline/readline.h> +#include <readline/history.h> +#endif /* ! Xorriso_with_old_readlinE */ +#endif /* Xorriso_with_readlinE */ + +#define TSOB_FELD(typ,anz) (typ *) malloc((anz)*sizeof(typ)); + + +/* Diet facility: exclude help texts from binaries */ +/* This will eventually be redefined to eat up its content */ +#define AlN(x) x + + +/* There is only one stage of diet: Xorriso_no_helP */ +#ifdef Xorriso_no_helP +#undef AlN +#define AlN(x) +#endif + + +/* ------------------------------------------------------------------------ */ + + +/* The official xorriso options API. "No shortcuts" */ +#include "xorriso.h" + +/* The inner isofs- and burn-library interface */ +#include "xorrisoburn.h" + +/* The inner description of XorrisO */ +#define Xorriso_is_xorriso_selF 1 +#include "xorriso_private.h" + + +/* ------------------------------------------------------------------------ */ + + +#ifndef Xorriso_sfile_externaL + + +char *Sfile_fgets(char *line, int maxl, FILE *fp) +{ + int l; + char *ret; + + ret= fgets(line,maxl,fp); + if(ret==NULL) + return(NULL); + l= strlen(line); + if(l>0) if(line[l-1]=='\r') line[--l]= 0; + if(l>0) if(line[l-1]=='\n') line[--l]= 0; + if(l>0) if(line[l-1]=='\r') line[--l]= 0; + return(ret); +} + + +int Sfile_count_components(char *path, int flag) +/* + bit0= do not ignore trailing slash + bit1= do not ignore empty components (other than the empty root name) +*/ +{ + int l,count= 0; + char *cpt; + + l= strlen(path); + if(l==0) + return(0); + count= 1; + for(cpt= path+l-1;cpt>=path;cpt--) { + if(*cpt=='/') { + if(*(cpt+1)==0 && !(flag&1)) + continue; + if(*(cpt+1)=='/' && !(flag&2)) + continue; + count++; + } + } + return(count); +} + + +int Sfile_component_pointer(char *path, char **sourcept, int idx, int flag) +/* + bit0= do not ignore trailing slash + bit1= do not ignore empty components (other than the empty root name) + bit2= accept 0 as '/' +*/ +{ + int count= 0; + char *spt; + + for(spt= path;*spt!=0 || (flag&4);spt++) { + if(count>=idx) { + *sourcept= spt; + return(1); + } + if(*spt=='/' || *spt==0) { + if(*(spt+1)=='/' && !(flag&2)) + continue; + if(*(spt+1)==0 && !(flag&1)) + continue; + count++; + } + } + if((flag&1) && count>=idx) + return(1); + return(0); +} + + +int Sfile_leafname(char *path, char leafname[SfileadrL], int flag) +{ + int count, ret; + char *lpt; + + leafname[0]= 0; + count= Sfile_count_components(path, 0); + if(count==0) + return(0); + ret= Sfile_component_pointer(path, &lpt, count-1, 0); + if(ret<=0) + return(ret); + if(Sfile_str(leafname, lpt, 0)<=0) + return(0); + lpt= strchr(leafname, '/'); + if(lpt!=NULL) + *lpt= 0; + return(1); +} + + +int Sfile_add_to_path(char path[SfileadrL], char *addon, int flag) +{ + int l; + + l= strlen(path); + if(l+1>=SfileadrL) + return(0); + if(l==0) { + strcpy(path,"/"); + l= 1; + } else if(path[l-1]!='/') { + path[l++]= '/'; + path[l]= 0; + } + if(l+strlen(addon)>=SfileadrL) + return(0); + if(addon[0]=='/') + strcpy(path+l,addon+1); + else + strcpy(path+l,addon); + return(1); +} + + +int Sfile_prepend_path(char *prefix, char path[SfileadrL], int flag) +{ + int l, i; + + l= strlen(path)+strlen(prefix)+1; + if(l>=SfileadrL) { + +#ifdef Not_yeT + /* >>> ??? how to transport messages to xorriso ? */ + sprintf(xorriso->info_text, + "Combination of wd and relative address too long (%d > %d)", + l,SfileadrL-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); +#endif + + return(-1); + } + l-= strlen(path); + for(i= strlen(path)+1; i>=0; i--) + path[i+l]= path[i]; + strcpy(path,prefix); + path[l-1]= '/'; + return(1); +} + +int Sfile_being_group_member(struct stat *stbuf, int flag) +{ + int i, suppl_groups; + gid_t *suppl_glist; + + if (getegid()==stbuf->st_gid) + return(1); + suppl_groups= getgroups(0, NULL); + suppl_glist= (gid_t *) malloc((suppl_groups + 1) * sizeof(gid_t)); + if (suppl_glist==NULL) + return(-1); + suppl_groups= getgroups(suppl_groups+1,suppl_glist); + for (i= 0; i<suppl_groups; i++) { + if (suppl_glist[i]==stbuf->st_gid) { + free((char *) suppl_glist); + return(1); + } + } + free((char *) suppl_glist); + return(0); +} + + +int Sfile_type(char *filename, int flag) +/* + bit0= return -1 if file is missing + bit1= return a hardlink with siblings as type 5 + bit2= evaluate eventual link target rather than the link object itself + bit3= return a socket or a char device as types 7 or 8 rather than 0 +*/ +/* + return: + 0=unknown + 1=regular + 2=directory + 3=symbolic link + 4=named pipe + 5=multiple hardlink (with bit1) + 6=block device + 7=socket (with bit3) + 8=character device (with bit3) +*/ +{ + struct stat stbuf; + if(flag&4) { + if(stat(filename,&stbuf)==-1) { + if(flag&1) return(-1); + else return(0); + } + } else { + if(lstat(filename,&stbuf)==-1) { + if(flag&1) return(-1); + else return(0); + } + } + if(S_ISREG(stbuf.st_mode)) { + if(flag&2) + if(stbuf.st_nlink>1) + return(5); + return(1); + } + if(S_ISDIR(stbuf.st_mode)) + return(2); + if((stbuf.st_mode&S_IFMT)==S_IFLNK) + return(3); + if(S_ISFIFO(stbuf.st_mode)) + return(4); + if(S_ISBLK(stbuf.st_mode)) + return(6); + if(flag&8) + if((stbuf.st_mode&S_IFMT)==S_IFSOCK) + return(7); + if(flag&8) + if(S_ISCHR(stbuf.st_mode)) + return(8); + return(0); +} + + +char *Sfile_datestr(time_t tim, short int flag) +/* + bit0=with hours+minutes + bit1=with seconds + + bit8= local time rather than UTC +*/ +{ + static char zeitcode[80]={"000000"}; + char puff[80]; + struct tm *azt; + + if(flag&256) + azt = localtime(&tim); + else + azt = gmtime(&tim); + + if(azt->tm_year>99) + sprintf(zeitcode,"%c%1.1d%2.2d%2.2d", + 'A'+(azt->tm_year-100)/10,azt->tm_year%10, + azt->tm_mon+1,azt->tm_mday); + else + sprintf(zeitcode,"%2.2d%2.2d%2.2d", + azt->tm_year,azt->tm_mon+1,azt->tm_mday); + if(flag&1){ + sprintf(puff,".%2.2d%2.2d",azt->tm_hour,azt->tm_min); + strcat(zeitcode,puff); + } + if(flag&2){ + sprintf(puff,"%2.2d",azt->tm_sec); + strcat(zeitcode,puff); + } + + return(zeitcode); +} + + +int Sfile_scale(double value, char *result, int siz, double thresh, int flag) +/* + bit0= eventually ommit 'b' + bit1= make text as short as possible + bit2= no fraction (if it would fit at all) +*/ +{ + char scale_c,scales[6],form[80]; + int i,dec_siz= 0,avail_siz= 1; + + strcpy(scales,"bkmgtp"); + scale_c= scales[0]; + for(i=1;scales[i]!=0;i++) { + if(value<thresh-0.5) + break; + value/= 1024.0; + scale_c= scales[i]; + } + if(scale_c!='b' && !(flag&4)) { /* is there room for fractional part ? */ + avail_siz= siz-1; + sprintf(form,"%%.f"); + sprintf(result,"%.f",value); + if(strlen(result)<=avail_siz-2) + dec_siz= 1; /* we are very modest */ + } + if(scale_c=='b' && (flag&1)) { + if(flag&2) + sprintf(form,"%%.f"); + else + sprintf(form,"%%%d.f",siz); + sprintf(result,form,value); + } else { + if(flag&2) + sprintf(form,"%%.f%%c"); + else if(dec_siz>0) + sprintf(form,"%%%d.%df%%c",avail_siz,dec_siz); + else + sprintf(form,"%%%d.f%%c",siz-1); + sprintf(result,form,value,scale_c); + } + return(1); +} + + +int Sfile_off_t_text(char text[80], off_t num, int flag) +{ + char *tpt; + off_t hnum, scale= 1; + int digits= 0, d, i; + + tpt= text; + hnum= num; + if(hnum<0) { + *(tpt++)= '-'; + hnum= -num; + } + if(hnum<0) { /* it can stay nastily persistent */ + strcpy(text, "_overflow_"); + return(0); + } + for(i= 0; i<23; i++) { /* good for up to 70 bit = 10 exp 21.07... */ + if(hnum==0) + break; + hnum/= 10; + if(hnum) + scale*= 10; + } + if(i==0) { + strcpy(text, "0"); + return(1); + } + if(i==23) { + strcpy(text, "_overflow_"); + return(0); + } + digits= i; + hnum= num; + for(; i>0; i--) { + d= hnum/scale; + tpt[digits-i]= '0'+d; + hnum= hnum%scale; + scale/= 10; + } + tpt[digits]= 0; + return(1); +} + + +int Sfile_destroy_argv(int *argc, char ***argv, int flag) +{ + int i; + + if(*argc>0 && *argv!=NULL){ + for(i=0;i<*argc;i++){ + if((*argv)[i]!=NULL) + Smem_freE((*argv)[i]); + } + Smem_freE((char *) *argv); + } + *argc= 0; + *argv= NULL; + return(1); +} + + +int Sfile_make_argv(char *progname, char *line, int *argc, char ***argv, + int flag) +/* + bit0= read progname as first argument from line + bit1= just release argument list argv and return + bit2= abort with return(0) if incomplete quotes are found + bit3= eventually prepend missing '-' to first argument read from line +*/ +{ + int i,pass,maxl=0,l,argzaehl=0,bufl,line_start_argc; + char *cpt,*start; + char buf[SfileadrL]; + + Sfile_destroy_argv(argc,argv,0); + if(flag&2) return(1); + + for(pass=0;pass<2;pass++) { + cpt= line-1; + if(!(flag&1)){ + argzaehl= line_start_argc= 1; + if(pass==0) + maxl= strlen(progname); + else + strcpy((*argv)[0],progname); + } else { + argzaehl= line_start_argc= 0; + if(pass==0) maxl= 0; + } + while(*(++cpt)!=0){ + if(isspace(*cpt)) continue; + start= cpt; + buf[0]= 0; + cpt--; + while(*(++cpt)!=0) { + if(isspace(*cpt)) break; + if(*cpt=='"'){ + l= cpt-start; bufl= strlen(buf); + if(l>0) {strncat(buf,start,l);buf[bufl+l]= 0;} + l= strlen(buf); + start= cpt+1; + while(*(++cpt)!=0) if(*cpt=='"') break; + if((flag&4) && *cpt==0) + return(0); + l= cpt-start; bufl= strlen(buf); + if(l>0) {strncat(buf,start,l);buf[bufl+l]= 0;} + start= cpt+1; + }else if(*cpt=='\''){ + l= cpt-start; bufl= strlen(buf); + if(l>0) {strncat(buf,start,l);buf[bufl+l]= 0;} + l= strlen(buf); + start= cpt+1; + while(*(++cpt)!=0) if(*cpt=='\'') break; + if((flag&4) && *cpt==0) + return(0); + l= cpt-start; bufl= strlen(buf); + if(l>0) {strncat(buf,start,l);buf[bufl+l]= 0;} + start= cpt+1; + } + if(*cpt==0) break; + } + l= cpt-start; + bufl= strlen(buf); + if(l>0) {strncat(buf,start,l);buf[bufl+l]= 0;} + l= strlen(buf); + if(pass==0){ + if(argzaehl==line_start_argc && (flag&8)) + if(buf[0]!='-' && buf[0]!=0 && buf[0]!='#') + l++; + if(l>maxl) maxl= l; + }else{ + strcpy((*argv)[argzaehl],buf); + if(argzaehl==line_start_argc && (flag&8)) + if(buf[0]!='-' && buf[0]!=0 && buf[0]!='#') + sprintf((*argv)[argzaehl],"-%s", buf); + } + argzaehl++; + if(*cpt==0) break; + } + if(pass==0){ + *argc= argzaehl; + if(argzaehl>0) { + *argv= (char **) Smem_malloC(argzaehl*sizeof(char *)); + if(*argv==NULL) + return(-1); + } + for(i=0;i<*argc;i++) { + (*argv)[i]= (char *) Smem_malloC((maxl+1)); + if((*argv)[i]==NULL) + return(-1); + } + } + } + return(1); +} + + +/* @param flag bit0= append */ +int Sfile_str(char target[SfileadrL], char *source, int flag) +{ + int l; + + l= strlen(source); + if(flag&1) + l+= strlen(target); + if(l>=SfileadrL) { + fprintf(stderr, "--- Path string overflow (%d > %d). Malicious input ?\n", + l,SfileadrL-1); + return(0); + } + if(flag&1) + strcat(target, source); + else + strcpy(target, source); + return(1); +} + + +/** Combine environment variable HOME with given filename + @param filename Address relative to $HOME + @param fileadr Resulting combined address + @param fa_size Size of array fileadr + @param flag Unused yet + @return 1=ok , 0=no HOME variable , -1=result address too long +*/ +int Sfile_home_adr_s(char *filename, char *fileadr, int fa_size, int flag) +{ + char *home; + + strcpy(fileadr,filename); + home= getenv("HOME"); + if(home==NULL) + return(0); + if(strlen(home)+strlen(filename)+1>=fa_size) + return(-1); + strcpy(fileadr,home); + if(filename[0]!=0){ + strcat(fileadr,"/"); + strcat(fileadr,filename); + } + return(1); +} + + +/** Return a double representing seconds and microseconds since 1 Jan 1970 */ +double Sfile_microtime(int flag) +{ + struct timeval tv; + struct timezone tz; + gettimeofday(&tv,&tz); + return((double) (tv.tv_sec+1.0e-6*tv.tv_usec)); +} + + +int Sfile_decode_datestr(struct tm *reply, char *text, int flag) +/* YYMMDD[.hhmm[ss]] */ +{ + int i,l; + time_t current_time; + struct tm *now; + + current_time= time(0); + now= localtime(¤t_time); + for(i=0;i<sizeof(struct tm);i++) + ((char *) reply)[i]= ((char *) now)[i]; + + if(text[0]<'0'|| (text[0]>'9' && text[0]<'A') || text[0]>'Z') + return(0); + l= strlen(text); + for(i=1;i<l;i++) + if(text[i]<'0'||text[i]>'9') + break; + if(i!=6) + return(0); + if(text[i]==0) + goto decode; + if(text[i]!='.' || (l!=11 && l!=13)) + return(0); + for(i++;i<l;i++) + if(text[i]<'0'||text[i]>'9') + break; + if(i!=l) + return(0); + +decode:; + reply->tm_hour= 0; + reply->tm_min= 0; + reply->tm_sec= 0; + i= 0; + if(text[0]>='A') + reply->tm_year= 100+(text[i]-'A')*10+text[1]-'0'; + else + reply->tm_year= 10*(text[0]-'0')+text[1]-'0'; + reply->tm_mon= 10*(text[2]-'0')+text[3]-'0'-1; + reply->tm_mday= 10*(text[4]-'0')+text[5]-'0'; + if(l==6) + return(1); + reply->tm_hour= 10*(text[7]-'0')+text[8]-'0'; + reply->tm_min= 10*(text[9]-'0')+text[10]-'0'; + if(l==11) + return(1); + reply->tm_sec= 10*(text[11]-'0')+text[12]-'0'; + return(1); +} + +#endif /* Xorriso_sfile_externaL */ + + +/* --------------------------------- misc --------------------------------- */ + + +int Write_to_channel(char *text, int channel_no, int flag) +/* + bit0= packet write disabled, write to stdin resp. stderr + bit1= text is the name of the log file for the given channel + bit2= text is the name of the consolidated packet log file for all channels +bit15= with bit1 or bit2: close depicted log file +*/ +{ + char *rpt,*npt,ret= 1; + char prefix[16]; + static int num_channels= 4; + static char channel_prefixes[4][4]= {".","R","I","M"}; + static FILE *logfile_fp[4]= {NULL,NULL,NULL,NULL}; + static FILE *pktlog_fp= NULL; + + if(channel_no<0 || channel_no>=num_channels) + return(-1); + + /* Logfiles */ + if((flag&2) && logfile_fp[channel_no]!=NULL) { + fprintf(logfile_fp[channel_no], + "! end ! end ! end ! end ! end ! end ! end ! end xorriso log : %s : %s\n", + channel_prefixes[channel_no],Sfile_datestr(time(0),1|2|256)); + fclose(logfile_fp[channel_no]); + logfile_fp[channel_no]= NULL; + } + if((flag&4) && pktlog_fp!=NULL) { + fprintf(pktlog_fp, + "I:1:! end ! end ! end ! end ! end ! end ! end ! end xorriso log : %s : %s\n", + channel_prefixes[channel_no],Sfile_datestr(time(0),1|2|256)); + fclose(pktlog_fp); + pktlog_fp= NULL; + } + if(flag&(1<<15)) + return(1); + if((flag&2)) { + logfile_fp[channel_no]= fopen(text,"a"); + if(logfile_fp[channel_no]==NULL) + return(0); + fprintf(logfile_fp[channel_no], + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xorriso log : %s : %s\n", + channel_prefixes[channel_no],Sfile_datestr(time(0),1|2|256)); + fflush(logfile_fp[channel_no]); + } + if((flag&4)) { + pktlog_fp= fopen(text,"a"); + if(pktlog_fp==NULL) + return(0); + fprintf(pktlog_fp, + "I:1:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xorriso log : . : %s\n", + Sfile_datestr(time(0),1|2|256)); + fflush(pktlog_fp); + } + if(flag&(2|4)) + return(1); + if(flag&1) { + if(channel_no==1 || channel_no==3) + printf("%s",text); + if(channel_no==2 || channel_no==3) + fprintf(stderr,"%s",text); + if(logfile_fp[channel_no]!=NULL) { + fprintf(logfile_fp[channel_no],"%s",text); + fflush(logfile_fp[channel_no]); + } + if(pktlog_fp!=NULL) + return(1); + } + rpt= text; + sprintf(prefix,"%s:x: ",channel_prefixes[channel_no]); + while(*rpt!=0) { + npt= strchr(rpt,'\n'); + if(npt==NULL) + prefix[2]= '0'; + else + prefix[2]= '1'; + if(!(flag&1)) { + ret= fwrite(prefix,5,1,stdout); + if(ret<=0) + return(0); + } + if(pktlog_fp!=NULL) { + ret= fwrite(prefix,5,1,pktlog_fp); + if(ret<=0) + return(0); + } + if(npt==NULL) { + if(!(flag&1)) { + ret= fwrite(rpt,strlen(rpt),1,stdout); + if(ret<=0) + return(0); + ret= fwrite("\n",1,1,stdout); + if(ret<=0) + return(0); + } + if(pktlog_fp!=NULL) { + ret= fwrite(rpt,strlen(rpt),1,pktlog_fp); + if(ret<=0) + return(0); + ret= fwrite("\n",1,1,pktlog_fp); + if(ret<=0) + return(0); + } + break; + } else { + if(!(flag&1)) { + ret= fwrite(rpt,npt+1-rpt,1,stdout); + if(ret<=0) + return(0); + } + if(pktlog_fp!=NULL) { + ret= fwrite(rpt,npt+1-rpt,1,pktlog_fp); + if(ret<=0) + return(0); + } + } + rpt= npt+1; + } + if(!(flag&1)) + fflush(stdout); + if(pktlog_fp!=NULL) + fflush(pktlog_fp); + return(1); +} + + +int Strcmp(const void *pt1, const void *pt2) +{ + return(strcmp(*((char **) pt1), *((char **) pt2))); +} + + +int Sort_argv(int argc, char **argv, int flag) +{ + if(argc<=0) + return(2); + qsort(argv,(size_t) argc,sizeof(char *),Strcmp); + return(1); +} + + +FILE *Afile_fopen(char *filename, char *mode, int flag) +/* + bit0= do not print error message on failure + bit6= write packeted error messages (see Write_to_channel()) +*/ +{ + FILE *fp= NULL; + char errmsg[2*SfileadrL]; + + if(strcmp(filename,"-")==0) { + if(mode[0]=='a' || mode[0]=='w' || + (mode[0]=='r' && mode[1]=='+') || + (mode[0]=='r' && mode[1]=='b' && mode[2]=='+')) + fp= stdout; + else + fp= stdin; + } else if(strncmp(filename,"tcp:",4)==0){ + sprintf(errmsg,"sorry - TCP/IP service isn't implemented yet.\n"); + Write_to_channel(errmsg,2,!(flag&64)); + } else if(strncmp(filename,"file:",5)==0){ + fp= fopen(filename+5,mode); + } else { + fp= fopen(filename,mode); + } + if(fp==NULL){ + if(!(flag&1)) { + sprintf(errmsg,"failed to open file '%s' in %s mode\n",filename,mode); + if(errno>0) + sprintf(errmsg+strlen(errmsg)," %s\n",strerror(errno)); + Write_to_channel(errmsg,2,!(flag&64)); + } + return(NULL); + } + return(fp); +} + + +/** Convert a text into a number of type double and multiply it by unit code + [kmgtpe] (2^10 to 2^60) or [s] (2048). (Also accepts capital letters.) + @param text Input like "42", "2k", "3.14m" or "-1g" + @param flag Bitfield for control purposes: + bit0= return -1 rathern than 0 on failure + @return The derived double value +*/ +double Scanf_io_size(char *text, int flag) +/* + bit0= default value -1 rather than 0 +*/ +{ + int c; + double ret= 0.0; + + if(flag&1) + ret= -1.0; + if(text[0]==0) + return(ret); + sscanf(text,"%lf",&ret); + c= text[strlen(text)-1]; + if(c=='k' || c=='K') ret*= 1024.0; + if(c=='m' || c=='M') ret*= 1024.0*1024.0; + if(c=='g' || c=='G') ret*= 1024.0*1024.0*1024.0; + if(c=='t' || c=='T') ret*= 1024.0*1024.0*1024.0*1024.0; + if(c=='p' || c=='P') ret*= 1024.0*1024.0*1024.0*1024.0*1024.0; + if(c=='e' || c=='E') ret*= 1024.0*1024.0*1024.0*1024.0*1024.0*1024.0; + if(c=='s' || c=='S') ret*= 2048.0; + return(ret); +} + + +int Decode_date_input_format(struct tm *erg, char *text, int flag) +/* MMDDhhmm[[CC]YY][.ss]] */ +{ + int i,l,year; + time_t current_time; + struct tm *now; + + current_time= time(0); + now= localtime(¤t_time); + for(i=0;i<sizeof(struct tm);i++) + ((char *) erg)[i]= ((char *) now)[i]; + + l= strlen(text); + for(i=0;i<l;i++) + if(text[i]<'0'||text[i]>'9') + break; + if(i!=8 && i!=10 && i!=12) + return(0); + if(text[i]==0) + goto decode; + if(text[i]!='.' || l!=15) + return(0); + i++; + if(text[i]<'0'||text[i]>'9') + return(0); + i++; + if(text[i]<'0'||text[i]>'9') + return(0); + +decode:; + /* MMDDhhmm[[CC]YY][.ss]] */ + i= 0; + erg->tm_mon= 10*(text[0]-'0')+text[1]-'0'-1; + erg->tm_mday= 10*(text[2]-'0')+text[3]-'0'; + erg->tm_hour= 10*(text[4]-'0')+text[5]-'0'; + erg->tm_min= 10*(text[6]-'0')+text[7]-'0'; + erg->tm_sec= 0; + if(l==8) + return(1); + if(l>10){ + year= 1000*(text[8]-'0')+100*(text[9]-'0')+10*(text[10]-'0')+(text[11]-'0'); + }else{ + year= 1900+10*(text[8]-'0')+(text[9]-'0'); + if(year<1970) + year+= 100; + } + erg->tm_year= year-1900; + if(l<=12) + return(1); + erg->tm_sec= 10*(text[13]-'0')+text[14]-'0'; + return(1); +} + + +int Decode_date_weekday(char *text, int flag) +{ + int i; + static char days[][4]= {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", ""}; + + for(i= 0; days[i][0]!=0; i++) + if(strncmp(text,days[i],3)==0) + return(i); + if((strlen(text)==3 || (strlen(text)==4 && text[3]==',')) && + isalpha(text[0]) && isalpha(text[1]) && isalpha(text[2])) + return(7); + return(-1); +} + + +int Decode_date_month(char *text, int flag) +{ + int i; + static char months[][4]= {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""}; + + for(i= 0; months[i][0]!=0; i++) + if(strncmp(text,months[i],3)==0) + return(i); + return(-1); +} + + +/* @return -1=not a number, -2=not a day , 1 to 31 day of month */ +int Decode_date_mday(char *text, int flag) +{ + int ret, i; + + for(i= 0; text[i]!=0; i++) + if(!isdigit(text[i])) + return(-1); + if(strlen(text)>2 || text[0]==0) + return(-2); + sscanf(text, "%d", &ret); + if(ret<=0 || ret>31) + return(-2); + return(ret); +} + +int Decode_date_hms(char *text, struct tm *erg, int flag) +{ + int i, hour= -1, minute= -1, second= 0; + + for(i= 0; i<9; i+= 3) { + if(i==6&&text[i]==0) + break; + if(!isdigit(text[i])) + return(-1); + if(!isdigit(text[i+1])) + return(-1); + if(text[i+2]!=':' && !(text[i+2]==0 && i>=3)) + return(-1); + if(i==0) + sscanf(text+i,"%d",&hour); + else if(i==3) + sscanf(text+i,"%d",&minute); + else + sscanf(text+i,"%d",&second); + } + if(hour<0 || hour>23 || minute<0 || minute>59 || second>59) + return(-1); + erg->tm_hour= hour; + erg->tm_min= minute; + erg->tm_sec= second; + return(1); +} + + +/* @return -1=not a number, -2=not a year , >=0 years AD */ +int Decode_date_year(char *text, int flag) +{ + int ret, i; + + for(i= 0; text[i]!=0; i++) + if(!isdigit(text[i])) + return(-1); + if(strlen(text)!=4) + return(-2); + sscanf(text, "%d", &ret); + if(ret<0 || ret>3000) + return(-2); + return(ret); +} + + +int Decode_date_timezone(char *text, struct tm *erg, int flag) +{ + int i; + static char tzs[][5]= {"GMT", "CET", "CEST", "0000", ""}; + + for(i= 0; tzs[i][0]!=0; i++) + if(strcmp(text,tzs[i])==0) { + + /* ??? >>> what to do with timezone info ? Add to ->tm_hour ? */ + + return(1); + } + if(text[0]=='+' || text[0]=='-') { + for(i= 1; text[i]!=0; i++) + if(!isdigit(text[i])) + return(-1); + if(i!=5) + return(-1); + + /* ??? >>> what to do with timezone info ? Add to ->tm_hour ? */ + + return(1); + } else { + for(i= 0; text[i]!=0; i++) + if(text[i]<'A' || text[i]>'Z') + return(-1); + if(i!=3 && i!=4) + return(-1); + return(2); + } +} + + +int Decode_date_output_format(struct tm *erg, char *text, int flag) +/* Thu Nov 8 09:07:50 CET 2007 */ +/* Sat, 03 Nov 2007 08:58:30 +0100 */ +/* Nov 7 23:24 */ +{ + int ret, i, argc= 0, seen_year= 0, seen_month= 0, seen_day= 0, seen_time= 0; + char **argv= NULL; + struct tm *now; + time_t timep; + + memset(erg, 0, sizeof(*erg)); + erg->tm_isdst= -1; + ret= Sfile_make_argv("xorriso", text, &argc, &argv, 0); + if(ret<=0) + goto ex; + for(i= 1; i<argc; i++) { + if(!seen_month) { + ret= Decode_date_month(argv[i], 0); + if(ret>=0) { + seen_month= 1; + erg->tm_mon= ret; + continue; + } + } + if(!seen_day) { + ret= Decode_date_mday(argv[i], 0); + if(ret>0) { + seen_day= 1; + erg->tm_mday= ret; + continue; + } + if(ret==-2) /* first pure number must be day of month */ + {ret= 0; goto ex;} + } + if(!seen_time) { + ret= Decode_date_hms(argv[i], erg, 0); + if(ret>0) { + seen_time= 1; + continue; + } + } + if(!seen_year) { + ret= Decode_date_year(argv[i], 0); + if(ret>0) { + erg->tm_year= ret-1900; + seen_year= 1; + continue; + } + } + + /* ignorants have to stay at the end of the loop */ + + ret= Decode_date_timezone(argv[i], erg, 0); + if(ret>=0) + continue; + ret= Decode_date_weekday(argv[i], 0); + if(ret>=0) + continue; /* ignore weekdays */ + + {ret= 0; goto ex;} /* unrecognizable component */ + } + + if(!(seen_day && seen_month)) + {ret= 0; goto ex;} + if(!seen_year) { /* then use this year */ + timep= time(NULL); + now= localtime(&timep); + erg->tm_year= now->tm_year; + } + ret= 1; +ex: + Sfile_make_argv("", "", &argc, &argv, 2); /* release storage */ + return(ret); +} + + +int Decode_xorriso_timestamp(struct tm *erg, char *code, int flag) + /* 2007.11.07.225624 */ +{ + char buf[20]; + int year,month,day,hour= 0,minute= 0,second= 0, i, l, mem; + + memset(erg, 0, sizeof(*erg)); + erg->tm_isdst= -1; + + l= strlen(code); + if(l>17 || l<10) + return(0); + strcpy(buf, code); + for(i= 0; buf[i]!=0 && i<4; i++) + if(!isdigit(buf[i])) + return(0); + if(buf[4]!='.') + return(0); + buf[4]= 0; + sscanf(buf, "%d", &year); + if(year<1900 || year>3000) + return(0); + if(!(isdigit(buf[5]) && isdigit(buf[6]) && buf[7]=='.')) + return(0); + buf[7]= 0; + sscanf(buf+5, "%d", &month); + if(month<1 || month>12) + return(0); + if(!(isdigit(buf[8]) && isdigit(buf[9]) && (buf[10]=='.' || buf[10]==0))) + return(0); + buf[10]= 0; + sscanf(buf+8, "%d", &day); + if(day<1 || day>31) + return(0); + if(l==10) + goto done; + if(!(isdigit(buf[11]) && isdigit(buf[12]) && + (isdigit(buf[13]) || buf[13]==0))) + return(0); + mem= buf[13]; + buf[13]= 0; + sscanf(buf+11, "%d", &hour); + buf[13]= mem; + if(hour<0 || hour>23) + return(0); + if(l==13) + goto done; + if(!(isdigit(buf[13]) && isdigit(buf[14]) && + (isdigit(buf[15]) || buf[15]==0))) + return(0); + mem= buf[15]; + buf[15]= 0; + sscanf(buf+13, "%d", &minute); + buf[15]= mem; + if(minute<0 || minute>59) + return(0); + if(l==15) + goto done; + if(!(isdigit(buf[15]) && isdigit(buf[16]) && buf[17]==0)) + return(0); + sscanf(buf+15, "%d", &second); + if(second<0 || second>59) + return(0); + +done:; + erg->tm_year= year-1900; + erg->tm_mon= month-1; + erg->tm_mday= day; + erg->tm_hour= hour; + erg->tm_min= minute; + erg->tm_sec= second; + return(1); +} + + +time_t Decode_timestring(char *code, time_t *date, int flag) +{ + char *cpt,scale_chr; + double value,seconds; + struct tm result_tm; + int seconds_valid= 0; + + *date= 0; + cpt= code; + if(code[0]=='-' || code[0]=='+' || code[0]=='='){ + if(code[1]==0) + return(0); + if(!isdigit(code[1])) + return(0); + value= -1; + if(code[0]=='=') { + seconds= 0; + sscanf(code+1,"%lf",&value); + } else { + seconds= time(NULL); + sscanf(code,"%lf",&value); + } + scale_chr= code[strlen(code)-1]; + if(isalpha(scale_chr)) + scale_chr= tolower(scale_chr); + if (scale_chr=='s') seconds+= 1.0*value; + else if(scale_chr=='h') seconds+= 3600.0*value; + else if(scale_chr=='d') seconds+= 86400.0*value; + else if(scale_chr=='w') seconds+= 86400.0*7.0*value; + else if(scale_chr=='m') seconds+= 86400.0*31.0*value; + else if(scale_chr=='y') seconds+= 86400.0*(365.25*value+1.0); + else seconds+= 1.0*value; + seconds_valid= 1; + goto completed; + } else if(Sfile_decode_datestr(&result_tm,code,0)>0) { + /* YYMMDD[.hhmm[ss]] */ + result_tm.tm_isdst= -1; + seconds= mktime(&result_tm); + seconds_valid= 1; + goto completed; + } else if(Decode_date_input_format(&result_tm,code,0)>0) { + /* MMDDhhmm[[CC]YY][.ss]] */ + result_tm.tm_isdst= -1; + seconds= mktime(&result_tm); + seconds_valid= 1; + goto completed; + } else if(Decode_xorriso_timestamp(&result_tm, code, 0)>0) { + /* 2007.11.07.225624 */ + seconds= mktime(&result_tm); + seconds_valid= 1; + goto completed; + } else if(Decode_date_output_format(&result_tm, code, 0)>0) { + /* Thu Nov 8 09:07:50 CET 2007 */; + /* Sat, 03 Nov 2007 08:58:30 +0100 */; + /* Nov 7 23:24 */; + seconds= mktime(&result_tm); + seconds_valid= 1; + goto completed; + } + return(0); +completed:; + if(!seconds_valid) + return(0); + *date= seconds; + return(1); +} + + +/* @param flag bit0=with year and seconds + bit1=timestamp format YYYY.MM.DD.hhmmss +*/ +char *Ftimetxt(time_t t, char timetext[40], int flag) +{ + char *rpt; + struct tm tms, *tmpt; + static char months[12][4]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + + tmpt= localtime_r(&t, &tms); + rpt= timetext; + rpt[0]= 0; + if(tmpt==0) + sprintf(rpt+strlen(rpt), "%12.f", (double) t); + else if (flag&2) + sprintf(rpt+strlen(rpt), "%4.4d.%2.2d.%2.2d.%2.2d%2.2d%2.2d", + 1900+tms.tm_year, tms.tm_mon, tms.tm_mday, + tms.tm_hour, tms.tm_min, tms.tm_sec); + else if (flag&1) + sprintf(rpt+strlen(rpt), "%2d %3s %4.4d %2.2d:%2.2d:%2.2d", + tms.tm_mday, months[tms.tm_mon], 1900+tms.tm_year, + tms.tm_hour, tms.tm_min, tms.tm_sec); + else if(time(NULL)-t < 180*86400 && time(NULL)-t >= 0) + sprintf(rpt+strlen(rpt), "%3s %2d %2.2d:%2.2d", + months[tms.tm_mon], tms.tm_mday, tms.tm_hour, tms.tm_min); + else + sprintf(rpt+strlen(rpt), "%3s %2d %4.4d", + months[tms.tm_mon], tms.tm_mday, 1900+tms.tm_year); + return(timetext); +} + + +/* @param flag bit0= single letters */ +char *Ftypetxt(mode_t st_mode, int flag) +{ + if(flag&1) + goto single_letters; + if(S_ISDIR(st_mode)) + return("directory"); + else if(S_ISREG(st_mode)) + return("regular_file"); + else if(S_ISLNK(st_mode)) + return("symbolic_link"); + else if(S_ISBLK(st_mode)) + return("block_device"); + else if(S_ISCHR(st_mode)) + return("char_device"); + else if(S_ISFIFO(st_mode)) + return("name_pipe"); + else if(S_ISSOCK(st_mode)) + return("unix_socket"); + return("unknown"); +single_letters:; + if(S_ISDIR(st_mode)) + return("d"); + else if(S_ISREG(st_mode)) + return("-"); + else if(S_ISLNK(st_mode)) + return("l"); + else if(S_ISBLK(st_mode)) + return("b"); + else if(S_ISCHR(st_mode)) + return("c"); + else if(S_ISFIFO(st_mode)) + return("p"); + else if(S_ISSOCK(st_mode)) + return("s"); + return("?"); +} + + +/* ------------------------------------------------------------------------ */ + + +#ifndef Xorriso_sregex_externaL + +#ifndef Smem_malloC +#define Smem_malloC malloc +#endif +#ifndef Smem_freE +#define Smem_freE free +#endif + + +int Sregex_string_cut(char **handle, char *text, int len, int flag) +/* + bit0= append (text!=NULL) +*/ +{ + int l=0; + char *old_handle; + + if((flag&1)&&*handle!=NULL) + l+= strlen(*handle); + old_handle= *handle; + if(text!=NULL) { + l+= len; + *handle= TSOB_FELD(char,l+1); + if(*handle==NULL) { + *handle= old_handle; + return(0); + } + if((flag&1) && old_handle!=NULL) + strcpy(*handle,old_handle); + else + (*handle)[0]= 0; + if(len>0) + strncat(*handle,text,len); + } else { + *handle= NULL; + } + if(old_handle!=NULL) + Smem_freE(old_handle); + return(1); +} + + +int Sregex_string(char **handle, char *text, int flag) +/* + bit0= append (text!=NULL) +*/ +{ + int ret,l=0; + + if(text!=NULL) + l= strlen(text); + +/* #define Sregex_looking_for_contenT 1 */ +#ifdef Sregex_looking_for_contenT + /* a debugging point if a certain text content has to be caught */ + if(text!=NULL) + if(strcmp(text,"clear")==0) + ret= 0; +#endif + + ret= Sregex_string_cut(handle,text,l,flag&1); + return(ret); +} + +#endif /* Xorriso_sregex_externaL */ + + +#ifndef Xorriso_text_shellsafe_externaL + +char *Text_shellsafe(char *in_text, char *out_text, int flag) +{ + int l,i,w=0; + + /* enclose everything by hard quotes */ + l= strlen(in_text); + out_text[w++]= '\''; + for(i=0;i<l;i++){ + if(in_text[i]=='\''){ + if(w+7>5*SfileadrL) + goto overflow; + /* escape hard quote within the text */ + out_text[w++]= '\''; + out_text[w++]= '"'; + out_text[w++]= '\''; + out_text[w++]= '"'; + out_text[w++]= '\''; + } else { + if(w+3>5*SfileadrL) { +overflow:; + strncpy(out_text, "'xorriso: TEXT MUCH TOO LONG ... ",33); + break; + } + out_text[w++]= in_text[i]; + } + } + out_text[w++]= '\''; + out_text[w++]= 0; + return(out_text); +} + + +#endif /* ! Xorriso_text_shellsafe_externaL */ + + + + +#ifndef Xorriso_fileliste_externaL + +/* ??? ts A71006 : Is this compatible with mkisofs pathspecs ? + I dimly remember so */ + +int Fileliste__target_source_limit(char *line, char sep, char **limit_pt, + int flag) +{ + char *npt; + + for(npt= line;*npt!=0;npt++) { + if(*npt=='\\') { + if(*(npt+1)!=0) + npt++; + continue; + } + if(*npt=='=') + break; + } + if(*npt==0) + npt= NULL; + (*limit_pt)= npt; + return(npt!=NULL); +} + +#endif /* ! Xorriso_fileliste_externaL */ + + +/* ------------------------------------------------------------------------ */ +/* DirseQ : crawl along a directory's content list */ + +static int Dirseq_buffer_sizE= 100; + +struct DirseQ { + char adr[SfileadrL]; + DIR *dirpt; + int count; + char **buffer; + int buffer_size; + int buffer_fill; + int buffer_rpt; + + struct DirseQ *next; +}; + +int Dirseq_destroy(struct DirseQ **o, int flag); +int Dirseq_next_adrblock(struct DirseQ *o, char *replies[], int *reply_count, + int max_replies, int flag); + + +int Dirseq_new(struct DirseQ **o, char *adr, int flag) +/* + bit0= with non-fatal errors do not complain about failed opendir() +*/ +{ + int ret,i,severe_error; + struct DirseQ *m; + + m= *o= TSOB_FELD(struct DirseQ,1); + if(m==NULL) + return(-1); + m->adr[0]= 0; + m->dirpt= NULL; + m->count= 0; + m->buffer= NULL; + m->buffer_size= 0; + m->buffer_fill= 0; + m->buffer_rpt= 0; + m->next= NULL; + if(Sfile_str(m->adr, adr, 0)<=0) + {ret= 0; goto failed;} + m->buffer= TSOB_FELD(char *,Dirseq_buffer_sizE); + if(m->buffer==NULL) + {ret= -1; goto failed;} + m->buffer_size= Dirseq_buffer_sizE; + for(i= 0;i<m->buffer_size;i++) + m->buffer[i]= NULL; + if(adr[0]==0) + m->dirpt= opendir("."); + else + m->dirpt= opendir(adr); + if(m->dirpt==NULL) { + severe_error= (errno && errno!=ENOENT && errno!=EACCES && errno!=ENOTDIR); + if(severe_error || !(flag&1)) + fprintf(stderr,"opendir(%s) failed : %s\n",adr,strerror(errno)); + ret= -severe_error; + goto failed; + } + return(1); +failed:; + Dirseq_destroy(o,0); + return(ret); +} + + +int Dirseq_destroy(struct DirseQ **o, int flag) +{ + int i; + + if(*o==NULL) + return(0); + if((*o)->dirpt!=NULL) + closedir((*o)->dirpt); + if((*o)->buffer!=NULL) { + for(i=0;i<(*o)->buffer_size;i++) + if((*o)->buffer[i]!=NULL) + free((*o)->buffer[i]); + free((char *) (*o)->buffer); + } + free((char *) *o); + (*o)= NULL; + return(1); +} + + +int Dirseq_set_next(struct DirseQ *o, struct DirseQ *next, int flag) +{ + o->next= next; + return(1); +} + + +int Dirseq_get_next(struct DirseQ *o, struct DirseQ **next, int flag) +{ + *next= o->next; + return(1); +} + + +int Dirseq_get_adr(struct DirseQ *o, char **adrpt, int flag) +{ + *adrpt= o->adr; + return(1); +} + + +int Dirseq_rewind(struct DirseQ *o, int flag) +{ + rewinddir(o->dirpt); + return(1); +} + + +int Dirseq_next_adr(struct DirseQ *o, char reply[SfileadrL], int flag) +/* +flag: + bit0= permission to use buffer + bit1= do not increment counter + bit2= ignore buffer in any case + bit3= do not exclude '.' and '..' + bit4= sort buffer + bit5= sort only incomplete last buffer +return: + <0 error + 0= no more entries available + 1= ok, reply is valid +*/ +{ + int ret; + struct dirent *entry; + char *name; + + static int override_flag_0= 0,override_flag_1= 32; + flag= (flag&~override_flag_0)|override_flag_1; + + if((flag&1) && o->buffer_rpt>=o->buffer_fill) { + /* permission to buffer and buffer empty : load a buffer */ + ret= Dirseq_next_adrblock(o,o->buffer,&(o->buffer_fill), + o->buffer_size,2|4|(flag&16)); + if(ret<=0) + return(ret); + o->buffer_rpt= 0; + if((flag&32) && o->buffer_fill<o->buffer_size && o->buffer_fill>0) + Sort_argv(o->buffer_fill,o->buffer,0); + } + if(o->buffer_rpt<o->buffer_fill && !(flag&4)) { + ret= Sfile_str(reply,o->buffer[o->buffer_rpt],0); + Sregex_string(&(o->buffer[o->buffer_rpt]),NULL,0); + if(ret<=0) + return(-1); + (o->buffer_rpt)++; + if(!(flag&2)) + o->count++; + return(1); + } + do { + entry= readdir(o->dirpt); + if(entry==NULL) { + /* >>> how to distinguish error from EOF , do i need a (FILE *) ? */ + return(0); + } + if(strlen(entry->d_name)>=SfileadrL) { + fprintf(stderr,"--- oversized directory entry (number %d) :\n %s", + o->count+1,entry->d_name); + return(-1); + } + name= entry->d_name; + if(flag&8) + break; + /* skip "." and ".." */ + } while(name[0]=='.' && ((name[1]=='.' && name[2]==0) || name[1]==0)); + if(Sfile_str(reply,name,0)<=0) + return(-1); + if(!(flag&2)) + o->count++; + return(1); +} + + +int Dirseq_next_adrblock(struct DirseQ *o, char *replies[], int *reply_count, + int max_replies, int flag) +/* @param replies A vector of Sregex_string pointers */ +/* +flag: + bit0= permission to use buffer + bit1= do not increment counter + bit2= ignore buffer in any case + bit4= sort replies +return: + <0 error + 0= no more entries available + 1= ok, reply is valid +*/ +{ + int i,ret; + char reply[SfileadrL]; + + *reply_count= 0; + for(i=0;i<max_replies;i++) { + ret= Dirseq_next_adr(o,reply,flag&(1|2|4)); + if(ret<0) + return(ret); + if(ret==0) + break; + if(Sregex_string(&(replies[i]),reply,0)<=0) + return(-1); + (*reply_count)++; + } + if((*reply_count)==0) + return(0); + if(flag&16) + Sort_argv(*reply_count,replies,0); + return(1); +} + + +/* ------------------------------ LinkiteM -------------------------------- */ + +struct LinkiteM { + char *link_path; + dev_t target_dev; + ino_t target_ino; + int link_count; + struct LinkiteM *next; +}; + +int Linkitem_destroy(struct LinkiteM **o, int flag); + + +int Linkitem_new(struct LinkiteM **o, char *link_path, dev_t target_dev, + ino_t target_ino, struct LinkiteM *next, int flag) +{ + struct LinkiteM *m; + + m= *o= TSOB_FELD(struct LinkiteM,1); + if(m==NULL) + return(-1); + m->target_dev= target_dev; + m->target_ino= target_ino; + m->next= next; + m->link_count= 1; + if(next!=NULL) + m->link_count= m->next->link_count+1; + m->link_path= strdup(link_path); + if(m->link_path==NULL) + goto failed; + return(1); +failed:; + Linkitem_destroy(o, 0); + return(-1); +} + + +int Linkitem_destroy(struct LinkiteM **o, int flag) +{ + if((*o)==NULL) + return(0); + if((*o)->link_path!=NULL) + free((*o)->link_path); + free((char *) (*o)); + *o= NULL; + return(1); +} + + +int Linkitem_reset_stack(struct LinkiteM **o, struct LinkiteM *to, int flag) +{ + struct LinkiteM *m, *m_next= NULL; + + /* Prevent memory corruption */ + for(m= *o; m!=to; m= m->next) + if(m==NULL) { /* this may actually not happen */ + *o= to; + return(-1); + } + + for(m= *o; m!=to; m= m_next) { + m_next= m->next; + Linkitem_destroy(&m, 0); + } + *o= to; + return(1); +} + + +int Linkitem_find(struct LinkiteM *stack, dev_t target_dev, ino_t target_ino, + struct LinkiteM **result, int flag) +{ + struct LinkiteM *m; + + for(m= stack; m!=NULL; m= m->next) { + if(target_dev == m->target_dev && target_ino == m->target_ino) { + *result= m; + return(1); + } + } + return(0); +} + + +/* ------------------------------- FindjoB -------------------------------- */ + + +struct FindjoB { + char *start_path; + + char *name_expr; +#ifdef Xorriso_with_regeX + regex_t name_re; + regmatch_t name_match; +#endif + + /* b = blockdev + c = chardev + d = directory + p = fifo + f = reg + - = reg + s = socket + m = subordinate mountpoint (does never match find start directory) + X = other + 0x0 = test inactive + */ + char file_type; + + + /* 0= echo + 1= rm (also rmdir) + 2= rm_r +>>> 3= mv target + 4= chown user + 5= chgrp group + 6= chmod mode_and mode_or + 7= alter_date type date + 8= lsdl + 9= chown_r user + 10= chgrp_r group + 11= chmod_r mode_and mode_or + 12= alter_date_r type date + 13= find + 14= compare disk_equivalent_of_start_path + 15= in_iso iso_rr_equivalent_of_start_path + 16= not_in_iso iso_rr_equiv + 17= update disk_equiv + 18= add_missing iso_rr_equiv + 19= empty_iso_dir iso_rr_equiv + 20= is_full_in_iso iso_rr_equiv + */ + int action; + char *target; + uid_t user; + gid_t group; + mode_t mode_and, mode_or; + int type; /* see Xorriso_set_time flag */ + time_t date; + struct FindjoB *subjob; + +}; + +int Findjob_destroy(struct FindjoB **job, int flag); + + +int Findjob_new(struct FindjoB **o, char *start_path, int flag) +{ + struct FindjoB *m; + + m= *o= TSOB_FELD(struct FindjoB,1); + if(m==NULL) + return(-1); + m->start_path= NULL; + m->name_expr= NULL; + m->file_type= 0; + m->action= 0; /* print */ + m->target= NULL; /* a mere pointer, not managed memory */ + m->user= 0; + m->group= 0; + m->type= 0; + m->date= 0; + m->subjob= NULL; + m->start_path= strdup(start_path); + if(m->start_path==NULL) + goto failed; + return(1); +failed:; + Findjob_destroy(o, 0); + return(-1); +} + + +int Findjob_destroy(struct FindjoB **o, int flag) +{ + struct FindjoB *m; + + m= *o; + if(m==NULL) + return(0); + if(m->start_path!=NULL) + free(m->start_path); + if(m->name_expr!=NULL) { +#ifdef Xorriso_with_regeX + regfree(&(m->name_re)); +#endif + free(m->name_expr); + } + Findjob_destroy(&(m->subjob), 0); + free((char *) m); + *o= NULL; + return(1); +} + + +int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag) +{ + if(o->start_path!=NULL) + free(o->start_path); + if(start_path!=NULL) { + o->start_path= strdup(start_path); + if(o->start_path==NULL) + return(-1); + } else + o->start_path= NULL; + return(1); +} + + +int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag) +{ + *start_path= o->start_path; + return(1); +} + + +int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag) +{ + char regexpr[2*SfileadrL+2]; + + if(o->name_expr!=NULL) { +#ifdef Xorriso_with_regeX + regfree(&(o->name_re)); +#endif + free(o->name_expr); + o->name_expr= NULL; + } + if(strlen(name_expr)>=SfileadrL) + return(0); + o->name_expr= strdup(name_expr); + if(o->name_expr==NULL) + return(-1); + Xorriso__bourne_to_reg(name_expr, regexpr, 0); + if(regcomp(&(o->name_re), regexpr, 0)!=0) + return(0); + return(1); +} + + +int Findjob_set_file_type(struct FindjoB *o, char file_type, int flag) +{ + static char known[]= {"bcdpf-lsmX"}; + + if(file_type!=0) + if(strchr(known, file_type)==NULL) + return(0); + o->file_type= file_type; + return(1); +} + + +/* @return 0=no match , 1=match , <0 = error +*/ +int Findjob_test(struct FindjoB *o, char *name, + struct stat *boss_stbuf, struct stat *stbuf, + int depth, int flag) +{ + int ret; + + if(o->name_expr!=NULL) { +#ifdef Xorriso_with_regeX + ret= regexec(&(o->name_re),name,1,&(o->name_match),0); +#else + ret= !(strcmp(name, o->name_expr)==0 || strcmp(o->name_expr, "*")==0); +#endif + if(ret!=0) + return(0); + } + + if(o->file_type!=0) { + if(S_ISBLK(stbuf->st_mode)) { + if(o->file_type!='b') + return(0); + } else if(S_ISCHR(stbuf->st_mode)) { + if(o->file_type!='c') + return(0); + } else if(S_ISDIR(stbuf->st_mode)) { + if(o->file_type=='m') { + if(boss_stbuf==NULL) + return(0); + if(boss_stbuf->st_dev == stbuf->st_dev) + return(0); + } else if(o->file_type!='d') + return(0); + } else if(S_ISFIFO(stbuf->st_mode)) { + if(o->file_type!='p') + return(0); + } else if(S_ISREG(stbuf->st_mode)) { + if(o->file_type!='f' && o->file_type!='-') + return(0); + } else if(((stbuf->st_mode)&S_IFMT)==S_IFLNK) { + if(o->file_type!='l') + return(0); + } else if(((stbuf->st_mode)&S_IFMT)==S_IFSOCK) { + if(o->file_type!='s') + return(0); + } else { + if(o->file_type!='X') + return(0); + } + } + + /* ??? >>> more tests to come ?*/; + + return(1); +} + + +int Findjob_get_action(struct FindjoB *o, int flag) +{ + return(o->action); +} + + +/* @return <0 error, >=0 see above struct FindjoB.action +*/ +int Findjob_get_action_parms(struct FindjoB *o, char **target, + uid_t *user, gid_t *group, + mode_t *mode_and, mode_t *mode_or, + int *type, time_t *date, struct FindjoB **subjob, + int flag) +{ + *target= o->target; + *user= o->user; + *group= o->group; + *mode_and= o->mode_and; + *mode_or= o->mode_or; + *type= o->type; + *date= o->date; + *subjob= o->subjob; + return(o->action); +} + + +int Findjob_set_action_target(struct FindjoB *o, int action, char *target, + int flag) +{ + o->action= action; + o->target= target; + return(1); +} + + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chown(struct FindjoB *o, uid_t user,int flag) +{ + int ret; + + if(flag&1) { + o->action= 0; + Findjob_destroy(&(o->subjob), 0); + ret= Findjob_new(&(o->subjob), "", 0); + if(ret<=0) + return(-1); + Findjob_set_action_chown(o->subjob, user, 0); + o->action= 9; + } else { + o->action= 4; + o->user= user; + } + return(1); +} + + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chgrp(struct FindjoB *o, gid_t group, int flag) +{ + int ret; + + if(flag&1) { + o->action= 0; + Findjob_destroy(&(o->subjob), 0); + ret= Findjob_new(&(o->subjob), "", 0); + if(ret<=0) + return(-1); + Findjob_set_action_chgrp(o->subjob, group, 0); + o->action= 10; + } else { + o->action= 5; + o->group= group; + } + return(1); +} + + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chmod(struct FindjoB *o, + mode_t mode_and, mode_t mode_or, int flag) +{ + int ret; + + if(flag&1) { + o->action= 0; + Findjob_destroy(&(o->subjob), 0); + ret= Findjob_new(&(o->subjob), "", 0); + if(ret<=0) + return(-1); + Findjob_set_action_chmod(o->subjob, mode_and, mode_or, 0); + o->action= 11; + } else { + o->action= 6; + o->mode_and= mode_and; + o->mode_or= mode_or; + } + return(1); +} + + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_ad(struct FindjoB *o, int type, time_t date, int flag) +{ + int ret; + + if(flag&1) { + o->action= 0; + Findjob_destroy(&(o->subjob), 0); + ret= Findjob_new(&(o->subjob), "", 0); + if(ret<=0) + return(-1); + Findjob_set_action_ad(o->subjob, type, date, 0); + o->action= 12; + } else { + o->action= 7; + o->type= type; + o->date= date; + } + return(1); +} + + +int Findjob_set_action_subjob(struct FindjoB *o, int action, + struct FindjoB *subjob, int flag) +{ + o->action= action; + Findjob_destroy(&(o->subjob), 0); + o->subjob= subjob; + return(1); +} + + +/* ---------------------------- SplitparT ------------------------- */ + + +struct SplitparT { + char *name; + int partno; + int total_parts; + off_t offset; + off_t bytes; + off_t total_bytes; +}; + + +int Splitparts_new(struct SplitparT **o, int count, int flag) +{ + int i; + + (*o)= TSOB_FELD(struct SplitparT, count); + if((*o)==NULL) + return(-1); + for(i= 0; i<count; i++) { + (*o)[i].name= NULL; + (*o)[i].partno= 0; + (*o)[i].total_parts= 0; + (*o)[i].offset= 0; + (*o)[i].bytes= 0; + (*o)[i].total_bytes= 0; + } + return(1); +} + + +int Splitparts_destroy(struct SplitparT **o, int count, int flag) +{ + int i; + + if((*o)==NULL) + return(0); + for(i= 0; i<count; i++) { + if((*o)[i].name!=NULL) + free((*o)[i].name); + } + free(*o); + *o= NULL; + return(1); +} + + +int Splitparts_set(struct SplitparT *o, int idx, + char *name, int partno, int total_parts, + off_t offset, off_t bytes, off_t total_bytes, int flag) +{ + if(o[idx].name!=NULL) + free(o[idx].name); + o[idx].name= strdup(name); + if(o[idx].name==NULL) + return(-1); + o[idx].partno= partno; + o[idx].total_parts= total_parts; + o[idx].offset= offset; + o[idx].bytes= bytes; + o[idx].total_bytes= total_bytes; + return(1); +} + + +int Splitparts_get(struct SplitparT *o, int idx, char **name, int *partno, + int *total_parts, off_t *offset, off_t *bytes, + off_t *total_bytes, int flag) +{ + *name= o[idx].name; + *partno= o[idx].partno; + *total_parts= o[idx].total_parts; + *offset= o[idx].offset; + *bytes= o[idx].bytes; + *total_bytes= o[idx].total_bytes; + return(1); +} + + +int Splitpart__read_next_num(char *base_pt, char **next_pt, off_t *num, + int flag) +{ + char *cpt, *ept, scale[4]; + + *num= 0; + for(cpt= base_pt; *cpt!=0 && !isdigit(*cpt); cpt++); + if(*cpt==0) + return(0); + for(ept= cpt; *ept!=0 && isdigit(*ept); ept++) + *num= (*num)*10+(*ept)-'0'; + scale[0]= '1'; + scale[1]= *ept; + scale[2]= 0; + *num *= (off_t) Scanf_io_size(scale, 0); + if(*ept!=0) + ept++; + *next_pt= ept; + return(1); +} + + +int Splitpart__parse(char *name, int *partno, int *total_parts, + off_t *offset, off_t *bytes, off_t *total_bytes, int flag) + +{ + int ret; + off_t num; + char *cpt, *ept; + + cpt= name; + ret= Splitpart__read_next_num(cpt, &ept, &num, 0); + if(ret<=0) + return(ret); + *partno= num; + cpt= ept; + ret= Splitpart__read_next_num(cpt, &ept, &num, 0); + if(ret<=0) + return(ret); + *total_parts= num; + cpt= ept; + ret= Splitpart__read_next_num(cpt, &ept, offset, 0); + if(ret<=0) + return(ret); + cpt= ept; + ret= Splitpart__read_next_num(cpt, &ept, bytes, 0); + if(ret<=0) + return(ret); + cpt= ept; + ret= Splitpart__read_next_num(cpt, &ept, total_bytes, 0); + if(ret<=0) + return(ret); + return(1); +} + + +int Splitpart__compose(char *adr, int partno, int total_parts, + off_t offset, off_t bytes, off_t total_bytes, int flag) +{ + sprintf(adr, "part_%d_of_%d_at_", partno, total_parts); + if((offset % (1024*1024))==0 && offset>0) { + Sfile_off_t_text(adr+strlen(adr), offset / (1024*1024), 0); + strcat(adr, "m"); + } else + Sfile_off_t_text(adr+strlen(adr), offset, 0); + strcat(adr, "_with_"); + if((bytes % (1024*1024))==0) { + Sfile_off_t_text(adr+strlen(adr), bytes / (1024*1024), 0); + strcat(adr, "m"); + } else + Sfile_off_t_text(adr+strlen(adr), bytes, 0); + strcat(adr, "_of_"); + Sfile_off_t_text(adr+strlen(adr), total_bytes, 0); + return(1); +} + + +/* ---------------------------- End SplitparT ------------------------- */ + +/* ------------------------------- Xorriso -------------------------------- */ + +/** The list of startup file names */ +#define Xorriso_rc_nuM 4 + +static char Xorriso_sys_rc_nameS[Xorriso_rc_nuM][80]= { + "/etc/default/xorriso", + "/etc/opt/xorriso/rc", + "/etc/xorriso/xorriso.conf", + "placeholder for $HOME/.xorrisorc" +}; + + +int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) +{ + int i; + struct XorrisO *m; + + *xorriso= m= TSOB_FELD(struct XorrisO,1); + if(m==NULL) + return(-1); + m->libs_are_started= 0; + strncpy(m->progname,progname,sizeof(m->progname)-1); + m->progname[sizeof(m->progname)-1]= 0; + if(getcwd(m->initial_wdx,sizeof(m->initial_wdx)-1)==NULL) + m->initial_wdx[0]= 0; + m->no_rc= 0; + + m->rc_filename_count= Xorriso_rc_nuM; + for(i=0;i<m->rc_filename_count-1;i++) + strcpy(m->rc_filenames[i],Xorriso_sys_rc_nameS[i]); + m->rc_filenames[m->rc_filename_count-1][0]= 0; + + m->wdi[0]= 0; + strcpy(m->wdx, m->initial_wdx); + m->did_something_useful= 0; + m->add_plainly= 0; + m->split_size= 0; + m->do_joliet= 0; + m->do_follow_pattern= 1; + m->do_follow_param= 0; + m->do_follow_links= 0; + m->follow_link_limit= 100; + m->do_follow_mount= 1; + m->do_global_uid= 0; + m->global_uid= 0; + strcpy(m->volid, "ISOIMAGE"); + m->loaded_volid[0]= 0; + m->volid_default= 1; + m->publisher[0]= 0; + m->session_logfile[0]= 0; + m->session_lba= -1; + m->session_blocks= 0; + m->do_global_gid= 0; + m->global_gid= 0; + m->do_global_mode= 0; + m->global_dir_mode= 0555; + m->global_file_mode= 0444; + m->do_overwrite= 2; + m->do_reassure= 0; + m->indev[0]= 0; + m->in_drive_handle= NULL; + m->in_volset_handle= NULL; + m->volset_change_pending= 0; + m->no_volset_present= 0; + m->outdev[0]= 0; + m->out_drive_handle= NULL; + m->dev_fd_1= -1; + m->ban_stdio_write= 0; + m->do_dummy= 0; + m->do_close= 0; + m->speed= 0; + m->fs= 4*512; /* 4 MiB */ + m->padding= 300*1024; + m->keep_boot_image= 0; + m->patch_isolinux_image= 0; + m->allow_graft_points= 0; + m->dialog= 0; + m->search_mode= 0; + m->structured_search= 1; + m->do_iso_rr_pattern= 1; + m->do_disk_pattern= 2; + m->temp_mem_limit= 16*1024*1024; + m->use_stdin= 0; + m->result_page_length= 0; + m->result_page_width= 80; + m->mark_text[0]= 0; + m->packet_output= 0; + for(i=0; i<4; i++) + m->logfile[i][0]= 0; + m->status_history_max= Xorriso_status_history_maX; + strcpy(m->report_about_text, "UPDATE"); + Xorriso__text_to_sev(m->report_about_text, &m->report_about_severity, 0); + m->library_msg_direct_print= 0; + strcpy(m->abort_on_text,"FATAL"); + Xorriso__text_to_sev(m->abort_on_text, &m->abort_on_severity, 0); + m->problem_status= 0; + m->problem_status_text[0]= 0; + m->errfile_log[0]= 0; + m->errfile_fp= NULL; + strcpy(m->return_with_text, "SORRY"); + Xorriso__text_to_sev(m->return_with_text, &m->return_with_severity, 0); + m->return_with_value= 32; + m->eternal_problem_status= 0; + m->eternal_problem_status_text[0]= 0; +#ifdef Xorriso_with_regeX + m->re= NULL; + /* >>> ??? how to initialize m->match[0] ? */ +#endif /* Xorriso_with_regeX */ + m->re_constants= NULL; + m->re_count= 0; + m->re_fill= 0; + m->reg_expr[0]= 0; + m->run_state= 0; + m->is_dialog= 0; + m->bar_is_fresh= 0; + m->pending_option[0]= 0; + m->request_to_abort= 0; + m->request_not_to_ask= 0; + m->idle_time= 0.0; + m->re_failed_at= -1; + m->prepended_wd= 0; + m->insert_count= 0; + m->insert_bytes= 0; + m->error_count= 0; + m->pacifier_interval= 1.0; + m->pacifier_count= 0; + m->pacifier_total= 0; + m->pacifier_fifo= NULL; + m->start_time= 0.0; + m->last_update_time= 0.0; + m->find_compare_result= 1; + m->result_line[0]= 0; + m->result_line_counter= 0; + m->result_page_counter= 0; + m->result_open_line_len= 0; + m->info_text[0]= 0; + + return(1); +} + + +int Xorriso_destroy_re(struct XorrisO *m, int flag) +{ + int i; + +#ifdef Xorriso_with_regeX + if(m->re!=NULL) { + for(i=0;i<m->re_fill;i++) { + if(m->re_constants!=NULL) + if(m->re_constants[i]!=NULL) + continue; /* ,->re[i] was never subject to regcomp() */ + regfree(&(m->re[i])); + } + free((char *) m->re); + m->re= NULL; + } +#endif /* Xorriso_with_regeX */ + + if(m->re_constants!=NULL) { + for(i=0;i<m->re_fill;i++) + if(m->re_constants[i]!=NULL) + free(m->re_constants[i]); + free((char *) m->re_constants); + m->re_constants= NULL; + } + m->re_count= 0; + m->re_fill= 0; + return(1); +} + + +/* @param flag bit0= global shutdown of libraries */ +int Xorriso_destroy(struct XorrisO **xorriso, int flag) +{ + struct XorrisO *m; + + m= *xorriso; + if(m==NULL) + return(0); + Xorriso_destroy_re(m,0); + Xorriso_detach_libraries(m, flag&1); + + free((char *) m); + *xorriso= NULL; + return(1); +} + + +int Xorriso_dialog_input(struct XorrisO *xorriso, char line[], int linesize, + int flag) +/* + bit0= do not write to history + bit1= do not read input (but eventually write to history) + bit2= do not write to history line which begin with "-history:" or "-history " +*/ +{ + char *cpt= NULL; + int ret; +#ifdef Xorriso_with_readlinE + int l; + static char last_input[SfileadrL]= {""}; +#endif /* ! Xorriso_with_readlinE */ + double tdiff; + struct timeval tv; + struct timezone tz; + + gettimeofday(&tv,&tz); + tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec); + + fflush(stdout); + +#ifdef Xorriso_with_readlinE + + if(xorriso->use_stdin || xorriso->dev_fd_1>=0) { + if(flag&2) + {ret= 1; goto ex;} + if(Sfile_fgets(line,linesize-1,stdin)==NULL) { + /* need a very dramatic end */ + kill(getpid(),SIGHUP); + {ret= -1; goto ex;} + } + {ret= 1; goto ex;} + } + if(flag&2) { + cpt= NULL; + } else { + cpt= readline(""); + if(cpt==NULL) { + /* need a very dramatic end */ + kill(getpid(),SIGHUP); + {ret= -1; goto ex;} + } + l= strlen(cpt); + if(l>=linesize) { + strncpy(line,cpt,linesize-1); + line[sizeof(line)-1]= 0; + } else + strcpy(line,cpt); + } + if(line[0]!=0 && strcmp(last_input,line)!=0 && !(flag&1)) + if(!((flag&4) && + (strncmp(line,"-history:",9)==0 || strncmp(line,"-history ",9)==0))) { + add_history(line); + strncpy(last_input,line,sizeof(last_input)-1); + last_input[sizeof(last_input)-1]= 0; + } + +#else /* Xorriso_with_readlinE */ + + if(flag&2) + {ret= 1; goto ex;} + if(Sfile_fgets(line,linesize-1,stdin)==NULL) { + /* need a very dramatic end */ + kill(getpid(),SIGHUP); + {ret= -1; goto ex;} + } + +#endif /* ! Xorriso_with_readlinE */ + + ret= 1; +ex:; + if(cpt!=NULL) + free(cpt); + gettimeofday(&tv,&tz); + xorriso->idle_time+= tv.tv_sec+(1.e-6*(double) tv.tv_usec)-tdiff; + return(ret); +} + + +int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag) +/* + bit0= important operation going on: + demand confirmation of abort, only abort on @@@ + bit1= mark '@' and '@@' by return 4 + bit2= accept: i|n= ignore | do not remove , r|y= retry | remove , q|x= abort + bit3= @@@ = 'done reading' rather than 'abort' + bit4= in non-dialog mode return 6 rather than 1 +*/ +/* return: <=0 error + 1= go on | do not remove existing file + 2= abort + 3= redo request for confirmation + 4= see flag bit1 + (5= skip volume) + 6= retry failed operation | remove existing file + */ +{ + int ret; + char line[SfileadrL],*cpt,previous_line[SfileadrL]; + char *abort_req_text,*abort_really_text; + + if(!xorriso->dialog) { + if(flag&16) + return(6); + return(1); + } + if(flag&8) { + abort_req_text= "request to end"; + abort_really_text= "done reading"; + } else { + abort_req_text= "request to abort"; + abort_really_text= "abort this command"; + } + ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1); + xorriso->result_line_counter= 0; + xorriso->result_page_counter++; + if(ret<=0) + if(xorriso->result_page_length>0) + xorriso->result_page_length= -xorriso->result_page_length; + + cpt= line; + if(strcmp(cpt,"@@@")==0 || + strcmp(cpt,"x")==0 || strcmp(cpt,"X")==0 || + strcmp(cpt,"q")==0 || strcmp(cpt,"Q")==0) { + if(flag&1) { + strcpy(previous_line,cpt); + sprintf(xorriso->info_text, + "... [%s = %s registered. Really %s ? (y/n) ] ...\n", + cpt,abort_req_text,abort_really_text); + Xorriso_info(xorriso,0); + ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1); + if(ret<=0) + return(ret); + cpt= line; + if(strcmp(cpt,previous_line)==0 || + ((*cpt=='Y' || *cpt=='y' || *cpt=='j' || *cpt=='J' || *cpt=='1') && + *(cpt+1)==0)) { + xorriso->request_to_abort= 1; + sprintf(xorriso->info_text, + "------- ( %s confirmed )\n",abort_req_text); + Xorriso_info(xorriso,0); + return(2); + } + sprintf(xorriso->info_text, "....... ( %s revoked )\n",abort_req_text); + Xorriso_info(xorriso,0); + return(3); + } + xorriso->request_to_abort= 1; + sprintf(xorriso->info_text, +"----------- [%s = request to abort registered. Operation ends ] ------------\n", + cpt); + Xorriso_info(xorriso,0); + return(2); + } else if(*cpt=='@') { + if(strcmp(cpt,"@@")==0) { + goto klammer_affe; + + } else if(strcmp(cpt,"@")==0) { +klammer_affe:; + if(xorriso->result_page_length>0) + xorriso->result_page_length= -xorriso->result_page_length; + if(flag&1) { + sprintf(xorriso->info_text, +"... [@ = prompt suppression registered. Prompting disabled temporarily ] ...\n"); + Xorriso_info(xorriso,0); + } + + } else { + Xorriso_dialog_input(xorriso,cpt,strlen(line)+1,2); /* write to history */ + sprintf(xorriso->info_text, + "--- Unrecognized input beginning with @. Please enter someting else.\n"); + Xorriso_info(xorriso,0); + return(3); + } + if(flag&2) + return(4); + if(flag&1) + return(3); + return(1); + } else if(flag&4) { + + if(strcmp(cpt,"i")==0 || strcmp(cpt,"I")==0 || + strcmp(cpt,"n")==0 || strcmp(cpt,"N")==0 || + *cpt==0) { + return(1); + } else if(strcmp(cpt,"r")==0 || strcmp(cpt,"R")==0 || + strcmp(cpt,"y")==0 || strcmp(cpt,"Y")==0) { + return(6); + } else { + /* >>> unknown input */ + sprintf(xorriso->info_text, + "--- Please enter one of : empty line, i,n, r,y, q,x, @, @@@\n"); + Xorriso_info(xorriso,0); + return(3); + } + + } else if(*cpt!=0 && !(flag&1)) { + Xorriso_dialog_input(xorriso,cpt,strlen(line)+1,2); /* write to history */ + strcpy(xorriso->pending_option,cpt); + xorriso->request_to_abort= 1; + sprintf(xorriso->info_text, +"-------------- [ Input of option registered. Operation ends ] ---------------\n"); + Xorriso_info(xorriso,0); + return(2); + + } else if(*cpt!=0) { + Xorriso_dialog_input(xorriso,cpt,strlen(line)+1,2); /* write to history */ + sprintf(xorriso->info_text, + "--- Please enter one of : empty line, @, @@@\n"); + Xorriso_info(xorriso,0); + return(3); + } + return(1); +} + + +int Xorriso_predict_linecount(struct XorrisO *xorriso, char *line, + int *linecount, int flag) +{ + int width,l; + char *spt,*ept; + + *linecount= 0; + spt= line; + width= xorriso->result_page_width; + while(1) { + ept= strchr(spt,'\n'); + if(ept==NULL) + l= strlen(spt); + else + l= ept-spt; + l+= xorriso->result_open_line_len; + if(ept!=NULL && l==0) + (*linecount)++; + else { + (*linecount)+= l/width; + if(ept==NULL) { + xorriso->result_open_line_len= l%width; + break; + } + (*linecount)+= !!(l%width); + } + xorriso->result_open_line_len= 0; + spt= ept+1; + } + return(1); +} + + +int Xorriso_pager(struct XorrisO *xorriso, char *line, int flag) +/* + bit1= mark '@' by return 4 +*/ +/* return: <=0 error , 1=go on , 2=abort , 4=see flag bit1*/ +{ + int ret,linecount; + char info_text[10*SfileadrL]; + + if(xorriso->result_page_length<=0 || xorriso->request_not_to_ask) + return(1); + Xorriso_predict_linecount(xorriso,line,&linecount,0); + if(xorriso->result_line_counter+linecount>xorriso->result_page_length) { +ask_for_page:; + strcpy(info_text,xorriso->info_text); + sprintf(xorriso->info_text,"\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->info_text, +".... [Press Enter to continue. @,Enter avoids further stops. @@@ aborts] ....\n"); + Xorriso_info(xorriso,0); + ret= Xorriso_request_confirmation(xorriso,flag&2); + strcpy(xorriso->info_text,info_text); + if(ret<=0) + return(ret); + if(ret==2) + return(2); + if(ret==3) + goto ask_for_page; + } + xorriso->result_line_counter+= linecount; + return(1); +} + + +int Xorriso_result(struct XorrisO *xorriso, int flag) +/* + bit0= no considerations or computations or dialog. Just put out. +*/ +{ + int ret; + + if(flag&1) + goto put_it_out; + if(xorriso->request_to_abort) + return(1); + if(xorriso->result_page_length>0) { + ret= Xorriso_pager(xorriso,xorriso->result_line,2); + if(ret<=0) + return(ret); + if(ret==2) + return(1); + if(xorriso->request_to_abort) + return(1); + } +put_it_out:; + xorriso->bar_is_fresh= 0; + ret= Write_to_channel(xorriso->result_line,1,!xorriso->packet_output); + return(ret); +} + + +int Xorriso_info(struct XorrisO *xorriso, int flag) +/* + bit0= use pager (as with result) + bit1= permission to suppress output + bit2= insist in showing output +*/ +{ + int ret; + static int note_sev= 0; + + if(flag&2) + if(xorriso->request_to_abort) + return(1); + + if(note_sev==0) + Xorriso__text_to_sev("NOTE", ¬e_sev, 0); + if(note_sev<xorriso->report_about_severity && + note_sev<xorriso->abort_on_severity && !(flag&4)) + return(1); + + if(flag&1) { + ret= Xorriso_pager(xorriso,xorriso->info_text,2); + if(ret<=0) + return(ret); + if(ret==2) + return(1); + if(flag&2) + if(xorriso->request_to_abort) + return(1); + } + xorriso->bar_is_fresh= 0; + ret= Write_to_channel(xorriso->info_text,2,!xorriso->packet_output); + return(ret); +} + + +int Xorriso_mark(struct XorrisO *xorriso, int flag) +{ + int ret= 1,r_ret,i_ret; + + if(xorriso->mark_text[0]==0) + return(1); + if(xorriso->packet_output) + ret= Write_to_channel(xorriso->mark_text,3,0); + else { + sprintf(xorriso->result_line,"%s\n",xorriso->mark_text); + r_ret= Xorriso_result(xorriso,1); + strcpy(xorriso->info_text,xorriso->result_line); + i_ret= Xorriso_info(xorriso,0); + if(r_ret==0 || i_ret==0) + ret= 0; + } + return(ret); +} + + +int Xorriso_restxt(struct XorrisO *xorriso, char *text) +{ + int ret; + + strncpy(xorriso->result_line,text,sizeof(xorriso->result_line)-1); + xorriso->result_line[sizeof(xorriso->result_line)-1]= 0; + ret= Xorriso_result(xorriso,0); + return(ret); +} + + +int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag) +{ + xorriso->start_time= Sfile_microtime(0); + xorriso->last_update_time= xorriso->start_time; + xorriso->pacifier_count= 0; + xorriso->pacifier_total= 0; + return(1); +} + + +/* This call is to be issued by long running workers in short intervals. + It will check whether enough time has elapsed since the last pacifier + message and eventually issue an update message. + @param what_done A sparse description of the action, preferrably in past + tense. E.g. "done" , "files added". + @param count The number of objects processed so far. + Is ignored if <=0. + @param todo The number of objects to be done in total. + Is ignored if <=0. + @param current_object A string telling the object currently processed. + Ignored if "". + @param flag bit0= report unconditionally, no time check + bit1= report count <=0 (no thank you for being patient then) +*/ +int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done, + off_t count, off_t todo, char *current_object, + int flag) +{ + double current_time, since; + char count_text[80]; + + current_time= Sfile_microtime(0); + if(current_time - xorriso->last_update_time < xorriso->pacifier_interval + && !(flag&1)) + return(1); + xorriso->last_update_time= Sfile_microtime(0); + since= current_time - xorriso->start_time; + if((flag&1)&&since<1.0) + since= 1.0; + if(count<=0.0 && !(flag&2)) { + sprintf(xorriso->info_text, + "Thank you for being patient since %.f seconds", since); + } else if(todo<=0.0) { + if(count<10000000) + sprintf(count_text, "%.f", (double) count); + else + Sfile_scale((double) count, count_text, 7, 1e5, 1); + sprintf(xorriso->info_text, + "%s %s in %.f seconds", count_text, what_done, since); + } else { + sprintf(xorriso->info_text, "%.f of %.f %s in %.f seconds", + (double) count, (double) todo, what_done, since); + } + if(current_object[0]!=0) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + ", now at %s", current_object); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + return(1); +} + + +int Xorriso_reset_counters(struct XorrisO *xorriso, int flag) +{ + xorriso->error_count= 0; + xorriso->insert_count= 0; + xorriso->insert_bytes= 0; + Xorriso_pacifier_reset(xorriso, 0); + return(1); +} + + +int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag) +/* reg_expr should be twice as large as bourne_expr ( + 2 to be exact) */ +/* return: 2= bourne_expr is surely a constant */ +{ + char *wpt,*lpt; + int backslash= 0,is_constant= 1,in_square_brackets= 0; + int first_in_square_brackets=0; + + wpt= reg_expr; + lpt= bourne_expr; + + *(wpt++)= '^'; + + while(*lpt!=0){ + if(first_in_square_brackets>0) + first_in_square_brackets--; + if(!backslash){ + switch(*lpt){ + case '?': + *(wpt++)= '.'; + is_constant= 0; + break;case '*': + *(wpt++)= '.'; + *(wpt++)= '*'; + is_constant= 0; + break;case '.': + *(wpt++)= '\\'; + *(wpt++)= '.'; + break;case '+': + *(wpt++)= '\\'; + *(wpt++)= '+'; + break;case '[': + *(wpt++)= *lpt; + first_in_square_brackets= 2; + in_square_brackets= 1; + is_constant= 0; + break;case ']': + *(wpt++)= *lpt; + in_square_brackets= 0; + break;case '!': + if(first_in_square_brackets) + *(wpt++)= '^'; + else if(in_square_brackets) + *(wpt++)= '!'; + else { + *(wpt++)= '\\'; + *(wpt++)= '!'; + } + break;case '^': + if(in_square_brackets) + *(wpt++)= '^'; + else + *(wpt++)= '\\'; + *(wpt++)= '^'; + break;case '$': + *(wpt++)= '\\'; + *(wpt++)= '$'; + break;case '\\': + backslash= 1; + *(wpt++)= '\\'; + is_constant= 0; + break;default: + *(wpt++)= *lpt; + } + } else { + backslash= 0; + *(wpt++)= *lpt; + } + lpt++; + } + *(wpt++)= '$'; + *wpt= 0; + return(1+(is_constant>0)); +} + + +/* @param flag bit0= do not augment relative structured search by xorriso->wdi + bit1= return 2 if bonked at start point by .. + (caller then aborts or retries without bit0) + bit2= eventually prepend wdx rather than wdi + @return <=0 error, 1= ok, 2= with bit1: relative pattern exceeds start point +*/ +int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag) +{ + int l,ret,i,count,bonked= 0,is_constant,is_still_relative= 0; + char *cpt,*npt,adr_part[2*SfileadrL],absolute_adr[2*SfileadrL],*adr_start,*wd; + + if(flag&4) + wd= xorriso->wdx; + else + wd= xorriso->wdi; +#ifndef Xorriso_with_regeX + + if(xorriso->search_mode==2 || + (xorriso->search_mode==3 && xorriso->structured_search==0)) { +no_regex_available:; + sprintf(xorriso->info_text,"%s : regular expressions not implemented", + xorriso->progname); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + +#endif /* ! Xorriso_with_regeX */ + + if(xorriso->search_mode>=2 && xorriso->search_mode<=4) { + if(xorriso->search_mode==3 || xorriso->search_mode==4) { + l= strlen(adr)+strlen(wd)+1; + if(l*2+2>sizeof(xorriso->reg_expr) || l*2+2>sizeof(adr_part)) { + sprintf(xorriso->info_text,"Search pattern too long"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + Xorriso_destroy_re(xorriso,0); + if(xorriso->structured_search && xorriso->search_mode==3) { + if(adr[0]!='/') + is_still_relative= 1; + if(is_still_relative && !(flag&1)) { + /* relative expression : prepend working directory */ + sprintf(absolute_adr,"%s/%s",wd,adr); + adr_start= absolute_adr; + xorriso->prepended_wd= 1; + is_still_relative= 0; + } else + adr_start= adr; + /* count slashes */; + cpt= adr_start; + while(*cpt=='/') + cpt++; + for(i= 0;1;i++) { + cpt= strchr(cpt,'/'); + if(cpt==NULL) + break; + while(*cpt=='/') + cpt++; + } + count= i+1; + +#ifdef Xorriso_with_regeX + xorriso->re= TSOB_FELD(regex_t,count); + if(xorriso->re==NULL) + return(-1); +#endif /* Xorriso_with_regeX */ + + xorriso->re_constants= TSOB_FELD(char *,count); + if(xorriso->re_constants==NULL) + return(-1); + for(i= 0;i<count;i++) + xorriso->re_constants[i]= NULL; + xorriso->re_count= count; + xorriso->re_fill= 0; + + /* loop over slash chunks*/; + cpt= adr_start; + xorriso->re_fill= 0; + while(*cpt=='/') + cpt++; + for(i= 0;i<count;i++) { + npt= strchr(cpt,'/'); + if(npt==NULL) { + if(strlen(cpt)>=sizeof(adr_part)) + return(-1); + strcpy(adr_part,cpt); + } else { + if(npt-cpt>=sizeof(adr_part)) + return(-1); + strncpy(adr_part,cpt,npt-cpt); + adr_part[npt-cpt]= 0; + } + + if(adr_part[0]==0) + goto next_adr_part; + if(adr_part[0]=='.' && adr_part[1]==0 && + (xorriso->re_fill>0 || i<count-1)) + goto next_adr_part; + if(adr_part[0]=='.' && adr_part[1]=='.' && adr_part[2]==0) { + /* delete previous part */ + if(xorriso->re_fill<=1) { + bonked= 1; + goto next_adr_part; + } + if(xorriso->re_constants[xorriso->re_fill-1]!=NULL) { + free(xorriso->re_constants[xorriso->re_fill-1]); + xorriso->re_constants[xorriso->re_fill-1]= NULL; + } else +#ifdef Xorriso_with_regeX + regfree(&(xorriso->re[xorriso->re_fill-1])); +#else /* Xorriso_with_regeX */ + ; +#endif /* ! Xorriso_with_regeX */ + (xorriso->re_fill)--; + goto next_adr_part; + } + if(strcmp(adr_part,"*")==0) { + adr_part[0]= 0; + ret= 2; + } else + ret= Xorriso__bourne_to_reg(adr_part,xorriso->reg_expr,0); + if(ret==2) { + if(Sregex_string(&(xorriso->re_constants[xorriso->re_fill]),adr_part,0) + <=0) + return(-1); + } else { + +#ifdef Xorriso_with_regeX + if(regcomp(&(xorriso->re[xorriso->re_fill]),xorriso->reg_expr,0)!=0) + goto cannot_compile; +#else /* Xorriso_with_regeX */ + if(!warned_of_regex) { + sprintf(xorriso->info_text, + "No wildcards get recognized besides single '*'"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",0); + warned_of_regex= 1; + } + if(Sregex_string(&(xorriso->re_constants[xorriso->re_fill]),adr_part,0) + <=0) + return(-1); +#endif /* ! Xorriso_with_regeX */ + + } + xorriso->re_fill++; +next_adr_part:; + if(i==count-1) + break; + cpt= npt+1; + while(*cpt=='/') + cpt++; + } + if(bonked) { + if(flag&2) + return(2); + sprintf(xorriso->info_text, "Your '..' bonked at the %s directory.", + is_still_relative ? "working" : "root"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE",0); + return(0); + } + + Xorriso__bourne_to_reg(adr_start,xorriso->reg_expr,0); /* just for show */ + + } else { + is_constant= 0; + if(strcmp(adr,"*")==0 || adr[0]==0) { + is_constant= 1; + } else if(xorriso->search_mode==3 || xorriso->search_mode==4) { + ret= Xorriso__bourne_to_reg(adr,xorriso->reg_expr,0); + is_constant= (ret==2); + } else { + if(strlen(adr)>=sizeof(xorriso->reg_expr)) + return(-1); + strcpy(xorriso->reg_expr,adr); + } + xorriso->re_count= 0; /* tells matcher that this is not structured */ + xorriso->re_constants= TSOB_FELD(char *,1); + if(xorriso->re_constants==NULL) + return(-1); + xorriso->re_constants[0]= NULL; + if(is_constant) { + if(strcmp(adr,"*")==0) { + if(Sregex_string(&(xorriso->re_constants[0]),"",0)<=0) + return(-1); + } else { + if(Sregex_string(&(xorriso->re_constants[0]),adr,0)<=0) + return(-1); + } + xorriso->re_fill= 1; + } else { +#ifdef Xorriso_with_regeX + xorriso->re= TSOB_FELD(regex_t,1); + if(xorriso->re==NULL) + return(-1); + if(regcomp(&(xorriso->re[0]),xorriso->reg_expr,0)!=0) { +cannot_compile:; + sprintf(xorriso->info_text, "Cannot compile regular expression : %s", + xorriso->reg_expr); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE",0); + return(0); + } +#else /* Xorriso_with_regeX */ + sprintf(xorriso->info_text, + "No wildcards get recognized besides single '*'"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",0); + Xorriso_info(xorriso,0); + if(Sregex_string(&(xorriso->re_constants[0]),adr,0)<=0) + return(-1); + xorriso->re_fill= 1; +#endif /* ! Xorriso_with_regeX */ + } + + } + } + return(1); +} + + +/* @return 0=match , else no match +*/ +int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at, + int flag) +/* + bit0= do not shortcut last component of to_match + bit2= retry beginning at failed last component +*/ +{ + int ret,i,re_start= 0,reg_nomatch= -1; + char *cpt,*npt,adr_part[SfileadrL],*mpt; + +#ifdef Xorriso_with_regeX + reg_nomatch= REG_NOMATCH; +#endif /* Xorriso_with_regeX */ + + *failed_at= 0; + if(!(xorriso->structured_search && xorriso->re_count>0)) { + if(xorriso->re_constants!=NULL) + if(xorriso->re_constants[0]!=NULL) { + if(xorriso->re_constants[0][0]==0) + return(0); + if(strcmp(xorriso->re_constants[0],to_match)!=0) + return(reg_nomatch); + return(0); + } +#ifdef Xorriso_with_regeX + ret= regexec(&(xorriso->re[0]),to_match,1,xorriso->match,0); +#else + ret= reg_nomatch; +#endif /* ! Xorriso_with_regeX */ + + return(ret); + } + + cpt= to_match; + while(*cpt=='/') + cpt++; + if(flag&4) + re_start= xorriso->re_failed_at; + if(re_start<0) + re_start= 0; + for(i= re_start;i<xorriso->re_fill;i++) { + *failed_at= i; + npt= strchr(cpt,'/'); + if(npt==NULL) { + if(i<xorriso->re_fill-1 && !(flag&1)) + return(reg_nomatch); /* this must be the last expression part */ + mpt= cpt; + } else { + strncpy(adr_part,cpt,npt-cpt); + adr_part[npt-cpt]= 0; + mpt= adr_part; + } + if(xorriso->re_constants[i]!=NULL) { + if(xorriso->re_constants[i][0]!=0) /* empty constant matches anything */ + if(strcmp(xorriso->re_constants[i],mpt)!=0) + return(reg_nomatch); + } else { + +#ifdef Xorriso_with_regeX + ret= regexec(&(xorriso->re[i]),mpt,1,xorriso->match,0); + if(ret!=0) + return(ret); +#else + return(reg_nomatch); +#endif /* ! Xorriso_with_regeX */ + + } + if(npt==NULL) { + if(i>=xorriso->re_fill-1) + return(0); /* MATCH */ + *failed_at= i+1; + return(reg_nomatch); + } + cpt= npt+1; + while(*cpt=='/') + cpt++; + } + *failed_at= xorriso->re_fill; + return(reg_nomatch); +} + + +/* @param flag bit0= simple readlink(): no normalization, no multi-hop +*/ +int Xorriso_resolve_link(struct XorrisO *xorriso, + char *link_path, char result_path[SfileadrL], int flag) +{ + ssize_t l; + struct stat stbuf; + int link_count= 0, ret, show_errno= 0; + char buf[SfileadrL], dirbuf[SfileadrL], *lpt, *spt, sfe[5*SfileadrL]; + static int link_limit= 100; + + if(!(flag&1)) + if(stat(link_path, &stbuf)==-1) + if(errno==ELOOP) { + show_errno= errno; + goto too_many_hops; + } + lpt= link_path; + while(1) { + l= readlink(lpt, buf, SfileadrL-1); + if(l==-1) { +handle_error:; + Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "Cannot obtain link target of : %s", + Text_shellsafe(link_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); +handle_abort:; + if(strcmp(lpt, link_path)!=0) { + sprintf(xorriso->info_text, + "Problem occured with intermediate path : %s", + Text_shellsafe(lpt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); + } + return(0); + } + buf[l]= 0; + if(l==0) { + Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "Empty link target with : %s", + Text_shellsafe(link_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + goto handle_abort; + } + + if(flag&1) { + strcpy(result_path, buf); + return(1); + } + + /* normalize relative to disk_path */ + if(Sfile_str(dirbuf, lpt, 0)<=0) + return(-1); + while(1) { + spt= strrchr(dirbuf,'/'); + if(spt!=NULL) { + *spt= 0; + if(*(spt+1)!=0) + break; + } else + break; + } + ret= Xorriso_normalize_img_path(xorriso, dirbuf, buf, result_path, 2|4); + if(ret<=0) + return(ret); + + if(lstat(result_path, &stbuf)==-1) { + lpt= result_path; + goto handle_error; + } + if(!S_ISLNK(stbuf.st_mode)) + break; + + lpt= result_path; + link_count++; + if(link_count>link_limit) { +too_many_hops:; + Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "Too many link hops with : %s", + Text_shellsafe(link_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, show_errno, + "FAILURE",0); + return(0); + } + } + return(1); +} + + +int Xorriso_status_result(struct XorrisO *xorriso, char *filter, FILE *fp, + int flag) +/* +bit1= do only report to fp +*/ +{ + int ret,l; + + if(filter!=NULL) + if(filter[0]=='-') { + l= strlen(filter); + if(strncmp(filter,xorriso->result_line,l)!=0) + return(2); + } + if(!(flag&2)) + Xorriso_result(xorriso,0); + if(fp!=NULL) { + ret= fwrite(xorriso->result_line,strlen(xorriso->result_line),1,fp); + if(ret<=0) + return(ret); + } + return(1); +} + + +int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag) +/* + bit0= do only report non-default settings + bit1= do only report to fp + bit2= report current -resume status even if bit0 is set, but only if valid + bit3= report readline history + bit4= report -resume options indirectly as + -options_from_file:${resume_state_file}_pos +*/ +{ + int is_default,no_defaults,i; + char *line, sfe[5*SfileadrL], mode[80], *form, *treatment; + static char channel_prefixes[4][4]= {".","R","I","M"}; + + no_defaults= flag&1; + line= xorriso->result_line; + + if(xorriso->no_rc) { + sprintf(line,"-no_rc\n"); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + is_default= 0; + if(xorriso->dialog) + sprintf(line,"-dialog on\n"); + else { + sprintf(line,"-dialog off\n"); + is_default= 1; + } + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->result_page_length==0 && xorriso->result_page_width==80); + sprintf(line,"-page %d %d\n", + (xorriso->result_page_length>=0?xorriso->result_page_length + :-xorriso->result_page_length), + xorriso->result_page_width); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->use_stdin==0); + sprintf(line,"-use_readline %s\n", (xorriso->use_stdin?"off":"on")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= !xorriso->packet_output; + sprintf(line,"-pkt_output %s\n",(xorriso->packet_output?"on":"off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + for(i=0;i<4;i++) { + is_default= (xorriso->logfile[i]!=0); + sprintf(line,"-logfile %s %s\n", + channel_prefixes[i],Text_shellsafe(xorriso->logfile[i],sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + is_default= (xorriso->errfile_log[0]==0); + sprintf(line,"-errfile_log %s\n",Text_shellsafe(xorriso->errfile_log,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->mark_text[0]==0); + sprintf(line,"-mark %s\n",Text_shellsafe(xorriso->mark_text,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->temp_mem_limit==16*1024*1024); + if((xorriso->temp_mem_limit/1024/1024)*1024*1024==xorriso->temp_mem_limit) + sprintf(line,"-temp_mem_limit %dm\n", xorriso->temp_mem_limit/1024/1024); + else + sprintf(line,"-temp_mem_limit %dk\n", xorriso->temp_mem_limit/1024); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + + sprintf(line,"-prog %s\n",Text_shellsafe(xorriso->progname,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + + if(xorriso->ban_stdio_write) { + sprintf(line,"-ban_stdio_write\n"); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + is_default= (xorriso->keep_boot_image==0 && xorriso->patch_isolinux_image==0); + form= "any"; + treatment= "discard"; + if(xorriso->patch_isolinux_image) { + form= "isolinux"; + treatment= "patch"; + } else if(xorriso->keep_boot_image) { + treatment= "keep"; + } + sprintf(line,"-boot_image %s %s\n", form, treatment); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + sprintf(line,"-cd %s\n", + (xorriso->wdi[0] ? Text_shellsafe(xorriso->wdi,sfe,0) : "'/'")); + Xorriso_status_result(xorriso,filter,fp,flag&2); + sprintf(line,"-cdx %s\n", + (xorriso->wdx[0] ? Text_shellsafe(xorriso->wdx,sfe,0) : "'/'")); + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->split_size==0); + strcpy(line,"-split_size "); + if(xorriso->split_size % (1024*1024) || xorriso->split_size==0) { + Sfile_off_t_text(line+strlen(line), xorriso->split_size, 0); + } else { + Sfile_off_t_text(line+strlen(line), xorriso->split_size / (1024*1024), 0); + strcat(line, "m"); + } + strcat(line, "\n"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->add_plainly==0); + sprintf(line,"-add_plainly %s\n", + (xorriso->add_plainly == 1 ? "unknown" : + xorriso->add_plainly == 2 ? "dashed" : + xorriso->add_plainly == 3 ? "any" : "none")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_iso_rr_pattern==1); + sprintf(line,"-iso_rr_pattern %s\n", + (xorriso->do_iso_rr_pattern == 1 ? "on" : + (xorriso->do_iso_rr_pattern == 2 ? "ls" : "off"))); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_disk_pattern==2); + sprintf(line,"-disk_pattern %s\n", + (xorriso->do_disk_pattern == 1 ? "on" : + (xorriso->do_disk_pattern == 2 ? "ls" : "off"))); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= xorriso->volid_default; + sprintf(line,"-volid %s\n",Text_shellsafe(xorriso->volid,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + if(is_default && xorriso->loaded_volid[0] && + strcmp(xorriso->loaded_volid, xorriso->volid)!=0 && !no_defaults) { + sprintf(line,"# loaded image effective -volid %s\n", + Text_shellsafe(xorriso->loaded_volid,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + is_default= (xorriso->publisher[0]==0); + sprintf(line,"-publisher %s\n",Text_shellsafe(xorriso->publisher,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_joliet==0); + sprintf(line,"-joliet %s\n", (xorriso->do_joliet == 1 ? "on" : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + if(xorriso->do_global_uid) { + sprintf(line,"-uid %lu\n", (unsigned long) xorriso->global_uid); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + if(xorriso->do_global_gid) { + sprintf(line,"-gid %lu\n", (unsigned long) xorriso->global_gid); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + is_default= !xorriso->allow_graft_points; + sprintf(line,"-pathspecs %s\n", xorriso->allow_graft_points ? "on" : "off"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_follow_pattern && (!xorriso->do_follow_param) + && xorriso->do_follow_mount && (!xorriso->do_follow_links) + && xorriso->follow_link_limit==100); + mode[0]= 0; + if(xorriso->do_follow_pattern && + !(xorriso->do_follow_links && xorriso->do_follow_mount)) + strcat(mode,":pattern"); + if(xorriso->do_follow_param && !(xorriso->do_follow_links)) + strcat(mode,":param"); + if(xorriso->do_follow_links) + strcat(mode,":link"); + if(xorriso->do_follow_mount) + strcat(mode,":mount"); + if(mode[0]==0) + strcpy(mode, ":off"); + sprintf(mode+strlen(mode), ":limit=%d", xorriso->follow_link_limit); + sprintf(line,"-follow %s\n", mode+1); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_overwrite==2); + sprintf(line,"-overwrite %s\n",(xorriso->do_overwrite == 1 ? "on" : + (xorriso->do_overwrite == 2 ? "nondir" : "off"))); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= !xorriso->do_reassure; + sprintf(line,"-reassure %s\n",(xorriso->do_reassure == 1 ? "on" : + (xorriso->do_reassure == 2 ? "tree" : "off"))); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= !xorriso->do_close; + sprintf(line,"-close %s\n",(xorriso->do_close ? "on" : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= !xorriso->do_dummy; + sprintf(line,"-dummy %s\n",(xorriso->do_dummy ? "on" : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->speed==0); + sprintf(line,"-speed %dkB/s\n", xorriso->speed); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->fs==4*512); + if((xorriso->fs/512)*512==xorriso->fs) + sprintf(line,"-fs %dm\n", xorriso->fs/512); + else + sprintf(line,"-fs %dk\n", xorriso->fs*2); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->padding==300*1024); + sprintf(line,"-padding %dk\n", xorriso->padding/1024); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (strcmp(xorriso->report_about_text,"UPDATE")==0); + sprintf(line,"-report_about %s\n",xorriso->report_about_text); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->session_logfile[0]==0); + sprintf(line,"-session_log %s\n", + Text_shellsafe(xorriso->session_logfile,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (strcmp(xorriso->return_with_text,"SORRY")==0 && + xorriso->return_with_value==32); + sprintf(line,"-return_with %s %d\n", + xorriso->return_with_text, xorriso->return_with_value); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (strcmp(xorriso->abort_on_text,"FATAL")==0); + sprintf(line,"-abort_on %s\n",xorriso->abort_on_text); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + if(xorriso->status_history_max!=Xorriso_status_history_maX || !no_defaults) { + sprintf(line,"-status_history_max %d\n",xorriso->status_history_max); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + +#ifdef Xorriso_with_readlinE + + if((flag&8) && xorriso->status_history_max>0) { + HIST_ENTRY **hl; + int hc,i; + + hl= history_list(); + if(hl!=NULL) { + for(hc= 0;hl[hc]!=NULL;hc++); + if(hc>0) + if(strcmp(hl[hc-1]->line,"-end")==0) + hc--; + if(hc>=xorriso->status_history_max) + i= hc-xorriso->status_history_max; + else + i= 0; + for(;i<hc;i++) { + sprintf(line,"-history %s\n",Text_shellsafe(hl[i]->line,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + } + } + +#endif /* Xorriso_with_readlinE */ + + if(strcmp(xorriso->indev,xorriso->outdev)==0) { + sprintf(line,"-dev %s\n", Text_shellsafe(xorriso->indev,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } else { + sprintf(line,"-indev %s\n", Text_shellsafe(xorriso->indev,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + sprintf(line,"-outdev %s\n", Text_shellsafe(xorriso->outdev,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + return(1); +} + + +/* @param flag bit2= this is a disk_pattern + @return <=0 failure , 1 pattern ok , 2 pattern needed prepended wd */ +int Xorriso_prepare_expansion_pattern(struct XorrisO *xorriso, char *pattern, + int flag) +{ + int ret, prepwd= 0; + + ret= Xorriso_prepare_regex(xorriso, pattern, 1|2|(flag&4)); + if(ret==2) { + ret= Xorriso_prepare_regex(xorriso, pattern, flag&4); + prepwd= 1; + } + if(ret<=0) { + sprintf(xorriso->info_text, + "Cannot compile pattern to regular expression: %s", pattern); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1+prepwd); +} + + +/* @param flag bit0= count results rather than storing them + bit1= unexpected change of number is a FATAL event + @return <=0 error , 1 is root (end processing) , + 2 is not root (go on processing) +*/ +int Xorriso_check_for_root_pattern(struct XorrisO *xorriso, + int *filec, char **filev, int count_limit, off_t *mem, int flag) +{ + if(xorriso->re_fill!=0) + return(2); + /* This is the empty pattern representing root */ + if(flag&1) { + (*filec)++; + (*mem)+= 8; + } else { + if(*filec >= count_limit) { + sprintf(xorriso->info_text, + "Number of matching files changed unexpectedly (> %d)", + count_limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (flag&2 ? "FATAL" : "WARNING"), 0); + return(flag&2 ? -1 : 0); + } + filev[*filec]= strdup("/"); + if(filev[*filec]==NULL) { + Xorriso_no_pattern_memory(xorriso, (off_t) 2, 0); + return(-1); + } + (*filec)++; + } + return(1); +} + + +/* @param flag bit0= prepend wd only if name does not begin by '/' + bit1= normalize image path + bit2= prepend wd (automatically done if wd[0]!=0) + bit3= (with bit1) this is an address in the disk world +*/ +int Xorriso_make_abs_adr(struct XorrisO *xorriso, char *wd, char *name, + char adr[], int flag) +{ + char norm_adr[SfileadrL]; + int ret; + + if((wd[0]!=0 || (flag&4)) && !((flag&1) && name[0]=='/')) { + if(strlen(wd)+1>=SfileadrL) + goto much_too_long; + strcpy(adr, wd); + if(name[0]) + if(Sfile_add_to_path(adr, name, 0)<=0) { +much_too_long:; + Xorriso_much_too_long(xorriso, (int) (strlen(adr)+strlen(name)+1), 2); + return(0); + } + } else { + if(strlen(name)+1>=SfileadrL) + goto much_too_long; + strcpy(adr, name); + } + if(flag&2) { + ret= Xorriso_normalize_img_path(xorriso, "", adr, norm_adr, + 1|2|((flag&8)>>1)); + if(ret<=0) + return(ret); + if(norm_adr[0]==0) + strcpy(norm_adr, "/"); + strcpy(adr, norm_adr); + } + return(1); +} + + +/* + @param result Bitfield indicationg type of mismatch + bit11= cannot open regular disk file + bit12= cannot open iso file + bit13= early eof of disk file + bit14= early eof of iso file + bit15= content bytes differ + @param flag bit0= mtimes of both file objects are equal + bit29= do not issue pacifier messages + bit31= do not issue result messages + @return >0 ok , <=0 error +*/ +int Xorriso_compare_2_contents(struct XorrisO *xorriso, char *common_adr, + char *disk_adr, off_t disk_size, + off_t offset, off_t bytes, + char *iso_adr, off_t iso_size, + int *result, int flag) +{ + int fd1= -1, ret, r1, r2, done, wanted, i, was_error= 0; + void *stream2= NULL; + off_t r1count= 0, r2count= 0, diffcount= 0, first_diff= -1; + char *respt, buf1[32*1024], buf2[32*1024], offset_text[80]; + + respt= xorriso->result_line; + + fd1= open(disk_adr, O_RDONLY); + if(fd1==-1) { + sprintf(respt, "- %s (DISK) : cannot open() : %s\n", + disk_adr, strerror(errno)); +cannot_address:; + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 2048; + return(0); + } + if(offset>0) + if(lseek(fd1, offset, SEEK_SET)==-1) { + sprintf(respt, "- %s (DISK) : cannot lseek(%.f) : %s\n", + disk_adr, (double) offset, strerror(errno)); + close(fd1); + goto cannot_address; + } + + ret= Xorriso_iso_file_open(xorriso, iso_adr, &stream2, 0); + if(ret<=0) { + sprintf(respt, "- %s (ISO) : cannot open() file in ISO image\n", iso_adr); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + close(fd1); + (*result)|= 4096; + return(0); + } + + done= 0; + while(!done) { + + wanted= sizeof(buf1); + if(r1count+offset+wanted>disk_size) + wanted= disk_size-r1count-offset; + if(r1count+wanted>bytes) + wanted= bytes-r1count; + r1= 0; + while(wanted>0) { + ret= read(fd1, buf1, wanted); + if(ret<=0) + break; + wanted-= ret; + r1+= ret; + } + + wanted= sizeof(buf2); + if(r2count+wanted>iso_size) + wanted= iso_size-r2count; +/* + if(r2count+wanted>bytes) + wanted= bytes-r2count; +*/ + if(wanted>0) + r2= Xorriso_iso_file_read(xorriso, stream2, buf2, wanted, 0); + else + r2= 0; + + if(r1<0 || r2<0) + was_error= 1; + + if(r1<=0 && r2<=0) + break; + if(r1<=0) { + if(r1<0) + r1= 0; + if(disk_size > r1count + r1 + offset) { + sprintf(respt, "- %s (DISK) : early EOF after %.f bytes\n", + disk_adr, (double) r1count); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 8196; + } + (*result)|= (1<<15); + } + r1count+= r1; + if(r2<=0 || r2<r1) { + if(r2<0) + r2= 0; + if(iso_size > r2count + r2) { + sprintf(respt, "- %s (ISO) : early EOF after %.f bytes\n", + iso_adr, (double) r2count); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= (1<<14); + } + (*result)|= (1<<15); + done= 1; + } + if(r2>r1) { + if(disk_size > r1count + r1 + offset) { + sprintf(respt, "- %s (DISK) : early EOF after %.f bytes\n", + disk_adr, (double) r1count); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 8196; + } + (*result)|= (1<<15); + done= 1; + } + r2count+= r2; + if(r1>r2) + r1= r2; + for(i= 0; i<r1; i++) { + if(buf1[i]!=buf2[i]) { + if(first_diff<0) + first_diff= i; + diffcount++; + } + } + if(!(flag&(1<<29))) { + xorriso->pacifier_count+= r1; + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 0); + } + } + if(diffcount>0 || r1count!=r2count) { + if(first_diff<0) + first_diff= (r1count>r2count ? r2count : r1count); + offset_text[0]= 0; + if(offset>0) + sprintf(offset_text, "%.f+", (double) offset); + sprintf(respt, "%s %s : differs by at least %.f bytes. First at %s%.f\n", + common_adr, (flag&1 ? "CONTENT": "content"), + (double) (diffcount + abs(r1count-r2count)), + offset_text, (double) first_diff); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= (1<<15); + } + if(fd1!=-1) + close(fd1); + Xorriso_iso_file_close(xorriso, &stream2, 0); + if(was_error) + return(-1); + return(1); +} + + +/* + @param result Bitfield indicationg type of mismatch + bit0= disk_adr not existing + bit1= iso_adr not existing + bit2= access permissions + bit3= file type + bit4= user id + bit5= group id + bit6= minor, major with device file + bit7= size + bit8= mtime + bit9= atime + bit10= ctime + bit11= cannot open regular disk file + bit12= cannot open iso file + bit13= early eof of disk file + bit14= early eof of iso file + bit15= content bytes differ + bit16= symbolic link on disk pointing to dir, dir in iso + bit17= file chunks detected and compared + bit18= incomplete chunk collection encountered + @param flag bit0= compare atime + bit1= compare ctime + bit2= check only existence of both file objects + count one or both missing as "difference" + bit28= examine eventual disk_path link target rather than link + bit29= do not issue pacifier messages + bit30= omit adr_common_tail in report messages + bit31= do not issue result messages + @return 1=files match properly , 0=difference detected , -1=error +*/ +int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr, + char *iso_adr, char *adr_common_tail, + int *result, int flag) +{ + struct stat s1, s2, stbuf; + int ret, missing= 0, is_split= 0, i, was_error= 0; + char *respt; + char a[5*SfileadrL], sfe[5*SfileadrL]; + char ttx1[40], ttx2[40]; + struct SplitparT *split_parts= NULL; + int split_count= 0; + + char part_path[SfileadrL], *part_name; + int partno, total_parts= 0; + off_t offset, bytes, total_bytes; + + *result= 0; + respt= xorriso->result_line; + if(flag&(1<<28)) + ret= stat(disk_adr, &s1); + else + ret= lstat(disk_adr, &s1); + if(ret==-1) { + sprintf(respt , "? %s (DISK) : cannot lstat() : %s\n", + Text_shellsafe(disk_adr, sfe, 0), strerror(errno)); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + missing= 1; + (*result)|= 1; + } + strcpy(a, Ftypetxt(s1.st_mode, 1)); + strcat(a, " "); + if(adr_common_tail[0]) + strcat(a, Text_shellsafe(adr_common_tail, sfe, 0)); + else + strcat(a, "'.'"); + strcat(a, " :"); + if(flag&(1<<30)) + a[0]= 0; + + ret= Xorriso_iso_lstat(xorriso, iso_adr, &s2, 0); + if(ret==-1) { + sprintf(respt, "? %s (ISO) : cannot find this file in ISO image\n", + Text_shellsafe(iso_adr, sfe, 0)); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + missing= 1; + (*result)|= 2; + } + + if((flag&4)||missing) + {ret= !missing; goto ex;} + + + /* Splitfile parts */ + if((S_ISREG(s1.st_mode) || S_ISBLK(s1.st_mode)) && S_ISDIR(s2.st_mode)) { + is_split= Xorriso_identify_split(xorriso, iso_adr, NULL, &split_parts, + &split_count, &s2, 0); + if(is_split>0) + (*result)|= (1<<17); + else + is_split= 0; + } + + /* Attributes */ + if(s1.st_mode != s2.st_mode) { + if((s1.st_mode&~S_IFMT)!=(s2.st_mode&~S_IFMT)) { + sprintf(respt, "%s st_mode : %7.7o <> %7.7o\n", + a, s1.st_mode, s2.st_mode); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 4; + } + if((s1.st_mode&S_IFMT)!=(s2.st_mode&S_IFMT)) { + sprintf(respt, "%s type : %s <> %s\n", + a, Ftypetxt(s1.st_mode, 0), Ftypetxt(s2.st_mode, 0)); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 8; + if((s1.st_mode&S_IFMT) == S_IFLNK) { + /* check whether link target type matches */ + ret= stat(disk_adr, &stbuf); + if(ret!=-1) + if(S_ISDIR(stbuf.st_mode) && S_ISDIR(s2.st_mode)) + (*result)|= (1<<16); + } + } + } + if(s1.st_uid != s2.st_uid) { + sprintf(respt, "%s st_uid : %d <> %d\n", a, s1.st_uid, s2.st_uid); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 16; + } + if(s1.st_gid != s2.st_gid) { + sprintf(respt, "%s st_gid : %d <> %d\n", a, s1.st_gid, s2.st_gid); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 32; + } + if((S_ISCHR(s1.st_mode) && S_ISCHR(s2.st_mode)) || + (S_ISBLK(s1.st_mode) && S_ISBLK(s2.st_mode))) { + if(s1.st_rdev != s2.st_rdev) { + sprintf(respt, "%s %s st_rdev : %lu <> %lu\n", a, + (S_ISCHR(s1.st_mode) ? "S_IFCHR" : "S_IFBLK"), + (unsigned long) s1.st_rdev, (unsigned long) s1.st_rdev); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 64; + } + } + if(S_ISREG(s2.st_mode) && s1.st_size != s2.st_size) { + sprintf(respt, "%s st_size : %.f <> %.f diff= %.f\n", + a, (double) s1.st_size, (double) s2.st_size, + ((double) s1.st_size) - (double) s2.st_size); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 128; + } + if(s1.st_mtime != s2.st_mtime) { + sprintf(respt, "%s st_mtime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_mtime, ttx1, 0), + Ftimetxt(s2.st_mtime, ttx2, 0), + ((double) s1.st_mtime) - (double) s2.st_mtime); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 256; + } + if(flag&1) { + if(s1.st_atime != s2.st_atime) { + sprintf(respt, "%s st_atime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_atime, ttx1, 0), + Ftimetxt(s2.st_atime, ttx2, 0), + ((double) s1.st_atime) - (double) s2.st_atime); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 512; + } + } + if(flag&2) { + if(s1.st_ctime != s2.st_ctime) { + sprintf(respt, "%s st_ctime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_ctime, ttx1, 0), + Ftimetxt(s2.st_ctime, ttx2, 0), + ((double) s1.st_ctime) - (double) s2.st_ctime); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 1024; + } + } + if(S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)) { + /* Content */ + if(is_split) { + for(i= 0; i<split_count; i++) { + Splitparts_get(split_parts, i, &part_name, &partno, &total_parts, + &offset, &bytes, &total_bytes, 0); + strcpy(part_path, iso_adr); + if(Sfile_add_to_path(part_path, part_name, 0)<=0) { + Xorriso_much_too_long(xorriso, strlen(iso_adr)+strlen(part_path)+1, + 2); + {ret= -1; goto ex;} + } + ret= Xorriso_iso_lstat(xorriso, part_path, &stbuf, 0); + if(ret==-1) + continue; + ret= Xorriso_compare_2_contents(xorriso, a, disk_adr, s1.st_size, + offset, bytes, + part_path, stbuf.st_size, result, + (s1.st_mtime==s2.st_mtime) | (flag&((1<<29)|(1<<31)))); + if(ret<0) + was_error= 1; + } + if(total_parts>0 && split_count!=total_parts) { + sprintf(xorriso->info_text, + "- %s/* (ISO) : Not all split parts present (%d of %d)\n", + iso_adr, split_count, total_parts); + if(!(flag&(1<<31))) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 1); + (*result)|= 1<<18; + } + } else { + ret= Xorriso_compare_2_contents(xorriso, a, disk_adr, s1.st_size, + (off_t) 0, s1.st_size, + iso_adr, s2.st_size, result, + (s1.st_mtime==s2.st_mtime) | (flag&((1<<29)|(1<<31)))); + if(ret<0) + was_error= 1; + } + + } + if(was_error) + ret= -1; + else + ret= (((*result)&~((1<<17)|(1<<18)))==0); +ex:; + if(split_parts!=NULL) + Splitparts_destroy(&split_parts, split_count, 0); + return(ret); +} + + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit0= update rather than compare + bit1= find[ix] is in recursion + @return <=0 error, 1= ok , 2= iso_path was deleted + 3=ok, do not dive into directory (e.g. because it is a split file) +*/ +int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, + char *iso_path, char *iso_prefix, char *disk_prefix, + int flag) +{ + int ret, result, uret, follow_links, deleted= 0; + char disk_path[SfileadrL], adrc[SfileadrL]; + + if(strncmp(iso_path, iso_prefix, strlen(iso_prefix))!=0) + return(-1); + if(strlen(disk_prefix)+strlen(iso_path)-strlen(iso_prefix)>=SfileadrL) + return(-1); + if(iso_path[strlen(iso_prefix)]=='/') + strcpy(adrc, iso_path+strlen(iso_prefix)+1); + else + strcpy(adrc, iso_path+strlen(iso_prefix)); + + ret= Xorriso_make_abs_adr(xorriso, disk_prefix, adrc, disk_path, 4|8); + if(ret<=0) + return(ret); + + /* >>> compare exclusions against disk_path resp. leaf name */; + /* >>> eventually return 3 */ + + follow_links= (xorriso->do_follow_links || + (xorriso->do_follow_param && !(flag&2))) <<28; + ret= Xorriso_compare_2_files(xorriso, disk_path, iso_path, adrc, &result, + 2|follow_links|((!(flag&1))<<29)|((flag&1)<<31)); + if(ret<xorriso->find_compare_result) + xorriso->find_compare_result= ret; + if(flag&1) { + if(ret<=0) { + if(ret<0) + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + return(ret); + uret= Xorriso_update_interpreter(xorriso, boss_iter, result, + disk_path, iso_path, (flag&2)<<1); + if(uret<=0) + ret= 0; + if(uret==2) + deleted= 1; + } + } + if(ret<0) + return(ret); + if(deleted) + return(2); + if(result&(1<<17)) + return(3); + return(ret); +} + + +/* @param flag bit0= count result rather than storing it + bit1= unexpected change of number is a FATAL event +*/ +int Xorriso_register_matched_adr(struct XorrisO *xorriso, + char *adr, int count_limit, + int *filec, char **filev, off_t *mem, int flag) +{ + int l; + + if(flag&1) { + (*filec)++; + l= strlen(adr)+1; + (*mem)+= sizeof(char *)+l; + if(l % sizeof(char *)) + (*mem)+= sizeof(char *)-(l % sizeof(char *)); + } else { + if(*filec >= count_limit) { + sprintf(xorriso->info_text, + "Number of matching files changed unexpectedly (> %d)", + count_limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (flag&2 ? "FATAL" : "WARNING"), 0); + return(flag&2 ? -1 : 0); + } + filev[*filec]= strdup(adr); + if(filev[*filec]==NULL) { + Xorriso_no_pattern_memory(xorriso, (off_t) (strlen(adr)+1), 0); + return(-1); + } + (*filec)++; + } + return(1); +} + + +/* @param flag bit0= count results rather than storing them + bit1= this is a recursion + bit2= prepend wd (automatically done if wd[0]!=0) + @return <=0 error , 1 ok , 2 could not open directory +*/ +int Xorriso_obtain_pattern_files_x( + struct XorrisO *xorriso, char *wd, char *dir_adr, + int *filec, char **filev, int count_limit, off_t *mem, + int *dive_count, int flag) +{ + int ret, failed_at, follow_mount, follow_links; + struct DirseQ *dirseq= NULL; + struct stat stbuf; + dev_t dir_dev; + char *path; + +#ifdef Xorriso_fat_local_meM + char adr[SfileadrL], name[SfileadrL], path_data[SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *adr= NULL, *name= NULL, *path_data= NULL; + + adr= malloc(SfileadrL); + name= malloc(SfileadrL); + path_data= malloc(SfileadrL); + if(adr==NULL || name==NULL || path_data==NULL) { + Xorriso_no_malloc_memory(xorriso, &adr, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ + + follow_mount= (xorriso->do_follow_mount || xorriso->do_follow_pattern); + follow_links= (xorriso->do_follow_links || xorriso->do_follow_pattern); + if(!(flag&2)) + *dive_count= 0; + else + (*dive_count)++; + + ret= Xorriso_check_for_root_pattern(xorriso, filec, filev, count_limit, + mem, flag&1); + if(ret!=2) + goto ex; + + if(lstat(dir_adr, &stbuf)==-1) + {ret= 2; goto ex;} + dir_dev= stbuf.st_dev; + if(S_ISLNK(stbuf.st_mode)) { + if(stat(dir_adr, &stbuf)==-1) + {ret= 2; goto ex;} + if(dir_dev != stbuf.st_dev && !follow_mount) + {ret= 2; goto ex;} + } + ret= Dirseq_new(&dirseq, dir_adr, 1); + if(ret<0) { + sprintf(xorriso->info_text, "Cannot obtain disk directory iterator"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + if(ret==0) + {ret= 2; goto ex;} + + while(1) { + ret= Dirseq_next_adr(dirseq,name,0); + if(ret==0) + break; + if(ret<0) { + sprintf(xorriso->info_text,"Failed to obtain next directory entry"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + + ret= Xorriso_make_abs_adr(xorriso, wd, name, adr, flag&4); + if(ret<=0) + goto ex; + + ret= Xorriso_regexec(xorriso, adr, &failed_at, 1); + if(ret>0) { /* no match */ + if(failed_at <= *dive_count) /* no hope for a match */ + continue; + path= adr; + if(adr[0]!='/') { + path= path_data; + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, adr, path, 1|4); + if(ret<=0) + goto ex; + } + + if(follow_links) + ret= stat(path,&stbuf); + else + ret= lstat(path,&stbuf); + if(ret==-1) + continue; + if(!S_ISDIR(stbuf.st_mode)) + continue; + if(dir_dev != stbuf.st_dev && !follow_mount) + continue; + + /* dive deeper */ + ret= Xorriso_obtain_pattern_files_x(xorriso, adr, path, + filec, filev, count_limit, mem, dive_count, flag|2); + if(ret<=0) + goto ex; + } else { + ret= Xorriso_register_matched_adr(xorriso, adr, count_limit, + filec, filev, mem, flag&1); + if(ret<0) + goto ex; + if(ret==0) + break; + } + } + ret= 1; +ex:; + +#ifndef Xorriso_fat_local_meM + if(adr!=NULL) + free(adr); + if(name!=NULL) + free(name); + if(path_data!=NULL) + free(path_data); +#endif /* ! Xorriso_fat_local_meM */ + + Dirseq_destroy(&dirseq,0); + if(flag&2) + (*dive_count)--; + return(ret); +} + + +int Xorriso_eval_nonmatch(struct XorrisO *xorriso, char *pattern, + int *nonconst_mismatches, off_t *mem, int flag) +{ + int k,l; + + /* Is this a constant pattern ? */ + for(k= 0; k<xorriso->re_fill; k++) { + if(xorriso->re_constants[k]==NULL) + break; + if(xorriso->re_constants[k][0]==0) + break; + } + if(k<xorriso->re_fill) + (*nonconst_mismatches)++; /* it is not */ + + l= strlen(pattern)+1; + (*mem)+= sizeof(char *)+l; + if(l % sizeof(char *)) + (*mem)+= sizeof(char *)-(l % sizeof(char *)); + return(1); +} + + +/* @param flag bit0= a match count !=1 is a SORRY event + bit1= a match count !=1 is a FAILURE event +*/ +int Xorriso_check_matchcount(struct XorrisO *xorriso, + int count, int nonconst_mismatches, int num_patterns, + char **patterns, int flag) +{ + char sfe[5*SfileadrL]; + + if((flag&1) && (count!=1 || nonconst_mismatches)){ + if(count-nonconst_mismatches>0) + sprintf(xorriso->info_text, + "Pattern match with more than one file object"); + else + sprintf(xorriso->info_text, "No pattern match with any file object"); + if(num_patterns==1) + sprintf(xorriso->info_text+strlen(xorriso->info_text), ": %s", + Text_shellsafe(patterns[0], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (flag&2 ? "FAILURE" : "SORRY"), 0); + return(0); + } + return(1); +} + + +int Xorriso_no_pattern_memory(struct XorrisO *xorriso, off_t mem, int flag) +{ + char mem_text[80]; + + Sfile_scale((double) mem, mem_text,5,1e4,1); + sprintf(xorriso->info_text, + "Cannot allocate enough memory (%s) for pattern expansion", + mem_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(1); +} + + +int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free, int flag) +{ + if(to_free!=NULL) + if(*to_free!=NULL) { + /* Eventual memory sacrifice to get on going */ + free(*to_free); + *to_free= NULL; + } + sprintf(xorriso->info_text, "Out of virtual memory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "ABORT", 0); + return(1); +} + + +int Xorriso_alloc_pattern_mem(struct XorrisO *xorriso, off_t mem, + int count, char ***filev, int flag) +{ + char mem_text[80], limit_text[80]; + + Sfile_scale((double) mem, mem_text,5,1e4,0); + sprintf(xorriso->info_text, + "Temporary memory needed for pattern expansion : %s", mem_text); + if(!(flag&1)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + if(mem > xorriso->temp_mem_limit) { + Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1); + sprintf(xorriso->info_text, + "List of matching file addresses exceeds -temp_mem_limit (%s > %s)", + mem_text, limit_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + + (*filev)= (char **) calloc(count, sizeof(char *)); + if(*filev==NULL) { + Xorriso_no_pattern_memory(xorriso, mem, 0); + return(-1); + } + return(1); +} + + +/* @param flag bit0= a match count !=1 is a FAILURE event + bit1= with bit0 tolerate 0 matches if pattern is a constant +*/ +int Xorriso_expand_disk_pattern(struct XorrisO *xorriso, + int num_patterns, char **patterns, int extra_filec, + int *filec, char ***filev, off_t *mem, int flag) +{ + int ret, count= 0, abs_adr= 0, i, was_count, was_filec; + int nonconst_mismatches= 0, dive_count= 0; + char sfe[5*SfileadrL], dir_adr[SfileadrL]; + + *filec= 0; + *filev= NULL; + + xorriso->search_mode= 3; + xorriso->structured_search= 1; + + for(i= 0; i<num_patterns; i++) { + + ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 4); + if(ret<=0) + return(ret); + if(ret==2) + abs_adr= 4; + + if(patterns[i][0]=='/' || abs_adr) { + strcpy(dir_adr, "/"); + abs_adr= 4; + } else { + strcpy(dir_adr, xorriso->wdx); + if(dir_adr[0]==0) + strcpy(dir_adr, "/"); + ret= Sfile_type(dir_adr, 1|4); + if(ret!=2) { + Xorriso_msgs_submit(xorriso, 0, dir_adr, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Address set by -cdx is not a directory: %s", + Text_shellsafe(dir_adr, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + + /* count the matches */ + was_count= count; + ret= Xorriso_obtain_pattern_files_x(xorriso, "", dir_adr, &count, NULL, 0, + mem, &dive_count, 1 | abs_adr); + if(ret<=0) + goto ex; + if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1) { + count++; + ret= Xorriso_eval_nonmatch(xorriso, patterns[i], + &nonconst_mismatches, mem, 0); + if(ret<=0) + goto ex; + } + } + + ret= Xorriso_check_matchcount(xorriso, count, nonconst_mismatches, + num_patterns, patterns, (flag&1)|2); + if(ret<=0) + goto ex; + + count+= extra_filec; + mem+= extra_filec*sizeof(char *); + + if(count<=0) + {ret= 0; goto ex;} + + ret= Xorriso_alloc_pattern_mem(xorriso, *mem, count, filev, 0); + if(ret<=0) + goto ex; + + /* now store addresses */ + for(i= 0; i<num_patterns; i++) { + + ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 4); + if(ret<=0) + return(ret); + + if(patterns[i][0]=='/' || abs_adr) { + strcpy(dir_adr, "/"); + abs_adr= 4; + } else + strcpy(dir_adr, xorriso->wdx); + + was_filec= *filec; + ret= Xorriso_obtain_pattern_files_x(xorriso, "", dir_adr, filec, *filev, + count, mem, &dive_count, abs_adr); + if(ret<=0) + goto ex; + + if(was_filec == *filec && strcmp(patterns[i],"*")!=0) { + (*filev)[*filec]= strdup(patterns[i]); + if((*filev)[*filec]==NULL) { + (*mem)= strlen(patterns[i])+1; + Xorriso_no_pattern_memory(xorriso, *mem, 0); + ret= -1; goto ex; + } + (*filec)++; + } + } + + ret= 1; +ex:; + if(ret<=0) { + if(filev!=NULL) + Sfile_destroy_argv(&count, filev, 0); + *filec= 0; + } + return(ret); +} + + +/* @param flag bit0= command without pattern capability + bit1= disk_pattern rather than iso_rr_pattern +*/ +int Xorriso_warn_of_wildcards(struct XorrisO *xorriso, char *path, int flag) +{ + if(strchr(path,'*')!=NULL || strchr(path,'?')!=NULL || + strchr(path,'[')!=NULL) { + if(flag&1) { + sprintf(xorriso->info_text, + "Pattern expansion of wildcards \"*?[\" does not apply to this command"); + } else { + sprintf(xorriso->info_text, + "Pattern expansion of wildcards \"*?[\" is disabled by command %s", + (flag&2) ? "-disk_pattern" : "-iso_rr_pattern"); + } + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(1); + } + return(0); +} + + +/* @param flag bit0= do not warn of wildcards + bit1= these are disk_paths +*/ +int Xorriso_end_idx(struct XorrisO *xorriso, + int argc, char **argv, int idx, int flag) +{ + int i, warned= 0; + + for(i= idx; i<argc; i++) { + if(strcmp(argv[i], "--")==0) + break; + if(!((flag&1) || warned)) + warned= Xorriso_warn_of_wildcards(xorriso, argv[i], flag&2); + } + return(i); +} + + +/* Returns a vector of strings which belong to an open ended arg list. + If expansion is enabled, the vector might be allocated, else it is + a pointer into the argv input vector. + Thus the release of that memory is an expert task to be done by this + function only. Use bit8 for that. Wiith bit8 parameter argc MUST be the + same value as with the call which might have allocated memory. + @param xorriso The environment object + @param argc Length of argv + @param argv The vector with arguments, eventual "--" and then eventual + unrelated words + @param idx Start index in argv of the argument list + @param optc Length of the effective possibly expanded option vector + @param optv The option vector. Maybe a pointer into argv or maybe + an own allocated vector. + @param flag bit0= do not warn of wildcards + bit1= these are disk_paths + bit2= never expand wildcards + bit3= do not expand last argument + bit4= ignore last argument + bit5= demand exactly one match + bit6= with bit allow 0 matches if pattern is a constant + bit8= free the eventually allocated sub_vector +*/ +int Xorriso_opt_args(struct XorrisO *xorriso, char *cmd, + int argc, char **argv, int idx, + int *end_idx, int *optc, char ***optv, int flag) +{ + int i, do_expand, nump, was_empty= 0, filec= 0, ret; + char **filev= NULL, **patterns= NULL; + off_t mem= 0; + + if(flag&2) + do_expand= xorriso->do_disk_pattern==1 && !(flag&4); + else + do_expand= xorriso->do_iso_rr_pattern==1 && !(flag&4); + if(flag&256) { + if(*optv<argv || *optv>=argv+argc) + Sfile_destroy_argv(optc, optv, 0); + return(1); + } + if(idx>=argc) { + *end_idx= argc; + *optc= 0; + *optv= NULL; + sprintf(xorriso->info_text, "%s : Not enough arguments given", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + *end_idx= Xorriso_end_idx(xorriso, argc, argv, idx, (flag&1) || do_expand); + if(*end_idx<0) + return(*end_idx); + if((flag&16) && (*end_idx)>idx) + (*end_idx)--; + *optc= *end_idx - idx; + *optv= argv+idx; + if(*optc<=0 || !do_expand) + return(1); + patterns= calloc(*optc, sizeof(char *)); + if(patterns==NULL) { +no_memory:; + sprintf(xorriso->info_text, + "%s : Cannot allocate enough memory for pattern expansion", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + nump= 0; + if(flag&8) { + was_empty= 1; + mem+= strlen(argv[idx + *optc - 1])+1+sizeof(char *); + } + for(i= 0; i<*optc-!!(flag&8); i++) { + if(argv[i + idx][0]==0) { + was_empty++; + mem+= sizeof(char *); /* as upper limit for size of an empty string */ + continue; + } + patterns[nump++]= argv[i + idx]; + } + if(nump<=0) { /* Only empty texts. May the caller get happy with them. */ + free(patterns); + return(1); + } + if(flag&2) + ret= Xorriso_expand_disk_pattern(xorriso, nump, patterns, was_empty, + &filec, &filev, &mem, (flag>>5)&3); + else + ret= Xorriso_expand_pattern(xorriso, nump, patterns, was_empty, + &filec, &filev, &mem, (flag>>5)&3); + if(ret<=0) + {ret= 0; goto ex;} + for(i= 0; i<was_empty; i++) { + if(i==was_empty-1 && (flag&8)) + filev[filec++]= strdup(argv[idx + *optc - 1]); + else + filev[filec++]= strdup(""); + if(filev[filec-1]==NULL) + goto no_memory; + } + +#ifdef Xorriso_verbous_pattern_expansioN +{ int l; + sprintf(xorriso->info_text, "Pattern expansion yields %d items:", filec); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + l= 0; + xorriso->info_text[0]= 0; + for(i= 0; i<filec; i++) { + l= strlen(xorriso->info_text); + if(l>0 && l+1+strlen(filev[i])>60) { + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + xorriso->info_text[0]= 0; + l= 0; + } + sprintf(xorriso->info_text+l, " %s", filev[i]); + } + l= strlen(xorriso->info_text); + if(l>0) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); +} +#endif /* Xorriso_verbous_pattern_expansioN */ + + ret= 1; +ex:; + if(ret<=0) { + if(patterns!=NULL) + free((char *) patterns); + Sfile_destroy_argv(&filec, &filev, 0); + } else { + *optc= filec; + *optv= filev; + } + return(ret); +} + + +int Xorriso_get_problem_status(struct XorrisO *xorriso, char severity[80], + int flag) +{ + strcpy(severity, xorriso->problem_status_text); + return(xorriso->problem_status); +} + + +int Xorriso_set_problem_status(struct XorrisO *xorriso, char *severity, + int flag) +{ + char *sev_text= "ALL"; + int sev, ret; + + if(severity[0]) + sev_text= severity; + ret= Xorriso__text_to_sev(sev_text, &sev, 0); + if(ret<=0) + return(0); + xorriso->problem_status= sev; + strcpy(xorriso->problem_status_text, sev_text); + if(sev > xorriso->eternal_problem_status) { + xorriso->eternal_problem_status= sev; + strcpy(xorriso->eternal_problem_status_text, sev_text); + } + return(1); +} + + +/* @param flag bit0-7= purpose + 0= ERRFILE + 1= mark line (only to be put out if enabled) +*/ +int Xorriso_process_errfile(struct XorrisO *xorriso, + int error_code, char msg_text[], int os_errno, + int flag) +{ + char ttx[41]; + int purpose; + + if(strlen(msg_text)>SfileadrL) + return(-1); + + purpose= flag&255; + if(purpose==1 && !(xorriso->errfile_mode&1)) + return(2); + if(xorriso->errfile_fp!=NULL) { + if(purpose==1) + fprintf(xorriso->errfile_fp, "----------------- %s %s\n", + msg_text, Ftimetxt(time(0), ttx, 1)); + else + fprintf(xorriso->errfile_fp, "%s\n", msg_text); + fflush(xorriso->errfile_fp); + return(1); + } + if(xorriso->errfile_log[0]==0) + return(1); + if(strcmp(xorriso->errfile_log, "-")==0 || + strcmp(xorriso->errfile_log, "-R")==0) { + if(purpose==1) + sprintf(xorriso->result_line, "----------------- %s %s\n", + msg_text, Ftimetxt(time(0), ttx, 1)); + else + sprintf(xorriso->result_line, "%s\n", msg_text); + Xorriso_result(xorriso, 1); + return(1); + } + if(strcmp(xorriso->errfile_log, "-I")==0) { + if(purpose==1) + sprintf(xorriso->info_text, "ERRFILE_MARK=%s %s\n", + msg_text, Ftimetxt(time(0), ttx, 1)); + else + sprintf(xorriso->info_text, "ERRFILE=%s", msg_text); + Xorriso_info(xorriso, 0); + return(1); + } + return(2); +} + + +/* Note: It is ok to submit xorriso->info_text as msg_text here. */ +/* flag: + bit0= for Xorriso_info() : use pager (as with result) + bit1= for Xorriso_info() : permission to suppress output + bit2..5= name prefix + 0="xorriso" + 1="libisofs" + 2="libburn" + 3="libisoburn" + else: "" +*/ +int Xorriso_msgs_submit(struct XorrisO *xorriso, + int error_code, char msg_text[], int os_errno, + char severity[], int flag) +{ + int ret, lt, li, sev, i; + char *sev_text= "FATAL", prefix[80]; + static char pfx_list[20][16]= { + "xorriso : ", "libisofs: ", "libburn : ", "libisoburn: ", + "", "", "", "", "", "", "", "", "", "", "", "" }; + + if(strcmp(severity, "ERRFILE")==0) + Xorriso_process_errfile(xorriso, error_code, msg_text, os_errno, 0); + + /* Set problem status */ + ret= Xorriso__text_to_sev(severity, &sev, 0); + if(ret<=0) + Xorriso__text_to_sev(sev_text, &sev, 0); + else + sev_text= severity; + if(xorriso->problem_status<sev) { + xorriso->problem_status= sev; + strcpy(xorriso->problem_status_text, sev_text); + } + if(xorriso->eternal_problem_status<sev) { + xorriso->eternal_problem_status= sev; + strcpy(xorriso->eternal_problem_status_text, sev_text); + } + + /* Report problem event */ + if(sev<xorriso->report_about_severity && sev<xorriso->abort_on_severity) + return(2); + sprintf(prefix,"%s%s : ", pfx_list[(flag>>2)&15], sev_text); + li= strlen(prefix); + lt= strlen(msg_text); + if(lt>sizeof(xorriso->info_text)-li-2) + lt= sizeof(xorriso->info_text)-li-2; + if(msg_text==xorriso->info_text) { + for(i= lt; i>=0; i--) + msg_text[i+li]= msg_text[i]; + for(i=0; i<li; i++) + msg_text[i]= prefix[i]; + } else { + strcpy(xorriso->info_text, prefix); + strncpy(xorriso->info_text+li, msg_text, lt); + } + xorriso->info_text[li+lt]= '\n'; + xorriso->info_text[li+lt+1]= 0; + Xorriso_info(xorriso,4|(flag&3)); + if(os_errno>0) { + sprintf(xorriso->info_text, "%ssys : %s\n", + pfx_list[(flag>>2)&15], strerror(os_errno)); + Xorriso_info(xorriso,4|(flag&3)); + } + return(1); +} + + +/** + @param flag bit0= do not issue own event messages + bit1= take xorriso->request_to_abort as reason for abort + @return Gives the advice: + 2= pardon was given, go on + 1= no problem, go on + 0= function failed but xorriso would not abort, go on + <0= do abort + -1 = due to problem_status + -2 = due to xorriso->request_to_abort +*/ +int Xorriso_eval_problem_status(struct XorrisO *xorriso, int ret, int flag) +{ + static int sev= 0; + if(sev==0) + Xorriso__text_to_sev("SORRY", &sev, 0); + + if((flag&2) && xorriso->request_to_abort) + return(-2); + + Xorriso_process_msg_queues(xorriso, 0); + if(ret>0 && xorriso->problem_status <= 0) + return(1); + + if(xorriso->problem_status < xorriso->abort_on_severity && + xorriso->problem_status > 0) { + if(xorriso->problem_status >= sev && !(flag&1)) { + sprintf(xorriso->info_text, + "xorriso : NOTE : Tolerated problem event of severity '%s'\n", + xorriso->problem_status_text); + Xorriso_info(xorriso, 0);/* submit not as problem event */ + } + ret= 2; + } else if(xorriso->problem_status > 0) { + sprintf(xorriso->info_text, + "xorriso : aborting : -abort_on '%s' encountered '%s'", + xorriso->abort_on_text, xorriso->problem_status_text); + if(!(flag&1)) + Xorriso_info(xorriso, 0);/* submit not as problem event */ + ret= -1; + } else if(ret>0) + ret= 1; + else + ret= 2; + return(ret); +} + + +int Xorriso_convert_uidstring(struct XorrisO *xorriso, char *uid_string, + uid_t *uid, int flag) +{ + double num; + char text[80]; + struct passwd *pwd; + + sscanf(uid_string, "%lf", &num); + sprintf(text,"%.f",num); + if(strcmp(text,uid_string)==0) { + *uid= num; + return(1); + } + pwd= getpwnam(uid_string); + if(pwd==NULL) { + sprintf(xorriso->info_text, "-uid: Not a known user: '%s'", uid_string); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + *uid= pwd->pw_uid; + return(1); +} + + +int Xorriso_convert_gidstring(struct XorrisO *xorriso, char *gid_string, + gid_t *gid, int flag) +{ + double num; + char text[80]; + struct group *grp; + + sscanf(gid_string, "%lf", &num); + sprintf(text,"%.f",num); + if(strcmp(text,gid_string)==0) { + *gid= num; + return(1); + } + grp= getgrnam(gid_string); + if(grp==NULL) { + sprintf(xorriso->info_text, "-gid: Not a known group: '%s'", gid_string); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + *gid= grp->gr_gid; + return(1); +} + + +int Xorriso_convert_modstring(struct XorrisO *xorriso, char *cmd, char *mode, + mode_t *mode_and, mode_t *mode_or, int flag) +{ + int who_val= 0; + char sfe[5*SfileadrL], *mpt, *vpt, *opt; + unsigned int num= 0; + mode_t mode_val,mask; + + *mode_and= ~1; + *mode_or= 0; + if(mode[0]=='0') { + *mode_and= 0; + sscanf(mode,"%o",&num); + *mode_or= num; + } else if(strchr(mode,'+')!=NULL || strchr(mode,'-')!=NULL + || strchr(mode,'=')!=NULL) { + /* [ugoa][+-][rwxst] */; + for(mpt= mode; mpt!=NULL; mpt= strchr(mpt, ',')) { + if(*mpt==',') + mpt++; + if(strlen(mpt)<2) + goto unrecognizable; + who_val= 0; + for(vpt= mpt; *vpt!='+' && *vpt!='-' && *vpt!='='; vpt++) { + if(*vpt=='u') + who_val|= 4; + else if(*vpt=='g') + who_val|= 2; + else if(*vpt=='o') + who_val|= 1; + else if(*vpt=='a') + who_val|= 7; + else + goto unrecognizable; + } + opt= vpt; + mode_val= 0; + for(vpt= opt+1; *vpt!=0 && *vpt!=','; vpt++) { + if(*vpt=='r') { + if(who_val&4) + mode_val|= S_IRUSR; + if(who_val&2) + mode_val|= S_IRGRP; + if(who_val&1) + mode_val|= S_IROTH; + } else if(*vpt=='w') { + if(who_val&4) + mode_val|= S_IWUSR; + if(who_val&2) + mode_val|= S_IWGRP; + if(who_val&1) + mode_val|= S_IWOTH; + } else if(*vpt=='x') { + if(who_val&4) + mode_val|= S_IXUSR; + if(who_val&2) + mode_val|= S_IXGRP; + if(who_val&1) + mode_val|= S_IXOTH; + } else if(*vpt=='s') { + if(who_val&4) + mode_val|= S_ISUID; + if(who_val&2) + mode_val|= S_ISGID; + } else if(*vpt=='t') { + if(who_val&1) + mode_val|= S_ISVTX; + } else + goto unrecognizable; + } + if(*opt=='+') { + (*mode_or)|= mode_val; + } else if(*opt=='=') { + mask= 0; + if(who_val&1) + mask|= S_IRWXO|S_ISVTX; + if(who_val&2) + mask|= S_IRWXG|S_ISGID; + if(who_val&4) + mask|= S_IRWXU|S_ISUID; + (*mode_and)&= ~(mask); + (*mode_or)= ((*mode_or) & ~mask) | mode_val; + } else if(*opt=='-') { + (*mode_or)&= ~mode_val; + (*mode_and)&= ~mode_val; + } + } + } else { +unrecognizable:; + sprintf(xorriso->info_text, + "%s: Unrecognizable or faulty permission mode %s\n", cmd, + Text_shellsafe(mode, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + return(1); +} + + +int Xorriso_convert_datestring(struct XorrisO *xorriso, char *cmd, + char *time_type, char *timestring, + int *t_type, time_t *t, int flag) +{ + int ret; + + if(strcmp(time_type, "a")==0) + (*t_type)|= 1; + else if(strcmp(time_type, "m")==0) + (*t_type)|= 4; + else if(strcmp(time_type, "b")==0) + (*t_type)|= 5; + else { + sprintf(xorriso->info_text, "%s: Unrecognized type '%s'", cmd, time_type); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + ret= Decode_timestring(timestring, t, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "%s: Cannot decode timestring '%s'", cmd, + timestring); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + sprintf(xorriso->info_text, "Understanding timestring '%s' as: %s", + timestring, ctime(t)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + return(1); +} + + +/* @param flag bit0=path is in source filesystem , bit1= unconditionally */ +int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag) +{ + if(len>=SfileadrL || (flag&2)) { + sprintf(xorriso->info_text, + "Path given for %s is much too long (%d)", + ((flag&1) ? "local filesystem" : "ISO image"), len); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag) +{ + sprintf(xorriso->info_text, "%s: cannot set create find job object", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(1); +} + + +/* @param flag bit1= do not report memory usage as DEBUG +*/ +int Xorriso_check_temp_mem_limit(struct XorrisO *xorriso, off_t mem, int flag) +{ + char mem_text[80], limit_text[80]; + + Sfile_scale((double) mem, mem_text,5,1e4,0); + if(!(flag&2)) { + sprintf(xorriso->info_text, + "Temporary memory needed for result sorting : %s", mem_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + if(mem > xorriso->temp_mem_limit) { + Sfile_scale((double) xorriso->temp_mem_limit,limit_text,5,1e4,1); + sprintf(xorriso->info_text, + "Cannot sort. List of matching files exceeds -temp_mem_limit (%s > %s)", + mem_text, limit_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(0); + } + return(1); +} + + +/* @param flag bit0= for Xorriso_msgs_submit: use pager + bit1= do not issue warnings +*/ +int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path, + struct LinkiteM **link_stack, struct stat *stbuf, int flag) +{ + int ret; + struct LinkiteM *litm; + char sfe[5*SfileadrL]; + + if(*link_stack != NULL) { + if((*link_stack)->link_count>=xorriso->follow_link_limit) { + sprintf(xorriso->info_text, + "Too many symbolic links in single tree branch at : %s", + Text_shellsafe(link_path, sfe, 0)); + if(!(flag&2)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,"WARNING",flag&1); + return(0); + } + } + ret= stat(link_path, stbuf); + if(ret==-1) + return(0); + ret= Linkitem_find(*link_stack, stbuf->st_dev, stbuf->st_ino, &litm, 0); + if(ret>0) { + sprintf(xorriso->info_text, + "Detected symbolic link loop around : %s", + Text_shellsafe(link_path, sfe, 0)); + if(!(flag&2)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", flag&1); + return(0); + } + ret= Linkitem_new(&litm, link_path, stbuf->st_dev, stbuf->st_ino, + *link_stack, 0); + if(ret<=0) { + sprintf(xorriso->info_text, + "Cannot add new item to link loop prevention stack"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", flag&1); + return(-1); + } + *link_stack= litm; + return(1); +} + + +/* @param flag bit0= do not only sum up sizes but also print subdirs + bit1= this is a recursion + @return <=0 error , 1 ok , 2 could not open directory +*/ +int Xorriso_show_dux_subs(struct XorrisO *xorriso, + char *abs_path, char *rel_path, off_t *size, + off_t boss_mem, + struct LinkiteM *link_stack, + int flag) +{ + int i, ret, no_sort= 0, filec= 0, l, j, fc, no_dive, is_link; + char **filev= NULL, *namept; + off_t sub_size, report_size, mem= 0; + struct DirseQ *dirseq= NULL; + struct stat stbuf; + dev_t dir_dev; + struct LinkiteM *own_link_stack; + +#ifdef Xorriso_fat_local_meM + char path[SfileadrL], show_path[SfileadrL], name[SfileadrL], sfe[5*SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *path= NULL, *show_path= NULL, *name= NULL, *sfe= NULL; + + sfe= malloc(5*SfileadrL); + path= malloc(SfileadrL); + show_path= malloc(SfileadrL); + name= malloc(SfileadrL); + if(path==NULL || show_path==NULL || name==NULL || sfe==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + +#endif /* ! Xorriso_fat_local_meM */ + + own_link_stack= link_stack; + namept= name; + *size= 0; + + if(lstat(abs_path, &stbuf)==-1) + {ret= 2; goto ex;} + dir_dev= stbuf.st_dev; + if(S_ISLNK(stbuf.st_mode)) { + if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&2)))) + {ret= 2; goto ex;} + if(stat(abs_path, &stbuf)==-1) + {ret= 2; goto ex;} + if(dir_dev != stbuf.st_dev && + !(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&2)))) + {ret= 2; goto ex;} + } + ret= Dirseq_new(&dirseq, abs_path, 1); + if(ret<0) { + sprintf(xorriso->info_text, "Cannot obtain disk directory iterator"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + if(ret==0) + {ret= 2; goto ex;} + + while(1) { + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + ret= Dirseq_next_adr(dirseq,name,0); + if(ret<0) + goto ex; + if(ret==0) + break; + + sub_size= 0; + strcpy(show_path, rel_path); + if(Sfile_add_to_path(show_path, name, 0)<=0) + goto much_too_long; + + strcpy(path, abs_path); + if(Sfile_add_to_path(path, name, 0)<=0) { +much_too_long:; + Xorriso_much_too_long(xorriso, strlen(path)+strlen(name)+1, 2); + {ret= -1; goto ex;} + } + no_dive= 0; + + ret= lstat(path, &stbuf); + if(ret==-1) + continue; + is_link= S_ISLNK(stbuf.st_mode); + if(is_link && xorriso->do_follow_links) { + ret= Xorriso_hop_link(xorriso, path, &own_link_stack, &stbuf, 1); + if(ret<0) + {ret= -1; goto ex;} + if(ret!=1) + no_dive= 1; + } + if(!S_ISDIR(stbuf.st_mode)) + no_dive= 1; + if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount) + no_dive= 1; + if(!no_dive) { + filec++; + l= strlen(rel_path)+1; + mem+= l; + if(l % sizeof(char *)) + mem+= sizeof(char *)-(l % sizeof(char *)); + if(flag&1) /* diving and counting is done further below */ + continue; + ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size, boss_mem, + own_link_stack,2); + if(ret<0) + goto ex; + if(ret==0) + continue; + } + +/* + sub_size+= stbuf.st_size+strlen(name)+1; +*/ + sub_size+= stbuf.st_size+2048; + if(sub_size>0) + (*size)+= sub_size; + } + + if(filec<=0 || !(flag&1)) + {ret= 1; goto ex;} + + /* Try to get a sorted list of directory names */ + mem+= (filec+1)*sizeof(char *); + ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, 2); + if(ret<0) + goto ex; + Dirseq_rewind(dirseq, 0); + if(ret==0) { +no_sort_possible:; + no_sort= 1; + } else { + filev= (char **) calloc(filec+1, sizeof(char *)); + if(filev==NULL) + goto no_sort_possible; + else { + for(i= 0; i<filec; i++) + filev[i]= NULL; + fc= 0; + while(1) { + ret= Dirseq_next_adr(dirseq,name,0); + if(ret<0) + goto ex; + if(ret==0) + break; + strcpy(path, abs_path); + if(Sfile_add_to_path(path, name, 0)<=0) + goto much_too_long; + + ret= lstat(path,&stbuf); + if(ret==-1) + continue; + is_link= S_ISLNK(stbuf.st_mode); + if(is_link && xorriso->do_follow_links) { + ret= stat(path,&stbuf); + if(ret==-1) + continue; + } + if(!S_ISDIR(stbuf.st_mode)) + continue; + if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount) + continue; + + if(fc>=filec) { /* Number of files changed (or programming error) */ +revoke_sorting:; + for(j=0; j<fc; j++) + free((char *) filev[j]); + free((char *) filev); + filev= NULL; + goto no_sort_possible; + } + + filev[fc]= strdup(name); + if(filev[fc]==NULL) + goto revoke_sorting; + fc++; + } + filec= fc; + if(filec>1) + Sort_argv(filec, filev, 0); + } + } + + for(i= 0; (no_sort || i<filec) && !(xorriso->request_to_abort); i++) { + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + if(no_sort) { + ret= Dirseq_next_adr(dirseq,name,0); + if(ret<0) + goto ex; + if(ret==0) + break; + } else + namept= filev[i]; + + sub_size= 0; + strcpy(show_path, rel_path); + if(Sfile_add_to_path(show_path, namept, 0)<=0) + goto much_too_long; + strcpy(path, abs_path); + if(Sfile_add_to_path(path, namept, 0)<=0) + goto much_too_long; + no_dive= 0; + + ret= lstat(path,&stbuf); + if(ret==-1) + continue; + is_link= S_ISLNK(stbuf.st_mode); + if(is_link && xorriso->do_follow_links) { + ret= Xorriso_hop_link(xorriso, path, &own_link_stack, &stbuf, 1); + if(ret<0) + {ret= -1; goto ex;} + if(ret!=1) + continue; + } + if(!S_ISDIR(stbuf.st_mode)) + continue; + if(dir_dev == stbuf.st_dev || xorriso->do_follow_mount) { + ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size, + boss_mem+mem, own_link_stack, 2|(flag&1)); + if(ret<0) + goto ex; + } + +/* + sub_size+= stbuf.st_size+strlen(namept)+1; +*/ + sub_size+= stbuf.st_size+2048; + if(sub_size>0) + (*size)+= sub_size; + report_size= sub_size/1024; + if(report_size*1024<sub_size) + report_size++; + sprintf(xorriso->result_line, "%7.f ",(double) (report_size)); + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + } + + ret= 1; +ex:; + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(path!=NULL) + free(path); + if(show_path!=NULL) + free(show_path); + if(name!=NULL) + free(name); +#endif /* ! Xorriso_fat_local_meM */ + + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + Dirseq_destroy(&dirseq, 0); + if(filev!=NULL) { + for(i=0; i<filec; i++) + if(filev[i]!=NULL) + free((char *) filev[i]); + free((char *) filev); + } + return(ret); +} + + +int Xorriso__mode_to_perms(mode_t st_mode, char perms[10], int flag) +{ + strcpy(perms,"---------"); + if(st_mode&S_IRUSR) perms[0]= 'r'; + if(st_mode&S_IWUSR) perms[1]= 'w'; + if(st_mode&S_IXUSR) perms[2]= 'x'; + if(st_mode&S_ISUID) { + if(st_mode&S_IXUSR) + perms[2]= 's'; + else + perms[2]= 'S'; + } + if(st_mode&S_IRGRP) perms[3]= 'r'; + if(st_mode&S_IWGRP) perms[4]= 'w'; + if(st_mode&S_IXGRP) perms[5]= 'x'; + if(st_mode&S_ISGID) { + if(st_mode&S_IXGRP) + perms[5]= 's'; + else + perms[5]= 'S'; + } + if(st_mode&S_IROTH) perms[6]= 'r'; + if(st_mode&S_IWOTH) perms[7]= 'w'; + if(st_mode&S_IXOTH) perms[8]= 'x'; + if(st_mode&S_ISVTX) { + if(st_mode&S_IXOTH) + perms[8]= 't'; + else + perms[8]= 'T'; + } + return(1); +} + + +int Xorriso_format_ls_l(struct XorrisO *xorriso, struct stat *stbuf, int flag) +{ + char *rpt, perms[10]; + mode_t st_mode; + + rpt= xorriso->result_line; + rpt[0]= 0; + st_mode= stbuf->st_mode; + + if(S_ISDIR(st_mode)) + strcat(rpt, "d"); + else if(S_ISREG(st_mode)) + strcat(rpt, "-"); + else if(S_ISLNK(st_mode)) + strcat(rpt, "l"); + else if(S_ISBLK(st_mode)) + strcat(rpt, "b"); + else if(S_ISCHR(st_mode)) + strcat(rpt, "c"); + else if(S_ISFIFO(st_mode)) + strcat(rpt, "p"); + else if(S_ISSOCK(st_mode)) + strcat(rpt, "s"); + else + strcat(rpt, "?"); + + Xorriso__mode_to_perms(st_mode, perms, 0); + strcat(rpt, perms); + + sprintf(rpt+strlen(rpt),"%4u ",(unsigned int) stbuf->st_nlink); + + sprintf(rpt+strlen(rpt), "%-8lu ", (unsigned long) stbuf->st_uid); + sprintf(rpt+strlen(rpt), "%-8lu ", (unsigned long) stbuf->st_gid); + sprintf(rpt+strlen(rpt), "%8.f ", (double) stbuf->st_size); + + Ftimetxt(stbuf->st_mtime, rpt+strlen(rpt), 0); + strcat(rpt, " "); + + return(1); +} + + +struct DirentrY { + char *adr; + struct DirentrY *next; +}; + + +int Xorriso_sorted_dir_x(struct XorrisO *xorriso, char *dir_path, + int *filec, char ***filev, off_t boss_mem, int flag) +{ + int count= 0, ret; + char name[SfileadrL]; + struct DirseQ *dirseq= NULL; + off_t mem; + struct DirentrY *last= NULL, *current= NULL; + + *filec= 0; + *filev= NULL; + mem= boss_mem; + ret= Dirseq_new(&dirseq, dir_path, 1); + if(ret<=0) + goto ex; + while(1) { /* loop over directory content */ + ret= Dirseq_next_adr(dirseq,name,0); + if(ret==0) + break; + if(ret<0) + goto ex; + mem+= strlen(name)+8+sizeof(struct DirentrY)+sizeof(char *); + if(mem>xorriso->temp_mem_limit) + {ret= 0; goto ex;} + + current= (struct DirentrY *) calloc(1, sizeof(struct DirentrY)); + if(current==NULL) + {ret= -1; goto ex;} + current->adr= NULL; + current->next= last; + last= current; + last->adr= strdup(name); + if(last->adr==NULL) + {ret= -1; goto ex;} + count++; + } + *filec= count; + if(count==0) + {ret= 1; goto ex;} + (*filev)= (char **) calloc(count, sizeof(char *)); + if(*filev==NULL) + {ret= -1; goto ex; } + count= 0; + for(current= last; current!=NULL; current= last) { + last= current->next; + (*filev)[count++]= current->adr; + free((char *) current); + } + Sort_argv(*filec, *filev, 0); + ret= 1; +ex:; + for(current= last; current!=NULL; current= last) { + last= current->next; + free(current->adr); + free((char *) current); + } + return(ret); +} + + +/* @param flag bit0= long format + bit1= do not print count of nodes + bit2= du format + bit3= print directories as themselves (ls -d) +*/ +int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd, + int filec, char **filev, off_t boss_mem, int flag) +{ + int i, ret, was_error= 0, dfilec= 0, pass, passes; + char sfe[5*SfileadrL], sfe2[5*SfileadrL], path[SfileadrL]; + char *rpt, link_target[SfileadrL], **dfilev= NULL; + off_t size; + struct stat stbuf; + + rpt= xorriso->result_line; + + Sort_argv(filec, filev, 0); + + /* Count valid nodes, warn of invalid ones */ + for(i= 0; i<filec; i++) { + ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4); + if(ret<=0) { + was_error++; + continue; + } + ret= lstat(path, &stbuf); + if(ret==-1) { + sprintf(xorriso->info_text, "Not found in local filesystem: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 1); + was_error++; + continue; + } + } + + if((flag&8) && !(flag&(2|4))) { + sprintf(xorriso->info_text,"Valid local files found: %d\n",filec-was_error); + Xorriso_info(xorriso,1); + if(filec-was_error<=0) + return(!was_error); + } + + passes= 1+!(flag&(4|8)); + for(pass= 0; pass<passes; pass++) + for(i= 0; i<filec && !(xorriso->request_to_abort); i++) { + ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4); + if(ret<=0) + continue; + ret= lstat(path, &stbuf); + if(ret==-1) + continue; + if(S_ISLNK(stbuf.st_mode) && + (xorriso->do_follow_links || xorriso->do_follow_param)) { + ret= stat(path, &stbuf); + if(ret==-1) + ret= lstat(path, &stbuf); + if(ret==-1) + continue; + } + if(S_ISDIR(stbuf.st_mode) && !(flag&(4|8))) { + if(pass==0) + continue; + if(filec>1) { + strcpy(xorriso->result_line, "\n"); + Xorriso_result(xorriso,0); + sprintf(xorriso->result_line, "%s:\n", Text_shellsafe(filev[i], sfe,0)); + Xorriso_result(xorriso,0); + } + ret= Xorriso_sorted_dir_x(xorriso, path, &dfilec, &dfilev, boss_mem, 0); + if(ret<=0) { + + /* >>> DirseQ loop and single item Xorriso_lsx_filev() */; + + } else { + if(flag&1) { + sprintf(xorriso->result_line, "total %d\n", dfilec); + Xorriso_result(xorriso,0); + } + Xorriso_lsx_filev(xorriso, path, + dfilec, dfilev, boss_mem, (flag&1)|2|8); + } + if(dfilec>0) + Sfile_destroy_argv(&dfilec, &dfilev, 0); + continue; + } else + if(pass>0) + continue; + link_target[0]= 0; + rpt[0]= 0; + if((flag&5)==1) { + ret= Xorriso_format_ls_l(xorriso, &stbuf, 0); + if(ret<=0) + continue; + if(S_ISLNK(stbuf.st_mode)) { + ret= Xorriso_resolve_link(xorriso, path, link_target, 1); + if(ret<=0) + link_target[0]= 0; + } + } else if(flag&4) { /* -du or -dus */ + size= stbuf.st_size; + if(S_ISDIR(stbuf.st_mode)) { + ret= Xorriso_show_dux_subs(xorriso, path, filev[i], &size, boss_mem, + NULL, flag&1); + if(ret<0) + return(-1); + if(ret==0) + continue; + } + sprintf(rpt, "%7.f ",(double) (size/1024)); + } + if(link_target[0]) + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n", + Text_shellsafe(filev[i], sfe, 0), + Text_shellsafe(link_target, sfe2, 0)); + else + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(filev[i], sfe, 0)); + Xorriso_result(xorriso, 0); + } + return(!was_error); +} + + +/* @param flag bit0= recursion +*/ +int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job, + char *abs_path, char *show_path, int depth, int flag) +{ + int ret= 0, type, action= 0, dpl= 0, compare_result, uret; + uid_t user= 0; + gid_t group= 0; + time_t date= 0; + mode_t mode_or= 0, mode_and= ~1; + char *target, sfe[5*SfileadrL], *disk_prefix, iso_path[SfileadrL]; + struct FindjoB *subjob; + struct stat stbuf; + + action= Findjob_get_action_parms(job, &target, &user, &group, + &mode_and, &mode_or, &type, &date, &subjob, 0); + if(action<0) + action= 0; + if(action<0) + action= 0; + if(action==15 || action==16 || action==18 || action==19 || action==20) { + /* in_iso , not_in_iso, add_missing , empty_iso_dir , is_full_in_iso */ + Findjob_get_start_path(job, &disk_prefix, 0); + if(strncmp(abs_path, disk_prefix, strlen(disk_prefix))!=0) + {ret= -1; goto ex;} + dpl= strlen(disk_prefix); + if(strlen(target)+strlen(abs_path)-dpl >= SfileadrL) + {ret= -1; goto ex;} + if(abs_path[dpl]=='/') + dpl++; + ret= Xorriso_make_abs_adr(xorriso, target, abs_path+dpl, iso_path, 4); + if(ret<=0) + {goto ex;} + + } + if(action==15) { /* in_iso */ + ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0); + if(ret==-1) + {ret= 1; goto ex;} + sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + ret= 1; + } else if(action==16) { /* not_in_iso */ + ret= Xorriso_compare_2_files(xorriso, abs_path, iso_path, abs_path+dpl, + &compare_result, 4); + if(ret<xorriso->find_compare_result) + xorriso->find_compare_result= ret; + if(ret>=0) + ret= 1; + } else if(action==18) { /* add_missing */ + ret= Xorriso_compare_2_files(xorriso, abs_path, iso_path, abs_path+dpl, + &compare_result, 4|(1<<31)); + if(ret<xorriso->find_compare_result) + xorriso->find_compare_result= ret; + if(ret==0) { + uret= Xorriso_update_interpreter(xorriso, NULL, compare_result, + abs_path, iso_path, (flag&1)<<2); + if(uret<=0) + ret= 0; + } + if(ret>=0) + ret= 1; + } else if(action==19) { /* empty_iso_dir */ + ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0); + if(ret==-1) + {ret= 1; goto ex;} + if(!S_ISDIR(stbuf.st_mode)) + {ret= 1; goto ex;} + ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, iso_path, 1|32); + if(ret>0) { + sprintf(xorriso->info_text, "Emptied directory %s", + Text_shellsafe(iso_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + } + } else if(action==20) { /* is_full_in_iso */ + ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0); + if(ret==-1) + {ret= 1; goto ex;} + if(!S_ISDIR(stbuf.st_mode)) + {ret= 1; goto ex;} + strcpy(sfe, xorriso->wdi); + strcpy(xorriso->wdi, iso_path); + ret= Xorriso_ls(xorriso, 4|8); + strcpy(xorriso->wdi, sfe); + if(ret>0) { + sprintf(xorriso->result_line, + "d %s (ISO) : non-empty directory (would not match mount point)\n", + Text_shellsafe(iso_path, sfe, 0)); + Xorriso_result(xorriso,0); + } + {ret= 1; goto ex;} + } else { + sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + ret= 1; + } +ex:; + if(action==15 || action==16 || action==18 || action==19 || action==20) + if(xorriso->no_volset_present) + xorriso->request_to_abort= 1; /* Need an image. No use to try again. */ + return(ret); +} + + +/* @param flag bit0=recursion +*/ +int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job, + char *abs_dir_parm, char *dir_path, + struct stat *dir_stbuf, int depth, + struct LinkiteM *link_stack, int flag) +{ + int ret,is_link, no_dive; + struct DirseQ *dirseq= NULL; + struct stat stbuf; + struct LinkiteM *own_link_stack; + char *abs_dir_path, *namept; + +#ifdef Xorriso_fat_local_meM + char name[SfileadrL], path[SfileadrL], sfe[5*SfileadrL]; + char abs_dir_path_data[SfileadrL], abs_path[SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *name= NULL, *path= NULL, *sfe= NULL; + char *abs_dir_path_data= NULL, *abs_path= NULL; + + sfe= malloc(5*SfileadrL); + name= malloc(SfileadrL); + path= malloc(SfileadrL); + abs_dir_path_data= malloc(SfileadrL); + abs_path= malloc(SfileadrL); + if(name==NULL || sfe==NULL || path==NULL || + abs_dir_path_data==NULL || abs_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ + + own_link_stack= link_stack; + abs_dir_path= abs_dir_parm; + if(abs_dir_path[0]==0) { + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, dir_path, + abs_dir_path_data, 1|2|8); + if(ret<=0) + goto ex; + abs_dir_path= abs_dir_path_data; + + /* >>> compare exclusions against abs_path resp. leaf name */; + + ret= lstat(abs_dir_path, dir_stbuf); + if(ret==-1) + {ret= 0; goto ex;} + if(S_ISLNK(dir_stbuf->st_mode) && + (xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) + if(stat(abs_dir_path, &stbuf)!=-1) + if(dir_stbuf->st_dev == stbuf.st_dev || + (xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1)))) + memcpy(dir_stbuf, &stbuf, sizeof(struct stat)); + + namept= strrchr(dir_path, '/'); + if(namept==NULL) + namept= dir_path; + else + namept++; + ret= Findjob_test(job, namept, NULL, dir_stbuf, depth, 0); + if(ret<0) + goto ex; + if(ret>0) { + ret= Xorriso_findx_action(xorriso, job, abs_dir_path, dir_path, depth, + flag&1); + if(ret<=0) { + if(xorriso->request_to_abort) + goto ex; + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + goto ex; + } + } + } + if(xorriso->request_to_abort) + {ret= 1; goto ex;} + if(!S_ISDIR(dir_stbuf->st_mode)) + {ret= 2; goto ex;} + + ret= Dirseq_new(&dirseq, abs_dir_path, 1); + if(ret<0) { + sprintf(xorriso->info_text, "Cannot obtain disk directory iterator"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + if(ret==0) + {ret= 2; goto ex;} + + while(!xorriso->request_to_abort) { + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + ret= Dirseq_next_adr(dirseq,name,0); + if(ret==0) + break; + if(ret<0) { + sprintf(xorriso->info_text,"Failed to obtain next directory entry"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + ret= Xorriso_make_abs_adr(xorriso, abs_dir_path, name, abs_path, 1); + if(ret<=0) + goto ex; + ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4); + if(ret<=0) + goto ex; + + /* >>> compare exclusions against abs_path resp. leaf name */; + + ret= lstat(abs_path, &stbuf); + if(ret==-1) + continue; + no_dive= 0; + + is_link= S_ISLNK(stbuf.st_mode); + if(is_link && xorriso->do_follow_links) { + ret= Xorriso_hop_link(xorriso, abs_path, &own_link_stack, &stbuf, 2); + if(ret<0) + {ret= -1; goto ex;} + if(ret!=1) + no_dive= 1; + } + ret= Findjob_test(job, name, dir_stbuf, &stbuf, depth, 0); + if(ret<0) + goto ex; + if(ret>0) { + ret= Xorriso_findx_action(xorriso, job, abs_path, path, depth, flag&1); + if(ret<=0) { + if(xorriso->request_to_abort) + goto ex; + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + goto ex; + } + } + if(!S_ISDIR(stbuf.st_mode)) + no_dive= 1; + if(dir_stbuf->st_dev != stbuf.st_dev && !xorriso->do_follow_mount) + no_dive= 1; + if(!no_dive) { + ret= Xorriso_findx(xorriso, job, abs_path, path, &stbuf, depth+1, + own_link_stack, flag|1); + if(ret<0) + goto ex; + } + } + + ret= 1; +ex:; + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(name!=NULL) + free(name); + if(path!=NULL) + free(path); + if(abs_dir_path_data!=NULL) + free(abs_dir_path_data); + if(abs_path!=NULL) + free(abs_path); +#endif /* ! Xorriso_fat_local_meM */ + + Dirseq_destroy(&dirseq, 0); + return(ret); +} + + +/* @param flag bit0= a non-existing target of multiple sources is a directory + bit1= all paths except the last one are disk_paths + @return <=0 iis error, 1= leaf file object, 2= directory +*/ +int Xorriso_cpmv_args(struct XorrisO *xorriso, char *cmd, + int argc, char **argv, int *idx, + int *optc, char ***optv, char eff_dest[SfileadrL], + int flag) +{ + int destc= 0, is_dir=0, end_idx, ret, i; + char **destv= NULL; + char sfe[5*SfileadrL]; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, + (xorriso->do_iso_rr_pattern==1)|(flag&2)); + if(end_idx - *idx < 2) { + sprintf(xorriso->info_text, "%s: not enough arguments", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } + + ret= Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, optc, optv, + (flag&2)|16); /* ignore last argument */ + if(ret<=0) + goto ex; + /* demand one match, or 0 with a constant */ + ret= Xorriso_opt_args(xorriso, cmd, argc, argv, end_idx, &end_idx, &destc, + &destv, 32|64); + if(ret<=0) + goto ex; + + /* Evaluate target address */ + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, destv[0], eff_dest, 1); + if(ret<0) + {ret= 0; goto ex;} + if(ret==2 || ((flag&1) && *optc > 1 && ret==0)) { + is_dir= 1; + } else if(*optc > 1) { + for(i= 0; i<*optc; i++) + Xorriso_msgs_submit(xorriso, 0, (*optv)[i], 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "%s: more than one origin given, destination is a non-directory: %s", + cmd, Text_shellsafe(destv[0], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + if(ret==0) { /* compute complete eff_dest */ + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, destv[0],eff_dest,2); + if(ret<0) + {ret= 0; goto ex;} + } + + ret= 1+is_dir; +ex:; + Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &destc, &destv, + 256); + (*idx)= end_idx; + return(ret); +} + + +/** @return -1= abort , 0= no , 1= yes +*/ +int Xorriso_reassure(struct XorrisO *xorriso, char *cmd, char *which_will, + int flag) +{ + int ret; + + if(!xorriso->do_reassure) + return(1); + sprintf(xorriso->info_text, "Really perform %s which will %s ? (y/n)\n", + cmd, which_will); + Xorriso_info(xorriso, 4); + do { + ret= Xorriso_request_confirmation(xorriso, 2|4|16); + } while(ret==3); + if(ret==6 || ret==4) { + sprintf(xorriso->info_text, "%s confirmed", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); + } + if(ret==2) { + sprintf(xorriso->info_text, "%s aborted", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(-1); + } + sprintf(xorriso->info_text, "%s revoked", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(0); +} + + +/* @param flag bit0+1= what to aquire after giving up outdev + 0=none, 1=indev, 2=outdev, 3=both +*/ +int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag) +{ + int ret, aq_flag; + char drive_name[SfileadrL], sfe[5*SfileadrL]; + + aq_flag= flag&3; + strcpy(drive_name, xorriso->outdev); + Xorriso_give_up_drive(xorriso, aq_flag); + if(aq_flag==0) { + sprintf(xorriso->info_text,"Gave up -outdev %s", + Text_shellsafe(xorriso->outdev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); + } + sprintf(xorriso->info_text,"Re-aquiring -outdev %s", + Text_shellsafe(drive_name, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= Xorriso_aquire_drive(xorriso, drive_name, aq_flag); + if(ret<=0) { + sprintf(xorriso->info_text,"Could not re-aquire -outdev %s", + Text_shellsafe(xorriso->outdev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + return(1); +} + + +/* micro version of cdrskin */ +int Xorriso_cdrskin(struct XorrisO *xorriso, char *whom, int argc, char **argv, + int flag) +{ + int ret, i, k, mem_do_close, aq_ret, eject_ret; + int do_atip= 0, do_checkdrive= 0, do_eject= 0, do_scanbus= 0; + int do_toc= 0, do_verbous= 0, do_version= 0, do_help= 0; + char track_source[SfileadrL], sfe[5*SfileadrL], dev_adr[SfileadrL], *cpt; + char mem_report_about_text[80], *report_about= "SORRY", blank_mode[80]; + char speed[80]; + + /* cdrecord 2.01 options which are not scheduled for implementation, yet */ + static char ignored_partial_options[][41]= { + "timeout=", "debug=", "kdebug=", "kd=", "driver=", "ts=", + "pregap=", "defpregap=", "mcn=", "isrc=", "index=", "textfile=", + "pktsize=", "cuefile=", + "gracetime=", "minbuf=", + + "assert_write_lba=", "fifo_start_at=", "dev_translation=", + "drive_scsi_dev_family=", "fallback_program=", "modesty_on_drive=", + "tao_to_sao_tsize=", + + "direct_write_amount=", "write_start_address=", "msifile=", + + "tsize=", + + "" + }; + static char ignored_full_options[][41]= { + "-d", "-Verbose", "-V", "-silent", "-s", "-setdropts", "-prcap", + "-reset", "-abort", "-overburn", "-ignsize", "-useinfo", + "-fix", "-nofix", + "-raw", "-raw96p", "-raw16", + "-clone", "-text", "-mode2", "-xa", "-xa1", "-xa2", "-xamix", + "-cdi", "-preemp", "-nopreemp", "-copy", "-nocopy", + "-scms", "-shorttrack", "-noshorttrack", "-packet", "-noclose", + "-media-info", "-minfo", + "-isosize", "-load", "-lock", "-raw96r", "-sao", "-dao", "-swab", + "-tao", "-waiti", "-force", "-format", + + "--adjust_speed_to_drive", "--allow_emulated_drives", "--allow_setuid", + "--allow_untested_media", "--any_track", "--demand_a_drive", + "--fifo_disable", "--fifo_start_empty", "--fill_up_media", + "--list_ignored_options", "--no_rc", "--no_convert_fs_adr", + "--prodvd_cli_compatible", "--single_track", + + "--tell_media_space", + + "" + }; + + static char helptext[][80]= { +"Usage: xorriso -as cdrecord [options|source_addresses]", +"Note: This is not cdrecord. See xorriso -help, xorriso -version, man xorriso", +"Options:", +"\t-version\tprint version information and exit emulation", +"\t--devices\tprint list of available MMC drives and exit emulation", +"\tdev=target\tpseudo-SCSI target to use as CD-Recorder", +"\t-v\t\tincrement verbose level by one", +"\t-checkdrive\tcheck if a driver for the drive is present", +"\t-inq\t\tdo an inquiry for the drive and exit emulation", +"\tspeed=#\t\tset speed of drive", +"\tblank=type\tblank a CD-RW disc (see blank=help)", +"\tfs=#\t\tSet fifo size to # (0 to disable, default is 4 MB)", +"\t-eject\t\teject the disk after doing the work", +"\t-toc\t\tretrieve and print TOC/PMA data", +"\t-atip\t\tretrieve media state, print \"Is *erasable\"", +"\tpadsize=#\tAmount of padding", +"\t-data\t\tSubsequent tracks are CD-ROM data mode 1 (default)", +"\t-pad\t\tpadsize=30k", +"\t-nopad\t\tDo not pad", +"\t-help\t\tprint this text to stderr and exit emulation", +"Actually this is the integrated ISO RockRidge filesystem manipulator xorriso", +"lending its libburn capabilities to a very limited cdrecord emulation.", +"Only a single data track can be burnt to blank or overwriteable media which", +"will be finalized afterwards if possible.", +"A much more elaborate cdrecord emulator is cdrskin from the same project.", +"@End_of_helptexT@" +}; +/* "\t-scanbus\tscan the SCSI bus and exit emulation", */ + +static char blank_help[][80]= { +"Blanking options:", +"\tall\t\tblank the entire disk", +"\tdisc\t\tblank the entire disk", +"\tdisk\t\tblank the entire disk", +"\tfast\t\tminimally blank the entire disk", +"\tminimal\t\tminimally blank the entire disk", +"\tdeformat\t\tblank a formatted DVD-RW", +"\tdeformat_quickest\t\tminimally blank a formatted DVD-RW to DAO only", +"@End_of_helptexT@" +}; + + strcpy(mem_report_about_text, xorriso->report_about_text); + mem_do_close= xorriso->do_close; + + track_source[0]= 0; + dev_adr[0]= 0; + blank_mode[0]= 0; + speed[0]= 0; + + if(xorriso->in_drive_handle != NULL) { + ret= Xorriso_option_dev(xorriso, "", 1); /* give up indev */ + if(ret!=1) + return(ret); + } + + + /* Assess plan, make settings */ + for(i= 0; i<argc; i++) { + sprintf(xorriso->info_text, "-as %s: %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + + for(k=0;ignored_partial_options[k][0]!=0;k++) { + if(argv[i][0]=='-') + if(strncmp(argv[i]+1,ignored_partial_options[k], + strlen(ignored_partial_options[k]))==0) + goto no_volunteer; + if(strncmp(argv[i],ignored_partial_options[k], + strlen(ignored_partial_options[k]))==0) + goto no_volunteer; + } + for(k=0;ignored_full_options[k][0]!=0;k++) + if(strcmp(argv[i],ignored_full_options[k])==0) + goto no_volunteer; + if(0) { +no_volunteer:; + sprintf(xorriso->info_text, "-as %s: Ignored option %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + continue; + } + + if(strcmp(argv[i], "-atip")==0) { + do_atip= 1; + } else if(strcmp(argv[i], "-audio")==0) { + sprintf(xorriso->info_text, "-as %s: Option -audio not supported.", whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } else if(strncmp(argv[i], "-blank=", 7)==0 || + strncmp(argv[i], "blank=", 6)==0) { + cpt= strchr(argv[i], '=')+1; + if(strcmp(cpt,"all")==0 || strcmp(cpt,"disc")==0 + || strcmp(cpt,"disk")==0) { + strcpy(blank_mode, "all"); + } else if(strcmp(cpt,"fast")==0 || strcmp(cpt,"minimal")==0) { + strcpy(blank_mode, "fast"); + } else if(strcmp(cpt,"help")==0) { + strcpy(blank_mode, "help"); + } else if(strcmp(cpt,"deformat")==0 || + strcmp(cpt,"deformat_sequential")==0 || + strcmp(cpt,"deformat_quickest")==0 || + strcmp(cpt,"deformat_sequential_quickest")==0) { + strcpy(blank_mode, cpt); + } else { + sprintf(xorriso->info_text, + "-as %s: blank=%s not supported. See blank=help .", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } else if(strcmp(argv[i], "-checkdrive")==0) { + do_checkdrive= 1; + } else if(strcmp(argv[i], "-data")==0) { + /* ok */; + } else if(strncmp(argv[i], "-dev=", 5)==0 || + strncmp(argv[i], "dev=", 4)==0) { + cpt= strchr(argv[i], '=')+1; + ret= Xorriso_option_dev(xorriso, cpt, 2|8); /* overwriteables as blank */ + if(ret<=0) + goto ex; + } else if(strncmp(argv[i],"driveropts=", 11)==0 || + strncmp(argv[i],"-driveropts=", 12)==0) { + if(strcmp(argv[i]+11, "help")==0) { + fprintf(stderr,"Driver options:\n"); + fprintf(stderr, + "burnfree\tPrepare writer to use BURN-Free technology\n"); + } + } else if(strcmp(argv[i], "-dummy")==0) { + xorriso->do_dummy= 1; + } else if(strcmp(argv[i], "-eject")==0) { + do_eject= 1; + } else if(strncmp(argv[i], "-fs=", 4)==0 || strncmp(argv[i], "fs=", 3)==0) { + cpt= strchr(argv[i], '=')+1; + ret= Xorriso_option_fs(xorriso, cpt, 0); + if(ret<=0) + goto ex; + } else if(strcmp(argv[i], "-inq")==0) { + do_checkdrive= 2; + } else if(strcmp(argv[i], "-nopad")==0) { + xorriso->padding= 0; + } else if(strcmp(argv[i], "-pad")==0) { + xorriso->padding= 15*2048; + } else if(strncmp(argv[i], "-padsize=", 9)==0 || + strncmp(argv[i], "padsize=", 8)==0) { + cpt= strchr(argv[i], '=')+1; + ret= Xorriso_option_padding(xorriso, cpt, 0); + if(ret<=0) + goto ex; + } else if(strncmp(argv[i], "-speed=", 7)==0 || + strncmp(argv[i], "speed=", 6)==0) { + cpt= strchr(argv[i], '=')+1; + strncpy(speed, cpt, 79); + speed[79]= 0; + } else if(strcmp(argv[i], "-multi")==0) { + sprintf(xorriso->info_text, "-as %s: Option -multi not supported.", whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } else if(strcmp(argv[i], "-msinfo")==0) { + sprintf(xorriso->info_text, "-as %s: Option -msinfo not supported.",whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } else if(strcmp(argv[i], "--devices")==0) { + do_scanbus= 2; + } else if(strcmp(argv[i], "-scanbus")==0) { + sprintf(xorriso->info_text, "-as %s: Option -scanbus not supported.", + whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + +/* do_scanbus= 1; */ + } else if(strcmp(argv[i], "-toc")==0) { + do_toc= 1; + } else if(strcmp(argv[i], "--grow_overwriteable_iso")==0) { + sprintf(xorriso->info_text, + "-as %s: Option --grow_overwriteable_iso not supported.", + whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i],"-verbose")==0) { + do_verbous++; + } else if(strcmp(argv[i], "-vv")==0) { + do_verbous+= 2; + } else if(strcmp(argv[i], "-vvv")==0) { + do_verbous+= 3; + } else if(strcmp(argv[i], "-version")==0) { + do_version= 1; + } else if(strcmp(argv[i], "-help")==0) { + do_help= 1; + } else if(argv[i][0]=='-' && argv[i][1]!=0) { + sprintf(xorriso->info_text, "-as %s: Unknown option %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } else { + if(track_source[0]) { + sprintf(xorriso->info_text, "-as %s: Surplus track source %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text, "First and only track source is %s", + Text_shellsafe(track_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 0; goto ex; + } + if(Sfile_str(track_source, argv[i], 0)<=0) + {ret= -1; goto ex;} + } + } + + /* Perform actions */ + Xorriso_option_report_about(xorriso, "NOTE", 0); + if(do_version) { + sprintf(xorriso->result_line, "Cdrecord 2.01-Emulation Copyright (C) 2008 see libburnia-project.org xorriso\n"); + Xorriso_result(xorriso, 1); + Xorriso_option_version(xorriso, 0); + ret= 1; goto ex; + } + if(do_help) { + for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) { + sprintf(xorriso->info_text, "%s\n", helptext[i]); + Xorriso_info(xorriso,0); + } + ret= 1; goto ex; + } + if(do_scanbus) { + if(do_scanbus==1) + /* >>> would need -scanbus compatible output and input format */; + else + Xorriso_option_devices(xorriso, 0); + ret= 1; goto ex; + } + if(strcmp(blank_mode, "help")==0) { + for(i= 0; strcmp(blank_help[i], "@End_of_helptexT@")!=0; i++) { + sprintf(xorriso->info_text, "%s\n", blank_help[i]); + Xorriso_info(xorriso,0); + } + ret= 1; goto ex; + } + + if(!(do_checkdrive || do_atip || do_toc || blank_mode[0] || track_source[0] || + do_eject)) + {ret= 1; goto ex;} + + if(xorriso->out_drive_handle==NULL) { + sprintf(xorriso->info_text, "-as %s: No output drive selected", whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(speed[0]) { + ret= Xorriso_option_speed(xorriso, speed, 0); + if(ret<=0) + goto ex; + } + + if(do_verbous<=0) + report_about= "SORRY"; + else if(do_verbous<=2) + report_about= "UPDATE"; + else if(do_verbous==3) + report_about= "DEBUG"; + else + report_about= "ALL"; + Xorriso_option_report_about(xorriso, report_about, 0); + + if(do_checkdrive) { + ret= Xorriso_atip(xorriso, 2-(do_checkdrive==2)); + if(ret<=0) + goto ex; + } + if(do_atip) { + ret= Xorriso_atip(xorriso, 0); + if(ret<=0) + goto ex; + } + if(do_toc) { + ret= Xorriso_option_toc(xorriso, 0); + if(ret<=0) + goto ex; + } + if(blank_mode[0]) { + ret= Xorriso_option_blank(xorriso, blank_mode, 0); + if(ret<=0) + goto ex; + } + if(track_source[0]) { + xorriso->do_close= 1; + ret= Xorriso_burn_track(xorriso, track_source, 0); + aq_ret= Xorriso_reaquire_outdev(xorriso, 2*(ret>0)); + if(ret<=0 && ret<aq_ret) + goto ex; + if(aq_ret<=0) + {ret= aq_ret; goto ex;} + } + + ret= 1; +ex:; + if(do_eject && ret>=0) { + eject_ret= Xorriso_option_eject(xorriso, "out", 0); + if(eject_ret<ret) + ret= eject_ret; + } + if(ret<=0) { + sprintf(xorriso->info_text, "-as %s: Job could not be performed properly.", + whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + Xorriso_option_report_about(xorriso, mem_report_about_text, 0); + xorriso->do_close= mem_do_close; + return(ret); +} + + +/* micro emulation of mkisofs */ +int Xorriso_genisofs(struct XorrisO *xorriso, char *whom, + int argc, char **argv, int flag) +{ + int ret, i, k, was_path= 0, was_other_option= 0, mem_graft_points; + int do_print_size= 0, idx_offset= 0, fd; + char sfe[5*SfileadrL], adr[SfileadrL+8], ra_text[80], pathspec[2*SfileadrL]; + char *ept, *add_pt, eff_path[SfileadrL]; + + /* mkisofs 2.01 options which are not scheduled for implementation, yet */ + static char ignored_arg0_options[][41]= { + "-allow-leading-dots", "-ldots", "-allow-lowercase", "-allow-multidot", + "-cache-inodes", "-no-cache-inodes", "-check-oldnames", "-d", "-D", + "-joliet-long", "-l", "-L", "-max-iso9660-filenames", "-N", "-nobak", + "-no-bak", "-force-rr", "-r", "-relaxed-filenames", "-T", "-U", + "-no-iso-translate", + "" + }; + static char ignored_arg1_options[][41]= { + "-A", "-biblio", "-check-session", "-p", "-root", + "-old-root", "-sysid", "-table-name", + "" + }; + static char helptext[][80]= { +"Usage: xorriso -as mkisofs [options] file...", +"Note: This is not mkisofs. See xorriso -help, xorriso -version, man xorriso", +"Options:", +" -f, -follow-links Follow symbolic links", +" -graft-points Allow to use graft points for filenames", +" -help Print option help", +" -J, -joliet Generate Joliet directory information", +" -no-pad Do not pad output", +" -o FILE, -output FILE Set output file name", +" -pad Pad output by 300k (default)", +" -path-list FILE File with list of pathnames to process", +" -print-size Print estimated filesystem size and exit", +" -quiet Run quietly", +" -R, -rock Generate Rock Ridge directory information", +" -V ID, -volid ID Set Volume ID", +" -v, -verbose Verbose", +" -version Print the current version", +"@End_of_helptexT@" +}; + + strcpy(ra_text, xorriso->report_about_text); + + if(xorriso->in_drive_handle != NULL) { + ret= Xorriso_option_dev(xorriso, "", 1); /* give up indev */ + if(ret!=1) + return(ret); + } + + adr[0]= 0; + for(i= 0; i<argc; i++) { + if(strcmp(argv[i], "-version")==0) { + sprintf(xorriso->result_line, +"mkisofs 2.01-Emulation Copyright (C) 2008 see libburnia-project.org xorriso\n" + ); + fd= xorriso->dev_fd_1; + if(fd<0) + fd= 1; + write(fd, xorriso->result_line, strlen(xorriso->result_line)); + fsync(fd); + Xorriso_option_version(xorriso, 0); + + /* >>> this would need a ban to write images to stdout */; + } else if(strcmp(argv[i], "-o")==0 || strcmp(argv[i], "-output")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + adr[0]= 0; + if(strcmp(argv[i],"-")!=0) + strcpy(adr, "stdio:"); + if(Sfile_str(adr+strlen(adr), argv[i], 0)<=0) + {ret= -1; goto ex;} + } else if(strcmp(argv[i], "-help")==0) { + Xorriso_option_report_about(xorriso, "NOTE", 0); + for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) { + sprintf(xorriso->info_text, "%s\n", helptext[i]); + Xorriso_info(xorriso,0); + } + Xorriso_option_report_about(xorriso, ra_text, 0); + } else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "-verbose")==0) { + strcpy(ra_text, "UPDATE"); + } else if(strcmp(argv[i], "-quiet")==0) { + strcpy(ra_text, "SORRY"); + } else if(strcmp(argv[i], "-f")==0 || strcmp(argv[i], "-follow-links")==0) { + ret= Xorriso_option_follow(xorriso, "on", 0); + if(ret<=0) + goto ex; + } else + was_other_option= 1; + } + Xorriso_option_report_about(xorriso, ra_text, 0); + if(adr[0]) { + if(strncmp(adr, "stdio:", 6)==0 && strncmp(adr, "stdio:/dev/fd/", 14)!=0) { + ret= Sfile_type(adr+6, 1); + if(ret==-1) { + /* ok */; + } else if(ret==2 || ret==3) { + sprintf(xorriso->info_text, + "-as %s: Cannot accept %s as target: -o %s", + whom, (ret==3 ? "symbolic link" : "directory"), + Text_shellsafe(adr+6, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + } + /* Regard overwriteable as blank, truncate regular files on write start */ + ret= Xorriso_option_dev(xorriso, adr, 2|8|16); + if(ret<=0) + goto ex; + } + if(!was_other_option) + {ret= 1; goto ex;} + if(xorriso->out_drive_handle==NULL) { + ret= Xorriso_option_dev(xorriso, "-", 2|4); /* set outdev to stdout */ + if(ret<=0) + return(ret); + } + + xorriso->padding= 300*1024; + + for(i= 0; i<argc; i++) { + sprintf(xorriso->info_text, "-as %s: %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + idx_offset= 0; + for(k=0;ignored_arg0_options[k][0]!=0;k++) + if(strcmp(argv[i],ignored_arg0_options[k])==0) + goto no_volunteer; + for(k=0;ignored_arg1_options[k][0]!=0;k++) + if(strcmp(argv[i],ignored_arg1_options[k])==0) { + i++; + idx_offset= -1; + goto no_volunteer; + } + if(0) { +no_volunteer:; + sprintf(xorriso->info_text, "-as %s: Ignored option %s", + whom, Text_shellsafe(argv[i+idx_offset], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + continue; + } + + if(strcmp(argv[i], "-version")==0) { + /* was already handled in first argument scan */; + + } else if(strcmp(argv[i], "-R")==0 || strcmp(argv[i], "-rock")==0) { + /* ok */; + } else if(strcmp(argv[i], "-J")==0 || strcmp(argv[i], "-joliet")==0) { + xorriso->do_joliet= 1; + } else if(strcmp(argv[i], "-graft-points")==0) { + xorriso->allow_graft_points= 1; + } else if(strcmp(argv[i], "-path-list")==0) { + if(i+1>=argc) { +not_enough_args:; + sprintf(xorriso->info_text, "-as %s: Not enough arguments to option %s", + whom, argv[i]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + i++; + ret= Xorriso_option_path_list(xorriso, argv[i], 0); + if(ret<=0) + goto ex; + } else if(strcmp(argv[i], "-f")==0 || strcmp(argv[i], "-follow-links")==0) { + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-pad")==0) { + xorriso->padding= 300*1024; + } else if(strcmp(argv[i], "-no-pad")==0) { + xorriso->padding= 0; + } else if(strcmp(argv[i], "-print-size")==0) { + do_print_size= 1; + } else if(strcmp(argv[i], "-o")==0) { + i++; + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-help")==0) { + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-V")==0 || strcmp(argv[i], "-volid")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + ret= Xorriso_option_volid(xorriso, argv[i], 0); + if(ret<=0) + goto ex; + } else if(strcmp(argv[i], "-P")==0 || strcmp(argv[i], "-publisher")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + ret= Xorriso_option_publisher(xorriso, argv[i], 0); + if(ret<=0) + goto ex; + } else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "-quiet")==0) { + /* was already handled in first argument scan */; + + } else if(argv[i][0]=='-' && argv[i][1]!=0) { + sprintf(xorriso->info_text, "-as %s: Unknown option %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } else { + int zero= 0; + + /* implementing mkisofs tendency to map single-path pathspecs to / */ + if((!xorriso->allow_graft_points) || + Fileliste__target_source_limit(argv[i], '=', &ept, 0)<=0) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, argv[i], + eff_path, 2|4); + if(ret<=0) + goto ex; + ret= Sfile_type(eff_path, + 1|((xorriso->do_follow_param||xorriso->do_follow_links)<<2)); + if(ret==2) { + strcpy(pathspec, "/="); + } else { + pathspec[0]= '/'; + pathspec[1]= 0; + ret= Sfile_leafname(eff_path, pathspec+1, 0); + if(ret>0) + strcat(pathspec, "="); + else + pathspec[0]= 0; + } + strcat(pathspec, eff_path); + add_pt= pathspec; + } else + add_pt= argv[i]; + mem_graft_points= xorriso->allow_graft_points; + xorriso->allow_graft_points= 1; + ret= Xorriso_option_add(xorriso, 1, &add_pt, &zero, was_path<<1); + xorriso->allow_graft_points= mem_graft_points; + if(ret<=0) + goto ex; + was_path= 1; + } + } + if(do_print_size) { + ret= Xorriso_option_print_size(xorriso, 1); + if(ret<=0) + goto ex; + } + + ret= 1; +ex:; + if(was_path && !do_print_size) + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + if(do_print_size && xorriso->volset_change_pending) + Xorriso_option_rollback(xorriso, 0); + return(ret); +} + + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit2= -follow: this is not a command parameter + @return <=0 error, 1= ok , 2= iso_rr_path has been deleted +*/ +int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, + int compare_result, char *disk_path, + char *iso_rr_path, int flag) +{ + int ret, deleted= 0, is_split= 0, i, loop_count; + char sfe[5*SfileadrL]; + struct stat stbuf; + struct SplitparT *split_parts= NULL; + int split_count= 0; + char part_path[SfileadrL], *part_name; + int partno, total_parts, new_total_parts; + off_t offset, bytes, total_bytes, disk_size, first_bytes; + + if(compare_result&((1<<11)|(1<<13))) { + /* cannot open regular disk file, early eof of disk file */ + sprintf(xorriso->info_text, "Problems with reading disk file %s\n", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1); + xorriso->find_compare_result= -1; + ret= 1; goto ex; + } + xorriso->info_text[0]= 0; + is_split= !!(compare_result & (1<<17)); + + if(compare_result&(8|64)) { + /* file type, minor+major with device file */ + ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, iso_rr_path, 1); /* rm_r */ + if(ret>0) { + deleted= 1; + ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path, + (off_t) 0, (off_t) 0, 2|(flag&4)); + } + sprintf(xorriso->info_text, "Deleted and re-added "); + + } else if(compare_result&(1)) { +delete:; + /* disk_adr not existing */ + ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, iso_rr_path, 1); + deleted= 1; + sprintf(xorriso->info_text, "Deleted "); + + } else if(compare_result&(2|128|(1<<12)|(1<<14)|(1<<15))) { + /* iso_adr not existing, size, cannot open iso file, early eof of iso file + content bytes differ */ + + if(is_split) { + ret= Xorriso_identify_split(xorriso, iso_rr_path, NULL, + &split_parts, &split_count, &stbuf, 0); + if(ret<=0) + {ret= -1; goto ex;} /* (should not happen) */ + ret= lstat(disk_path, &stbuf); + if(ret==-1) + goto delete; + disk_size= stbuf.st_size; + Splitparts_get(split_parts, 0, &part_name, &partno, &total_parts, + &offset, &first_bytes, &total_bytes, 0); + new_total_parts= disk_size/first_bytes; + if(disk_size % first_bytes) + new_total_parts++; + + loop_count= split_count; + /* If disk file grew over part limit and all parts are present: + add new parts */ + if(new_total_parts > total_parts && split_count == total_parts) + loop_count= new_total_parts; + + for(i= 0; i<loop_count; i++) { + if(i<split_count) { + /* Delete old part */ + Splitparts_get(split_parts, i, &part_name, &partno, &total_parts, + &offset, &bytes, &total_bytes, 0); + strcpy(part_path, iso_rr_path); + if(Sfile_add_to_path(part_path, part_name, 0)<=0) { + Xorriso_much_too_long(xorriso, + strlen(iso_rr_path)+strlen(part_path)+1, 2); + {ret= -1; goto ex;} + } + ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, part_path, 1); + if(ret<=0) + goto ex; + } else { + partno= i+1; + offset= i*first_bytes; + } + if(disk_size<=offset) + continue; + /* Insert new part */ + if(strlen(part_path)+160>SfileadrL) { + Xorriso_much_too_long(xorriso, strlen(part_path)+160, 2); + ret= 0; goto ex; + } + Splitpart__compose(part_path+strlen(iso_rr_path)+1, partno, + new_total_parts, offset, first_bytes, disk_size, 0); + ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, part_path, + offset, bytes, 2|(flag&4)|8); + if(ret<=0) + goto ex; + } + /* Copy file attributes to iso_rr_path, augment r-perms by x-perms */ + ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 2); + if(ret<=0) + goto ex; + } else + ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path, + (off_t) 0, (off_t) 0, 2|(flag&4)); + sprintf(xorriso->info_text, "Added/overwrote "); + + } else if(compare_result&(4|16|32|256|512|1024)) { + /* access permissions, user id, group id, mtime, atime, ctime */ + + if(is_split) { + ret= Xorriso_identify_split(xorriso, iso_rr_path, NULL, + &split_parts, &split_count, &stbuf, 0); + if(ret<=0) + {ret= -1; goto ex;} /* (should not happen) */ + for(i= 0; i<split_count; i++) { + Splitparts_get(split_parts, i, &part_name, &partno, &total_parts, + &offset, &bytes, &total_bytes, 0); + strcpy(part_path, iso_rr_path); + if(Sfile_add_to_path(part_path, part_name, 0)<=0) { + Xorriso_much_too_long(xorriso, + strlen(iso_rr_path)+strlen(part_path)+1, 2); + {ret= -1; goto ex;} + } + ret= Xorriso_copy_properties(xorriso, disk_path, part_path, 0); + if(ret<=0) + goto ex; + } + /* Copy file attributes to iso_rr_path, augment r-perms by x-perms */ + ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 2); + if(ret<=0) + goto ex; + } else + ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 0); + sprintf(xorriso->info_text, "Adjusted attributes of "); + + } else + ret= 1; + if(ret>0 && xorriso->info_text[0]) { + strcat(xorriso->info_text, Text_shellsafe(iso_rr_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + } + ret= 1; +ex:; + if(split_parts!=NULL) + Splitparts_destroy(&split_parts, split_count, 0); + if(ret<=0) + return(ret); + if(deleted) + return(2); + return(1); +} + + +int Xorriso_write_session_log(struct XorrisO *xorriso, int flag) +{ + FILE *fp= NULL; + char sfe[5*SfileadrL], timetext[40], *rpt, *wpt; + + if(xorriso->session_logfile[0]==0) + return(2); + fp= fopen(xorriso->session_logfile, "a"); + if(fp==0) { + sprintf(xorriso->info_text, "-session_log: Cannot open file %s", + Text_shellsafe(xorriso->session_logfile, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + wpt= sfe; + for(rpt= xorriso->volid; *rpt!=0; rpt++) { + if(*rpt=='\n') { + *(wpt++)= '\\'; + *(wpt++)= 'n'; + } else + *(wpt++)= *rpt; + } + *wpt= 0; + fprintf(fp, "%s %d %d %s\n", + Ftimetxt(time(0), timetext, 2), xorriso->session_lba, + xorriso->session_blocks, sfe); + fclose(fp); + return(1); +} + + +/* ---------------------------- Options API ------------------------ */ + + +/* Option -abort_on */ +int Xorriso_option_abort_on(struct XorrisO *xorriso, char *severity, int flag) +{ + int ret, sev; + char sfe[5*SfileadrL]; + + ret= Xorriso__text_to_sev(severity, &sev, 0); + if(ret<=0) { + sprintf(xorriso->info_text, + "-abort_on: Not a known severity name : %s", + Text_shellsafe(severity, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + if(Sfile_str(xorriso->abort_on_text,severity,0)<=0) + return(-1); + xorriso->abort_on_severity= sev; + Xorriso_set_abort_severity(xorriso, 0); + return(1); +} + + +/* Option -add */ +/* @param flag bit0=do not report the added item + bit1=do not reset pacifier, no final pacifier message +*/ +int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, end_idx, ret, was_failure= 0, fret, optc= 0, split; + char target[SfileadrL], source[SfileadrL], *ept, eff_path[SfileadrL]; + char **optv= NULL, *rpt, *wpt; + + ret= Xorriso_opt_args(xorriso, "-add", argc, argv, *idx, &end_idx, + &optc, &optv, ((!!xorriso->allow_graft_points)<<2)|2); + if(ret<=0) + goto ex; + + if(!(flag&2)) + Xorriso_pacifier_reset(xorriso, 0); + for(i= 0; i<optc; i++) { + if(Sfile_str(target,optv[i],0)<=0) + {ret= -1; goto ex;} + strcpy(source, optv[i]); + split= 0; + if(xorriso->allow_graft_points) { + ret= Fileliste__target_source_limit(target, '=', &ept, 0); + if(ret>0) { + *ept= 0; + strcpy(source, ept+1); + split= 1; + } + /* unescape \= */; + if(split) + rpt= wpt= target; + else + rpt= wpt= source; + for(; *rpt!=0; rpt++) { + if(*rpt=='\\') + if(*(rpt+1)=='=') + continue; + *(wpt++)= *rpt; + } + *wpt= 0; + } + if(split==0) { + strcpy(target, source); + } else if(target[0]!='/') { + ret= Sfile_prepend_path(xorriso->wdi, target, 0); + if(ret<=0) + goto problem_handler; + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, target, eff_path, 2); + if(ret<=0) + goto problem_handler; + strcpy(target, eff_path); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, source,eff_path,2|4); + if(ret<=0) + goto problem_handler; + strcpy(source, eff_path); + + ret= Xorriso_graft_in(xorriso, NULL, source, target, (off_t)0, (off_t)0, 0); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n", + (ret>1 ? "directory" : "file"), target, source); + if(!(flag&1)) + Xorriso_info(xorriso, 0); + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + if(!(flag&2)) + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-add", argc, argv, *idx, &end_idx, &optc, &optv, + 256); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -add_plainly "none"|"unknown" */ +int Xorriso_option_add_plainly(struct XorrisO *xorriso, char *mode,int flag) +{ + if(strcmp(mode, "none")==0) + xorriso->add_plainly= 0; + if(strcmp(mode, "unknown")==0) + xorriso->add_plainly= 1; + else if(strcmp(mode, "dashed")==0) + xorriso->add_plainly= 2; + else if(strcmp(mode, "any")==0) + xorriso->add_plainly= 3; + else { + sprintf(xorriso->info_text, "-add_plainly: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -alter_date , -alter_date_r */ +/* @param flag bit0=recursive (-alter_date_r) +*/ +int Xorriso_option_alter_date(struct XorrisO *xorriso, + char *time_type, char *timestring, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, t_type= 0, end_idx, fret; + time_t t; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-alter_date", argc, argv, *idx, &end_idx, + &optc, &optv, 0); + if(ret<=0) + goto ex; + ret= Xorriso_convert_datestring(xorriso, "-alter_date", time_type, timestring, + &t_type, &t, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-chmod_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_ad(job, t_type, t, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else + ret= Xorriso_set_time(xorriso, optv[i], t, t_type); + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-alter_date", argc, argv, *idx, &end_idx, &optc, + &optv, 256); + Findjob_destroy(&job, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -as */ +/* @param flag bit0=do not report the added item + bit1=do not reset pacifier, no final pacifier message +*/ +int Xorriso_option_as(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int end_idx, ret, idx_count; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + idx_count= end_idx-(*idx); + if(end_idx<=0) { + if(idx_count<1) + sprintf(xorriso->info_text, + "-as : Not enough arguments given. Needed: whom do_what"); + else + sprintf(xorriso->info_text, + "-as %s : Not enough arguments given. Needed: do_what", + argv[*idx]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(strcmp(argv[*idx], "cdrecord")==0 || strcmp(argv[*idx], "wodim")==0 || + strcmp(argv[*idx], "cdrskin")==0) { + ret= Xorriso_cdrskin(xorriso, argv[*idx], end_idx-(*idx)-1, argv+(*idx)+1, + 0); + if(ret<=0) + goto ex; + } else if(strcmp(argv[*idx], "mkisofs")==0 || + strcmp(argv[*idx], "genisoimage")==0 || + strcmp(argv[*idx], "genisofs")==0) { + ret= Xorriso_genisofs(xorriso, argv[*idx], end_idx-(*idx)-1, argv+(*idx)+1, + 0); + if(ret<=0) + goto ex; + } else { + sprintf(xorriso->info_text, + "-as : Not a known emulation personality: '%s'", argv[*idx]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + ret= 1; +ex:; + (*idx)= end_idx; + return(ret); +} + + + +/* Option -ban_stdio_write */ +int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag) +{ + xorriso->ban_stdio_write= 1; + return(1); +} + + +/* Option -blank and -format */ +/* @param flag bit0= format rather than blank + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag) +{ + char drive_name[SfileadrL], *cmd= "-blank"; + int aq_ret; + int ret, aq_flag= 2, mode_flag; + + if(flag&1) + cmd= "-format"; + if(xorriso->out_drive_handle == NULL) { + sprintf(xorriso->info_text, + "%s: No output drive set by -dev -or -outdev", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(xorriso->in_drive_handle == xorriso->out_drive_handle) { + if(xorriso->volset_change_pending) { + sprintf(xorriso->info_text, + "%s: Image changes pending. -commit or -rollback first.", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + aq_flag= 3; + } + ret= Xorriso_reassure(xorriso, cmd, + "possibly make unreadable data on outdev", 0); + if(ret<=0) + return(2); + + if(strcmp(mode, "all")==0 || strcmp(mode, "full")==0) + mode_flag= 0; + else if(strcmp(mode, "deformat")==0 || strcmp(mode, "deformat_sequential")==0) + mode_flag= 2; + else if(strcmp(mode, "deformat_quickest")==0 || + strcmp(mode, "deformat_sequential_quickest")==0) + mode_flag= 3; + else if(strcmp(mode, "fast")==0 || mode[0]==0) + mode_flag= 1; + else { + sprintf(xorriso->info_text, + "%s: Unknown %s mode '%s'", + cmd, ((flag&1) ? "format" : "blank"), mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(flag&1) + ret= Xorriso_format_media(xorriso, 0); + else + ret= Xorriso_blank_media(xorriso, mode_flag); + if(ret==0) + return(ret); + strcpy(drive_name, xorriso->outdev); + if(ret!=2) { + if(ret<=0) + aq_flag= 0; + aq_ret= Xorriso_reaquire_outdev(xorriso, aq_flag); + if(ret<=0 && ret<aq_ret) + return(ret); + if(aq_ret<=0) + return(aq_ret); + } + return(1); +} + + +/* Option -boot_image */ +int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form, + char *treatment, int flag) +{ + int was_ok= 1; + char *formpt, *treatpt; + + formpt= form; + if(formpt[0]=='-') + formpt++; + treatpt= treatment; + if(treatpt[0]=='-') + treatpt++; + if(strcmp(formpt, "any")==0) { + if(strcmp(treatpt, "keep")==0) { + xorriso->keep_boot_image= 1; + xorriso->patch_isolinux_image= 0; + } else if(strcmp(treatpt, "discard")==0) { + xorriso->keep_boot_image= 0; + xorriso->patch_isolinux_image= 0; + } else + was_ok= 0; + } else if(strcmp(formpt, "isolinux")==0) { + if(strcmp(treatpt, "patch")==0) { + xorriso->keep_boot_image= 1; + xorriso->patch_isolinux_image= 1; + } else if(strcmp(treatpt, "keep")==0) { + xorriso->keep_boot_image= 1; + xorriso->patch_isolinux_image= 0; + } else if(strcmp(treatpt, "discard")==0) { + xorriso->keep_boot_image= 0; + xorriso->patch_isolinux_image= 0; + } else + was_ok= 0; + } else + was_ok= 0; + if(!was_ok) { + sprintf(xorriso->info_text, "Unrecognized options with -boot_image: %s %s", + form, treatment); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -cd alias -cdi */ +int Xorriso_option_cdi(struct XorrisO *xorriso, char *iso_rr_path, int flag) +{ + char sfe[5*SfileadrL], path[SfileadrL], eff_path[SfileadrL]; + int ret; + + if (strlen(iso_rr_path)>sizeof(xorriso->wdi)) { + sprintf(xorriso->info_text,"-cdi: iso_rr_path too long (%d > %d)", + (int) strlen(iso_rr_path), (int) sizeof(xorriso->wdi)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + Xorriso_warn_of_wildcards(xorriso, iso_rr_path, 1); + sprintf(xorriso->info_text,"previous working directory:\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->result_line,"%s/\n",Text_shellsafe(xorriso->wdi, sfe, 0)); + Xorriso_result(xorriso,0); + if(strcmp(iso_rr_path,"/")==0 || iso_rr_path[0]==0) { + strcpy(xorriso->wdi,""); + Xorriso_option_pwdi(xorriso, 0); + return(1); + } else if(iso_rr_path[0]!='/') { + strcpy(path, xorriso->wdi); + if(Sfile_add_to_path(path,iso_rr_path,0)<=0) + return(-1); + } else { + if(Sfile_str(path,iso_rr_path,0)<=0) + return(-1); + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1); + if(ret<0) + return(ret); + if(ret==0) { + sprintf(xorriso->info_text, "-cdi: not existing yet in ISO image : %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2); + if(ret<=0) + return(ret); + } else if(ret!=2) { + sprintf(xorriso->info_text, "-cdi: not a directory : %s", + Text_shellsafe(eff_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + strcpy(xorriso->wdi, eff_path); + + Xorriso_option_pwdi(xorriso, 0); + return(1); +} + + +/* Option -cdx */ +int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag) +{ + char sfe[5*SfileadrL], path[SfileadrL], eff_path[SfileadrL]; + int ret; + + if (strlen(disk_path)>sizeof(xorriso->wdx)) { + sprintf(xorriso->info_text,"-cdx: disk_path too long (%d > %d)", + (int) strlen(disk_path), (int) sizeof(xorriso->wdx)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + Xorriso_warn_of_wildcards(xorriso, disk_path, 1|2); + sprintf(xorriso->info_text,"previous working directory on hard disk:\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->result_line,"%s/\n",Text_shellsafe(xorriso->wdx, sfe, 0)); + Xorriso_result(xorriso,0); + if(strcmp(disk_path,"/")==0) { + strcpy(xorriso->wdx,""); + Xorriso_option_pwdx(xorriso, 0); + return(1); + } else if(disk_path[0]!='/') { + strcpy(path, xorriso->wdx); + if(Sfile_add_to_path(path,disk_path,0)<=0) + return(-1); + } else { + if(Sfile_str(path,disk_path,0)<=0) + return(-1); + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, path, eff_path, 2|4); + if(ret<=0) + return(ret); + if(eff_path[0]) { + ret= Sfile_type(eff_path,1|4|8); + if(ret<0) { + Xorriso_msgs_submit(xorriso, 0, eff_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text,"-cdx: file not found : %s", + Text_shellsafe(eff_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(ret!=2) { + Xorriso_msgs_submit(xorriso, 0, eff_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "-cdx: not a directory : %s", + Text_shellsafe(eff_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + if(Sfile_str(xorriso->wdx,eff_path,0)<=0) + return(-1); + Xorriso_option_pwdx(xorriso, 0); + return(1); +} + + +/* Option -chgrp alias -chgrpi , chgrp_r alias chgrpi */ +/* @param flag bit0=recursive (-chgrp_r) +*/ +int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + gid_t gid_number; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-chgrpi", argc, argv, *idx, &end_idx, &optc, + &optv, 0); + if(ret<=0) + goto ex; + ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-chgrp_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_chgrp(job, gid_number, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else + ret= Xorriso_set_gid(xorriso, optv[i], gid_number, 0); + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-chgrpi", argc, argv, *idx, &end_idx, &optc, &optv, + 256); /* clean up */ + if(ret<=0) + return(ret); + Findjob_destroy(&job, 0); + return(!was_failure); +} + + +/* Option -chmod alias -chmodi , -chmod_r alias chmod_ri */ +/* @param flag bit0=recursive (-chmod_r) +*/ +int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + mode_t mode_and= ~0, mode_or= 0; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-chmodi", argc, argv, *idx, &end_idx, &optc, + &optv, 0); + if(ret<=0) + goto ex; + ret= Xorriso_convert_modstring(xorriso, "-chmodi", + mode, &mode_and, &mode_or, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-chmod_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_chmod(job, mode_and, mode_or, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else { + ret= Xorriso_set_st_mode(xorriso, optv[i], mode_and, mode_or, 0); + } + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + ret= 0; goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-chmodi", argc, argv, *idx, &end_idx, &optc, &optv, + 256); + Findjob_destroy(&job, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -chown alias -chowni , chown_r alias chown_ri */ +/* @param flag bit0=recursive (-chown_r) +*/ +int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + uid_t uid_number; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-chowni", argc, argv, *idx, &end_idx, + &optc, &optv, 0); + if(ret<=0) + goto ex; + ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-chown_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_chown(job, uid_number, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else + ret= Xorriso_set_uid(xorriso, optv[i], uid_number, 0); + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + ret= 0; goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-chowni", argc, argv, *idx, &end_idx, + &optc, &optv, 256); + Findjob_destroy(&job, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -close "on"|"off" */ +int Xorriso_option_close(struct XorrisO *xorriso, char *mode, int flag) +{ + xorriso->do_close= !!strcmp(mode, "off"); + return(1); +} + + +/* Option -commit */ +/* @param flag bit0= leave indrive and outdrive aquired as they were, + i.e. do not aquire outdrive as new in-out-drive + bit1= do not perform eventual -reassure + @return <=0 error , 1 success, 2 revoked by -reassure , 3 no change pending +*/ +int Xorriso_option_commit(struct XorrisO *xorriso, int flag) +{ + int ret; + char newdev[SfileadrL]; + + if(!xorriso->volset_change_pending) { + sprintf(xorriso->info_text, "-commit: No image modifications pending"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(3); + } + if(!(flag&2)) { + ret= Xorriso_reassure(xorriso, "-commit", + "write the pending image changes to media", 0); + if(ret<=0) + return(2); + } + Xorriso_process_errfile(xorriso, 0, "burn session start", 0, 1); + ret= Xorriso_write_session(xorriso, 0); + Xorriso_process_errfile(xorriso, 0, "burn session end", 0, 1); + if(ret<=0) + return(ret); + Xorriso_write_session_log(xorriso, 0); + xorriso->volset_change_pending= 0; + xorriso->no_volset_present= 0; + if(flag&1) + return(1); + strcpy(newdev, xorriso->outdev); + ret= Xorriso_option_dev(xorriso, newdev, 3|4); + return(ret); +} + + +/* Option -commit_eject */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_commit_eject(struct XorrisO *xorriso, char *which, int flag) +{ + int ret, eret; + + ret= Xorriso_option_commit(xorriso, 1); + if(ret<=0 || ret==2 || ret==3) + return(ret); + if(strcmp(which, "none")==0) + eret= 1; + else + eret= Xorriso_option_eject(xorriso, which, 1); + ret= Xorriso_option_dev(xorriso, "", 3|4); + if(eret<ret) + return(eret); + return(ret); +} + + +/* Options -compare and -compare_r + @param flag bit0= issue summary message + bit1= do not reset pacifier, no final pacifier message + bit2= do not issue pacifier messages at all + bit3= recursive: -compare_r +*/ +int Xorriso_option_compare(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag) +{ + int ret, mem_pci, zero= 0, result, follow_links; + double mem_lut= 0.0; + char *ipth, *argv[6]; + + ipth= iso_path; + if(ipth[0]==0) + ipth= disk_path; + + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + mem_pci= xorriso->pacifier_interval; + xorriso->pacifier_interval= 5.0; + + if(flag&8) { + xorriso->find_compare_result= 1; + argv[0]= ipth; + argv[1]= "-exec"; + argv[2]= "compare"; + argv[3]= disk_path; + zero= 0; + ret= Xorriso_option_find(xorriso, 4, argv, &zero, 2); /* -findi */ + if(ret>0) { + argv[0]= disk_path; + argv[1]= "-exec"; + argv[2]= "not_in_iso"; + argv[3]= ipth; + zero= 0; + ret= Xorriso_option_find(xorriso, 4, argv, &zero, 1|2); /* -findx */ + if(ret>0 && !xorriso->do_follow_mount) { + argv[0]= disk_path; + argv[1]= "-type"; + argv[2]= "m"; + argv[3]= "-exec"; + argv[4]= "is_full_in_iso"; + argv[5]= ipth; + zero= 0; + ret= Xorriso_option_find(xorriso, 6, argv, &zero, 1|2); /* -findx */ + } + if(ret>0) + ret= xorriso->find_compare_result; + else + ret= -1; + } else + ret= -1; + } else { + follow_links= (xorriso->do_follow_links || xorriso->do_follow_param) << 28; + ret= Xorriso_compare_2_files(xorriso, disk_path, ipth, "", &result, + 2 | follow_links | ((flag&4)<<27) | (1<<30)); + } + + xorriso->pacifier_interval= mem_pci; + if(mem_lut!=xorriso->last_update_time && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 1); + if(ret>0) { + sprintf(xorriso->result_line, + "Both file objects match as far as expectable.\n"); + } else if(ret==0) { + sprintf(xorriso->result_line, "Differences detected.\n"); + } else { + sprintf(xorriso->result_line, "Comparison failed due to error.\n"); + } + if(flag&1) + Xorriso_result(xorriso,0); + if(ret<0) + return(ret); + return(1); +} + + +/* Option -cpr alias -cpri */ +int Xorriso_option_cpri(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, ret, is_dir= 0, was_failure= 0, fret, end_idx_dummy; + char eff_origin[SfileadrL], eff_dest[SfileadrL]; + char dest_dir[SfileadrL], leafname[SfileadrL]; + int optc= 0; + char **optv= NULL; + + ret= Xorriso_cpmv_args(xorriso, "-cpri", argc, argv, idx, + &optc, &optv, eff_dest, 1|2); + if(ret<=0) + goto ex; + if(ret==2) { + is_dir= 1; + strcpy(dest_dir, eff_dest); + } + + /* Perform graft-ins */ + Xorriso_pacifier_reset(xorriso, 0); + for(i= 0; i<optc && !xorriso->request_to_abort; i++) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, optv[i], eff_origin, + 2|4); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + if(is_dir) { + ret= Sfile_leafname(eff_origin, leafname, 0); + if(ret<=0) + goto problem_handler; + strcpy(eff_dest, dest_dir); + ret= Sfile_add_to_path(eff_dest, leafname, 0); + if(ret<=0) { + printf(xorriso->info_text, "Effective path gets much too long (%d)", + strlen(eff_dest)+strlen(leafname)+1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto problem_handler; + } + } + ret= Xorriso_graft_in(xorriso, NULL, eff_origin, eff_dest, + (off_t) 0, (off_t) 0, 0); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n", + (ret>1 ? "directory" : "file"), eff_dest, eff_origin); + if(!(flag&1)) + Xorriso_info(xorriso, 0); + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + ret= !was_failure; +ex:; + Xorriso_opt_args(xorriso, "-cpri", + argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256); + return(ret); +} + + +/* SPLIT : proposed target format + part_{partno}_of_{total_parts}_at_{offset}_with_{bytes}_of_{total_bytes} +*/ + +/* Option -cut_out */ +int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path, + char *start, char *count, char *iso_rr_path, int flag) +{ + int ret; + double num; + off_t startbyte, bytecount; + + num= Scanf_io_size(start, 0); + if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */ + sprintf(xorriso->info_text, + "-cut_out: startbyte address negative or much too large (%s)", start); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + startbyte= num; + num= Scanf_io_size(count, 0); + if(num<=0 || num > 1.0e18) { + sprintf(xorriso->info_text, + "-cut_out: bytecount zero, negative or much too large (%s)", count); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + bytecount= num; + sprintf(xorriso->info_text, + "-cut_out from %s , byte %.f to %.f, and graft as %s", + disk_path, (double) startbyte, (double) (startbyte+bytecount), + iso_rr_path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + + ret= Xorriso_cut_out(xorriso, disk_path, startbyte, bytecount, + iso_rr_path, 0); + return(ret); +} + + +/* Options -dev , -indev, -outdev */ +/** @param flag bit0= use as indev + bit1= use as outdev + bit2= do not -reassure + bit3= regard overwriteable media as blank + bit4= if the drive is a regular disk file: truncate it to + the write start address + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag) +{ + int ret; + char sfe[5*SfileadrL], *adr; + + adr= in_adr; + if(strcmp(in_adr, "-")==0) + adr= "stdio:/dev/fd/1"; + if(strncmp(adr, "stdio:", 6)==0) { + if(strlen(adr)==6 || strcmp(adr, "stdio:/")==0 || + strcmp(adr, "stdio:.")==0 || strcmp(adr, "stdio:..")==0 || + strcmp(adr, "stdio:-")==0) { + sprintf(xorriso->info_text, + "No suitable path given by device address '%s'", adr); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(xorriso->ban_stdio_write) { + sprintf(xorriso->info_text, + "Drive address banned by -ban_stdio_write : '%s'", adr); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + + if(xorriso->volset_change_pending && (flag&1)) { + sprintf(xorriso->info_text, + "%s: Image changes pending. -commit or -rollback first", + (flag&2) ? "-dev" : "-indev"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if((flag&1) && !(flag&4)) { + ret= Xorriso_reassure(xorriso, (flag&2) ? "-dev" : "-indev", + "eventually discard the current image", 0); + if(ret<=0) + return(2); + } + + if(adr[0]==0) { + if((flag&1) && xorriso->in_drive_handle != NULL) { + if(xorriso->in_drive_handle == xorriso->out_drive_handle) + sprintf(xorriso->info_text,"Giving up -dev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + else + sprintf(xorriso->info_text,"Giving up -indev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + if((flag&2) && xorriso->in_drive_handle != NULL && + xorriso->in_drive_handle != xorriso->out_drive_handle) { + sprintf(xorriso->info_text,"Giving up -outdev %s", + Text_shellsafe(xorriso->outdev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + ret= Xorriso_give_up_drive(xorriso, flag&3); + } else + ret= Xorriso_aquire_drive(xorriso, adr, (flag&3)|((flag&(8|16))>>1)); + if(ret<=0) + return(ret); + return(1); +} + + +/* Option -devices */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_devices(struct XorrisO *xorriso, int flag) +{ + int ret; + char sfe[5*SfileadrL]; + + if(xorriso->volset_change_pending) { + sprintf(xorriso->info_text, + "-devices: Image changes pending. -commit or -rollback first"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Xorriso_reassure(xorriso, "-devices", + "eventually discard the current image", 0); + if(ret<=0) + return(2); + xorriso->info_text[0]= 0; + if(xorriso->in_drive_handle!=NULL || xorriso->out_drive_handle!=NULL) { + if(xorriso->in_drive_handle == xorriso->out_drive_handle) { + sprintf(xorriso->info_text, "Gave up -dev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + }else { + if(xorriso->in_drive_handle!=NULL) { + sprintf(xorriso->info_text, "Gave up -indev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + if(xorriso->out_drive_handle!=NULL) { + sprintf(xorriso->info_text, "Gave up -outdev %s", + Text_shellsafe(xorriso->outdev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + } + Xorriso_give_up_drive(xorriso, 3); + } + ret= Xorriso_show_devices(xorriso, 0); + return(ret); +} + + +/* Option -dialog "on"|"off" */ +int Xorriso_option_dialog(struct XorrisO *xorriso, char *mode, int flag) +{ + xorriso->dialog= !!strcmp(mode, "off"); + return(1); +} + + +/* Option -disk_pattern "on"|"ls"|"off" */ +int Xorriso_option_disk_pattern(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_disk_pattern= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_disk_pattern= 1; + else if(strcmp(mode, "ls")==0) + xorriso->do_disk_pattern= 2; + else { + sprintf(xorriso->info_text, "-disk_pattern: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -dummy "on"|"off" */ +int Xorriso_option_dummy(struct XorrisO *xorriso, char *mode, int flag) +{ + xorriso->do_dummy= !!strcmp(mode, "off"); + return(1); +} + + +/* Option -eject */ +/* @param flag bit0=do not report toc of eventually remaining drives +*/ +int Xorriso_option_eject(struct XorrisO *xorriso, char *which, int flag) +{ + int gu_flag= 4, ret; + + if(strncmp(which,"in",2)==0) + gu_flag|= 1; + else if(strncmp(which,"out",3)==0) + gu_flag|= 2; + else + gu_flag|= 3; + if((gu_flag&1) && xorriso->volset_change_pending) { + sprintf(xorriso->info_text, + "-eject: Image changes pending. -commit or -rollback first"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(flag&1) + gu_flag|= 8; + ret= Xorriso_give_up_drive(xorriso, gu_flag); + return(ret); +} + + +/* Options -end , and -rollback_end */ +/* @param flag bit0= discard pending changes + bit1= do not -reassure + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_end(struct XorrisO *xorriso, int flag) +{ + int ret; + char *cmd, *which_will; + + if(flag&1) + cmd= "-rollback_end"; + else + cmd= "-end"; + if(xorriso->volset_change_pending) { + if(flag&1) + which_will= "end the program discarding image changes"; + else + which_will= "commit image changes and then end the program"; + } else { + which_will= "end the program"; + } + if(!(flag&2)) { + ret= Xorriso_reassure(xorriso, cmd, which_will, 0); + if(ret<=0) + return(2); + } + + if(xorriso->volset_change_pending) { + if(flag&1) { + xorriso->volset_change_pending= 0; + } else { + ret= Xorriso_option_commit(xorriso, 1); + xorriso->volset_change_pending= 0; /* no further tries to commit */ + if(ret<=0) + return(ret); + } + } + ret= Xorriso_give_up_drive(xorriso, 3); + if(ret<=0) + return(ret); + return(1); +} + + +/* Option -errfile_log marked|plain path|-|"" */ +int Xorriso_option_errfile_log(struct XorrisO *xorriso, + char *mode, char *path, int flag) +{ + int ret, mode_word; + FILE *fp= NULL; + char sfe[5*SfileadrL]; + + if(path[0]==0 || path[0]=='-') { + /* ok */; + } else { + fp= fopen(path, "a"); + if(fp==0) { + sprintf(xorriso->info_text, "-errfile_log: Cannot open file %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + mode_word= xorriso->errfile_mode; + if(strcmp(mode, "marked")==0) + mode_word|= 1; + else if(strcmp(mode, "plain")==0) + mode_word&= ~1; + else { + sprintf(xorriso->info_text, "-errfile_log: Unknown mode %s", + Text_shellsafe(mode, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + + Xorriso_process_errfile(xorriso, 0, "log end", 0, 1); + if(xorriso->errfile_fp!=NULL) + fclose(xorriso->errfile_fp); + xorriso->errfile_fp= fp; + xorriso->errfile_mode= mode_word; + ret= Sfile_str(xorriso->errfile_log, path, 0); + if(ret>0) + ret= Xorriso_process_errfile(xorriso, 0, "log start", 0, 1); + if(ret<=0) + return(ret); + return(1); +} + + +/* Option -follow */ +int Xorriso_option_follow(struct XorrisO *xorriso, char *mode, int flag) +{ + int was_fl, was_fm, was_fpr, was_fpt, l; + double num; + char *cpt, *npt; + + was_fpt= xorriso->do_follow_pattern; + was_fpr= xorriso->do_follow_param; + was_fl= xorriso->do_follow_links; + was_fm= xorriso->do_follow_mount; + xorriso->do_follow_pattern= 0; + xorriso->do_follow_param= 0; + xorriso->do_follow_links= 0; + xorriso->do_follow_mount= 0; + npt= cpt= mode; + for(cpt= mode; npt!=NULL; cpt= npt+1) { + npt= strchr(cpt,':'); + if(npt==NULL) + l= strlen(cpt); + else + l= npt-cpt; + if(l==0) + goto unknown_mode; + if(strncmp(cpt, "off", l)==0) { + xorriso->do_follow_pattern= 0; + xorriso->do_follow_param= 0; + xorriso->do_follow_links= 0; + xorriso->do_follow_mount= 0; + } else if(strncmp(cpt, "on", l)==0) { + xorriso->do_follow_pattern= 1; + xorriso->do_follow_param= 1; + xorriso->do_follow_links= 1; + xorriso->do_follow_mount= 1; + } else if(strncmp(cpt, "default", l)==0) { + xorriso->do_follow_pattern= 1; + xorriso->do_follow_param= 0; + xorriso->do_follow_links= 0; + xorriso->do_follow_mount= 1; + xorriso->follow_link_limit= 100; + } else if(strncmp(cpt, "link", l)==0 || strncmp(cpt,"links", l)==0) { + xorriso->do_follow_links= 1; + } else if(strncmp(cpt, "mount", l)==0) { + xorriso->do_follow_mount= 1; + } else if(strncmp(cpt,"param", l)==0) { + xorriso->do_follow_param= 1; + } else if(strncmp(cpt, "pattern", l)==0) { + xorriso->do_follow_pattern= 1; + } else if(strncmp(cpt, "limit=", 6)==0) { + sscanf(cpt+6, "%lf", &num); + if(num<=0 || num>1.0e6) { + sprintf(xorriso->info_text, "-follow: Value too %s with '%s'", + num<=0 ? "small" : "large", cpt+6); + goto sorry_ex; + } + xorriso->follow_link_limit= num; + } else { +unknown_mode:; + if(l<SfileadrL) + sprintf(xorriso->info_text, "-follow: unknown mode '%s'", cpt); + else + sprintf(xorriso->info_text, "-follow: oversized mode parameter (%d)",l); +sorry_ex: + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + xorriso->do_follow_pattern= was_fpt; + xorriso->do_follow_param= was_fpr; + xorriso->do_follow_links= was_fl; + xorriso->do_follow_mount= was_fm; + return(0); + } + } + return(1); +} + + +/* Option -find alias -findi, and -findx */ +/* @param flag bit0= -findx rather than -findi + bit1= do not reset pacifier, no final pacifier message + do not reset find_compare_result + bit2= do not count deleted files with rm and rm_r +*/ +int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int ret, i, end_idx, type= 0, action, deleter= 0; + struct FindjoB *job, *first_job= NULL, *new_job; + char *start_path, sfe[5*SfileadrL], *cpt, other_path_start[SfileadrL]; + struct stat dir_stbuf; + uid_t user= 0; + gid_t group= 0; + time_t date= 0; + mode_t mode_or= 0, mode_and= ~1; + double mem_lut= 0.0; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + start_path= "."; + if(end_idx > *idx && start_path[0]!=0) + start_path= argv[*idx]; + ret= Findjob_new(&first_job, start_path, 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find[ix]", 0); + {ret= -1; goto ex;} + } + job= first_job; + if(!(flag&2)) + xorriso->find_compare_result= 1; + for(i= *idx+1; i<end_idx; i++) { + if(strcmp(argv[i], "-name")==0) { + if(i+1>=end_idx) { +not_enough_arguments:; + sprintf(xorriso->info_text, + "-find[ix]: not enough arguments with -exec %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } + i++; + ret= Findjob_set_name_expr(job, argv[i], 0); + if(ret<=0) { + sprintf(xorriso->info_text, "-find[ix]: cannot set -name expression %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } + } else if(strcmp(argv[i], "-exec")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + cpt= argv[i]; + if(*cpt=='-') + cpt++; + if(strcmp(cpt, "echo")==0) { + Findjob_set_action_target(job, 0, NULL, 0); + } else if(strcmp(cpt, "rm")==0) { + Findjob_set_action_target(job, 1, NULL, 0); + deleter= 1; + } else if(strcmp(cpt, "rm_r")==0) { + Findjob_set_action_target(job, 2, NULL, 0); + deleter= 1; + +#ifdef NIX +/* >>> not implemented yet */; + } else if(strcmp(cpt, "mv")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + Findjob_set_action_target(job, 3, argv[i], 0); +#endif + + } else if(strcmp(cpt, "chown")==0 || strcmp(cpt, "chown_r")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Xorriso_convert_uidstring(xorriso, argv[i], &user, 0); + if(ret<=0) + goto ex; + ret= Findjob_set_action_chown(job, user, strlen(cpt)>5); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find -exec chown_r", 0); + goto ex; + } + } else if(strcmp(cpt, "chgrp")==0 || strcmp(cpt, "chgrp_r")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Xorriso_convert_gidstring(xorriso, argv[i], &group, 0); + if(ret<=0) + goto ex; + ret= Findjob_set_action_chgrp(job, group, strlen(cpt)>5); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find -exec chgrp_r", 0); + goto ex; + } + } else if(strcmp(cpt, "chmod")==0 || strcmp(cpt, "chmod_r")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Xorriso_convert_modstring(xorriso, "-find -exec chmod", + argv[i], &mode_and, &mode_or, 0); + if(ret<=0) + goto ex; + ret= Findjob_set_action_chmod(job, mode_and, mode_or, strlen(cpt)>5); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find -exec chmod_r", 0); + goto ex; + } + } else if(strcmp(cpt, "alter_date")==0 || strcmp(cpt, "alter_date_r")==0){ + if(i+2>=end_idx) + goto not_enough_arguments; + i+= 2; + ret= Xorriso_convert_datestring(xorriso, "-find -exec alter_date", + argv[i-1], argv[i], &type, &date, 0); + if(ret<=0) + goto ex; + ret= Findjob_set_action_ad(job, type, date, strlen(cpt)>10); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find -exec alter_date_r", 0); + goto ex; + } + } else if(strcmp(cpt, "lsdl")==0) { + Findjob_set_action_target(job, 8, NULL, 0); + + } else if(strcmp(cpt, "find")==0) { + ret= Findjob_new(&new_job, "", 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find[ix]", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_subjob(job, 13, new_job, 0); + job= new_job; + + } else if(strcmp(cpt, "compare")==0 || strcmp(cpt, "update")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + action= 14; + if(strcmp(cpt, "update")==0) + action= 17; + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, argv[i], + other_path_start, 1|2|4|8); + if(ret<=0) + goto ex; + Findjob_set_action_target(job, action, other_path_start, 0); + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, start_path,sfe, 1|2|4); + if(ret<=0) + goto ex; + Findjob_set_start_path(job, sfe, 0); + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + } else if(strcmp(cpt, "in_iso")==0 || + strcmp(cpt, "not_in_iso")==0 || + strcmp(cpt, "add_missing")==0 || + strcmp(cpt, "empty_iso_dir")==0 || + strcmp(cpt, "is_full_in_iso")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, argv[i], + other_path_start, 1|2|4); + if(ret<=0) + goto ex; + if(strcmp(cpt, "in_iso")==0) + action= 15; + else if(strcmp(cpt, "add_missing")==0) + action= 18; + else if(strcmp(cpt, "empty_iso_dir")==0) + action= 19; + else if(strcmp(cpt, "is_full_in_iso")==0) + action= 20; + else + action= 16; + Findjob_set_action_target(job, action, other_path_start, 0); + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, start_path, sfe, + 1|2|4|8); + if(ret<=0) + goto ex; + Findjob_set_start_path(job, sfe, 0); + + } else { + sprintf(xorriso->info_text, "-find -exec: unknown action %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } + } else if(strcmp(argv[i], "-type")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Findjob_set_file_type(job, argv[i][0], 0); + if(ret<=0) { + sprintf(xorriso->info_text, "-find[ix]: unknown -type '%c'",argv[i][0]); + goto sorry_ex; + } + } else { + sprintf(xorriso->info_text, "-find[ix]: unknown option %s", + Text_shellsafe(argv[i], sfe, 0)); +sorry_ex:; + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + } + if(flag&1) + ret= Xorriso_findx(xorriso, first_job, "", start_path, &dir_stbuf, 0, NULL, + 0); + else + ret= Xorriso_findi(xorriso, first_job, NULL, (off_t) 0, NULL, + start_path, &dir_stbuf, 0, (flag&4)>>1); +ex:; + if(deleter && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "iso_rr_paths deleted", + xorriso->pacifier_count, 0, "", 1|2); + else if(mem_lut!=xorriso->last_update_time && mem_lut!=0.0 && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 1); + Findjob_destroy(&first_job, 0); + (*idx)= end_idx; + return(ret); +} + + +/* Option -fs */ +int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag) +{ + double num; + + num= Scanf_io_size(size, 0); + if(num < 64*1024 || num > 1024.0 * 1024.0 * 1024.0) { + sprintf(xorriso->info_text, "-fs: wrong size %.f (allowed: %.f - %.f)", + num, 64.0 * 1024.0, 1024.0 * 1024.0 * 1024.0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->fs= num / 2048.0; + if(xorriso->fs * 2048 < num) + xorriso->fs++; + return(1); +} + + +/* Option -gid */ +int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag) +{ + int ret; + + xorriso->do_global_gid= 0; + if(gid[0]==0 || strcmp(gid,"-")==0) + return(1); + ret= Xorriso_convert_gidstring(xorriso, gid, &(xorriso->global_gid), 0); + if(ret>0) + xorriso->do_global_gid= 1; + return(ret); +} + + +/* Option -help and part of -prog_help */ +int Xorriso_option_help(struct XorrisO *xorriso, int flag) +{ + static char text[][80]={ + +#ifdef Xorriso_no_helP + +"This binary program does not contain a help text.", +"If available, read: man 1 xorriso", + +#else + +"This program creates, loads, manipulates and writes ISO 9660 filesystem", +"images with Rock Ridge extensions. Write targets can be drives with optical", +"media or local filesystem objects.", +"", +"Preparation options:", +"Drive addresses are either /dev/... as listed with option -devices or", +"disk files with prefix \"stdio:\", e.g. stdio:/tmp/pseudo_drive .", +" -dev address Set input and output drive and load eventual ISO image.", +" Set the image expansion method to growing.", +" -indev address Set input drive and load eventual ISO image. Switch from", +" growing to modifying.", +" -outdev address", +" Set output drive and switch from growing to modifying.", +" -ban_stdio_write", +" Allow for writing only the usage of optical drives.", +" -blank \"fast\"|\"all\"|\"deformat\"|\"deformat_quickest\"", +" Blank media resp. invalidate ISO image on media.", +" -format \"full\"", +" Format DVD-RW to overwriteable state or de-ice DVD+RW.", +" -volid volume_id", +" Specifies the volume ID text. (32 chars out of [A-Z0-9_])", +" -publisher name", +" Specifies the publisher name. (128 chars)", +" -joliet \"on\"|\"off\"", +" Generate Joliet info additional to Rock Ridge info.", +" -bootimage \"any\"|\"isolinux\" \"discard\"|\"keep\"|\"patch\"", +" Whether to discard or keep an exiting El-Torito boot image.", +"", +" -uid uid User id to be used for the whole multi-session ISO image.", +" -gid gid Group id for the same purpose.", +"", +" -devices Show list of available optical drives and their addresses.", +"", +" -toc Show media specific table of content. (MMC, not ISO 9660)", +"", +" -print-size Print the foreseeable consumption by next -commit.", +"", +" -tell_media_space", +" Print foreseeable available space on output media", +"", +"Manipulation options:", +"disk_path is a path to an object in the local filesystem tree.", +"iso_rr_path is the Rock Ridge name of a file object in the ISO image.", +"pathspec is either a disk_path or (if allowed) a pair: iso_rr_path=disk_path", +"Options with variable length path list [...] need \"--\" as end mark", +"if they are followed by another option. In dialog and with options read from", +"files, the line end serves as such a mark. With program arguments this mark", +"can be omitted only with the last option in the list of arguments.", +"Options marked by [***] have variable argument length and perform pattern", +"expansion if enabled by -iso_rr_pattern resp. -disk_pattern.", +"", +" -pathspecs \"on\"|\"off\" Allow or disallow pathspecs of form ", +" iso_rr_path=disk_path . Only \"off\" allows eventual", +" -disk_pattern expansion.", +" -add pathspec [...] | disk_path [***]", +" Insert the given files or directory trees from", +" filesystem into the ISO image. Much like mkisofs.", +" -add_plainly \"none\"|\"unknown\"|\"dashed\"|\"any\"", +" Whether to add lonely arguments as pathspec resp. disk_path.", +" -path-list disk_path", +" Like -add but read the pathspecs from file disk_path.", +"", +" -update disk_path iso_rr_path", +" Compare both file objects and do what is necessary to make", +" iso_rr_path a matching copy of disk_path.", +" -update_r disk_path iso_rr_path", +" Like -update but affecting all files below directories.", +" -cpr disk_path [...] iso_rr_path", +" Insert the given files or directory trees from filesystem", +" into the ISO image.", +" -cut_out disk_path byte_offset byte_count iso_rr_path", +" Map a byte interval of a regular disk file into a regular", +" file in the ISO image.", +"", +" -rm iso_rr_path [***]", +" Delete the given files from the ISO image.", +" -rm_r iso_rr_path [***]", +" Delete the given directory trees from ISO image.", +" -mv iso_rr_path [***] iso_rr_path", +" Rename the given file objects in the ISO tree to the last", +" argument in the list.", +" -chown uid iso_rr_path [***]", +" Equivalent to chown in the ISO image.", +" -chown_r uid iso_rr_path [***]", +" Like -chown but affecting all files below directories.", +" -chgrp gid iso_rr_path [***]", +" Equivalent to chgrp in the ISO image.", +" -chgrp_r gid iso_rr_path [***]", +" Like -chgrp but affecting all files below directories.", +" -chmod mode iso_rr_path [***]", +" Equivalent to chmod in the ISO image.", +" -chmod_r mode iso_rr_path [***]", +" Like -chmod but affecting all files below directories.", +" -alter_date type timestring iso_rr_path [***]", +" Alter the date entries of a file in the ISO image. type is", +" one of \"a\", \"m\", \"b\" for:", +" access time, modification time, both times.", +" -alter_date_r type timestring iso_rr_path [***]", +" Like -alter_date but affecting all files below directories.", +" -find iso_rr_path [-name pattern] [-type t] [-exec action [params]]", +" performs an action on files below the current working", +" directory in the ISO image. If -name pattern is given", +" then only files with matching leaf names are processed.", +" If -type is given then only files with matching type are", +" processed. Types: block,char,dir,pipe,file,link,socket.", +" action may be one of: echo, chown, chown_r, chgrp, chgrp_r", +" chmod, chmod_r, alter_date, alter_date_r, lsdl, compare,", +" rm, rm_r, compare, update, find.", +" params are their arguments except iso_rr_path.", +" I.e. echo, lsdl, rm, rm_r have no params at all.", +" -mkdir iso_rr_path [...]", +" Create empty directories if they do not exist yet.", +" -rmdir iso_rr_path [***]", +" Delete empty directories.", +" -- Mark end of particular action argument list.", +"", +" -follow \"on\"|\"pattern:param:link:mount:limit=#\"|\"default\"|\"off\"", +" Follow symbolic links and mount points within disk_path.", +" -overwrite \"on\"|\"nondir\"|\"off\"", +" Allow or disallow to overwrite existing files in ISO image.", +" -split_size number[\"k\"|\"m\"]", +" Set the threshold for automatic splitting of regular files.", +" -reassure \"on\"|\"tree\"|\"off\"", +" If \"on\" then ask the user for \"y\" or \"n\" with any", +" file before deleting or overwriting it in the ISO image.", +"", +"Write-to-media options:", +"", +" -rollback Discard the manipulated ISO image and reload it.", +"", +" -commit Perform the write operation and then perform -dev outdrive.", +" Hint: To perform a final write operation with no new -dev", +" and no new loading of image, execute option -end.", +" -commit_eject \"in\"|\"out\"|\"all\"|\"none\"", +" Like -commit but rather eject than load image from outdrive.", +" Give up any unejected drive afterwards.", +" -close \"on\"|\"off\"", +" If \"on\" then mark the written media as not appendable.", +" -padding number[\"k\"|\"m\"]", +" Append extra bytes to image stream. (Default is 300k)", +" -dummy \"on\"|\"off\"", +" If \"on\" simulate burning. Refuse if media cannot simulate.", +" -speed number[\"k\"|\"m\"|\"[x]CD\"|\"[x]DVD\"]", +" Set the burn speed. Default is 0 = maximum speed.", +" -fs number[\"k\"|\"m\"]", +" Set the size of the fifo buffer. (Default is 4m)", +" -eject \"in\"|\"out\"|\"all\"", +" Immediately eject the media in -indev, resp. -outdev,", +" resp. both.", +"", +"Navigation options:", +"", +" -cd iso_rr_path Change working directory in the ISO image. iso_rr_paths", +" which do not begin with '/' will be inserted beginning at", +" the path given with -cd. -ls patterns will eventually", +" looked up at this path.", +" -cdi disk_path Same as -cd disk_path", +" -cdx disk_path Change the current working directory in the local", +" filesystem. disk_paths which do not begin with '/'", +" will be looked up beginning at the path given with -cdx.", +" -lsx patterns will eventually be looked up at this path.", +" -pwd tells the current working directory in the ISO image.", +" -pwdi same as -pwd.", +" -pwdx tells the current working directory in the local filesystem.", +"", +" -iso_rr_pattern \"on\"|\"ls\"|\"off\"", +" Enable or disable pattern expansions for ISO image commands", +" marked by [***]. \"ls\" restricts it to -ls and -du.", +" -disk_pattern \"on\"|\"ls\"|\"off\"", +" Enable or disable pattern expansions for local filesystem", +" commands marked by [***]. \"ls\" restricts to -ls*x and -du*x.", +"", +" -ls pattern [***] lists files of the ISO image which match one of the", +" given shell parser patterns. (I.e. wildcards '*' '?').", +" Directories are listed by their content.", +" -lsd pattern [***] like -ls but listing directories as single items.", +" -lsl pattern [***] like -ls but also telling some file attributes.", +" -lsdl pattern [***] like -lsd but also telling some file attributes.", +"", +" -lsx pattern [***] lists files of the local filesystem which match one", +" of the patterns. Directories are listed by their content.", +" -lsdx pattern [***] like -lsx but listing directories as single items.", +" -lslx pattern [***] like -lsx but also telling some file attributes.", +" -lsdlx pattern [***] like -lsdx but also telling some file attributes.", +"", +" -du pattern [***] recursively lists sizes of files or directories in the", +" ISO image which match one of the shell parser patterns.", +" -dux pattern [***] recursively lists sizes of files or directories in the", +" local filesystem which match one of the shell parser", +" patterns.", +" -dus pattern [***] like -du but summing up subdirectories without", +" listing them explicitely.", +" -dusx pattern [***] like -dux but summing up subdirectories without", +" listing them explicitely.", +"", +" -findx disk_path [-name pattern] [-type t] [-exec action [params]]", +" Like -find but operating on local filesystem. Most -exec", +" actions are defaulted to action is always echo. Supported", +" actions are: in_iso, not_in_iso, is_full_in_iso,", +" add_missing, empty_iso_dir.", +"", +" -compare disk_path iso_rr_path", +" compare attributes and in case of regular data files the", +" content of filesystem object and ISO object.", +" -compare_r disk_path iso_rr_path ", +" Like -compare but affecting all files below directories.", +"", +"Compatibility emulation (argument list may be ended by --):", +" -as mkisofs [-help|-o|-R|-J|-V|-P|-f|-graft-points|-path-list|pathspecs]", +" Perform some mkisofs gestures, understand pathspecs as mkisofs", +" does. Commit happens outside emulation at usual occasions.", +" -as cdrecord [-help|-v|dev=|speed=|blank=|fs=|-eject|-atip|padsize=|path|-]", +" Perform some cdrecord gestures, eventually write at most one", +" data track to blank or overwriteable media.", +"", +"General options:", +" -help Print this text", +" -abort_on severity Set the threshhold for events to abort the program.", +" Useful severities: NEVER, ABORT, FATAL, FAILURE, SORRY, WARNING", +" -return_with severity exit_value Set the threshhold for events to return", +" at program end the given exit_value even if not aborted.", +" exit_value may be 0 or 32 to 63.", +" -report_about severity Set the threshhold for events to be reported.", +" Use -abort_on severities or: HINT, NOTE, UPDATE, DEBUG, ALL", +" -dialog After all arguments are processed, enter dialog mode.", +" In this mode you may enter searchtexts or any of the options", +" described here. One per line.", +" -dialog_reset Revoke -dialog (works only if given as argument)", +" -page len width Prompt user after len output lines (0=no prompt).", +" width (default 80) can adjust line number computation", +" to the output terminal's line width.", +#ifdef Xorriso_with_readlinE +" -use_stdin Use raw standard input even if libreadline is available", +" -use_readline Use libreadline for dialog if available", +" -history text Copy text into libreadline history. This command", +" itself is not copied to the history list.", +#endif /* Xorriso_with_readlinE */ +" -pkt_output \"on\"|\"off\" Direct output to stdout and prefix each line", +" by a short header which tells channel id and a mode number.", +" Each such output packet is finalized by a newline.", +" Channel ids are 'R:' for result lines, 'I:' for notes", +" and error messages, 'M:' for -mark texts. Bit 0 of the", +" mode number tells whether the newline is also part of the", +" packet payload. Example of a info message with newline:", +" I:1: enter option text :", +" -pkt_output:on is intended for use by frontend programs.", +" -logfile channel fileaddress Copy output of a channel to the given file.", +" channel may be 'R','I','M' as with -pkt_output or '.'", +" for the consolidated -pkt_output stream.", +" -mark text If text is not empty it will get put out each time an", +" option is completed.", +" -temp_mem_limit number[\"k\"|\"m\"]", +" Set the maximum size for pattern expansion. (Default is 16m)", +" -prog text Use text as this program's name in subsequent messages", +" -prog_help text Use text as this program's name and perform -help", +" -status mode|filter Report the current settings of persistent options.", +" Modes:", +" short... print only important or altered options", +" long ... print options even if they have default settings", +" long_history like long plus -history: lines", +" Filters begin with '-' and are compared literally against the", +" output lines of -status long_history. A line is put out only", +" if its start matches the filter.", +" -status_history_max number Maximum number of history lines to be reported", +" with -status:long_history", +" -options_from_file fileaddress", +" Reads lines from the given file and executes them as program", +" options.", +" -no_rc Only if used as first command line argument this option", +" prevents reading and interpretation of startup files.", +" -print text", +" Print a text to result channel.", +" -prompt text", +" Wait for Enter key resp. for a line of input at stdin.", +" -errfile_log mode path|channel", +" Log disk paths of files involved in problem events.", +" -session_log path", +" Set path of a file where a log record gets appended after", +" each session. Form: timestamp start_lba size volume-id", +" # any text Is ignored. In dialog mode the input line will be stored in", +" the eventual readline history, nevertheless.", +" -version Tell program and version number", +" -end End program. Commit eventual pending changes.", +" -rollback_end", +" End program. Discard pending changes.", +"", +"", +"Option -page causes a user prompt after the given number of result lines.", +"Empty input resumes output until the next prompt. Other input may be:", +" @ suppresses paging until the current action is done", +" @@ suppresses further result output but continues the action", +" @@@ aborts the current action", +" other aborts the current action and executes input as new", +" option", +"", + +#endif /* ! Xorriso_no_helP */ + +"@ENDE_OF_HELPTEXT_(HOPEFULLY_UNIQUELY_SILLY_TEXT)@" + }; + + char *tpt= NULL; + int i,pass; + + Xorriso_restxt(xorriso,"\n"); + sprintf(xorriso->result_line,"usage: %s [settings|actions]\n", + xorriso->progname); + Xorriso_result(xorriso,0); + Xorriso_restxt(xorriso,"\n"); + for(pass=0;pass<1;pass++) { + for(i=0;1;i++) { + if(pass==0) + tpt= text[i]; + + if(strcmp(tpt,"@ENDE_OF_HELPTEXT_(HOPEFULLY_UNIQUELY_SILLY_TEXT)@")==0) + break; + sprintf(xorriso->result_line,"%s\n",tpt); + Xorriso_result(xorriso,0); + if(xorriso->request_to_abort) + return(1); + } + } + Xorriso_restxt(xorriso,"\n"); + return(1); +} + + +/* Option -history */ +int Xorriso_option_history(struct XorrisO *xorriso, char *line, int flag) +{ + Xorriso_dialog_input(xorriso,line,strlen(line)+1,2); + return(1); +} + + +/* Option -iso_rr_pattern "on"|"ls"|"off" */ +int Xorriso_option_iso_rr_pattern(struct XorrisO *xorriso, char *mode,int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_iso_rr_pattern= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_iso_rr_pattern= 1; + else if(strcmp(mode, "ls")==0) + xorriso->do_iso_rr_pattern= 2; + else { + sprintf(xorriso->info_text, "-iso_rr_pattern: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -joliet "on"|"off" */ +int Xorriso_option_joliet(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_joliet= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_joliet= 1; + else { + sprintf(xorriso->info_text, "-joliet: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Options -ls alias -lsi and -lsl alias -lsli + and -lsd alias -lsdi and -lsdl alias -lsdli + and -du alias -dui and -dus alias -dusi + @param flag bit0= long format (-lsl , -du) + bit1= do not expand patterns but use literally + bit2= du rather than ls + bit3= list directories as themselves (ls -d) +*/ +int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int ret, end_idx, filec= 0, nump, i; + char **filev= NULL, **patterns= NULL; + off_t mem= 0; + struct stat stbuf; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + if(xorriso->do_iso_rr_pattern==0) + flag|= 2; + + nump= end_idx - *idx; + if((flag&2) && nump>0 ) { + ; + } else if(nump <= 0) { + if(Xorriso_iso_lstat(xorriso, xorriso->wdi, &stbuf, 0)==-1) { + sprintf(xorriso->info_text, + "Current -cd path does not yet exist in the ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } + if(!S_ISDIR(stbuf.st_mode)) { + sprintf(xorriso->info_text, + "Current -cd meanwhile points to a non-directory in ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } + patterns= calloc(1, sizeof(char *)); + if(patterns == NULL) { +no_memory:; + sprintf(xorriso->info_text, + "Cannot allocate enough memory for pattern expansion"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + nump= 1; + if(flag&8) + patterns[0]= "."; + else + patterns[0]= "*"; + flag&= ~2; + } else { + patterns= calloc(nump, sizeof(char *)); + if(patterns==NULL) + goto no_memory; + for(i= 0; i<nump; i++) { + if(argv[i + *idx][0]==0) + patterns[i]= "*"; + else + patterns[i]= argv[i + *idx]; + } + } + if(flag&2) { + ret= Xorriso_ls_filev(xorriso, xorriso->wdi, nump, argv + (*idx), mem, + flag&(1|4|8)); + } else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){ + /* save temporary memory by calling simpler function */ + ret= Xorriso_ls(xorriso, (flag&1)|4); + } else { + ret= Xorriso_expand_pattern(xorriso, nump, patterns, 0, &filec, &filev, + &mem, 0); + if(ret<=0) + {ret= 0; goto ex;} + ret= Xorriso_ls_filev(xorriso, xorriso->wdi, filec, filev, mem, + flag&(1|4|8)); + } + if(ret<=0) + {ret= 0; goto ex;} + + ret= 1; +ex:; + if(patterns!=NULL) + free((char *) patterns); + Sfile_destroy_argv(&filec, &filev, 0); + (*idx)= end_idx; + return(ret); +} + + +/* Options -lsx, -lslx, -lsdx , -lsdlx , -dux , -dusx + @param flag bit0= long format (-lslx , -dux) + bit1= do not expand patterns but use literally + bit2= du rather than ls + bit3= list directories as themselves (ls -d) +*/ +int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int ret, end_idx, filec= 0, nump, i; + char **filev= NULL, **patterns= NULL; + off_t mem= 0; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1|2); + if(xorriso->do_disk_pattern==0) + flag|= 2; + + nump= end_idx - *idx; + if((flag&2) && nump>0) { + ; + } else if(nump <= 0) { + patterns= calloc(1, sizeof(char *)); + if(patterns == NULL) { +no_memory:; + sprintf(xorriso->info_text, + "Cannot allocate enough memory for pattern expansion"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + nump= 1; + if(flag&8) + patterns[0]= "."; + else + patterns[0]= "*"; + flag&= ~2; + } else { + patterns= calloc(nump, sizeof(char *)); + if(patterns==NULL) + goto no_memory; + for(i= 0; i<nump; i++) { + if(argv[i + *idx][0]==0) + patterns[i]= "*"; + else + patterns[i]= argv[i + *idx]; + } + } + if(flag&2) { + ret= Xorriso_lsx_filev(xorriso, xorriso->wdx, + nump, argv + (*idx), mem, flag&(1|4|8)); + +#ifdef Not_yeT + } else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){ + /* save temporary memory by calling simpler function */ + ret= Xorriso_ls(xorriso, (flag&1)|4); +#endif + + } else { + ret= Xorriso_expand_disk_pattern(xorriso, nump, patterns, 0, &filec, &filev, + &mem, 0); + if(ret<=0) + {ret= 0; goto ex;} + ret= Xorriso_lsx_filev(xorriso, xorriso->wdx, filec, filev, mem, + flag&(1|4|8)); + } + if(ret<=0) + {ret= 0; goto ex;} + + ret= 1; +ex:; + if(patterns!=NULL) + free((char *) patterns); + Sfile_destroy_argv(&filec, &filev, 0); + (*idx)= end_idx; + return(ret); +} + + +/* Option -logfile */ +int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel, + char *fileadr, int flag) +{ + int hflag,channel_no= 0, ret; + + if(channel[0]==0) { +logfile_wrong_form:; + sprintf(xorriso->info_text,"Wrong form. Correct would be: -logfile \".\"|\"R\"|\"I\"|\"M\" file_address"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + hflag= 2; + if(channel[0]=='R') + channel_no= 1; + else if(channel[0]=='I') + channel_no= 2; + else if(channel[0]=='M') + channel_no= 3; + else if(channel[0]=='.') + hflag= 4; + else + goto logfile_wrong_form; + if(strcmp(fileadr,"-")==0 || fileadr[0]==0) + hflag|= (1<<15); + xorriso->logfile[channel_no][0]= 0; + ret= Write_to_channel(fileadr,channel_no,hflag); + if(ret<=0) { + sprintf(xorriso->info_text, "Cannot open logfile: %s", fileadr); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + } else if(!(hflag&(1<<15))) + if(Sfile_str(xorriso->logfile[channel_no], fileadr, 0)<=0) + return(-1); + return(ret>0); +} + + +/* Option -mark */ +int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag) +{ + if(mark[0]==0) + xorriso->mark_text[0]= 0; + else + strncpy(xorriso->mark_text,mark,sizeof(xorriso->mark_text)-1); + xorriso->mark_text[sizeof(xorriso->mark_text)-1]= 0; + return(1); +} + + +/* Option -mkdir alias -mkdiri */ +int Xorriso_option_mkdiri(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, end_idx, ret, was_failure= 0, fret; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); + + for(i= *idx; i<end_idx; i++) { + ret= Xorriso_mkdir(xorriso, argv[i], 0); + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -mv alias -mvi */ +int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, end_idx_dummy, ret, is_dir= 0, was_failure= 0, fret; + char sfe[5*SfileadrL], sfe2[5*SfileadrL]; + char eff_origin[SfileadrL], eff_dest[SfileadrL], dest_dir[SfileadrL]; + char leafname[SfileadrL]; + int optc= 0; + char **optv= NULL; + + ret= Xorriso_cpmv_args(xorriso, "-mvi", argc, argv, idx, + &optc, &optv, eff_dest, 0); + if(ret<=0) + goto ex; + if(ret==2) { + is_dir= 1; + strcpy(dest_dir, eff_dest); + } + /* Perform movements */ + for(i= 0; i<optc; i++) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi,optv[i],eff_origin,0); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + if(is_dir) { + ret= Sfile_leafname(eff_origin, leafname, 0); + if(ret<=0) + goto problem_handler; + strcpy(eff_dest, dest_dir); + ret= Sfile_add_to_path(eff_dest, leafname, 0); + if(ret<=0) { + printf(xorriso->info_text, "Effective path gets much too long (%d)", + strlen(eff_dest)+strlen(leafname)+1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto problem_handler; + } + } + ret= Xorriso_rename(xorriso, NULL, eff_origin, eff_dest, 0); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + sprintf(xorriso->info_text, "Renamed in ISO image: %s to %s\n", + Text_shellsafe(eff_origin,sfe,0),Text_shellsafe(eff_dest,sfe2,0)); + Xorriso_info(xorriso, 0); + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= !was_failure; +ex:; + Xorriso_opt_args(xorriso, "-mvi", + argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256); + return(ret); +} + + +/* Option -no_rc */ +int Xorriso_option_no_rc(struct XorrisO *xorriso, int flag) +{ + xorriso->no_rc= 1; + return(1); +} + + +/* Option -options_from_file*/ +int Xorriso_option_options_from_file(struct XorrisO *xorriso, char *adr, + int flag) +/* + bit0= called from Xorriso_prescan_args, + therefore execute via that same function +*/ +/* +return: + <=0 error , 1 = success , 3 = end program run +*/ +{ + int ret,linecount= 0, argc, was_failure= 0, fret; + FILE *fp= NULL; + char line[5*SfileadrL], shellsafe[5*SfileadrL]; + char **argv= NULL; + + if(adr[0]==0) { + sprintf(xorriso->info_text,"Empty file name given with -options_from_file"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + Text_shellsafe(adr,shellsafe,0); + if(xorriso->is_dialog) { + sprintf(xorriso->info_text,"+ performing command lines from file %s :\n", + shellsafe); + Xorriso_info(xorriso,1); + } + fp= Afile_fopen(adr,"rb",((!!xorriso->packet_output)<<6)); + if(fp==NULL) + return(0); + while(1) { + if(Sfile_fgets(line,sizeof(line),fp)==NULL) { + ret= 1; + if(ferror(fp)) + ret= 0; + break; + } + linecount++; + if(line[0]==0 || line[0]=='#') + continue; + + if(flag&1) { + ret= Sfile_make_argv(xorriso->progname, line, &argc, &argv, 4|8); + if(ret<=0) + goto problem_handler; + ret= Xorriso_prescan_args(xorriso,argc,argv,1); + Sfile_make_argv("", "", &argc, &argv, 2); /* release memory */ + if(ret==0) + {ret= 3; goto ex;} + if(ret<0) + goto problem_handler; + } else { + if(xorriso->is_dialog) { + sprintf(xorriso->info_text,"+ %d: %s\n",linecount,line); + Xorriso_info(xorriso,1); + } + ret= Xorriso_execute_option(xorriso,line,1|(1<<16)); + if(ret==3) + goto ex; + if(ret<=0) + goto problem_handler; + } + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1); + if(fret>=0) + continue; + goto ex; + } +ex:; + Xorriso_reset_counters(xorriso,0); + if(fp!=NULL) + fclose(fp); + if(ret<=0) { + sprintf(xorriso->info_text, + "error triggered by line %d of file:\n %s\n", + linecount,shellsafe); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 1); + } + if(ret!=1) + return(ret); + return(!was_failure); +} + + +/* Option -overwrite "on"|"nondir"|"off" */ +int Xorriso_option_overwrite(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_overwrite= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_overwrite= 1; + else if(strcmp(mode, "nondir")==0) + xorriso->do_overwrite= 2; + else { + sprintf(xorriso->info_text, "-overwrite: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -padding */ +int Xorriso_option_padding(struct XorrisO *xorriso, char *size, int flag) +{ + double num; + + num= Scanf_io_size(size, 0); + if(num < 0 || num > 1024.0 * 1024.0 * 1024.0) { + sprintf(xorriso->info_text, "-padding: wrong size %.f (allowed: %.f - %.f)", + num, 0.0, 1024.0 * 1024.0 * 1024.0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->padding= num; + if(xorriso->padding/2048 != num/2048.0) + xorriso->padding++; + return(1); +} + + +/* Option -page */ +int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag) +{ + if(len<0 || width<=0) { + sprintf(xorriso->info_text, + "Improper numeric value of arguments of -page: %d %d", + len, width); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->result_page_length= len; + xorriso->result_page_width= width; + return(1); +} + + +/* Option -path-list */ +int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag) +{ + int ret,linecount= 0, insertcount= 0, null= 0, was_failure= 0, fret= 0; + int was_ferror= 0; + FILE *fp= NULL; + char *argpt, sfe[5*SfileadrL],line[SfileadrL]; + + Xorriso_pacifier_reset(xorriso, 0); + if(adr[0]==0) { + sprintf(xorriso->info_text,"Empty file name given with -path-list"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(0); + } + fp= Afile_fopen(adr,"rb",((!!xorriso->packet_output)<<6)); + if(fp==NULL) + return(0); + while(1) { + if(Sfile_fgets(line,sizeof(line),fp)==NULL) { + ret= 1; + if(ferror(fp)) + was_ferror= 1; + break; + } + linecount++; + if(line[0]==0) + continue; + argpt= line; + null= 0; + ret= Xorriso_option_add(xorriso, 1, &argpt, &null, 1|2); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + insertcount++; + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + if(ret<=0) { + sprintf(xorriso->info_text, "Aborted reading of file %s in line number %d", + Text_shellsafe(adr, sfe, 0), linecount); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (fret==-2 ? "NOTE" : "FAILURE"), 0); + } + ret= !was_ferror; + sprintf(xorriso->info_text, "Added %d items from file %s\n", + insertcount, Text_shellsafe(adr, sfe, 0)); + Xorriso_info(xorriso,0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -pathspecs */ +int Xorriso_option_pathspecs(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->allow_graft_points= 0; + else if(strcmp(mode, "on")==0) + xorriso->allow_graft_points= 1; + else { + sprintf(xorriso->info_text, "-pathspecs: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -pkt_output */ +int Xorriso_option_pkt_output(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode,"off")==0) + xorriso->packet_output= 0; + else + xorriso->packet_output= 1; + return(1); +} + + +/* Option -print */ +int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag) +{ + sprintf(xorriso->result_line,"%s\n",text); + Xorriso_result(xorriso,1); + return(1); +} + + +/* Option -print-size + @param flag bit0= report in mkisofs compatible form on real stdout +*/ +int Xorriso_option_print_size(struct XorrisO *xorriso, int flag) +{ + int ret, fd; + + if(!xorriso->volset_change_pending) { + sprintf(xorriso->info_text,"-print-size: No image modifications pending"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + sprintf(xorriso->result_line,"Image size : 0s\n"); + Xorriso_result(xorriso,0); + return(2); + } + ret= Xorriso_write_session(xorriso, 1); + if(ret<=0) { + sprintf(xorriso->info_text,"-print-size: Failed to set up virtual -commit"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + if(flag&1) { + sprintf(xorriso->result_line,"%d\n", ret); + fd= xorriso->dev_fd_1; + if(fd<0) + fd= 1; + write(fd, xorriso->result_line, strlen(xorriso->result_line)); + fsync(fd); + } else { + sprintf(xorriso->result_line,"Image size : %ds\n", ret); + Xorriso_result(xorriso,0); + } + return(1); +} + + +/* Option -prog */ +int Xorriso_option_prog(struct XorrisO *xorriso, char *name, int flag) +{ + if(strlen(name)>=sizeof(xorriso->progname)) { + sprintf(xorriso->info_text, + "Name too long with option -prog (%d > %d)", + (int) strlen(name), (int) sizeof(xorriso->progname)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + if(Sfile_str(xorriso->progname,name,0)<=0) + return(-1); + return(1); +} + + +/* Option -prog_help */ +int Xorriso_option_prog_help(struct XorrisO *xorriso, char *name, int flag) +{ + int ret; + + ret= Xorriso_option_prog(xorriso, name, 0); + if(ret<=0) + return(ret); + ret= Xorriso_option_help(xorriso, 0); + return(ret); +} + + +/* Option -prompt */ +int Xorriso_option_prompt(struct XorrisO *xorriso, char *text, int flag) +{ + int ret; + char line[80]; + + strncpy(xorriso->result_line,text,sizeof(xorriso->result_line)-1); + xorriso->result_line[sizeof(xorriso->result_line)-1]= 0; + Xorriso_result(xorriso,0); + ret= Xorriso_dialog_input(xorriso, line, sizeof(line),1); + return(ret); +} + + +/* Option -publisher */ +int Xorriso_option_publisher(struct XorrisO *xorriso, char *name, int flag) +{ + int ret; + + if(strlen(name)>=sizeof(xorriso->publisher)) { + sprintf(xorriso->info_text, + "Name too long with option -publisher (%d > %d)", + (int) strlen(name), (int) sizeof(xorriso->publisher)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + ret= Xorriso_set_publisher(xorriso, name, 0); + if(ret<=0) + return(ret); + if(Sfile_str(xorriso->publisher,name,0)<=0) + return(-1); + return(1); +} + + +/* Option -pwd alias -pwdi */ +int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag) +{ + sprintf(xorriso->info_text,"current working directory in ISO image:\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->result_line,"%s/\n",xorriso->wdi); + Xorriso_result(xorriso,0); + return(1); +} + + +/* Option -pwdx */ +int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag) +{ + sprintf(xorriso->info_text,"current working directory on hard disk:\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->result_line,"%s/\n",xorriso->wdx); + Xorriso_result(xorriso,0); + return(1); +} + + +/* Option -reassure "on"|"tree"|"off" */ +int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_reassure= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_reassure= 1; + else if(strcmp(mode, "tree")==0) + xorriso->do_reassure= 2; + else { + sprintf(xorriso->info_text, "-reassure: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + return(1); +} + + +/* Option -report_about */ +int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity, + int flag) +{ + int ret, sev; + char sfe[5*SfileadrL]; + + ret= Xorriso__text_to_sev(severity, &sev, 0); + if(ret<=0) { + sprintf(xorriso->info_text, + "-report_about: Not a known severity name : %s", + Text_shellsafe(severity, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(ret); + } + if(Sfile_str(xorriso->report_about_text,severity,0)<=0) + return(-1); + xorriso->report_about_severity= sev; + return(1); +} + + +/* Option -return_with */ +int Xorriso_option_return_with(struct XorrisO *xorriso, char *severity, + int exit_value, int flag) +{ + int ret, sev; + char sfe[5*SfileadrL]; + + ret= Xorriso__text_to_sev(severity, &sev, 0); + if(ret<=0) { + sprintf(xorriso->info_text, + "-return_with: Not a known severity name : %s", + Text_shellsafe(severity, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + if(exit_value && (exit_value < 32 || exit_value > 63)) { + sprintf(xorriso->info_text, + "-return_with: Not an allowed exit_value. Use 0, or 32 to 63."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(Sfile_str(xorriso->return_with_text,severity,0)<=0) + return(-1); + xorriso->return_with_severity= sev; + return(1); +} + + +/* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */ +/* @param flag bit0=recursive , bit1= remove empty directory: rmdir */ +int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, ret, end_idx, was_failure= 0, fret; + char path[SfileadrL], eff_path[SfileadrL], sfe[5*SfileadrL]; + int optc= 0; + char **optv= NULL; + + ret= Xorriso_opt_args(xorriso, "-rm*i", + argc, argv, *idx, &end_idx, &optc, &optv, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(Sfile_str(path,optv[i],0)<=0) + {ret= -1; goto problem_handler;} + if(path[0]!='/') { + ret= Sfile_prepend_path(xorriso->wdi, path, 0); + if(ret<=0) + goto problem_handler; + } + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1); + if(ret<0) + goto problem_handler; + if(ret==0) { + sprintf(xorriso->info_text, + "Cannot find path %s in loaded ISO image for removal", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + goto problem_handler; + } + strcpy(path, eff_path); + + ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, path, flag&(1|2)); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + if(ret<3) { + sprintf(xorriso->info_text, "Removed from ISO image: %s '%s'\n", + ((flag&2) ? "directory" : (ret>1 ? "subtree" : "file")), path); + Xorriso_info(xorriso, 0); + } + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-rm*i", + argc, argv, *idx, &end_idx, &optc, &optv, 256); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -rollback */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_rollback(struct XorrisO *xorriso, int flag) +{ + int ret; + char indev[SfileadrL], *which_will; + + if(xorriso->volset_change_pending) + which_will= "revoke the pending image changes"; + else + which_will= "reload the image"; + ret= Xorriso_reassure(xorriso, "-rollback", which_will, 0); + if(ret<=0) + return(2); + + if(Sfile_str(indev, xorriso->indev, 0)<=0) + return(-1); + ret= Xorriso_give_up_drive(xorriso, 1|8); + if(ret<=0) + return(ret); + ret= Xorriso_option_dev(xorriso, indev, 1|4); +/* + 1|((xorriso->out_drive_handle==NULL)<<1)); +*/ + return(ret); +} + + +/* Option -session_log */ +int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag) +{ + if(Sfile_str(xorriso->session_logfile, path, 0)<=0) + return(-1); + return(1); +} + + +/* Option -speed */ +int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag) +{ + int is_cd= 1, unit_found= 0, ret, profile_number; + double num; + char *cpt, profile_name[80]; + + if(speed[0]==0 || strcmp(speed, "any")==0) { + xorriso->speed= 0; /* full speed */ + return(1); + } + + sscanf(speed,"%lf",&num); + for(cpt= speed+strlen(speed)-1; cpt>=speed; cpt--) + if(isdigit(*cpt) || *cpt=='.') + break; + cpt++; + + if(*cpt=='k' || *cpt=='K') { + /* is merchand kilobyte, stays merchand kilobyte */ + unit_found= 1; + } else if(*cpt=='m' || *cpt=='M') { + num*= 1000; + unit_found= 1; + } else if(*cpt=='x' || *cpt=='X') + cpt++; + + if(*cpt=='c' || *cpt=='C') { +cd_speed:; + num*= 176.4; + } else if(*cpt=='d' || *cpt=='D') { +dvd_speed:; + num*= 1385; + } else if (!unit_found) { + ret= Xorriso_get_profile(xorriso, &profile_number, profile_name, 2); + is_cd= (ret==2); + if(is_cd) + goto cd_speed; + else + goto dvd_speed; + } + + if(num> 2.0e9) { + sprintf(xorriso->info_text, + "-speed: Value too large or not recognizable: '%s'", speed); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->speed= num; + if(xorriso->speed<num) + xorriso->speed++; + return(1); +} + + +/* Option -split_size */ +int Xorriso_option_split_size(struct XorrisO *xorriso, char *size, int flag) +{ + double num; + static off_t limit= ((off_t) 4) * ((off_t) 1024*1024*1024) - (off_t) 1; + + num= Scanf_io_size(size, 0); + if(num > limit) { + sprintf(xorriso->info_text, "-split_size: too large %.f (allowed: %.f)", + num, (double) limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } else if(num < 0) + num= 0.0; + xorriso->split_size= num; + return(1); +} + + +/* Option -status */ +int Xorriso_option_status(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode,"short")==0) + Xorriso_status(xorriso,NULL,NULL,1); + else if(strcmp(mode,"long")==0) + Xorriso_status(xorriso,NULL,NULL,0); + else if(strcmp(mode,"long_history")==0) + Xorriso_status(xorriso,NULL,NULL,8); + else if(mode[0]=='-') + Xorriso_status(xorriso,mode,NULL,8); + else + Xorriso_status(xorriso,NULL,NULL,1); + return(1); +} + + +/* Option -status_history_max */ +int Xorriso_option_status_history_max(struct XorrisO *xorriso, int num, + int flag) +{ + if(num>=0 && num<1000000) + xorriso->status_history_max= num; + return(1); +} + + +/* Option -tell_media_space */ +int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag) +{ + int ret, free_space= 0, media_space= 0; + + ret= Xorriso_tell_media_space(xorriso, &media_space, &free_space, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "Cannot -tell_media_space"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + if(free_space<0) { + sprintf(xorriso->info_text, + "Pending image size larger than free space on media"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + sprintf(xorriso->result_line, "Media space : %ds\n", media_space); + Xorriso_result(xorriso, 0); + sprintf(xorriso->result_line, "After commit : %ds\n", free_space); + Xorriso_result(xorriso, 0); + return(1); +} + + +/* Option -temp_mem_limit */ +int Xorriso_option_temp_mem_limit(struct XorrisO *xorriso, char *size, + int flag) +{ + double num; + + num= Scanf_io_size(size, 0); + if(num < 64.0 * 1024.0 || num > 1024.0 * 1024.0 * 1024.0) { + sprintf(xorriso->info_text, + "-temp_mem_limit: wrong size %.f (allowed: %.f - %.f)", + num, 64.0 * 1024.0, 1024.0 * 1024.0 * 1024.0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->temp_mem_limit= num; + return(1); +} + + +/* Option -toc */ +int Xorriso_option_toc(struct XorrisO *xorriso, int flag) +{ + int ret, in_ret= 1000; + + if(strcmp(xorriso->indev,xorriso->outdev)==0) + ret= Xorriso_toc(xorriso, 0); + else { + if(xorriso->indev[0]!=0) + in_ret= Xorriso_toc(xorriso, 0); + if(xorriso->indev[0]!=0 && xorriso->outdev[0]!=0) { + strcpy(xorriso->result_line, "-------------: ---------------------------------------------------------------\n"); + Xorriso_result(xorriso,0); + } + ret= 1; + if(xorriso->outdev[0]!=0) + ret= Xorriso_toc(xorriso, 2); + if(in_ret<ret) + ret= in_ret; + } + return(ret); +} + + +/* Option -uid */ +int Xorriso_option_uid(struct XorrisO *xorriso, char *uid, int flag) +{ + int ret; + + xorriso->do_global_uid= 0; + if(uid[0]==0 || strcmp(uid,"-")==0) + return(1); + ret= Xorriso_convert_uidstring(xorriso, uid, &(xorriso->global_uid), 0); + if(ret>0) + xorriso->do_global_uid= 1; + return(ret); +} + + +/* Options -update and -update_r + @param flag bit0= issue start and summary message + bit1= do not reset pacifier, no final pacifier message + bit2= do not issue pacifier messages at all + bit3= recursive: -update_r +*/ +int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag) +{ + int ret, mem_pci, zero= 0, result, uret, follow_links; + double mem_lut= 0.0, start_time; + char *ipth, *argv[6], sfe[5*SfileadrL]; + struct stat stbuf; + + start_time= Sfile_microtime(0); + + ipth= iso_path; + if(ipth[0]==0) + ipth= disk_path; + + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + mem_pci= xorriso->pacifier_interval; + xorriso->pacifier_interval= 5.0; + + if(flag&1) { + sprintf(xorriso->info_text, "Updating %s to", + Text_shellsafe(disk_path, sfe, 0)); + sprintf(xorriso->info_text+strlen(xorriso->info_text), " %s\n", + Text_shellsafe(ipth, sfe, 0)); + Xorriso_info(xorriso,0); + } + if(flag&8) { + xorriso->find_compare_result= 1; + ret= Xorriso_iso_lstat(xorriso, ipth, &stbuf, 0); + if(ret != -1) { + argv[0]= ipth; + argv[1]= "-exec"; + argv[2]= "update"; + argv[3]= disk_path; + zero= 0; + ret= Xorriso_option_find(xorriso, 4, argv, &zero, 2); /* -findi */ + } else + ret= 1; + if(ret>0) { + ret= lstat(disk_path, &stbuf); + if(ret != -1) { + argv[0]= disk_path; + argv[1]= "-exec"; + argv[2]= "add_missing"; + argv[3]= ipth; + zero= 0; + ret= Xorriso_option_find(xorriso, 4, argv, &zero, 1|2); /* -findx */ + if(ret>0 && !xorriso->do_follow_mount) { + argv[0]= disk_path; + argv[1]= "-type"; + argv[2]= "m"; + argv[3]= "-exec"; + argv[4]= "empty_iso_dir"; + argv[5]= ipth; + zero= 0; + ret= Xorriso_option_find(xorriso, 6, argv, &zero, 1|2); /* -findx */ + } + if(ret>0) + ret= xorriso->find_compare_result; + else + ret= -1; + } else + ret= xorriso->find_compare_result; + } else + ret= -1; + } else { + /* compare ctime too, no filename reporting, eventually silent */ + follow_links= (xorriso->do_follow_links || xorriso->do_follow_param) <<28; + ret= Xorriso_compare_2_files(xorriso, disk_path, ipth, "", &result, + 2 | follow_links | ((flag&4)<<27) | (3<<30)); + if(ret==0) { + uret= Xorriso_update_interpreter(xorriso, NULL, result, disk_path, ipth, + 0); + if(uret<=0) + ret= -1; + } + } + xorriso->pacifier_interval= mem_pci; + if(mem_lut!=xorriso->last_update_time && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 1); + if(ret>0) { + sprintf(xorriso->info_text, + "No file object needed update."); + } else if(ret==0) { + sprintf(xorriso->info_text, "Differences detected and updated."); + } else { + sprintf(xorriso->info_text, + "Not ok. Comparison or update failed due to error."); + } + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " (runtime %.1f s)\n", Sfile_microtime(0)-start_time); + if(flag&1) + Xorriso_info(xorriso,0); + if(ret<0) + return(ret); + return(1); +} + + +/* Option -use_readline */ +int Xorriso_option_use_readline(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode,"off")==0) + xorriso->use_stdin= 1; + else + xorriso->use_stdin= 0; + return(1); +} + + +/* Option -version */ +int Xorriso_option_version(struct XorrisO *xorriso, int flag) +{ + sprintf(xorriso->result_line, + "xorriso %s : RockRidge filesystem manipulator\n", + Xorriso_program_versioN); + sprintf(xorriso->result_line+strlen(xorriso->result_line), +"Copyright (C) 2008, Thomas Schmitt <scdbackup@gmx.net>, libburnia project\n"); + Xorriso_result(xorriso, 0); + sprintf(xorriso->result_line, + "xorriso version : %s\n", Xorriso_program_versioN); + sprintf(xorriso->result_line+strlen(xorriso->result_line), + "Version timestamp : %s\n",Xorriso_timestamP); + sprintf(xorriso->result_line+strlen(xorriso->result_line), + "Build timestamp : %s\n",Xorriso_build_timestamP); + Xorriso_result(xorriso, 0); + Xorriso_report_lib_versions(xorriso, 0); + return(1); +} + + +/* Option -volid */ +int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag) +{ + int warn_shell= 0, warn_ecma= 0, i, ret; + static char shell_chars[]= { + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-+=:.,~@"}; + static char ecma_chars[]= {"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"}; + + for(i=0; volid[i]!=0; i++) { + if(strchr(shell_chars, volid[i])==NULL) + warn_shell= 1; + if(strchr(ecma_chars, volid[i])==NULL) + warn_ecma= 1; + } + if(i>32) { + sprintf(xorriso->info_text, "-volid: Text too long (%d > 32)", i); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(warn_shell) { + sprintf(xorriso->info_text, + "-volid text problematic as automatic mount point name"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + if(xorriso->do_joliet && strlen(volid)>16) { + sprintf(xorriso->info_text, + "-volid text is too long for Joliet (%d > 16)",(int) strlen(volid)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + if(warn_ecma) { + sprintf(xorriso->info_text, + "-volid text does not comply to ISO 9660 / ECMA 119 rules"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + strcpy(xorriso->volid, volid); + ret= Xorriso_set_volid(xorriso, volid, 0); + if(ret<=0) + return(ret); + xorriso->volid_default= (strcmp(xorriso->volid, "ISOIMAGE")==0 || + xorriso->volid[0]==0); + return(1); +} + + +/* ---------------------------- End Options API ------------------------ */ + + +int Xorriso_interpreter(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag) +/* +return: + <=0 error , 1 = success , 2 = problem event ignored , 3 = end program run +*/ +/* + bit0= recursion +*/ +{ + int ret, was_dashed, end_ret; + int num1, num2; + char *cmd, *arg1, *arg2; + + if(xorriso==NULL) + return(0); + if(xorriso->is_dialog) { + xorriso->result_line_counter= xorriso->result_page_counter= 0; + if(xorriso->result_page_length<0) + xorriso->result_page_length= -xorriso->result_page_length; + } + +next_command:; + xorriso->prepended_wd= 0; + xorriso->request_to_abort= xorriso->request_not_to_ask= 0; + Xorriso_set_problem_status(xorriso, "", 0); + if((*idx)<argc) + cmd= argv[*idx]; + else + cmd= ""; + if(xorriso->add_plainly==3 && cmd[0] && !xorriso->is_dialog) { + (*idx)++; + goto add_plain_argument; + } + was_dashed= 0; + if(cmd[0]=='-' && cmd[1]!='-' && cmd[1]!=0) { + was_dashed= 1; + cmd++; + } + (*idx)++; + + if((*idx)<argc) + arg1= argv[(*idx)]; + else + arg1= ""; + if((*idx)+1<argc) + arg2= argv[(*idx)+1]; + else + arg2= ""; + + ret= 1; + if(cmd[0]=='#' || cmd[0]==0) { + /* ignore comment line and empty option */; + + } else if(strcmp(cmd,"abort_on")==0) { + (*idx)++; + ret= Xorriso_option_abort_on(xorriso, arg1, 0); + + } else if(strcmp(cmd,"add")==0) { + ret= Xorriso_option_add(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"add_plainly")==0) { + (*idx)++; + ret= Xorriso_option_add_plainly(xorriso, arg1, 0); + + } else if(strcmp(cmd,"alter_date")==0 || strcmp(cmd,"alter_date_r")==0) { + (*idx)+= 2; + ret= Xorriso_option_alter_date(xorriso, arg1, arg2, argc, argv, idx, + strlen(cmd)>10); + + } else if(strcmp(cmd,"as")==0) { + ret= Xorriso_option_as(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"ban_stdio_write")==0) { + ret= Xorriso_option_ban_stdio_write(xorriso, 0); + + } else if(strcmp(cmd,"blank")==0) { + (*idx)++; + ret= Xorriso_option_blank(xorriso, arg1, 0); + + } else if(strcmp(cmd,"boot_image")==0) { + (*idx)+= 2; + ret= Xorriso_option_boot_image(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"cd")==0 || strcmp(cmd,"cdi")==0) { + (*idx)++; + ret= Xorriso_option_cdi(xorriso, arg1, 0); + + } else if(strcmp(cmd,"cdx")==0) { + (*idx)++; + ret= Xorriso_option_cdx(xorriso, arg1, 0); + + } else if(strcmp(cmd,"chgrp")==0 || strcmp(cmd,"chgrpi")==0) { + (*idx)+= 1; + ret= Xorriso_option_chgrpi(xorriso, arg1, argc, argv, idx, 0); + + } else if(strcmp(cmd,"chgrp_r")==0 || strcmp(cmd,"chgrp_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_chgrpi(xorriso, arg1, argc, argv, idx, 1); + + } else if(strcmp(cmd,"chmod")==0 || strcmp(cmd,"chmodi")==0) { + (*idx)+= 1; + ret= Xorriso_option_chmodi(xorriso, arg1, argc, argv, idx, 0); + + } else if(strcmp(cmd,"chmod_r")==0 || strcmp(cmd,"chmod_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_chmodi(xorriso, arg1, argc, argv, idx, 1); + + } else if(strcmp(cmd,"chown_r")==0 || strcmp(cmd,"chown_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 1); + + } else if(strcmp(cmd,"chown")==0 || strcmp(cmd,"chowni")==0) { + (*idx)+= 1; + ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 0); + + } else if(strcmp(cmd,"close")==0) { + (*idx)++; + ret= Xorriso_option_close(xorriso, arg1, 0); + + } else if(strcmp(cmd,"commit")==0) { + ret= Xorriso_option_commit(xorriso, 0); + + } else if(strcmp(cmd,"commit_eject")==0) { + (*idx)++; + ret= Xorriso_option_commit_eject(xorriso, arg1, 0); + + } else if(strcmp(cmd,"compare")==0) { + (*idx)+= 2; + ret= Xorriso_option_compare(xorriso, arg1, arg2, 1); + + } else if(strcmp(cmd,"compare_r")==0) { + (*idx)+= 2; + ret= Xorriso_option_compare(xorriso, arg1, arg2, 1|8); + + } else if(strcmp(cmd,"cpr")==0 || strcmp(cmd,"cpri")==0) { + ret= Xorriso_option_cpri(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"cut_out")==0) { + (*idx)+= 4; + if((*idx)>argc) { + sprintf(xorriso->info_text, + "-cut_out: Not enough arguments. Needed are: disk_path start count so_rr_path"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; + } else + ret= Xorriso_option_cut_out(xorriso, arg1, arg2, + argv[(*idx)-2], argv[(*idx)-1], 0); + + } else if(strcmp(cmd,"dev")==0) { + (*idx)++; + ret= Xorriso_option_dev(xorriso, arg1, 3); + + } else if(strcmp(cmd,"devices")==0) { + ret= Xorriso_option_devices(xorriso, 0); + + } else if(strcmp(cmd,"dummy")==0) { + (*idx)++; + ret= Xorriso_option_dummy(xorriso, arg1, 0); + + } else if(strcmp(cmd,"dialog")==0) { + (*idx)++; + ret= Xorriso_option_dialog(xorriso, arg1, 0); + + } else if(strcmp(cmd,"disk_pattern")==0) { + (*idx)++; + ret= Xorriso_option_disk_pattern(xorriso, arg1, 0); + + } else if(strcmp(cmd,"du")==0 || strcmp(cmd,"dui")==0 || + strcmp(cmd,"dus")==0 || strcmp(cmd,"dusi")==0) { + ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[2]!='s')|4); + + } else if(strcmp(cmd,"dux")==0 || strcmp(cmd,"dusx")==0) { + ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[2]!='s')|4); + + } else if(strcmp(cmd,"eject")==0) { + (*idx)++; + ret= Xorriso_option_eject(xorriso, arg1, 0); + + } else if(strcmp(cmd,"end")==0) { + end_ret= Xorriso_option_end(xorriso, 0); + ret= Xorriso_eval_problem_status(xorriso, ret, 0); + if(ret<0) + return(ret); + if(end_ret!=2) + {ret= 3; goto ex;} + + } else if(strcmp(cmd,"errfile_log")==0) { + (*idx)+= 2; + ret= Xorriso_option_errfile_log(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"iso_rr_pattern")==0) { + (*idx)++; + ret= Xorriso_option_iso_rr_pattern(xorriso, arg1, 0); + + } else if(strcmp(cmd,"follow")==0) { + (*idx)++; + ret= Xorriso_option_follow(xorriso, arg1, 0); + + } else if(strcmp(cmd,"find")==0 || strcmp(cmd,"findi")==0) { + ret= Xorriso_option_find(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"findx")==0) { + ret= Xorriso_option_find(xorriso, argc, argv, idx, 1); + + } else if(strcmp(cmd,"format")==0) { + (*idx)++; + ret= Xorriso_option_blank(xorriso, arg1, 1); + + } else if(strcmp(cmd,"fs")==0) { + (*idx)++; + ret= Xorriso_option_fs(xorriso, arg1, 0); + + } else if(strcmp(cmd,"gid")==0) { + (*idx)++; + ret= Xorriso_option_gid(xorriso,arg1,0); + + } else if(strcmp(cmd,"help")==0) { + Xorriso_option_help(xorriso,0); + + } else if(strcmp(cmd,"history")==0) { + /* add to readline history */ + (*idx)++; + ret= Xorriso_option_history(xorriso, arg1, 0); + + } else if(strcmp(cmd,"indev")==0) { + (*idx)++; + ret= Xorriso_option_dev(xorriso, arg1, 1); + + } else if(strcmp(cmd,"joliet")==0) { + (*idx)++; + ret= Xorriso_option_joliet(xorriso, arg1, 0); + + } else if(strcmp(cmd,"ls")==0 || strcmp(cmd,"lsi")==0 || + strcmp(cmd,"lsl")==0 || strcmp(cmd,"lsli")==0) { + ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[2]=='l')); + + } else if(strcmp(cmd,"lsd")==0 || strcmp(cmd,"lsdi")==0 || + strcmp(cmd,"lsdl")==0 || strcmp(cmd,"lsdli")==0) { + ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[3]=='l')|8); + + } else if(strcmp(cmd,"lsdx")==0 || strcmp(cmd,"lsdlx")==0) { + ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[3]=='l')|8); + + } else if(strcmp(cmd,"lsx")==0 || strcmp(cmd,"lslx")==0) { + ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[2]=='l')); + + } else if(strcmp(cmd,"logfile")==0) { + (*idx)+= 2; + ret= Xorriso_option_logfile(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"mark")==0) { + (*idx)++; + ret= Xorriso_option_mark(xorriso, arg1, 0); + + } else if(strcmp(cmd,"mv")==0 || strcmp(cmd,"mvi")==0) { + ret= Xorriso_option_mvi(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"mkdir")==0 || strcmp(cmd,"mkdiri")==0) { + ret= Xorriso_option_mkdiri(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"no_rc")==0) { + ret= Xorriso_option_no_rc(xorriso, 0); + + } else if(strcmp(cmd,"options_from_file")==0) { + (*idx)++; + ret= Xorriso_option_options_from_file(xorriso,arg1,0); + if(ret==3) + goto ex; + + } else if(strcmp(cmd,"overwrite")==0) { + (*idx)++; + ret= Xorriso_option_overwrite(xorriso,arg1,0); + + } else if(strcmp(cmd,"outdev")==0) { + (*idx)++; + ret= Xorriso_option_dev(xorriso, arg1, 2); + + } else if(strcmp(cmd,"padding")==0) { + (*idx)++; + ret= Xorriso_option_padding(xorriso, arg1, 0); + + } else if(strcmp(cmd,"page")==0) { + (*idx)+= 2; + num1= num2= 0; + sscanf(arg1,"%d",&num1); + sscanf(arg2,"%d",&num2); + if(num1<0) + num1= 0; + if(arg1[0]==0) + num1= 16; + if(num2<=0) + num2= 80; + ret= Xorriso_option_page(xorriso, num1, num2, 0); + + } else if(strcmp(cmd,"path-list")==0 || strcmp(cmd,"path_list")==0) { + (*idx)++; + ret= Xorriso_option_path_list(xorriso, arg1, 0); + + } else if(strcmp(cmd,"pathspecs")==0) { + (*idx)++; + ret= Xorriso_option_pathspecs(xorriso, arg1, 0); + + } else if(strcmp(cmd,"pkt_output")==0) { + (*idx)++; + ret= Xorriso_option_pkt_output(xorriso, arg1, 0); + + } else if(strcmp(cmd,"print")==0) { + (*idx)++; + ret= Xorriso_option_print(xorriso, arg1, 0); + + } else if(strcmp(cmd,"print-size")==0 || strcmp(cmd,"print_size")==0) { + Xorriso_option_print_size(xorriso, 0); + + } else if(strcmp(cmd,"prompt")==0) { + (*idx)++; + ret= Xorriso_option_prompt(xorriso, arg1, 0); + + } else if(strcmp(cmd,"prog")==0) { + (*idx)++; + ret= Xorriso_option_prog(xorriso, arg1, 0); + + } else if(strcmp(cmd,"publisher")==0) { + (*idx)++; + Xorriso_option_publisher(xorriso, arg1, 0); + + } else if(strcmp(cmd,"pwd")==0 || strcmp(cmd,"pwdi")==0) { + Xorriso_option_pwdi(xorriso, 0); + + } else if(strcmp(cmd,"pwdx")==0) { + Xorriso_option_pwdx(xorriso, 0); + + } else if(strcmp(cmd,"reassure")==0) { + (*idx)++; + ret= Xorriso_option_reassure(xorriso, arg1, 0); + + } else if(strcmp(cmd,"report_about")==0) { + (*idx)++; + ret= Xorriso_option_report_about(xorriso, arg1, 0); + + } else if(strcmp(cmd,"return_with")==0) { + (*idx)+= 2; + num2= 0; + sscanf(arg2,"%d",&num2); + ret= Xorriso_option_return_with(xorriso, arg1, num2, 0); + + } else if(strcmp(cmd,"rm")==0 || strcmp(cmd,"rmi")==0) { + ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"rm_r")==0 || strcmp(cmd,"rm_ri")==0) { + ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 1); + + } else if(strcmp(cmd,"rmdir")==0 || strcmp(cmd,"rmdiri")==0) { + ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 2); + + } else if(strcmp(cmd,"rollback")==0) { + ret= Xorriso_option_rollback(xorriso, 0); + + } else if(strcmp(cmd,"rollback_end")==0) { + end_ret= Xorriso_option_end(xorriso, 1); + ret= Xorriso_eval_problem_status(xorriso, ret, 0); + if(ret<0) + return(ret); + if(end_ret!=2) + {ret= 3; goto ex;} + + } else if(strcmp(cmd,"session_log")==0) { + (*idx)++; + ret= Xorriso_option_session_log(xorriso, arg1, 0); + + } else if(strcmp(cmd,"speed")==0) { + (*idx)++; + ret= Xorriso_option_speed(xorriso, arg1, 0); + + } else if(strcmp(cmd,"split_size")==0) { + (*idx)++; + ret= Xorriso_option_split_size(xorriso, arg1, 0); + + } else if(strcmp(cmd,"status")==0) { + (*idx)++; + ret= Xorriso_option_status(xorriso, arg1, 0); + + } else if(strcmp(cmd,"status_history_max")==0) { + (*idx)++; + sscanf(arg1,"%d",&num1); + ret= Xorriso_option_status_history_max(xorriso, num1, 0); + + } else if(strcmp(cmd,"tell_media_space")==0) { + Xorriso_option_tell_media_space(xorriso, 0); + + } else if(strcmp(cmd,"temp_mem_limit")==0) { + (*idx)++; + ret= Xorriso_option_temp_mem_limit(xorriso, arg1, 0); + + } else if(strcmp(cmd,"test")==0) { /* This option does not exist. */ + ; + + } else if(strcmp(cmd,"toc")==0) { + Xorriso_option_toc(xorriso, 0); + + } else if(strcmp(cmd,"uid")==0) { + (*idx)++; + ret= Xorriso_option_uid(xorriso,arg1,0); + + } else if(strcmp(cmd,"update")==0) { + (*idx)+= 2; + ret= Xorriso_option_update(xorriso, arg1, arg2, 1); + + } else if(strcmp(cmd,"update_r")==0) { + (*idx)+= 2; + ret= Xorriso_option_update(xorriso, arg1, arg2, 1|8); + + } else if(strcmp(cmd,"volid")==0) { + (*idx)++; + ret= Xorriso_option_volid(xorriso,arg1,0); + + } else if(strcmp(cmd,"use_readline")==0) { + (*idx)++; + ret= Xorriso_option_use_readline(xorriso, arg1, 0); + + } else if(strcmp(cmd,"version")==0){ + ret= Xorriso_option_version(xorriso, 0); + + } else if(strcmp(cmd,"--")==0){ + /* tis ok */; + + } else if(was_dashed) { + if(xorriso->add_plainly>1) + goto add_plain_argument; +unknown_option:; + sprintf(xorriso->info_text, + "=== Not a known option:\n"); + sprintf(xorriso->info_text+strlen(xorriso->info_text), + "=== '%s%s'\n",(was_dashed ? "-" : ""), cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto eval_any_problems;} + + } else { + if(xorriso->add_plainly<=0) + goto unknown_option; +add_plain_argument:; + (*idx)--; + ret= Xorriso_option_add(xorriso, (*idx)+1, argv, idx, 0); + (*idx)++; + + } + +eval_any_problems: + ret= Xorriso_eval_problem_status(xorriso, ret, 0); + if(ret<0) + return(ret); + + if(*idx<argc) + goto next_command; + +ex:; + if((!xorriso->is_dialog) && !(flag&1)) + Xorriso_mark(xorriso,0); + fflush(stdout); + return(ret); +} + + +int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag) +/* + bit0-bit15 are forwarded to Xorriso_interpreter + + bit16= no pageing of info lines + bit17= print === bar even if xorriso->found<0 +*/ +{ + int ret,argc= 0, idx= 1; + char **argv= NULL; + double tdiff; + struct timeval tv; + struct timezone tz; + + gettimeofday(&tv,&tz); + Xorriso_reset_counters(xorriso,0); + xorriso->idle_time= 0.0; + tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec); + + /* parse line into args */ + ret= Sfile_make_argv(xorriso->progname, line, &argc, &argv, 4); + if(ret<=0) + goto ex; + if(argc<2) + {ret= 1; goto ex;} + if(argv[1][0]=='#') + {ret= 1; goto ex;} + + ret= Xorriso_interpreter(xorriso, argc, argv, &idx, flag&0xffff); + if(ret<0) + goto ex; + gettimeofday(&tv,&tz); + tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec)-tdiff-xorriso->idle_time; + if(tdiff<0.001) + tdiff= 0.001; + if(xorriso->error_count>0) { + sprintf(xorriso->info_text, + "----------------------------- %7.f errors encountered\n", + xorriso->error_count); + Xorriso_info(xorriso,!(flag&(1<<16))); + } + + /* ??? >>> print elapsed time tdiff ? */; + + if((flag&(1<<17)) && !xorriso->bar_is_fresh) { + sprintf(xorriso->info_text,"============================\n"); + Xorriso_info(xorriso,0); + xorriso->bar_is_fresh= 1; + } + Xorriso_reset_counters(xorriso,0); +ex:; + Sfile_make_argv("", "", &argc, &argv, 2); /* release memory */ + return(ret); +} + + +int Xorriso_dialog(struct XorrisO *xorriso, int flag) +{ + int ret,first_round; + char line[2*SfileadrL]; + + xorriso->is_dialog= 1; + for(first_round= 1;1;first_round= 0) { + if(xorriso->pending_option[0]!=0) { + Xorriso_mark(xorriso,0); + strcpy(line,xorriso->pending_option); + xorriso->pending_option[0]= 0; + } else { + if(!xorriso->bar_is_fresh) { + sprintf(xorriso->info_text,"============================\n"); + Xorriso_info(xorriso,0); + xorriso->bar_is_fresh= 1; + } + sprintf(xorriso->info_text,"enter option and arguments :\n"); + Xorriso_info(xorriso,0); + Xorriso_mark(xorriso,0); + ret= Xorriso_dialog_input(xorriso,line,sizeof(line),4); + if(ret<=0) + break; + } + sprintf(xorriso->info_text, + "==============================================================\n"); + Xorriso_info(xorriso,0); + + ret= Xorriso_execute_option(xorriso,line,1<<17); + if(ret<0) + goto ex; + if(ret==3) + break; + xorriso->did_something_useful= 1; + xorriso->no_volset_present= 0; /* Re-enable "No ISO image present." */ + } + ret= 1; +ex:; + xorriso->is_dialog= 0; + return(ret); +} + + +int Xorriso_protect_stdout(struct XorrisO *xorriso, int flag) +{ + if(xorriso->dev_fd_1>=0) + return(2); + xorriso->dev_fd_1= dup(1); + close(1); + dup2(2,1); + return(1); +} + + +int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv, + int flag) +/* + bit0= do not interpret argv[1] +*/ +/* + return: + <0 error + 0 end program + 1 ok, go on +*/ +{ + int i, ret, was_dashed, num2; + int was_report_about= 0, was_abort_on= 0, was_return_with= 0; + char *cmd, *arg1, *arg2; + + for(i=1+(flag&1);i<argc;i++) { + cmd= argv[i]; + was_dashed= 0; + if(cmd[0]=='-' && cmd[1]!='-' && cmd[1]!=0) { + was_dashed= 1; + cmd++; + } + arg1= ""; + if(i+1<argc) + arg1= argv[i+1]; + arg2= ""; + if(i+2<argc) + arg2= argv[2+1]; + if(i>1) + xorriso->did_something_useful= 1; + if(i==1 && argc==2) { + if(strcmp(cmd,"prog_help")==0) { + i++; + Xorriso_option_prog_help(xorriso,arg1,0); + xorriso->did_something_useful= 1; + return(0); + } else if(strcmp(cmd,"help")==0) { + Xorriso_option_help(xorriso,0); + xorriso->did_something_useful= 1; + return(0); + } + } else if(i==1 && strcmp(cmd,"no_rc")==0) { + ret= Xorriso_option_no_rc(xorriso, 0); + if(ret<=0) + return(ret); + + } else if((strcmp(cmd,"dev")==0 || strcmp(cmd,"outdev")==0 || + strcmp(cmd,"indev")==0) && + (strcmp(arg1,"stdio:/dev/fd/1")==0 || strcmp(arg1,"-")==0) && + xorriso->dev_fd_1<0) { + /* Detach fd 1 from externally perceived stdout and attach it to stderr. + Keep dev_fd_1 connected to external stdout. dev_fd_1 is to be used when + "stdio:/dev/fd/1" is interpreted as drive address. + */ +protect_stdout:; + Xorriso_protect_stdout(xorriso, 0); + sprintf(xorriso->info_text, + "Encountered - or stdio:/dev/fd/1 as possible write target."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + sprintf(xorriso->info_text, + "Redirecting nearly all text message output to stderr."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + sprintf(xorriso->info_text, "Disabling use of libreadline."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + + } else if(strcmp(cmd,"abort_on")==0 && was_dashed) { + i++; + if(!was_abort_on) + Xorriso_option_abort_on(xorriso, arg1, 0); + was_abort_on= 1; + + } else if(strcmp(cmd,"report_about")==0 && was_dashed) { + i++; + if(!was_report_about) + Xorriso_option_report_about(xorriso, arg1, 0); + was_report_about= 1; + + } else if(strcmp(cmd,"return_with")==0 && was_dashed) { + i+= 2; + num2= 0; + sscanf(arg2,"%d",&num2); + if(!was_return_with) + Xorriso_option_return_with(xorriso, arg1, num2, 0); + was_return_with= 1; + + } else if(strcmp(cmd,"as")==0 && was_dashed) { + if(strcmp(arg1, "mkisofs")==0 || strcmp(arg1, "genisoimage")==0 || + strcmp(arg1, "genisofs")==0) + goto protect_stdout; + + } + } + return(1); +} + + +/** Load content startup files into preskin cache */ +int Xorriso_read_rc(struct XorrisO *xorriso, int flag) +{ + int ret,i,was_failure= 0,fret; + + i= xorriso->rc_filename_count-1; + Sfile_home_adr_s(".xorrisorc", xorriso->rc_filenames[i], + sizeof(xorriso->rc_filenames[i]),0); + for(i=0;i<xorriso->rc_filename_count;i++) { + ret= Sfile_type(xorriso->rc_filenames[i],1|8); + if(ret!=1) + continue; + ret= Xorriso_option_options_from_file(xorriso,xorriso->rc_filenames[i],0); + if(ret>1) + return(ret); + if(ret==1) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1); + if(fret>=0) + continue; + return(ret); + } + return(!was_failure); +} + + +int Xorriso_make_return_value(struct XorrisO *xorriso, int flag) +{ + int exit_value= 0; + + if(xorriso->eternal_problem_status >= xorriso->return_with_severity) + exit_value= xorriso->return_with_value; + if(exit_value) { + sprintf(xorriso->info_text, + "-return_with %s %d triggered by problem severity %s", + xorriso->return_with_text, exit_value, + xorriso->eternal_problem_status_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + return(exit_value); +} + + +#ifdef Xorriso_with_maiN + +int main(int argc, char **argv) +{ + +#else + +int Xorriso_main(int argc, char **argv) +{ + +#endif /* Xorriso_with_maiN */ + + int ret,i; + struct XorrisO *xorriso= NULL; + + if(argc<2) { + fprintf(stderr, + "xorriso %s : RockRidge filesystem manipulator, libburnia project.\n\n", + Xorriso_program_versioN); + fprintf(stderr,"usage : %s [options]\n", + argv[0]); + fprintf(stderr," More is told by option -help\n"); + exit(2); + } + ret= Xorriso_new(&xorriso,argv[0],0); + if(ret<=0) { + fprintf(stderr,"Creation of XorrisO object failed. (not enough memory ?)\n"); + exit(3); + } + + /* The prescan of arguments performs actions which have to happen before + the normal processing of startup files and arguments. + */ + ret= Xorriso_prescan_args(xorriso,argc,argv,0); + if(ret==0) + goto end_sucessfully; + if(ret<0) + exit(5); + + fprintf(stderr, + "xorriso %s : RockRidge filesystem manipulator, libburnia project.\n\n", + Xorriso_program_versioN); + ret= Xorriso_startup_libraries(xorriso, 0); + if(ret<=0) + exit(4); + Xorriso_process_msg_queues(xorriso, 0); + + /* Interpret startup file */ + if(!xorriso->no_rc) { + ret= Xorriso_read_rc(xorriso, 0); + if(ret==3) + goto end_sucessfully; + if(ret<=0) + exit(5); + } + + /* Interpret program arguments */ + i= 1; + ret= Xorriso_interpreter(xorriso,argc,argv,&i,0); + if(ret==3) + goto end_sucessfully; + if(ret<=0) + exit(5); + + if(xorriso->dialog) { + ret= Xorriso_dialog(xorriso,0); + if(ret<=0) + exit(6); + } +end_sucessfully:; + Xorriso_process_msg_queues(xorriso, 0); + if(xorriso->volset_change_pending) + Xorriso_option_end(xorriso, 2); + Xorriso_process_msg_queues(xorriso, 0); + ret= Xorriso_make_return_value(xorriso, 0); + Xorriso_process_errfile(xorriso, 0, "xorriso end", 0, 1); + Xorriso_destroy(&xorriso,1); + exit(ret); +} + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorriso.h b/libisoburn/branches/ZeroOneFour/xorriso/xorriso.h new file mode 100644 index 00000000..a4db462c --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorriso.h @@ -0,0 +1,456 @@ + +/* Command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2008 Thomas Schmitt, <scdbackup@gmx.net> + + Provided under GPL version 2. + + This file contains the public option interface of xorriso. +*/ + +#ifndef Xorriso_includeD +#define Xorriso_includeD yes + +/** Opaque handle of the xorriso runtime context */ +struct XorrisO; + + +/* --------------------- Fundamental Management ------------------- */ + +/* Create a new xorriso object and tell it the program name to be used + with messages. +*/ +int Xorriso_new(struct XorrisO ** xorriso, char *progname, int flag); + + +/* Make global library initializations. + This must be done with the first xorriso object that gets created and + with the first xorriso object that gets created after Xorriso_destroy(,1). +*/ +int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag); + + +/* Destroy xorriso object when it is no longer needed. + @param flag bit0= Make global librariy shutdown. + Use only with last xorriso object to be destroyed. + +*/ +int Xorriso_destroy(struct XorrisO **xorriso, int flag); + + +/* --------------------- Problem Status and Message API ------------------- */ + + +/** Submit a problem message to the xorriso problem reporting and handling + system. This will eventually increase problem status rank, which may + at certain stages in the program be pardoned and reset to 0. + The pardon is governed by Xorriso_option_abort_on() and by the anger + of the affected program part. If no pardon has been given, then the problem + status reaches the caller of option functions. + Problem status should be inquired by Xorriso_eval_problem_status() and be + reset before next option execution by Xorriso_set_problem_status(). + The problem status itself does not cause the failure of option functions. + But in case of failures for other reasons, a remnant overly severe problem + status can cause overly harsh program reactions. + @param xorriso The environment handle + @param error_code The unique error code of your message. + Submit 0 if you do not have reserved error codes within + the libburnia project. + @param msg_text Not more than 8196 characters of message text. + A final newline character gets appended automatically. + @param os_errno Eventual errno related to the message. Submit 0 if + the message is not related to a operating system error. + @param severity One of "ABORT", "FATAL", "SORRY", "WARNING", "HINT", + "NOTE", "UPDATE", "DEBUG". Defaults to "FATAL". + @param flag Bitfield for control purposes + bit0= use pager (as with result) + bit1= permission to suppress output + @return 1 if message was delivered, <=0 if failure +*/ +int Xorriso_msgs_submit(struct XorrisO *xorriso, + int error_code, char msg_text[], int os_errno, + char severity[], int flag); + + +/** Evaluate an advise whether to abort or whether to go on with option + processing. This should be called after any option function was processed. + It updates the problem status by processing the library message queues + and then it uses this status and the submitted return value ot the + option function to evaluate the situation. + @param xorriso The environment handle + @param ret The return value of the previously called option function + @param flag bit0= do not issue own event messages + bit1= take xorriso->request_to_abort as reason for abort + @return Gives the advice: + 2= pardon was given, go on + 1= no problem, go on + 0= function failed but xorriso would not abort, go on + <0= do abort + -1 = due to xorriso->problem_status + or due to ret<0 + -2 = due to xorriso->request_to_abort +*/ +int Xorriso_eval_problem_status(struct XorrisO *xorriso, int ret, int flag); + + +/** Set the current problem status of the xorriso handle. + @param xorriso The environment handle + @param severity A severity text. Empty text resets to "No Problem". + @param flag Unused yet. Submit 0. + @return <=0 failure (e.g. wrong severity text), 1 success. +*/ +int Xorriso_set_problem_status(struct XorrisO *xorriso, char *severity, + int flag); + + +/* The next two functions are part of Xorriso_eval_problem_status(). + You may use them to build an own advisor function or to drain the + library message queues more frequently. +*/ + +/** Obtain the current problem status of the xorriso handle. + @param xorriso The environment handle + @param severity The severity text matching the current problem status + @param flag Unused yet. Submit 0. + @return The severity rank number. 0= no problem occured. +*/ +int Xorriso_get_problem_status(struct XorrisO *xorriso, char severity[80], + int flag); + + +/** Forward any pending messages from the library message queues to the + xorriso message system which puts out on info channel. This registers + the severity of the library events like the severity of a message submitted + via Xorriso_msgs_submit(). + xorriso sets the message queues of the libraries to queuing "ALL". + So it is essential that they get drained regularly. + @param xorriso The environment handle + @param flag Unused yet. Submit 0. + @return 1 on success, <=0 if failure +*/ +int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag); + + + +/* ---------------------------- Options API ------------------------ */ +/* See man 1 xorriso for explanation of the particular options */ +/* + Before each call to an option function, there should happen: + Xorriso_set_problem_status() with empty severity text. + + After each call to an option function, there should happen: + Xorriso_eval_problem_status() + One should follow its eventual advice to abort. +*/ + + +/* Option -abort_on */ +int Xorriso_option_abort_on(struct XorrisO *xorriso, char *severity, int flag); + +/* Option -add */ +/* @param flag bit0=do not report the added item + bit1=do not reset pacifier, no final pacifier message +*/ +int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -add_plainly "on"|"off" */ +int Xorriso_option_add_plainly(struct XorrisO *xorriso, char *mode, + int flag); + + +/* Option -alter_date, alter_date_r */ +/* @param flag bit0=recursive (-alter_date_r) +*/ +int Xorriso_option_alter_date(struct XorrisO *xorriso, + char *time_type, char *timestring, + int argc, char **argv, int *idx, int flag); + +/* Option -ban_stdio_write */ +int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag); + +/* Option -blank and -format */ +/* @param flag bit0= format rather than blank + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -boot_image */ +int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form, + char *treatment, int flag); + +/* Option -cd alias -cdi */ +int Xorriso_option_cdi(struct XorrisO *xorriso, char *iso_rr_path, int flag); + +/* Option -cdx */ +int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag); + +/* Option -chgrp alias -chgrpi , chgrp_r alias chgrpi */ +/* @param flag bit0=recursive (-chgrp_r) +*/ +int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, + int argc, char **argv, int *idx, int flag); + +/* Option -chmod alias -chmodi , -chmod_r alias chmod_ri */ +/* @param flag bit0=recursive (-chmod_r) +*/ +int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode, + int argc, char **argv, int *idx, int flag); + +/* Option -chown alias -chowni , chown_r alias chown_ri */ +/* @param flag bit0=recursive (-chown_r) +*/ +int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, + int argc, char **argv, int *idx, int flag); + +/* Option -close "on"|"off" */ +int Xorriso_option_close(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -commit */ +/* @param flag bit0= leave indrive and outdrive aquired as they were, + i.e. do not aquire outdrive as new in-out-drive + bit1= do not perform eventual -reassure + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_commit(struct XorrisO *xorriso, int flag); + +/* Option -commit_eject */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_commit_eject(struct XorrisO *xorriso, char *which, int flag); + +/* Option -compare and -compare_r + @param flag bit0= issue summary message + bit1= do not reset pacifier, no final pacifier message + bit2= do not issue pacifier messages at all + bit3= recursive: -compare_r +*/ +int Xorriso_option_compare(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag); + +/* Option -cpr alias -cpri */ +int Xorriso_option_cpri( struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -cut_out */ +int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path, + char *start, char *count, char *iso_rr_path, int flag); + +/* Options -dev , -indev, -outdev */ +/* @param flag bit0=use as indev , bit1= use as outdev + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_dev(struct XorrisO *xorriso, char *adr, int flag); + +/* Option -devices */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_devices(struct XorrisO *xorriso, int flag); + +/* Option -dialog "on"|"off" */ +int Xorriso_option_dialog(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -disk_pattern "on"|"ls"|"off" */ +int Xorriso_option_disk_pattern(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -dummy "on"|"off" */ +int Xorriso_option_dummy(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -eject */ +/* @param flag bit0=do not report toc of eventually remaining drives +*/ +int Xorriso_option_eject(struct XorrisO *xorriso, char *which, int flag); + +/* Options -end , and -rollback_end */ +/* @param flag bit0= discard pending changes + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_end(struct XorrisO *xorriso, int flag); + +/* Option -iso_rr_pattern "on"|"ls"|"off" */ +int Xorriso_option_iso_rr_pattern(struct XorrisO *xorriso, char *mode, + int flag); + +/* Option -follow */ +int Xorriso_option_follow(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -find alias -findi, and -findx */ +/* @param flag bit0= -findx rather than -findi + bit1= do not reset pacifier, no final pacifier message + do not reset find_compare_result +*/ +int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -fs */ +int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag); + +/* Option -gid */ +int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag); + +/* Option -help and part of -prog_help */ +int Xorriso_option_help(struct XorrisO *xorriso, int flag); + +/* Option -history */ +int Xorriso_option_history(struct XorrisO *xorriso, char *line, int flag); + +/* Option -joliet "on"|"off" */ +int Xorriso_option_joliet(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -logfile */ +int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel, + char *fileadr, int flag); + +/* Options -ls alias -lsi and -lsl alias -lsli + and -lsd alias -lsdi and -lsdl alias -lsdli + and -du alias -dui and -dus alias -dusi + @param flag bit0= long format (-lsl , -du) + bit1= do not expand patterns but use literally + bit2= du rather than ls + bit3= list directories as themselves (ls -d) +*/ +int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Options -lsx, -lslx, -lsdx , -lsdlx , -dux , -dusx + @param flag bit0= long format (-lslx , -dux) + bit1= do not expand patterns but use literally + bit2= du rather than ls + bit3= list directories as themselves (ls -d) +*/ +int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -mark */ +int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag); + +/* Option -mkdir alias -mkdiri */ +int Xorriso_option_mkdiri(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -mv alias -mvi */ +int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -no_rc */ +int Xorriso_option_no_rc(struct XorrisO *xorriso, int flag); + +/* Option -options_from_file*/ +/* @return <=0 error , 1 = success , 3 = request to end program run */ +int Xorriso_option_options_from_file(struct XorrisO *xorriso, char *adr, + int flag); + +/* Option -overwrite "on"|"nondir"|"off" */ +int Xorriso_option_overwrite(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -padding */ +int Xorriso_option_padding(struct XorrisO *xorriso, char *size, int flag); + +/* Option -page */ +int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag); + +/* Option -path-list */ +int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag); + +/* Option -pathspecs */ +int Xorriso_option_pathspecs(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -pkt_output */ +int Xorriso_option_pkt_output(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -print */ +int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag); + +/* Option -print-size + @param flag bit0= report in mkisofs compatible form on real stdout +*/ +int Xorriso_option_print_size(struct XorrisO *xorriso, int flag); + +/* Option -prog */ +int Xorriso_option_prog(struct XorrisO *xorriso, char *name, int flag); + +/* Option -prog_help */ +int Xorriso_option_prog_help(struct XorrisO *xorriso, char *name, int flag); + +/* Option -publisher */ +int Xorriso_option_publisher(struct XorrisO *xorriso, char *name, int flag); + +/* Option -pwd alias -pwdi */ +int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag); + +/* Option -pwdx */ +int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag); + +/* Option -report_about */ +int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity, + int flag); + +/* Option -return_with */ +int Xorriso_option_return_with(struct XorrisO *xorriso, char *severity, + int exit_value, int flag); + +/* Option -reassure "on"|"tree"|"off" */ +int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag); + +/* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */ +/* @param flag bit0=recursive , bit2= remove empty directory: rmdir */ +int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -rollback */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_rollback(struct XorrisO *xorriso, int flag); + +/* Option -session_log */ +int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag); + +/* Option -speed */ +int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag); + +/* Option -split_size */ +int Xorriso_option_split_size(struct XorrisO *xorriso, char *s, int flag); + +/* Option -status */ +int Xorriso_option_status(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -status_history_max */ +int Xorriso_option_status_history_max(struct XorrisO *xorriso, int num1, + int flag); + +/* Option -tell_media_space */ +int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag); + +/* Option -temp_mem_limit */ +int Xorriso_option_temp_mem_limit(struct XorrisO *xorriso, char *size, + int flag); + +/* Option -toc */ +int Xorriso_option_toc(struct XorrisO *xorriso, int flag); + +/* Option -uid */ +int Xorriso_option_uid(struct XorrisO *xorriso, char *uid, int flag); + +/* Options -update and -update_r + @param flag bit0= issue summary message + bit1= do not reset pacifier, no final pacifier message + bit2= do not issue pacifier messages at all + bit3= recursive: -update_r +*/ +int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag); + +/* Option -use_readline */ +int Xorriso_option_use_readline(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -version */ +int Xorriso_option_version(struct XorrisO *xorriso, int flag); + +/* Option -volid */ +int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag); + + +#endif /* Xorriso_includeD */ + + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorriso_eng.html b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_eng.html new file mode 100644 index 00000000..3f55dd6a --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_eng.html @@ -0,0 +1,479 @@ +<HTML> + +<HEAD> +<META NAME="description" CONTENT="xorriso, creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions"> +<META NAME="keywords" CONTENT="xorriso, libburn, libburnia, burn, CD, DVD, ISO, ISO 9660, RockRidge, Rock Ridge, linux, recording, burning, CD-R, CD-RW, DVD-R, DVD-RW, DVD+RW, DVD+R, DVD+R/DL, scdbackup"> +<META NAME="robots" CONTENT="follow"> +<TITLE>xorriso homepage english + + + + + +
+

Homepage of

+

xorriso

+ +

ISO 9660 Rock Ridge Filesystem Manipulator for Linux

+
+ +

+

Purpose:

+xorriso maps file objects from POSIX compliant filesystems +into Rock Ridge enhanced ISO 9660 filesystems and allows +session-wise manipulation of such filesystems. It can load the management +information of existing ISO images and it writes the session results to +optical media or to filesystem objects. +

+

+ +


+ +Direct hop to download links -> + +

+

Hardware requirements:

+A CD/DVD recorder suitable for +http://libburnia-project.org
+(SCSI , ATA , USB , or SATA writers compliant to standard MMC-3 for CD +and to MMC-5 for DVD). +
+

+ +

+

Software requirements :

+
+
Linux with kernel 2.4 or higher (and libc, of course) :
+
With kernel 2.4 an ATA drive has to be under ide-scsi emulation.
+
With kernel 2.6 the drive should not be under ide-scsi.
+
libpthread
+
is supposed to be a standard system component.
+
libreadline and libreadline-dev
+
are optional and eventually make dialog more convenient.
+
+

+ +

+

+GPL software included:
+

+
+
libburn-0.4.3
+
reads and writes data from and to CD and DVD.
+
(founded by Derek Foreman and Ben Jansens, +furthered since August 2006 by team of libburnia-project.org)
+
libisofs-0.6.3
+
operates ISO 9660 images.
+
(By Vreixo Formoso and Mario Danic from team of libburnia-project.org)
+
libisoburn-0.1.1
+
coordinates libburn and libisofs, emulates multi-session where needed.
+
(By Vreixo Formoso and Thomas Schmitt +from team of libburnia-project.org)
+
+
The source code of this software is independent of +cdrecord and mkisofs. +
+

+ +

+This program system has been tested on Intel/AMD Linux systems only.
+For ports to other usable systems contact us. +

+ +
+ +

+

Special features:

+
    +
  • +ISO 9660 formatter and burner for CD or DVD are fixely integrated. +
  • +
  • +Operates on an existing ISO image or creates a new one. +
  • +
  • +Copies files from filesystem into the ISO image. +
  • +
  • +Renames or deletes file objects in the ISO image. +
  • +
  • +Changes file properties in the ISO image. +
  • +
  • +Updates ISO subtrees incrementally to match given disk subtrees. +
  • +
  • +Can write result as completely new image to optical media or +filesystem objects. +
  • +
  • +Can write result as add-on session to appendable multi-session media, +to overwriteable media, to regular files, and to block devices. +
  • +
  • +Scans for optical drives, blanks re-useable optical media. +
  • +
  • +Suitable for: CD-R, CD-RW, DVD-R, DVD-RW, DVD+R, DVD+R/DL, DVD+RW, DVD-RAM. +
  • +
  • +Reads its instructions from command line arguments, dialog, and batch files. +
  • +
  • +Provides navigation commands for interactive ISO image manipulation. +
  • +
  • +Adjustable thresholds for abort, exit value, and problem reporting. +
  • + +
+

+ +

+

Command Examples:

+
+
Get an overview of drives and their addresses
+
# xorriso -devices
+
Being superuser avoids permission problems with /dev/srN resp. /dev/hdX . +
+
Ordinary users should then get granted rw access to the /dev files +as listed by option -devices.
+
 
+ +
Options are either performed as program arguments or as dialog input. +Some options have a parameter list of variable length. This list has to +be terminated by word '--' or by the end of the input line. Option -add +may accept pathspecs of form target=source as known from program mkisofs.
+ +
+ +
Get info about a particular drive and loaded media:
+
$ xorriso -indev /dev/sr0 -du / -- -toc 2>&1 | less
+ +
Make re-usable media writable again, delete any ISO 9660 image:
+
$ xorriso -outdev /dev/sr0 -blank fast -eject all
+ +
+
+
+ +
Write some directories into a new or existing ISO 9660 image:
+
$ xorriso -dev /dev/sr0 -add /home/me/sounds /home/me/pictures +
+ +
Check the result:
+
$ xorriso -indev /dev/sr0 -du / -- -toc 2>&1 | less
+ +
+
+
+ +
Create new ISO-9660 filesystem image, compose content, +adjust permissions to make it publicly read-only, +write it to media and immediately eject media without +previously reloading the written image. +
+
$ xorriso -outdev /dev/sr0 -blank fast -pathspecs on \
+
  -add /sounds=/home/me/sounds \
+
       +/pictures=/home/me/pictures -- \
+
  -rm_r /sounds/indecent '/pictures/*private*' -- \
+
  -add /pictures/private/horses=/home/me/pictures/private/horses -- \
+
  -chmod_r a+r,a-w / -- \
+
  -find / -type d -exec chmod a+x -- \
+
  -volid SOUNDS_PICS_2008_01_16 \
+
  -commit_eject all
+ +
+
+
+ +
Load the previous session from media, +remove (i.e. hide) directory /sounds, +rename /pictures/private/horses, +add new directory trees /sounds and /movies, +disallow any access for group and others. +Finally write as additional session to media and eject:
+
$ xorriso -dev /dev/sr0 -pathspecs on \
+
  -rm_r /sounds -- \
+
  -mv /pictures/private/horses /horse_show -- \
+
  -add /sounds=/home/me/prepared_for_dvd/sounds_dummy \
+
       /movies=/home/me/prepared_for_dvd/movies -- \
+
  -chmod_r go-rwx / -- \
+
  -volid SOUNDS_PICS_2008_01_17 \
+
  -commit_eject all
+ +
+
+
+ +
Merge the various sessions from old readable media into a single session +on new writeable media, +cleaning out all invalidated files and session overhead. +Touch / in order to mark the image as worth to be written. +
+Important: -indev and -outdev have to be different drives. +
+
$ xorriso -indev /dev/dvd \
+
  -alter_date a +0 / -- \
+
  -outdev /dev/sr0 -blank fast \
+
  -commit_eject all
+ +
+
+
+ +
Dialog mode accepts one or more options per line. An option and all its +arguments have to be given in one single line. Command -end stops the program +run. It will write eventually pending changes to media, if that has not +already been done by a previous -commit.
+
$ xorriso -dialog on
+
enter option and arguments :
+
-dev /dev/sr0 -pathspecs on
+
enter option and arguments :
+
-add /sounds=/home/me/prepared_for_dvd/sounds_dummy /movies=/home/me/prepared_for_dvd/movies
+
Available navigation commands: -cd, -ls, -du, -find
+
enter option and arguments :
+
-commit
+
... perform further commands and finally do:
+
enter option and arguments :
+
-end
+ +
+
+
+ +
The following command can be run on blank media to create a complete +copy of the mentioned disk directory trees, and it can be run on appendable +media to perform a minimal set of change operations which update the +old ISO copies to match the new disk trees. On CD-R[W], DVD-R[W] and DVD+R +older states can be retrieved by help of mount option "session=". +So this constitutes true incremental backup. +On overwriteable media only the newest state is accessible. +
+
$ xorriso -dev /dev/sr0 \
+
   -update_r /home/thomas/open_source_projects /open_source_projects \
+
   -update_r /home/thomas/personal_mail /personal_mail \
+
   -commit_eject all \
+ +
+
+
+ +
In batch mode it is possible to operate xorriso in a pipeline +with an external consumer of the generated ISO image. Any message +output will be redirected to stderr in this case.
+
$ xorriso -outdev - ...other.options... | consumer
+ +
+
+
+ + +
Get overview of the options:
+
$ xorriso -help
+ +
Read the detailed manual page:
+
$ man xorriso
+
+ + +Testers wanted who are willing to risk some double layer DVD media. + +

+ +
+ +

+

+
Download as source code (see README):
+
xorriso-0.1.2.pl00.tar.gz +(950 KB). +
+ + + +
+ + +
Documentation:
+
README about installation and drive setup
+
xorriso -help gives an overview of options
+
man xorriso is the manual page
+
+ +
Contact:
+
Thomas Schmitt, scdbackup@gmx.net
+
libburn development mailing list, +libburn-hackers@pykix.org
+
+
License:
+
GPL version 2, +an Open Source approved license
+
 
+
+

+ +
+ +

+Enhancements towards previous stable version xorriso-0.1.0: +

    +
  • Improved attribute transfer from disk for implicit target directories
  • +
  • New option -as "cdrecord" emulates a narrow set of cdrecord gestures
  • +
  • New option -as "mkisofs" emulates a narrow set of mkisofs gestures
  • +
  • New option -publisher
  • +
  • New option -errfile_log
  • +
  • Support for DVD+R/DL media
  • +
  • New options -compare , -compare_r and according -find -exec action
  • +
  • New options -update , -update_r and according -find -exec action
  • +
  • New -find actions "rm", "rm_r", new -findx -type "m" -exec "empty_iso_dir" +
  • +
  • New option -cut_out
  • +
+Bug fixes towards xorriso-0.1.0.pl00: +
    +
  • -report_about HINT or higher did not report at all
  • +
  • speed=number without unit or media type letter was always CD speed
  • +
  • It was possible to write to appendable media which was not -indev
  • +
  • -follow param did not work for adding non-directory symbolic links
  • +
  • It was not possible to do: -add /THIS=a /b=THIS --
  • +
+

+ +
+ +

+

+

Development snapshot, version 0.1.3 :

+
Bug fixes towards xorriso-0.1.2.pl00: +
    +
  • -as mkisofs -no-pad was misspelled -nopad
  • +
  • Implicite directory attribute copying with -cut_out was wrong
  • + +
+
+
Enhancements towards stable version 0.1.2.pl00: +
    +
  • Coordination of -cut_out, -compare and -update
  • +
  • New option -session_log
  • +
  • New option -split_size allows automated splitting of oversized files
  • +
  • Improved performance with reading directory trees
  • + +
+
+
 
+
README 0.1.3 +
xorriso_0.1.3 -help
+
man xorriso (as of 0.1.3)
+
 
+
If you want to distribute development versions of xorriso, then use +this tarball which produces static linking between xorriso and the +libburnia libraries. +
+
Source (./bootstrap is already applied, build tested, +installation see README) +
+
+xorriso-0.1.3.tar.gz +(960 KB). +
+
A dynamically linked development version of xorriso can be obtained +from repositories of + libburnia-project.org. +xorriso is part of libisoburn/trunk and will get built by its "make". +
+
Be warned that the libraries in SVN and bzr are development versions with +possibly unstable API/ABI enhancements. Do not distribute development +versions for dynamic linking. Only release versions are safe for that. +
+
Download: svn co http://svn.libburnia-project.org/libburn/trunk libburn +
+
Install: cd libburn ; ./bootstrap ; ./configure --prefix /usr ; make ; make install +
+
Download: bzr branch lp:libisofs
+
Install: cd libisofs ; ./bootstrap ; ./configure --prefix /usr ; make ; make install +
+
Download: svn co http://svn.libburnia-project.org/libisoburn/trunk libisoburn +
+
Install: cd libisoburn ; ./bootstrap ; ./configure --prefix /usr ; make ; make install +
+
Build of SVN versions needs +autotools of at least version 1.7 installed. +But after the run of ./bootstrap, only +vanilla tools like make and gcc are needed.
+ +
 
+ + + +
+

+ +
+ +

+Many thanks to Derek Foreman and Ben Jansens for starting libburn. +
+Very special thanks to Andy Polyakov whose +dvd+rw-tools +provide the libburnia project with invaluable examples on how to deal +with DVD media and how to emulate multi-session on overwriteable media. +

+ +
+ + +
+ +

+Enjoying free Open Source hosting by www.webframe.org
+ +100 % Microsoft free
+and by sourceforge.net
+ +SourceForge Logo + +
+
+
+
Links to my other published software projects :
+
+cdrskin, a cdrecord emulator
+
+scdbackup, multi volume CD backup
+
+(a second source of above)
+
Some Tools for Image Collectors
+
+pppoem, a DSL throughput monitor (mainly for Linux kernel 2.4)
+
+

+Legal statement: This website does not serve any commercial purpose.
+

+
+ + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorriso_makefile_am.txt b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_makefile_am.txt new file mode 100644 index 00000000..6cdb689b --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_makefile_am.txt @@ -0,0 +1,189 @@ +pkgconfigdir=$(libdir)/pkgconfig +libincludedir= + +lib_LTLIBRARIES = + +## ========================================================================= ## + +libinclude_HEADERS = + +## ========================================================================= ## + +bin_PROGRAMS = \ + xorriso/xorriso + +xorriso_xorriso_CPPFLAGS = -I./libburn -I./libisofs -I./libisoburn -I./xorriso + +# No readline in the vanilla version because the necessary headers +# are in a separate readline-development package. +xorriso_xorriso_CFLAGS = -DXorriso_standalonE -DXorriso_with_maiN -DXorriso_with_regeX $(READLINE_DEF) + +xorriso_xorriso_LDADD = $(THREAD_LIBS) + +xorriso_xorriso_SOURCES = \ + \ + xorriso/xorriso.h \ + xorriso/xorriso_private.h \ + xorriso/xorriso.c \ + xorriso/xorrisoburn.h \ + xorriso/xorrisoburn.c \ + xorriso/xorriso_timestamp.h \ + \ + libisoburn/libisoburn.h \ + libisoburn/isoburn.h \ + libisoburn/isoburn.c \ + libisoburn/isofs_wrap.c \ + libisoburn/burn_wrap.c \ + libisoburn/data_source.c \ + \ + libisofs/builder.h \ + libisofs/builder.c \ + libisofs/error.h \ + libisofs/node.h \ + libisofs/node.c \ + libisofs/tree.h \ + libisofs/tree.c \ + libisofs/image.h \ + libisofs/image.c \ + libisofs/iso1999.h \ + libisofs/iso1999.c \ + libisofs/fsource.h \ + libisofs/fsource.c \ + libisofs/fs_local.c \ + libisofs/fs_image.h \ + libisofs/fs_image.c \ + libisofs/messages.h \ + libisofs/messages.c \ + libisofs/libiso_msgs.h \ + libisofs/libiso_msgs.c \ + libisofs/stream.h \ + libisofs/stream.c \ + libisofs/util.h \ + libisofs/util.c \ + libisofs/util_rbtree.c \ + libisofs/util_htable.c \ + libisofs/filesrc.h \ + libisofs/filesrc.c \ + libisofs/ecma119.h \ + libisofs/ecma119.c \ + libisofs/ecma119_tree.h \ + libisofs/ecma119_tree.c \ + libisofs/writer.h \ + libisofs/buffer.c \ + libisofs/rockridge.h \ + libisofs/rockridge.c \ + libisofs/rockridge_read.c \ + libisofs/joliet.h \ + libisofs/joliet.c \ + libisofs/eltorito.h \ + libisofs/eltorito.c \ + libisofs/data_source.c \ + libisofs/find.c \ + libisofs/filter.h \ + libisofs/filter.c \ + libisofs/filters/xor_encrypt.c \ + \ + libburn/async.c \ + libburn/async.h \ + libburn/back_hacks.h \ + libburn/cleanup.c \ + libburn/cleanup.h \ + libburn/crc.c \ + libburn/crc.h \ + libburn/debug.c \ + libburn/debug.h \ + libburn/drive.c \ + libburn/drive.h \ + libburn/error.h \ + libburn/file.c \ + libburn/file.h \ + libburn/init.c \ + libburn/init.h \ + libburn/lec.c \ + libburn/lec.h \ + libburn/libburn.h \ + libburn/libdax_audioxtr.h \ + libburn/libdax_audioxtr.c \ + libburn/libdax_msgs.h \ + libburn/libdax_msgs.c \ + libburn/mmc.c \ + libburn/mmc.h \ + libburn/null.c \ + libburn/null.h \ + libburn/options.c \ + libburn/options.h \ + libburn/os.h \ + libburn/read.c \ + libburn/read.h \ + libburn/sbc.c \ + libburn/sbc.h \ + libburn/sector.c \ + libburn/sector.h \ + libburn/sg.c \ + libburn/sg.h \ + libburn/source.h \ + libburn/source.c \ + libburn/spc.c \ + libburn/spc.h \ + libburn/structure.c \ + libburn/structure.h \ + libburn/toc.c \ + libburn/toc.h \ + libburn/transport.h \ + libburn/util.c \ + libburn/util.h \ + libburn/write.c \ + libburn/write.h \ + \ + version.h + + +noinst_PROGRAMS = \ + test/compare_file + +# A program to compare two trees of files in mounted filesystems +# To compare tree /media/dvd and /original/dir : +# find /media/dvd -exec test/compare_file '{}' /media/dvd /original/dir ';' +# +test_compare_file_CPPFLAGS = +test_compare_file_CFLAGS = +test_compare_file_LDADD = +test_compare_file_SOURCES = test/compare_file.c + + +## ========================================================================= ## + +# Indent source files +indent_files = + + +indent: $(indent_files) + indent -bad -bap -nbbb -nbbo -nbc -bli0 -br -bls \ + -cdw -ce -cli0 -ncs -nbfda -i8 -l79 -lc79 \ + -lp -saf -sai -nprs -npsl -saw -sob -ss -ut \ + -sbi0 -nsc -ts8 -npcs -ncdb -fca \ + $^ + +.PHONY: indent + +## ========================================================================= ## + +# Extra things +nodist_pkgconfig_DATA = \ + xorriso.pc + +man_MANS = xorriso/xorriso.1 + +EXTRA_DIST = \ + xorriso.pc.in \ + version.h.in \ + README \ + AUTHORS \ + CONTRIBUTORS \ + COPYRIGHT \ + COPYING \ + INSTALL \ + xorriso/changelog.txt \ + $(man_MANS) + + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorriso_pc_in.txt b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_pc_in.txt new file mode 100644 index 00000000..5e35e873 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_pc_in.txt @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: xorriso +Description: ISO 9660 filesystem image manipulator +Version: @VERSION@ +Requires: +Libs: -L${libdir} -lpthread +Cflags: + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorriso_private.h b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_private.h new file mode 100644 index 00000000..bbd97908 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_private.h @@ -0,0 +1,457 @@ + +/* Command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2008 Thomas Schmitt, + + Provided under GPL version 2. + + This file contains inner declarations of xorriso. + The public interface is in xorriso.h +*/ + + +/* For now, #ifdef Xorriso_is_xorriso_selF has no meaning. + But it is already now to be set only by the xorriso.c module. +*/ + +#ifndef Xorriso_private_includeD +#define Xorriso_private_includeD yes + +#define Xorriso_program_versioN "0.1.3" + +/** The source code release timestamp */ +#include "xorriso_timestamp.h" +#ifndef Xorriso_timestamP +#define Xorriso_timestamP "-none-given-" +#endif + +/** The binary build timestamp is to be set externally by the compiler */ +#ifndef Xorriso_build_timestamP +#define Xorriso_build_timestamP "-none-given-" +#endif + + +/* Because regex_t is mentioned in struct XorrisO */ +#ifdef Xorriso_with_regeX +#include +#endif /* Xorriso_with_regeX */ + + +#define Smem_malloC malloc +#define Smem_freE free +#define SfileadrL 4096 + +/* <<< ??? */ +typedef int (*Cleanup_app_handler_T)(); + +struct LinkiteM; + +/* maximum number of history lines to be reported with -status:long_history */ +#define Xorriso_status_history_maX 100 + +/* <<< ??? */ +/* try to catch signals and ignore them during abort handling */ +#define Xorriso_abort_handler_defaulT (1|(2<<4)) + + +/** The list of startup file names */ +#define Xorriso_rc_nuM 4 + + +struct XorrisO { /* the global context of xorriso */ + + int libs_are_started; + + /* source */ + char progname[SfileadrL]; + char initial_wdx[SfileadrL]; + int no_rc; + + /** List of startupfiles */ + char rc_filenames[Xorriso_rc_nuM][SfileadrL]; + int rc_filename_count; + + char wdi[SfileadrL]; + char wdx[SfileadrL]; + int did_something_useful; + + int add_plainly; + off_t split_size; + + /* >>> put libisofs aspects here <<< */ + + int do_joliet; + int do_follow_pattern; + int do_follow_param; + int do_follow_links; + int follow_link_limit; + int do_follow_mount; + int do_global_uid; + uid_t global_uid; + int do_global_gid; + gid_t global_gid; + int do_global_mode; + mode_t global_dir_mode; + mode_t global_file_mode; + + int do_overwrite; /* 0=off, 1=on, 2=nondir */ + int do_reassure; /* 0=off, 1=on, 2=tree */ + + char volid[33]; + int volid_default; + char loaded_volid[33]; + + char publisher[129]; + + char session_logfile[SfileadrL]; + int session_lba; + int session_blocks; + + /* >>> put libburn/isoburn aspects here */ + + char indev[SfileadrL]; + void *in_drive_handle; /* interpreted only by xorrisoburn.c */ + void *in_volset_handle; /* interpreted only by xorrisoburn.c */ + + int volset_change_pending; /* whether -commit would make sense */ + int no_volset_present; /* set to 1 on first failure */ + + char outdev[SfileadrL]; + void *out_drive_handle; /* interpreted only by xorrisoburn.c */ + int dev_fd_1; /* The fd which substitutes for /dev/fd/1 and is + connected to externaly perveived stdout. + */ + + int ban_stdio_write; + int do_dummy; + int do_close; + int speed; /* in libburn units : 1000 bytes/second , 0 = Max, -1 = Min */ + int fs; /* fifo size in 2048 byte chunks : at most 1 GB */ + int padding; /* number of bytes to add after ISO 9660 image */ + + int keep_boot_image; + int patch_isolinux_image; + + + /* XORRISO options */ + int allow_graft_points; + + int dialog; + + + /* Pattern matching facility. It still carries legacy from scdbackup/askme.c + but is fully functional for xorriso. + */ + int search_mode; + /* 0= start text + 1= fgrep , + 2= regular expression + 3= (eventually structured) shell parser expression + 4= shell parser expression for leaf name + */ + + int structured_search; + /* 0= flat text search + 1= '/' is a significant separator that cannot be matched by wildcards + ( 2= like 1 : but report only occurence in tree, no payload, no location ) + ( 3= like 2 : but report first content level of matching directories ) + 4= actually not structured but unique find mode (with search_mode 4) + */ + + int do_iso_rr_pattern; /* 0=off, 1=on, 2=ls */ + int do_disk_pattern; /* 0=off, 1=on, 2=ls */ + + int temp_mem_limit; + + int use_stdin; /* use raw stdin even if readline support is compiled */ + int result_page_length; + int result_page_width; + char mark_text[SfileadrL]; /* ( stdout+stderr, M: ) */ + int packet_output; + char logfile[4][SfileadrL]; + int status_history_max; /* for -status long_history */ + + char report_about_text[20]; + int report_about_severity; + int library_msg_direct_print; + char abort_on_text[20]; + int abort_on_severity; /* A severity rank number as threshold */ + int problem_status; /* Severity rank number. 0= no abort condition present */ + char problem_status_text[20]; + + char errfile_log[SfileadrL]; /* for -errfile_log */ + int errfile_mode; /* bit0= marked */ + FILE *errfile_fp; + + char return_with_text[20]; + int return_with_severity; + int return_with_value; + int eternal_problem_status; + char eternal_problem_status_text[20]; + + /* temporary search facilities */ +#ifdef Xorriso_with_regeX + regex_t *re; + regmatch_t match[1]; +#endif /* Xorriso_with_regeX */ + char **re_constants; + int re_count; + int re_fill; + char reg_expr[2*SfileadrL]; + + /* run state */ + int run_state; /* 0=preparing , 1=writing image */ + int is_dialog; + int bar_is_fresh; + char pending_option[SfileadrL]; /* eventual option entered at page prompt */ + int request_to_abort; /* abort a single operation like -ls, not the program */ + int request_not_to_ask; /* suppress reassure and pager */ + double idle_time; + int re_failed_at; /* mismatch position with structured_search */ + int prepended_wd; + double insert_count; + double insert_bytes; + double error_count; /* double will not roll over */ + + /* pacifiers */ + double pacifier_interval; + double start_time; + double last_update_time; + /* optional global counters for brain reduced callback functions */ + off_t pacifier_count; + off_t pacifier_total; + + void *pacifier_fifo; + + int find_compare_result; /* 1=everything matches , 0=mismatch , -1=error */ + + /* result (stdout, R: ) */ + char result_line[5*SfileadrL]; + int result_line_counter; + int result_page_counter; + int result_open_line_len; + + + /* info (stderr, I:) */ + char info_text[10*SfileadrL]; + +}; + + +int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag); + +int Xorriso_result(struct XorrisO *xorriso, int flag); + +int Xorriso_info(struct XorrisO *xorriso, int flag); + +int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag); + +int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv, + int flag); + +int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag); + +/* @return 0=match , else no match +*/ +int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at, + int flag); + +int Xorriso_prepare_expansion_pattern(struct XorrisO *xorriso, char *pattern, + int flag); + +int Xorriso__mode_to_perms(mode_t st_mode, char perms[10], int flag); + +int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag); + +int Xorriso_check_temp_mem_limit(struct XorrisO *xorriso, off_t mem, int flag); + +int Xorriso_eval_nonmatch(struct XorrisO *xorriso, char *pattern, + int *nonconst_mismatches, off_t *mem, int flag); + +/* @param flag bit0= a match count !=1 is a SORRY event +*/ +int Xorriso_check_matchcount(struct XorrisO *xorriso, + int count, int nonconst_mismatches, int num_patterns, + char **patterns, int flag); + +int Xorriso_no_pattern_memory(struct XorrisO *xorriso, off_t mem, int flag); + +int Xorriso_alloc_pattern_mem(struct XorrisO *xorriso, off_t mem, + int count, char ***filev, int flag); + +/* @param flag bit0= count results rather than storing them + @return <=0 error , 1 is root (end processing) , + 2 is not root (go on processing) +*/ +int Xorriso_check_for_root_pattern(struct XorrisO *xorriso, + int *filec, char **filev, int count_limit, off_t *mem, int flag); + +/* @param flag bit0= prepend wd only if name does not begin by '/' + bit2= prepend wd (automatically done if wd[0]!=0) +*/ +int Xorriso_make_abs_adr(struct XorrisO *xorriso, char *wd, char *name, + char adr[], int flag); + +/* @param flag bit0= count result rather than storing it + bit1= unexpected change of number is a FATAL event +*/ +int Xorriso_register_matched_adr(struct XorrisO *xorriso, + char *adr, int count_limit, + int *filec, char **filev, off_t *mem, int flag); + +int Xorriso_format_ls_l(struct XorrisO *xorriso, struct stat *stbuf, int flag); + +/* @param flag bit0= simple readlink(): no normalization, no multi-hop +*/ +int Xorriso_resolve_link(struct XorrisO *xorriso, + char *link_path, char result_path[SfileadrL], int flag); + +/* @param flag bit0= for Xorriso_msgs_submit: use pager +*/ +int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path, + struct LinkiteM **link_stack, struct stat *stbuf, int flag); + +/* reg_expr should be twice as large as bourne_expr ( + 2 to be exact) */ +/* return: 2= bourne_expr is surely a constant */ +int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag); + +int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free, + int flag); + +int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag); + +/* This call is to be issued by long running workers in short intervals. + It will check whether enough time has elapsed since the last pacifier + message and eventually issue an update message. + @param what_done A sparse description of the action, preferrably in past + tense. E.g. "done" , "files added". + @param count The number of objects processed so far. + Is ignored if <=0. + @param todo The number of objects to be done in total. + Is ignored if <=0. + @param current_object A string telling the object currently processed. + Ignored if "". + @param flag bit0= report unconditionally, no time check +*/ +int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done, + off_t count, off_t todo, char *current_object, + int flag); + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit0= update rather than compare +*/ +int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, + char *iso_path, char *iso_prefix, char *disk_prefix, + int flag); + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world +*/ +int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, + int compare_result, char *disk_path, + char *iso_rr_path, int flag); + +int Sfile_str(char target[SfileadrL], char *source, int flag); + +double Sfile_microtime(int flag); + +int Sfile_add_to_path(char path[SfileadrL], char *addon, int flag); + +int Sfile_scale(double value, char *result, int siz, double thresh, int flag); + +int Sfile_destroy_argv(int *argc, char ***argv, int flag); + +/* + bit0= do not ignore trailing slash + bit1= do not ignore empty components (other than the empty root name) +*/ +int Sfile_count_components(char *path, int flag); + + +char *Text_shellsafe(char *in_text, char *out_text, int flag); + +int Sort_argv(int argc, char **argv, int flag); + +/* @param flag bit0= single letters */ +char *Ftypetxt(mode_t st_mode, int flag); + +struct DirseQ; + +int Dirseq_new(struct DirseQ **o, char *adr, int flag); + +int Dirseq_destroy(struct DirseQ **o, int flag); + +int Dirseq_next_adr(struct DirseQ *o, char reply[SfileadrL], int flag); + + +int Linkitem_reset_stack(struct LinkiteM **o, struct LinkiteM *to, int flag); + + +struct FindjoB; + +/* @return 0=no match , 1=match , <0 = error +*/ +int Findjob_test(struct FindjoB *job, char *name, + struct stat *boss_stbuf, struct stat *stbuf, + int depth, int flag); + +/* @return <0 error, >=0 see xorriso.c struct FindjoB.action +*/ +int Findjob_get_action(struct FindjoB *o, int flag); + +/* @return <0 error, >=0 see xorriso.c struct FindjoB.action +*/ +int Findjob_get_action_parms(struct FindjoB *o, char **target, + uid_t *user, gid_t *group, + mode_t *mode_and, mode_t *mode_or, + int *type, time_t *date, struct FindjoB **subjob, + int flag); + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_target(struct FindjoB *o, int action, char *target, + int flag); + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chgrp(struct FindjoB *o, gid_t group, int flag); + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chmod(struct FindjoB *o, + mode_t mode_and, mode_t mode_or, int flag); + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_ad(struct FindjoB *o, int type, time_t date, int flag); + +int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag); + +int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag); + + +struct SplitparT; + +int Splitparts_new(struct SplitparT **o, int count, int flag); + +int Splitparts_destroy(struct SplitparT **o, int count, int flag); + +int Splitparts_set(struct SplitparT *o, int idx, + char *name, int partno, int total_parts, + off_t offset, off_t bytes, off_t total_bytes, int flag); + +int Splitparts_get(struct SplitparT *o, int idx, char **name, int *partno, + int *total_parts, off_t *offset, off_t *bytes, + off_t *total_bytes, int flag); + +int Splitpart__parse(char *name, int *partno, int *total_parts, + off_t *offset, off_t *bytes, off_t *total_bytes, int flag); + +int Splitpart__compose(char *adr, int partno, int total_parts, + off_t offset, off_t bytes, off_t total_bytes, int flag); + + +#endif /* Xorriso_private_includeD */ + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorriso_timestamp.h b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_timestamp.h new file mode 100644 index 00000000..ab668c24 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorriso_timestamp.h @@ -0,0 +1 @@ +#define Xorriso_timestamP "2008.04.20.111419" diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorrisoburn.c b/libisoburn/branches/ZeroOneFour/xorriso/xorrisoburn.c new file mode 100644 index 00000000..73916902 --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorrisoburn.c @@ -0,0 +1,4948 @@ + + +/* Adapter to libisoburn, libisofs and libburn for xorriso, + a command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2008 Thomas Schmitt, + + Provided under GPL version 2. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +/* ------------------------------------------------------------------------ */ + +#ifndef Xorriso_standalonE + +/* The library which does the ISO 9660 / RockRidge manipulations */ +#include + +/* The library which does MMC optical drive operations */ +#include + +/* The library which enhances overwriteable media with ISO 9660 multi-session + capabilities via the method invented by Andy Polyakov for growisofs */ +#include + +/* The official xorriso options API. "No shortcuts" */ +#include "xorriso.h" + +/* The inner description of XorrisO */ +#include "xorriso_private.h" + +/* The inner isofs- and burn-library interface */ +#include "xorrisoburn.h" + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" +#include "../libisoburn/libisoburn.h" +#include "xorriso.h" +#include "xorriso_private.h" +#include "xorrisoburn.h" + +#endif /* Xorriso_standalonE */ + +/* Some private in advance declarations */ +int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive, + int flag); + +int Xorriso__read_pacifier(IsoImage *image, IsoFileSource *filesource); + +int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume, + IsoDir *dir, char *disk_path, char *img_name, + char *nominal_source, char *nominal_target, + off_t offset, off_t cut_size, + IsoNode **node, int flag); + +int Xorriso_is_split(struct XorrisO *xorriso, IsoNode *node, int flag); + + +#define LIBISO_ISDIR(node) (iso_node_get_type(node) == LIBISO_DIR) +#define LIBISO_ISREG(node) (iso_node_get_type(node) == LIBISO_FILE) +#define LIBISO_ISLNK(node) (iso_node_get_type(node) == LIBISO_SYMLINK) +#define LIBISO_ISCHR(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \ + S_ISCHR(iso_node_get_mode(node))) +#define LIBISO_ISBLK(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \ + S_ISBLK(iso_node_get_mode(node))) +#define LIBISO_ISFIFO(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \ + S_ISFIFO(iso_node_get_mode(node))) +#define LIBISO_ISSOCK(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \ + S_ISSOCK(iso_node_get_mode(node))) + +/* CD specs say one shall not write tracks < 600 kiB */ +#define Xorriso_cd_min_track_sizE 300 + + +/* ------------------------------------------------------------------------ */ + + +int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag) +{ + int ret, major, minor, micro; + char *handler_prefix= NULL; + char *queue_sev, *print_sev, reason[1024]; + + +/* First an ugly compile time check for header version compatibility. + If everthing matches, then no C code is produced. In case of mismatch, + intentionally faulty C code will be inserted. +*/ + +/* The minimum requirement of xorriso towards the libisoburn header + at compile time is defined in xorriso/xorrisoburn.h + xorriso_libisoburn_req_major + xorriso_libisoburn_req_minor + xorriso_libisoburn_req_micro + It gets compared against the version macros in libburn/libburn.h : + isoburn_header_version_major + isoburn_header_version_minor + isoburn_header_version_micro + If the header is too old then the following code shall cause failure of + cdrskin compilation rather than to allow production of a program with + unpredictable bugs or memory corruption. + The compiler messages supposed to appear in this case are: + error: 'LIBISOBURN_MISCONFIGURATION' undeclared (first use in this function) + error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisoburn_dot_h_TOO_OLD__SEE_xorrisoburn_dot_c' undeclared (first use in this function) + error: 'LIBISOBURN_MISCONFIGURATION_' undeclared (first use in this function) +*/ +/* The indendation is an advise of man gcc to help old compilers ignoring */ + #if xorriso_libisoburn_req_major > isoburn_header_version_major + #define Isoburn_libisoburn_dot_h_too_olD 1 + #endif + #if xorriso_libisoburn_req_major == isoburn_header_version_major && xorriso_libisoburn_req_minor > isoburn_header_version_minor + #define Isoburn_libisoburn_dot_h_too_olD 1 + #endif + #if xorriso_libisoburn_req_minor == isoburn_header_version_minor && xorriso_libisoburn_req_micro > isoburn_header_version_micro + #define Isoburn_libisoburn_dot_h_too_olD 1 + #endif + +#ifdef Isoburn_libisoburn_dot_h_too_olD +LIBISOBURN_MISCONFIGURATION = 0; +INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisoburn_dot_h_TOO_OLD__SEE_xorrisoburn_dot_c = 0; +LIBISOBURN_MISCONFIGURATION_ = 0; +#endif + +/* End of ugly compile time test (scroll up for explanation) */ + + + sprintf(xorriso->info_text, "Starting up libraries ...\n"); + Xorriso_info(xorriso, 0); + + handler_prefix= calloc(strlen(xorriso->progname)+3+1, 1); + if(handler_prefix==NULL) { + sprintf(xorriso->info_text, + "Cannot allocate memory for initializing libraries"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + reason[0]= 0; + ret= isoburn_initialize(reason, 0); + if(ret==0) { + sprintf(xorriso->info_text, "Cannot initialize libraries"); + if(reason[0]) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + ". Reason given:\n%s", reason); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + free(handler_prefix); + return(0); + } + ret= isoburn_is_compatible(isoburn_header_version_major, + isoburn_header_version_minor, + isoburn_header_version_micro, 0); + if(ret<=0) { + isoburn_version(&major, &minor, µ); + sprintf(xorriso->info_text, + "libisoburn version too old: %d.%d.%d . Need at least: %d.%d.%d .\n", + major, minor, micro, + isoburn_header_version_major, isoburn_header_version_minor, + isoburn_header_version_micro); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + + xorriso->libs_are_started= 1; + + queue_sev= "ALL"; + if(xorriso->library_msg_direct_print) { + + /* >>> need option for controlling this in XorrisO. + See also Xorriso_msgs_submit */; + + print_sev= xorriso->report_about_text; + } else + print_sev= "NEVER"; + + iso_set_msgs_severities(queue_sev, print_sev, "libsofs : "); + burn_msgs_set_severities(queue_sev, print_sev, "libburn : "); + + /* ??? >>> do we want united queues ? */ + /* burn_set_messenger(iso_get_messenger()); */ + + sprintf(handler_prefix, "%s : ", xorriso->progname); + burn_set_signal_handling(handler_prefix, NULL, 0); + + Xorriso_process_msg_queues(xorriso,0); + if(reason[0]) { + sprintf(xorriso->info_text, "%s", reason); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + + sprintf(xorriso->info_text, "Library startup done.\n"); + Xorriso_info(xorriso, 0); + free(handler_prefix); + return(1); +} + + +/* @param flag bit0= global shutdown of libraries */ +int Xorriso_detach_libraries(struct XorrisO *xorriso, int flag) +{ + Xorriso_give_up_drive(xorriso, 3); + if(xorriso->in_volset_handle!=NULL) { /* standalone image */ + iso_image_unref((IsoImage *) xorriso->in_volset_handle); + xorriso->in_volset_handle= NULL; + } + if(flag&1) { + if(xorriso->libs_are_started==0) + return(0); + isoburn_finish(); + } + return(1); +} + + +/* @param flag bit1= obtain outdrive, else indrive */ +int Xorriso_get_drive_handles(struct XorrisO *xorriso, + struct burn_drive_info **dinfo, + struct burn_drive **drive, + char *attempt, int flag) +{ + if(flag&2) + *dinfo= (struct burn_drive_info *) xorriso->out_drive_handle; + else + *dinfo= (struct burn_drive_info *) xorriso->in_drive_handle; + if(*dinfo==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "No %s drive aquired %s", + (flag&2 ? "output" : "input"), attempt); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + *drive= (*dinfo)[0].drive; + return((*drive)!=NULL); +} + + +/* ts A80408 : Moved to libburn-0.4.4 +*/ +#define Xorriso_on_libburn_after_0_4_2 yes + + +#ifndef Xorriso_on_libburn_after_0_4_2 + +/* >>> todo: throw out the copies of libdax_msgs entrails */ + +/* <<< to be replaced by libburn-0.4.3 API call burn_sev_to_text(). + This is a copy of libdax_msgs__sev_to_text() which is not exposed + by the API of of libburn-0.4.2 . As soon as xorriso gets based on + libburn-0.4.4 this redundancy is to be removed. + It is safe, nevertheless, because the severity codes are eternal. +*/ +#define LIBDAX_MSGS_SEV_ALL 0x00000000 +#define LIBDAX_MSGS_SEV_ERRFILE 0x08000000 +#define LIBDAX_MSGS_SEV_DEBUG 0x10000000 +#define LIBDAX_MSGS_SEV_UPDATE 0x20000000 +#define LIBDAX_MSGS_SEV_NOTE 0x30000000 +#define LIBDAX_MSGS_SEV_HINT 0x40000000 +#define LIBDAX_MSGS_SEV_WARNING 0x50000000 +#define LIBDAX_MSGS_SEV_SORRY 0x60000000 +#define LIBDAX_MSGS_SEV_MISHAP 0x64000000 +#define LIBDAX_MSGS_SEV_FAILURE 0x68000000 +#define LIBDAX_MSGS_SEV_FATAL 0x70000000 +#define LIBDAX_MSGS_SEV_ABORT 0x71000000 +#define LIBDAX_MSGS_SEV_NEVER 0x7fffffff + +#endif /* ! Xorriso_on_libburn_after_0_4_2 */ + + +int Xorriso__sev_to_text(int severity, char **severity_name, + int flag) +{ + int ret; + + ret= iso_sev_to_text(severity, severity_name); + if(ret>0) + return(ret); + +#ifdef Xorriso_on_libburn_after_0_4_2 + + ret= burn_sev_to_text(severity, severity_name, 0); + if(ret>0) + return(ret); + *severity_name= ""; + return(0); + +#else /* Xorriso_on_libburn_after_0_4_2 */ + + if(flag&1) { + *severity_name= "NEVER\nABORT\nFATAL\nFAILURE\nSORRY\nWARNING\nHINT\nNOTE\nUPDATE\nDEBUG\nALL"; + return(1); + } + *severity_name= ""; + if(severity>=LIBDAX_MSGS_SEV_NEVER) + *severity_name= "NEVER"; + else if(severity>=LIBDAX_MSGS_SEV_ABORT) + *severity_name= "ABORT"; + else if(severity>=LIBDAX_MSGS_SEV_FATAL) + *severity_name= "FATAL"; + else if(severity>=LIBDAX_MSGS_SEV_FAILURE) + *severity_name= "FAILURE"; + else if(severity>=LIBDAX_MSGS_SEV_MISHAP) + *severity_name= "MISHAP"; + else if(severity>=LIBDAX_MSGS_SEV_SORRY) + *severity_name= "SORRY"; + else if(severity>=LIBDAX_MSGS_SEV_WARNING) + *severity_name= "WARNING"; + else if(severity>=LIBDAX_MSGS_SEV_HINT) + *severity_name= "HINT"; + else if(severity>=LIBDAX_MSGS_SEV_NOTE) + *severity_name= "NOTE"; + else if(severity>=LIBDAX_MSGS_SEV_UPDATE) + *severity_name= "UPDATE"; + else if(severity>=LIBDAX_MSGS_SEV_DEBUG) + *severity_name= "DEBUG"; + else if(severity>=LIBDAX_MSGS_SEV_ERRFILE) + *severity_name= "ERRFILE"; + else if(severity>=LIBDAX_MSGS_SEV_ALL) + *severity_name= "ALL"; + else { + *severity_name= ""; + return(0); + } + return(1); + +#endif /* ! Xorriso_on_libburn_after_0_4_2 */ + +} + + +int Xorriso__text_to_sev(char *severity_name, int *severity_number, int flag) +{ + int ret= 1; + + ret= iso_text_to_sev(severity_name, severity_number); + if(ret>0) + return(ret); + +#ifndef Xorriso_on_libburn_after_0_4_2 + if(severity_name[0]==0) + *severity_number= 0; + else if(strcmp(severity_name, "MISHAP")==0) + *severity_number= LIBDAX_MSGS_SEV_MISHAP; + else if(strcmp(severity_name, "ERRFILE")==0) + *severity_number= LIBDAX_MSGS_SEV_ERRFILE; + else +#endif /* ! Xorriso_on_libburn_after_0_4_2 */ + + ret= burn_text_to_sev(severity_name, severity_number, 0); + return(ret); +} + + +/* @param flag bit0= report libisofs error text + bit1= victim is disk_path + bit2= do not inquire libisofs, report msg_text and min_severity +*/ +int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim, + int iso_error_code, char msg_text[], int os_errno, + char min_severity[], int flag) +{ + int error_code, iso_sev, min_sev, ret; + char *sev_text_pt, *msg_text_pt= NULL; + char sfe[6*SfileadrL]; + static int sorry_sev= -1; + + if(sorry_sev<0) + Xorriso__text_to_sev("SORRY", &sorry_sev, 0); + + if(flag&4) { + error_code= 0x00050000; + Xorriso__text_to_sev(min_severity, &iso_sev, 0); + } else { + error_code= iso_error_get_code(iso_error_code); + if(error_code < 0x00030000 || error_code >= 0x00040000) + error_code= (error_code & 0xffff) | 0x00050000; + if(flag&1) + msg_text_pt= (char *) iso_error_to_msg(iso_error_code); + iso_sev= iso_error_get_severity(iso_error_code); + } + if(msg_text_pt==NULL) + msg_text_pt= msg_text; + + if(iso_sev >= sorry_sev && (flag & 2) && victim[0]) + Xorriso_msgs_submit(xorriso, 0, victim, 0, "ERRFILE", 0); + sev_text_pt= min_severity; + Xorriso__text_to_sev(min_severity, &min_sev, 0); + if(min_sev < iso_sev && !(flag&4)) + Xorriso__sev_to_text(iso_sev, &sev_text_pt, 0); + strcpy(sfe, msg_text_pt); + if(victim[0]) { + strcat(sfe, ": "); + Text_shellsafe(victim, sfe+strlen(sfe), 0); + } + ret= Xorriso_msgs_submit(xorriso, error_code, sfe, os_errno, sev_text_pt, 4); + return(ret); +} + + +/* @param flag bit0= suppress messages below UPDATE + bit1= suppress messages below FAILURE +*/ +int Xorriso_set_image_severities(struct XorrisO *xorriso, int flag) +{ + char *queue_sev, *print_sev; + + if(flag&2) + queue_sev= "FAILURE"; + else if(flag&1) + queue_sev= "UPDATE"; + else + queue_sev= "ALL"; + if(xorriso->library_msg_direct_print) + print_sev= xorriso->report_about_text; + else + print_sev= "NEVER"; + iso_set_msgs_severities(queue_sev, print_sev, "libisofs : "); + return(1); +} + + +int Xorriso_update_volid(struct XorrisO *xorriso, int flag) +{ + int gret, sret= 1; + + gret= Xorriso_get_volid(xorriso, xorriso->loaded_volid, 0); + if(gret<=0 || (!xorriso->volid_default) || xorriso->loaded_volid[0]==0) + sret= Xorriso_set_volid(xorriso, xorriso->volid, 1); + return(gret>0 && sret>0); +} + + +int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag) +{ + int ret; + IsoImage *volset; + struct isoburn_read_opts *ropts; + struct burn_drive_info *dinfo= NULL; + struct burn_drive *drive= NULL; + + if(xorriso->out_drive_handle != NULL) { + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to attach volset to drive", 2); + if(ret<=0) + return(ret); + } + if(xorriso->in_volset_handle!=NULL) { + iso_image_unref((IsoImage *) xorriso->in_volset_handle); + xorriso->in_volset_handle= NULL; + xorriso->loaded_volid[0]= 0; + xorriso->volset_change_pending= 0; + xorriso->no_volset_present= 0; + } + + ret= isoburn_ropt_new(&ropts, 0); + if(ret<=0) + return(ret); + /* Note: no return before isoburn_ropt_destroy() */ + isoburn_ropt_set_extensions(ropts, isoburn_ropt_pretend_blank); + isoburn_ropt_set_input_charset(ropts, NULL); + isoburn_set_read_pacifier(drive, NULL, NULL); + ret= isoburn_read_image(drive, ropts, &volset); + Xorriso_process_msg_queues(xorriso,0); + isoburn_ropt_destroy(&ropts, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "Failed to create new empty ISO image object"); + Xorriso_report_iso_error(xorriso, "", ret, xorriso->info_text, 0, "FATAL", + 0); + return(-1); + } + xorriso->in_volset_handle= (void *) volset; + Xorriso_update_volid(xorriso, 0); + xorriso->volset_change_pending= 0; + xorriso->no_volset_present= 0; + return(1); +} + + +/* @param flag bit0= aquire as isoburn input drive + bit1= aquire as libburn output drive (as isoburn drive if bit0) + bit2= regard overwriteable media as blank + bit3= if the drive is a regular disk file: truncate it to + the write start address + @return <=0 failure , 1= ok + 2=success, but not writeable with bit1 + 3=success, but not blank and not ISO with bit0 +*/ +int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) +{ + int ret, hret, not_writeable= 0, has_what; + uint32_t size; + struct burn_drive_info *dinfo= NULL, *out_dinfo, *in_dinfo; + struct burn_drive *drive, *out_drive, *in_drive; + enum burn_disc_status state; + IsoImage *volset = NULL; + struct isoburn_read_opts *ropts= NULL; + char adr_data[SfileadrL], *libburn_adr, *boot_fate; + + if((flag&3)==0) { + sprintf(xorriso->info_text, + "XORRISOBURN program error : Xorriso_aquire_drive bit0+bit1 not set"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + ret= Xorriso_give_up_drive(xorriso, (flag&3)|8); + if(ret<=0) + return(ret); + + libburn_adr= adr; + if(strcmp(adr,"stdio:/dev/fd/1")==0) { + if(xorriso->dev_fd_1<0) { + sprintf(xorriso->info_text, + "-*dev \"stdio:/dev/fd/1\" was not a start argument. Cannot use it now."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } else { + sprintf(adr_data, "stdio:/dev/fd/%d", xorriso->dev_fd_1); + libburn_adr= adr_data; + } + } + + if((flag&3)==1 && xorriso->out_drive_handle!=NULL) { + ret= Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive, + "on attempt to compare new indev with outdev", 2); + if(ret<=0) + goto ex; + ret= burn_drive_equals_adr(out_drive, libburn_adr, 1); + if(ret==1) + dinfo= out_dinfo; + } else if((flag&3)==2 && xorriso->in_drive_handle!=NULL) { + ret= Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive, + "on attempt to compare new indev with outdev", 0); + if(ret<=0) + goto ex; + ret= burn_drive_equals_adr(in_drive, libburn_adr, 1); + if(ret==1) + dinfo= in_dinfo; + } + + if(dinfo==NULL) { + ret= isoburn_drive_aquire(&dinfo, libburn_adr, 1|((flag&(8|4))>>1)); + Xorriso_process_msg_queues(xorriso,0); + if(ret<=0) { + sprintf(xorriso->info_text,"Cannot aquire drive '%s'", adr); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + drive= dinfo[0].drive; + state= isoburn_disc_get_status(drive); + Xorriso_process_msg_queues(xorriso,0); + if(flag&1) { + volset= isoburn_get_attached_image(drive); + if(volset != NULL) { /* The image object is already created */ + iso_image_unref(volset); + } + } + + if(flag&2) { + xorriso->out_drive_handle= dinfo; + if(Sfile_str(xorriso->outdev, adr, 0)<=0) + {ret= -1; goto ex;} + if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) { + sprintf(xorriso->info_text, "Disc status unsuitable for writing"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + not_writeable= 1; + } + } + if(flag&1) { + xorriso->in_drive_handle= dinfo; + if(Sfile_str(xorriso->indev, adr, 0)<=0) + {ret= -1; goto ex;} + } else if(flag&2) { + if(xorriso->in_volset_handle==NULL) { + /* No volume loaded: create empty one */ + ret= Xorriso_create_empty_iso(xorriso, 0); + if(ret<=0) + goto ex; + } else { + iso_image_ref((IsoImage *) xorriso->in_volset_handle); + ret= isoburn_attach_image(drive, (IsoImage *) xorriso->in_volset_handle); + if(ret<=0) { + sprintf(xorriso->info_text, + "Failed to attach ISO image object to outdev"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + } + Xorriso_toc(xorriso, 1|2); + {ret= 1+not_writeable; goto ex;} + } + + if(xorriso->in_volset_handle!=NULL) + iso_image_unref((IsoImage *) xorriso->in_volset_handle); + xorriso->in_volset_handle= NULL; + + /* check for invalid state */ + if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE && + state != BURN_DISC_FULL) { + sprintf(xorriso->info_text, + "Disc status not blank and unsuitable for reading"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } + /* fill read opts */ + ret= isoburn_ropt_new(&ropts, 0); + if(ret<=0) + goto ex; + isoburn_ropt_set_extensions(ropts, isoburn_ropt_noiso1999); + isoburn_ropt_set_default_perms(ropts, (uid_t) 0, (gid_t) 0, (mode_t) 0555); + isoburn_ropt_set_input_charset(ropts, NULL); + + Xorriso_set_image_severities(xorriso, 1); /* No DEBUG messages */ + Xorriso_pacifier_reset(xorriso, 0); + isoburn_set_read_pacifier(drive, Xorriso__read_pacifier, (void *) xorriso); + if(isoburn_read_image(drive, ropts, &volset) <= 0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_set_image_severities(xorriso, 0); + sprintf(xorriso->info_text,"Cannot read ISO image volset"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 3; goto ex; + } + Xorriso_pacifier_callback(xorriso, "nodes read", xorriso->pacifier_count, 0, + "", 1); /* report end count */ + xorriso->in_volset_handle= (void *) volset; + Xorriso_set_image_severities(xorriso, 0); + Xorriso_update_volid(xorriso, 0); + + if(xorriso->out_drive_handle != NULL && + xorriso->out_drive_handle != xorriso->in_drive_handle) { + ret= Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive, + "on attempt to attach ISO image volset to outdev", 2); + if(ret<=0) + goto ex; + iso_image_ref((IsoImage *) xorriso->in_volset_handle); + isoburn_attach_image(out_drive, xorriso->in_volset_handle); + } + Xorriso_process_msg_queues(xorriso,0); + isoburn_ropt_get_size_what(ropts, &size, &has_what); + if(has_what & isoburn_ropt_has_el_torito) { + if(xorriso->patch_isolinux_image) + boot_fate= "patched as isolinux image"; + else if(xorriso->keep_boot_image) + boot_fate= "kept unchanged"; + else + boot_fate= "discarded"; + sprintf(xorriso->info_text, + "Detected El-Torito boot information which currently is set to be %s", + boot_fate); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + + Xorriso_toc(xorriso, 1); + if(xorriso->loaded_volid[0]!=0) { + sprintf(xorriso->result_line,"Volume id : '%s'\n",xorriso->loaded_volid); + Xorriso_result(xorriso,0); + if(strcmp(xorriso->loaded_volid, xorriso->volid)!=0 && + !xorriso->volid_default) { + sprintf(xorriso->result_line, "New volume id: '%s'\n", xorriso->volid); + Xorriso_result(xorriso,0); + } + } + ret= 1+not_writeable; +ex: + Xorriso_process_msg_queues(xorriso,0); + if(ret<=0) { + hret= Xorriso_give_up_drive(xorriso, flag&3); + if(hretin_drive_handle == xorriso->out_drive_handle); + if((flag&4) && in_is_out_too && (flag&(1|2))) { + if((flag&3)!=3) { + sprintf(xorriso->info_text,"Giving up for -eject whole -dev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + flag|= 3; /* give up in/out drive to eject it */ + } + + if((flag&1) && xorriso->in_drive_handle != NULL) { + Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to give up drive", 0); + + if(!in_is_out_too) { + if(drive!=NULL && !in_is_out_too) + isoburn_drive_release(drive,!!(flag&4)); + if(dinfo!=NULL && !in_is_out_too) + burn_drive_info_free(dinfo); + } + xorriso->in_drive_handle= NULL; + xorriso->indev[0]= 0; + + if(xorriso->in_volset_handle!=NULL) + iso_image_unref((IsoImage *) xorriso->in_volset_handle); + xorriso->in_volset_handle= NULL; + xorriso->loaded_volid[0]= 0; + xorriso->volset_change_pending= 0; + xorriso->no_volset_present= 0; + in_is_out_too= 0; + } + if((flag&2) && xorriso->out_drive_handle!=NULL) { + Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to give up drive", 2); + if(!in_is_out_too) { + if(drive!=NULL) + isoburn_drive_release(drive,!!(flag&4)); + if(dinfo!=NULL) + burn_drive_info_free(dinfo); + } + xorriso->out_drive_handle= NULL; + xorriso->outdev[0]= 0; + } else if((flag&1) && xorriso->out_drive_handle!=NULL) { + ret= Xorriso_create_empty_iso(xorriso, 0); + if(ret<=0) + return(ret); + if(!(flag&8)) { + sprintf(xorriso->info_text, + "Only the output drive remains. Created empty ISO image.\n"); + Xorriso_info(xorriso, 0); + Xorriso_toc(xorriso, 1|2); + } + } + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_make_write_options( + struct XorrisO *xorriso, struct burn_drive *drive, + struct burn_write_opts **burn_options, int flag) +{ + int drive_role; + + *burn_options= burn_write_opts_new(drive); + if(*burn_options==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Cannot allocate option set"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + burn_write_opts_set_simulate(*burn_options, !!xorriso->do_dummy); + drive_role= burn_drive_get_drive_role(drive); + burn_write_opts_set_multi(*burn_options, + !(xorriso->do_close || drive_role==0 || drive_role==3)); + burn_drive_set_speed(drive, xorriso->speed, xorriso->speed); + burn_write_opts_set_underrun_proof(*burn_options, 1); + return(1); +} + + +/* @param flag bit0= do not write but only prepare and return size in sectors + bit1= do not use isoburn wrappers +*/ +int Xorriso_sanitize_image_size(struct XorrisO *xorriso, + struct burn_drive *drive, struct burn_disc *disc, + struct burn_write_opts *burn_options, int flag) +{ + int ret, img_sectors, num_sessions= 0, num_tracks= 0, padding= 0, profile; + int media_space; + char profile_name[80]; + struct burn_session **sessions; + struct burn_track **tracks; + + img_sectors= burn_disc_get_sectors(disc); + + sessions= burn_disc_get_sessions(disc, &num_sessions); + if(sessions==NULL || num_sessions < 1) { +no_track:; + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Program error : no track in prepared disc"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + tracks= burn_session_get_tracks(sessions[0], &num_tracks); + if(tracks==NULL || num_tracks < 1) + goto no_track; + + padding= 0; + ret= burn_disc_get_profile(drive, &profile, profile_name); + padding= xorriso->padding / 2048; + if(xorriso->padding > padding * 2048) + padding++; + if(img_sectors>0 && (profile==0x09 || profile==0x0a)) { /* CD-R , CD-RW */ + if(img_sectors + padding < Xorriso_cd_min_track_sizE) { + padding= Xorriso_cd_min_track_sizE - img_sectors; + sprintf(xorriso->info_text, + "Expanded track to minimum size of %d sectors", + Xorriso_cd_min_track_sizE); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + } + burn_track_define_data(tracks[0], 0, padding * 2048, 0, BURN_MODE1); + Xorriso_process_msg_queues(xorriso,0); + + if(flag&2) + media_space= burn_disc_available_space(drive, burn_options) / + (off_t) 2048; + else + media_space= isoburn_disc_available_space(drive, burn_options) / + (off_t) 2048; + if(media_space < img_sectors + padding) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Image size %ds exceeds free space on media %ds", + img_sectors + padding, media_space); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + if(flag&1) { + ret= img_sectors+padding; + } else + ret= 1; +ex:; + return(ret); +} + + +/* @param flag bit0= do not write but only prepare and return size in sectors +*/ +int Xorriso_write_session(struct XorrisO *xorriso, int flag) +{ + int ret, relax= 0, i; + int major, minor, micro; + char xorriso_id[256], *img_id; + struct isoburn_imgen_opts *sopts= NULL; + struct burn_drive_info *dinfo, *source_dinfo; + struct burn_drive *drive, *source_drive; + struct burn_disc *disc= NULL; + struct burn_write_opts *burn_options; + off_t readcounter= 0,writecounter= 0; + int num_sessions= 0, num_tracks= 0; + struct burn_session **sessions; + struct burn_track **tracks; + enum burn_disc_status s; + IsoImage *image = NULL; + ElToritoBootImage *bootimg; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to write", 2); + if(ret<=0) + return(0); + + if(xorriso->out_drive_handle == xorriso->in_drive_handle) { + source_drive= drive; + } else { + if(xorriso->in_drive_handle == NULL) { + source_drive= drive; + } else { + ret= Xorriso_get_drive_handles(xorriso, &source_dinfo, &source_drive, + "on attempt to get source for write", 0); + if(ret<=0) + goto ex; + } + s= isoburn_disc_get_status(drive); + if(s!=BURN_DISC_BLANK) { + s= burn_disc_get_status(drive); + if(s!=BURN_DISC_BLANK) + sprintf(xorriso->info_text, + "-indev differs from -outdev and -outdev media is not blank"); + else + sprintf(xorriso->info_text, + "-indev differs from -outdev and -outdev media holds valid ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + } + + ret= isoburn_igopt_new(&sopts, 0); + if(ret<=0) + return(ret); + relax= isoburn_igopt_allow_deep_paths; + + /* Adjust or discard boot image */ + image= isoburn_get_attached_image(source_drive); + /* >>> ??? move down to libisoburn ? */ + if(image!=NULL && !(flag&1)) { + ret= iso_image_get_boot_image(image, &bootimg, NULL, NULL); + if(xorriso->patch_isolinux_image) { + if(ret==1) { + relax|= isoburn_igopt_allow_full_ascii; + sprintf(xorriso->info_text, "Patching alleged isolinux boot image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + el_torito_patch_isolinux_image(bootimg); + } else { + sprintf(xorriso->info_text, + "Could not find any boot image for -boot_image isolinux patch"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + } else if(xorriso->keep_boot_image && ret==1) { + relax|= isoburn_igopt_allow_full_ascii; + sprintf(xorriso->info_text, "Keeping boot image unchanged"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } else if(ret==1) { + iso_image_remove_boot_image(image); + sprintf(xorriso->info_text, "Discarded boot image from old session"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + } + isoburn_igopt_set_level(sopts, 2); + isoburn_igopt_set_extensions(sopts, 1|((!!xorriso->do_joliet)<<1)); + isoburn_igopt_set_relaxed(sopts, isoburn_igopt_allow_deep_paths); + isoburn_igopt_set_sort_files(sopts, 1); + isoburn_igopt_set_over_mode(sopts, 0, 0, (mode_t) 0, (mode_t) 0); + isoburn_igopt_set_over_ugid(sopts, 0, 0, (uid_t) 0, (gid_t) 0); + isoburn_igopt_set_out_charset(sopts, NULL); + isoburn_igopt_set_fifo_size(sopts, xorriso->fs * 2048); + + if(image!=NULL && + strlen(Xorriso_program_versioN)+strlen(Xorriso_timestamP)<80) { + sprintf(xorriso_id, "XORRISO-%s %s", + Xorriso_program_versioN, Xorriso_timestamP); + isoburn_version(&major, &minor, µ); + if(strlen(xorriso_id)<80) + sprintf(xorriso_id+strlen(xorriso_id), + ", LIBISOBURN-%d.%d.%d", major, minor, micro); + iso_lib_version(&major, &minor, µ); + if(strlen(xorriso_id)<80) + sprintf(xorriso_id+strlen(xorriso_id), + ", LIBISOFS-%d.%d.%d", major, minor, micro); + burn_version(&major, &minor, µ); + if(strlen(xorriso_id)<80) + sprintf(xorriso_id+strlen(xorriso_id), + ", LIBBURN-%d.%d.%d", major, minor, micro); + xorriso_id[128]= 0; + img_id= (char *) iso_image_get_data_preparer_id(image); + if(img_id!=NULL) { + for(i= strlen(img_id)-1; i>=0 && img_id[i]==' '; i--); + if(i>0) { + sprintf(xorriso->info_text, "Overwrote previous preparer id '%s'", + img_id); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + } + iso_image_set_data_preparer_id(image, xorriso_id); + } + + /* Make final abort check before starting expensive activities */ + ret= Xorriso_eval_problem_status(xorriso, 1, 0); + if(ret<0) + {ret= 0; goto ex;} + Xorriso_set_abort_severity(xorriso, 1); + if(xorriso->out_drive_handle == xorriso->in_drive_handle || + xorriso->in_drive_handle == NULL) { + ret= isoburn_prepare_disc(source_drive, &disc, sopts); + } else { + ret= isoburn_prepare_new_image(source_drive, &disc, sopts, drive); + } + if (ret <= 0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Failed to prepare session write run"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + isoburn_igopt_get_effective_lba(sopts, &(xorriso->session_lba)); + + ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0); + if(ret<=0) + goto ex; + + ret= Xorriso_sanitize_image_size(xorriso, drive, disc, burn_options, flag&1); + if(ret<=0 || (flag&1)) { + Xorriso_process_msg_queues(xorriso,0); + if(flag&1) /* set queue severity to FAILURE */ + Xorriso_set_image_severities(xorriso, 2); + isoburn_cancel_prepared_write(source_drive, drive, 0); + if(flag&1) /* reset queue severity */ + Xorriso_set_image_severities(xorriso, 0); + goto ex; + } + + xorriso->run_state= 1; /* Indicate that burning has started */ + isoburn_disc_write(burn_options, disc); + burn_write_opts_free(burn_options); + + ret= Xorriso_pacifier_loop(xorriso, drive, 0); + if(ret<=0) + goto ex; + if(!isoburn_drive_wrote_well(drive)) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "libburn indicates failure with writing."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + sessions= burn_disc_get_sessions(disc, &num_sessions); + if(num_sessions>0) { + tracks= burn_session_get_tracks(sessions[0], &num_tracks); + if(tracks!=NULL && num_tracks>0) { + burn_track_get_counters(tracks[0],&readcounter,&writecounter); + xorriso->session_blocks= (int) (writecounter/ (off_t) 2048); + sprintf(xorriso->info_text, + "ISO image produced: %d sectors. Written to media: %d sectors at LBA %d\n", + (int) (readcounter/ (off_t) 2048), + xorriso->session_blocks, xorriso->session_lba); + Xorriso_info(xorriso, 0); + } + } + + ret= isoburn_activate_session(drive); + Xorriso_process_msg_queues(xorriso,0); + if(ret<=0) { + sprintf(xorriso->info_text, + "Could not write new set of volume descriptors"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + goto ex; + } + /* Done early to free any reference to the libisofs resources via disc */ + if(disc!=NULL) + burn_disc_free(disc); + disc= NULL; + /* To wait for the end of the libisofs threads and their messages. */ + isoburn_sync_after_write(source_drive, drive, 0); + Xorriso_process_msg_queues(xorriso,0); + + sprintf(xorriso->info_text, "Writing completed sucessfully.\n\n"); + Xorriso_info(xorriso, 0); + ret= 1; +ex:; + xorriso->run_state= 0; /* Indicate that burning has ended */ + Xorriso_set_abort_severity(xorriso, 0); + + if(ret<=0) { + /* >>> ??? revive discarded boot image */; + } + + if(disc!=NULL) + burn_disc_free(disc); + isoburn_igopt_destroy(&sopts, 0); + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + +int Xorriso_check_burn_abort(struct XorrisO *xorriso, int flag) +{ + int ret; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + + if(xorriso->run_state!=1) + return(0); + ret= Xorriso_eval_problem_status(xorriso, 1, 1); + if(ret>=0) + return(0); + sprintf(xorriso->info_text, + "-abort_on '%s' encountered '%s' during image writing", + xorriso->abort_on_text, xorriso->problem_status_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + xorriso->problem_status_text, 0); + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to abort burn run", 2); + if(ret<=0) + return(0); + + burn_drive_cancel(drive); + sprintf(xorriso->info_text, + "libburn has now been urged to cancel its operation"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); +} + + +/* This loop watches burn runs until they end. + It issues pacifying update messages to the user. + @param flag bit0-3 = emulation mode + 0= xorriso + 1= cdrskin + bit4= report speed in CD units +*/ +int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive, + int flag) +{ + int ret, size, free_bytes, i, aborting= 0, emul, buffer_fill= 50, last_sector; + struct burn_progress progress; + char *status_text; + enum burn_drive_status drive_status; + double start_time, current_time, last_time; + double measured_speed, speed_factor= 1385000; + + start_time= Sfile_microtime(0); + while(burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING) + usleep(100002); + + emul= flag&15; + if(flag&16) + speed_factor= 150.0*1024; + progress.sector= 0; + current_time= Sfile_microtime(0); + while(1) { + last_time= current_time; + last_sector= progress.sector; + drive_status= burn_drive_get_status(drive, &progress); + if(drive_status == BURN_DRIVE_IDLE) + break; + current_time= Sfile_microtime(0); + if(drive_status == BURN_DRIVE_WRITING && progress.sectors > 0) { + if(emul==1) { + if(progress.sector<=progress.sectors) + sprintf(xorriso->info_text, "%4d of %4d MB written", + progress.sector / 512, progress.sectors / 512); + else + sprintf(xorriso->info_text, "%4d MB written", + progress.sector / 512); + + if(xorriso->pacifier_fifo!=NULL) { + ret= burn_fifo_inquire_status(xorriso->pacifier_fifo, + &size, &free_bytes, &status_text); + if(ret>0 ) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " (fifo %2d%%)", + (int) (100.0-100.0*((double) free_bytes)/(double) size)); + } + + buffer_fill= 50; + if(progress.buffer_capacity>0) + buffer_fill= (double) (progress.buffer_capacity + - progress.buffer_available) * 100.0 + / (double) progress.buffer_capacity; + sprintf(xorriso->info_text+strlen(xorriso->info_text), " [buf %3d%%]", + buffer_fill); + + if(current_time-last_time>0.2) { + measured_speed= (progress.sector - last_sector) * 2048.0 / + (current_time - last_time); + sprintf(xorriso->info_text+strlen(xorriso->info_text), " %4.1fx.", + measured_speed/speed_factor); + } + + } else { + if(progress.sector<=progress.sectors) + sprintf(xorriso->info_text, "Writing: sector %d of %d", + progress.sector, progress.sectors); + else + sprintf(xorriso->info_text, "Writing: sector %d", progress.sector); + ret= isoburn_get_fifo_status(drive, &size, &free_bytes, &status_text); + if(ret>0 ) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " [fifo %s, %2d%% fill]", status_text, + (int) (100.0-100.0*((double) free_bytes)/(double) size)); + } + } else if(drive_status == BURN_DRIVE_CLOSING_SESSION || + drive_status == BURN_DRIVE_CLOSING_TRACK) + sprintf(xorriso->info_text, + "Closing track/session. Working since %.f seconds", + current_time-start_time); + else if(drive_status == BURN_DRIVE_FORMATTING) + sprintf(xorriso->info_text, "Formatting. Working since %.f seconds", + current_time-start_time); + else + sprintf(xorriso->info_text, + "Thank you for being patient since %.f seconds", + current_time-start_time); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + + for(i= 0; i<10; i++) { + Xorriso_process_msg_queues(xorriso, 0); + if(aborting<=0) + aborting= Xorriso_check_burn_abort(xorriso, 0); + usleep(100000); + } + } + return(1); +} + + +int Xorriso__read_pacifier(IsoImage *image, IsoFileSource *filesource) +{ + struct XorrisO *xorriso; + + xorriso= (struct XorrisO *) iso_image_get_attached_data(image); + if(xorriso==NULL) + return(1); + xorriso->pacifier_count++; + if(xorriso->pacifier_count%10) + return(1); + Xorriso_pacifier_callback(xorriso, "nodes read", xorriso->pacifier_count, 0, + "", 0); + return(1); +} + + +int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume, + int flag) +{ + if(xorriso->in_volset_handle==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"No ISO image present."); + if(xorriso->indev[0]==0 && xorriso->outdev[0]==0) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " No -dev, -indev, or -outdev selected."); + else + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " Possible program error with drive '%s'.", xorriso->indev); + + if(!xorriso->no_volset_present) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + xorriso->no_volset_present= 1; + return(0); + } + *volume= (IsoImage *) xorriso->in_volset_handle; + xorriso->no_volset_present= 0; + return(*volume != NULL); +} + + +/* @param flag bit0=do not complain about non existent node */ +int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume, + char *path, IsoNode **node, int flag) +{ + int ret; + char sfe[5*SfileadrL], *path_pt; + + path_pt= path; + if(path[0]==0) + path_pt= "/"; + *node= NULL; + ret= iso_tree_path_to_node(volume, path_pt, node); + Xorriso_process_msg_queues(xorriso,0); + if(ret<=0) { + if(!(flag&1)) { + sprintf(xorriso->info_text, "Cannot find path %s in loaded ISO image", + Text_shellsafe(path_pt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + return(0); + } + return(1); +} + + +/* @param eff_path returns resulting effective path. + Must provide at least SfileadrL bytes of storage. + @param flag bit0= do not produce problem events (unless faulty path format) + bit1= work purely literally, do not use libisofs + bit2= (with bit1) this is an address in the disk world + @return -1 = faulty path format, 0 = not found , + 1 = found simple node , 2 = found directory +*/ +int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, + char *img_path, char eff_path[], int flag) +{ + int ret, is_dir= 0, done= 0; + IsoImage *volume; + IsoDir *dir= NULL; + IsoNode *node= NULL; + char path[SfileadrL], *apt, *npt, sfe[5*SfileadrL], *cpt; + + eff_path[0]= 0; + if(img_path[0]==0) + return(2); /* root directory */ + + if(!(flag&2)) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + } + + apt= npt= path; + if(img_path[0]!='/') { + strcpy(path, wd); + ret= Sfile_add_to_path(path, img_path, 0); + if(ret<=0) + goto much_too_long; + } else + if(Sfile_str(path, img_path, 0)<=0) + return(-1); + + if(path[0]!='/') { + sprintf(xorriso->info_text, + "Internal error: Unresolvable relative addressing in iso_rr_path '%s'", + img_path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FATAL", 0); + return(-1); + } else if(path[1]==0) + return(2); /* root directory */ + + for(npt= apt; !done; apt= npt+1) { + npt= strchr(apt, '/'); + if(npt==NULL) { + npt= apt+strlen(apt); + done= 1; + } else + *npt= 0; + if(*apt==0) { + *apt= '/'; + apt++; + if(done) + break; + continue; + } + if(strcmp(apt,".")==0) { + is_dir= 1; + continue; + } + if(strcmp(apt,"..")==0) { + if(!(flag&2)) { + node= (IsoNode *) dir; + if(node==NULL) { +bonked_root:; + sprintf(xorriso->info_text, + "Relative addressing in path exceeds root directory: %s", + Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(-1); + } + dir= iso_node_get_parent(node); + } + /* truncate eff_path */; + cpt= strrchr(eff_path, '/'); + if(cpt==NULL) /* ??? if not flag&2 then this is a bug */ + goto bonked_root; + *cpt= 0; + is_dir= 1; + continue; + } + ret= Sfile_add_to_path(eff_path, apt, 0); + if(ret<=0) { +much_too_long:; + sprintf(xorriso->info_text, "Effective path gets much too long (%d)", + (int) (strlen(eff_path)+strlen(apt)+1)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(-1); + } + if(!(flag&2)) { + dir= (IsoDir *) node; + ret= Xorriso_node_from_path(xorriso, volume, eff_path, &node, flag&1); + if(ret<=0) + return(0); + if(dir==NULL) /* could be false with "/dir/.." */ + dir= iso_node_get_parent(node); + is_dir= LIBISO_ISDIR(node); + } + } + return(1+!!is_dir); +} + + +int Xorriso_get_node_by_path(struct XorrisO *xorriso, + char *in_path, char *eff_path, + IsoNode **node, int flag) +{ + int ret; + char path[SfileadrL]; + IsoImage *volume; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, in_path, path, 0); + if(ret<=0) + return(ret); + if(eff_path!=NULL) + strcpy(eff_path, path); + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + ret= Xorriso_node_from_path(xorriso, volume, path, node, 0); + if(ret<=0) + return(0); + return(1); +} + + +/* @param flag bit0= give directory x-permission where is r-permission +*/ +int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf, + IsoNode *node, int flag) +{ + mode_t mode; + + mode= stbuf->st_mode; + if((flag&1) && S_ISDIR(mode)) { + if(mode&S_IRUSR) + mode|= S_IXUSR; + if(mode&S_IRGRP) + mode|= S_IXGRP; + if(mode&S_IROTH) + mode|= S_IXOTH; + } + iso_node_set_permissions(node, mode & 07777); + iso_node_set_uid(node, stbuf->st_uid); + iso_node_set_gid(node, stbuf->st_gid); + iso_node_set_atime(node, stbuf->st_atime); + iso_node_set_mtime(node, stbuf->st_mtime); + iso_node_set_ctime(node, stbuf->st_ctime); + return(1); +} + + +int Xorriso_graft_split(struct XorrisO *xorriso, IsoImage *volume, + IsoDir *dir, char *disk_path, char *img_name, + char *nominal_source, char *nominal_target, + off_t size, IsoNode **node, int flag) +{ + int ret; + IsoDir *new_dir= NULL; + IsoNode *part_node; + int partno, total_parts; + off_t offset; + char part_name[SfileadrL], sfe[5*SfileadrL]; + + ret= iso_tree_add_new_dir(dir, img_name, &new_dir); + if(ret<0) + return(ret); + *node= (IsoNode *) new_dir; + + total_parts= size / xorriso->split_size; + if(size % xorriso->split_size) + total_parts++; + for(partno= 1; partno<=total_parts; partno++) { + offset = xorriso->split_size * (off_t) (partno-1); + Splitpart__compose(part_name, partno, total_parts, offset, + xorriso->split_size, size, 0); + ret= Xorriso_tree_graft_node(xorriso, volume, + new_dir, disk_path, part_name, + nominal_source, nominal_target, + offset, xorriso->split_size, + &part_node, 8); + if(ret<=0) + return(0); + } + sprintf(xorriso->info_text, "Split into %d parts: %s", + total_parts, Text_shellsafe(nominal_target, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); +} + + +/* + @param flag bit3= cut_out_node: offset and size are valid +*/ +int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume, + IsoDir *dir, char *disk_path, char *img_name, + char *nominal_source, char *nominal_target, + off_t offset, off_t cut_size, + IsoNode **node, int flag) +{ + int ret; + struct stat stbuf; + char sfe[5*SfileadrL]; + off_t size= 0; + static off_t limit= ((off_t) 4) * ((off_t) 1024*1024*1024) - (off_t) 1; + + if(flag&8) { + if(cut_size > limit) { + sprintf(xorriso->info_text, + "File piece exceeds size limit of %.f bytes: %.f from %s\n", + (double) limit, (double) cut_size, + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= iso_tree_add_new_cut_out_node(volume, dir, img_name, disk_path, + offset, cut_size, node); + if(ret<0) + goto ex; + } else { + + if(stat(disk_path, &stbuf)!=-1) + if(S_ISREG(stbuf.st_mode)) + size= stbuf.st_size; + if(xorriso->split_size > 0 && size > xorriso->split_size) { + ret= Xorriso_graft_split(xorriso, volume, dir, disk_path, img_name, + nominal_source, nominal_target, size, + node, 0); + if(ret<=0) + goto ex; + return(1); + } else if(size > limit) { + sprintf(xorriso->info_text, + "File exceeds size limit of %.f bytes: %s\n", + (double) limit, Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= iso_tree_add_new_node(volume, dir, img_name, disk_path, node); + if(ret<0) + goto ex; + } +ex:; + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, nominal_source, ret, + "Cannot add node to tree", 0, "FAILURE", 1|2); + return(ret); + } + return(1); +} + + +/* @param flag bit0= recursion is active + bit1= do not report added files +*/ +int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir, + char *img_dir_path, char *disk_dir_path, + struct LinkiteM *link_stack, int flag) +{ + IsoImage *volume; + IsoNode *node; + IsoSymlink *iso_symlink; + int ret, target_is_dir, source_is_dir, source_is_link, fret, was_failure= 0; + int do_not_dive, target_is_split= 0; + struct DirseQ *dirseq= NULL; + char *name, *img_name, *srcpt, *stbuf_src= ""; + struct stat stbuf, hstbuf; + dev_t dir_dev; + struct LinkiteM *own_link_stack; + +#ifdef Xorriso_fat_local_meM + char sfe[5*SfileadrL], sfe2[5*SfileadrL]; + char disk_path[2*SfileadrL], img_path[2*SfileadrL], link_target[SfileadrL]; +#else /* Xorriso_fat_local_meM */ + + char *sfe= NULL, *sfe2= NULL; + char *disk_path= NULL, *img_path= NULL, *link_target= NULL; + + /* Avoiding large local memory objects in order to save stack space */ + sfe= malloc(5*SfileadrL); + sfe2= malloc(5*SfileadrL); + disk_path= malloc(2*SfileadrL); + img_path= malloc(2*SfileadrL); + link_target= malloc(SfileadrL); + if(sfe==NULL || sfe2==NULL || disk_path==NULL || img_path==NULL || + link_target==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + +#endif /* ! Xorriso_fat_local_meM */ + + own_link_stack= link_stack; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + goto ex; + + stbuf_src= disk_dir_path; + if(lstat(disk_dir_path, &stbuf)==-1) + goto cannot_open_dir; + dir_dev= stbuf.st_dev; + if(S_ISLNK(stbuf.st_mode)) { + if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) + {ret= 2; goto ex;} + stbuf_src= disk_dir_path; + if(stat(disk_dir_path, &stbuf)==-1) + goto cannot_open_dir; + if(dir_dev != stbuf.st_dev && + !(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1)))) + {ret= 2; goto ex;} + } + ret= Dirseq_new(&dirseq, disk_dir_path, 1); + if(ret<0) { + sprintf(xorriso->info_text,"Failed to create source filesystem iterator"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + if(ret==0) { +cannot_open_dir:; + Xorriso_msgs_submit(xorriso, 0, disk_dir_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text,"Cannot open as source directory: %s", + Text_shellsafe(disk_dir_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + + if(Sfile_str(disk_path, disk_dir_path,0)<=0) + {ret= -1; goto ex;} + if(disk_path[0]==0 || disk_path[strlen(disk_path)-1]!='/') + strcat(disk_path,"/"); + name= disk_path+strlen(disk_path); + if(Sfile_str(img_path, img_dir_path, 0)<=0) + {ret= -1; goto ex;} + if(img_path[0] || img_path[strlen(img_path)-1]!='/') + strcat(img_path,"/"); + img_name= img_path+strlen(img_path); + + while(1) { /* loop over directory content */ + stbuf_src= ""; + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + srcpt= disk_path; + Xorriso_process_msg_queues(xorriso,0); + ret= Dirseq_next_adr(dirseq,name,0); /* name is a pointer into disk_path */ + if(ret==0) + break; + if(ret<0) { + sprintf(xorriso->info_text,"Failed to obtain next directory entry"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + + /* >>> compare exclusions against disk_path resp. name */; + + strcpy(img_name, name); + if(Xorriso_much_too_long(xorriso, strlen(img_path), 0)<=0) + {ret= 0; goto was_problem;} + if(Xorriso_much_too_long(xorriso, strlen(srcpt), 0)<=0) + {ret= 0; goto was_problem;} + stbuf_src= srcpt; + if(lstat(srcpt, &stbuf)==-1) { +cannot_lstat:; + Xorriso_msgs_submit(xorriso, 0, srcpt, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Cannot determine attributes of source file %s", + Text_shellsafe(srcpt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + ret= 0; goto was_problem; + } + source_is_dir= 0; + source_is_link= S_ISLNK(stbuf.st_mode); + if(xorriso->do_follow_links && source_is_link) { + /* Xorriso_hop_link checks for wide link loops */ + ret= Xorriso_hop_link(xorriso, srcpt, &own_link_stack, &hstbuf, 0); + if(ret<0) + goto was_problem; + if(ret==1) { + ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 0); + if(ret<=0) + goto was_problem; + srcpt= link_target; + stbuf_src= srcpt; + if(lstat(srcpt, &stbuf)==-1) + goto cannot_lstat; + } else { + if(Xorriso_eval_problem_status(xorriso, 0, 1|2)<0) + {ret= 0; goto was_problem;} + } + } else if (S_ISLNK(stbuf.st_mode)) { + ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 1); + if(ret<=0) + goto was_problem; + } + do_not_dive= 0; + if(S_ISDIR(stbuf.st_mode)) { + source_is_dir= 1; + if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount) + do_not_dive= 1; + } + + /* does a node exist with this name ? */ + node= NULL; + ret= Xorriso_node_from_path(xorriso, volume, img_path, &node, 1); + if(ret>0) { + target_is_dir= LIBISO_ISDIR(node); + target_is_split= 0; + if(target_is_dir) + target_is_split= Xorriso_is_split(xorriso, node, 0); + + if(!((target_is_dir && !target_is_split) && source_is_dir)) { + Xorriso_process_msg_queues(xorriso,0); + + /* handle overwrite situation */; + if(xorriso->do_overwrite==1 || + (xorriso->do_overwrite==2 && !(target_is_dir && !target_is_split))) { + ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, img_path, 1|8); + if(ret<=0) + goto was_problem; + if(ret==3) { + sprintf(xorriso->info_text, "User revoked adding of: %s", + Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 0; goto was_problem; + } + node= NULL; + } else { + Xorriso_msgs_submit(xorriso, 0, srcpt, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "While grafting %s : file object exists and may not be overwritten by %s", + Text_shellsafe(img_path,sfe,0), Text_shellsafe(stbuf_src,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto was_problem; + } + } + } + + if(node==NULL) { + if(S_ISLNK(stbuf.st_mode)) { + + /* ??? NG : A80107 : is this solved now ? */ + /* <<< One should rather change libisofs so that iso_tree_add_node() + adds a disk_link as RR link, if RR is enabled */ + + ret= iso_tree_add_new_symlink(dir, img_name, link_target, &iso_symlink); + node= (IsoNode *) iso_symlink; + if(ret>0) { + ret= Xorriso_transfer_properties(xorriso, &stbuf, node, 0); + if(ret<=0) + goto was_problem; + } else { + Xorriso_report_iso_error(xorriso, stbuf_src, ret, + "Cannot create symbolic link", 0, "FAILURE", 1|2); + {ret= 0; goto was_problem;} + } + } else { + ret= Xorriso_tree_graft_node(xorriso, volume, dir, srcpt, img_name, + "", img_path, (off_t) 0, (off_t) 0, + &node, 0); + } + } + if(node==NULL) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_msgs_submit(xorriso, 0, stbuf_src, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "Grafting failed: %s = %s", + Text_shellsafe(img_path,sfe,0), Text_shellsafe(stbuf_src,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret=0; goto was_problem; + } + + xorriso->pacifier_count++; + if((xorriso->pacifier_count%100)==0) + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 0); + + xorriso->volset_change_pending= 1; + if(source_is_dir) { + if(do_not_dive) { + sprintf(xorriso->info_text, "Did not follow mount point : %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } else { + ret= Xorriso_add_tree(xorriso, (IsoDir *) node, + img_path, disk_path, own_link_stack, 1|(flag&2)); + } + if(ret<=0) + goto was_problem; + } + + continue; /* regular bottom of loop */ +was_problem:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret<0) + goto ex; + } + + ret= 1; +ex: + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(sfe2!=NULL) + free(sfe2); + if(disk_path!=NULL) + free(disk_path); + if(img_path!=NULL) + free(img_path); + if(link_target!=NULL) + free(link_target); +#endif /* ! Xorriso_fat_local_meM */ + + Xorriso_process_msg_queues(xorriso,0); + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + Dirseq_destroy(&dirseq, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* @param flag bit0= cut_out mode : base on leaf parent directory +*/ +int Xorriso_copy_implict_properties(struct XorrisO *xorriso, IsoDir *dir, + char *full_img_path, char *img_path, char *full_disk_path, int flag) +{ + int ret, nfic, nic, nfdc, d, i; + char nfi[SfileadrL], ni[SfileadrL], nfd[SfileadrL], *cpt; + char sfe[5*SfileadrL]; + struct stat stbuf; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, full_img_path, nfi, + 1|2); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, img_path, ni, 1|2); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, full_disk_path, nfd, + 1|2|4); + if(ret<=0) + return(ret); + nfic= Sfile_count_components(nfi, 0); + nic= Sfile_count_components(ni, 0); + nfdc= Sfile_count_components(nfd, 0); + d= nfic-(flag&1)-nic; + if(d<0) + return(-1); + if(d>nfdc) + return(0); + for(i= 0; iinfo_text, + "Copied properties for %s", Text_shellsafe(ni, sfe, 0)); + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " from %s", Text_shellsafe(nfd, sfe, 0)); + if(!((flag&1) && d==0)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + return(1); +} + + +/* @param bit0= copy link target properties rather than link properties + bit1= give directory x-permission where is r-permission +*/ +int Xorriso_copy_properties(struct XorrisO *xorriso, + char *disk_path, char *img_path, int flag) +{ + int ret; + IsoNode *node; + struct stat stbuf; + + ret= Xorriso_get_node_by_path(xorriso, img_path, NULL, &node, 0); + if(ret<=0) + return(ret); + if(lstat(disk_path, &stbuf)==-1) + return(0); + Xorriso_transfer_properties(xorriso, &stbuf, node, (flag&2)>>1); + xorriso->volset_change_pending= 1; + return(1); +} + + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit0= mkdir: graft in as empty directory, not as copy from disk + bit1= do not report added files + bit2= -follow: this is not a command parameter + bit3= use offset and cut_size for cut_out_node + @return <=0 = error , 1 = added simple node , 2 = added directory +*/ +int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter, + char *disk_path, char *img_path, + off_t offset, off_t cut_size, int flag) +{ + IsoImage *volume; + char path[SfileadrL], *apt, *npt, *cpt, sfe[5*SfileadrL], sfe2[5*SfileadrL]; + char *disk_path_pt, resolved_disk_path[SfileadrL]; + IsoDir *dir, *hdir; + IsoNode *node; + int done= 0, is_dir= 0, l, ret, target_is_dir, source_is_dir, resolve_link= 0; + int target_is_split; + struct stat stbuf; + + + /* >>> compare exclusions against disk_path resp. name + but no leaf patter if flag&4 */; + + + for(cpt= img_path; 1; cpt++) { + cpt= strstr(cpt,"/."); + if(cpt==NULL) + break; + if(cpt[2]=='.') { + if(cpt[3]=='/' || cpt[3]==0) + break; + } else if(cpt[2]=='/' || cpt[2]==0) + break; + } + if(cpt!=NULL) { + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Unsupported relative addressing in iso_rr_path %s (disk: %s)", + Text_shellsafe(img_path, sfe, 0), Text_shellsafe(disk_path, sfe2, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + + strncpy(path, img_path, sizeof(path)-1); + path[sizeof(path)-1]= 0; + apt= npt= path; + + if(!(flag&1)) { + ret= lstat(disk_path, &stbuf); + if(ret!=-1) { + if(S_ISDIR(stbuf.st_mode)) + is_dir= 1; + else if((stbuf.st_mode&S_IFMT)==S_IFLNK && + (xorriso->do_follow_links || + (xorriso->do_follow_param && !(flag&4)))) { + resolve_link= 1; + ret= stat(disk_path, &stbuf); + if(ret!=-1) { + if(S_ISDIR(stbuf.st_mode)) + is_dir= 1; + } + } + } + if(ret == -1) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Cannot determine attributes of source file %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + if(S_ISDIR(stbuf.st_mode)) { + is_dir= 1; + } else { + l= strlen(img_path); + if(l>0) + if(img_path[l-1]=='/') + l= 0; + if(l==0) { + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Source '%s' is not a directory. Target '%s' would be.", + Text_shellsafe(disk_path, sfe, 0), Text_shellsafe(img_path, sfe2, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + } + + dir= iso_image_get_root(volume); + if(dir==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "While grafting '%s' : no root node available", img_path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(0); + } + for(npt= apt; !done; apt= npt+1) { + npt= strchr(apt, '/'); + if(npt==NULL) { + npt= apt+strlen(apt); + done= 1; + } else + *npt= 0; + if(*apt==0) { + *apt= '/'; + apt++; + if(done) + goto attach_source; + continue; + } + source_is_dir= (is_dir || (flag&1) || !done); + ret= Xorriso_node_from_path(xorriso, volume, path, &node, 1); + if(ret>0) { + target_is_dir= LIBISO_ISDIR(node); + + target_is_split= 0; + if(target_is_dir) + target_is_split= Xorriso_is_split(xorriso, node, 0); + + if(!((target_is_dir && !target_is_split) && source_is_dir)) { + Xorriso_process_msg_queues(xorriso,0); + + /* handle overwrite situation */; + if(xorriso->do_overwrite==1 || + (xorriso->do_overwrite==2 && !(target_is_dir && !target_is_split))) { + ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, path, 1|8); + if(ret<=0) + return(ret); + if(ret==3) { + sprintf(xorriso->info_text, "User revoked adding of: %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(0); + } + node= NULL; + goto handle_path_node; + } + + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "While grafting '%s' : '%s' exists and may not be overwritten", + img_path, path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + dir= (IsoDir *) node; + } + +handle_path_node:; + if(node==NULL && source_is_dir) { /* make a directory */ + ret= iso_tree_add_new_dir(dir, apt, &hdir); + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + Xorriso_report_iso_error(xorriso, img_path, ret, + "Cannot create directory", 0, "FAILURE", 1); + sprintf(xorriso->info_text, + "While grafting '%s' : could not insert '%s'", img_path, path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + dir= hdir; + xorriso->volset_change_pending= 1; + iso_node_set_ctime((IsoNode *) dir, time(NULL)); + iso_node_set_uid((IsoNode *) dir, geteuid()); + iso_node_set_gid((IsoNode *) dir, getegid()); + + if(disk_path!=NULL && !done) + Xorriso_copy_implict_properties(xorriso, dir, img_path, path, disk_path, + !!(flag&8)); + + } + if(done) { +attach_source:; + if(flag&1) { + /* directory node was created above */; + + } else if(is_dir) { + Xorriso_transfer_properties(xorriso, &stbuf, (IsoNode *) dir, 0); + ret= Xorriso_add_tree(xorriso, dir, img_path, disk_path, NULL, flag&2); + if(ret<=0) + return(ret); + + } else { + if(resolve_link) { + ret= Xorriso_resolve_link(xorriso, disk_path, resolved_disk_path, 0); + if(ret<=0) + return(ret); + disk_path_pt= resolved_disk_path; + } else + disk_path_pt= disk_path; + + ret= Xorriso_tree_graft_node(xorriso, volume, dir, disk_path_pt, apt, + disk_path, img_path, + offset, cut_size, &node, flag&8); + if(ret<0) { + sprintf(xorriso->info_text, "Grafting failed: %s = %s", + Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + xorriso->volset_change_pending= 1; + iso_node_set_name(node, apt); + + xorriso->pacifier_count++; + if(xorriso->pacifier_count%100 && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "files added", + xorriso->pacifier_count, + xorriso->pacifier_total, "", 0); + } + } else + *npt= '/'; + } + Xorriso_process_msg_queues(xorriso,0); + return(1+!!is_dir); +} + + +/* @param flag bit0= -follow: disk_path is not a command parameter +*/ +int Xorriso_cut_out(struct XorrisO *xorriso, char *disk_path, + off_t startbyte, off_t bytecount, char *iso_rr_path, int flag) +{ + int ret; + char eff_source[SfileadrL], eff_dest[SfileadrL], sfe[SfileadrL*5]; + struct stat stbuf; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_source, + 2|4); + if(ret<=0) + return(ret); + + if(lstat(eff_source, &stbuf)==-1) { + Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "-cut_out: Cannot determine type of %s", + Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + if((stbuf.st_mode&S_IFMT) == S_IFLNK) { + if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) + goto unsupported_type; + if(stat(eff_source, &stbuf)==-1) { + Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "-cut_out: Cannot determine link target type of %s", + Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + return(0); + } + } + if(S_ISREG(stbuf.st_mode)) { + if(stbuf.st_sizeinfo_text, + "-cut_out: Byte offset %.f larger than file size %.f", + (double) startbyte, (double) stbuf.st_size); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0); + return(0); + } + } else { +unsupported_type:; + Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "-cut_out: Unsupported file type (%s) with %s", + Ftypetxt(stbuf.st_mode, 0), Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, iso_rr_path, eff_dest, + 2|((flag&1)<<2)); + if(ret<=0) + return(ret); + + ret= Xorriso_graft_in(xorriso, NULL, eff_source, eff_dest, + startbyte, bytecount, 8); + return(ret); +} + + +int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag) +{ + int ret, error_code= 0, os_errno= 0, count= 0, pass, imgid, tunneled; + char severity[80]; + + if(!xorriso->libs_are_started) + return(1); + for(pass= 0; pass< 2; pass++) { + while(1) { + tunneled= 0; + if(pass==0) + ret= iso_obtain_msgs("ALL", &error_code, &imgid, + xorriso->info_text, severity); + else { + ret= burn_msgs_obtain("ALL", &error_code, xorriso->info_text, &os_errno, + severity); + if((error_code>=0x00030000 && error_code<0x00040000) || + (error_code>=0x00050000 && error_code<0x00060000)) + tunneled= -1; /* "libisofs:" */ + else if(error_code>=0x00060000 && error_code<0x00070000) + tunneled= 1; /* "libisoburn:" */ + } + if(ret<=0) + break; + + /* <<< tunneled MISHAP from libisoburn through libburn + or well known error codes of MISHAP events + With libburn-0.4.4 this is not necessary */ + if(error_code==0x5ff73 || error_code==0x3ff73 || + error_code==0x3feb9 || error_code==0x3feb2) + strcpy(severity, "MISHAP"); + else if(error_code==0x51001) + strcpy(severity, "ERRFILE"); + + Xorriso_msgs_submit(xorriso, error_code, xorriso->info_text, os_errno, + severity, ((pass+tunneled)+1)<<2); + count++; + } + } + if(xorriso->library_msg_direct_print && count>0) { + sprintf(xorriso->info_text," (%d library messages repeated by xorriso)\n", + count); + Xorriso_info(xorriso, 0); + } + return(1); +} + + +/* @param flag bit0=short report form + bit1=report about output drive +*/ +int Xorriso_toc(struct XorrisO *xorriso, int flag) +{ + int num_sessions= 0, num_tracks= 0, lba= 0, nwa= -1, pmin, psec, pframe, ret; + int track_count= 0, session_no, track_no, profile_no= -1; + int last_track_start= 0, last_track_size= -1, num_data= 0, is_data= 0; + int is_inout_drive= 0, drive_role; + int num_payload= 0, num_wasted= 0, num_nondata= 0; + char profile_name[80],*respt,*devadr; + struct burn_disc *disc= NULL; + struct burn_session **sessions; + struct burn_track **tracks; + struct burn_toc_entry toc_entry; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + enum burn_disc_status s; + char mem_text[80]; + off_t start_byte= 0, num_free= 0; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to print Table Of Content", flag&2); + if(ret<=0) + return(0); + + respt= xorriso->result_line; + + if(strcmp(xorriso->indev, xorriso->outdev)==0) + is_inout_drive= 1; + if(flag&2) + devadr= xorriso->outdev; + else + devadr= xorriso->indev; + sprintf(respt, "Drive current: %s '%s'\n", + (is_inout_drive ? "-dev" : (flag&2 ? "-outdev" : "-indev")), + devadr); + Xorriso_result(xorriso,0); + sprintf(respt, "Drive type : vendor '%s' product '%s' revision '%s'\n", + dinfo[0].vendor, dinfo[0].product, dinfo[0].revision); + if(!(flag&1)) + Xorriso_result(xorriso,0); + + sprintf(respt, "Media current: "); + ret= burn_disc_get_profile(drive, &profile_no, profile_name); + if (profile_no > 0 && ret > 0) { + if (profile_name[0]) + sprintf(respt+strlen(respt), "%s", profile_name); + else + sprintf(respt+strlen(respt), "%4.4Xh", profile_no); + drive_role= burn_drive_get_drive_role(drive); + if(drive_role==2) + sprintf(respt+strlen(respt), ", overwriteable"); + else if(drive_role==0 || drive_role==3) + sprintf(respt+strlen(respt), ", sequential"); + strcat(respt, "\n"); + } else + sprintf(respt+strlen(respt), "is not recognizable\n"); + Xorriso_result(xorriso,0); + + sprintf(respt, "Media status : "); + s= isoburn_disc_get_status(drive); + if (s == BURN_DISC_FULL) { + sprintf(respt+strlen(respt), "is written , is closed\n"); + } else if (s == BURN_DISC_APPENDABLE) { + sprintf(respt+strlen(respt), "is written , is appendable\n"); + } else if (s == BURN_DISC_BLANK) { + sprintf(respt+strlen(respt), "is blank\n"); + } else if (s == BURN_DISC_EMPTY) + sprintf(respt+strlen(respt), "is not present\n"); + else + sprintf(respt+strlen(respt), "is not recognizable\n"); + Xorriso_result(xorriso,0); + + if(s != BURN_DISC_FULL && s != BURN_DISC_APPENDABLE) + return(1); + + if(xorriso->request_to_abort) + return(1); + + disc= burn_drive_get_disc(drive); + if (disc==NULL) { + Xorriso_process_msg_queues(xorriso,0); + ret= isoburn_get_min_start_byte(drive, &start_byte, 0); + nwa= start_byte / 2048; + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + if(flag&1) + return(0); + sprintf(xorriso->info_text, "Cannot obtain Table Of Content"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + /* fabricate TOC */ + sprintf(respt, "Media content: session %2d ", 1); + sprintf(respt+strlen(respt), "track %2d %s lba: %9d\n", 1, "data ", 0); + if(!(flag&1)) + Xorriso_result(xorriso,0); + last_track_start= lba; + sprintf(respt, "Media content: session %2d ", 1); + sprintf(respt+strlen(respt), "leadout lba: %9d\n", nwa); + if(!(flag&1)) + Xorriso_result(xorriso,0); + num_payload= num_data= last_track_size= nwa; + num_sessions= 1; + } else { + sessions= burn_disc_get_sessions(disc, &num_sessions); + for (session_no= 0; session_norequest_to_abort); + session_no++) { + tracks = burn_session_get_tracks(sessions[session_no], &num_tracks); + if (tracks==NULL) + continue; + for(track_no= 0; track_norequest_to_abort); + track_no++) { + track_count++; + is_data= 0; + burn_track_get_entry(tracks[track_no], &toc_entry); + if (toc_entry.extensions_valid & 1) { + /* DVD extension valid */ + lba= toc_entry.start_lba; + } else { + lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, toc_entry.pframe); + } + sprintf(respt, "Media content: session %2d ", session_no+1); + sprintf(respt+strlen(respt), "track %2d %s lba: %9d\n", + track_count, ((toc_entry.control&7)<4?"audio":"data "), lba); + if(!(flag&1)) + Xorriso_result(xorriso,0); + if(track_no>0) + num_payload+= lba - last_track_start; + last_track_start= lba; + if((toc_entry.control&7)>=4) /* data track */ + is_data= 1; + } + burn_session_get_leadout_entry(sessions[session_no], &toc_entry); + if (toc_entry.extensions_valid & 1) { + lba= toc_entry.start_lba; + burn_lba_to_msf(lba, &pmin, &psec, &pframe); + } else { + lba= burn_msf_to_lba(pmin, psec, pframe); + lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, toc_entry.pframe); + } + sprintf(respt, "Media content: session %2d ", session_no+1); + sprintf(respt+strlen(respt), "leadout lba: %9d\n", lba); + if(!(flag&1)) + Xorriso_result(xorriso,0); + last_track_size= lba - last_track_start; + num_payload+= last_track_size; + if(is_data) + num_data+= last_track_size; + } + } + if(xorriso->request_to_abort) + return(1); + num_wasted= lba - num_payload; + num_nondata= lba - num_data; + Sfile_scale(((double) num_data) * 2048.0, mem_text,5,1e4,1); + +#ifdef NIX + sprintf(respt, "Media summary: %d session%s, %d data blocks, %s", + num_sessions, (num_sessions==1 ? "" : "s"), num_data, mem_text); + if(num_nondata>0) { + Sfile_scale(((double) num_nondata) * 2048.0, mem_text,5,1e4,1); + sprintf(respt+strlen(respt), ", %s non-data", mem_text); + } +#else + sprintf(respt, "Media summary: %d session%s, %d data blocks, %s data", + num_sessions, (num_sessions==1 ? "" : "s"), num_data, mem_text); + num_free= isoburn_disc_available_space(drive, NULL); + Sfile_scale((double) num_free, mem_text,5,1e4,1); + sprintf(respt+strlen(respt), ", %s free", mem_text); +#endif + + sprintf(respt+strlen(respt), "\n"); + Xorriso_result(xorriso,0); + + if (s == BURN_DISC_APPENDABLE && nwa!=0) { + ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa); + if(ret>0) { + sprintf(respt, "Media nwa : %ds\n", nwa); + if(!(flag&1)) + Xorriso_result(xorriso,0); + } + } + + if (disc!=NULL) + burn_disc_free(disc); + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_show_devices(struct XorrisO *xorriso, int flag) +{ + char adr[BURN_DRIVE_ADR_LEN]; + int i; + struct burn_drive_info *drive_list= NULL; + unsigned int drive_count; + char *respt, perms[8]; + struct stat stbuf; + + sprintf(xorriso->info_text, "Beginning to scan for devices ...\n"); + Xorriso_info(xorriso,0); + + burn_drive_clear_whitelist(); + while(!burn_drive_scan(&drive_list, &drive_count)) { + Xorriso_process_msg_queues(xorriso,0); + usleep(100000); + } + Xorriso_process_msg_queues(xorriso,0); + if(drive_count <= 0) { + + /* >>> was a drive_list created at all ? */ + /* >>> must it be freed ? */ + + sprintf(xorriso->info_text, "No drives found"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + sprintf(xorriso->info_text, "Full drive scan done\n"); + Xorriso_info(xorriso,0); + + respt= xorriso->result_line; + for(i= 0; i < drive_count && !(xorriso->request_to_abort); i++) { + if(burn_drive_get_adr(&(drive_list[i]), adr)<=0) + strcpy(adr, "-get_adr_failed-"); + Xorriso_process_msg_queues(xorriso,0); + if(stat(adr,&stbuf)==-1) { + sprintf(perms,"errno=%d",errno); + } else { + strcpy(perms,"------"); + if(stbuf.st_mode&S_IRUSR) perms[0]= 'r'; + if(stbuf.st_mode&S_IWUSR) perms[1]= 'w'; + if(stbuf.st_mode&S_IRGRP) perms[2]= 'r'; + if(stbuf.st_mode&S_IWGRP) perms[3]= 'w'; + if(stbuf.st_mode&S_IROTH) perms[4]= 'r'; + if(stbuf.st_mode&S_IWOTH) perms[5]= 'w'; + } + sprintf(respt, "%d -dev '%s' %s : '%-8.8s' '%s' \n", + i, adr, perms, drive_list[i].vendor, drive_list[i].product); + Xorriso_result(xorriso,0); + } + burn_drive_info_free(drive_list); + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_tell_media_space(struct XorrisO *xorriso, + int *media_space, int *free_space, int flag) +{ + int ret; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + struct burn_write_opts *burn_options; + + (*free_space)= (*media_space)= 0; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to -tell_media_space", 2); + if(ret<=0) + return(0); + + ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0); + if(ret<=0) + return(-1); + (*free_space)= (*media_space)= + isoburn_disc_available_space(drive, burn_options) / (off_t) 2048; + burn_write_opts_free(burn_options); + + if(xorriso->volset_change_pending) { + ret= Xorriso_write_session(xorriso, 1); + if(ret>0) + (*free_space)-= ret; + } + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +/* @param flag bit0=fast , bit1=deformat + @return 0=failure, did not touch media , -1=failure, altered media + 1=success, altered media , 2=success, did not touch media +*/ +int Xorriso_blank_media(struct XorrisO *xorriso, int flag) +{ + int ret, do_deformat= 0; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + enum burn_disc_status disc_state; + struct burn_progress p; + double percent = 1.0; + int current_profile; + char current_profile_name[80]; + char mode_names[4][80]= {"all", "fast", "deformat", "deformat_quickest"}; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to -blank", 2); + if(ret<=0) + return(0); + + burn_disc_get_profile(drive, ¤t_profile, current_profile_name); + + /* >>> */; + + disc_state = isoburn_disc_get_status(drive); + if(current_profile == 0x13) { /* overwriteable DVD-RW */ + /* Depending on flag bit1 formatted DVD-RW will get blanked to sequential + state or pseudo blanked by invalidating an eventual ISO image. */ + if(flag&2) + do_deformat= 1; + } else if(current_profile == 0x14) { /* sequential DVD-RW */ + if((flag&1) && !(flag&2)) { + sprintf(xorriso->info_text, + "-blank: DVD-RW present. Mode 'fast' defaulted to mode 'all'."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + sprintf(xorriso->info_text, + "Mode 'deformat_quickest' produces single-session-only media."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + flag&= ~1; + } + } else if(disc_state == BURN_DISC_BLANK) { + sprintf(xorriso->info_text,"Blank media detected. Will leave it untouched"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return 2; + } else if(disc_state==BURN_DISC_FULL || disc_state==BURN_DISC_APPENDABLE) { + ; + } else if(disc_state == BURN_DISC_EMPTY) { + sprintf(xorriso->info_text,"No media detected in drive"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return 0; + } else { + sprintf(xorriso->info_text, "Unsuitable drive and media state"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return 0; + } + if(!isoburn_disc_erasable(drive)) { + sprintf(xorriso->info_text, "Media is not of erasable type"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return 0; + } + if(xorriso->do_dummy) { + sprintf(xorriso->info_text, + "-dummy mode prevents blanking of media in mode '%s'.", + mode_names[flag&3]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); + } + sprintf(xorriso->info_text, "Beginning to blank media in mode '%s'.\n", + mode_names[flag&3]); + Xorriso_info(xorriso,0); + + if(do_deformat) + burn_disc_erase(drive, (flag&1)); + else + isoburn_disc_erase(drive, (flag&1)); + usleep(1000000); + while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) { + if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */ + percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0; + sprintf(xorriso->info_text, "Blanking ( %.1f%% done )", percent); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + usleep(1000000); + } + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "Blanking done\n"); + Xorriso_info(xorriso,0); + return(1); +} + +/* @return 0=failure, did not touch media , -1=failure, altered media + 1=success, altered media , 2=success, did not touch media +*/ +int Xorriso_format_media(struct XorrisO *xorriso, int flag) +{ + int ret, mode_flag= 0; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + int current_profile; + char current_profile_name[80]; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to -format", 2); + if(ret<=0) + return(0); + + burn_disc_get_profile(drive, ¤t_profile, current_profile_name); + if(current_profile == 0x14) { + ; /* ok DVD-RW sequential */ + } else if(current_profile == 0x1a) { + mode_flag= 2; + } else { + sprintf(xorriso->info_text, + "Can only -format DVD+RW and sequential DVD-RW"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text,"Media current: %s (%4.4xh)", + current_profile_name, current_profile); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return 0; + } + + if(xorriso->do_dummy) { + sprintf(xorriso->info_text, "-dummy mode prevents formatting of media."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); + } + sprintf(xorriso->info_text, "Beginning to format media.\n"); + Xorriso_info(xorriso, 0); + burn_disc_format(drive, (off_t) 0, mode_flag); + + ret= Xorriso_pacifier_loop(xorriso, drive, 0); + if(ret<=0) + return(ret); + + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "Formatting done\n"); + Xorriso_info(xorriso,0); + return(1); +} + + +int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag) +{ + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, "", iso_error, "Cannot create iter", 0, + "FATAL", 1); + sprintf(xorriso->info_text, "Cannot create IsoDirIter object"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(1); +} + + +int Xorriso__node_lba_cmp(const void *node1, const void *node2) +{ + uint32_t lba1= 0, lba2= 0; + int ret; + + ret = iso_node_get_old_image_lba(*((IsoNode **) node1), &lba1, 0); + if(ret!=1) + lba1= 0; + ret = iso_node_get_old_image_lba(*((IsoNode **) node2), &lba2, 0); + if(ret!=1) + lba1= 0; + return(lba1-lba2); +} + +/* The caller shall make no assumptions about the meaning of iter, node_array, + node_count, node_idx ! They are just opaque handles for which the caller + provides the memory of proper type. + @param flag bit0= initialize iteration + bit1= action needs full freedom of object manipulation + bit2= action needs LBA sorted iteration + bit31= end iteration (mandatory !) +*/ +int Xorriso_findi_iter(struct XorrisO *xorriso, IsoDir *dir_node, off_t *mem, + IsoDirIter **iter, + IsoNode ***node_array, int *node_count, int *node_idx, + IsoNode **iterated_node, int flag) +{ + int ret, i; + IsoNode *node; + off_t new_mem= 0; + char mem_text[80], limit_text[80]; + + if(flag&1) { + *node_array= NULL; + *node_count= -1; + *node_idx= 0; + *iter= NULL; + ret= iso_dir_get_children(dir_node, iter); + if(ret<0) { +cannot_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + return(-1); + } + if((flag&2)|(flag&4)) { + /* copy list of nodes and prepare soft iterator */ + *node_count= 0; + while(iso_dir_iter_next(*iter, &node) == 1) + (*node_count)++; + iso_dir_iter_free(*iter); + *iter= NULL; + + new_mem= ((*node_count)+1) * sizeof(IsoNode *); + if(new_mem > xorriso->temp_mem_limit) { + Sfile_scale((double) new_mem, mem_text, 5,1e4, 0); + Sfile_scale((double) xorriso->temp_mem_limit, limit_text, 5,1e4, 0); + sprintf(xorriso->info_text, + "Stacked directory snapshots exceed -temp_mem_limit (%s > %s)", + mem_text, limit_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + *node_count= -1; + return(-1); + } + (*node_array)= (IsoNode **) calloc((*node_count)+1, sizeof(IsoNode *)); + if(*node_array == NULL) { + sprintf(xorriso->info_text, + "Could not allocate inode list of %.f bytes", + ((double) (*node_count)+1) * (double) sizeof(IsoNode *)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + *node_count= -1; + return(-1); + } + *mem= new_mem; + ret= iso_dir_get_children(dir_node, iter); + if(ret<0) + goto cannot_iter; + while(iso_dir_iter_next(*iter, &node) == 1 && *node_idx < *node_count) { + (*node_array)[*node_idx]= node; + iso_node_ref(node); + (*node_idx)++; + } + iso_dir_iter_free(*iter); + *iter= NULL; + *node_count= *node_idx; + *node_idx= 0; + if((flag&4) && *node_count>1) + qsort(*node_array, *node_count, sizeof(IsoNode *), + Xorriso__node_lba_cmp); + } + } + + if(flag&(1<<31)) { + if(*node_count>=0 && *node_array!=NULL) { + for(i= 0; i<*node_count; i++) + iso_node_unref((*node_array)[i]); + free(*node_array); + *node_array= NULL; + *node_count= -1; + *node_idx= 0; + } else { + if(*iter!=NULL) + iso_dir_iter_free(*iter); + *iter= NULL; + } + } + + if(flag&(1|(1<<31))) + return(1); + if(*node_count>=0) { + /* return next node_array element */ + if(*node_idx>=*node_count) + return(0); + *iterated_node= (*node_array)[*node_idx]; + (*node_idx)++; + } else { + ret= iso_dir_iter_next(*iter, iterated_node); + return(ret == 1); + } + return(1); +} + + +/* @param boss_iter If not NULL then this is an iterator suitable for + iso_dir_iter_remove() which is then to be used instead + of iso_node_remove(). + @param flag bit0= remove whole sub tree: rm -r + bit1= remove empty directory: rmdir + bit2= recursion: do not reassure in mode 2 "tree" + bit3= this is for overwriting and not for plain removal + bit4= count deleted files in xorriso->pacifier_count + bit5= with bit0 only remove directory content, not the directory + @return <=0 = error + 1 = removed simple node + 2 = removed directory or tree + 3 = did not remove on user revocation +*/ +int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, off_t boss_mem, + char *path, int flag) +{ + int ret, is_dir= 0, pl, not_removed= 0, fret; + IsoNode *victim_node, *node; + IsoDir *boss_node, *root_dir; + IsoDirIter *iter= NULL; + IsoImage *volume; + char *sub_name, *name; + char *sfe= NULL, *sub_path= NULL; + off_t mem; + IsoNode **node_array= NULL; + int node_count, node_idx; + +#ifdef Xorriso_fat_local_meM + char sfe[5*SfileadrL], sub_path[2*SfileadrL]; +#else + + /* Avoiding large local memory objects in order to save stack space */ + sfe= malloc(5*SfileadrL); + sub_path= malloc(2*SfileadrL); + if(sfe==NULL || sub_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ + +#ifndef Libisofs_iso_dir_iter_sufficienT + /* Ticket 127: A80301 - A80302 + I do not not deem IsoDirIter safe for node list manipulations. + The parameter boss_iter once was intended to allow such but + has now been downgraded to a mere check for eventual programming bugs. + */ + if(boss_iter!=NULL) { + sprintf(xorriso->info_text, + "Program error: Xorriso_rmi() was requested to delete iterated node %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= -1; goto ex; + } +#endif /* Libisofs_iso_dir_iter_sufficienT */ + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + goto ex; + + if(Xorriso_much_too_long(xorriso, strlen(path), 0)<=0) + {ret= 0; goto ex;} + ret= Xorriso_node_from_path(xorriso, volume, path, &victim_node, 0); + if(ret<=0) + goto ex; + root_dir= iso_image_get_root(volume); + if(((void *) root_dir) == ((void *) victim_node)) { + sprintf(xorriso->info_text, "May not delete root directory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + + if(LIBISO_ISDIR(victim_node)) + is_dir= 1; + if(!is_dir) { + if(flag&2) { /* rmdir */ + sprintf(xorriso->info_text, "%s in loaded ISO image is not a directory", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } else { + if(flag&1) { /* rm -r */ + if((xorriso->do_reassure==1 && !xorriso->request_not_to_ask) || + (flag&32)) { + /* Iterate over subordinates and delete them */ + mem= boss_mem; + + ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, + &iter, &node_array, &node_count, &node_idx, + &node, 1|2); + if(ret<=0) { +cannot_create_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + ret= -1; goto ex; + } + pl= strlen(path); + strcpy(sub_path, path); + if(pl==0 || sub_path[pl-1]!='/') { + sub_path[pl++]= '/'; + sub_path[pl]= 0; + } + sub_name= sub_path+pl; + while(1) { + ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, &iter, + &node_array, &node_count, &node_idx, &node, 0); + if(ret<0) + goto ex; + if(ret==0 || xorriso->request_to_abort) + break; + name= (char *) iso_node_get_name(node); + if(Xorriso_much_too_long(xorriso, pl+1+strlen(name), 0)<=0) + {ret= 0; goto rm_r_problem_handler;} + strcpy(sub_name, name); + ret= Xorriso_rmi(xorriso, iter, mem, sub_path, (flag&(1|2|8|16))|4); + if(ret==3 || ret<=0 || xorriso->request_to_abort) { +rm_r_problem_handler:; + not_removed= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret<0) + goto dir_not_removed; + } + } + if(flag&32) + {ret= 2; goto ex;} + + if(not_removed) { +dir_not_removed:; + sprintf(xorriso->info_text, "Directory not removed: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + if(ret>0) + ret= 3; + goto ex; + } + } + } else { + if(!(flag&2)) { /* not rmdir */ + sprintf(xorriso->info_text, "%s in loaded ISO image is a directory", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + ret= iso_dir_get_children((IsoDir *) victim_node, &iter); + Xorriso_process_msg_queues(xorriso,0); + if(ret<0) + goto cannot_create_iter; + if(ret>0) { + if(iso_dir_iter_next(iter, &node) == 1) { + sprintf(xorriso->info_text, + "Directory not empty on attempt to delete: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + } + } + + if(xorriso->request_to_abort) + {ret= 3; goto ex;} + boss_node= iso_node_get_parent(victim_node); + Xorriso_process_msg_queues(xorriso,0); + if(boss_node==NULL) { + sprintf(xorriso->info_text, + "Cannot find parent node of %s in loaded ISO image", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + while((xorriso->do_reassure==1 || (xorriso->do_reassure==2 && !(flag&4))) + && !xorriso->request_not_to_ask) { + /* ls -ld */ + Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 1|2|8); + if(is_dir) /* du -s */ + Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 2|4); + if(flag&8) + sprintf(xorriso->info_text, + "File exists. Remove ? n= keep old, y= remove, x= abort, @= stop asking\n"); + else + sprintf(xorriso->info_text, + "Remove above file ? n= keep it, y= remove it, x= abort, @= stop asking\n"); + Xorriso_info(xorriso, 4); + ret= Xorriso_request_confirmation(xorriso, 1|2|4|16); + if(ret<=0) + goto ex; + if(xorriso->request_to_abort) { + sprintf(xorriso->info_text, + "Removal operation aborted by user before file: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 3; goto ex; + } + if(ret==3) + continue; + if(ret==6) /* yes */ + break; + if(ret==4) { /* yes, do not ask again */ + xorriso->request_not_to_ask= 1; + break; + } + if(ret==1) { /* no */ + sprintf(xorriso->info_text, "Kept in existing state: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 3; goto ex; + } + } + +#ifdef Libisofs_iso_dir_iter_sufficienT + + if(boss_iter!=NULL) { + ret= iso_dir_iter_remove((IsoDirIter *) boss_iter); + if(ret<0) + ret= -1; + } else + ret= iso_node_remove(victim_node); + +#else /* ! Libisofs_iso_dir_iter_sufficienT */ + + ret= iso_node_remove(victim_node); + +#endif /* Libisofs_iso_dir_iter_sufficienT */ + + Xorriso_process_msg_queues(xorriso,0); + if(ret<0) { + Xorriso_report_iso_error(xorriso, path, ret, "Cannot remove node", 0, + "FATAL", 1); + sprintf(xorriso->info_text, + "Internal failure to remove %s from loaded ISO image", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= -1; goto ex; + } + if(flag&16) + xorriso->pacifier_count++; + xorriso->volset_change_pending= 1; + ret= 1+!!is_dir; +ex:; + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(sub_path!=NULL) + free(sub_path); +#endif /* ! Xorriso_fat_local_meM */ + + Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, &iter, + &node_array, &node_count, &node_idx, &node, (1<<31)); + return(ret); +} + + +int Xorriso__node_name_cmp(const void *node1, const void *node2) +{ + char *name1, *name2; + + name1= (char *) iso_node_get_name(*((IsoNode **) node1)); + name2= (char *) iso_node_get_name(*((IsoNode **) node2)); + return(strcmp(name1,name2)); +} + + +/* @param flag bit0= only accept directory nodes + bit1= do not report memory usage as DEBUG + bit2= do not apply search pattern but accept any node +*/ +int Xorriso_sorted_node_array(struct XorrisO *xorriso, + IsoDir *dir_node, + int *nodec, IsoNode ***node_array, + off_t boss_mem, int flag) +{ + int i, ret, failed_at; + char *npt; + IsoDirIter *iter= NULL; + IsoNode *node; + off_t mem; + + mem= ((*nodec)+1)*sizeof(IsoNode *); + ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, flag&2); + if(ret<=0) + return(ret); + + *node_array= calloc(sizeof(IsoNode *), (*nodec)+1); + if(*node_array==NULL) { + sprintf(xorriso->info_text, + "Cannot allocate memory for %d directory entries", *nodec); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { + Xorriso_cannot_create_iter(xorriso, ret, 0); + return(-1); + } + + for(i= 0; iso_dir_iter_next(iter, &node) == 1 && i<*nodec; ) { + npt= (char *) iso_node_get_name(node); + if(!(flag&4)) { + ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); + if(ret) + continue; /* no match */ + } + if(flag&1) + if(!LIBISO_ISDIR(node)) + continue; + (*node_array)[i++]= node; + } + iso_dir_iter_free(iter); + *nodec= i; + if(*nodec<=0) + return(1); + qsort(*node_array, *nodec, sizeof(IsoNode *), Xorriso__node_name_cmp); + return(1); +} + + +/* @param flag bit0= do not only sum up sizes but also print subdirs +*/ +int Xorriso_show_du_subs(struct XorrisO *xorriso, IsoDir *dir_node, + char *abs_path, char *rel_path, off_t *size, + off_t boss_mem, int flag) +{ + int i, ret, no_sort= 0, filec= 0, l; + IsoDirIter *iter= NULL; + IsoNode *node, **node_array= NULL; + char *name; + off_t sub_size, report_size, mem= 0; + +#ifdef Xorriso_fat_local_meM + char path[SfileadrL], show_path[SfileadrL], sfe[5*SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *path= NULL, *show_path= NULL, *sfe= NULL; + + sfe= malloc(5*SfileadrL); + path= malloc(SfileadrL); + show_path= malloc(SfileadrL); + if(path==NULL || show_path==NULL || sfe==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + +#endif /* ! Xorriso_fat_local_meM */ + + *size= 0; + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { +cannot_create_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + {ret= -1; goto ex;} + } + for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { + sub_size= 0; + name= (char *) iso_node_get_name(node); + strcpy(show_path, rel_path); + if(Sfile_add_to_path(show_path, name, 0)<=0) + goto much_too_long; + if(LIBISO_ISDIR(node)) { + strcpy(path, abs_path); + if(Sfile_add_to_path(path, name, 0)<=0) { +much_too_long:; + Xorriso_much_too_long(xorriso, strlen(path)+strlen(name)+1, 2); + {ret= -1; goto ex;} + } + filec++; + l= strlen(rel_path)+1; + mem+= l; + if(l % sizeof(char *)) + mem+= sizeof(char *)-(l % sizeof(char *)); + if(flag&1) /* diving and counting is done further below */ + continue; + ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, + path, show_path, &sub_size, boss_mem, 0); + if(ret<0) + goto ex; + if(ret==0) + continue; + } + + if(LIBISO_ISREG(node)) { + sub_size+= iso_file_get_size((IsoFile *) node)+2048; +/* + sub_size+= iso_file_get_size((IsoFile *) node)+strlen(name)+1; +*/ + } + + if(sub_size>0) + (*size)+= sub_size; + Xorriso_process_msg_queues(xorriso,0); + } + + if(filec<=0 || !(flag&1)) + {ret= 1; goto ex;} + + /* Reset iteration */ + iso_dir_iter_free(iter); + iter= NULL; + Xorriso_process_msg_queues(xorriso,0); + + ret= Xorriso_sorted_node_array(xorriso, dir_node, &filec, &node_array, + boss_mem, 1|2|4); + if(ret<0) + goto ex; + if(ret==0) { + no_sort= 1; + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) + goto cannot_create_iter; + } + + for(i= 0; (no_sort || irequest_to_abort); i++) { + if(no_sort) { + ret= iso_dir_iter_next(iter, &node); + if(ret!=1) + break; + if(!LIBISO_ISDIR(node)) + continue; + } else + node= node_array[i]; + + sub_size= 0; + name= (char *) iso_node_get_name(node); + strcpy(show_path, rel_path); + if(Sfile_add_to_path(show_path, name, 0)<=0) + goto much_too_long; + strcpy(path, abs_path); + if(Sfile_add_to_path(path, name, 0)<=0) + goto much_too_long; + ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, + path, show_path, &sub_size, boss_mem+mem, flag&1); + if(ret<0) + goto ex; + + if(LIBISO_ISREG(node)) { + sub_size+= iso_file_get_size((IsoFile *) node)+2048; +/* + sub_size+= iso_tree_node_get_size((IsoFile *) node)+strlen(name)+1; +*/ + } + if(sub_size>0) + (*size)+= sub_size; + report_size= sub_size/1024; + if(report_size*1024result_line, "%7.f ",(double) (report_size)); + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + } + ret= 1; +ex:; + +#ifndef Xorriso_fat_local_meM + if(sfe!=NULL) + free(sfe); + if(path!=NULL) + free(path); + if(show_path!=NULL) + free(show_path); +#endif /* ! Xorriso_fat_local_meM */ + + if(iter!=NULL) + iso_dir_iter_free(iter); + if(node_array!=NULL) + free((char *) node_array); + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + +/* @param flag bit0= *node is already valid + bit1= add extra block for size estimation +*/ +int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, + IsoNode **node, int flag) +{ + int ret; + IsoImage *volume; + + memset((char *) stbuf, 0, sizeof(struct stat)); + if(!(flag&1)) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(-1); + ret= Xorriso_node_from_path(xorriso, volume, path, node, 1); + if(ret<=0) + *node= NULL; + } + if(*node==NULL) + return(0); + + /* >>> stbuf->st_dev */ + /* >>> stbuf->st_ino */ + + stbuf->st_mode= iso_node_get_permissions(*node) & 07777; + if(LIBISO_ISDIR(*node)) + stbuf->st_mode|= S_IFDIR; + else if(LIBISO_ISREG(*node)) + stbuf->st_mode|= S_IFREG; + else if(LIBISO_ISLNK(*node)) + stbuf->st_mode|= S_IFLNK; + else if(LIBISO_ISLNK(*node)) + stbuf->st_mode|= S_IFCHR; + else if(LIBISO_ISBLK(*node)) + stbuf->st_mode|= S_IFBLK; + else if(LIBISO_ISFIFO(*node)) + stbuf->st_mode|= S_IFIFO; + else if(LIBISO_ISSOCK(*node)) + stbuf->st_mode|= S_IFSOCK; + + /* >>> NG How to represent LIBISO_BOOT ? */ + + + /* >>> With directories this should be : number of subdirs + 2 */ + /* >>> ??? How to obtain RR hardlink number for other types ? */ + stbuf->st_nlink= 1; + + stbuf->st_uid= iso_node_get_uid(*node); + stbuf->st_gid= iso_node_get_gid(*node); + + /* >>> stbuf->st_rdev */ + + if(LIBISO_ISREG(*node)) + stbuf->st_size= iso_file_get_size((IsoFile *) *node)+ (2048 * !!(flag&2)); + else + stbuf->st_size= 0; + + stbuf->st_blksize= 2048; + stbuf->st_blocks= stbuf->st_size / (off_t) 2048; + if(stbuf->st_blocks * (off_t) 2048 != stbuf->st_size) + stbuf->st_blocks++; + + stbuf->st_atime= iso_node_get_atime(*node); + stbuf->st_mtime= iso_node_get_mtime(*node); + stbuf->st_ctime= iso_node_get_ctime(*node); + return(1); +} + + +int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf, + int flag) +{ + int ret; + IsoNode *node; + + ret= Xorriso_fake_stbuf(xorriso, path, stbuf, &node, 0); + if(ret>0) + return(0); + return(-1); +} + + +int Xorriso_sorted_dir_i(struct XorrisO *xorriso, IsoDir *dir_node, + int *filec, char ***filev, off_t boss_mem, int flag) +{ + int i,j,ret; + IsoDirIter *iter= NULL; + IsoNode *node; + char *name; + off_t mem; + + (*filec)= 0; + (*filev)= NULL; + + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { +cannot_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + {ret= -1; goto ex;} + } + mem= 0; + for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { + name= (char *) iso_node_get_name(node); + mem+= sizeof(char *)+strlen(name)+8; + (*filec)++; + } + iso_dir_iter_free(iter); + iter= NULL; + if(*filec==0) + {ret= 1; goto ex;} + + ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, 2); + if(ret<=0) + goto ex; + (*filev)= (char **) calloc(*filec, sizeof(char *)); + if(*filev==NULL) + {ret= -1; goto ex; } + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) + goto cannot_iter; + for(i= 0; i<*filec; i++) { + ret= iso_dir_iter_next(iter, &node); + if(ret!=1) + break; + name= (char *) iso_node_get_name(node); + (*filev)[i]= strdup(name); + if((*filev)[i]==NULL) { + for(j= 0; jresult_line; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + + Sort_argv(filec, filev, 0); + + /* Count valid nodes, warn of invalid ones */ + for(i= 0; iinfo_text, "Not found in ISO image: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + was_error++; + continue; + } + } + + if((flag&8) && !(flag&(2|4))) { + sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec-was_error); + Xorriso_info(xorriso,1); + if(filec-was_error<=0) + return(!was_error); + } + + passes= 1+!(flag&(4|8)); + for(pass= 0; passrequest_to_abort); i++) { + rpt[0]= 0; + ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4); + if(ret<=0) + continue; + ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, (flag&4)>>1); + if(ret<=0) + continue; + if(LIBISO_ISDIR(node) && !(flag&(4|8))) { + if(pass==0) + continue; + if(filec>1) { + strcpy(xorriso->result_line, "\n"); + Xorriso_result(xorriso,0); + sprintf(xorriso->result_line, "%s:\n", Text_shellsafe(filev[i], sfe,0)); + Xorriso_result(xorriso,0); + } + ret= Xorriso_sorted_dir_i(xorriso, + (IsoDir *) node, &dfilec, &dfilev, boss_mem, 0); + if(ret<=0) { + + /* >>> libisofs iterator loop and single item Xorriso_lsx_filev() */; + + } else { + if(flag&1) { + sprintf(xorriso->result_line, "total %d\n", dfilec); + Xorriso_result(xorriso,0); + } + Xorriso_ls_filev(xorriso, path, + dfilec, dfilev, boss_mem, (flag&1)|2|8); + } + if(dfilec>0) + Sfile_destroy_argv(&dfilec, &dfilev, 0); + continue; + } else + if(pass>0) + continue; + link_target[0]= 0; + if((flag&5)==1) { /* -ls_l */ + ret= Xorriso_format_ls_l(xorriso, &stbuf, 0); + if(ret<=0) + continue; + if(LIBISO_ISLNK(node)) { + if(Sfile_str(link_target, (char *) iso_symlink_get_dest( + (IsoSymlink *) node), 0)<=0) + link_target[0]= 0; + } + } else if(flag&4) { /* -du or -dus */ + size= stbuf.st_size; + if(S_ISDIR(stbuf.st_mode)) { + ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, + path, filev[i], &size, boss_mem, flag&1); + if(ret<0) + return(-1); + if(ret==0) + continue; + } + sprintf(rpt, "%7.f ",(double) (size/1024)); + } + if(link_target[0] && (flag&5)==1) + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n", + Text_shellsafe(filev[i], sfe, 0), + Text_shellsafe(link_target, sfe2, 0)); + else + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(filev[i], sfe, 0)); + Xorriso_result(xorriso, 0); + } + return(!was_error); +} + + +/* This function needs less buffer memory than Xorriso_ls_filev() but cannot + perform structured pattern matching as done by Xorriso_expand_pattern() + for subsequent Xorriso_ls_filev(). + @param flag bit0= long format + bit1= only check for directory existence + bit2= do not apply search pattern but accept any file + bit3= just count nodes and return number +*/ +int Xorriso_ls(struct XorrisO *xorriso, int flag) +{ + int ret, is_dir= 0, i, filec= 0, failed_at, no_sort= 0; + IsoNode *node, **node_array= NULL; + IsoDir *dir_node; + IsoImage *volume; + IsoDirIter *iter= NULL; + char sfe[5*SfileadrL], sfe2[5*SfileadrL], link_target[SfileadrL], *npt, *rpt; + struct stat stbuf; + + rpt= xorriso->result_line; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + + ret= Xorriso_node_from_path(xorriso, volume, xorriso->wdi, &node, 0); + if(ret<=0) + goto wdi_is_not_a_dir; + if(LIBISO_ISDIR(node)) + is_dir= 1; + if(!is_dir) { +wdi_is_not_a_dir:; + sprintf(xorriso->info_text, + "Working directory path does not lead to a directory in ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(flag&2) + {ret= 1; goto ex;} + + dir_node= (IsoDir *) node; + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { +cannot_create_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + {ret= -1; goto ex;} + } + Xorriso_process_msg_queues(xorriso,0); + + for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { + npt= (char *) iso_node_get_name(node); + if(!(flag&4)) { + ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); + if(ret) + continue; /* no match */ + } + filec++; + } + /* Reset iteration */ + iso_dir_iter_free(iter); + iter= NULL; + Xorriso_process_msg_queues(xorriso,0); + if(flag&8) + {ret= filec; goto ex;} + sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec); + Xorriso_info(xorriso,1); + + ret= Xorriso_sorted_node_array(xorriso, dir_node, &filec, &node_array, 0, + flag&4); + if(ret<0) + goto ex; + if(ret==0) { + no_sort= 1; + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) + goto cannot_create_iter; + } + + for(i= 0; irequest_to_abort); i++) { + if(no_sort) { + ret= iso_dir_iter_next(iter, &node); + if(ret!=1) + break; + npt= (char *) iso_node_get_name(node); + if(!(flag&4)) { + ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); + if(ret) + continue; /* no match */ + } + } else + node= node_array[i]; + + npt= (char *) iso_node_get_name(node); + link_target[0]= 0; + if(LIBISO_ISLNK(node)) { + if(Sfile_str(link_target, (char *) iso_symlink_get_dest( + (IsoSymlink *) node), 0)<=0) + link_target[0]= 0; + } + rpt[0]= 0; + if(flag&1) { + ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1); + if(ret<=0) + continue; + ret= Xorriso_format_ls_l(xorriso, &stbuf, 0); + if(ret<=0) + continue; + } + if(link_target[0] && (flag&1)) + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n", + Text_shellsafe(npt, sfe, 0), + Text_shellsafe(link_target, sfe2, 0)); + else + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(npt, sfe, 0)); + Xorriso_result(xorriso, 0); + } + + ret= 1; +ex:; + if(iter!=NULL) + iso_dir_iter_free(iter); + Xorriso_process_msg_queues(xorriso,0); + if(node_array!=NULL) + free((char *) node_array); + return(ret); +} + + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world +*/ +int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter, + char *origin, char *dest, int flag) +{ + int ret, ol, dest_ret; + char sfe[5*SfileadrL], eff_dest[SfileadrL], dir_adr[SfileadrL], *cpt; + char *leafname, eff_origin[SfileadrL], sfe2[5*SfileadrL], *old_leafname; + IsoImage *volume; + IsoDir *origin_dir, *dest_dir; + IsoNode *node, *iso_node; + +#ifndef Libisofs_iso_dir_iter_sufficienT + /* Ticket 127: A80301 - A80302 + I do not not deem IsoDirIter safe for node list manipulations. + The parameter boss_iter once was intended to allow such but + has now been downgraded to a mere check for eventual programming bugs. + */ + if(boss_iter!=NULL) { + sprintf(xorriso->info_text, + "Program error: Xorriso_rename() was requested to delete iterated node %s", + Text_shellsafe(origin, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } +#endif /* Libisofs_iso_dir_iter_sufficienT */ + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, origin, eff_origin, 0); + if(ret<=0) + return(ret); + dest_ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest,1); + if(dest_ret<0) + return(dest_ret); + if(dest_ret==0) { /* obtain eff_dest address despite it does not exist */ + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest, 2); + if(ret<=0) + return(ret); + } + + /* Prevent that destination is a subordinate of origin + (that would be a black hole plopping out of the universe) */ + ol= strlen(eff_origin); + if(ol==0) { + sprintf(xorriso->info_text, "May not rename root directory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } else if(strcmp(eff_origin, eff_dest)==0) { + sprintf(xorriso->info_text, "Ignored attempt to rename %s to itself", + Text_shellsafe(eff_origin,sfe,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(0); + } else if(strncmp(eff_origin, eff_dest, ol)==0 && + (eff_dest[ol]==0 || eff_dest[ol]=='/')) { + sprintf(xorriso->info_text, + "May not rename %s to its own sub address %s", + Text_shellsafe(eff_origin,sfe,0), Text_shellsafe(eff_dest,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + + /* Check whether destination exists and may be not overwriteable */ + if(dest_ret==2 && xorriso->do_overwrite!=1) { + sprintf(xorriso->info_text, "Renaming may not overwrite directory: %s", + Text_shellsafe(eff_dest, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } else if (dest_ret==1 && !xorriso->do_overwrite) { + sprintf(xorriso->info_text, "Renaming may not overwite: %s", + Text_shellsafe(eff_dest, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } else if(dest_ret>0) { + ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, eff_dest, 1|8); + if(ret<=0) + return(0); + if(ret==3) { + sprintf(xorriso->info_text, "User revoked renaming of: %s", + Text_shellsafe(eff_origin, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(0); + } + } + + /* Ensure existence of destination directory */ + strcpy(dir_adr, eff_dest); + cpt= strrchr(dir_adr, '/'); + if(cpt==NULL) + cpt= dir_adr+strlen(dir_adr); + *cpt= 0; + if(dir_adr[0]!=0) { + ret= Xorriso_graft_in(xorriso, boss_iter, NULL, dir_adr, + (off_t) 0, (off_t) 0, 1); + if(ret<=0) + return(ret); + } + + /* Move node */ + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + Xorriso_node_from_path(xorriso, volume, dir_adr, &iso_node, 0); + dest_dir= (IsoDir *) iso_node; + strcpy(dir_adr, eff_origin); + cpt= strrchr(dir_adr, '/'); + if(cpt==NULL) + cpt= dir_adr+strlen(dir_adr); + *cpt= 0; + Xorriso_node_from_path(xorriso, volume, dir_adr, &iso_node, 0); + origin_dir= (IsoDir *) iso_node; + Xorriso_node_from_path(xorriso, volume, eff_origin, &node, 0); + if(dest_dir==NULL || origin_dir==NULL || node==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Internal error on rename: confirmed node turns out as NULL"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + ret= iso_node_take(node); + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot take", 0, "FATAL",1); + sprintf(xorriso->info_text, + "Internal error on rename: failed to take node"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + leafname= strrchr(eff_dest, '/'); + if(leafname==NULL) + leafname= eff_dest; + else + leafname++; + + old_leafname= (char *) iso_node_get_name(node); + if(strcmp(leafname, old_leafname)!=0) + ret= iso_node_set_name(node, leafname); + else + ret= 1; + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot set name", 0, + "FAILURE", 1); + return(-1); + } + Xorriso_process_msg_queues(xorriso,0); + ret= iso_dir_add_node(dest_dir, node, 0); + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot add", 0, "FATAL", 1); + sprintf(xorriso->info_text, + "Internal error on rename: failed to insert node"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + return(1); +} + + +/* @param flag bit0= do not produce info message on success + @return 1=success, + 0=was already directory, -1=was other type, -2=other error +*/ +int Xorriso_mkdir(struct XorrisO *xorriso, char *path, int flag) +{ + int ret; + char eff_path[SfileadrL], sfe[5*SfileadrL]; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1); + if(ret<0) + return(-2); + if(ret>0) { + sprintf(xorriso->info_text,"-mkdir: Address already existing %s", + Text_shellsafe(eff_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (ret==2 ? "WARNING" : "FAILURE"), 0); + return(-1+(ret==2)); + } + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2); + if(ret<0) + return(-2); + ret= Xorriso_graft_in(xorriso, NULL, NULL, eff_path, (off_t) 0, (off_t) 0, 1); + if(ret<=0) + return(-2); + if(!(flag&1)) { + sprintf(xorriso->info_text, "Created directory in ISO image: %s\n", + Text_shellsafe(eff_path,sfe,0)); + Xorriso_info(xorriso, 0); + } + return(1); +} + + +/* @param flag bit0= count results rather than storing them + bit1= this is a recursion + bit2= prepend wd (automatically done if wd[0]!=0) +*/ +int Xorriso_obtain_pattern_files_i( + struct XorrisO *xorriso, char *wd, IsoDir *dir, + int *filec, char **filev, int count_limit, off_t *mem, + int *dive_count, int flag) +{ + int ret, failed_at; + IsoDirIter *iter= NULL; + IsoNode *node; + char *name; + +#ifdef Xorriso_fat_local_meM + char adr[SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *adr= NULL; + + adr= malloc(SfileadrL); + if(adr==NULL) { + Xorriso_no_malloc_memory(xorriso, &adr, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ + + + if(!(flag&2)) + *dive_count= 0; + else + (*dive_count)++; + ret= Xorriso_check_for_root_pattern(xorriso, filec, filev, count_limit, + mem, (flag&1)|2); + if(ret!=2) + goto ex; + + ret= iso_dir_get_children(dir, &iter); + if(ret<0) { + Xorriso_cannot_create_iter(xorriso, ret, 0); + {ret= -1; goto ex;} + } + while(iso_dir_iter_next(iter, &node) == 1) { + name= (char *) iso_node_get_name(node); + ret= Xorriso_make_abs_adr(xorriso, wd, name, adr, flag&4); + if(ret<=0) + goto ex; + ret= Xorriso_regexec(xorriso, adr, &failed_at, 1); + if(ret) { /* no match */ + if(failed_at <= *dive_count) /* no hope for a match */ + continue; + + if(!LIBISO_ISDIR(node)) { + + /* >>> How to deal with softlinks ? */ + + continue; + } + /* dive deeper */ + ret= Xorriso_obtain_pattern_files_i( + xorriso, adr, (IsoDir *) node, + filec, filev, count_limit, mem, dive_count, flag|2); + if(ret<=0) + goto ex; + } else { + ret= Xorriso_register_matched_adr(xorriso, adr, count_limit, + filec, filev, mem, (flag&1)|2); + if(ret<=0) + goto ex; + } + } + ret= 1; +ex:; + +#ifndef Xorriso_fat_local_meM + if(adr!=NULL) + free(adr); +#endif /* ! Xorriso_fat_local_meM */ + + if(flag&2) + (*dive_count)--; + return(ret); +} + + +/* @param flag bit0= a match count !=1 is a FAILURE event + bit1= with bit0 tolerate 0 matches if pattern is a constant +*/ +int Xorriso_expand_pattern(struct XorrisO *xorriso, + int num_patterns, char **patterns, int extra_filec, + int *filec, char ***filev, off_t *mem, int flag) +{ + int ret, count= 0, abs_adr= 0, i, was_count, was_filec; + int nonconst_mismatches= 0, dive_count= 0; + char sfe[5*SfileadrL]; + IsoImage *volume; + IsoDir *dir= NULL, *root_dir; + IsoNode *iso_node; + + *filec= 0; + *filev= NULL; + + xorriso->search_mode= 3; + xorriso->structured_search= 1; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + root_dir= iso_image_get_root(volume); + if(root_dir==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "While expanding pattern : Cannot obtain root node of ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= -1; goto ex; + } + + for(i= 0; iwdi does not exist yet, but one may + not use it as base for relative address searches. + */ + ret= Xorriso_node_from_path(xorriso, volume, xorriso->wdi, &iso_node, 1); + dir= (IsoDir *) iso_node; + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "While expanding pattern %s : Working directory does not exist in ISO image", + Text_shellsafe(patterns[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(!LIBISO_ISDIR((IsoNode *) dir)) { + sprintf(xorriso->info_text, + "Working directory path does not lead to a directory in ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + + /* count the matches */ + was_count= count; + ret= Xorriso_obtain_pattern_files_i(xorriso, "", dir, &count, NULL, 0, + mem, &dive_count, 1 | abs_adr); + if(ret<=0) + goto ex; + if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1) { + count++; + Xorriso_eval_nonmatch(xorriso, patterns[i], &nonconst_mismatches, mem, 0); + } + } + + ret= Xorriso_check_matchcount(xorriso, count, nonconst_mismatches, + num_patterns, patterns, (flag&1)|2); + if(ret<=0) + goto ex; + count+= extra_filec; + mem+= extra_filec*sizeof(char *); + if(count<=0) + {ret= 0; goto ex;} + ret= Xorriso_alloc_pattern_mem(xorriso, *mem, count, filev, 0); + if(ret<=0) + goto ex; + /* now store addresses */ + for(i= 0; iinfo_text,"Permissions now: %-5.5o %s", + mode, Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + xorriso->volset_change_pending= 1; + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_set_uid(struct XorrisO *xorriso, char *in_path, uid_t uid, + int flag) +{ + int ret; + IsoNode *node; + + ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); + if(ret<=0) + return(ret); + iso_node_set_uid(node, uid); + iso_node_set_ctime(node, time(NULL)); + xorriso->volset_change_pending= 1; + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_set_gid(struct XorrisO *xorriso, char *in_path, gid_t gid, + int flag) +{ + int ret; + IsoNode *node; + + ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); + if(ret<=0) + return(ret); + iso_node_set_gid(node, gid); + iso_node_set_ctime(node, time(NULL)); + xorriso->volset_change_pending= 1; + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +/* @parm flag bit0= atime, bit1= ctime, bit2= mtime, bit8=no auto ctime */ +int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t, + int flag) +{ + int ret; + IsoNode *node; + + ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); + if(ret<=0) + return(ret); + if(flag&1) + iso_node_set_atime(node, t); + if(flag&2) + iso_node_set_ctime(node, t); + if(flag&4) + iso_node_set_mtime(node, t); + if(!(flag&(2|256))) + iso_node_set_ctime(node, time(NULL)); + xorriso->volset_change_pending= 1; + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +/* @param flag bit0= not a command parameter (directory iteration or recursion) + bit1= do not count deleted files with rm and rm_r + @return <=0 error, + 1=ok + 2=ok, node has been deleted, + 3=ok, do not dive into directory (e.g. because it is a split file) +*/ +int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, + IsoDirIter *boss_iter, off_t boss_mem, + char *abs_path, char *show_path, + IsoNode *node, int depth, int flag) +{ + int ret= 0, type, action= 0, hflag, deleted= 0, no_dive= 0; + uid_t user= 0; + gid_t group= 0; + time_t date= 0; + mode_t mode_or= 0, mode_and= ~1; + char *target, sfe[5*SfileadrL], *iso_prefix; + struct FindjoB *subjob; + struct stat dir_stbuf; + + action= Findjob_get_action_parms(job, &target, &user, &group, + &mode_and, &mode_or, &type, &date, &subjob, 0); + if(action<0) + action= 0; + + hflag= 16*!(flag&2); + if(action==1) { /* rm (including rmdir) */ + ret= Xorriso_fake_stbuf(xorriso, abs_path, &dir_stbuf, &node, 1); + if(ret>0) { + if(S_ISDIR(dir_stbuf.st_mode)) + hflag= 2; + ret= Xorriso_rmi(xorriso, boss_iter, boss_mem, abs_path, hflag); + deleted= 1; + } + } else if(action==2) { /* rm_r */ + ret= Xorriso_rmi(xorriso, boss_iter, boss_mem, abs_path, 1|hflag); + deleted= 1; + } else if(action==3) { + + /* >>> mv target */; + + } else if(action==4) { /* chown */ + ret= Xorriso_set_uid(xorriso, abs_path, user, 0); + } else if(action==5) { /* chgrp */ + ret= Xorriso_set_gid(xorriso, abs_path, group, 0); + } else if(action==6) { /* chmod */ + ret= Xorriso_set_st_mode(xorriso, abs_path, mode_and, mode_or, 0); + } else if(action==7) { /* alter_date */ + ret= Xorriso_set_time(xorriso, abs_path, date, type&7); + } else if(action==8) { /* lsdl */ + ret= Xorriso_ls_filev(xorriso, "", 1, &abs_path, (off_t) 0, 1|2|8); + } else if(action>=9 && action<=13) { /* actions which have own findjobs */ + Findjob_set_start_path(subjob, abs_path, 0); + ret= Xorriso_findi(xorriso, subjob, boss_iter, boss_mem, NULL, + abs_path, &dir_stbuf, depth, 1); + } else if(action==14 || action==17) { /* compare , update */ + Findjob_get_start_path(job, &iso_prefix, 0); + ret= Xorriso_find_compare(xorriso, (void *) boss_iter, abs_path, + iso_prefix, target, (action==17)|((flag&1)<<1)); + if(ret==2) + deleted= 1; + if(ret==3) + no_dive= 1; + if(ret>=0) + ret= 1; + } else if(action==16 || action==18) { /* not_in_iso , add_missing */ + ; + } else { /* includes : 15 in_iso */ + sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + ret= 1; + } + if(ret<=0) + return(ret); + if(deleted) + return(2); + if(no_dive) + return(3); + return(1); +} + + +/* @param flag bit0= recursion + bit1= do not count deleted files with rm and rm_r + @return <=0 error, 1= ok , 2= dir node and path has been deleted +*/ +int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, + void *boss_iter, off_t boss_mem, + void *dir_node_generic, char *dir_path, + struct stat *dir_stbuf, int depth, int flag) +{ + int ret, action= 0, hflag, deleted= 0, no_dive= 0; + IsoDirIter *iter= NULL; + IsoDir *dir_node= NULL; + IsoNode *node, *iso_node; + IsoImage *volume; + struct stat stbuf; + char *name; + off_t mem; + IsoNode **node_array= NULL; + int node_count, node_idx; +#ifdef Xorriso_fat_local_meM + char path[SfileadrL], abs_path[SfileadrL]; +#else /* Xorriso_fat_local_meM */ + char *path= NULL, *abs_path= NULL; + + path= malloc(SfileadrL); + abs_path= malloc(SfileadrL); + if(path==NULL || abs_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &path, 0); + {ret= -1; goto ex;} + } +#endif /* ! Xorriso_fat_local_meM */ + + action= Findjob_get_action(job, 0); + if(action<0) + action= 0; + + dir_node= (IsoDir *) dir_node_generic; + if(dir_node==NULL) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + {ret= -1; goto ex;} + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, dir_path, path, 1|2|4); + if(ret<=0) + goto ex; + ret= Xorriso_node_from_path(xorriso, volume, path, &iso_node, 0); + dir_node= (IsoDir *) iso_node; + if(ret<=0) + {ret= 0; goto ex;} + ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, &iso_node, 1); + dir_node= (IsoDir *) iso_node; + if(ret<=0) + goto ex; + + name= strrchr(dir_path, '/'); + if(name==NULL) + name= dir_path; + else + name++; + ret= Findjob_test(job, name, NULL, dir_stbuf, depth, 0); + if(ret<0) + goto ex; + if(ret>0) { + ret= Xorriso_findi_action(xorriso, job, + (IsoDirIter *) boss_iter, boss_mem, + path, dir_path, (IsoNode *) dir_node, depth, + flag&(1|2)); + if(ret<=0) + goto ex; + if(ret==2) { + deleted= 1; + goto ex; + } + if(ret==3) + no_dive= 1; + } + } + if(no_dive || !LIBISO_ISDIR((IsoNode *) dir_node)) + {ret= 1; goto ex;} + + mem= boss_mem; + hflag= 1; + if(action==1 || action==2 || action==3 || action==14) + hflag|= 2; /* need freedom to manipulate image */ + if(action==14 || action==17) + hflag|= 4; /* need LBA sorted iteration for good data reading performance */ + ret= Xorriso_findi_iter(xorriso, dir_node, &mem, + &iter, &node_array, &node_count, &node_idx, + &node, hflag); + if(ret<=0) + goto ex; + while(1) { + ret= Xorriso_findi_iter(xorriso, dir_node, &mem, &iter, + &node_array, &node_count, &node_idx, &node, 0); + if(ret<0) + goto ex; + if(ret==0 || xorriso->request_to_abort) + break; + name= (char *) iso_node_get_name(node); + ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4); + if(ret<=0) + goto ex; + ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1); + if(ret<0) + goto ex; + if(ret==0) + continue; + +/* ??? This seems to be redundant with the single test above + ??? Should i dive in unconditionally and leave out test and action here ? + ??? Then do above test unconditionally ? + --- Seems that the current configuration represents the special + handling of the find start path with mount points. Dangerous to change. +*/ + ret= Findjob_test(job, name, dir_stbuf, &stbuf, depth, 0); + if(ret<0) + goto ex; + if(ret>0) { + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, path, abs_path, 1|2|4); + if(ret<=0) + goto ex; + ret= Xorriso_findi_action(xorriso, job, iter, mem, + abs_path, path, node, depth, 1|(flag&2)); + if(ret==2) /* node has been deleted */ + continue; + no_dive= (ret==3); + if(ret<=0) { + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + goto ex; + } + } + + if(S_ISDIR(stbuf.st_mode) && !no_dive) { + ret= Xorriso_findi(xorriso, job, (void *) iter, mem, + (void *) node, path, &stbuf, depth+1, flag|1); + if(ret<0) + goto ex; + } + } + + ret= 1; +ex:; + +#ifndef Xorriso_fat_local_meM + if(path!=NULL) + free(path); + if(abs_path!=NULL) + free(abs_path); +#endif /* ! Xorriso_fat_local_meM */ + + Xorriso_process_msg_queues(xorriso,0); + + Xorriso_findi_iter(xorriso, dir_node, &mem, &iter, &node_array, &node_count, + &node_idx, &node, (1<<31)); + if(ret<=0) + return(ret); + if(deleted) + return(2); + return(1); +} + + +/* @param flag bit0= do not mark image as changed */ +int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag) +{ + int ret; + IsoImage *volume; + + if(xorriso->in_volset_handle == NULL) + return(2); + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + iso_image_set_volume_id(volume, volid); + if(!(flag&1)) + xorriso->volset_change_pending= 1; + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Volume ID: '%s'",iso_image_get_volume_id(volume)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + return(1); +} + + +int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag) +{ + int ret; + IsoImage *volume; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + strncpy(volid, iso_image_get_volume_id(volume), 32); + volid[32]= 0; + return(1); +} + + +/* @param flag bit0= do not mark image as changed */ +int Xorriso_set_publisher(struct XorrisO *xorriso, char *name, int flag) +{ + int ret; + IsoImage *volume; + + if(xorriso->in_volset_handle == NULL) + return(2); + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + iso_image_set_publisher_id(volume, name); + if(!(flag&1)) + xorriso->volset_change_pending= 1; + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Publisher: '%s'", + iso_image_get_publisher_id(volume)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + return(1); +} + + +/* @param flag bit0=prepare for a burn run */ +int Xorriso_set_abort_severity(struct XorrisO *xorriso, int flag) +{ + int ret; + + /* ??? <<< On MISHAP use FAILURE as abort severity known to libisofs. + On ERRFILE use NEVER. + The pacifier loop will care for canceling libburn on MISHAP + and thus also cancel the image generation. + with libisofs-0.6.4 this should not be necessary + Shall it be uphold anyway ? + */ + if((flag&1) && strcmp(xorriso->abort_on_text, "MISHAP")==0) + ret= iso_set_abort_severity("FAILURE"); + else if((flag&1) && strcmp(xorriso->abort_on_text, "ERRFILE")==0) + ret= iso_set_abort_severity("NEVER"); + else + ret= iso_set_abort_severity(xorriso->abort_on_text); + return(ret>=0); +} + + +int Xorriso_report_lib_versions(struct XorrisO *xorriso, int flag) +{ + int major, minor, micro; + int req_major, req_minor, req_micro; + + iso_lib_version(&major, &minor, µ); + isoburn_libisofs_req(&req_major, &req_minor, &req_micro); + sprintf(xorriso->result_line, + "libisofs in use : %d.%d.%d (min. %d.%d.%d)\n", + major, minor, micro, req_major, req_minor, req_micro); + Xorriso_result(xorriso, 0); + burn_version(&major, &minor, µ); + isoburn_libburn_req(&req_major, &req_minor, &req_micro); + sprintf(xorriso->result_line, + "libburn in use : %d.%d.%d (min. %d.%d.%d)\n", + major, minor, micro, req_major, req_minor, req_micro); + Xorriso_result(xorriso, 0); + isoburn_version(&major, &minor, µ); + sprintf(xorriso->result_line, + "libisoburn in use : %d.%d.%d (min. %d.%d.%d)\n", + major, minor, micro, + isoburn_header_version_major, isoburn_header_version_minor, + isoburn_header_version_micro); + Xorriso_result(xorriso, 0); + return(1); +} + + +/* @param flag bit0= -inq + bit1= -checkdrive +*/ +int Xorriso_atip(struct XorrisO *xorriso, int flag) +{ + int ret, profile_number= 0; + char *respt, profile_name[80]; + double x_speed_max, x_speed_min= -1.0; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + enum burn_disc_status s; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to print drive and media info", 2); + if(ret<=0) + return(0); + respt= xorriso->result_line; + sprintf(respt, "Device type :"); + ret= burn_drive_get_drive_role(drive); + if(ret==0) + sprintf(respt+strlen(respt), "%s\n", "Emulated (null-drive)"); + else if(ret==2) + sprintf(respt+strlen(respt), "%s\n", + "Emulated (stdio-drive, 2k random read-write)"); + else if(ret==3) + sprintf(respt+strlen(respt), "%s\n", + "Emulated (stdio-drive, sequential write-only)"); + else if(ret!=1) + sprintf(respt+strlen(respt), "%s\n","Emulated (stdio-drive)"); + else + sprintf(respt+strlen(respt), "%s\n","Removable CD-ROM"); + sprintf(respt+strlen(respt), "Vendor_info : '%s'\n",dinfo->vendor); + sprintf(respt+strlen(respt), "Identifikation : '%s'\n",dinfo->product); + sprintf(respt+strlen(respt), "Revision : '%s'\n",dinfo->revision); + Xorriso_result(xorriso,1); + if(flag&1) + return(1); + sprintf(respt, "Driver flags : BURNFREE\n"); + sprintf(respt+strlen(respt), "Supported modes: SAO TAO\n"); + Xorriso_result(xorriso,1); + if(flag&2) + return(1); + + s= burn_disc_get_status(drive); + ret= burn_disc_get_profile(drive,&profile_number,profile_name); + if(ret<=0) { + profile_number= 0; + strcpy(profile_name, "-unidentified-"); + } + if(s != BURN_DISC_UNSUITABLE) { + ret= burn_disc_read_atip(drive); + if(ret>0) { + ret= burn_drive_get_min_write_speed(drive); + x_speed_min= ((double) ret)/176.4; + } + } + if(s==BURN_DISC_EMPTY) { + sprintf(respt, "Current: none\n"); + Xorriso_result(xorriso,1); + return(1); + } else + sprintf(respt, "Current: %s\n",profile_name); + Xorriso_result(xorriso,1); + if(strstr(profile_name,"DVD")==profile_name) { + sprintf(respt, "book type: %s (emulated booktype)\n", profile_name); + Xorriso_result(xorriso,1); + sprintf(respt, "xorriso: message for sdvdbackup: \"(growisofs mode Restricted Overwrite)\"\n"); + Xorriso_result(xorriso,1); + } else { + sprintf(respt, "ATIP info from disk:\n"); + Xorriso_result(xorriso,1); + if(burn_disc_erasable(drive)) + sprintf(respt, " Is erasable\n"); + else + sprintf(respt, " Is not erasable\n"); + Xorriso_result(xorriso,1); + { int start_lba,end_lba,min,sec,fr; + ret= burn_drive_get_start_end_lba(drive,&start_lba,&end_lba,0); + if(ret>0) { + burn_lba_to_msf(start_lba,&min,&sec,&fr); + sprintf(respt, " ATIP start of lead in: %d (%-2.2d:%-2.2d/%-2.2d)\n", + start_lba,min,sec,fr); + Xorriso_result(xorriso,1); + burn_lba_to_msf(end_lba,&min,&sec,&fr); + sprintf(respt, " ATIP start of lead out: %d (%-2.2d:%-2.2d/%-2.2d)\n", + end_lba,min,sec,fr); + Xorriso_result(xorriso,1); + } + } + ret= burn_drive_get_write_speed(drive); + x_speed_max= ((double) ret)/176.4; + if(x_speed_min<0) + x_speed_min= x_speed_max; + sprintf(respt, + " 1T speed low: %.f 1T speed high: %.f\n",x_speed_min,x_speed_max); + Xorriso_result(xorriso,1); + } + return(1); +} + + +int Xorriso_burn_track(struct XorrisO *xorriso, char *track_source, int flag) +{ + int ret, fd, unpredicted_size, profile_number, is_cd= 0; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + struct burn_write_opts *burn_options; + struct burn_disc *disc= NULL; + struct burn_session *session; + struct burn_track *track; + struct stat stbuf; + off_t fixed_size= 0; + struct burn_source *data_src, *fifo_src; + enum burn_disc_status disc_state; + char reasons[BURN_REASONS_LEN], sfe[5*SfileadrL], profile_name[80]; + + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to burn track", 2); + if(ret<=0) + return(0); + ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0); + if(ret<=0) + goto ex; + + disc= burn_disc_create(); + session= burn_session_create(); + ret= burn_disc_add_session(disc,session,BURN_POS_END); + if(ret==0) { + /* >>> */; + goto ex; + } + track= burn_track_create(); + if(track_source[0] == '-' && track_source[1] == 0) { + fd= 0; + } else { + fd= open(track_source, O_RDONLY); + if(fd>=0) + if(fstat(fd,&stbuf)!=-1) + if((stbuf.st_mode&S_IFMT)==S_IFREG) + fixed_size= stbuf.st_size; + } + if(fixed_size==0) + unpredicted_size= 1; + + data_src= NULL; + if(fd>=0) + data_src= burn_fd_source_new(fd, -1, fixed_size); + if(data_src==NULL) { + sprintf(xorriso->info_text, "Could not open data source %s", + Text_shellsafe(track_source,sfe,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + ret= 0; goto ex; + } + fifo_src= burn_fifo_source_new(data_src, 2048, xorriso->fs, 0); + if(fifo_src == NULL) { + sprintf(xorriso->info_text, "Could not create fifo object of 4 MB"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= 0; goto ex; + } + xorriso->pacifier_fifo= fifo_src; + if(burn_track_set_source(track, fifo_src)!=BURN_SOURCE_OK) { + sprintf(xorriso->info_text, + "Cannot attach source object to track object"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= 0; goto ex; + } + burn_session_add_track(session, track, BURN_POS_END); + burn_source_free(data_src); + + disc_state = burn_disc_get_status(drive); + if(disc_state == BURN_DISC_BLANK) { + /* ok */; + } else if(disc_state == BURN_DISC_APPENDABLE) { + if(!isoburn_needs_emulation(drive)) { + sprintf(xorriso->info_text, + "Appendable media with data detected. Need blank media."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } else { + if(disc_state == BURN_DISC_FULL) { + sprintf(xorriso->info_text, + "Closed media with data detected. Need blank media."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + if(burn_disc_erasable(drive)) { + sprintf(xorriso->info_text, "Try --blank_fast\n"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + } + } else if(disc_state == BURN_DISC_EMPTY) { + sprintf(xorriso->info_text, "No media detected in drive"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } else { + sprintf(xorriso->info_text, + "Cannot recognize state of drive and media"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + ret= 0; goto ex; + } + if(burn_write_opts_auto_write_type(burn_options, disc, reasons, 0) == + BURN_WRITE_NONE) { + sprintf(xorriso->info_text, + "Failed to find a suitable write mode with this media.\n"); + sprintf(xorriso->info_text+strlen(xorriso->info_text), + "Reasons given:\n%s", reasons); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + ret= Xorriso_get_profile(xorriso, &profile_number, profile_name, 2); + is_cd= (ret==2); + if(isoburn_needs_emulation(drive)) + burn_write_opts_set_start_byte(burn_options, (off_t) 0); + ret= Xorriso_sanitize_image_size(xorriso, drive, disc, burn_options, 2); + if(ret<=0) + goto ex; + + xorriso->run_state= 1; /* Indicate that burning has started */ + burn_disc_write(burn_options, disc); + + ret= Xorriso_pacifier_loop(xorriso, drive, 1|(is_cd<<4)); + if(ret<=0) + goto ex; + if(!burn_drive_wrote_well(drive)) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "libburn indicates failure with writing."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + sprintf(xorriso->info_text, "Writing completed sucessfully.\n\n"); + Xorriso_info(xorriso, 0); + ret= 1; +ex:; + Xorriso_process_msg_queues(xorriso,0); + if(disc!=NULL) + burn_disc_free(disc); + if(xorriso->pacifier_fifo!=NULL) + burn_source_free(xorriso->pacifier_fifo); + xorriso->pacifier_fifo= NULL; + xorriso->run_state= 0; /* Indicate that burning has ended */ + return(ret); +} + + + +/* @param flag bit1= outdev rather than indev + @return <0 error, 0 = no profile to see , 1= ok , 2= ok, is CD profile +*/ +int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number, + char profile_name[80], int flag) +{ + int ret; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + + *profile_number= 0; + profile_name[0]= 0; + if(xorriso->out_drive_handle==NULL) + return(0); + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to determine media type", flag&2); + if(ret<=0) + return(0); + ret=burn_disc_get_profile(drive, profile_number, profile_name); + if(ret<=0) + return(ret); + if(*profile_number==0x08 || *profile_number==0x09 || *profile_number==0x0a) + return(2); + return(0); +} + + +int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname, + void **stream, int flag) +{ + int ret; + char eff_path[SfileadrL]; + IsoNode *node= NULL; + IsoFile *filenode= NULL; + IsoStream *iso_stream= NULL; + +/* for debugging +#define Libisofs_lba_tesT yes +*/ +#ifdef Libisofs_lba_tesT + uint32_t lba; +#endif + + *stream= NULL; + ret= Xorriso_get_node_by_path(xorriso, pathname, eff_path, &node, 0); + if(ret<=0) + return(ret); + if(!LIBISO_ISREG(node)) { + sprintf(xorriso->info_text, + "Given path does not lead to a regular data file in the image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + +#ifdef Libisofs_lba_tesT + ret = iso_node_get_old_image_lba(node, &lba, 0); + sprintf(xorriso->info_text, "%s : ret= %d , LBA= %lx", + pathname, ret, (unsigned long) lba); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); +#endif + + filenode= (IsoFile *) node; + iso_stream= iso_file_get_stream(filenode); + if(iso_stream==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Could not obtain source stream of file in the image for reading"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= iso_stream_open(iso_stream); + if(ret<0) { + sprintf(xorriso->info_text, + "Could not open data file in the image for reading"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(!iso_stream_is_repeatable(iso_stream)) { + sprintf(xorriso->info_text, + "The data production of the file in the image is one-time only"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + iso_stream_close(iso_stream); + return(0); + } + Xorriso_process_msg_queues(xorriso,0); + *stream= iso_stream; + return(1); +} + + +int Xorriso_iso_file_read(struct XorrisO *xorriso, void *stream, char *buf, + int count, int flag) +{ + int ret, rcnt= 0; + IsoStream *stream_pt; + + stream_pt= (IsoStream *) stream; + + while(rcnt>> ??? sort list ? */ + for(i= 0; i<*count; i++) { + /* >>> check for disjointness */; + } + + memcpy(total_stbuf, &first_stbuf, sizeof(struct stat)); + total_stbuf->st_size= total_bytes; + ret= 1; +ex:; + if(iter!=NULL) + iso_dir_iter_free(iter); + return(ret); +} + + +int Xorriso_is_split(struct XorrisO *xorriso, IsoNode *node, int flag) +{ + struct SplitparT *split_parts= NULL; + int split_count= 0, ret; + struct stat stbuf; + + ret= Xorriso_identify_split(xorriso, "", (void *) node, &split_parts, + &split_count, &stbuf, 1); + if(split_parts!=NULL) + Splitparts_destroy(&split_parts, split_count, 0); + return(ret>0); +} + diff --git a/libisoburn/branches/ZeroOneFour/xorriso/xorrisoburn.h b/libisoburn/branches/ZeroOneFour/xorriso/xorrisoburn.h new file mode 100644 index 00000000..9a28a4ca --- /dev/null +++ b/libisoburn/branches/ZeroOneFour/xorriso/xorrisoburn.h @@ -0,0 +1,208 @@ + + +/* Adapter to libisoburn, libisofs and libburn for xorriso, + a command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2008 Thomas Schmitt, + + Provided under GPL version 2. + + This file contains the inner isofs- and burn-library interface of xorriso. +*/ + +#ifndef Xorrisoburn_includeD +#define Xorrisoburn_includeD yes + +struct XorrisO; +struct FindjoB; + +/* The minimum version of libisoburn to be used with this version of xorriso +*/ +#define xorriso_libisoburn_req_major 0 +#define xorriso_libisoburn_req_minor 1 +#define xorriso_libisoburn_req_micro 3 + +int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag); + +/* @param flag bit0= global shutdown of libraries */ +int Xorriso_detach_libraries(struct XorrisO *xorriso, int flag); + +int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag); + +/* @param flag bit0=aquire as isoburn input drive + bit1=aquire as libburn output drive (as isoburn drive if bit0) + @return <=0 failure , 1=success , 2=neither readable or writeable +*/ +int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag); + +int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag); + +int Xorriso_write_session(struct XorrisO *xorriso, int flag); + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit0= mkdir: graft in as empty directory, not as copy from disk + bit1= do not report added files + @return <=0 = error , 1 = added simple node , 2 = added directory +*/ +int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter, + char *disk_path, char *img_path, + off_t offset, off_t cut_size, int flag); + +int Xorriso__text_to_sev(char *severity_name, int *severity_number,int flag); + +/* @param flag bit0=report about output drive + bit1=short report form +*/ +int Xorriso_toc(struct XorrisO *xorriso, int flag); + +int Xorriso_show_devices(struct XorrisO *xorriso, int flag); + +int Xorriso_tell_media_space(struct XorrisO *xorriso, + int *media_space, int *free_space, int flag); + +int Xorriso_blank_media(struct XorrisO *xorriso, int flag); + +int Xorriso_format_media(struct XorrisO *xorriso, int flag); + +/* @param boss_iter Opaque internal handle. Use NULL outside xorrisoburn.c : + If not NULL then this is an iterator suitable for + iso_dir_iter_remove() which is then to be used instead + of iso_node_remove(). + @param flag bit0= remove whole sub tree: rm -r + bit1= remove empty directory: rmdir + bit2= recursion: do not reassure in mode 2 "tree" + bit3= this is for overwriting and not for plain removal + @return <=0 = error + 1 = removed simple node + 2 = removed directory or tree + 3 = did not remove on user revocation +*/ +int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, off_t boss_mem, + char *path, int flag); + +/* @param flag bit0= long format + bit1= do not print count of nodes + bit2= du format + bit3= print directories as themselves (ls -d) +*/ +int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd, + int filec, char **filev, off_t boss_mem, int flag); + +/* This function needs less buffer memory than Xorriso_ls_filev() but cannot + perform structured pattern matching. + @param flag bit0= long format + bit1= only check for directory existence + bit2= do not apply search pattern but accept any file + bit3= just count nodes and return number +*/ +int Xorriso_ls(struct XorrisO *xorriso, int flag); + +/* @param wd Path to prepend in case img_path is not absolute + @param img_path Absolute or relative path to be normalized + @param eff_path returns resulting effective path. + Must provide at least SfileadrL bytes of storage. + @param flag bit0= do not produce problem events (unless faulty path format) + bit1= work purely literally, do not use libisofs + bit2= (with bit1) this is an address in the disk world + @return -1 = faulty path format, 0 = not found , + 1 = found simple node , 2 = found directory +*/ +int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, + char *img_path, char eff_path[], int flag); + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world +*/ +int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter, + char *origin, char *dest, int flag); + +/* @param flag bit0= do not produce info message on success + @return 1=success, 0=was already directory, -1=was other type, -2=bad path +*/ +int Xorriso_mkdir(struct XorrisO *xorriso, char *img_path, int flag); + +/* @param flag bit0= a match count !=1 is a SORRY event */ +int Xorriso_expand_pattern(struct XorrisO *xorriso, + int num_patterns, char **patterns, int extra_filec, + int *filec, char ***filev, off_t *mem, int flag); + +int Xorriso_set_st_mode(struct XorrisO *xorriso, char *path, + mode_t mode_and, mode_t mode_or, int flag); + +int Xorriso_set_uid(struct XorrisO *xorriso, char *in_path, uid_t uid, + int flag); + +int Xorriso_set_gid(struct XorrisO *xorriso, char *in_path, gid_t gid, + int flag); + +/* @parm flag bit0= atime, bit1= ctime, bit2= mtime, bit8=no auto ctime */ +int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t, + int flag); + +/* @param flag bit0= recursion + bit1= do not count deleted files with rm and rm_r +*/ +int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, + void *boss_iter, off_t boss_mem, + void *dir_node_generic, char *dir_path, + struct stat *dir_stbuf, int depth, int flag); + +/* @param flag bit0= do not mark image as changed */ +int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag); + +int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag); + +int Xorriso_set_abort_severity(struct XorrisO *xorriso, int flag); + +int Xorriso_report_lib_versions(struct XorrisO *xorriso, int flag); + +/* @return 0= stbuf content is valid , -1 = path not found */ +int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf, + int flag); + +/* @param flag bit0= -inq + bit1= -checkdrive +*/ +int Xorriso_atip(struct XorrisO *xorriso, int flag); + +int Xorriso_burn_track(struct XorrisO *xorriso, char *track_source, int flag); + +/* @param flag bit1= outdev rather than indev + @return <=0 = failure , 1= ok , 2= ok, is CD profile +*/ +int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number, + char profile_name[80], int flag); + +/* @param flag bit0= do not mark image as changed */ +int Xorriso_set_publisher(struct XorrisO *xorriso, char *name, int flag); + + +int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname, + void **stream, int flag); + +int Xorriso_iso_file_read(struct XorrisO *xorriso, void *stream, char *buf, + int count, int flag); + +int Xorriso_iso_file_close(struct XorrisO *xorriso, void **stream, int flag); + +/* @param bit0= copy link target properties rather than link properties +*/ +int Xorriso_copy_properties(struct XorrisO *xorriso, + char *disk_path, char *img_path, int flag); + +int Xorriso_cut_out(struct XorrisO *xorriso, char *disk_path, + off_t startbyte, off_t bytecount, char *iso_rr_path, int flag); + +struct SplitparT; + +/* @param flag bit0= in_node is valid, do not resolve iso_adr +*/ +int Xorriso_identify_split(struct XorrisO *xorriso, char *iso_adr, + void *in_node, + struct SplitparT **parts, int *count, + struct stat *total_stbuf, int flag); + +#endif /* Xorrisoburn_includeD */ +