Changed prototype of new API call Xorriso_start_msg_watcher()

This commit is contained in:
2012-09-15 09:52:29 +00:00
parent eaa501c9ec
commit 6338febf8f
6 changed files with 51 additions and 25 deletions

View File

@ -938,7 +938,7 @@ ex:;
}
int Xorriso_result_handler_stdout(struct XorrisO *xorriso, char *text)
int Xorriso_result_handler_stdout(void *handle, char *text)
{
printf("%s", text);
fflush(stdout);
@ -946,8 +946,11 @@ int Xorriso_result_handler_stdout(struct XorrisO *xorriso, char *text)
}
int Xorriso_info_handler_stderr(struct XorrisO *xorriso, char *text)
int Xorriso_info_handler_stderr(void *handle, char *text)
{
struct XorrisO *xorriso;
xorriso= (struct XorrisO *) handle;
if(xorriso->stderr_fp != NULL) {
fprintf(xorriso->stderr_fp, "%s", text);
fflush(xorriso->stderr_fp);
@ -966,23 +969,30 @@ int Xorriso_process_msg_lists(struct XorrisO *xorriso,
{
struct Xorriso_lsT *lpt;
int ret;
int (*handler)(struct XorrisO *xorriso, char *text);
int (*handler)(void *handle, char *text);
void *handle;
handler= xorriso->msgw_result_handler;
if(handler == NULL)
handle= xorriso->msgw_result_handle;
if(handler == NULL) {
handler= Xorriso_result_handler_stdout;
handle= xorriso;
}
for(lpt= result_list; lpt != NULL; lpt= lpt->next) {
(*line_count)++;
ret= (*handler)(xorriso, Xorriso_lst_get_text(lpt, 0));
ret= (*handler)(handle, Xorriso_lst_get_text(lpt, 0));
if(ret < 0)
return(-1);
}
handler= xorriso->msgw_info_handler;
if(handler == NULL)
handle= xorriso->msgw_info_handle;
if(handler == NULL) {
handler= Xorriso_info_handler_stderr;
handle= xorriso;
}
for(lpt= info_list; lpt != NULL; lpt= lpt->next) {
(*line_count)++;
ret= (*handler)(xorriso, Xorriso_lst_get_text(lpt, 0));
ret= (*handler)(handle, Xorriso_lst_get_text(lpt, 0));
if(ret < 0)
return(-1);
}
@ -993,7 +1003,7 @@ int Xorriso_process_msg_lists(struct XorrisO *xorriso,
static void *Xorriso_msg_watcher(void *state_pt)
{
struct XorrisO *xorriso;
int ret, u_wait= 10000, line_count, sleep_thresh= 20;
int ret, u_wait= 25000, line_count, sleep_thresh= 20;
struct Xorriso_lsT *result_list= NULL, *info_list= NULL;
static int debug_sev= 0;
@ -1042,8 +1052,10 @@ static void *Xorriso_msg_watcher(void *state_pt)
int Xorriso_start_msg_watcher(struct XorrisO *xorriso,
int (*result_handler)(struct XorrisO *xorriso, char *text),
int (*info_handler)(struct XorrisO *xorriso, char *text),
int (*result_handler)(void *handle, char *text),
void *result_handle,
int (*info_handler)(void *handle, char *text),
void *info_handle,
int flag)
{
int ret, u_wait= 1000, locked= 0, pushed= 0, uret, line_count= 0;
@ -1076,7 +1088,9 @@ int Xorriso_start_msg_watcher(struct XorrisO *xorriso,
/* Register watcher */
xorriso->msgw_result_handler= result_handler;
xorriso->msgw_result_handle= result_handle;
xorriso->msgw_info_handler= info_handler;
xorriso->msgw_info_handle= info_handle;
xorriso->msg_watcher_state= 1;
/* Start thread */