New command -msg_op

This commit is contained in:
Thomas Schmitt 2012-12-08 17:55:58 +00:00
parent db6e65dde8
commit c86aafaa0f
14 changed files with 593 additions and 138 deletions

View File

@ -227,6 +227,7 @@ Xorriso_option_md5;
Xorriso_option_mkdiri;
Xorriso_option_mount;
Xorriso_option_mount_opts;
Xorriso_option_msg_op;
Xorriso_option_mvi;
Xorriso_option_no_rc;
Xorriso_option_not_leaf;

View File

@ -331,6 +331,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->msgw_msg_pending= 0;
m->msgw_fetch_lock_ini= 0;
m->msg_sieve= NULL;
m->msg_sieve_disabled= 0;
m->msglist_stackfill= 0;
m->status_history_max= Xorriso_status_history_maX;
m->scsi_log= 0;

View File

@ -2076,6 +2076,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" packet payload. Example of a info message with newline:",
" I:1: enter option text :",
" -pkt_output:on is intended for use by frontend programs.",
" -msg_op \"start_sieve\"|\"read_sieve\"|\"clear_sieve\"|\"end_sieve\"|\"parse\"",
" Enable, use, or disable message sieve. Or parse line into",
" words.",
" -logfile channel fileaddress Copy output of a channel to the given file.",
" channel may be 'R','I','M' as with -pkt_output or '.'",
" for the consolidated -pkt_output stream.",

View File

@ -838,6 +838,146 @@ unknown_mode:;
}
/* Command -msg_op */
int Xorriso_option_msg_op(struct XorrisO *xorriso, char *what, char *arg,
int flag)
{
int ret, available, argc, pargc, i, pflag, max_words, input_lines, l, msd_mem;
char **argv= NULL, **pargv= NULL, *msg= "";
char *pline= NULL, *prefix, *separators;
msd_mem= xorriso->msg_sieve_disabled;
Xorriso_alloc_meM(pline, char, SfileadrL);
ret= 1;
if(strcmp(what, "parse") == 0) {
ret= Xorriso_parse_line(xorriso, arg, "", "", 4, &argc, &argv, 0);
prefix= "";
if(argc > 0)
prefix= argv[0];
separators= "";
if(argc > 1)
separators= argv[1];
max_words= 0;
if(argc > 2)
sscanf(argv[2], "%d", &max_words);
pflag= 0;
if(argc > 3)
sscanf(argv[3], "%d", &pflag);
input_lines= 1;
if(argc > 4)
sscanf(argv[4], "%d", &input_lines);
if(input_lines > 1)
sprintf(xorriso->info_text, "-msg_op parse: Enter %d lines of text\n",
input_lines);
else
sprintf(xorriso->info_text, "-msg_op parse: Enter text line\n");
Xorriso_info(xorriso, 0);
pline[0]= 0;
for(i= 0; i < input_lines; i++) {
l= strlen(pline);
ret= Xorriso_dialog_input(xorriso, pline + l, SfileadrL - l - 1, 8);
if(ret <= 0)
goto ex;
if(i < input_lines - 1)
strcat(pline, "\n");
}
sprintf(xorriso->info_text, "-msg_op parse: Text input complete\n");
Xorriso_info(xorriso, 0);
ret= Xorriso_parse_line(xorriso, pline, prefix, separators, max_words,
&pargc, &pargv, pflag);
xorriso->msg_sieve_disabled= 1;
sprintf(xorriso->result_line, "%d\n", ret);
Xorriso_result(xorriso, 1);
if(ret == 1) {
sprintf(xorriso->result_line, "%d\n", pargc);
Xorriso_result(xorriso, 1);
for(i= 0; i < pargc; i++) {
ret= Sfile_count_char(pargv[i], '\n') + 1;
sprintf(xorriso->result_line, "%d\n", ret);
Xorriso_result(xorriso, 1);
Sfile_str(xorriso->result_line, pargv[i], 0);
strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso, 1);
}
} else {
sprintf(xorriso->result_line, "0\n");
Xorriso_result(xorriso, 1);
}
xorriso->msg_sieve_disabled= msd_mem;
Xorriso__dispose_words(&argc, &argv);
Xorriso__dispose_words(&pargc, &pargv);
} else if(strcmp(what, "start_sieve") == 0) {
Xorriso_sieve_dispose(xorriso, 0);
ret= Xorriso_sieve_big(xorriso, 0);
msg= "Message sieve enabled";
/* >>> } else if(strcmp(what, "add_filter_rule") == 0) { */;
} else if(strcmp(what, "clear_sieve") == 0) {
ret= Xorriso_sieve_clear_results(xorriso, 0);
msg= "Recorded message sieve results disposed";
} else if(strcmp(what, "end_sieve") == 0) {
ret= Xorriso_sieve_dispose(xorriso, 0);
msg= "Message sieve disabled";
} else if(strcmp(what, "read_sieve") == 0) {
ret= Xorriso_sieve_get_result(xorriso, arg, &pargc, &pargv, &available, 0);
xorriso->msg_sieve_disabled= 1;
sprintf(xorriso->result_line, "%d\n", ret);
Xorriso_result(xorriso, 1);
if(ret > 0) {
sprintf(xorriso->result_line, "%d\n", pargc);
Xorriso_result(xorriso, 1);
for(i= 0; i < pargc; i++) {
ret= Sfile_count_char(pargv[i], '\n') + 1;
sprintf(xorriso->result_line, "%d\n", ret);
Xorriso_result(xorriso, 1);
Sfile_str(xorriso->result_line, pargv[i], 0);
strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso, 1);
}
} else {
strcpy(xorriso->result_line, "0\n");
Xorriso_result(xorriso, 1);
available= 0;
}
sprintf(xorriso->result_line, "%d\n", available);
Xorriso_result(xorriso, 1);
xorriso->msg_sieve_disabled= msd_mem;
Xorriso__dispose_words(&pargc, &pargv);
ret= 1;
} else if(strcmp(what, "show_sieve") == 0) {
ret= Xorriso_sieve_get_result(xorriso, "", &pargc, &pargv, &available, 8);
xorriso->msg_sieve_disabled= 1;
sprintf(xorriso->result_line, "%d\n", ret);
Xorriso_result(xorriso, 1);
if(ret > 0) {
sprintf(xorriso->result_line, "%d\n", pargc);
Xorriso_result(xorriso, 1);
for(i= 0; i < pargc; i++) {
sprintf(xorriso->result_line, "%s\n", pargv[i]);
Xorriso_result(xorriso, 1);
}
}
xorriso->msg_sieve_disabled= msd_mem;
Xorriso__dispose_words(&pargc, &pargv);
} else {
sprintf(xorriso->info_text, "-msg_op: unknown operation '%s'", what);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0;
}
if(ret > 0 && msg[0])
Xorriso_msgs_submit(xorriso, 0, msg, 0, "NOTE", 0);
ex:;
xorriso->msg_sieve_disabled= msd_mem;
Xorriso_free_meM(pline);
return(ret);
}
/* Option -mv alias -mvi */
int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag)

