Now recognizing fused single character -as mkisofs options without parameters

This commit is contained in:
Thomas Schmitt 2012-04-25 19:10:34 +00:00
parent 32428f7890
commit 4768b08005
2 changed files with 172 additions and 30 deletions

View File

@ -954,6 +954,97 @@ int Xorriso_genisofs_strip_dash(struct XorrisO *xorriso, char *arg_in,
}
/* Interprets a string of single-char options which have no parameters
@param flag bit0=check whether string is ok
bit1=this is pass 1
@return with flag bit0: 0=no , 1=yes, 2= with bit1: non-pass-1 options seen
else : 1 = ok , <= 0 indicates error
*/
int Xorriso_genisofs_fused_options(struct XorrisO *xorriso, char *whom,
char *opts,
int *option_d, int *iso_level, int *lower_r,
char ra_text[80], int flag)
{
int ret, non_pass1= 0;
char *cpt;
static char pass1_covered[]= {"fvz"};
static char covered[]= {"dDfJlNRrTUvz"};
if(flag & 1) {
for(cpt= opts; *cpt != 0; cpt++) {
if(strchr(covered, *cpt) == NULL)
{ret= 0; goto ex;}
if(flag & 2)
if(strchr(pass1_covered, *cpt) == NULL)
non_pass1= 1;
}
ret= 1 + non_pass1; goto ex;
}
for(cpt= opts; *cpt != 0; cpt++) {
if(*cpt == 'd') {
if(flag & 2)
continue;
Xorriso_relax_compliance(xorriso, "no_force_dots", 0);
} else if(*cpt == 'D') {
if(flag & 2)
continue;
*option_d= 1;
} else if(*cpt == 'f') {
if(!(flag & 2))
continue;
ret= Xorriso_option_follow(xorriso, "on", 0);
if(ret <= 0)
goto ex;
} else if(*cpt == 'J') {
if(flag & 2)
continue;
xorriso->do_joliet= 1;
} else if(*cpt == 'l') {
if(flag & 2)
continue;
if(xorriso->iso_level <= 2)
Xorriso_relax_compliance(xorriso, "iso_9660_level=2", 0);
if(*iso_level <= 2)
*iso_level= 2;
} else if(*cpt == 'N') {
if(flag & 2)
continue;
Xorriso_relax_compliance(xorriso, "omit_version", 0);
} else if(*cpt == 'R') {
/* inavoidable */;
} else if(*cpt == 'r') {
if(flag & 2)
continue;
*lower_r= 1;
} else if(*cpt == 'T') {
/* ignored */;
} else if(*cpt == 'U') {
if(flag & 2)
continue;
Xorriso_relax_compliance(xorriso,
"no_force_dots:long_paths:long_names:omit_version:full_ascii:lowercase",
0);
} else if(*cpt == 'v') {
if(!(flag & 2))
continue;
strcpy(ra_text, "UPDATE");
} else if(*cpt == 'z') {
if(!(flag & 2))
continue;
Xorriso_option_zisofs(xorriso, "by_magic=on", 0);
} else {
sprintf(xorriso->info_text, "-as %s: Unsupported option -%c", whom, *cpt);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
}
ret= 1;
ex:;
return(ret);
}
/* micro emulation of mkisofs */
int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
int argc, char **argv, int flag)
@ -1079,12 +1170,16 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
} else if(strcmp(argpt, "-help")==0) {
Xorriso_genisofs_help(xorriso, 0);
} else if(strcmp(argpt, "-v")==0 || strcmp(argpt, "-verbose")==0) {
strcpy(ra_text, "UPDATE");
ret= Xorriso_genisofs_fused_options(xorriso, whom, "v",
&option_d, &iso_level, &lower_r, ra_text, 2);
if(ret <= 0)
goto problem_handler_1;
} else if(strcmp(argpt, "-quiet")==0) {
strcpy(ra_text, "SORRY");
} else if(strcmp(argpt, "-f")==0 || strcmp(argpt, "-follow-links")==0) {
ret= Xorriso_option_follow(xorriso, "on", 0);
if(ret<=0)
ret= Xorriso_genisofs_fused_options(xorriso, whom, "f",
&option_d, &iso_level, &lower_r, ra_text, 2);
if(ret <= 0)
goto problem_handler_1;
} else if(strcmp(argpt, "-iso-level")==0) {
if(i+1>=argc)
@ -1197,6 +1292,10 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
Xorriso_option_md5(xorriso, "on", 0);
} else if(strcmp(argpt, "-z")==0 ||
strcmp(argpt, "-transparent-compression")==0) {
ret= Xorriso_genisofs_fused_options(xorriso, whom, "z",
&option_d, &iso_level, &lower_r, ra_text, 2);
if(ret <= 0)
goto problem_handler_1;
Xorriso_option_zisofs(xorriso, "by_magic=on", 0);
} else if(strcmp(argpt, "--stdio_sync")==0) {
if(i+1>=argc)
@ -1214,11 +1313,26 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
} else if(strcmp(argpt, "-log-file") == 0) {
/* already handled before this loop */;
} else {
was_other_option= 1;
hargv[0]= argpt;
ret= Xorriso_genisofs_count_args(xorriso, argc - i, hargv, &count, 0);
if(ret > 0)
i+= count; /* skip eventual arguments of known option */
if(argv[i][0] == '-') {
ret= Xorriso_genisofs_fused_options(xorriso, whom, argv[i] + 1,
&option_d, &iso_level, &lower_r, ra_text, 1 | 2);
if(ret != 1)
was_other_option= 1;
} else {
ret= 0;
was_other_option= 1;
}
if(ret > 0) {
Xorriso_genisofs_fused_options(xorriso, whom, argv[i] + 1,
&option_d, &iso_level, &lower_r, ra_text, 2);
if(ret <= 0)
goto problem_handler_1;
} else {
hargv[0]= argpt;
ret= Xorriso_genisofs_count_args(xorriso, argc - i, hargv, &count, 0);
if(ret > 0)
i+= count; /* skip eventual arguments of known option */
}
}
continue; /* regular bottom of loop */
problem_handler_1:;
@ -1343,9 +1457,15 @@ illegal_c:;
} else if(strcmp(argpt, "-R")==0 || strcmp(argpt, "-rock")==0) {
/* ok */;
} else if(strcmp(argpt, "-r")==0 || strcmp(argpt, "-rational-rock")==0){
lower_r= 1;
ret= Xorriso_genisofs_fused_options(xorriso, whom, "r",
&option_d, &iso_level, &lower_r, ra_text, 0);
if(ret <= 0)
goto problem_handler_2;
} else if(strcmp(argpt, "-J")==0 || strcmp(argpt, "-joliet")==0) {
xorriso->do_joliet= 1;
ret= Xorriso_genisofs_fused_options(xorriso, whom, "J",
&option_d, &iso_level, &lower_r, ra_text, 0);
if(ret <= 0)
goto problem_handler_2;
} else if(strcmp(argpt, "-joliet-long")==0) {
Xorriso_relax_compliance(xorriso,
"joliet_long_paths:joliet_long_names", 0);
@ -1519,8 +1639,10 @@ not_enough_args:;
/* was already handled in first argument scan */;
} else if(strcmp(argpt, "-U") == 0 ||
strcmp(argpt, "-untranslated-filenames") == 0) {
Xorriso_relax_compliance(xorriso,
"no_force_dots:long_paths:long_names:omit_version:full_ascii:lowercase", 0);
ret= Xorriso_genisofs_fused_options(xorriso, whom, "U",
&option_d, &iso_level, &lower_r, ra_text, 0);
if(ret <= 0)
goto problem_handler_2;
} else if(strcmp(argpt, "-untranslated_name_len") == 0) {
if(i+1>=argc)
goto not_enough_args;
@ -1531,18 +1653,24 @@ not_enough_args:;
goto problem_handler_2;
} else if(strcmp(argpt, "-N") == 0 ||
strcmp(argpt, "-omit-version-number") == 0) {
Xorriso_relax_compliance(xorriso, "omit_version", 0);
ret= Xorriso_genisofs_fused_options(xorriso, whom, "N",
&option_d, &iso_level, &lower_r, ra_text, 0);
if(ret <= 0)
goto problem_handler_2;
} else if(strcmp(argpt, "-l") == 0 ||
strcmp(argpt, "-full-iso9660-filenames") == 0) {
if(xorriso->iso_level <= 2)
Xorriso_relax_compliance(xorriso, "iso_9660_level=2", 0);
if(iso_level <= 2)
iso_level= 2;
ret= Xorriso_genisofs_fused_options(xorriso, whom, "l",
&option_d, &iso_level, &lower_r, ra_text, 0);
if(ret <= 0)
goto problem_handler_2;
} else if(strcmp(argpt, "-max-iso9660-filenames") == 0) {
Xorriso_relax_compliance(xorriso, "long_names", 0);
} else if(strcmp(argpt, "-d") == 0 ||
strcmp(argpt, "-omit-period") == 0) {
Xorriso_relax_compliance(xorriso, "no_force_dots", 0);
ret= Xorriso_genisofs_fused_options(xorriso, whom, "d",
&option_d, &iso_level, &lower_r, ra_text, 0);
if(ret <= 0)
goto problem_handler_2;
} else if(strcmp(argpt, "-allow-lowercase") == 0) {
Xorriso_relax_compliance(xorriso, "lowercase", 0);
} else if(strcmp(argpt, "-relaxed-filenames") == 0) {
@ -1678,7 +1806,10 @@ not_enough_args:;
} else if(strcmp(argpt, "-D") == 0 ||
strcmp(argpt, "-disable-deep-relocation") == 0) {
option_d= 1;
ret= Xorriso_genisofs_fused_options(xorriso, whom, "D",
&option_d, &iso_level, &lower_r, ra_text, 0);
if(ret <= 0)
goto problem_handler_2;
} else if(strcmp(argpt, "-hide-rr-moved") == 0) {
rr_reloc_dir_pt= ".rr_moved";
@ -1705,16 +1836,25 @@ rr_reloc_dir:;
/* was already handled before this loop */;
} else if(argpt[0]=='-' && argpt[1]!=0) {
hargv[0]= argpt;
ret= Xorriso_genisofs_count_args(xorriso, argc - i, hargv, &count, 1);
if(ret > 0) {
sprintf(xorriso->info_text, "-as %s: Unsupported option %s",
whom, Text_shellsafe(argv[i], sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
i+= count;
goto problem_handler_2;
} else
goto is_pathspec_2;
ret= Xorriso_genisofs_fused_options(xorriso, whom, argv[i] + 1,
&option_d, &iso_level, &lower_r, ra_text, 1);
if(ret == 1) {
ret= Xorriso_genisofs_fused_options(xorriso, whom, argv[i] + 1,
&option_d, &iso_level, &lower_r, ra_text, 0);
if(ret <= 0)
goto problem_handler_2;
} else {
hargv[0]= argpt;
ret= Xorriso_genisofs_count_args(xorriso, argc - i, hargv, &count, 1);
if(ret > 0) {
sprintf(xorriso->info_text, "-as %s: Unsupported option %s",
whom, Text_shellsafe(argv[i], sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
i+= count;
goto problem_handler_2;
} else
goto is_pathspec_2;
}
} else {
is_pathspec_2:;
/* implementing mkisofs tendency to map single-path pathspecs to / */
@ -1893,6 +2033,8 @@ problem_handler_2:;
argpt= argv[i] + 1;
else
argpt= argv[i];
if(ret <= 0)
goto ex;
if(strcmp(argpt, "-no-emul-boot")==0) {
emul_boot= xorriso->boot_image_emul= 0;
} else if(strcmp(argpt, "-hard-disk-boot")==0) {

View File

@ -1 +1 @@
#define Xorriso_timestamP "2012.04.22.100352"
#define Xorriso_timestamP "2012.04.25.191110"