Worked on failure severities, message system, program abort decision
This commit is contained in:
@ -32,6 +32,9 @@
|
||||
capabilities via the method invented by Andy Polyakov for growisofs */
|
||||
#include <libisoburn/libisoburn.h>
|
||||
|
||||
/* The official xorriso options API. "No shortcuts" */
|
||||
#include "xorriso.h"
|
||||
|
||||
/* The inner description of XorrisO */
|
||||
#include "xorriso_private.h"
|
||||
|
||||
@ -47,33 +50,40 @@ 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");
|
||||
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) {
|
||||
|
||||
/* >>> rather send this to msg system of xorriso */;
|
||||
fprintf(stderr, "--- Cannot allocate memory for initializing libraries\n");
|
||||
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot allocate memory for initializing libraries");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
||||
return(-1);
|
||||
}
|
||||
ret= isoburn_initialize();
|
||||
if(ret==0) {
|
||||
|
||||
/* >>> rather send this to msg system of xorriso */;
|
||||
fprintf(stderr, "--- Cannot initialize libraries\n");
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text, "Cannot initialize libraries");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
||||
free(handler_prefix);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* >>> need option for controlling this in XorrisO */
|
||||
/* >>> change from printing to queuing */
|
||||
iso_msgs_set_severities("NEVER", "DEBUG", "libisofs : ");
|
||||
burn_msgs_set_severities("NEVER", "DEBUG", "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);
|
||||
|
||||
fprintf(stderr,"Library startup done.\n");
|
||||
sprintf(xorriso->info_text, "Library startup done.\n");
|
||||
Xorriso_info(xorriso, 0);
|
||||
free(handler_prefix);
|
||||
return(1);
|
||||
}
|
||||
@ -93,7 +103,9 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
|
||||
|
||||
|
||||
if((flag&3)!=3) {
|
||||
fprintf(stderr,">>> XORRISOBURN: Xorriso_aquire_drive bit0+bit1 not set\n");
|
||||
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(0);
|
||||
}
|
||||
ret= Xorriso_give_up_drive(xorriso, flag&3);
|
||||
@ -102,7 +114,11 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
|
||||
|
||||
ret= isoburn_drive_scan_and_grab(&dinfo, adr, 1);
|
||||
if(ret<=0) {
|
||||
fprintf(stderr,"--- Cannot aquire drive '%s'\n", adr);
|
||||
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text,"Cannot aquire drive '%s'", adr);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
if(flag&2)
|
||||
@ -120,10 +136,8 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
|
||||
/* >>> show drive and media status */;
|
||||
|
||||
if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) {
|
||||
|
||||
/* >>> rather send this to msg system of xorriso */;
|
||||
fprintf(stderr, "Unsuitable disc status\n");
|
||||
|
||||
sprintf(xorriso->info_text, "Unsuitable disc status");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
/* fill read opts */
|
||||
@ -136,9 +150,10 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
|
||||
|
||||
if(isoburn_read_volset(drive, &ropts, &volset) <= 0) {
|
||||
|
||||
/* >>> rather send this to msg system of xorriso */;
|
||||
fprintf(stderr, "Can't read volset\n");
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text,"Caninot read ISO image volset");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
xorriso->in_volset_handle= volset;
|
||||
@ -204,10 +219,8 @@ int Xorriso_write_growing(struct XorrisO *xorriso, int flag)
|
||||
|
||||
dinfo= (struct burn_drive_info *) xorriso->in_drive_handle;
|
||||
if(dinfo==NULL) {
|
||||
|
||||
/* >>> */
|
||||
fprintf(stderr, "--- No drive aquired\n");
|
||||
|
||||
sprintf(xorriso->info_text,"No drive aquired on attempt to write");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
drive= dinfo[0].drive;
|
||||
@ -236,18 +249,20 @@ int Xorriso_write_growing(struct XorrisO *xorriso, int flag)
|
||||
|
||||
if (isoburn_prepare_disc(drive, &disc, &sopts) <= 0) {
|
||||
|
||||
/* >>> */
|
||||
fprintf(stderr, "--- Cannot prepare disc\n");
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text,"Cannot prepare disc");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
burn_options= burn_write_opts_new(drive);
|
||||
if(burn_options==NULL) {
|
||||
|
||||
/* >>> */
|
||||
fprintf(stderr, "--- Cannot allocate option set\n");
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text,"Cannot allocate option set");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
burn_write_opts_set_simulate(burn_options, !!xorriso->do_dummy);
|
||||
@ -286,16 +301,14 @@ int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
|
||||
usleep(100002);
|
||||
|
||||
while(burn_drive_get_status(drive, &progress) != BURN_DRIVE_IDLE) {
|
||||
|
||||
/* >>> make this output go into xorriso info channel */;
|
||||
|
||||
printf("Writing: sector %d of %d",
|
||||
sprintf(xorriso->info_text, "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,
|
||||
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
||||
" [fifo %s, %2d%% fill]", status_text,
|
||||
(int) (100.0-100.0*((double) free_bytes)/(double) size));
|
||||
printf("\n");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
|
||||
|
||||
for(i= 0; i<10; i++) {
|
||||
|
||||
@ -321,14 +334,16 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
|
||||
|
||||
if(xorriso->in_volset_handle==NULL) {
|
||||
|
||||
/* >>> */
|
||||
fprintf(stderr, "--- No volset is loaded.\n");
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text,"No volset is loaded.");
|
||||
if(xorriso->indev[0]==0)
|
||||
fprintf(stderr, "--- No -dev or -indev is selected.\n");
|
||||
sprintf(xorriso->info_text," No -dev or -indev is selected.");
|
||||
else
|
||||
fprintf(stderr, "--- Possible program error with drive '%s'\n",
|
||||
sprintf(xorriso->info_text," Possible program error with drive '%s'.",
|
||||
xorriso->indev);
|
||||
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
strncpy(path, img_path, sizeof(path)-1);
|
||||
@ -339,20 +354,22 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_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);
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot determine attributes of source file '%s'",disk_path);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0);
|
||||
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);
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text,
|
||||
"Source file '%s' is of non-supported file type", disk_path);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
} else {
|
||||
l= strlen(img_path);
|
||||
@ -360,22 +377,21 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
|
||||
if(img_path[l-1]=='/')
|
||||
l= 0;
|
||||
if(l==0) {
|
||||
|
||||
/* >>> */
|
||||
fprintf(stderr,
|
||||
"--- Source '%s' is not a directory. Target '%s' would be.\n",
|
||||
sprintf(xorriso->info_text,
|
||||
"Source '%s' is not a directory. Target '%s' would be.",
|
||||
disk_path, img_path);
|
||||
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
}
|
||||
}
|
||||
|
||||
dir= iso_volume_get_root(volume);
|
||||
if(dir==NULL) {
|
||||
|
||||
/* >>> */
|
||||
fprintf(stderr, "--- While grafting '%s' : no root node available\n",
|
||||
img_path);
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
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) {
|
||||
@ -402,11 +418,10 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
|
||||
|
||||
}
|
||||
|
||||
/* >>> */
|
||||
fprintf(stderr,
|
||||
"--- While grafting '%s' : '%s' exists and is not a directory\n",
|
||||
sprintf(xorriso->info_text,
|
||||
"While grafting '%s' : '%s' exists and is not a directory",
|
||||
img_path, path);
|
||||
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
dir= (struct iso_tree_node_dir *) node;
|
||||
@ -414,10 +429,11 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
|
||||
dir= iso_tree_add_dir(dir, apt);
|
||||
if(dir==NULL) {
|
||||
|
||||
/* >>> */
|
||||
fprintf(stderr, "--- While grafting '%s' : could not insert '%s'\n",
|
||||
img_path, path);
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text,
|
||||
"While grafting '%s' : could not insert '%s'", img_path, path);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
@ -429,10 +445,12 @@ attach_source:;
|
||||
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);
|
||||
/* >>> fetch all messages from library message queue first */
|
||||
|
||||
sprintf(xorriso->info_text,
|
||||
"While grafting '%s'='%s' : libisofs_errno = %d",
|
||||
img_path, disk_path, libisofs_errno);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
iso_tree_node_set_name(node, apt);
|
||||
@ -440,10 +458,24 @@ attach_source:;
|
||||
} else
|
||||
*npt= '/';
|
||||
}
|
||||
fprintf(stderr, "NOTE: added %s '%s'='%s'\n", (is_dir ? "directory" : "node"),
|
||||
img_path, disk_path);
|
||||
sprintf(xorriso->info_text,
|
||||
"Added %s '%s'='%s'", (is_dir ? "directory" : "node"),
|
||||
img_path, disk_path);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
xorriso->volset_change_pending= 1;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso__text_to_sev(char *severity_name, int *severity_number, int flag)
|
||||
{
|
||||
int ret= 1;
|
||||
|
||||
if(severity_name[0]==0)
|
||||
*severity_number= 0;
|
||||
else
|
||||
ret= burn_text_to_sev(severity_name, severity_number, 0);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user