New command -msg_op
This commit is contained in:
@ -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:;
|
||||
|
Reference in New Issue
Block a user