Skip to content

Commit d467d2c

Browse files
a3a3elcrmafra
authored andcommitted
fookb: add default parameter values.
If there is no config-file in $HOME, use a default parameter value instead of complaining and exiting. Signed-off-by: Jeremy Sowden <[email protected]>
1 parent f6531a0 commit d467d2c

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

fookb/params.c

+35-13
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,40 @@ char *read_param(char *string)
1919

2020
/* Command line parameters take precedence over all */
2121

22-
if (!strcmp(string, "Icon1") && icon1)
23-
return icon1;
24-
if (!strcmp(string, "Icon2") && icon2)
25-
return icon2;
26-
if (!strcmp(string, "Icon3") && icon3)
27-
return icon3;
28-
if (!strcmp(string, "Icon4") && icon4)
29-
return icon4;
30-
if (!strcmp(string, "IconBoom") && iconboom)
31-
return iconboom;
22+
if (!strcmp(string, "Icon1")) {
23+
if (icon1)
24+
return icon1;
25+
26+
result = DEFAULT_ICON1;
27+
}
28+
if (!strcmp(string, "Icon2")) {
29+
if (icon2)
30+
return icon2;
31+
32+
result = DEFAULT_ICON2;
33+
}
34+
if (!strcmp(string, "Icon3")) {
35+
if (icon3)
36+
return icon3;
37+
38+
result = DEFAULT_ICON3;
39+
}
40+
if (!strcmp(string, "Icon4")) {
41+
if (icon4)
42+
return icon4;
43+
44+
result = DEFAULT_ICON4;
45+
}
46+
if (!strcmp(string, "IconBoom")) {
47+
if (iconboom)
48+
return iconboom;
49+
50+
result = DEFAULT_ICON_BOOM;
51+
}
52+
if (!strcmp(string, "Sound"))
53+
result = DEFAULT_SOUND;
54+
if (!strcmp(string, "Command"))
55+
result = DEFAULT_COMMAND;
3256

3357
/*
3458
* Here we start the game with property lists.
@@ -44,9 +68,7 @@ char *read_param(char *string)
4468
wfree(path);
4569

4670
if (!pl) {
47-
lputs("Cannot open config file: ");
48-
lputs(DEFAULTS_FILE);
49-
exit(EXIT_FAILURE);
71+
return result;
5072
}
5173

5274
tmp = WMCreatePLString(string);

fookb/params.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88
#ifndef PARAMS_H
99
#define PARAMS_H
1010

11+
#define DEFAULTS_FILE "~/.fookb"
1112

12-
#define DEFAULTS_FILE "~/.fookb"
13+
#define DEFAULT_ICON1 "/usr/local/share/fookb/lat.xpm"
14+
#define DEFAULT_ICON2 "/usr/local/share/fookb/rus.xpm"
15+
#define DEFAULT_ICON3 "/usr/local/share/fookb/3.xpm"
16+
#define DEFAULT_ICON4 "/usr/local/share/fookb/4.xpm"
17+
#define DEFAULT_ICON_BOOM "/usr/local/share/fookb/boom.xpm"
18+
#define DEFAULT_SOUND "Yes"
19+
#define DEFAULT_COMMAND "/usr/bin/play /usr/local/share/fookb/beep_spring.au"
1320

1421
char *read_param(char *);
1522

0 commit comments

Comments
 (0)