#include <frsh.h>
#include <ncurses.h>
#include <fwp_res.h>
+#include <ul_log.h>
+#include <ul_logreg.h>
+
+static UL_LOG_CUST(ulogd);
+static ul_log_domain_t ulogd = {UL_LOGL_MSG, "wclient"};
+UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(init_ulogd_wclient, ulogd);
+
#endif
#define MAX_STREAMS 10
void wait_for_all_threads_to_finish_fwp(void)
{
int i;
- /* Wait for all threads to finish */
- /* FIXME: */
-/* for (i=0; i < 2*nr_streams; i++) { */
-/* sem_wait(&sem_thread_finished); */
-/* } */
+ /* wait for all threads to finish */
+ for (i=0; i < 2*nr_streams; i++) {
+ sem_wait(&sem_thread_finished);
+ }
}
#else
void wait_for_all_threads_to_finish_native(void)
#endif
#ifdef WITH_FWP
+
+WINDOW *logwin;
+
+struct log_params {
+ ul_log_domain_t *domain;
+ int level;
+ const char *format;
+ va_list ap;
+};
+
+
+int locked_log(WINDOW *logwin, void *arg)
+{
+ struct log_params *p = arg;
+ if(!(p->level&UL_LOGL_CONT)) {
+ p->level&=UL_LOGL_MASK;
+ if(p->level)
+ wprintw(logwin,"<%d>", p->level);
+ if(p->domain && p->domain->name)
+ wprintw(logwin,"%s: ",p->domain->name);
+ }
+ vwprintw(logwin, p->format, p->ap);
+ wnoutrefresh(logwin);
+ return 0;
+}
+
+void
+wclient_log_fnc(ul_log_domain_t *domain, int level,
+ const char *format, va_list ap)
+{
+ struct log_params p = {
+ .domain = domain,
+ .level = level,
+ .format = format,
+ };
+ va_copy(p.ap, ap);
+ va_end(ap);
+
+ use_window(logwin, locked_log, (void*)&p);
+}
+
+
void init_gui()
{
initscr();
cbreak();
noecho();
+
+ logwin = newwin(0, 0, LINES/2, 0);
+ if (logwin) {
+ scrollok(logwin, TRUE);
+ ul_log_redir(wclient_log_fnc, 0);
+ }
+}
+
+void end_gui()
+{
+ endwin();
+ if (logwin) {
+ ul_log_redir(NULL, 0);
+ }
}
+
#define addfield(title, format, ...) \
move(y, x); \
x+=strlen(title)+1; \
addfield("Worst-case delay", "%s", usec_to_text(s1, s->wc_delay));
addfield("Received responses", "%lld", s->received);
}
- refresh();
+ wnoutrefresh(stdscr);
+ doupdate();
}
#else
void init_gui() {}
+void end_gui() {}
void print_status(int seconds)
{
int ac;
if (some_contract_not_accepted) {
stopper();
} else {
- //init_gui();
+ init_gui();
seconds = 1;
frames=0;
}
#ifdef WITH_FWP
- //endwin();
+ end_gui();
for (i=0; i < nr_streams; i++) {
if (streams[i].vres)
frsh_contract_cancel(streams[i].vres);