From b083b5fb858b08ef3f9144187a2f53ed4423a556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Sat, 25 Jan 2025 21:27:08 -0500 Subject: [PATCH] Add the thing to save the web lists. --- src/syncterm/bbslist.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/syncterm/bbslist.c b/src/syncterm/bbslist.c index 611a235e58..e6ea7eb45d 100644 --- a/src/syncterm/bbslist.c +++ b/src/syncterm/bbslist.c @@ -2917,7 +2917,38 @@ kbwait(void) static void write_webgets(void) { - // TODO: Save changes + FILE *inifile; + char inipath[MAX_PATH + 1]; + str_list_t ini_file; + + if (safe_mode) + return; + get_syncterm_filename(inipath, sizeof(inipath), SYNCTERM_PATH_INI, false); + if ((inifile = fopen(inipath, "r")) != NULL) { + ini_file = iniReadFile(inifile); + fclose(inifile); + } + else { + ini_file = strListInit(); + } + + iniRemoveSection(&ini_file, "WebLists"); + + if (settings.webgets != NULL) { + for (size_t i = 0; settings.webgets[i]; i++) + iniSetString(&ini_file, "WebLists", settings.webgets[i]->name, settings.webgets[i]->value, &ini_style); + } + if ((inifile = fopen(inipath, "w")) != NULL) { + iniWriteFile(inifile, ini_file); + fclose(inifile); + } + else { + uifc.helpbuf = "There was an error writing the INI file.\nCheck permissions and try again.\n"; + uifc.msg("Cannot write to the .ini file!"); + check_exit(false); + } + + strListFree(&ini_file); } static void -- GitLab