1 /* wdread.c - read value from defaults database
3 * WindowMaker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * (cowardly remade from wdwrite.c; by judas@hell on Jan 26 2001)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #define _GNU_SOURCE /* getopt_long */
28 * WindowMaker defaults DB reader
38 #include <WINGs/WUtil.h>
40 #include "../src/wconfig.h"
42 extern char *__progname
;
44 void print_help(int print_usage
, int exitval
)
46 printf("Usage: %s [OPTIONS] <domain> <key>\n", __progname
);
48 puts("Read <key> from <domain>'s database");
50 puts(" -h, --help display this help message");
51 puts(" -v, --version output version information and exit");
56 int main(int argc
, char **argv
)
59 WMPropList
*key
, *value
, *dict
;
62 struct option longopts
[] = {
63 { "version", no_argument
, NULL
, 'v' },
64 { "help", no_argument
, NULL
, 'h' },
68 while ((ch
= getopt_long(argc
, argv
, "hv", longopts
, NULL
)) != -1)
71 printf("%s (Window Maker %s)\n", __progname
, VERSION
);
90 key
= WMCreatePLString(argv
[1]);
92 snprintf(path
, sizeof(path
), "%s", wdefaultspathfordomain(argv
[0]));
94 dict
= WMReadPropListFromFile(path
);
96 return 1; /* bad domain */
98 value
= WMGetFromPLDictionary(dict
, key
);
100 return 2; /* bad key */
102 printf("%s\n", WMGetPropListDescription(value
, True
));