New option -return_with
This commit is contained in:
parent
9d4709e4a5
commit
8105a9d455
@ -972,16 +972,43 @@ bootimage which is present on the input media.
|
||||
Most safe is the default: "any" "discard".
|
||||
.TP
|
||||
.B Exception processing:
|
||||
.PP
|
||||
Since the tasks of xorriso are manifold and prone to external influence, there
|
||||
may arise the need for xorriso to report and handle problem events.
|
||||
.br
|
||||
Those events get classified when they are detected by one of the software
|
||||
modules and forwarded to reporting and evaluation modules which decide about
|
||||
reactions. Event classes are sorted by severity:
|
||||
.br
|
||||
"NEVER" The upper end of the severity spectrum.
|
||||
.br
|
||||
"ABORT" The program is being aborted and on its way to end.
|
||||
.br
|
||||
"FATAL" The main purpose of the run failed
|
||||
or an important resource failed unexpectedly.
|
||||
.br
|
||||
"FAILURE" An important part of the job could not be performed.
|
||||
.br
|
||||
"SORRY" A less important part could not be performed or
|
||||
source file access problems have been ignored at image generation time.
|
||||
.br
|
||||
"WARNING" A situation is suspicious of being not intended by the user.
|
||||
.br
|
||||
"HINT" A proposal to the user how to achieve better results.
|
||||
.br
|
||||
"NOTE" A harmless information about noteworthy cuircumstances.
|
||||
.br
|
||||
"UPDATE" A pacifier message during long running operations.
|
||||
.br
|
||||
"DEBUG" A message which would only interest the program developers.
|
||||
.br
|
||||
"ALL" The lower end of the severity spectrum.
|
||||
.PP
|
||||
.TP
|
||||
\fB\-abort_on\fR severity
|
||||
Set the threshold for events to abort the program.
|
||||
Events are classified by severity. In decreasing order:
|
||||
Set the severity threshold for events to abort the program.
|
||||
.br
|
||||
"NEVER", "ABORT", "FATAL", "FAILURE" , "SORRY",
|
||||
"WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL"
|
||||
.br
|
||||
Severities "NEVER" and "ALL" do not occur but mark the extreme
|
||||
ends of this potentially expandable range.
|
||||
Useful: "NEVER", "ABORT", "FATAL", "FAILURE" , "SORRY"
|
||||
.br
|
||||
It may become necessary to abort the program anyway, despite
|
||||
the setting by this option. Expect not many "ABORT" events to
|
||||
@ -992,10 +1019,33 @@ program start argument. I.e. the first -abort_on setting among the
|
||||
start arguments is in effect already when the first operations of xorriso
|
||||
begin. Only "-abort_on" with dash "-" is recognized that way.
|
||||
.TP
|
||||
\fB\-return_with\fR severity exit_value
|
||||
Set the threshhold and exit_value to be returned at program end if no abort
|
||||
has happened. This is to allow xorriso to go on after problems but to get
|
||||
a failure indicating exit value from the program, nevertheless.
|
||||
Useful are the same values as with -abort_on, plus "WARNING".
|
||||
.br
|
||||
exit_value may be either 0 (indicating success to the starter of the program)
|
||||
or a number between 32 and 63. Some other exit_values are used by xorriso if
|
||||
it decides to abort the program run:
|
||||
.br
|
||||
1=abort due to external signal
|
||||
.br
|
||||
2=no program arguments given
|
||||
.br
|
||||
3=creation of xorriso main object failed
|
||||
.br
|
||||
4=failure to start libburnia-project.org libraries
|
||||
.br
|
||||
5=program abort during argument processing
|
||||
.br
|
||||
6=program abort during dialog processing
|
||||
.TP
|
||||
\fB\-report_about\fR severity
|
||||
Set the threshold for events to be reported.
|
||||
Events are the same as with -abort_on. Regardless what is
|
||||
set by -report_about, messages get always reported if they
|
||||
.br
|
||||
Useful: "SORRY", "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL"
|
||||
Regardless what is set by -report_about, messages get always reported if they
|
||||
reach the severity threshold of -abort_on .
|
||||
.br
|
||||
Event messages are sent to the info channel "I" which is usually stderr
|
||||
|
@ -2731,6 +2731,11 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
||||
Xorriso__text_to_sev(m->abort_on_text, &m->abort_on_severity, 0);
|
||||
m->problem_status= 0;
|
||||
m->problem_status_text[0]= 0;
|
||||
strcpy(m->return_with_text, "SORRY");
|
||||
Xorriso__text_to_sev(m->return_with_text, &m->return_with_severity, 0);
|
||||
m->return_with_value= 32;
|
||||
m->eternal_problem_status= 0;
|
||||
m->eternal_problem_status_text[0]= 0;
|
||||
#ifdef Xorriso_with_regeX
|
||||
m->re= NULL;
|
||||
/* >>> ??? how to initialize m->match[0] ? */
|
||||
@ -3964,6 +3969,11 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
|
||||
is_default= (strcmp(xorriso->return_with_text,"SORRY")==0);
|
||||
sprintf(line,"-return_with %s\n",xorriso->return_with_text);
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
|
||||
is_default= (strcmp(xorriso->abort_on_text,"FATAL")==0);
|
||||
sprintf(line,"-abort_on %s\n",xorriso->abort_on_text);
|
||||
if(!(is_default && no_defaults))
|
||||
@ -4682,6 +4692,10 @@ int Xorriso_set_problem_status(struct XorrisO *xorriso, char *severity,
|
||||
return(0);
|
||||
xorriso->problem_status= sev;
|
||||
strcpy(xorriso->problem_status_text, sev_text);
|
||||
if(sev > xorriso->eternal_problem_status) {
|
||||
xorriso->eternal_problem_status= sev;
|
||||
strcpy(xorriso->eternal_problem_status_text, sev_text);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
@ -4717,6 +4731,10 @@ int Xorriso_msgs_submit(struct XorrisO *xorriso,
|
||||
xorriso->problem_status= sev;
|
||||
strcpy(xorriso->problem_status_text, sev_text);
|
||||
}
|
||||
if(xorriso->eternal_problem_status<sev) {
|
||||
xorriso->eternal_problem_status= sev;
|
||||
strcpy(xorriso->eternal_problem_status_text, sev_text);
|
||||
}
|
||||
|
||||
/* Report problem event */
|
||||
if(sev<xorriso->report_about_severity && sev<xorriso->abort_on_severity)
|
||||
@ -7279,6 +7297,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" -help Print this text",
|
||||
" -abort_on severity Set the threshhold for events to abort the program.",
|
||||
" Useful severities: NEVER, ABORT, FATAL, FAILURE, SORRY, WARNING",
|
||||
" -return_with severity exit_value Set the threshhold for events to return",
|
||||
" at program end the given exit_value even if not aborted.",
|
||||
" exit_value may be 0 or 32 to 63.",
|
||||
" -report_about severity Set the threshhold for events to be reported.",
|
||||
" Use -abort_on severities or: HINT, NOTE, UPDATE, DEBUG, ALL",
|
||||
" -dialog after all arguments are processed, enter dialog mode.",
|
||||
@ -8078,6 +8099,34 @@ int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity,
|
||||
}
|
||||
|
||||
|
||||
/* Option -return_with */
|
||||
int Xorriso_option_return_with(struct XorrisO *xorriso, char *severity,
|
||||
int exit_value, int flag)
|
||||
{
|
||||
int ret, sev;
|
||||
char sfe[5*SfileadrL];
|
||||
|
||||
ret= Xorriso__text_to_sev(severity, &sev, 0);
|
||||
if(ret<=0) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-return_with: Not a known severity name : %s",
|
||||
Text_shellsafe(severity, sfe, 0));
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(ret);
|
||||
}
|
||||
if(exit_value && (exit_value < 32 || exit_value > 63)) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-return_with: Not an allowed exit_value. Use 0, or 32 to 63.");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
if(Sfile_str(xorriso->return_with_text,severity,0)<=0)
|
||||
return(-1);
|
||||
xorriso->return_with_severity= sev;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */
|
||||
/* @param flag bit0=recursive , bit2= remove empty directory: rmdir */
|
||||
int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv,
|
||||
@ -8724,6 +8773,12 @@ next_command:;
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_report_about(xorriso, arg1, 0);
|
||||
|
||||
} else if(strcmp(cmd,"return_with")==0) {
|
||||
(*idx)+= 2;
|
||||
num2= 0;
|
||||
sscanf(arg2,"%d",&num2);
|
||||
ret= Xorriso_option_return_with(xorriso, arg1, num2, 0);
|
||||
|
||||
} else if(strcmp(cmd,"rm")==0 || strcmp(cmd,"rmi")==0) {
|
||||
ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 0);
|
||||
|
||||
@ -8975,8 +9030,9 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
1 ok, go on
|
||||
*/
|
||||
{
|
||||
int i, ret, was_dashed, was_report_about= 0, was_abort_on;
|
||||
char *cmd, *arg1;
|
||||
int i, ret, was_dashed, num2;
|
||||
int was_report_about= 0, was_abort_on= 0, was_return_with= 0;
|
||||
char *cmd, *arg1, *arg2;
|
||||
|
||||
for(i=1+(flag&1);i<argc;i++) {
|
||||
cmd= argv[i];
|
||||
@ -8988,6 +9044,9 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
arg1= "";
|
||||
if(i+1<argc)
|
||||
arg1= argv[i+1];
|
||||
arg2= "";
|
||||
if(i+2<argc)
|
||||
arg2= argv[2+1];
|
||||
if(i>1)
|
||||
xorriso->did_something_useful= 1;
|
||||
if(i==1 && argc==2) {
|
||||
@ -9044,6 +9103,14 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
Xorriso_option_report_about(xorriso, arg1, 0);
|
||||
was_report_about= 1;
|
||||
|
||||
} else if(strcmp(cmd,"return_with")==0 && was_dashed) {
|
||||
i+= 2;
|
||||
num2= 0;
|
||||
sscanf(arg2,"%d",&num2);
|
||||
if(!was_return_with)
|
||||
Xorriso_option_return_with(xorriso, arg1, num2, 0);
|
||||
was_return_with= 1;
|
||||
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
@ -9077,6 +9144,23 @@ int Xorriso_read_rc(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_make_return_value(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
int exit_value= 0;
|
||||
|
||||
if(xorriso->eternal_problem_status >= xorriso->return_with_severity)
|
||||
exit_value= xorriso->return_with_value;
|
||||
if(exit_value) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-return_with %s %d triggered by problem severity %s",
|
||||
xorriso->return_with_text, exit_value,
|
||||
xorriso->eternal_problem_status_text);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
}
|
||||
return(exit_value);
|
||||
}
|
||||
|
||||
|
||||
#ifdef Xorriso_with_maiN
|
||||
|
||||
int main(int argc, char **argv)
|
||||
@ -9151,7 +9235,8 @@ end_sucessfully:;
|
||||
if(xorriso->volset_change_pending)
|
||||
Xorriso_option_end(xorriso, 2);
|
||||
Xorriso_process_msg_queues(xorriso, 0);
|
||||
ret= Xorriso_make_return_value(xorriso, 0);
|
||||
Xorriso_destroy(&xorriso,1);
|
||||
exit(0);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -372,6 +372,10 @@ int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag);
|
||||
int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity,
|
||||
int flag);
|
||||
|
||||
/* Option -return_with */
|
||||
int Xorriso_option_return_with(struct XorrisO *xorriso, char *severity,
|
||||
int exit_value, int flag);
|
||||
|
||||
/* Option -reassure "on"|"tree"|"off" */
|
||||
int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag);
|
||||
|
||||
|
@ -159,6 +159,12 @@ struct XorrisO { /* the global context of xorriso */
|
||||
int problem_status; /* Severity rank number. 0= no abort condition present */
|
||||
char problem_status_text[20];
|
||||
|
||||
char return_with_text[20];
|
||||
int return_with_severity;
|
||||
int return_with_value;
|
||||
int eternal_problem_status;
|
||||
char eternal_problem_status_text[20];
|
||||
|
||||
/* temporary search facilities */
|
||||
#ifdef Xorriso_with_regeX
|
||||
regex_t *re;
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2008.02.11.113235"
|
||||
#define Xorriso_timestamP "2008.02.11.135418"
|
||||
|
Loading…
Reference in New Issue
Block a user