Began to implement interface to our libraries

This commit is contained in:
Thomas Schmitt 2007-10-14 12:20:56 +00:00
parent 17112a88f1
commit f890e06e48
5 changed files with 298 additions and 152 deletions

View File

@ -9,7 +9,8 @@ or
cc -g -DXorriso_with_maiN -DXorriso_with_regeX -DXorriso_with_readlinE \ cc -g -DXorriso_with_maiN -DXorriso_with_regeX -DXorriso_with_readlinE \
-Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-o test/xorriso test/xorriso.c \ -o test/xorriso \
test/xorriso.c test/xorrisoburn.c \
-lpthread -lreadline -lburn -lisofs -lisoburn -lpthread -lreadline -lburn -lisofs -lisoburn
*/ */
@ -61,9 +62,7 @@ or
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
#ifdef Xorriso_with_regeX /* eventually, this is done in xorriso_private.h : #include <regex.h> */
#include <regex.h>
#endif /* Xorriso_with_regeX */
#ifdef Xorriso_with_readlinE #ifdef Xorriso_with_readlinE
#ifdef Xorriso_with_old_readlinE #ifdef Xorriso_with_old_readlinE
@ -89,30 +88,20 @@ or
#define AlN(x) #define AlN(x)
#endif #endif
#define Smem_malloC malloc
#define Smem_freE free
#define SfileadrL 4096
/* <<< ??? */
typedef int (*Cleanup_app_handler_T)();
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* The library which does the ISO 9660 / RockRidge manipulations */
#include <libisofs/libisofs.h>
/* The library which does MMC optical drive operations */
#include <libburn/libburn.h>
/* The library which enhances overwriteable media with ISO 9660 multi-session
capabilities via the method invented by Andy Polyakov for growisofs */
#include <libisoburn/libisoburn.h>
/* The official xorriso options API. "No shortcuts" */ /* The official xorriso options API. "No shortcuts" */
#include "xorriso.h" #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"
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -1663,13 +1652,6 @@ return:
/* ------------------------------- Xorriso -------------------------------- */ /* ------------------------------- Xorriso -------------------------------- */
/* 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 */ /** The list of startup file names */
#define Xorriso_rc_nuM 4 #define Xorriso_rc_nuM 4
@ -1680,127 +1662,6 @@ static char Xorriso_sys_rc_nameS[Xorriso_rc_nuM][80]= {
"placeholder for $HOME/.xorrisorc" "placeholder for $HOME/.xorrisorc"
}; };
struct XorrisO { /* the global context of askme */
/* 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;
/* >>> put libisofs aspects here <<< */
int do_joliet;
int do_follow_links;
int do_global_uid;
uid_t global_uid;
int do_global_gid;
gid_t global_gid;
int do_overwrite;
int do_reassure;
char volid[SfileadrL];
/* >>> put libburn/isoburn aspects here */
char indev[SfileadrL];
char outdev[SfileadrL];
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 */
/* XORRISO options */
int allow_graft_points;
int dialog;
/* ??? does this search stuff make sense ? */
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 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 */
/* >>> put -abort_on severity parameters here <<< */
char abort_on_severity[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];
/* >>> put overwrite_mode here */
/* run state */
int is_dialog;
int bar_is_fresh;
char pending_option[SfileadrL]; /* eventual option entered at page prompt */
int request_to_abort;
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 */
/* <<< ??? 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_destroy(struct XorrisO **xorriso, int flag);
int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag);
int Xorriso_info(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);
int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
{ {
int i; int i;
@ -3300,11 +3161,23 @@ int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path,
/** @param flag bit0=use as indev , bit1= use as outdev */ /** @param flag bit0=use as indev , bit1= use as outdev */
int Xorriso_option_dev(struct XorrisO *xorriso, char *adr, int flag) int Xorriso_option_dev(struct XorrisO *xorriso, char *adr, int flag)
{ {
int ret;
if(xorriso->indev[0]==0 && xorriso->outdev==0) {
ret= Xorriso_startup_libraries(xorriso, 0);
if(ret<=0)
return(ret);
}
if((flag&3)==0) if((flag&3)==0)
flag|= 3; flag|= 3;
else {
/* <<< for now only -dev */;
fprintf(stderr, ">>> XORRISO : would execute -%sdev %s\n", fprintf(stderr, ">>> XORRISO : would execute -%sdev %s\n",
((flag&3)==1 ? "in" : ((flag&3)==2 ? "out" : "")), adr); ((flag&3)==1 ? "in" : ((flag&3)==2 ? "out" : "")), adr);
}
fprintf(stderr, ">>> XORRISO : would execute -dev %s\n", adr);
return(1); return(1);
} }

169
test/xorriso_private.h Normal file
View File

@ -0,0 +1,169 @@
/* Command line oriented batch and dialog tool which creates, loads,
manipulates and burns ISO 9660 filesystem images.
Copyright 2007 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2.
This file contains the inner description of xorriso.
*/
/* 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
/* Because regex_t is mentioned in struct XorrisO */
#ifdef Xorriso_with_regeX
#include <regex.h>
#endif /* Xorriso_with_regeX */
#define Smem_malloC malloc
#define Smem_freE free
#define SfileadrL 4096
/* <<< ??? */
typedef int (*Cleanup_app_handler_T)();
/* 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 */
/* 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;
/* >>> put libisofs aspects here <<< */
int do_joliet;
int do_follow_links;
int do_global_uid;
uid_t global_uid;
int do_global_gid;
gid_t global_gid;
int do_overwrite;
int do_reassure;
char volid[SfileadrL];
/* >>> put libburn/isoburn aspects here */
char indev[SfileadrL];
char outdev[SfileadrL];
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 */
/* XORRISO options */
int allow_graft_points;
int dialog;
/* ??? does this search stuff make sense ? */
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 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 */
/* >>> put -abort_on severity parameters here <<< */
char abort_on_severity[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];
/* >>> put overwrite_mode here */
/* run state */
int is_dialog;
int bar_is_fresh;
char pending_option[SfileadrL]; /* eventual option entered at page prompt */
int request_to_abort;
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 */
/* <<< ??? 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_destroy(struct XorrisO **xorriso, int flag);
int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag);
int Xorriso_info(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);
#endif /* Xorriso_private_includeD */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.10.14.110003" #define Xorriso_timestamP "2007.10.14.122456"

81
test/xorrisoburn.c Normal file
View File

@ -0,0 +1,81 @@
/* 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 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2.
*/
#include <ctype.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
/* ------------------------------------------------------------------------ */
/* The library which does the ISO 9660 / RockRidge manipulations */
#include <libisofs/libisofs.h>
/* The library which does MMC optical drive operations */
#include <libburn/libburn.h>
/* The library which enhances overwriteable media with ISO 9660 multi-session
capabilities via the method invented by Andy Polyakov for growisofs */
#include <libisoburn/libisoburn.h>
/* The inner description of XorrisO */
#include "xorriso_private.h"
/* The inner isofs- and burn-library interface */
#include "xorrisoburn.h"
/* ------------------------------------------------------------------------ */
int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag)
{
int ret;
char *handler_prefix= NULL;
/* >>> rather send this to msg system of xorriso */;
fprintf(stderr, "starting up libraries ...\n");
handler_prefix= calloc(strlen(xorriso->progname)+3+1, 1);
if(handler_prefix==NULL) {
/* >>> rather send this to msg system of xorriso */;
fprintf(stderr, "--- Cannot allocate memory for initializing libraries\n");
return(-1);
}
ret= isoburn_initialize();
if(ret==0) {
/* >>> rather send this to msg system of xorriso */;
fprintf(stderr, "--- Cannot initialize libraries\n");
free(handler_prefix);
return(0);
}
/* >>> need option for controlling this in XorrisO */
iso_msgs_set_severities("NEVER", "DEBUG", "libisofs : ");
burn_msgs_set_severities("NEVER", "DEBUG", "libburn : ");
sprintf(handler_prefix, "%s : ", xorriso->progname);
burn_set_signal_handling("%s : ", NULL, 0);
fprintf(stderr,"Library startup done.\n");
free(handler_prefix);
return(1);
}

23
test/xorrisoburn.h Normal file
View File

@ -0,0 +1,23 @@
/* 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 Thomas Schmitt, <scdbackup@gmx.net>
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;
int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag);
#endif /* Xorrisoburn_includeD */