New -msg_op opcode "parse_bulk"

master
Thomas Schmitt 10 years ago
parent c4f476b1b4
commit 518dbac61c
  1. 4
      xorriso/opts_d_h.c
  2. 55
      xorriso/opts_i_o.c
  3. 128
      xorriso/text_io.c
  4. 10
      xorriso/text_io.h
  5. 20
      xorriso/xorriso.1
  6. 20
      xorriso/xorriso.texi
  7. 2
      xorriso/xorriso_timestamp.h

@ -2079,8 +2079,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" 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\"|\"compare_sev\"|\"list_sev\"",
" Enable, use, or disable message sieve. Or parse line into",
" \"parse\"|\"parse_bulk\"|\"compare_sev\"|\"list_sev\" param_text",
" Enable, use, or disable message sieve. Or parse lines into",
" words. Or compare or list severity names.",
" -logfile channel fileaddress Copy output of a channel to the given file.",
" channel may be 'R','I','M' as with -pkt_output or '.'",

@ -842,17 +842,15 @@ unknown_mode:;
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;
int ret, available, argc, pargc, i, pflag, max_words, input_lines, msd_mem;
char **argv= NULL, **pargv= NULL, *msg= "";
char *pline= NULL, *prefix, *separators;
char *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);
if(strcmp(what, "parse") == 0 || strcmp(what, "parse_bulk") == 0) {
ret= Xorriso_parse_line(xorriso, arg, "", "", 5, &argc, &argv, 0);
prefix= "";
if(argc > 0)
prefix= argv[0];
@ -865,50 +863,20 @@ int Xorriso_option_msg_op(struct XorrisO *xorriso, char *what, char *arg,
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);
}
if(strcmp(what, "parse") == 0) {
ret= Xorriso_msg_op_parse(xorriso, "", prefix, separators,
max_words, pflag, input_lines, 0);
} else {
sprintf(xorriso->result_line, "0\n");
Xorriso_result(xorriso, 1);
ret= Xorriso_msg_op_parse_bulk(xorriso, prefix, separators,
max_words, pflag, input_lines, 0);
}
if(ret <= 0)
goto ex;
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);
@ -988,7 +956,6 @@ int Xorriso_option_msg_op(struct XorrisO *xorriso, char *what, char *arg,
ex:;
xorriso->msg_sieve_disabled= msd_mem;
Xorriso_free_meM(pline);
return(ret);
}

@ -3545,3 +3545,131 @@ int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity,
return(1);
}
/* @param flag bit0= do not issue prompt messages on info channel
bit1= use line rather than asking at dialog input
*/
int Xorriso_msg_op_parse(struct XorrisO *xorriso, char *line,
char *prefix, char *separators,
int max_words, int pflag, int input_lines,
int flag)
{
int ret, i, l, pargc= 0;
char *pline= NULL, **pargv= NULL, *parse_line;
Xorriso_alloc_meM(pline, char, SfileadrL);
if(!(flag & 1)) {
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);
}
if(flag & 2) {
parse_line= line;
} else {
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");
}
parse_line= pline;
}
ret= Xorriso_parse_line(xorriso, parse_line, 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);
}
ret= 1;
ex:;
Xorriso__dispose_words(&pargc, &pargv);
Xorriso_free_meM(pline);
return ret;
}
int Xorriso_msg_op_parse_bulk(struct XorrisO *xorriso,
char *prefix, char *separators,
int max_words, int pflag, int bulk_lines,
int flag)
{
int ret, input_lines, i, j, l;
char line[80];
struct Xorriso_lsT *input_list= NULL, *input_end= NULL, *new_lst, *lst;
char *pline= NULL;
sprintf(xorriso->info_text,
"Enter %d groups of lines. Each group begins by a line which tells the\n",
bulk_lines);
Xorriso_info(xorriso, 0);
sprintf(xorriso->info_text,
"number of following lines in the group. Then come the announced lines\n");
Xorriso_info(xorriso, 0);
sprintf(xorriso->info_text,
"Do this blindly. No further prompt will appear. Best be a computer.\n");
Xorriso_info(xorriso, 0);
Xorriso_alloc_meM(pline, char, SfileadrL);
for(i= 0; i < bulk_lines; i++) {
ret= Xorriso_dialog_input(xorriso, line, sizeof(line), 8);
if(ret <= 0)
goto ex;
input_lines= -1;
sscanf(line, "%d", &input_lines);
pline[0]= 0;
for(j= 0; j < input_lines; j++) {
l= strlen(pline);
ret= Xorriso_dialog_input(xorriso, pline + l, SfileadrL - l - 1, 8);
if(ret <= 0)
goto ex;
if(j < input_lines - 1)
strcat(pline, "\n");
}
ret= Xorriso_lst_new(&new_lst, pline, input_end, 0);
if(ret <= 0)
goto ex;
if(input_list == NULL)
input_list= new_lst;
input_end= new_lst;
}
for(lst= input_list; lst != NULL; lst= Xorriso_lst_get_next(lst, 0)) {
ret= Xorriso_msg_op_parse(xorriso, Xorriso_lst_get_text(lst, 0),
prefix, separators, max_words, pflag,
input_lines, 1 | 2);
if(ret <= 0)
goto ex;
}
ret= 1;
ex:;
Xorriso_lst_destroy_all(&input_list, 0);
Xorriso_free_meM(pline);
return(1);
}

