From b05f38abd013174465a499b38f7e0a2acc634b5b Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Sat, 20 Apr 2024 14:51:45 +0200 Subject: [PATCH] Add missing options to show configuration --- src/alert.c | 20 ++++++++++++++++++-- src/alert.h | 7 ++++--- src/options.c | 21 ++++++++++++++++++++- src/options.h | 6 +++--- src/script.c | 16 ++++++++++++++++ src/script.h | 5 +++-- 6 files changed, 64 insertions(+), 11 deletions(-) diff --git a/src/alert.c b/src/alert.c index cc6abdd..e2f90a4 100644 --- a/src/alert.c +++ b/src/alert.c @@ -19,6 +19,7 @@ * 02110-1301, USA. */ +#include "alert.h" #include "config.h" #include #include @@ -28,9 +29,9 @@ #include "print.h" #include "options.h" -enum alert_t alert_option_parse(const char *arg) +alert_t alert_option_parse(const char *arg) { - enum alert_t alert = option.alert; // Default + alert_t alert = option.alert; // Default if (arg != NULL) { @@ -108,3 +109,18 @@ void alert_disconnect(void) break; } } + +const char *alert_state_to_string(alert_t state) +{ + switch (state) + { + case ALERT_NONE: + return "none"; + case ALERT_BELL: + return "bell"; + case ALERT_BLINK: + return "blink"; + default: + return "Unknown"; + } +} diff --git a/src/alert.h b/src/alert.h index 10932ea..d7b66f5 100644 --- a/src/alert.h +++ b/src/alert.h @@ -21,14 +21,15 @@ #pragma once -enum alert_t +typedef enum { ALERT_NONE, ALERT_BELL, ALERT_BLINK, ALERT_END, -}; +} alert_t; -enum alert_t alert_option_parse(const char *arg); +alert_t alert_option_parse(const char *arg); void alert_connect(void); void alert_disconnect(void); +const char *alert_state_to_string(alert_t state); diff --git a/src/options.c b/src/options.c index 500ede1..79556aa 100644 --- a/src/options.c +++ b/src/options.c @@ -289,7 +289,7 @@ const char *output_mode_by_string(output_mode_t mode) return NULL; } -enum script_run_t script_run_option_parse(const char *arg) +script_run_t script_run_option_parse(const char *arg) { if (strcmp("once", arg) == 0) { @@ -320,6 +320,7 @@ void options_print() tio_printf(" Parity: %s", option.parity); tio_printf(" Local echo: %s", option.local_echo ? "enabled" : "disabled"); tio_printf(" Timestamp: %s", timestamp_state_to_string(option.timestamp)); + tio_printf(" Timestamp timeout: %u", option.timestamp_timeout); tio_printf(" Output delay: %d", option.output_delay); tio_printf(" Output line delay: %d", option.output_line_delay); tio_printf(" Auto connect: %s", option.no_autoconnect ? "disabled" : "enabled"); @@ -331,12 +332,30 @@ void options_print() option.ri_pulse_duration); tio_printf(" Input mode: %s", input_mode_by_string(option.input_mode)); tio_printf(" Output mode: %s", output_mode_by_string(option.output_mode)); + tio_printf(" Alert: %s", alert_state_to_string(option.alert)); if (option.map[0] != 0) + { tio_printf(" Map flags: %s", option.map); + } if (option.log) + { tio_printf(" Log file: %s", log_get_filename()); + if (option.log_directory != NULL) + { + tio_printf(" Log file directory: %s", option.log_directory); + } + tio_printf(" Log append: %s", option.log_append ? "enabled" : "disabled"); + tio_printf(" Log strip: %s", option.log_strip ? "enabled" : "disabled"); + } if (option.socket) + { tio_printf(" Socket: %s", option.socket); + } + if (option.script_filename != NULL) + { + tio_printf(" Script file: %s", option.script_filename); + tio_printf(" Script run: %s", script_run_state_to_string(option.script_run)); + } } void options_parse(int argc, char *argv[]) diff --git a/src/options.h b/src/options.h index dca5d13..6f872a5 100644 --- a/src/options.h +++ b/src/options.h @@ -83,11 +83,11 @@ struct option_t uint32_t rs485_config_flags; int32_t rs485_delay_rts_before_send; int32_t rs485_delay_rts_after_send; - enum alert_t alert; + alert_t alert; bool complete_sub_configs; const char *script; const char *script_filename; - enum script_run_t script_run; + script_run_t script_run; unsigned int timestamp_timeout; }; @@ -98,7 +98,7 @@ void options_parse(int argc, char *argv[]); void options_parse_final(int argc, char *argv[]); void line_pulse_duration_option_parse(const char *arg); -enum script_run_t script_run_option_parse(const char *arg); +script_run_t script_run_option_parse(const char *arg); input_mode_t input_mode_option_parse(const char *arg); output_mode_t output_mode_option_parse(const char *arg); diff --git a/src/script.c b/src/script.c index da2a9a1..8dd91dd 100644 --- a/src/script.c +++ b/src/script.c @@ -35,6 +35,7 @@ #include "tty.h" #include "xymodem.h" #include "log.h" +#include "script.h" #define MAX_BUFFER_SIZE 2000 // Maximum size of circular buffer @@ -523,3 +524,18 @@ void script_run(int fd) lua_close(L); } + +const char *script_run_state_to_string(script_run_t state) +{ + switch (state) + { + case SCRIPT_RUN_ONCE: + return "once"; + case SCRIPT_RUN_ALWAYS: + return "always"; + case SCRIPT_RUN_NEVER: + return "never"; + default: + return "Unknown"; + } +} diff --git a/src/script.h b/src/script.h index a2778e7..d6df204 100644 --- a/src/script.h +++ b/src/script.h @@ -21,12 +21,13 @@ #pragma once -enum script_run_t +typedef enum { SCRIPT_RUN_ONCE, SCRIPT_RUN_ALWAYS, SCRIPT_RUN_NEVER, SCRIPT_RUN_END, -}; +} script_run_t; void script_run(int fd); +const char *script_run_state_to_string(script_run_t state);