Adapted version checking to new library situation

This commit is contained in:
2010-05-21 13:37:25 +00:00
parent d3f770827f
commit bcc6a38094
6 changed files with 219 additions and 78 deletions

View File

@ -1,11 +1,5 @@
/*
( cd .. ; libisoburn-develop/xorriso/compile_xorriso.sh -g )
*/
/* Command line oriented batch and dialog tool which creates, loads,
/* xorriso - 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>
@ -30,19 +24,27 @@
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.
libisoburn by its lower level API encapsulates the connectivity issues
between libburn and libisofs. This API also enables multi-session emulation
on overwritable media and random access file objects.
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 is the higher level API of libisoburn which allows to operate all
three libraries by a unified set of commands.
xorriso.h exposes the public functions.
Among these functions are direct equivalents of the xorriso interpreter
commands. There are also functions for fundamental management and for
handling event messages.
The source is divided in two groups:
This file xorriso_main.c runs the xorriso API as batch and dialog program.
One should not mix the use of the xorriso API with the use of the lower
level APIs of libburn, libisofs, libisoburn.
The xorriso 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
@ -56,6 +58,7 @@
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
@ -73,8 +76,6 @@
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.
@ -99,31 +100,99 @@
#include "xorriso.h"
#ifdef Xorriso_standalonE
/* Make sure that both version tests always match. */
#define Xorriso_main_program_versioN Xorriso_program_versioN
#else /* Xorriso_standalonE */
/* xorriso consists only of a main() stub which has an own version to match
the version of libxorriso header and runtime code.
/* The minimum version of libisoburn to be used with this version of xorriso
*/
#define Xorriso_main_program_versioN "0.5.7"
#endif /* ! Xorriso_without_subS */
#define Xorriso_req_majoR 0
#define Xorriso_req_minoR 5
#define Xorriso_req_micrO 7
static void yell_xorriso()
{
fprintf(stderr,
"%sxorriso %s%s : RockRidge filesystem manipulator, libburnia project.\n\n",
"%sxorriso %d.%d.%d%s : RockRidge filesystem manipulator, libburnia project.\n\n",
#ifdef Xorriso_GNU_xorrisO
"GNU ",
#else
"",
#endif
Xorriso_main_program_versioN, Xorriso_program_patch_leveL);
Xorriso_header_version_majoR, Xorriso_header_version_minoR,
Xorriso_header_version_micrO, Xorriso_program_patch_leveL);
}
/* Check whether build configuration and runtime linking are consistent.
*/
static void check_compatibility()
{
int lib_major, lib_minor, lib_micro;
/* 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 above
Xorriso_req_majoR
Xorriso_req_minoR
Xorriso_req_micrO
It gets compared against the version macros in xorriso.h :
Xorriso_header_version_majoR
Xorriso_header_version_minoR
Xorriso_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: 'XORRISO_MISCONFIGURATION' undeclared (first use in this function)
error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_xorriso_dot_h_TOO_OLD__SEE_xorriso_main_dot_c' undeclared (first use in this function)
error: 'XORRISO_MISCONFIGURATION_' undeclared (first use in this function)
*/
/* The indendation is an advise of man gcc to help old compilers ignoring */
#if Xorriso_req_majoR > Xorriso_header_version_majoR
#define Xorriso_dot_h_too_olD 1
#endif
#if Xorriso_req_majoR == Xorriso_header_version_majoR && Xorriso_req_minoR > Xorriso_header_version_minoR
#define Xorriso_dot_h_too_olD 1
#endif
#if Xorriso_req_minoR == Xorriso_header_version_minoR && Xorriso_req_micrO > Xorriso_header_version_micrO
#define Xorriso_dot_h_too_olD 1
#endif
#ifdef Xorriso_dot_h_too_olD
XORRISO_MISCONFIGURATION = 0;
INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_xorriso_dot_h_TOO_OLD__SEE_xorriso_main_dot_c = 0;
XORRISO_MISCONFIGURATION_ = 0;
#endif
/* End of ugly compile time test (scroll up for explanation) */
/* Needed are at least 44 bits in signed type off_t .
This is a popular mistake in configuration or compilation.
*/
if(sizeof(off_t) < 6) {
yell_xorriso();
fprintf(stderr,
"xorriso : FATAL : Compile time misconfiguration. sizeof(off_t) too small.\n\n");
exit(4);
}
/* Check whether the linked xorriso code is young enough.
*/
if(! Xorriso__is_compatible(Xorriso_header_version_majoR,
Xorriso_header_version_minoR,
Xorriso_header_version_micrO, 0)) {
yell_xorriso();
Xorriso__version(&lib_major, &lib_minor, &lib_micro);
fprintf(stderr,
"xorriso : FATAL : libisoburn/xorriso runtime version mismatch. Found %d.%d.%d, need %d.%d.%d\n\n",
lib_major, lib_minor, lib_micro,
Xorriso_header_version_majoR, Xorriso_header_version_minoR,
Xorriso_header_version_micrO);
exit(4);
}
}
@ -133,26 +202,7 @@ int main(int argc, char **argv)
struct XorrisO *xorriso= NULL;
char **orig_argv= NULL;
if(sizeof(off_t) < 8) {
yell_xorriso();
fprintf(stderr,
"xorriso : FATAL : Compile time misconfiguration. sizeof(off_t) too small.\n\n");
exit(4);
}
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);
}
check_compatibility(); /* might exit() */
if(argc < 2) {
yell_xorriso();
@ -178,7 +228,9 @@ int main(int argc, char **argv)
yell_xorriso();
/* The following functions are allowed only after this initialization */
/* The following command interpreters are allowed only after this
initialization.
*/
ret= Xorriso_startup_libraries(xorriso, 0);
if(ret <= 0)
{ret= 4; goto emergency_exit;}