mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-06 13:54:12 +01:00
Idle fixes
- add new wglobaldefaultspathfordomain() to wings (replaces several hand-rolled individual implementations in utils/) - make all of 'em handle -h|--help, -v|--version - try making them not to nothing silently - change various ways of knowing thyselves to using __progname - generally try to make them feel similar (NOT right, similar -- right is a completely different matter)
This commit is contained in:
committed by
Carlos R. Mafra
parent
9dadfe7a68
commit
118a93808a
@@ -29,43 +29,15 @@
|
||||
|
||||
#include "../src/wconfig.h"
|
||||
|
||||
char *ProgName;
|
||||
|
||||
char *defaultsPathForDomain(char *domain)
|
||||
{
|
||||
static char path[1024];
|
||||
char *gspath;
|
||||
|
||||
gspath = getenv("GNUSTEP_USER_ROOT");
|
||||
if (gspath) {
|
||||
strcpy(path, gspath);
|
||||
strcat(path, "/");
|
||||
} else {
|
||||
char *home;
|
||||
|
||||
home = getenv("HOME");
|
||||
if (!home) {
|
||||
printf("%s:could not get HOME environment variable!\n", ProgName);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
strcpy(path, home);
|
||||
strcat(path, "/GNUstep/");
|
||||
}
|
||||
strcat(path, DEFAULTS_DIR);
|
||||
strcat(path, "/");
|
||||
strcat(path, domain);
|
||||
|
||||
return path;
|
||||
}
|
||||
extern char *__progname;
|
||||
|
||||
void print_help()
|
||||
{
|
||||
printf("Usage: %s [OPTIONS] FILE\n", ProgName);
|
||||
printf("Usage: %s [OPTIONS] FILE\n", __progname);
|
||||
puts("Reads icon configuration from FILE and updates Window Maker.");
|
||||
puts("");
|
||||
puts(" --help display this help and exit");
|
||||
puts(" --version output version information and exit");
|
||||
puts(" -h, --help display this help and exit");
|
||||
puts(" -v, --version output version information and exit");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
@@ -75,41 +47,40 @@ int main(int argc, char **argv)
|
||||
int i;
|
||||
char *path = NULL;
|
||||
|
||||
ProgName = argv[0];
|
||||
|
||||
if (argc < 2) {
|
||||
printf("%s: missing argument\n", ProgName);
|
||||
printf("Try '%s --help' for more information\n", ProgName);
|
||||
printf("%s: missing argument\n", __progname);
|
||||
printf("Try '%s --help' for more information\n", __progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
||||
print_help();
|
||||
exit(0);
|
||||
} else if (strcmp(argv[i], "--version") == 0) {
|
||||
} else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
|
||||
puts(PROG_VERSION);
|
||||
exit(0);
|
||||
} else {
|
||||
if (path) {
|
||||
printf("%s: invalid argument '%s'\n", ProgName, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", ProgName);
|
||||
printf("%s: invalid argument '%s'\n", __progname, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", __progname);
|
||||
exit(1);
|
||||
}
|
||||
path = argv[i];
|
||||
}
|
||||
}
|
||||
|
||||
path = defaultsPathForDomain("WMWindowAttributes");
|
||||
path = wdefaultspathfordomain("WMWindowAttributes");
|
||||
|
||||
all_windows = WMReadPropListFromFile(path);
|
||||
if (!all_windows) {
|
||||
printf("%s:could not load WindowMaker configuration file \"%s\".\n", ProgName, path);
|
||||
printf("%s: could not load WindowMaker configuration file \"%s\".\n", __progname, path);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
iconset = WMReadPropListFromFile(argv[1]);
|
||||
if (!iconset) {
|
||||
printf("%s:could not load icon set file \"%s\".\n", ProgName, argv[1]);
|
||||
printf("%s: could not load icon set file \"%s\".\n", __progname, argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user