Allowed independent redirecton of result and info channel

This commit is contained in:
Thomas Schmitt 2008-08-15 10:29:47 +00:00
parent b5d7d75598
commit afc27f89fe
4 changed files with 38 additions and 8 deletions

View File

@ -3259,6 +3259,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
for(i= 0; i < Xorriso_max_outlist_stacK; i++) { for(i= 0; i < Xorriso_max_outlist_stacK; i++) {
m->result_msglists[i]= NULL; m->result_msglists[i]= NULL;
m->info_msglists[i]= NULL; m->info_msglists[i]= NULL;
m->msglist_flags[i]= 0;
} }
m->msglist_stackfill= 0; m->msglist_stackfill= 0;
m->status_history_max= Xorriso_status_history_maX; m->status_history_max= Xorriso_status_history_maX;
@ -3676,7 +3677,8 @@ int Xorriso_write_to_channel(struct XorrisO *xorriso,
bit15= with bit1 or bit2: close depicted log file bit15= with bit1 or bit2: close depicted log file
*/ */
{ {
char *rpt,*npt,ret= 1; char *rpt,*npt;
int ret= 1, info_redirected= 0, result_redirected= 0;
char prefix[16]; char prefix[16];
FILE *logfile_fp, *pktlog_fp; FILE *logfile_fp, *pktlog_fp;
struct Xorriso_lsT *msglist; struct Xorriso_lsT *msglist;
@ -3728,6 +3730,12 @@ bit15= with bit1 or bit2: close depicted log file
/* Eventually perform messag redirection */ /* Eventually perform messag redirection */
if(xorriso->msglist_stackfill > 0) { if(xorriso->msglist_stackfill > 0) {
if(xorriso->msglist_flags[xorriso->msglist_stackfill - 1] & 1)
result_redirected= 1;
if(xorriso->msglist_flags[xorriso->msglist_stackfill - 1] & 2)
info_redirected= 1;
}
if(result_redirected) {
if(channel_no==1 || channel_no==3) { if(channel_no==1 || channel_no==3) {
msglist= xorriso->result_msglists[xorriso->msglist_stackfill - 1]; msglist= xorriso->result_msglists[xorriso->msglist_stackfill - 1];
ret= Xorriso_lst_append_binary(&msglist, text, strlen(text) + 1, 0); ret= Xorriso_lst_append_binary(&msglist, text, strlen(text) + 1, 0);
@ -3736,6 +3744,8 @@ bit15= with bit1 or bit2: close depicted log file
if(xorriso->result_msglists[xorriso->msglist_stackfill - 1] == NULL) if(xorriso->result_msglists[xorriso->msglist_stackfill - 1] == NULL)
xorriso->result_msglists[xorriso->msglist_stackfill - 1]= msglist; xorriso->result_msglists[xorriso->msglist_stackfill - 1]= msglist;
} }
}
if(info_redirected) {
if(channel_no==2 || channel_no==3) { if(channel_no==2 || channel_no==3) {
msglist= xorriso->info_msglists[xorriso->msglist_stackfill - 1]; msglist= xorriso->info_msglists[xorriso->msglist_stackfill - 1];
ret= Xorriso_lst_append_binary(&msglist, text, strlen(text) + 1, 0); ret= Xorriso_lst_append_binary(&msglist, text, strlen(text) + 1, 0);
@ -3744,8 +3754,11 @@ bit15= with bit1 or bit2: close depicted log file
if(xorriso->info_msglists[xorriso->msglist_stackfill - 1] == NULL) if(xorriso->info_msglists[xorriso->msglist_stackfill - 1] == NULL)
xorriso->info_msglists[xorriso->msglist_stackfill - 1]= msglist; xorriso->info_msglists[xorriso->msglist_stackfill - 1]= msglist;
} }
return(1);
} }
if((channel_no == 1 && result_redirected) ||
(channel_no == 2 && info_redirected) ||
(result_redirected && info_redirected))
return(1);
/* Non-redirected output */ /* Non-redirected output */
if(!xorriso->packet_output) { if(!xorriso->packet_output) {
@ -3828,9 +3841,12 @@ int Xorriso_push_outlists(struct XorrisO *xorriso, int *stack_handle,
"Overflow of message output redirection stack", 0, "FATAL", 0); "Overflow of message output redirection stack", 0, "FATAL", 0);
return(-1); return(-1);
} }
if((flag & 3) == 0)
flag|= 3;
xorriso->msglist_stackfill++; xorriso->msglist_stackfill++;
xorriso->result_msglists[xorriso->msglist_stackfill - 1]= NULL; xorriso->result_msglists[xorriso->msglist_stackfill - 1]= NULL;
xorriso->info_msglists[xorriso->msglist_stackfill - 1]= NULL; xorriso->info_msglists[xorriso->msglist_stackfill - 1]= NULL;
xorriso->msglist_flags[xorriso->msglist_stackfill - 1]= flag & 3;
*stack_handle= xorriso->msglist_stackfill - 1; *stack_handle= xorriso->msglist_stackfill - 1;
return(1); return(1);
} }
@ -3864,13 +3880,16 @@ int Xorriso_result(struct XorrisO *xorriso, int flag)
bit0= no considerations or computations or dialog. Just put out. bit0= no considerations or computations or dialog. Just put out.
*/ */
{ {
int ret; int ret, redirected= 0;
if(flag&1) if(flag&1)
goto put_it_out; goto put_it_out;
if(xorriso->request_to_abort) if(xorriso->request_to_abort)
return(1); return(1);
if(xorriso->result_page_length>0 && xorriso->msglist_stackfill <= 0) { if(xorriso->msglist_stackfill > 0)
if(xorriso->msglist_flags[xorriso->msglist_stackfill - 1] & 1)
redirected= 1;
if(xorriso->result_page_length>0 && !redirected) {
ret= Xorriso_pager(xorriso,xorriso->result_line,2); ret= Xorriso_pager(xorriso,xorriso->result_line,2);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
@ -8844,17 +8863,22 @@ int Xorriso_toc_to_string(struct XorrisO *xorriso, char **toc_text, int flag)
struct Xorriso_lsT *results= NULL, *infos= NULL, *lpt; struct Xorriso_lsT *results= NULL, *infos= NULL, *lpt;
*toc_text= NULL; *toc_text= NULL;
ret= Xorriso_push_outlists(xorriso, &stack_handle, 0); ret= Xorriso_push_outlists(xorriso, &stack_handle, 1);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
toc_ret= Xorriso_toc(xorriso, flag & 4); toc_ret= Xorriso_toc(xorriso, flag & 4);
ret= Xorriso_pull_outlists(xorriso, stack_handle, &results, &infos, 0); ret= Xorriso_pull_outlists(xorriso, stack_handle, &results, &infos, 0);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
#ifdef NIX
/* <<< info is no longer redirected */
for(lpt= infos; lpt != NULL; lpt= Xorriso_lst_get_next(lpt, 0)) { for(lpt= infos; lpt != NULL; lpt= Xorriso_lst_get_next(lpt, 0)) {
strcpy(xorriso->info_text, Xorriso_lst_get_text(lpt, 0)); strcpy(xorriso->info_text, Xorriso_lst_get_text(lpt, 0));
Xorriso_info(xorriso, 0); Xorriso_info(xorriso, 0);
} }
#endif
if(toc_ret <= 0) if(toc_ret <= 0)
{ret= toc_ret; goto ex;} {ret= toc_ret; goto ex;}

View File

@ -163,7 +163,7 @@ struct Xorriso_lsT;
/** Maximum number of stacked redirections */ /** Maximum number of stacked redirections */
#define Xorriso_max_outlist_stacK 32 #define Xorriso_max_outlist_stacK 32
/** Enable a new redirection of info and result channel. The normal message /** Enable a new redirection of info and/or result channel. The normal message
output and eventual older redirections will not see new messages until output and eventual older redirections will not see new messages until
the redirection is ended by a call to Xorriso_pull_outlists() with the the redirection is ended by a call to Xorriso_pull_outlists() with the
stack_handle value returned by this call. stack_handle value returned by this call.
@ -173,7 +173,10 @@ struct Xorriso_lsT;
@param stack_handle returns an id number which is unique as long as @param stack_handle returns an id number which is unique as long as
its redirection is stacked. It may be re-used after its redirection is stacked. It may be re-used after
its redirection was pulled from the stack. its redirection was pulled from the stack.
@param flag unused yet, submit 0 @param flag Bitfield for control purposes
bit0= redirect result channel
bit1= redirect info channel
If bit0 and bit1 are 0, both channels get redirected.
@return 1 on success, <=0 if failure @return 1 on success, <=0 if failure
*/ */
int Xorriso_push_outlists(struct XorrisO *xorriso, int *stack_handle, int Xorriso_push_outlists(struct XorrisO *xorriso, int *stack_handle,

View File

@ -230,6 +230,9 @@ struct XorrisO { /* the global context of xorriso */
FILE *pktlog_fp; FILE *pktlog_fp;
struct Xorriso_lsT *result_msglists[Xorriso_max_outlist_stacK]; struct Xorriso_lsT *result_msglists[Xorriso_max_outlist_stacK];
struct Xorriso_lsT *info_msglists[Xorriso_max_outlist_stacK]; struct Xorriso_lsT *info_msglists[Xorriso_max_outlist_stacK];
int msglist_flags[Xorriso_max_outlist_stacK]; /* bit0= result is redirected
bit1= info is redirected
*/
int msglist_stackfill; int msglist_stackfill;
int status_history_max; /* for -status long_history */ int status_history_max; /* for -status long_history */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.08.14.221412" #define Xorriso_timestamP "2008.08.15.102849"