View File

@ -529,7 +529,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"data_cache_size",
"errfile_log","error_behavior","extract","extract_single",
"jigdo","lns","lnsi","load","logfile",
"map","map_single","page","return_with",
"map","map_single","msg_op","page","return_with",
"scdbackup_tag","update","update_r","volume_date",
""
};
@ -735,7 +735,7 @@ int Xorriso_cmd_sorting_rank(struct XorrisO *xorriso,
"check_media_defaults", "check_media", "check_md5", "check_md5_r",
"* Support for frontend programs via stdin and stdout (2):",
"pkt_output", "logfile", "mark",
"pkt_output", "logfile", "mark", "msg_op",
"* Dialog mode control:",
"dialog", "page", "use_readline", "reassure",
@ -1437,6 +1437,10 @@ next_command:;
(*idx)++;
ret= Xorriso_option_mount_opts(xorriso, arg1, 0);
} else if(strcmp(cmd,"msg_op") == 0) {
(*idx)+= 2;
ret= Xorriso_option_msg_op(xorriso, arg1, arg2, 0);
} else if(strcmp(cmd,"mv")==0 || strcmp(cmd,"mvi")==0) {
ret= Xorriso_option_mvi(xorriso, argc, argv, idx, 0);
@ -1829,7 +1833,7 @@ next_command:;
} else if(strcmp(arg1, "sieve_get_result") == 0) {
(*idx)++;
sev1= "Media summary:";
name= "Media summary:";
if(*idx - 1 < argc)
name= argv[*idx - 1];
ret= Xorriso_sieve_get_result(xorriso, name, &pargc, &pargv, &available,

View File

@ -46,6 +46,18 @@ char *Sfile_fgets_n(char *line, int maxl, FILE *fp, int flag)
}
int Sfile_count_char(char *text, char to_count)
{
int count= 0;
char *cpt;
for(cpt= text; *cpt != 0; cpt++)
if(*cpt == to_count)
count++;
return count;
}
int Sfile_count_components(char *path, int flag)
/*
bit0= do not ignore trailing slash

View File

@ -43,6 +43,9 @@ int Sfile_scale(double value, char *result, int siz, double thresh, int flag);
int Sfile_destroy_argv(int *argc, char ***argv, int flag);
int Sfile_count_char(char *text, char to_count);
/*
bit0= do not ignore trailing slash
bit1= do not ignore empty components (other than the empty root name)

View File

@ -65,6 +65,7 @@ int Xorriso_dialog_input(struct XorrisO *xorriso, char line[], int linesize,
bit0= do not write to history
bit1= do not read input (but eventually write to history)
bit2= do not write to history line which begin with "-history:" or "-history "
bit3= enforce single line dialog mode
*/
{
char *cpt= NULL, **argv= NULL, *linept, *why_append= "";
@ -131,7 +132,7 @@ process_single:;
#endif /* ! Xorriso_with_readlinE */
if(xorriso->dialog == 2) {
if(xorriso->dialog == 2 && !(flag & 8)) {
append_line= 0;
if(linept != line && strcmp(linept, "@@@") == 0) {
sprintf(xorriso->info_text, "Incomplete input line cleared by %s",
@ -1604,6 +1605,7 @@ int Xorriso_sieve_clear_results(struct XorrisO *xorriso, int flag)
Do not allocate memory.
bit2= If *argv is not NULL, then free it before attaching
new memory.
bit3= Do not read recorded data but rather list all filter names
*/
int Xorriso_sieve_get_result(struct XorrisO *xorriso, char *name,
int *argc, char ***argv, int *available, int flag)
@ -1620,6 +1622,26 @@ int Xorriso_sieve_get_result(struct XorrisO *xorriso, char *name,
if(xorriso->msg_sieve == NULL)
return(0);
if(flag & 8) {
if(xorriso->msg_sieve->num_filters <= 0)
return(0);
*argv= calloc(xorriso->msg_sieve->num_filters, sizeof(char *));
if(*argv == NULL)
goto no_mem;
*argc= xorriso->msg_sieve->num_filters;
for(i= 0; i < *argc; i++)
(*argv)[i]= NULL;
i= 0;
for(f= xorriso->msg_sieve->first_filter; f != NULL; f= f->next) {
(*argv)[*argc - i - 1]= strdup(f->name);
if((*argv)[*argc - i - 1] == NULL)
goto no_mem;
i++;
}
*argc= i;
return(1);
}
for(f= xorriso->msg_sieve->first_filter; f != NULL; f= f->next) {
if(strcmp(f->name, name) != 0)
continue;
@ -1694,50 +1716,94 @@ int Xorriso_sieve_big(struct XorrisO *xorriso, int flag)
int flag;
};
static struct Xorriso_sieve_big_filteR filters[] = {
{"-changes_pending", 3, "-changes_pending", "", 1,
{ 0, -1, -1, -1, -1, -1}, 1, 0},
{"? -dev", 3, "? -dev", "", 4, { 0, 1, 3, 4, -1, -1},
10, 0},
{"?? -dev", 3, "?? -dev", "", 4, { 0, 1, 3, 4, -1, -1},
90, 0},
{"Abstract File:", 3, "Abstract File: ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"After commit :", 3, "Image size :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"App Id :", 3, "App Id : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Biblio File :", 3, "Biblio File : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Build timestamp :", 3, "Build timestamp : ", "", 1,
{ 0, -1, -1, -1, -1, -1}, 1, 1},
{"CopyrightFile:", 3, "CopyrightFile: ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"DVD obs 64 kB:", 3, "DVD obs 64 kB:", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Drive current:", 3, "Drive current:", "", 2, { 0, 1, -1, -1, -1, -1},
2, 0},
{"Drive type :", 3, "Drive type :", "", 3, { 1, 3, 5, -1, -1, -1},
2, 0},
{"Media current:", 3, "Media current: ", "", 1, { 0, -1, -1, -1, -1, -1},
2, 1},
{"Media status :", 3, "Media status : ", "", 1, { 0, -1, -1, -1, -1, -1},
2, 1},
{"Media blocks :", 3, "Media blocks :", "", 3, { 0, 3, 6, -1, -1, -1},
2, 0},
{"Media summary:", 3, "Media summary:", "", 4, { 0, 2, 5, 7, -1, -1},
2, 0},
{"Media nwa :", 3, "Media nwa :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Volume id :", 3, "Volume id :", "", 1, { 0, -1, -1, -1, -1, -1},
2, 0},
{"Ext. filters :", 3, "Ext. filters : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"File damaged :", 3, "File damaged :", "", 4, { 0, 2, 4, 6, -1, -1},
10000, 0},
{"File data lba:", 3, "File data lba:", "", 5, { 0, 2, 4, 6, 8, -1},
10000, 0},
{"Format idx :", 3, "Format idx ", ",: ", 4, { 0, 1, 2, 3, -1, -1},
100, 1},
{"Format status:", 3, "Format status:", ", ", 2, { 0, 1, -1, -1, -1, -1},
1, 1},
{"ISO session :", 3, "ISO session :", "", 4, { 0, 2, 4, 6, -1, -1},
10000, 1},
{"Image size :", 3, "Image size :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Jigdo files :", 3, "Jigdo files :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Local ACL :", 3, "Local ACL :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Local xattr :", 3, "Local xattr :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"MD5 MISMATCH:", 3, "MD5 MISMATCH:", "", 1, { 0, -1, -1, -1, -1, -1},
10000, 0},
{"MD5 tag range:", 3, "MD5 tag range:", "", 3, { 0, 2, 4, -1, -1, -1},
10000, 1},
{"Media blocks :", 3, "Media blocks :", "", 3, { 0, 3, 6, -1, -1, -1},
2, 0},
{"Media current:", 3, "Media current: ", "", 1, { 0, -1, -1, -1, -1, -1},
2, 1},
{"Media nwa :", 3, "Media nwa :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Media product:", 3, "Media product:", "", 2, { 0, 2, -1, -1, -1, -1},
2, 1},
{"Media region :", 3, "Media region :", "", 3, { 0, 2, 4, -1, -1, -1},
10000, 1},
{"Media space :", 3, "Image size :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"After commit :", 3, "Image size :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Media status :", 3, "Media status : ", "", 1, { 0, -1, -1, -1, -1, -1},
2, 1},
{"Media summary:", 3, "Media summary:", "", 4, { 0, 2, 5, 7, -1, -1},
2, 0},
{"PVD address :", 3, "PVD address :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Preparer Id :", 3, "Preparer Id : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Profile :", 3, "Profile :", "", 2, { 0, 1, -1, -1, -1, -1},
256, 1},
{"Publisher Id :", 3, "Publisher Id : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Readline :", 3, "Readline :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Size lower :", 3, "Size lower :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Size upper :", 3, "Size upper :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"System Id :", 3, "System Id : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Version timestamp :", 3, "Version timestamp :", "", 1,
{ 0, -1, -1, -1, -1, -1}, 1, 0},
{"Volume Id :", 3, "Volume Id : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Volume Set Id:", 3, "Volume Set Id: ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Publisher Id :", 3, "Publisher Id : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Preparer Id :", 3, "Preparer Id : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"App Id :", 3, "App Id : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"System Id :", 3, "System Id : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"CopyrightFile:", 3, "CopyrightFile: ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Abstract File:", 3, "Abstract File: ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Biblio File :", 3, "Biblio File : ", "", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"Volume id :", 3, "Volume id :", "", 1, { 0, -1, -1, -1, -1, -1},
2, 0},
{"Write speed :", 3, "Write speed :", "", 2, { 0, 2, -1, -1, -1, -1},
100, 0},
{"Write speed H:", 3, "Write speed H:", "", 2, { 0, 2, -1, -1, -1, -1},
@ -1748,75 +1814,23 @@ int Xorriso_sieve_big(struct XorrisO *xorriso, int flag)
1, 0},
{"Write speed l:", 3, "Write speed l:", "", 2, { 0, 2, -1, -1, -1, -1},
1, 0},
{"Format status:", 3, "Format status:", ", ", 2, { 0, 1, -1, -1, -1, -1},
1, 1},
{"Format idx :", 3, "Format idx ", ",: ", 4, { 0, 1, 2, 3, -1, -1},
100, 1},
{"Profile :", 3, "Profile :", "", 2, { 0, 1, -1, -1, -1, -1},
256, 1},
{"-changes_pending", 3, "-changes_pending ", "", 1,
{ 0, -1, -1, -1, -1, -1}, 1, 0},
{"Media region :", 3, "Media region :", "", 3, { 0, 2, 4, -1, -1, -1},
10000, 1},
{"MD5 tag range:", 3, "MD5 tag range:", "", 3, { 0, 2, 4, -1, -1, -1},
10000, 1},
{"Local ACL :", 3, "Local ACL :", ", ", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Local xattr :", 3, "Local xattr :", ", ", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Jigdo files :", 3, "Jigdo files :", ", ", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"zisofs :", 3, "zisofs :", ", ", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Ext. filters :", 3, "Ext. filters : ", ", ", 1, { 0, -1, -1, -1, -1, -1},
1, 1},
{"DVD obs 64 kB:", 3, "DVD obs 64 kB:", ", ", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Readline :", 3, "Readline :", ", ", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"xorriso version :", 3, "xorriso version :", ", ", 1,
{ 0, -1, -1, -1, -1, -1}, 1, 0},
{"Version timestamp :", 3, "Version timestamp :", ", ", 1,
{ 0, -1, -1, -1, -1, -1}, 1, 0},
{"Build timestamp :", 3, "Build timestamp : ", ", ", 1,
{"libburn in use :", 3, "libburn in use :", "", 2,
{ 0, 1, -1, -1, -1, -1}, 1, 1},
{"libburn OS adapter:", 3, "libburn OS adapter: ", "", 1,
{ 0, -1, -1, -1, -1, -1}, 1, 1},
{"libisofs in use :", 3, "libisofs in use :", ", ", 2,
{"libisoburn in use :", 3, "libisoburn in use :", "", 2,
{ 0, 1, -1, -1, -1, -1}, 1, 1},
{"libjte in use :", 3, "libjte in use :", ", ", 2,
{"libisofs in use :", 3, "libisofs in use :", "", 2,
{ 0, 1, -1, -1, -1, -1}, 1, 1},
{"libburn in use :", 3, "libburn in use :", ", ", 2,
{"libjte in use :", 3, "libjte in use :", "", 2,
{ 0, 1, -1, -1, -1, -1}, 1, 1},
{"libburn OS adapter:", 3, "libburn OS adapter: ", ", ", 1,
{ 0, -1, -1, -1, -1, -1}, 1, 1},
{"libisoburn in use :", 3, "libisoburn in use :", ", ", 2,
{ 0, 1, -1, -1, -1, -1}, 1, 1},
{"File damaged :", 3, "File damaged :", "", 4, { 0, 2, 4, 6, -1, -1},
10000, 0},
{"File data lba:", 3, "File data lba:", "", 5, { 0, 2, 4, 6, 8, -1},
10000, 0},
{"MD5 MISMATCH:", 3, "MD5 MISMATCH:", "", 1, { 0, -1, -1, -1, -1, -1},
10000, 0},
{"Size lower :", 3, "Size lower :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"Size upper :", 3, "Size upper :", "", 1, { 0, -1, -1, -1, -1, -1},
{"xorriso version :", 3, "xorriso version :", "", 1,
{ 0, -1, -1, -1, -1, -1}, 1, 0},
{"zisofs :", 3, "zisofs :", "", 1, { 0, -1, -1, -1, -1, -1},
1, 0},
{"@", 0, "@", "", 0, {-1, -1, -1, -1, -1, -1}, 0, 0}
};
/* >>> Problem cases:
-devices -device_links
have no well recognizable prefix
-pwd -pwdx
have a headline and a value line
-> outlist stack
-ls* , -getfacl* , -getfattr* , -du* , -compare* , -show_stream*
have no well recognizable prefix
-> outlist stack
*/
struct Xorriso_sieve_big_filteR *f;
int ret, i, num_filters= 1000;
@ -1848,12 +1862,12 @@ failure:
*/
int Xorriso_sieve_filter_msg(struct XorrisO *xorriso, char *msg, int flag)
{
int channel, ret, argc= 0, i, max_words, l, widx;
char **argv= NULL;
int channel, ret, argc= 0, i, max_words, l, widx, skip;
char **argv= NULL, *prefix_storage= NULL, *prefix, *cpt, *to_parse= NULL;
struct Xorriso_msg_filteR *f;
struct Xorriso_lsT *lst, *prev_lst, *next_lst;
if(xorriso->msg_sieve == NULL)
if(xorriso->msg_sieve == NULL || xorriso->msg_sieve_disabled)
return(1);
channel= flag & 3;
@ -1861,9 +1875,37 @@ int Xorriso_sieve_filter_msg(struct XorrisO *xorriso, char *msg, int flag)
for(f= xorriso->msg_sieve->first_filter; f != NULL; f= f->next) {
if(!(f->channels & (1 << channel)))
continue;
if(f->prefix[0])
if(strncmp(f->prefix, msg, strlen(f->prefix)) != 0)
prefix= f->prefix;
if(prefix[0] == '?') {
skip= 0;
for(cpt= prefix; *cpt; cpt++)
if(*cpt == '?')
skip++;
else
break;
l= strlen(prefix);
if(strlen(msg) >= (unsigned int) l) {
if(l - skip == 0 || strncmp(prefix + skip, msg + skip, l - skip) == 0) {
Xorriso_alloc_meM(prefix_storage, char, l + 1);
strncpy(prefix_storage, msg, l);
prefix_storage[l]= 0;
prefix= prefix_storage;
}
}
}
if(prefix[0])
if(strncmp(prefix, msg, strlen(prefix)) != 0)
continue;
to_parse= strdup(msg);
if(to_parse == NULL)
goto no_mem;
l= strlen(to_parse);
if(l > 0)
if(to_parse[l - 1] == '\n')
to_parse[l - 1]= 0;
max_words= 0;
if(f->last_word_line_end)
if(f->num_words > 0) /* Let last word take rest of line */
@ -1878,20 +1920,20 @@ int Xorriso_sieve_filter_msg(struct XorrisO *xorriso, char *msg, int flag)
if(argv == NULL)
goto no_mem;
argc= 1;
argv[0]= strdup(msg + strlen(f->prefix));
argv[0]= strdup(to_parse + strlen(prefix));
if(argv[0] == NULL)
goto no_mem;
ret= 1;
} else {
ret= Xorriso_parse_line(xorriso, msg, f->prefix, f->separators, max_words,
&argc, &argv, 0);
ret= Xorriso_parse_line(xorriso, to_parse, prefix, f->separators,
max_words, &argc, &argv, 0);
}
if(ret < 0)
goto ex;
if(ret == 0)
continue;
if(f->last_word_line_end) {
if(f->last_word_line_end && argc > max_words) {
l= strlen(argv[max_words]);
if(l > 0)
if(argv[max_words][l - 1] == '\n')
@ -1935,10 +1977,15 @@ int Xorriso_sieve_filter_msg(struct XorrisO *xorriso, char *msg, int flag)
prev_lst= lst;
}
(f->num_results)++;
Xorriso_free_meM(prefix_storage);
prefix_storage= NULL;
Xorriso__dispose_words(&argc, &argv);
}
ret= 1;
ex:
if(to_parse != NULL)
free(to_parse);
Xorriso_free_meM(prefix_storage);
Xorriso__dispose_words(&argc, &argv);
return(ret);
no_mem:;

View File

@ -9,7 +9,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Version 1.2.5, Nov 05, 2012"
.TH XORRISO 1 "Version 1.2.5, Dec 08, 2012"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -4465,6 +4465,83 @@ If text is not empty it will get put out on "M" channel each time
\fBxorriso\fR is ready for the next dialog line or before
\fBxorriso\fR performs a command that was entered to the pager prompt.
.TP
\fB\-msg_op\fR opcode parameter_text
This command shall facilitate extraction of particular information from
the message output of other commands. It gives access to the C API function
Xorriso_parse_line and to the message sieve that is provided by the C API.
Please refer to their description in file xorriso.h.
.br
Intended users are frontend programs which operate xorriso in dialog mode.
.br
The result output of this command is not caught by the message sieve.
.br
The following opcodes are defined:
.br
\fBstart_sieve\fR
.br
Install the message sieve as of Xorriso_sieve_big() and start watching
program messages. The parameter_text has no meaning.
.br
\fBshow_sieve\fR
.br
Show a list of filter rule names. The parameter_text has no meaning.
The list begins by a line with the return value of Xorriso_sieve_get_result()
with flag bit3. If this value is larger than 0, then the next line tells
the number of names. The following lines show one name each.
.br
\fBread_sieve\fR
.br
Use the parameter_text as name of a filter rule and inquire its next
recorded result.
See Xorriso_sieve_big() for a list of names and reply strings.
.br
The recorded strings are put out on result channel. They get wrapped
into lines which tell their structure.
The first line tells the return value of Xorriso_sieve_get_result().
The next line tells the number of strings. Each string begins by a line that
tells the number of lines of the string. Then follow these lines. They are to
be concatenated with a newline character inbetween each of them.
Finally the number of still available recorded results of the given name
is put out.
.br
\fBclear_sieve\fR
.br
Dispose all recorded strings and continue watching program messages.
The parameter_text has no meaning.
.br
\fBend_sieve\fR
.br
Dispose the sieve with its filter rules and stop watching program messages.
The parameter_text has no meaning.
.br
\fBparse\fR
.br
Read a text from dialog input and submit it to Xorriso_parse_line().
The parameter_text word shall consist of several words separated by blanks.
It will be necessary to use both kinds of quotation marks.
.br
E.g. "'ISO session :' '' 0 0 1"
.br
The five parameter words are: prefix, separators, max_words, flag,
number_of_input_lines.
The former four are handed over to Xorriso_parse_line(). The number of
input lines minus one tells xorriso how many newline characters are
part of the input text.
.br
The announced number of text lines will be read from dialog input,
concatenated with a newline character inbetween each of them,
and submitted to Xorriso_parse_line() as parameter line.
Note that newlines outside of quotation marks are
interpreted as separators if the separators parameter is empty.
.br
The parsed strings are put out on result channel. They get wrapped
into lines which tell their structure.
The first line tells the return value of Xorriso_parse_line().
The next line tells the number of strings. Each string begins by a line that
tells the number of lines of the string. Then follow these lines. They are to
be concatenated with a newline character inbetween each of them.
.br
.TP
\fB\-prog\fR text
Use text as name of this program in subsequent messages
.TP

View File

@ -665,6 +665,11 @@ int Xorriso_process_errfile(struct XorrisO *xorriso,
bit2= mark channel
@param prefix The line start to watch for. Will also be handed over
to Xorriso_parse_line(). Empty text matches all lines.
If the prefix begins by '?' characters, then these
match any character at the beginning of a message.
The prefix of the filter rule will then be adapted
to really match the line, before it gets handed over
to Xorriso_parse_line().
@param separators List of separator characters for Xorriso_parse_line()
@param num_words Number of word indice in word_idx
@param word_idx Array with the argv indice to be picked from the
@ -702,9 +707,12 @@ int Xorriso_sieve_add_filter(struct XorrisO *xorriso, char *name,
Do not allocate memory.
bit2= If *argv is not NULL, then free it before attaching
new memory.
@return <0 error: -1 = memor shortage
bit3= Do not read recorded data but rather list all
filter names.
@return <0 error: -1 = memory shortage
-2 = no filter rule found
0 no more data available for the given name
0 No more data available for the given name
With bit3: No filter rules installed.
>0 argc and argv are valid
*/
int Xorriso_sieve_get_result(struct XorrisO *xorriso, char *name,
@ -748,7 +756,18 @@ int Xorriso_sieve_dispose(struct XorrisO *xorriso, int flag);
------------------------------------------------------------------------
"-changes_pending" up to 1 result from -changes_pending show_status
argv[0]= "yes" or "no"
(Note: prefix is "-changes_pending ")
"? -dev" up to 10 results from -devices or -device_links
(records drives with single digit index number)
argv[0]= drive address
argv[1]= permissions
argv[2]= drive vendor
argv[3]= product id
"?? -dev" up to 90 results from -devices or -device_links
(records drives with double digit index number)
argv[0]= drive address
argv[1]= permissions
argv[2]= drive vendor
argv[3]= product id
"Abstract File:" up to 1 result from -pvd_info
argv[0]= file name
(Note: prefix is "Abstract File: ")
@ -799,13 +818,13 @@ int Xorriso_sieve_dispose(struct XorrisO *xorriso, int flag);
"Format status:" up to 1 result from -list_formats
argv[0]= status
argv[1]= capacity
"Image size :" up to 1 result from -print_size
argv[0]= number of blocks with "s" appended
"ISO session :" up to 10000 results from -toc
argv[0]= Idx
argv[1]= sbsector
argv[2]= Size
argv[3]= Volume Id
"Image size :" up to 1 result from -print_size
argv[0]= number of blocks with "s" appended
"Jigdo files :" up to 1 result from -list_extras
argv[0]= "yes" or "no"
"Local ACL :" up to 1 result from -list_extras
@ -827,6 +846,9 @@ int Xorriso_sieve_dispose(struct XorrisO *xorriso, int flag);
(Note: prefix is "Media current: " which eats extra blank)
"Media nwa :" up to 1 result from -toc
argv[0]= next writable address
"Media product:" up to 2 results from -toc
argv[0]= product id
argv[1]= manufacturer
"Media region :" up to 10000 results from -check_media
argv[0]= lba
argv[1]= size in blocks
@ -1589,6 +1611,10 @@ int Xorriso_option_mount(struct XorrisO *xorriso, char *dev, char *adr_mode,
/* Command -mount_opts option[:...] */
int Xorriso_option_mount_opts(struct XorrisO *xorriso, char *mode, int flag);
/* Command -msg_op */
int Xorriso_option_msg_op(struct XorrisO *xorriso, char *what, char *arg,
int flag);
/* Command -mv alias -mvi */
int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag);

View File

@ -3920,6 +3920,65 @@ File: xorriso.info, Node: Frontend, Next: ExDevices, Prev: Scripting, Up: Co
`xorriso' is ready for the next dialog line or before `xorriso'
performs a command that was entered to the pager prompt.
-msg_op opcode parameter_text
This command shall facilitate extraction of particular information
from the message output of other commands. It gives access to the
C API function Xorriso_parse_line and to the message sieve that is
provided by the C API. Please refer to their description in file
xorriso.h.
Intended users are frontend programs which operate xorriso in
dialog mode.
The result output of this command is not caught by the message
sieve.
The following opcodes are defined:
*start_sieve*
Install the message sieve as of Xorriso_sieve_big() and start
watching program messages. The parameter_text has no meaning.
*show_sieve*
Show a list of filter rule names. The parameter_text has no
meaning. The list begins by a line with the return value of
Xorriso_sieve_get_result() with flag bit3. If this value is larger
than 0, then the next line tells the number of names. The
following lines show one name each.
*read_sieve*
Use the parameter_text as name of a filter rule and inquire its
next recorded result. See Xorriso_sieve_big() for a list of names
and reply strings.
The recorded strings are put out on result channel. They get
wrapped into lines which tell their structure. The first line
tells the return value of Xorriso_sieve_get_result(). The next
line tells the number of strings. Each string begins by a line that
tells the number of lines of the string. Then follow these lines.
They are to be concatenated with a newline character inbetween
each of them. Finally the number of still available recorded
results of the given name is put out.
*clear_sieve*
Dispose all recorded strings and continue watching program
messages. The parameter_text has no meaning.
*end_sieve*
Dispose the sieve with its filter rules and stop watching program
messages. The parameter_text has no meaning.
*parse*
Read a text from dialog input and submit it to
Xorriso_parse_line(). The parameter_text word shall consist of
several words separated by blanks. It will be necessary to use
both kinds of quotation marks.
E.g. "'ISO session :' " 0 0 1"
The five parameter words are: prefix, separators, max_words, flag,
number_of_input_lines. The former four are handed over to
Xorriso_parse_line(). The number of input lines minus one tells
xorriso how many newline characters are part of the input text.
The announced number of text lines will be read from dialog input,
concatenated with a newline character inbetween each of them, and
submitted to Xorriso_parse_line() as parameter line. Note that
newlines outside of quotation marks are interpreted as separators
if the separators parameter is empty.
The parsed strings are put out on result channel. They get wrapped
into lines which tell their structure. The first line tells the
return value of Xorriso_parse_line(). The next line tells the
number of strings. Each string begins by a line that tells the
number of lines of the string. Then follow these lines. They are to
be concatenated with a newline character inbetween each of them.
-prog text
Use text as name of this program in subsequent messages
@ -4658,6 +4717,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -mount issues mount command for ISO session: Restore. (line 126)
* -mount_cmd composes mount command line: Inquiry. (line 41)
* -mount_cmd controls mount command: Inquiry. (line 57)
* -msg_op perform operations on program messages: Frontend. (line 30)
* -mv renames file in ISO image: Manip. (line 35)
* -no_rc disables startup files: Scripting. (line 7)
* -not_leaf sets exclusion pattern: SetInsert. (line 62)
@ -4681,8 +4741,8 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -print_info prints message text line: Scripting. (line 102)
* -print_mark prints synchronizing text line: Scripting. (line 105)
* -print_size predicts image size: Inquiry. (line 80)
* -prog sets program name: Frontend. (line 30)
* -prog_help prints help text: Frontend. (line 33)
* -prog sets program name: Frontend. (line 89)
* -prog_help prints help text: Frontend. (line 92)
* -prompt prompts for enter key: Scripting. (line 110)
* -publisher sets publisher id: SetWrite. (line 186)
* -pvd_info shows image id strings: Inquiry. (line 93)
@ -4944,13 +5004,14 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Process, log output channels to file, -logfile: Frontend. (line 20)
* Process, read command file, -options_from_file: Scripting. (line 12)
* Process, set synchronizing message, -mark: Frontend. (line 25)
* Program messages, perform operations, -msg_op: Frontend. (line 30)
* Program, backslash conversion, -backslash_codes: Scripting. (line 67)
* Program, curb memory, -temp_mem_limit: Scripting. (line 92)
* Program, end and write, -end: Scripting. (line 156)
* Program, end without writing, -rollback_end: Scripting. (line 159)
* Program, list extra features, -list_extras: Scripting. (line 26)
* Program, print help text, -help: Scripting. (line 20)
* Program, print help text, -prog_help: Frontend. (line 33)
* Program, print help text, -prog_help: Frontend. (line 92)
* Program, print message text line, -print_info: Scripting. (line 102)
* Program, print result text line, -print: Scripting. (line 99)
* Program, print synchronizing text line, -print_mark: Scripting.
@ -4958,7 +5019,7 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Program, print version, -version: Scripting. (line 23)
* Program, prompt for enter key, -prompt: Scripting. (line 110)
* Program, replace --, -list_delimiter: Scripting. (line 60)
* Program, set name, -prog: Frontend. (line 30)
* Program, set name, -prog: Frontend. (line 89)
* Program, show current settings, -status: Scripting. (line 47)
* Program, status history, -status_history_max: Scripting. (line 56)
* Program, wait a time span, -sleep: Scripting. (line 114)
@ -5064,28 +5125,28 @@ Node: Restore174189
Node: Emulation181099
Node: Scripting190911
Node: Frontend198072
Node: Examples199373
Node: ExDevices200551
Node: ExCreate201210
Node: ExDialog202495
Node: ExGrowing203760
Node: ExModifying204565
Node: ExBootable205069
Node: ExCharset205621
Node: ExPseudo206442
Node: ExCdrecord207340
Node: ExMkisofs207657
Node: ExGrowisofs208997
Node: ExException210132
Node: ExTime210586
Node: ExIncBackup211045
Node: ExRestore215037
Node: ExRecovery215997
Node: Files216567
Node: Seealso217866
Node: Bugreport218589
Node: Legal219170
Node: CommandIdx220181
Node: ConceptIdx236126
Node: Examples202666
Node: ExDevices203844
Node: ExCreate204503
Node: ExDialog205788
Node: ExGrowing207053
Node: ExModifying207858
Node: ExBootable208362
Node: ExCharset208914
Node: ExPseudo209735
Node: ExCdrecord210633
Node: ExMkisofs210950
Node: ExGrowisofs212290
Node: ExException213425
Node: ExTime213879
Node: ExIncBackup214338
Node: ExRestore218330
Node: ExRecovery219290
Node: Files219860
Node: Seealso221159
Node: Bugreport221882
Node: Legal222463
Node: CommandIdx223474
Node: ConceptIdx239492

End Tag Table

View File

@ -50,7 +50,7 @@
@c man .\" First parameter, NAME, should be all caps
@c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
@c man .\" other parameters are allowed: see man(7), man(1)
@c man .TH XORRISO 1 "Version 1.2.5, Nov 05, 2012"
@c man .TH XORRISO 1 "Version 1.2.5, Dec 08, 2012"
@c man .\" Please adjust this date whenever revising the manpage.
@c man .\"
@c man .\" Some roff macros, for reference:
@ -5248,6 +5248,85 @@ If text is not empty it will get put out on "M" channel each time
@command{xorriso} is ready for the next dialog line or before
@command{xorriso} performs a command that was entered to the pager prompt.
@c man .TP
@item -msg_op opcode parameter_text
@kindex -msg_op perform operations on program messages
@cindex Program messages, perform operations, -msg_op
This command shall facilitate extraction of particular information from
the message output of other commands. It gives access to the C API function
Xorriso_parse_line and to the message sieve that is provided by the C API.
Please refer to their description in file xorriso.h.
@*
Intended users are frontend programs which operate xorriso in dialog mode.
@*
The result output of this command is not caught by the message sieve.
@*
The following opcodes are defined:
@*
@strong{start_sieve}
@*
Install the message sieve as of Xorriso_sieve_big() and start watching
program messages. The parameter_text has no meaning.
@*
@strong{show_sieve}
@*
Show a list of filter rule names. The parameter_text has no meaning.
The list begins by a line with the return value of Xorriso_sieve_get_result()
with flag bit3. If this value is larger than 0, then the next line tells
the number of names. The following lines show one name each.
@*
@strong{read_sieve}
@*
Use the parameter_text as name of a filter rule and inquire its next
recorded result.
See Xorriso_sieve_big() for a list of names and reply strings.
@*
The recorded strings are put out on result channel. They get wrapped
into lines which tell their structure.
The first line tells the return value of Xorriso_sieve_get_result().
The next line tells the number of strings. Each string begins by a line that
tells the number of lines of the string. Then follow these lines. They are to
be concatenated with a newline character inbetween each of them.
Finally the number of still available recorded results of the given name
is put out.
@*
@strong{clear_sieve}
@*
Dispose all recorded strings and continue watching program messages.
The parameter_text has no meaning.
@*
@strong{end_sieve}
@*
Dispose the sieve with its filter rules and stop watching program messages.
The parameter_text has no meaning.
@*
@strong{parse}
@*
Read a text from dialog input and submit it to Xorriso_parse_line().
The parameter_text word shall consist of several words separated by blanks.
It will be necessary to use both kinds of quotation marks.
@*
E.g. "'ISO session :' '' 0 0 1"
@*
The five parameter words are: prefix, separators, max_words, flag,
number_of_input_lines.
The former four are handed over to Xorriso_parse_line(). The number of
input lines minus one tells xorriso how many newline characters are
part of the input text.
@*
The announced number of text lines will be read from dialog input,
concatenated with a newline character inbetween each of them,
and submitted to Xorriso_parse_line() as parameter line.
Note that newlines outside of quotation marks are
interpreted as separators if the separators parameter is empty.
@*
The parsed strings are put out on result channel. They get wrapped
into lines which tell their structure.
The first line tells the return value of Xorriso_parse_line().
The next line tells the number of strings. Each string begins by a line that
tells the number of lines of the string. Then follow these lines. They are to
be concatenated with a newline character inbetween each of them.
@*
@c man .TP
@item -prog text
@kindex -prog sets program name
@cindex Program, set name, -prog

View File

@ -592,6 +592,7 @@ struct XorrisO { /* the global context of xorriso */
pthread_mutex_t msgw_fetch_lock;
struct Xorriso_msg_sievE *msg_sieve;
int msg_sieve_disabled;
int status_history_max; /* for -status long_history */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2012.12.07.193658"
#define Xorriso_timestamP "2012.12.08.175205"