MODULE check_daemon_message (THREAD *thread) { /* This table converts a SYSMAN message id into a dialog event */ static struct { dbyte id; event_t event; } idents [] = { { SYSMAN_READY, ready_event }, { SYSMAN_ERROR, error_event }, { SYSMAN_HALTING, halting_event }, { SYSMAN_TASK_ID, task_id_event }, { SYSMAN_TASK_NF, task_nf_event }, { SYSMAN_TASK_RUNNING, task_running_event }, { SYSMAN_TASK_PAUSED, task_paused_event }, { SYSMAN_TASK_STOPPED, task_stopped_event }, { SYSMAN_START_OK, start_ok_event }, { SYSMAN_START_ERROR, start_error_event }, { SYSMAN_PAUSE_OK, pause_ok_event }, { SYSMAN_PAUSE_ERROR, pause_error_event }, { SYSMAN_STOP_OK, stop_ok_event }, { SYSMAN_STOP_ERROR, stop_error_event }, { 0, 0 } }; int ident_nbr; if (the_external_event == ok_event) { /* Get arguments from message */ control_id = get_control_msg (thread, control_body); for (ident_nbr = 0; idents [ident_nbr].id; ident_nbr++) { if (idents [ident_nbr].id == control_id) { the_next_event = idents [ident_nbr].event; break; } } if (idents [ident_nbr].id == 0) { signal_unexpected_message (thread); raise_exception (exception_event); } } else raise_exception (the_external_event); }
/* Draws error message on the screen or redraws the last message when both * title_arg and message_arg are NULL. */ static void redraw_error_msg(const char title_arg[], const char message_arg[], int prompt_skip, int lazy) { /* TODO: refactor this function redraw_error_msg() */ static const char *title; static const char *message; static int ctrl_c; const char *ctrl_msg; const int centered = (msg_kind == D_QUERY); if(title_arg != NULL && message_arg != NULL) { title = title_arg; message = message_arg; ctrl_c = prompt_skip; } if(title == NULL || message == NULL) { assert(title != NULL && "Asked to redraw dialog, but no title is set."); assert(message != NULL && "Asked to redraw dialog, but no message is set."); return; } ctrl_msg = get_control_msg(msg_kind, ctrl_c); draw_msg(title, message, ctrl_msg, centered, 0); if(lazy) { wnoutrefresh(error_win); } else { wrefresh(error_win); } }