Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
goto ERROR;
}
- // Print the stats
- r = fireperf_ctx_dump_stats(ctx);
+ // Fetch the stats
+ struct fireperf_stats stats = fireperf_ctx_get_stats(ctx);
+
+ // Update the TUI
+ r = fireperf_tui_update(ctx->tui, stats);
if (r)
goto ERROR;
#include <ncurses.h>
#include "ctx.h"
+#include "stats.h"
#include "tui.h"
+#define MAX_STATS 128
+
struct fireperf_tui {
struct fireperf_ctx* ctx;
+ // Stats
+ struct fireperf_stats stats[MAX_STATS];
+ unsigned int s;
+
// The main screen
WINDOW* screen;
return 0;
}
+
+/*
+ Called when there is new data to update the UI
+*/
+int fireperf_tui_update(struct fireperf_tui* tui, struct fireperf_stats stats) {
+ int r;
+
+ // Store stats
+ tui->stats[tui->s++] = stats;
+
+ // Wrap the pointer around
+ tui->s %= MAX_STATS;
+
+ return 0;
+}
struct fireperf_tui;
#include "ctx.h"
+#include "stats.h"
int fireperf_tui_init(struct fireperf_tui** tui, struct fireperf_ctx* ctx);
void fireperf_tui_finish(struct fireperf_tui* tui);
int fireperf_tui_register(struct fireperf_tui* tui, int epollfd);
int fireperf_tui_action(struct fireperf_tui* tui);
+int fireperf_tui_update(struct fireperf_tui* tui, struct fireperf_stats stats);
+
#endif /* FIREPERF_TUI_H */