New option -assert_volid
This commit is contained in:
@ -1745,6 +1745,31 @@ int Sregex_resolve_var(char *form, char *vars[][2], int num_vars,
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= only test expression whether compilable
|
||||
*/
|
||||
int Sregex_match(char *pattern, char *text, int flag)
|
||||
{
|
||||
int ret;
|
||||
char re_text[2*SfileadrL];
|
||||
regex_t re;
|
||||
regmatch_t match[1];
|
||||
|
||||
Xorriso__bourne_to_reg(pattern, re_text, 0);
|
||||
ret= regcomp(&re, re_text, 0);
|
||||
if(ret != 0)
|
||||
return(-1);
|
||||
if(flag & 1) {
|
||||
regfree(&re);
|
||||
return(1);
|
||||
}
|
||||
ret= regexec(&re, text, 1, match, 0);
|
||||
regfree(&re);
|
||||
if(ret != 0)
|
||||
return(0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* Xorriso_sregex_externaL */
|
||||
|
||||
|
||||
@ -3805,8 +3830,10 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
||||
m->do_global_uid= 0;
|
||||
m->global_uid= 0;
|
||||
strcpy(m->volid, "ISOIMAGE");
|
||||
m->loaded_volid[0]= 0;
|
||||
m->volid_default= 1;
|
||||
m->loaded_volid[0]= 0;
|
||||
m->assert_volid[0]= 0;
|
||||
m->assert_volid_sev[0]= 0;
|
||||
m->publisher[0]= 0;
|
||||
m->application_id[0]= 0;
|
||||
m->session_logfile[0]= 0;
|
||||
@ -6042,7 +6069,16 @@ 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= (xorriso->assert_volid[0] == 0);
|
||||
sprintf(line, "-assert_volid ");
|
||||
Text_shellsafe(xorriso->assert_volid, line, 1);
|
||||
strcat(line, " ");
|
||||
Text_shellsafe(xorriso->assert_volid_sev, line, 1);
|
||||
strcat(line, "\n");
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
|
||||
do_single= 0;
|
||||
if(filter != NULL)
|
||||
if(strncmp(filter, "-indev", 6) == 0 ||
|
||||
@ -10802,11 +10838,6 @@ int Xorriso_option_application_id(struct XorrisO *xorriso, char *name,
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef NIX
|
||||
Xorriso_set_application_id(xorriso, name, 0);
|
||||
#endif
|
||||
|
||||
if(Sfile_str(xorriso->application_id,name,0)<=0)
|
||||
return(-1);
|
||||
return(1);
|
||||
@ -10864,6 +10895,51 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
/* Option -assert_volid */
|
||||
int Xorriso_option_assert_volid(struct XorrisO *xorriso, char *pattern,
|
||||
char *severity, int flag)
|
||||
{
|
||||
int ret, sev;
|
||||
char *sev_text= "";
|
||||
|
||||
if(strlen(pattern)>=sizeof(xorriso->assert_volid)) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Name too long with option -application_id (%d > %d)",
|
||||
(int) strlen(pattern), (int) sizeof(xorriso->assert_volid)-1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
if(pattern[0]) {
|
||||
ret= Sregex_match(pattern, "", 1);
|
||||
if(ret <= 0) {
|
||||
sprintf(xorriso->info_text, "-assert_volid: Cannot use given pattern.");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if(severity[0] != 0 || pattern[0] != 0) {
|
||||
if(severity[0] == 0) {
|
||||
if(strcmp(xorriso->abort_on_text, "NEVER") == 0)
|
||||
sev_text= "ABORT";
|
||||
else
|
||||
sev_text= xorriso->abort_on_text;
|
||||
} else
|
||||
sev_text= severity;
|
||||
ret= Xorriso__text_to_sev(sev_text, &sev, 0);
|
||||
if(ret<=0) {
|
||||
sprintf(xorriso->info_text, "-assert_volid: Not a known severity name : ");
|
||||
Text_shellsafe(severity, xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(ret);
|
||||
}
|
||||
}
|
||||
if(Sfile_str(xorriso->assert_volid, pattern,0) <= 0)
|
||||
return(-1);
|
||||
strcpy(xorriso->assert_volid_sev, sev_text);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* Option -backslash_codes */
|
||||
int Xorriso_option_backslash_codes(struct XorrisO *xorriso, char *mode,
|
||||
int flag)
|
||||
@ -12876,6 +12952,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" -rom_toc_scan \"on\"|\"off\"[:\"emul_on\"|\"emul_off\"]",
|
||||
" Enable scanning for ISO sessions on read-only drives/media",
|
||||
" resp. on overwriteable media with emulated TOC.",
|
||||
" -assert_volid pattern severity",
|
||||
" Accept input image only if its volume id matches pattern.",
|
||||
" -charset name Set the character set name to be used for file name",
|
||||
" conversion from and to media.",
|
||||
" -in_charset name",
|
||||
@ -15373,7 +15451,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
""
|
||||
};
|
||||
static char arg2_commands[][40]= {
|
||||
"boot_image","compare","compare_r",
|
||||
"assert_volid","boot_image","compare","compare_r",
|
||||
"errfile_log","error_behavior","extract","extract_single",
|
||||
"load","logfile",
|
||||
"map","map_single","page","return_with","update","update_r",
|
||||
@ -15537,6 +15615,10 @@ next_command:;
|
||||
} else if(strcmp(cmd,"as")==0) {
|
||||
ret= Xorriso_option_as(xorriso, argc, argv, idx, 0);
|
||||
|
||||
} else if(strcmp(cmd,"assert_volid")==0) {
|
||||
(*idx)+= 2;
|
||||
ret= Xorriso_option_assert_volid(xorriso, arg1, arg2, 0);
|
||||
|
||||
} else if(strcmp(cmd,"backslash_codes")==0) {
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_backslash_codes(xorriso, arg1, 0);
|
||||
|
Reference in New Issue
Block a user