1 /* wdwrite.c - write key/value to defaults database
3 * WindowMaker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
23 #define PROG_VERSION "wdwrite (Window Maker) 0.2"
26 * WindowMaker defaults DB writer
29 #include "../src/wconfig.h"
36 #include <WINGs/WUtil.h>
44 char *home = getenv("HOME");
50 user = getpwuid(getuid());
69 printf("Syntax:\n%s [OPTIONS] <domain> <option> <value>\n", ProgName);
71 puts(" --help display this help message");
72 puts(" --version output version information and exit");
76 int main(int argc, char **argv)
79 WMPropList *dom, *key, *value, *dict;
85 for (i = 1; i < argc; i++) {
86 if (strcmp("--help", argv[i]) == 0) {
89 } else if (strcmp("--version", argv[i]) == 0) {
96 printf("%s: invalid argument format\n", ProgName);
97 printf("Try '%s --help' for more information\n", ProgName);
101 dom = WMCreatePLString(argv[1]);
102 key = WMCreatePLString(argv[2]);
103 value = WMCreatePropListFromDescription(argv[3]);
105 printf("%s:syntax error in value \"%s\"", ProgName, argv[3]);
108 gsdir = getenv("GNUSTEP_USER_ROOT");
110 path = wstrdup(gsdir);
112 path = wstrdup(gethomedir());
113 path = wstrappend(path, "/GNUstep");
115 path = wstrappend(path, "/");
116 path = wstrappend(path, DEFAULTS_DIR);
117 path = wstrappend(path, "/");
118 path = wstrappend(path, argv[1]);
120 dict = WMReadPropListFromFile(path);
122 dict = WMCreatePLDictionary(key, value, NULL);
124 WMPutInPLDictionary(dict, key, value);
127 WMWritePropListToFile(dict, path, True);