@ -86,5 +86,15 @@ int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity,
int Xorriso_protect_stdout(struct XorrisO *xorriso, int flag);
int Xorriso_msg_op_parse(struct XorrisO *xorriso, char *line,
char *prefix, char *separators,
int max_words, int pflag, int input_lines,
int flag);
int Xorriso_msg_op_parse_bulk(struct XorrisO *xorriso,
char *prefix, char *separators,
int max_words, int pflag, int bulk_lines,
int flag);
#endif /* ! Xorriso_pvt_textio_includeD */

@ -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, Dec 14, 2012"
.TH XORRISO 1 "Version 1.2.5, Dec 16, 2012"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -4479,8 +4479,9 @@ If text is not empty it will get put out on "M" channel each time
\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.
Xorriso_parse_line() and to the message sieve that is provided by the C API.
Please refer to their descriptions in file xorriso.h.
Further it helps to interpret the severity codes of info messages.
.br
Intended users are frontend programs which operate xorriso in dialog mode.
.br
@ -4552,6 +4553,19 @@ 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
\fBparse_bulk\fR
.br
Like "parse", but with the fifth parameter word being number_of_input_texts
rather than number_of_input_lines. Each input text has to be preceded by
a line that tells number_of_input_lines as with "parse".
Then come the announced number of text lines.
.br
All input texts will be read before printing of result lines begins.
This consumes memory in xorriso. So the number_of_input_texts should not
be extremely high. On the other hand, large transactions of command,
input texts, and results are desirable if connection latency is an
issue.
.br
\fBcompare_sev\fR
.br
The parameter_text should contain two comma separated severity texts as

@ -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, Dec 14, 2012"
@c man .TH XORRISO 1 "Version 1.2.5, Dec 16, 2012"
@c man .\" Please adjust this date whenever revising the manpage.
@c man .\"
@c man .\" Some roff macros, for reference:
@ -5265,8 +5265,9 @@ If text is not empty it will get put out on "M" channel each time
@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.
Xorriso_parse_line() and to the message sieve that is provided by the C API.
Please refer to their descriptions in file xorriso.h.
Further it helps to interpret the severity codes of info messages.
@*
Intended users are frontend programs which operate xorriso in dialog mode.
@*
@ -5338,6 +5339,19 @@ 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.
@*
@strong{parse_bulk}
@*
Like "parse", but with the fifth parameter word being number_of_input_texts
rather than number_of_input_lines. Each input text has to be preceded by
a line that tells number_of_input_lines as with "parse".
Then come the announced number of text lines.
@*
All input texts will be read before printing of result lines begins.
This consumes memory in xorriso. So the number_of_input_texts should not
be extremely high. On the other hand, large transactions of command,
input texts, and results are desirable if connection latency is an
issue.
@*
@strong{compare_sev}
@*
The parameter_text should contain two comma separated severity texts as

@ -1 +1 @@
#define Xorriso_timestamP "2012.12.15.093055"
#define Xorriso_timestamP "2012.12.16.131128"

Loading…
Cancel
Save