New flag bit1 of API call Xorriso_prescan_args() reports unknown commands

This commit is contained in:
Thomas Schmitt 2011-05-17 15:16:56 +00:00
parent 55d6788bb6
commit f28da0c7ce
4 changed files with 22 additions and 12 deletions

View File

@ -1624,15 +1624,17 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
"stdio:/dev/fd/1" is interpreted as drive address. "stdio:/dev/fd/1" is interpreted as drive address.
*/ */
protect_stdout:; protect_stdout:;
Xorriso_protect_stdout(xorriso, 0); ret= Xorriso_protect_stdout(xorriso, 0);
sprintf(xorriso->info_text, if(ret == 1) {
sprintf(xorriso->info_text,
"Encountered - or stdio:/dev/fd/1 as possible write target."); "Encountered - or stdio:/dev/fd/1 as possible write target.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Redirecting nearly all text message output to stderr."); "Redirecting nearly all text message output to stderr.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
sprintf(xorriso->info_text, "Disabling use of libreadline."); sprintf(xorriso->info_text, "Disabling use of libreadline.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
}
} else if(strcmp(cmd,"abort_on")==0 && was_dashed == 1) { } else if(strcmp(cmd,"abort_on")==0 && was_dashed == 1) {
i++; i++;
@ -1691,8 +1693,8 @@ protect_stdout:;
ret= Xorriso_count_args(xorriso, argc - i, argv + i, &arg_count, 1); ret= Xorriso_count_args(xorriso, argc - i, argv + i, &arg_count, 1);
if(ret == 1) { if(ret == 1) {
i+= arg_count; i+= arg_count;
} else if((was_dashed && xorriso->add_plainly <= 1) || } else if((flag & 2) && ((was_dashed && xorriso->add_plainly <= 1) ||
xorriso->add_plainly <= 0) { xorriso->add_plainly <= 0)) {
sprintf(xorriso->info_text, "Not a known option: '%s'\n", sprintf(xorriso->info_text, "Not a known option: '%s'\n",
original_cmd); original_cmd);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);

View File

@ -252,6 +252,8 @@ int Xorriso_destroy(struct XorrisO **xorriso, int flag);
*idx will iterate over commands and parameters until this *idx will iterate over commands and parameters until this
function aborts or until argc is reached. function aborts or until argc is reached.
@param flag bit0= do not interpret argv[1] @param flag bit0= do not interpret argv[1]
bit1= produce FAILURE events on unknown commands
@since 1.1.0
@return <0 error @return <0 error
0 end program 0 end program
1 ok, go on 1 ok, go on

View File

@ -226,14 +226,20 @@ int main(int argc, char **argv)
/* The prescan of arguments performs actions which have to happen before /* The prescan of arguments performs actions which have to happen before
the normal processing of startup files and arguments. the normal processing of startup files and arguments.
Among them are -help and -prog_help which end the program without
yelling its name and version.
*/ */
ret= Xorriso_prescan_args(xorriso,argc,argv,0); ret= Xorriso_prescan_args(xorriso,argc,argv,0);
if(ret == 0) if(ret == 0)
goto end_successfully; goto end_successfully;
/* Put out program name and version to stderr only if not done already now */
yell_xorriso();
if(ret < 0)
exit(5);
/* After having yelled xorriso, prescan again for unknown arguments */
ret= Xorriso_prescan_args(xorriso, argc, argv, 2);
if(ret < 0) if(ret < 0)
exit(5); exit(5);
yell_xorriso();
/* The following command interpreters are allowed only after this /* The following command interpreters are allowed only after this
initialization. initialization.

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.05.16.134341" #define Xorriso_timestamP "2011.05.17.151719"