New option -session_log
This commit is contained in:
@ -1491,6 +1491,7 @@ completed:;
|
||||
|
||||
|
||||
/* @param flag bit0=with year and seconds
|
||||
bit1=timestamp format YYYY.MM.DD.hhmmss
|
||||
*/
|
||||
char *Ftimetxt(time_t t, char timetext[40], int flag)
|
||||
{
|
||||
@ -1504,6 +1505,10 @@ char *Ftimetxt(time_t t, char timetext[40], int flag)
|
||||
rpt[0]= 0;
|
||||
if(tmpt==0)
|
||||
sprintf(rpt+strlen(rpt), "%12.f", (double) t);
|
||||
else if (flag&2)
|
||||
sprintf(rpt+strlen(rpt), "%4.4d.%2.2d.%2.2d.%2.2d%2.2d%2.2d",
|
||||
1900+tms.tm_year, tms.tm_mon, tms.tm_mday,
|
||||
tms.tm_hour, tms.tm_min, tms.tm_sec);
|
||||
else if (flag&1)
|
||||
sprintf(rpt+strlen(rpt), "%2d %3s %4.4d %2.2d:%2.2d:%2.2d",
|
||||
tms.tm_mday, months[tms.tm_mon], 1900+tms.tm_year,
|
||||
@ -2971,8 +2976,11 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
||||
m->global_uid= 0;
|
||||
strcpy(m->volid, "ISOIMAGE");
|
||||
m->loaded_volid[0]= 0;
|
||||
m->publisher[0]= 0;
|
||||
m->volid_default= 1;
|
||||
m->publisher[0]= 0;
|
||||
m->session_logfile[0]= 0;
|
||||
m->session_lba= -1;
|
||||
m->session_blocks= 0;
|
||||
m->do_global_gid= 0;
|
||||
m->global_gid= 0;
|
||||
m->do_global_mode= 0;
|
||||
@ -4287,6 +4295,12 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
|
||||
sprintf(line,"-report_about %s\n",xorriso->report_about_text);
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
|
||||
is_default= (xorriso->session_logfile[0]==0);
|
||||
sprintf(line,"-session_log %s\n",
|
||||
Text_shellsafe(xorriso->session_logfile,sfe,0));
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
|
||||
is_default= (strcmp(xorriso->return_with_text,"SORRY")==0 &&
|
||||
xorriso->return_with_value==32);
|
||||
@ -7760,6 +7774,37 @@ ex:;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_write_session_log(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
FILE *fp= NULL;
|
||||
char sfe[5*SfileadrL], timetext[40], *rpt, *wpt;
|
||||
|
||||
if(xorriso->session_logfile[0]==0)
|
||||
return(2);
|
||||
fp= fopen(xorriso->session_logfile, "a");
|
||||
if(fp==0) {
|
||||
sprintf(xorriso->info_text, "-session_log: Cannot open file %s",
|
||||
Text_shellsafe(xorriso->session_logfile, sfe, 0));
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
wpt= sfe;
|
||||
for(rpt= xorriso->volid; *rpt!=0; rpt++) {
|
||||
if(*rpt=='\n') {
|
||||
*(wpt++)= '\\';
|
||||
*(wpt++)= 'n';
|
||||
} else
|
||||
*(wpt++)= *rpt;
|
||||
}
|
||||
*wpt= 0;
|
||||
fprintf(fp, "%s %d %d %s\n",
|
||||
Ftimetxt(time(0), timetext, 2), xorriso->session_lba,
|
||||
xorriso->session_blocks, sfe);
|
||||
fclose(fp);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------- Options API ------------------------ */
|
||||
|
||||
@ -8468,6 +8513,7 @@ int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
|
||||
Xorriso_process_errfile(xorriso, 0, "burn session end", 0, 1);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
Xorriso_write_session_log(xorriso, 0);
|
||||
xorriso->volset_change_pending= 0;
|
||||
xorriso->no_volset_present= 0;
|
||||
if(flag&1)
|
||||
@ -9520,7 +9566,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" 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.",
|
||||
" -dialog After all arguments are processed, enter dialog mode.",
|
||||
" In this mode you may enter searchtexts or any of the options",
|
||||
" described here. One per line.",
|
||||
" -dialog_reset Revoke -dialog (works only if given as argument)",
|
||||
@ -9572,6 +9618,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" Wait for Enter key resp. for a line of input at stdin.",
|
||||
" -errfile_log mode path|channel",
|
||||
" Log disk paths of files involved in problem events.",
|
||||
" -session_log path",
|
||||
" Set path of a file where a log record gets appended after",
|
||||
" each session. Form: timestamp start_lba size volume-id",
|
||||
" # any text Is ignored. In dialog mode the input line will be stored in",
|
||||
" the eventual readline history, nevertheless.",
|
||||
" -version Tell program and version number",
|
||||
@ -10508,6 +10557,15 @@ int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
|
||||
/* Option -session_log */
|
||||
int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag)
|
||||
{
|
||||
if(Sfile_str(xorriso->session_logfile, path, 0)<=0)
|
||||
return(-1);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* Option -speed */
|
||||
int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag)
|
||||
{
|
||||
@ -11244,6 +11302,10 @@ next_command:;
|
||||
if(end_ret!=2)
|
||||
{ret= 3; goto ex;}
|
||||
|
||||
} else if(strcmp(cmd,"session_log")==0) {
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_session_log(xorriso, arg1, 0);
|
||||
|
||||
} else if(strcmp(cmd,"speed")==0) {
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_speed(xorriso, arg1, 0);
|
||||
|
Reference in New Issue
Block a user