From 97fda364dbb979634902d71493e29576ed368cf3 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 16 May 2011 13:43:16 +0000 Subject: [PATCH] Checking for unknown xorriso commands already in Xorriso_prescan_args() --- xorriso/parse_exec.c | 39 +++++++++++++++++++++++++++++++------ xorriso/xorriso.h | 5 +++-- xorriso/xorriso_timestamp.h | 2 +- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/xorriso/parse_exec.c b/xorriso/parse_exec.c index 78c70a32..57a96279 100644 --- a/xorriso/parse_exec.c +++ b/xorriso/parse_exec.c @@ -581,6 +581,7 @@ return: */ { int ret, was_dashed, end_ret, num1, num2, cmd_data_size= 2 * SfileadrL; + int mem_idx; char *cmd, *original_cmd, *cmd_data= NULL, *arg1, *arg2; Xorriso_alloc_meM(cmd_data, char, cmd_data_size); @@ -1411,9 +1412,10 @@ unknown_option:; if(xorriso->add_plainly<=0) goto unknown_option; add_plain_argument:; + mem_idx= *idx; (*idx)--; ret= Xorriso_option_add(xorriso, (*idx)+1, argv, idx, 0); - (*idx)++; + (*idx)= mem_idx; } @@ -1561,14 +1563,17 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv, */ { int i, ret, was_dashed, num2, arg_count; + int advice, mem_add_plainly, error_seen= 0; int was_report_about= 0, was_abort_on= 0, was_return_with= 0; int was_signal_handling= 0, was_scsi_log= 0, cmd_data_size= 5 * SfileadrL; char *cmd, *original_cmd, *cmd_data= NULL, *arg1, *arg2; char mem_list_delimiter[81]; + strcpy(mem_list_delimiter, xorriso->list_delimiter); + mem_add_plainly= xorriso->add_plainly; + Xorriso_alloc_meM(cmd_data, char, cmd_data_size); - strcpy(mem_list_delimiter, xorriso->list_delimiter); for(i=1+(flag&1);iargument_emulation >= 1 && xorriso->argument_emulation <= 2) { {ret= 1; goto ex;} @@ -1659,8 +1664,17 @@ protect_stdout:; i++; ret= Xorriso_option_list_delimiter(xorriso, arg1, 0); if(ret <= 0) - goto ex; + error_seen= 1; + } else if(strcmp(cmd, "add_plainly") == 0) { + i++; + ret= Xorriso_option_add_plainly(xorriso, arg1, 0); + if(ret <= 0) + error_seen= 1; + if(xorriso->add_plainly == 3) { + /* All further arguments count as pathspecs */ + {ret= 1; goto ex;} + } } else if(strcmp(cmd, "scsi_log") == 0 && was_dashed == 1) { i++; if(!was_scsi_log) @@ -1674,15 +1688,28 @@ protect_stdout:; was_signal_handling= 1; } else { - ret= Xorriso_count_args(xorriso, argc-i, argv+i, &arg_count, 1); - if(ret==1) + ret= Xorriso_count_args(xorriso, argc - i, argv + i, &arg_count, 1); + if(ret == 1) { i+= arg_count; + } else if((was_dashed && xorriso->add_plainly <= 1) || + xorriso->add_plainly <= 0) { + sprintf(xorriso->info_text, "Not a known option: '%s'\n", + original_cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + error_seen= 1; + } } } ret= 1; ex:; strcpy(xorriso->list_delimiter, mem_list_delimiter); + xorriso->add_plainly= mem_add_plainly; Xorriso_free_meM(cmd_data); + if(error_seen && ret > 0) { + advice= Xorriso_eval_problem_status(xorriso, 0, 0); + if(advice < 0) + ret= -1; + } return(ret); } diff --git a/xorriso/xorriso.h b/xorriso/xorriso.h index af771288..5da50198 100644 --- a/xorriso/xorriso.h +++ b/xorriso/xorriso.h @@ -240,8 +240,9 @@ int Xorriso_destroy(struct XorrisO **xorriso, int flag); -prog_help , -help , -no_rc Some get examined for the need to redirect stdout messages -dev , -outdev , -indev , -as - Command -list_delimiter gets into effect during this call. But the - setting at begin of the call gets restored before the call returns. + Commands -list_delimiter and -add_plainly get into effect during this + call. But their setting at begin of the call gets restored before the + call returns. @param xorriso The context object in which to perform the commands. @param argc Number of arguments. @param argv The arguments. argv[0] contains the program name. diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 4ef7590c..de4a2a56 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2011.05.16.133231" +#define Xorriso_timestamP "2011.05.16.134341"