From 72640eecc20e9babed3661335e2ea71dd10ee618 Mon Sep 17 00:00:00 2001 From: Tim Segers Date: Fri, 23 Dec 2022 20:01:46 +0100 Subject: Add support for toml-based config file --- src/opendeco.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/opendeco.c') diff --git a/src/opendeco.c b/src/opendeco.c index 862923e..029a81f 100644 --- a/src/opendeco.c +++ b/src/opendeco.c @@ -138,13 +138,16 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, "en_US.utf8"); /* argp */ + char *gas_default = strdup("Air"); + char *decogasses_default = strdup(""); + struct arguments arguments = { .depth = -1, .time = -1, - .gas = "Air", + .gas = gas_default, .gflow = 30, .gfhigh = 75, - .decogasses = "", + .decogasses = decogasses_default, .SURFACE_PRESSURE = SURFACE_PRESSURE_DEFAULT, .SWITCH_INTERMEDIATE = SWITCH_INTERMEDIATE_DEFAULT, .LAST_STOP_AT_SIX = LAST_STOP_AT_SIX_DEFAULT, @@ -153,6 +156,7 @@ int main(int argc, char *argv[]) .SHOW_TRAVEL = SHOW_TRAVEL_DEFAULT, }; + opendeco_conf_parse("opendeco.toml", &arguments); opendeco_argp_parse(argc, argv, &arguments); /* apply global options */ @@ -213,6 +217,10 @@ int main(int argc, char *argv[]) wprintf(L"\nNDL: %i TTS: %i TTS @+5: %i\n", (int) floor(di.ndl), (int) ceil(di.tts), (int) ceil(di_plus5.tts)); print_planfoot(&ds); + /* cleanup */ free(deco_gasses); + free(arguments.gas); + free(arguments.decogasses); + return 0; } -- cgit v1.2.3-70-g09d2