diff --git a/src/container.c b/src/container.c index 29e7bb83..eb36401e 100644 --- a/src/container.c +++ b/src/container.c @@ -1749,21 +1749,15 @@ static const DialogDef DlgContainer = { */ #include "conf.h" -static void -ContainersConfigLoad(void) +static int +_ContainersConfigLoad(FILE * fs) { int err = 0; - FILE *fs; char s[FILEPATH_LEN_MAX]; char s2[FILEPATH_LEN_MAX]; int i1, i2; Container *ct, ct_dummy; - Esnprintf(s, sizeof(s), "%s.ibox", EGetSavePrefix()); - fs = fopen(s, "r"); - if (!fs) - return; - ct = &ct_dummy; while (fgets(s, sizeof(s), fs)) { @@ -1831,11 +1825,22 @@ ContainersConfigLoad(void) break; } } + + done: if (err) Eprintf("Error: Iconbox configuration file load problem.\n"); - done: - fclose(fs); + return err; +} + +static void +ContainersConfigLoad(void) +{ + char s[4096]; + + Esnprintf(s, sizeof(s), "%s.ibox", EGetSavePrefix()); + + ConfigFileLoad(s, NULL, _ContainersConfigLoad, 0); } static void diff --git a/src/groups.c b/src/groups.c index 771d6946..2d991629 100644 --- a/src/groups.c +++ b/src/groups.c @@ -537,19 +537,13 @@ GroupsSave(void) fclose(f); } -void -GroupsLoad(void) +static int +_GroupsLoad(FILE * fs) { - FILE *f; char s[1024]; Group *g = NULL; - Esnprintf(s, sizeof(s), "%s.groups", EGetSavePrefix()); - f = fopen(s, "r"); - if (!f) - return; - - while (fgets(s, sizeof(s), f)) + while (fgets(s, sizeof(s), fs)) { char ss[128]; int ii; @@ -596,7 +590,18 @@ GroupsLoad(void) g->cfg.shade = ii; } } - fclose(f); + + return 0; +} + +void +GroupsLoad(void) +{ + char s[4096]; + + Esnprintf(s, sizeof(s), "%s.groups", EGetSavePrefix()); + + ConfigFileLoad(s, NULL, _GroupsLoad, 0); } #if ENABLE_DIALOGS diff --git a/src/snaps.c b/src/snaps.c index 5f451853..6c0b0a36 100644 --- a/src/snaps.c +++ b/src/snaps.c @@ -1184,24 +1184,16 @@ SnapshotsSpawn(void) } /* load all snapped info */ -void -SnapshotsLoad(void) +static int +_SnapshotsLoad(FILE * fs) { Snapshot *sn = NULL; char buf[4096], *s; - FILE *f; int res_w, res_h, a, b, c, d; - GroupsLoad(); - - Esnprintf(buf, sizeof(buf), "%s.snapshots", EGetSavePrefix()); - f = fopen(buf, "r"); - if (!f) - return; - res_w = WinGetW(VROOT); res_h = WinGetH(VROOT); - while (fgets(buf, sizeof(buf), f)) + while (fgets(buf, sizeof(buf), fs)) { s = strchr(buf, ':'); if (!s) @@ -1390,7 +1382,20 @@ SnapshotsLoad(void) #endif } } - fclose(f); + + return 0; +} + +void +SnapshotsLoad(void) +{ + char s[4096]; + + GroupsLoad(); + + Esnprintf(s, sizeof(s), "%s.snapshots", EGetSavePrefix()); + + ConfigFileLoad(s, NULL, _SnapshotsLoad, 0); } /* make a client window conform to snapshot info */