From 67fba52fb2dad4ed691eba32a960ed12c1300e74 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 17 Oct 2007 13:02:32 +0000 Subject: [PATCH] Worked on failure severities, message system, program abort decision --- test/xorrisoburn.c | 107 +++++++++++++++++++++++++++------------------ 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/test/xorrisoburn.c b/test/xorrisoburn.c index b3c2e01a..bf3d5411 100644 --- a/test/xorrisoburn.c +++ b/test/xorrisoburn.c @@ -49,6 +49,7 @@ int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag) { int ret; char *handler_prefix= NULL; + char *queue_sev, *print_sev; sprintf(xorriso->info_text, "Starting up libraries ...\n"); Xorriso_info(xorriso, 0); @@ -62,19 +63,24 @@ int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag) } ret= isoburn_initialize(); if(ret==0) { - - /* >>> fetch all messages from library message queue first */ - + Xorriso_process_msg_queues(xorriso,0); 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 : "); + queue_sev= "DEBUG"; + if(xorriso->library_msg_direct_print) { + + /* >>> need option for controlling this in XorrisO. + See also Xorriso_msgs_submit */; + + print_sev= "DEBUG"; + } else + print_sev= "NEVER"; + iso_msgs_set_severities(queue_sev, print_sev, "libisofs : "); + burn_msgs_set_severities(queue_sev, print_sev, "libburn : "); /* ??? >>> do we want united queues ? */ /* burn_set_messenger(iso_get_messenger()); */ @@ -82,6 +88,7 @@ int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag) sprintf(handler_prefix, "%s : ", xorriso->progname); burn_set_signal_handling(handler_prefix, NULL, 0); + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Library startup done.\n"); Xorriso_info(xorriso, 0); free(handler_prefix); @@ -113,10 +120,8 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) return(ret); ret= isoburn_drive_scan_and_grab(&dinfo, adr, 1); + Xorriso_process_msg_queues(xorriso,0); if(ret<=0) { - - /* >>> 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); @@ -132,7 +137,8 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) /* check for invalid state */ state= isoburn_disc_get_status(drive); - + Xorriso_process_msg_queues(xorriso,0); + /* >>> show drive and media status */; if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) { @@ -149,9 +155,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) ropts.mode= 0555; if(isoburn_read_volset(drive, &ropts, &volset) <= 0) { - - /* >>> fetch all messages from library message queue first */ - + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text,"Caninot read ISO image volset"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); ret= 0; goto ex; @@ -164,6 +168,7 @@ ex: /* >>> ??? give up not-so-suitable drive ? */; } + Xorriso_process_msg_queues(xorriso,0); return(ret); } @@ -204,6 +209,7 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag) xorriso->out_drive_handle= NULL; } + Xorriso_process_msg_queues(xorriso,0); return(1); } @@ -248,9 +254,7 @@ int Xorriso_write_growing(struct XorrisO *xorriso, int flag) /* >>> -fs : isoburn_prepare_disc() needs fifo parameters */ if (isoburn_prepare_disc(drive, &disc, &sopts) <= 0) { - - /* >>> fetch all messages from library message queue first */ - + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text,"Cannot prepare disc"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); @@ -258,9 +262,7 @@ int Xorriso_write_growing(struct XorrisO *xorriso, int flag) burn_options= burn_write_opts_new(drive); if(burn_options==NULL) { - - /* >>> fetch all messages from library message queue first */ - + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text,"Cannot allocate option set"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); @@ -278,13 +280,17 @@ int Xorriso_write_growing(struct XorrisO *xorriso, int flag) return(ret); ret= isoburn_activate_session(drive); + Xorriso_process_msg_queues(xorriso,0); if(ret<=0) { - fprintf(stderr, "--- Could not write new set olf volume descriptors\n"); + sprintf(xorriso->info_text, + "Could not write new set of volume descriptors"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); return(ret); } /* >>> cleanup disc ? */ + Xorriso_process_msg_queues(xorriso,0); return(1); } @@ -311,9 +317,7 @@ int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); for(i= 0; i<10; i++) { - - /* >>> check message system of libburn */; - + Xorriso_process_msg_queues(xorriso, 0); usleep(100000); } } @@ -333,9 +337,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, struct stat stbuf; if(xorriso->in_volset_handle==NULL) { - - /* >>> fetch all messages from library message queue first */ - + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text,"No volset is loaded."); if(xorriso->indev[0]==0) sprintf(xorriso->info_text," No -dev or -indev is selected."); @@ -353,9 +355,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, (struct iso_volset *) xorriso->in_volset_handle, 0); if(lstat(disk_path, &stbuf) == -1) { - - /* >>> fetch all messages from library message queue first */ - + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Cannot determine attributes of source file '%s'",disk_path); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0); @@ -364,9 +364,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, if(S_ISDIR(stbuf.st_mode)) is_dir= 1; else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) { - - /* >>> fetch all messages from library message queue first */ - + Xorriso_process_msg_queues(xorriso,0); 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); @@ -386,9 +384,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, dir= iso_volume_get_root(volume); if(dir==NULL) { - - /* >>> fetch all messages from library message queue first */ - + 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); @@ -411,13 +407,13 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, node= iso_tree_volume_path_to_node(volume,path); if(node!=NULL) { if(iso_tree_node_get_type(node)!=LIBISO_NODE_DIR) { + Xorriso_process_msg_queues(xorriso,0); if(done) { /* >>> handle overwrite situation */; } - sprintf(xorriso->info_text, "While grafting '%s' : '%s' exists and is not a directory", img_path, path); @@ -428,9 +424,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, } else if(is_dir || !done) { dir= iso_tree_add_dir(dir, apt); if(dir==NULL) { - - /* >>> fetch all messages from library message queue first */ - + Xorriso_process_msg_queues(xorriso,0); 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); @@ -444,9 +438,7 @@ attach_source:; } else { node= iso_tree_add_node(dir, disk_path); if(node == NULL) { - - /* >>> fetch all messages from library message queue first */ - + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "While grafting '%s'='%s' : libisofs_errno = %d", img_path, disk_path, libisofs_errno); @@ -458,6 +450,7 @@ attach_source:; } else *npt= '/'; } + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Added %s '%s'='%s'", (is_dir ? "directory" : "node"), img_path, disk_path); @@ -479,3 +472,31 @@ int Xorriso__text_to_sev(char *severity_name, int *severity_number, int flag) } +int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag) +{ + int ret, error_code= 0, os_errno= 0, count= 0, pass; + char severity[80]; + + for(pass= 0; pass< 2; pass++) { + while(1) { + if(pass==0) + ret= iso_msgs_obtain("ALL", &error_code, xorriso->info_text, &os_errno, + severity); + else + ret= burn_msgs_obtain("ALL", &error_code, xorriso->info_text, &os_errno, + severity); + if(ret<=0) + break; + Xorriso_msgs_submit(xorriso, error_code, xorriso->info_text, os_errno, + severity, 0); + 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); +} +