wmail: call `XSetCommand()`.
[dockapps.git] / fookb / params.c
blob8501e04fb7f1c9a14cb2daa7fcb710098e94e4d1
1 #include <stdio.h>
2 #include <string.h> /* strlen & strcat */
3 #include <ctype.h> /* toupper */
4 #include <stdlib.h>
5 #include <WINGs/WUtil.h>
6 #include "params.h"
7 #include "opts.h"
9 /* Let's make lint happy */
10 #define lputs(x) (void)puts(x)
12 char *read_param(char *string)
14 WMPropList *pl;
15 WMPropList *value;
16 WMPropList *tmp;
17 char *path;
18 char *result;
20 /* Command line parameters take precedence over all */
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;
34 * Here we start the game with property lists.
35 * pl will be property list, read from DEFAULTS_FILE.
36 * tmp will be temporary key for this property list,
37 * constructed using ``string'', supplied to function.
38 * value will be property list, which contain the value
39 * of parameter
42 path = wexpandpath(DEFAULTS_FILE);
43 pl = WMReadPropListFromFile(path);
44 wfree(path);
46 if (!pl) {
47 lputs("Cannot open config file: ");
48 lputs(DEFAULTS_FILE);
49 exit(EXIT_FAILURE);
52 tmp = WMCreatePLString(string);
53 value = WMGetFromPLDictionary(pl, tmp);
54 WMReleasePropList(tmp);
57 * pl and value objects will exist as long as fookb is running
60 if (!value) {
61 lputs("Cannot find in config file value for: ");
62 lputs(string);
63 exit(EXIT_FAILURE);
66 if (!WMIsPLString(value)) {
67 lputs("Value for: ");
68 lputs(string);
69 lputs("in config file is not a string.");
70 exit(EXIT_FAILURE);
73 result = WMGetFromPLString(value);
75 if (!result) {
76 lputs("Something wrong with libWUtils :(");
77 lputs("Please report this error to fookb author.");
78 exit(EXIT_FAILURE);
81 return result;