230 lines
7.0 KiB
C
230 lines
7.0 KiB
C
|
|
/*
|
|
|
|
( cd .. ; libisoburn-develop/xorriso/compile_xorriso.sh -g )
|
|
|
|
*/
|
|
|
|
/* Command line oriented batch and dialog tool which creates, loads,
|
|
manipulates and burns ISO 9660 filesystem images.
|
|
|
|
Copyright 2007-2010 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 or later, with the announcement that this
|
|
might get changed in future. I would prefer BSD or LGPL as soon as the
|
|
license situation of the library code allows that.
|
|
(This announcement affects only future releases of xorriso and it will
|
|
always be possible to derive a GPLv2+ from the future license.)
|
|
|
|
There is a derived package "GNU xorriso" under GPLv3+ which combines the
|
|
libburnia libraries and program xorriso to a statically linked binary.
|
|
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
The source is divided in two groups:
|
|
|
|
A set of source modules interacts with the libraries:
|
|
base_obj.[ch] fundamental operations of the XorrisO object
|
|
lib_mgt.[ch] manages the relation between xorriso and the libraries
|
|
drive_mgt.[ch] operates on drives and media
|
|
iso_img.[ch] operates on ISO images and their global properties
|
|
iso_tree.[ch] access nodes of the libisofs tree model
|
|
iso_manip.[ch] manipulates the libisofs tree model
|
|
sort_cmp.[ch] sorts and compare tree nodes
|
|
write_run.[ch] functions to write sessions
|
|
read_run.[ch] functions to read data from ISO image
|
|
filters.[ch] operates on data filter objects
|
|
xorrisoburn.h declarations needed by the non-library modules
|
|
|
|
Another set is independent of the liburnia libraries:
|
|
parse_exec.c deals with parsing and interpretation of command input
|
|
sfile.c functions around files and strings
|
|
aux_objects.c various helper classes
|
|
misc_funct.c miscellaneous helper functions
|
|
findjob.c performs tree searches in libisofs or in POSIX filesystem
|
|
check_media.c perform verifying runs on media resp. images
|
|
text_io.c text i/o functions
|
|
match.c functions for pattern matching
|
|
emulators.c emulators for mkisofs and cdrecord
|
|
disk_ops.c actions on onjects of disk filesystems
|
|
cmp_update.c compare or update files between disk filesystem and
|
|
ISO filesystem
|
|
opts_a_c.c options -a* to -c*
|
|
opts_d_h.c options -d* to -h*
|
|
opts_i_o.c options -i* to -o*
|
|
opts_p_z.c options -p* to -z*
|
|
|
|
xorriso_main.c the main program
|
|
|
|
xorriso_private.h contains the definition of struct Xorriso and for
|
|
convenience includes the .h files of the non-library group.
|
|
|
|
*/
|
|
|
|
/* This may be changed to Xorriso_GNU_xorrisO in order to create GNU xorriso */
|
|
#define Xorriso_libburnia_xorrisO yes
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include <locale.h>
|
|
|
|
/* The official xorriso options API. "No shortcuts" */
|
|
#include "xorriso.h"
|
|
|
|
|
|
|
|
#ifdef Xorriso_without_subS
|
|
|
|
/* xorriso consists only of a main() stub which has an own version to match
|
|
the version of libxorriso header and runtime code.
|
|
*/
|
|
#define Xorriso_main_program_versioN "0.5.7"
|
|
|
|
#else /* Xorriso_without_subS */
|
|
|
|
/* Make sure that both version tests always match. */
|
|
#define Xorriso_main_program_versioN Xorriso_program_versioN
|
|
|
|
#endif /* ! Xorriso_without_subS */
|
|
|
|
|
|
static void yell_xorriso()
|
|
{
|
|
fprintf(stderr,
|
|
"%sxorriso %s%s : RockRidge filesystem manipulator, libburnia project.\n\n",
|
|
#ifdef Xorriso_GNU_xorrisO
|
|
"GNU ",
|
|
#else
|
|
"",
|
|
#endif
|
|
Xorriso_main_program_versioN, Xorriso_program_patch_leveL);
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int ret, i;
|
|
struct XorrisO *xorriso= NULL;
|
|
char **orig_argv= NULL;
|
|
|
|
if(strcmp(Xorriso_main_program_versioN, Xorriso_program_versioN)) {
|
|
yell_xorriso();
|
|
fprintf(stderr,
|
|
"xorriso : FATAL : libxorriso compile time version mismatch. Found %s\n\n",
|
|
Xorriso_program_versioN);
|
|
exit(4);
|
|
}
|
|
if(strcmp(Xorriso_program_versioN, Xorriso__get_version_text(0))) {
|
|
yell_xorriso();
|
|
fprintf(stderr,
|
|
"xorriso : FATAL : libxorriso runtime version mismatch. Found %s\n\n",
|
|
Xorriso__get_version_text(0));
|
|
exit(4);
|
|
}
|
|
|
|
if(argc < 2) {
|
|
yell_xorriso();
|
|
fprintf(stderr,"usage : %s [options]\n", argv[0]);
|
|
fprintf(stderr, " More is told by option -help\n");
|
|
exit(2);
|
|
}
|
|
setlocale(LC_CTYPE, "");
|
|
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);
|
|
|
|
yell_xorriso();
|
|
|
|
/* The following functions are allowed only after this initialization */
|
|
ret= Xorriso_startup_libraries(xorriso, 0);
|
|
if(ret <= 0)
|
|
{ret= 4; goto emergency_exit;}
|
|
Xorriso_process_msg_queues(xorriso, 0);
|
|
|
|
/* Interpret startup files */
|
|
ret= Xorriso_read_rc(xorriso, 0);
|
|
if(ret == 3)
|
|
goto end_sucessfully;
|
|
if(ret <= 0)
|
|
{ret= 5; goto emergency_exit;}
|
|
|
|
/* Interpret program arguments */
|
|
orig_argv= argv;
|
|
ret= Xorriso_program_arg_bsl(xorriso, argc, &argv, 0);
|
|
if(ret <= 0)
|
|
{ret= 5; goto emergency_exit;}
|
|
i= 1;
|
|
ret= Xorriso_interpreter(xorriso, argc, argv, &i, 2);
|
|
if(ret == 3)
|
|
goto end_sucessfully;
|
|
if(ret <= 0)
|
|
{ret= 5; goto emergency_exit;}
|
|
|
|
/* Enter dialog mode if it has been activated meanwhile */
|
|
ret= Xorriso_dialog(xorriso, 0);
|
|
if(ret <= 0)
|
|
{ret= 6; goto emergency_exit;}
|
|
|
|
end_sucessfully:; /* normal shutdown, including eventual -commit */
|
|
Xorriso_process_msg_queues(xorriso, 0);
|
|
if(Xorriso_change_is_pending(xorriso, 0))
|
|
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);
|
|
if(orig_argv != argv && orig_argv != NULL) {
|
|
for(i= 0; i < argc; i++)
|
|
if(argv[i] != NULL)
|
|
free(argv[i]);
|
|
free(argv);
|
|
}
|
|
exit(ret);
|
|
|
|
emergency_exit:;
|
|
if(xorriso != NULL) { /* minimal shutdown */
|
|
Xorriso_process_msg_queues(xorriso, 0);
|
|
Xorriso_destroy(&xorriso, 1);
|
|
}
|
|
exit(ret);
|
|
}
|
|
|
|
|