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

This commit is contained in:
Thomas Schmitt 2011-05-05 12:16:19 +00:00
parent f1b5626786
commit 9c1fc23901
2 changed files with 62 additions and 50 deletions

View File

@ -44,7 +44,7 @@
int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag) int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
{ {
int ret; int ret;
char sfe[5*SfileadrL], *adr; char *adr;
adr= in_adr; adr= in_adr;
if(strcmp(in_adr, "-")==0) if(strcmp(in_adr, "-")==0)
@ -77,17 +77,16 @@ int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
if(adr[0]==0) { if(adr[0]==0) {
if((flag&1) && xorriso->in_drive_handle != NULL) { if((flag&1) && xorriso->in_drive_handle != NULL) {
if(xorriso->in_drive_handle == xorriso->out_drive_handle) if(xorriso->in_drive_handle == xorriso->out_drive_handle)
sprintf(xorriso->info_text,"Giving up -dev %s", sprintf(xorriso->info_text,"Giving up -dev ");
Text_shellsafe(xorriso->indev, sfe, 0));
else else
sprintf(xorriso->info_text,"Giving up -indev %s", sprintf(xorriso->info_text,"Giving up -indev ");
Text_shellsafe(xorriso->indev, sfe, 0)); Text_shellsafe(xorriso->indev, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
} }
if((flag&2) && xorriso->out_drive_handle != NULL && if((flag&2) && xorriso->out_drive_handle != NULL &&
xorriso->in_drive_handle != xorriso->out_drive_handle) { xorriso->in_drive_handle != xorriso->out_drive_handle) {
sprintf(xorriso->info_text,"Giving up -outdev %s", sprintf(xorriso->info_text,"Giving up -outdev ");
Text_shellsafe(xorriso->outdev, sfe, 0)); Text_shellsafe(xorriso->outdev, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
} }
ret= Xorriso_give_up_drive(xorriso, (flag&3)|((flag&32)>>2)); ret= Xorriso_give_up_drive(xorriso, (flag&3)|((flag&32)>>2));
@ -108,7 +107,6 @@ int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
int Xorriso_option_devices(struct XorrisO *xorriso, int flag) int Xorriso_option_devices(struct XorrisO *xorriso, int flag)
{ {
int ret; int ret;
char sfe[5*SfileadrL];
if(xorriso->volset_change_pending) { if(xorriso->volset_change_pending) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
@ -123,18 +121,18 @@ int Xorriso_option_devices(struct XorrisO *xorriso, int flag)
xorriso->info_text[0]= 0; xorriso->info_text[0]= 0;
if(xorriso->in_drive_handle!=NULL || xorriso->out_drive_handle!=NULL) { if(xorriso->in_drive_handle!=NULL || xorriso->out_drive_handle!=NULL) {
if(xorriso->in_drive_handle == xorriso->out_drive_handle) { if(xorriso->in_drive_handle == xorriso->out_drive_handle) {
sprintf(xorriso->info_text, "Gave up -dev %s", sprintf(xorriso->info_text, "Gave up -dev ");
Text_shellsafe(xorriso->indev, sfe, 0)); Text_shellsafe(xorriso->indev, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}else { }else {
if(xorriso->in_drive_handle!=NULL) { if(xorriso->in_drive_handle!=NULL) {
sprintf(xorriso->info_text, "Gave up -indev %s", sprintf(xorriso->info_text, "Gave up -indev ");
Text_shellsafe(xorriso->indev, sfe, 0)); Text_shellsafe(xorriso->indev, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
} }
if(xorriso->out_drive_handle!=NULL) { if(xorriso->out_drive_handle!=NULL) {
sprintf(xorriso->info_text, "Gave up -outdev %s", sprintf(xorriso->info_text, "Gave up -outdev ");
Text_shellsafe(xorriso->outdev, sfe, 0)); Text_shellsafe(xorriso->outdev, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
} }
} }
@ -396,15 +394,14 @@ int Xorriso_option_errfile_log(struct XorrisO *xorriso,
{ {
int ret, mode_word; int ret, mode_word;
FILE *fp= NULL; FILE *fp= NULL;
char sfe[5*SfileadrL];
if(path[0]==0 || path[0]=='-') { if(path[0]==0 || path[0]=='-') {
/* ok */; /* ok */;
} else { } else {
fp= fopen(path, "a"); fp= fopen(path, "a");
if(fp==0) { if(fp==0) {
sprintf(xorriso->info_text, "-errfile_log: Cannot open file %s", sprintf(xorriso->info_text, "-errfile_log: Cannot open file ");
Text_shellsafe(path, sfe, 0)); Text_shellsafe(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);
return(0); return(0);
} }
@ -415,8 +412,8 @@ int Xorriso_option_errfile_log(struct XorrisO *xorriso,
else if(strcmp(mode, "plain")==0) else if(strcmp(mode, "plain")==0)
mode_word&= ~1; mode_word&= ~1;
else { else {
sprintf(xorriso->info_text, "-errfile_log: Unknown mode %s", sprintf(xorriso->info_text, "-errfile_log: Unknown mode ");
Text_shellsafe(mode, sfe, 0)); Text_shellsafe(mode, 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);
if(fp != NULL) if(fp != NULL)
fclose(fp); fclose(fp);
@ -508,7 +505,10 @@ int Xorriso_option_extract(struct XorrisO *xorriso, char *iso_path,
char *disk_path, int flag) char *disk_path, int flag)
{ {
int ret, problem_count; int ret, problem_count;
char eff_origin[SfileadrL], eff_dest[SfileadrL], *ipth, *eopt[1], *edpt[1]; char *eff_origin= NULL, *eff_dest= NULL, *ipth, *eopt[1], *edpt[1];
Xorriso_alloc_meM(eff_origin, char, SfileadrL);
Xorriso_alloc_meM(eff_dest, char, SfileadrL);
if(xorriso->allow_restore <= 0) { if(xorriso->allow_restore <= 0) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
@ -555,6 +555,8 @@ int Xorriso_option_extract(struct XorrisO *xorriso, char *iso_path,
ex:; ex:;
if(!(flag & (4 | 32))) if(!(flag & (4 | 32)))
Xorriso_destroy_node_array(xorriso, 0); Xorriso_destroy_node_array(xorriso, 0);
Xorriso_free_meM(eff_origin);
Xorriso_free_meM(eff_dest);
return(ret); return(ret);
} }
@ -648,7 +650,7 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
{ {
int ret, i, end_idx, type= 0, action, deleter= 0, start_lba, count; int ret, i, end_idx, type= 0, action, deleter= 0, start_lba, count;
struct FindjoB *job, *first_job= NULL, *new_job; struct FindjoB *job, *first_job= NULL, *new_job;
char *start_path, sfe[5*SfileadrL], *cpt, other_path_start[SfileadrL]; char *start_path, *path= NULL, *cpt, *other_path_start= NULL;
char *access_acl_text= NULL, *default_acl_text= NULL; char *access_acl_text= NULL, *default_acl_text= NULL;
struct stat dir_stbuf; struct stat dir_stbuf;
@ -658,6 +660,9 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
mode_t mode_or= 0, mode_and= ~1; mode_t mode_or= 0, mode_and= ~1;
double mem_lut= 0.0; double mem_lut= 0.0;
Xorriso_alloc_meM(path, char, SfileadrL);
Xorriso_alloc_meM(other_path_start, char, SfileadrL);
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
start_path= "."; start_path= ".";
if(end_idx > *idx && start_path[0]!=0) if(end_idx > *idx && start_path[0]!=0)
@ -675,15 +680,15 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
if(i+1>=end_idx) { if(i+1>=end_idx) {
not_enough_arguments:; not_enough_arguments:;
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"-find[ix]: not enough arguments with test %s", "-find[ix]: not enough arguments with test ");
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
goto sorry_ex; goto sorry_ex;
} }
i++; i++;
ret= Findjob_set_name_expr(job, argv[i], 0); ret= Findjob_set_name_expr(job, argv[i], 0);
if(ret<=0) { if(ret<=0) {
sprintf(xorriso->info_text, "-find[ix]: cannot set -name expression %s", sprintf(xorriso->info_text, "-find[ix]: cannot set -name expression ");
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
goto sorry_ex; goto sorry_ex;
} }
} else if(strcmp(argv[i], "-wholename")==0) { } else if(strcmp(argv[i], "-wholename")==0) {
@ -693,8 +698,8 @@ not_enough_arguments:;
ret= Findjob_set_name_expr(job, argv[i], 1); ret= Findjob_set_name_expr(job, argv[i], 1);
if(ret<=0) { if(ret<=0) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"-find[ix]: cannot set -wholename expression %s", "-find[ix]: cannot set -wholename expression ");
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
goto sorry_ex; goto sorry_ex;
} }
} else if(strcmp(argv[i], "-type")==0) { } else if(strcmp(argv[i], "-type")==0) {
@ -746,8 +751,8 @@ not_enough_arguments:;
ret= Findjob_set_name_expr(job, argv[i], 2); ret= Findjob_set_name_expr(job, argv[i], 2);
if(ret<=0) { if(ret<=0) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"-find[ix]: cannot set -disk_name expression %s", "-find[ix]: cannot set -disk_name expression ");
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
goto sorry_ex; goto sorry_ex;
} }
} else if(strcmp(argv[i], "-hidden")==0) { } else if(strcmp(argv[i], "-hidden")==0) {
@ -756,8 +761,8 @@ not_enough_arguments:;
i+= 1; i+= 1;
type= Xorriso__hide_mode(argv[i], 0); type= Xorriso__hide_mode(argv[i], 0);
if(type < 0) { if(type < 0) {
sprintf(xorriso->info_text, "-findi: -hidden : unknown hide state %s", sprintf(xorriso->info_text, "-findi: -hidden : unknown hide state ");
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
goto sorry_ex; goto sorry_ex;
} else { } else {
ret= Findjob_set_test_hidden(job, type, 0); ret= Findjob_set_test_hidden(job, type, 0);
@ -807,8 +812,8 @@ not_enough_arguments:;
if(i+1>=end_idx) { if(i+1>=end_idx) {
not_enough_exec_arguments:; not_enough_exec_arguments:;
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"-find[ix]: not enough arguments with -exec %s", "-find[ix]: not enough arguments with -exec ");
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
goto sorry_ex; goto sorry_ex;
} }
i++; i++;
@ -917,10 +922,11 @@ not_enough_exec_arguments:;
if(ret<=0) if(ret<=0)
goto ex; goto ex;
Findjob_set_action_target(job, action, other_path_start, 0); Findjob_set_action_target(job, action, other_path_start, 0);
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, start_path,sfe, 1|2|4); ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, start_path,
path, 1|2|4);
if(ret<=0) if(ret<=0)
goto ex; goto ex;
Findjob_set_start_path(job, sfe, 0); Findjob_set_start_path(job, path, 0);
if(!(flag&2)) { if(!(flag&2)) {
Xorriso_pacifier_reset(xorriso, 0); Xorriso_pacifier_reset(xorriso, 0);
mem_lut= xorriso->last_update_time; mem_lut= xorriso->last_update_time;
@ -948,11 +954,11 @@ not_enough_exec_arguments:;
else else
action= 16; action= 16;
Findjob_set_action_target(job, action, other_path_start, 0); Findjob_set_action_target(job, action, other_path_start, 0);
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, start_path, sfe, ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, start_path, path,
1|2|4|8); 1|2|4|8);
if(ret<=0) if(ret<=0)
goto ex; goto ex;
Findjob_set_start_path(job, sfe, 0); Findjob_set_start_path(job, path, 0);
} else if(strcmp(cpt, "report_damage")==0) { } else if(strcmp(cpt, "report_damage")==0) {
Findjob_set_action_target(job, 21, NULL, 0); Findjob_set_action_target(job, 21, NULL, 0);
@ -1030,8 +1036,8 @@ not_enough_exec_arguments:;
i++; i++;
type= Xorriso__hide_mode(argv[i], 0); type= Xorriso__hide_mode(argv[i], 0);
if(type < 0) { if(type < 0) {
sprintf(xorriso->info_text, "-find -exec hide: unknown hide state %s", sprintf(xorriso->info_text, "-find -exec hide: unknown hide state ");
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
goto sorry_ex; goto sorry_ex;
} }
Findjob_set_action_type(job, 39, type, 0); Findjob_set_action_type(job, 39, type, 0);
@ -1044,13 +1050,13 @@ not_enough_exec_arguments:;
Findjob_set_action_target(job, 43, NULL, 0); Findjob_set_action_target(job, 43, NULL, 0);
xorriso->update_flags&= ~1; /* End update_merge mode for node adding */ xorriso->update_flags&= ~1; /* End update_merge mode for node adding */
} else { } else {
sprintf(xorriso->info_text, "-find -exec: unknown action %s", sprintf(xorriso->info_text, "-find -exec: unknown action ");
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
goto sorry_ex; goto sorry_ex;
} }
} else { } else {
sprintf(xorriso->info_text, "-find[ix]: unknown option %s", sprintf(xorriso->info_text, "-find[ix]: unknown option ");
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], xorriso->info_text, 1);
sorry_ex:; sorry_ex:;
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;}
@ -1091,6 +1097,8 @@ ex:;
if(default_acl_text != NULL) if(default_acl_text != NULL)
free(default_acl_text); free(default_acl_text);
Findjob_destroy(&first_job, 0); Findjob_destroy(&first_job, 0);
Xorriso_free_meM(path);
Xorriso_free_meM(other_path_start);
(*idx)= end_idx; (*idx)= end_idx;
return(ret); return(ret);
} }
@ -1288,14 +1296,15 @@ int Xorriso_option_grow_blindly(struct XorrisO *xorriso, char *msc2, int flag)
int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag) int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag)
{ {
int ret; int ret;
char what_data[SfileadrL], *what, *what_next; char *what_data= NULL, *what, *what_next;
Xorriso_alloc_meM(what_data, char, SfileadrL);
if(Sfile_str(what_data, mode, 0)<=0) { if(Sfile_str(what_data, mode, 0)<=0) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"-hardlinks: mode string is much too long (%d)", "-hardlinks: mode string is much too long (%d)",
(int) strlen(mode)); (int) strlen(mode));
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;}
} }
for(what= what_data; what != NULL; what= what_next) { for(what= what_data; what != NULL; what= what_next) {
what_next= strchr(what, ':'); what_next= strchr(what, ':');
@ -1317,7 +1326,7 @@ int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag)
xorriso->ino_behavior&= ~(1 | 2 | 4 | 8); xorriso->ino_behavior&= ~(1 | 2 | 4 | 8);
ret= Xorriso_make_di_array(xorriso, 1); ret= Xorriso_make_di_array(xorriso, 1);
if(ret <= 0) if(ret <= 0)
return(ret); goto ex;
} else if(strcmp(what, "end_update") == 0) { } else if(strcmp(what, "end_update") == 0) {
Xorriso_finish_hl_update(xorriso, 0); Xorriso_finish_hl_update(xorriso, 0);
} else if(strcmp(what, "perform_update") == 0) { } else if(strcmp(what, "perform_update") == 0) {
@ -1326,7 +1335,7 @@ int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag)
xorriso->ino_behavior&= ~(1 | 2 | 4); xorriso->ino_behavior&= ~(1 | 2 | 4);
ret= Xorriso_make_hln_array(xorriso, 1); ret= Xorriso_make_hln_array(xorriso, 1);
if(ret <= 0) if(ret <= 0)
return(ret); goto ex;
} else if(strcmp(what, "end_extract") == 0) { } else if(strcmp(what, "end_extract") == 0) {
Xorriso_destroy_hln_array(xorriso, 0); Xorriso_destroy_hln_array(xorriso, 0);
} else if(strcmp(what, "discard_extract") == 0) { } else if(strcmp(what, "discard_extract") == 0) {
@ -1339,7 +1348,7 @@ int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag)
sprintf(xorriso->info_text, "-hardlinks: unknown mode '%s' in '%s'", sprintf(xorriso->info_text, "-hardlinks: unknown mode '%s' in '%s'",
what, mode); what, mode);
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;}
} }
} }
@ -1354,7 +1363,10 @@ int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag)
Xorriso_option_compliance(xorriso, "new_rr", 0); Xorriso_option_compliance(xorriso, "new_rr", 0);
*/ */
return(1); ret= 1;
ex:;
Xorriso_free_meM(what_data);
return(ret);
} }

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.05.05.105310" #define Xorriso_timestamP "2011.05.05.121640"