Eat up leading dashes with command options, convert inner dashes to underscores
This commit is contained in:
parent
191f54eca2
commit
073da62d73
@ -399,6 +399,9 @@ All command words are shown with a leading dash although this dash is not
|
|||||||
mandatory for the option to be recognized. There may be future emulation
|
mandatory for the option to be recognized. There may be future emulation
|
||||||
modes, where dashes may become mandatory in order to distinguish options
|
modes, where dashes may become mandatory in order to distinguish options
|
||||||
from file addresses.
|
from file addresses.
|
||||||
|
.br
|
||||||
|
Normally any number of leading dashes is ignored with command words and
|
||||||
|
inner dashes are interpreted as underscores.
|
||||||
.TP
|
.TP
|
||||||
.B Aquiring source and target drive:
|
.B Aquiring source and target drive:
|
||||||
.TP
|
.TP
|
||||||
|
@ -9040,7 +9040,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
|||||||
"",
|
"",
|
||||||
" -list_formats Show media specific list of format descriptors.",
|
" -list_formats Show media specific list of format descriptors.",
|
||||||
"",
|
"",
|
||||||
" -print-size Print the foreseeable consumption by next -commit.",
|
" -print_size Print the foreseeable consumption by next -commit.",
|
||||||
"",
|
"",
|
||||||
" -tell_media_space",
|
" -tell_media_space",
|
||||||
" Print foreseeable available space on output media",
|
" Print foreseeable available space on output media",
|
||||||
@ -10198,7 +10198,7 @@ int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Option -print-size
|
/* Option -print_size
|
||||||
@param flag bit0= report in mkisofs compatible form on real stdout
|
@param flag bit0= report in mkisofs compatible form on real stdout
|
||||||
*/
|
*/
|
||||||
int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
|
int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
|
||||||
@ -10206,7 +10206,7 @@ int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
|
|||||||
int ret, fd;
|
int ret, fd;
|
||||||
|
|
||||||
if(!xorriso->volset_change_pending) {
|
if(!xorriso->volset_change_pending) {
|
||||||
sprintf(xorriso->info_text,"-print-size: No image modifications pending");
|
sprintf(xorriso->info_text,"-print_size: No image modifications pending");
|
||||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
||||||
sprintf(xorriso->result_line,"Image size : 0s\n");
|
sprintf(xorriso->result_line,"Image size : 0s\n");
|
||||||
Xorriso_result(xorriso,0);
|
Xorriso_result(xorriso,0);
|
||||||
@ -10214,7 +10214,7 @@ int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
|
|||||||
}
|
}
|
||||||
ret= Xorriso_write_session(xorriso, 1);
|
ret= Xorriso_write_session(xorriso, 1);
|
||||||
if(ret<=0) {
|
if(ret<=0) {
|
||||||
sprintf(xorriso->info_text,"-print-size: Failed to set up virtual -commit");
|
sprintf(xorriso->info_text,"-print_size: Failed to set up virtual -commit");
|
||||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@ -10897,6 +10897,41 @@ int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag)
|
|||||||
/* ---------------------------- End Options API ------------------------ */
|
/* ---------------------------- End Options API ------------------------ */
|
||||||
|
|
||||||
|
|
||||||
|
/* @return <0 error , >=0 number of skipped dashes
|
||||||
|
*/
|
||||||
|
int Xorriso_normalize_command(struct XorrisO *xorriso, char *original_cmd,
|
||||||
|
int argno, char *cmd_data, int sizeof_cmd_data,
|
||||||
|
char **cmd, int flag)
|
||||||
|
{
|
||||||
|
int was_dashed= 0;
|
||||||
|
char *dash_pt;
|
||||||
|
|
||||||
|
if(strlen(original_cmd)>= sizeof_cmd_data) {
|
||||||
|
if(argno>=0)
|
||||||
|
sprintf(xorriso->info_text, "Oversized argument #%d (length %d)\n",
|
||||||
|
argno, (int) strlen(original_cmd));
|
||||||
|
else
|
||||||
|
sprintf(xorriso->info_text, "Oversized option (length %d)\n",
|
||||||
|
(int) strlen(original_cmd));
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
strcpy(cmd_data, original_cmd);
|
||||||
|
*cmd= cmd_data;
|
||||||
|
if(strcmp(*cmd, "--")==0)
|
||||||
|
return(1);
|
||||||
|
while((*cmd)[0]=='-') {
|
||||||
|
if((*cmd)[1]==0)
|
||||||
|
break;
|
||||||
|
was_dashed++;
|
||||||
|
(*cmd)++;
|
||||||
|
}
|
||||||
|
for(dash_pt= *cmd; *dash_pt!=0; dash_pt++)
|
||||||
|
if(*dash_pt=='-')
|
||||||
|
*dash_pt= '_';
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int Xorriso_interpreter(struct XorrisO *xorriso,
|
int Xorriso_interpreter(struct XorrisO *xorriso,
|
||||||
int argc, char **argv, int *idx, int flag)
|
int argc, char **argv, int *idx, int flag)
|
||||||
/*
|
/*
|
||||||
@ -10909,7 +10944,7 @@ return:
|
|||||||
{
|
{
|
||||||
int ret, was_dashed, end_ret;
|
int ret, was_dashed, end_ret;
|
||||||
int num1, num2;
|
int num1, num2;
|
||||||
char *cmd, *arg1, *arg2;
|
char *cmd, *original_cmd, cmd_data[2*SfileadrL], *arg1, *arg2;
|
||||||
|
|
||||||
if(xorriso==NULL)
|
if(xorriso==NULL)
|
||||||
return(0);
|
return(0);
|
||||||
@ -10924,18 +10959,32 @@ next_command:;
|
|||||||
xorriso->request_to_abort= xorriso->request_not_to_ask= 0;
|
xorriso->request_to_abort= xorriso->request_not_to_ask= 0;
|
||||||
Xorriso_set_problem_status(xorriso, "", 0);
|
Xorriso_set_problem_status(xorriso, "", 0);
|
||||||
if((*idx)<argc)
|
if((*idx)<argc)
|
||||||
cmd= argv[*idx];
|
original_cmd= cmd= argv[*idx];
|
||||||
else
|
else
|
||||||
cmd= "";
|
original_cmd= cmd= "";
|
||||||
if(xorriso->add_plainly==3 && cmd[0] && !xorriso->is_dialog) {
|
if(xorriso->add_plainly==3 && cmd[0] && !xorriso->is_dialog) {
|
||||||
(*idx)++;
|
(*idx)++;
|
||||||
goto add_plain_argument;
|
goto add_plain_argument;
|
||||||
}
|
}
|
||||||
was_dashed= 0;
|
was_dashed= 0;
|
||||||
|
|
||||||
|
#ifdef NIX
|
||||||
|
|
||||||
if(cmd[0]=='-' && cmd[1]!='-' && cmd[1]!=0) {
|
if(cmd[0]=='-' && cmd[1]!='-' && cmd[1]!=0) {
|
||||||
was_dashed= 1;
|
was_dashed= 1;
|
||||||
cmd++;
|
cmd++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* NIX */
|
||||||
|
|
||||||
|
ret= Xorriso_normalize_command(xorriso, original_cmd, -1,
|
||||||
|
cmd_data, sizeof(cmd_data), &cmd, 0);
|
||||||
|
if(ret<0)
|
||||||
|
goto eval_any_problems;
|
||||||
|
was_dashed= ret;
|
||||||
|
|
||||||
|
#endif /* ! NIX */
|
||||||
|
|
||||||
(*idx)++;
|
(*idx)++;
|
||||||
|
|
||||||
if((*idx)<argc)
|
if((*idx)<argc)
|
||||||
@ -11234,7 +11283,7 @@ next_command:;
|
|||||||
(*idx)++;
|
(*idx)++;
|
||||||
ret= Xorriso_option_print(xorriso, arg1, 0);
|
ret= Xorriso_option_print(xorriso, arg1, 0);
|
||||||
|
|
||||||
} else if(strcmp(cmd,"print-size")==0 || strcmp(cmd,"print_size")==0) {
|
} else if(strcmp(cmd,"print_size")==0) {
|
||||||
Xorriso_option_print_size(xorriso, 0);
|
Xorriso_option_print_size(xorriso, 0);
|
||||||
|
|
||||||
} else if(strcmp(cmd,"prompt")==0) {
|
} else if(strcmp(cmd,"prompt")==0) {
|
||||||
@ -11357,10 +11406,8 @@ next_command:;
|
|||||||
if(xorriso->add_plainly>1)
|
if(xorriso->add_plainly>1)
|
||||||
goto add_plain_argument;
|
goto add_plain_argument;
|
||||||
unknown_option:;
|
unknown_option:;
|
||||||
sprintf(xorriso->info_text,
|
sprintf(xorriso->info_text, "=== Not a known option:\n === '%s'\n",
|
||||||
"=== Not a known option:\n");
|
original_cmd);
|
||||||
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
|
||||||
"=== '%s%s'\n",(was_dashed ? "-" : ""), cmd);
|
|
||||||
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 eval_any_problems;}
|
{ret= 0; goto eval_any_problems;}
|
||||||
|
|
||||||
@ -11514,15 +11561,28 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
|||||||
{
|
{
|
||||||
int i, ret, was_dashed, num2;
|
int i, ret, was_dashed, num2;
|
||||||
int was_report_about= 0, was_abort_on= 0, was_return_with= 0;
|
int was_report_about= 0, was_abort_on= 0, was_return_with= 0;
|
||||||
char *cmd, *arg1, *arg2;
|
char *cmd, *original_cmd, cmd_data[5*SfileadrL], *arg1, *arg2;
|
||||||
|
|
||||||
for(i=1+(flag&1);i<argc;i++) {
|
for(i=1+(flag&1);i<argc;i++) {
|
||||||
cmd= argv[i];
|
original_cmd= cmd= argv[i];
|
||||||
was_dashed= 0;
|
was_dashed= 0;
|
||||||
|
|
||||||
|
#ifdef NIX
|
||||||
|
|
||||||
if(cmd[0]=='-' && cmd[1]!='-' && cmd[1]!=0) {
|
if(cmd[0]=='-' && cmd[1]!='-' && cmd[1]!=0) {
|
||||||
was_dashed= 1;
|
was_dashed= 1;
|
||||||
cmd++;
|
cmd++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* NIX */
|
||||||
|
|
||||||
|
was_dashed= Xorriso_normalize_command(xorriso, original_cmd, i,
|
||||||
|
cmd_data, sizeof(cmd_data), &cmd, 0);
|
||||||
|
if(was_dashed<0)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
#endif /* ! NIX */
|
||||||
|
|
||||||
arg1= "";
|
arg1= "";
|
||||||
if(i+1<argc)
|
if(i+1<argc)
|
||||||
arg1= argv[i+1];
|
arg1= argv[i+1];
|
||||||
|
@ -386,7 +386,7 @@ int Xorriso_option_pkt_output(struct XorrisO *xorriso, char *mode, int flag);
|
|||||||
/* Option -print */
|
/* Option -print */
|
||||||
int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag);
|
int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag);
|
||||||
|
|
||||||
/* Option -print-size
|
/* Option -print_size
|
||||||
@param flag bit0= report in mkisofs compatible form on real stdout
|
@param flag bit0= report in mkisofs compatible form on real stdout
|
||||||
*/
|
*/
|
||||||
int Xorriso_option_print_size(struct XorrisO *xorriso, int flag);
|
int Xorriso_option_print_size(struct XorrisO *xorriso, int flag);
|
||||||
|
@ -1 +1 @@
|
|||||||
#define Xorriso_timestamP "2008.05.13.180624"
|
#define Xorriso_timestamP "2008.05.13.180912"
|
||||||
|
Loading…
Reference in New Issue
Block a user