|
|
|
@ -1772,6 +1772,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
|
|
|
|
for(i=0; i<4; i++)
|
|
|
|
|
m->logfile[i][0]= 0;
|
|
|
|
|
m->status_history_max= Xorriso_status_history_maX;
|
|
|
|
|
m->library_msg_direct_print= 0;
|
|
|
|
|
strcpy(m->abort_on_text,"FATAL");
|
|
|
|
|
Xorriso__text_to_sev(m->abort_on_text, &m->abort_on_severity, 0);
|
|
|
|
|
m->problem_status= 0;
|
|
|
|
@ -2316,9 +2317,9 @@ int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag)
|
|
|
|
|
if(xorriso->search_mode==2 ||
|
|
|
|
|
(xorriso->search_mode==3 && xorriso->structured_search==0)) {
|
|
|
|
|
no_regex_available:;
|
|
|
|
|
sprintf(xorriso->info_text,"%s : regular expressions not implemented\n",
|
|
|
|
|
sprintf(xorriso->info_text,"%s : regular expressions not implemented",
|
|
|
|
|
xorriso->progname);
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2328,8 +2329,8 @@ no_regex_available:;
|
|
|
|
|
if(xorriso->search_mode==3 || xorriso->search_mode==4) {
|
|
|
|
|
l= strlen(adr)+strlen(xorriso->wdi)+1;
|
|
|
|
|
if(l*2+2>sizeof(xorriso->reg_expr) || l*2+2>sizeof(adr_part)) {
|
|
|
|
|
sprintf(xorriso->info_text,"%s : search text too long\n",xorriso->progname);
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
sprintf(xorriso->info_text,"Search pattern too long");
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2426,8 +2427,8 @@ no_regex_available:;
|
|
|
|
|
#else /* Xorriso_with_regeX */
|
|
|
|
|
if(!warned_of_regex) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"=== Note: no wildcards get recognized besides single '*'\n");
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
"No wildcards get recognized besides single '*'");
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",0);
|
|
|
|
|
warned_of_regex= 1;
|
|
|
|
|
}
|
|
|
|
|
if(Sregex_string(&(xorriso->re_constants[xorriso->re_fill]),adr_part,0)
|
|
|
|
@ -2445,9 +2446,8 @@ next_adr_part:;
|
|
|
|
|
cpt++;
|
|
|
|
|
}
|
|
|
|
|
if(bonked) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"=== Note: Your '..' bonked at the root directory.\n");
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
sprintf(xorriso->info_text, "Your '..' bonked at the root directory.");
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Xorriso__bourne_to_reg(adr_start,xorriso->reg_expr,0); /* just for show */
|
|
|
|
@ -2485,14 +2485,15 @@ next_adr_part:;
|
|
|
|
|
return(-1);
|
|
|
|
|
if(regcomp(&(xorriso->re[0]),xorriso->reg_expr,0)!=0) {
|
|
|
|
|
cannot_compile:;
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"%s : cannot compile regular expression : %s\n",
|
|
|
|
|
xorriso->progname,xorriso->reg_expr);
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
sprintf(xorriso->info_text, "Cannot compile regular expression : %s",
|
|
|
|
|
xorriso->reg_expr);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY",0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
#else /* Xorriso_with_regeX */
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"No wildcards get recognized besides single '*'");
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",0);
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
if(Sregex_string(&(xorriso->re_constants[0]),adr,0)<=0)
|
|
|
|
|
return(-1);
|
|
|
|
@ -2866,6 +2867,12 @@ int Xorriso_exec(struct XorrisO *xorriso, char *cmd, int flag)
|
|
|
|
|
int is_done= 0,argc= 0,widx= 0,cmd_l,pass,ret;
|
|
|
|
|
|
|
|
|
|
cmd_l= strlen(cmd);
|
|
|
|
|
if(cmd_l>SfileadrL) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Command for external process too long : %d (max %d)",
|
|
|
|
|
cmd_l, SfileadrL);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
}
|
|
|
|
|
for(pass=0;pass<2;pass++) {
|
|
|
|
|
is_done= 0;
|
|
|
|
|
widx= 0;
|
|
|
|
@ -2900,12 +2907,11 @@ int Xorriso_exec(struct XorrisO *xorriso, char *cmd, int flag)
|
|
|
|
|
for(widx=0; widx<cmd_l; widx++)
|
|
|
|
|
if(cmd[widx]==0)
|
|
|
|
|
cmd[widx]= ' ';
|
|
|
|
|
sprintf(xorriso->info_text,"--- failed : %s\n",cmd);
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
if(errmsg[0]!=0) {
|
|
|
|
|
sprintf(xorriso->info_text,"--- message: %s\n",errmsg);
|
|
|
|
|
Xorriso_info(xorriso,1);
|
|
|
|
|
}
|
|
|
|
|
sprintf(xorriso->info_text,"External process failed : %s",cmd);
|
|
|
|
|
if(errmsg[0]!=0)
|
|
|
|
|
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
|
|
|
|
"message: %s\n",errmsg);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
|
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
|
}
|
|
|
|
|
ret= 1;
|
|
|
|
@ -2954,6 +2960,10 @@ int Xorriso_set_problem_status(struct XorrisO *xorriso, char *severity,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Note: It is ok to submit xorriso->info_text as msg_text here. */
|
|
|
|
|
/* flag:
|
|
|
|
|
bit0= for Xorriso_info() : use pager (as with result)
|
|
|
|
|
bit1= for Xorriso_info() : permission to suppress output
|
|
|
|
|
*/
|
|
|
|
|
int Xorriso_msgs_submit(struct XorrisO *xorriso,
|
|
|
|
|
int error_code, char msg_text[], int os_errno,
|
|
|
|
|
char severity[], int flag)
|
|
|
|
@ -2973,6 +2983,9 @@ int Xorriso_msgs_submit(struct XorrisO *xorriso,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Report problem event */
|
|
|
|
|
|
|
|
|
|
/* >>> need option with threshhold for message reporting */
|
|
|
|
|
|
|
|
|
|
sprintf(prefix,"xorriso : %s : ", sev_text);
|
|
|
|
|
li= strlen(prefix);
|
|
|
|
|
lt= strlen(msg_text);
|
|
|
|
@ -2989,17 +3002,48 @@ int Xorriso_msgs_submit(struct XorrisO *xorriso,
|
|
|
|
|
}
|
|
|
|
|
xorriso->info_text[li+lt]= '\n';
|
|
|
|
|
xorriso->info_text[li+lt+1]= 0;
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
Xorriso_info(xorriso,flag&3);
|
|
|
|
|
if(os_errno>0) {
|
|
|
|
|
/* >>> report errno and strerror */;
|
|
|
|
|
|
|
|
|
|
/* (errno > 0 ? strerror(errno) : "unknown error"), errno); */
|
|
|
|
|
|
|
|
|
|
sprintf(xorriso->info_text, "xorriso : system: %s (%d)\n",
|
|
|
|
|
strerror(os_errno), os_errno);
|
|
|
|
|
Xorriso_info(xorriso,flag&3);
|
|
|
|
|
}
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_eval_problem_status(struct XorrisO *xorriso, int ret, int flag)
|
|
|
|
|
{
|
|
|
|
|
static int sev= 0;
|
|
|
|
|
|
|
|
|
|
if(sev==0)
|
|
|
|
|
Xorriso__text_to_sev("SORRY", &sev, 0);
|
|
|
|
|
|
|
|
|
|
Xorriso_process_msg_queues(xorriso, 0);
|
|
|
|
|
if(ret>0 && xorriso->problem_status <= 0)
|
|
|
|
|
return(1);
|
|
|
|
|
|
|
|
|
|
if(xorriso->problem_status < xorriso->abort_on_severity &&
|
|
|
|
|
xorriso->problem_status > 0) {
|
|
|
|
|
if(xorriso->problem_status >= sev) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"xorriso : NOTE : Tolerated problem event of severity '%s'\n",
|
|
|
|
|
xorriso->problem_status_text);
|
|
|
|
|
Xorriso_info(xorriso, 0);/* submit not as problem event */
|
|
|
|
|
}
|
|
|
|
|
ret= 2;
|
|
|
|
|
} else if(xorriso->problem_status > 0) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"xorriso : ABORT : -abort_on '%s' encountered '%s'",
|
|
|
|
|
xorriso->abort_on_text, xorriso->problem_status_text);
|
|
|
|
|
Xorriso_info(xorriso, 0);/* submit not as problem event */
|
|
|
|
|
ret= -1;
|
|
|
|
|
} else if(ret>0)
|
|
|
|
|
ret= 1;
|
|
|
|
|
return(ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ---------------------------- Options API ------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3104,9 +3148,9 @@ int Xorriso_option_cdi(struct XorrisO *xorriso, char *iso_rr_path, int flag)
|
|
|
|
|
int ret, l;
|
|
|
|
|
|
|
|
|
|
if (strlen(iso_rr_path)>sizeof(xorriso->wdi)) {
|
|
|
|
|
sprintf(xorriso->info_text,"%s: -cdi: iso_rr_path too long (%d > %d)\n",
|
|
|
|
|
xorriso->progname, strlen(iso_rr_path), sizeof(xorriso->wdi)-1);
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
sprintf(xorriso->info_text,"-cdi: iso_rr_path too long (%d > %d)",
|
|
|
|
|
strlen(iso_rr_path), sizeof(xorriso->wdi)-1);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
sprintf(xorriso->info_text,"previous working directory:\n");
|
|
|
|
@ -3148,9 +3192,9 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag)
|
|
|
|
|
int ret, l;
|
|
|
|
|
|
|
|
|
|
if (strlen(disk_path)>sizeof(xorriso->wdx)) {
|
|
|
|
|
sprintf(xorriso->info_text,"%s: -cdx: disk_path too long (%d > %d)\n",
|
|
|
|
|
xorriso->progname, strlen(disk_path), sizeof(xorriso->wdx)-1);
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
sprintf(xorriso->info_text,"-cdx: disk_path too long (%d > %d)",
|
|
|
|
|
strlen(disk_path), sizeof(xorriso->wdx)-1);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
sprintf(xorriso->info_text,"previous working directory on hard disk:\n");
|
|
|
|
@ -3166,13 +3210,14 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag)
|
|
|
|
|
ret= 1;
|
|
|
|
|
ret= Sfile_type(disk_path,1|4|8);
|
|
|
|
|
if(ret<0) {
|
|
|
|
|
sprintf(xorriso->info_text,"-cdx: file not found :\n%s\n",disk_path);
|
|
|
|
|
sprintf(xorriso->info_text,"-cdx: file not found :\n%s",disk_path);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
if(ret!=2) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"-cdx: file is not a directory :\n%s\n",disk_path);
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
"-cdx: file is not a directory :\n%s",disk_path);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
if(Sfile_str(xorriso->wdx,disk_path,0)<=0)
|
|
|
|
@ -3800,8 +3845,8 @@ int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel,
|
|
|
|
|
|
|
|
|
|
if(channel[0]==0) {
|
|
|
|
|
logfile_wrong_form:;
|
|
|
|
|
sprintf(xorriso->info_text,"--- Wrong form. Correct would be: -logfile \".\"|\"R\"|\"I\"|\"M\" file_address\n");
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
sprintf(xorriso->info_text,"Wrong form. Correct would be: -logfile \".\"|\"R\"|\"I\"|\"M\" file_address");
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
hflag= 2;
|
|
|
|
@ -3820,10 +3865,8 @@ logfile_wrong_form:;
|
|
|
|
|
xorriso->logfile[channel_no][0]= 0;
|
|
|
|
|
ret= Write_to_channel(fileadr,channel_no,hflag);
|
|
|
|
|
if(ret<=0) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"--- Cannot open logfile: %s\n %s\n",
|
|
|
|
|
fileadr,(errno>0?strerror(errno):"-unknown error-"));
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
sprintf(xorriso->info_text, "Cannot open logfile: %s", fileadr);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
} else if(!(hflag&(1<<15)))
|
|
|
|
|
if(Sfile_str(xorriso->logfile[channel_no], fileadr, 0)<=0)
|
|
|
|
|
return(-1);
|
|
|
|
@ -3906,8 +3949,8 @@ return:
|
|
|
|
|
char **argv= NULL;
|
|
|
|
|
|
|
|
|
|
if(adr[0]==0) {
|
|
|
|
|
sprintf(xorriso->info_text,"--- Empty file name with -options_from_file\n");
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
sprintf(xorriso->info_text,"Empty file name given with -options_from_file");
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
Text_shellsafe(adr,shellsafe,0);
|
|
|
|
@ -3956,9 +3999,9 @@ ex:;
|
|
|
|
|
fclose(fp);
|
|
|
|
|
if(ret<=0) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"--- error triggered by line %d of file:\n %s\n",
|
|
|
|
|
linecount,shellsafe);
|
|
|
|
|
Xorriso_info(xorriso,1);
|
|
|
|
|
"error triggered by line %d of file:\n %s\n",
|
|
|
|
|
linecount,shellsafe);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 1);
|
|
|
|
|
}
|
|
|
|
|
return(ret);
|
|
|
|
|
}
|
|
|
|
@ -3977,9 +4020,9 @@ int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag)
|
|
|
|
|
{
|
|
|
|
|
if(len<0 || width<=0) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"--- Improper numeric value of arguments of -page: %d %d\n",
|
|
|
|
|
"Improper numeric value of arguments of -page: %d %d",
|
|
|
|
|
len, width);
|
|
|
|
|
Xorriso_info(xorriso,1);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
xorriso->result_page_length= len;
|
|
|
|
@ -4032,9 +4075,9 @@ int Xorriso_option_prog(struct XorrisO *xorriso, char *name, int flag)
|
|
|
|
|
{
|
|
|
|
|
if(strlen(name)>=sizeof(xorriso->progname)) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"--- Name too long with option -prog (%d > %d)\n",
|
|
|
|
|
strlen(name), sizeof(xorriso->progname)-1);
|
|
|
|
|
Xorriso_info(xorriso,1);
|
|
|
|
|
"Name too long with option -prog (%d > %d)",
|
|
|
|
|
strlen(name), sizeof(xorriso->progname)-1);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
if(Sfile_str(xorriso->progname,name,0)<=0)
|
|
|
|
@ -4634,7 +4677,7 @@ next_command:;
|
|
|
|
|
"=== Input line beginning with '-' is not a known option\n");
|
|
|
|
|
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
|
|
|
|
"=== '%s'\n",cmd);
|
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
@ -4644,19 +4687,11 @@ next_command:;
|
|
|
|
|
sprintf(xorriso->info_text, "Ignored argument : '%s'", cmd);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
|
|
|
|
}
|
|
|
|
|
if(ret<=0) {
|
|
|
|
|
if(xorriso->problem_status < xorriso->abort_on_severity &&
|
|
|
|
|
xorriso->problem_status > 0) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"xorriso: NOTE : Tolerated problem event of severity '%s'",
|
|
|
|
|
xorriso->problem_status_text);
|
|
|
|
|
Xorriso_info(xorriso, 0);/* submit as info output, not as problem event */
|
|
|
|
|
ret= 2;
|
|
|
|
|
} else if(xorriso->problem_status > 0) {
|
|
|
|
|
ret= -1; goto ex;
|
|
|
|
|
} else
|
|
|
|
|
goto ex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret= Xorriso_eval_problem_status(xorriso, ret, 0);
|
|
|
|
|
if(ret<0)
|
|
|
|
|
return(ret);
|
|
|
|
|
|
|
|
|
|
if(*idx<argc)
|
|
|
|
|
goto next_command;
|
|
|
|
|
|
|
|
|
@ -4873,6 +4908,7 @@ int Xorriso_main(int argc, char **argv)
|
|
|
|
|
ret= Xorriso_startup_libraries(xorriso, 0);
|
|
|
|
|
if(ret<=0)
|
|
|
|
|
exit(4);
|
|
|
|
|
Xorriso_process_msg_queues(xorriso, 0);
|
|
|
|
|
|
|
|
|
|
/* Interpret startup file */
|
|
|
|
|
if(!xorriso->no_rc) {
|
|
|
|
@ -4897,6 +4933,7 @@ int Xorriso_main(int argc, char **argv)
|
|
|
|
|
exit(6);
|
|
|
|
|
}
|
|
|
|
|
end_sucessfully:;
|
|
|
|
|
Xorriso_process_msg_queues(xorriso, 0);
|
|
|
|
|
Xorriso_destroy(&xorriso,0);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|