Use ConfigFileLoad some more.

SVN revision: 47704
This commit is contained in:
Kim Woelders 2010-04-02 15:28:20 +00:00
parent 155a5473f0
commit e6beff1eaf
3 changed files with 47 additions and 32 deletions

View File

@ -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

View File

@ -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

View File

@ -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 */