aboutsummaryrefslogtreecommitdiff
path: root/ui/daemon/ui.j2.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/daemon/ui.j2.c')
-rw-r--r--ui/daemon/ui.j2.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/ui/daemon/ui.j2.c b/ui/daemon/ui.j2.c
index 7d92f9d..02df79b 100644
--- a/ui/daemon/ui.j2.c
+++ b/ui/daemon/ui.j2.c
@@ -8,13 +8,36 @@
volatile bool g_running;
uint64_t g_step_block;
+void info_impl(const char *restrict fmt, ...) {
+ assert(fmt);
+ printf("\033[1;34mINFO:\033[0m ");
+
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+
+ printf("\n");
+}
+
+void warn_impl(const char *restrict fmt, ...) {
+ assert(fmt);
+ printf("\033[1;31mWARN:\033[0m ");
+
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+
+ printf("\n");
+}
+
void sig_handler(int signo) {
- switch (signo) {
- case SIGINT:
- case SIGTERM:
- printf("Signal received, will stop simulator soon...\n");
+ (void)signo;
+
+ if (g_running) {
+ g_warn("Signal received, will stop simulator soon...");
g_running = false;
- break;
}
}
@@ -31,10 +54,13 @@ void step_block() {
g_step_block >>= 1;
}
- printf("Simulator running on step '%#lx'\n", g_steps);
+ g_info("Simulator running on step '%#lx'", g_steps);
}
int main() {
+ g_info = info_impl;
+ g_warn = warn_impl;
+
{% if args.command == "new" %}
salis_init();
{% elif args.command == "load" %}
@@ -51,10 +77,10 @@ int main() {
step_block();
}
- printf("Saving simulation...\n");
+ g_info("Saving simulation...");
salis_save("{{ sim_path }}");
salis_free();
- printf("Exiting salis...\n");
+ g_info("Exiting salis...");
return 0;
}