Replaced some large local variables by other means in xorriso/write_run.c

This commit is contained in:
Thomas Schmitt 2011-05-08 08:39:01 +00:00
parent 76bf672c86
commit f5ceb22dea
2 changed files with 49 additions and 30 deletions

View File

@ -390,7 +390,7 @@ ex:;
int Xorriso_attach_boot_image(struct XorrisO *xorriso, int flag) int Xorriso_attach_boot_image(struct XorrisO *xorriso, int flag)
{ {
int ret; int ret;
char sfe[5*SfileadrL], *cpt; char *cpt;
struct burn_drive_info *source_dinfo; struct burn_drive_info *source_dinfo;
struct burn_drive *source_drive; struct burn_drive *source_drive;
IsoImage *image= NULL; IsoImage *image= NULL;
@ -447,8 +447,8 @@ int Xorriso_attach_boot_image(struct XorrisO *xorriso, int flag)
load_size= ((stbuf.st_size / (off_t) 512) + load_size= ((stbuf.st_size / (off_t) 512) +
!!(stbuf.st_size % (off_t) 512)) * 512; !!(stbuf.st_size % (off_t) 512)) * 512;
} }
sprintf(xorriso->info_text, "Adding boot image %s", sprintf(xorriso->info_text, "Adding boot image ");
Text_shellsafe(bin_path, sfe, 0)); Text_shellsafe(bin_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
if(emul == 0) if(emul == 0)
@ -461,8 +461,8 @@ int Xorriso_attach_boot_image(struct XorrisO *xorriso, int flag)
ret= Xorriso_node_from_path(xorriso, image, bin_path, &node, 1); ret= Xorriso_node_from_path(xorriso, image, bin_path, &node, 1);
if(ret <= 0) { if(ret <= 0) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Cannot find in ISO image: -boot_image ... bin_path=%s", "Cannot find in ISO image: -boot_image ... bin_path=");
Text_shellsafe(bin_path, sfe, 0)); Text_shellsafe(bin_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;} {ret= 0; goto ex;}
} }
@ -482,8 +482,8 @@ int Xorriso_attach_boot_image(struct XorrisO *xorriso, int flag)
if(ret > 0) { if(ret > 0) {
if(!xorriso->do_overwrite) { if(!xorriso->do_overwrite) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"May not overwite existing -boot_image ... cat_path=%s", "May not overwite existing -boot_image ... cat_path=");
Text_shellsafe(xorriso->boot_image_cat_path, sfe, 0)); Text_shellsafe(xorriso->boot_image_cat_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;} {ret= 0; goto ex;}
} }
@ -491,8 +491,8 @@ int Xorriso_attach_boot_image(struct XorrisO *xorriso, int flag)
8 | (xorriso->do_overwrite == 1)); 8 | (xorriso->do_overwrite == 1));
if(ret != 1) { if(ret != 1) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Could not remove existing -boot_image cat_path=%s", "Could not remove existing -boot_image cat_path=");
Text_shellsafe(xorriso->boot_image_cat_path, sfe, 0)); Text_shellsafe(xorriso->boot_image_cat_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;} {ret= 0; goto ex;}
} }
@ -555,7 +555,7 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
{ {
int ret, relax= 0, i, pacifier_speed= 0, data_lba, ext, is_bootable= 0; int ret, relax= 0, i, pacifier_speed= 0, data_lba, ext, is_bootable= 0;
int freshly_bootable= 0, hide_attr, pad_by_libisofs= 0, signal_mode; int freshly_bootable= 0, hide_attr, pad_by_libisofs= 0, signal_mode;
char xorriso_id[256], *img_id, sfe[5*SfileadrL], *out_cs, *part_image; char *xorriso_id= NULL, *img_id, *sfe= NULL, *out_cs, *part_image;
struct isoburn_imgen_opts *sopts= NULL; struct isoburn_imgen_opts *sopts= NULL;
struct burn_drive_info *dinfo, *source_dinfo; struct burn_drive_info *dinfo, *source_dinfo;
struct burn_drive *drive, *source_drive; struct burn_drive *drive, *source_drive;
@ -569,13 +569,17 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
IsoImage *image= NULL; IsoImage *image= NULL;
IsoNode *root_node; IsoNode *root_node;
int profile_number; int profile_number;
char profile_name[80]; char *profile_name= NULL;
IsoBoot *bootcat_node; IsoBoot *bootcat_node;
uint32_t padding; uint32_t padding;
Xorriso_alloc_meM(sfe, char, 5 * SfileadrL);
Xorriso_alloc_meM(xorriso_id, char, 256);
Xorriso_alloc_meM(profile_name, char, 80);
ret= Xorriso_finish_hl_update(xorriso, 0); ret= Xorriso_finish_hl_update(xorriso, 0);
if(ret <= 0) if(ret <= 0)
return(ret); goto ex;
out_cs= xorriso->out_charset; out_cs= xorriso->out_charset;
if(out_cs == NULL) if(out_cs == NULL)
@ -584,12 +588,12 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
if(!(flag & 1)) { if(!(flag & 1)) {
ret= Xorriso_auto_format(xorriso, 0); ret= Xorriso_auto_format(xorriso, 0);
if(ret <=0 ) if(ret <=0 )
return(0); {ret= 0; goto ex;}
} }
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to write", 2); "on attempt to write", 2);
if(ret<=0) if(ret<=0)
return(0); goto ex;
s= isoburn_disc_get_status(drive); s= isoburn_disc_get_status(drive);
if(xorriso->out_drive_handle == xorriso->in_drive_handle) { if(xorriso->out_drive_handle == xorriso->in_drive_handle) {
@ -1007,6 +1011,9 @@ ex:;
isoburn_igopt_destroy(&sopts, 0); isoburn_igopt_destroy(&sopts, 0);
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
Xorriso_append_scdbackup_record(xorriso, 0); Xorriso_append_scdbackup_record(xorriso, 0);
Xorriso_free_meM(sfe);
Xorriso_free_meM(xorriso_id);
Xorriso_free_meM(profile_name);
return(ret); return(ret);
cancel_iso:; cancel_iso:;
@ -1636,21 +1643,25 @@ int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address,
off_t fixed_size= 0; off_t fixed_size= 0;
struct burn_source *data_src= NULL, *fifo_src= NULL; struct burn_source *data_src= NULL, *fifo_src= NULL;
enum burn_disc_status disc_state; enum burn_disc_status disc_state;
char reasons[BURN_REASONS_LEN], sfe[5*SfileadrL], profile_name[80]; char *reasons= NULL, *profile_name= NULL;
char head_buffer[64*1024]; char *head_buffer= NULL;
Xorriso_alloc_meM(reasons, char, BURN_REASONS_LEN);
Xorriso_alloc_meM(profile_name, char, 80);
Xorriso_alloc_meM(head_buffer, char, 64 * 1024);
ret= Xorriso_may_burn(xorriso, 0); ret= Xorriso_may_burn(xorriso, 0);
if(ret <= 0) if(ret <= 0)
return(0); {ret= 0; goto ex;}
ret= Xorriso_auto_format(xorriso, 0); ret= Xorriso_auto_format(xorriso, 0);
if(ret <=0 ) if(ret <=0 )
return(0); {ret= 0; goto ex;}
do_isosize= !!(flag&2); do_isosize= !!(flag&2);
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to burn track", 2); "on attempt to burn track", 2);
if(ret<=0) if(ret<=0)
return(0); {ret= 0; goto ex;}
ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0); ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0);
if(ret<=0) if(ret<=0)
goto ex; goto ex;
@ -1682,8 +1693,8 @@ int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address,
if(fd>=0) if(fd>=0)
data_src= burn_fd_source_new(fd, -1, fixed_size); data_src= burn_fd_source_new(fd, -1, fixed_size);
if(data_src==NULL) { if(data_src==NULL) {
sprintf(xorriso->info_text, "Could not open data source %s", sprintf(xorriso->info_text, "Could not open data source ");
Text_shellsafe(track_source,sfe,0)); Text_shellsafe(track_source, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
ret= 0; goto ex; ret= 0; goto ex;
} }
@ -1853,8 +1864,9 @@ int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address,
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
} }
sprintf(xorriso->info_text, "Writing to %s completed successfully.\n\n", sprintf(xorriso->info_text, "Writing to ");
Text_shellsafe(xorriso->outdev,sfe,0)); Text_shellsafe(xorriso->outdev, xorriso->info_text, 1);
strcat(xorriso->info_text, " completed successfully.\n\n");
Xorriso_info(xorriso, 0); Xorriso_info(xorriso, 0);
ret= 1; ret= 1;
ex:; ex:;
@ -1871,6 +1883,9 @@ ex:;
burn_source_free(xorriso->pacifier_fifo); burn_source_free(xorriso->pacifier_fifo);
xorriso->pacifier_fifo= NULL; xorriso->pacifier_fifo= NULL;
xorriso->run_state= 0; /* Indicate that burning has ended */ xorriso->run_state= 0; /* Indicate that burning has ended */
Xorriso_free_meM(reasons);
Xorriso_free_meM(profile_name);
Xorriso_free_meM(head_buffer);
return(ret); return(ret);
} }
@ -2392,15 +2407,16 @@ int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
int Xorriso_set_system_area_path(struct XorrisO *xorriso, char *path, int flag) int Xorriso_set_system_area_path(struct XorrisO *xorriso, char *path, int flag)
{ {
int ret; int ret;
char eff_src[SfileadrL]; char *eff_src= NULL;
if(path[0] == 0) { if(path[0] == 0) {
xorriso->system_area_disk_path[0]= 0; xorriso->system_area_disk_path[0]= 0;
return(1); {ret= 1; goto ex;}
} }
Xorriso_alloc_meM(eff_src, char, SfileadrL);
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, path, eff_src, 2|4|16); ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, path, eff_src, 2|4|16);
if(ret < 0) if(ret < 0)
return(ret); goto ex;
if(ret == 0) { if(ret == 0) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Given path does not exist on disk: -boot_image system_area="); "Given path does not exist on disk: -boot_image system_area=");
@ -2412,11 +2428,14 @@ int Xorriso_set_system_area_path(struct XorrisO *xorriso, char *path, int flag)
"Given path leads to a directory: -boot_image system_area="); "Given path leads to a directory: -boot_image system_area=");
Text_shellsafe(eff_src, xorriso->info_text, 1); Text_shellsafe(eff_src, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0); {ret= 0; goto ex;}
} }
ret= Sfile_str(xorriso->system_area_disk_path, eff_src, 0); ret= Sfile_str(xorriso->system_area_disk_path, eff_src, 0);
if(ret <= 0) if(ret <= 0)
return(-1); {ret= -1; goto ex;}
return(1); ret= 1;
ex:
Xorriso_free_meM(eff_src);
return(ret);
} }

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.05.07.184625" #define Xorriso_timestamP "2011.05.08.083929"