1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-28 09:22:27 +01:00

Collect low-hanging fruits

This commit is contained in:
Tamas TEVESZ
2010-03-18 01:25:03 +01:00
committed by Carlos R. Mafra
parent 5f02b1b5f4
commit d51bbe6626
2 changed files with 41 additions and 119 deletions

View File

@@ -373,16 +373,9 @@ void print_help()
puts(" --no-cursors ignore cursor related options");
puts(" --ignore <option> ignore changes in the specified option");
puts(" --help display this help and exit");
/*
puts(" --format <format> specifies the format of the theme to be converted");
*/
puts(" --version output version information and exit");
/*puts("");
puts("Supported formats: blackbox"); */
}
#define F_BLACKBOX 1
int main(int argc, char **argv)
{
WMPropList *prop, *style;
@@ -422,20 +415,6 @@ int main(int argc, char **argv)
} else if (strcmp("--help", argv[i]) == 0) {
print_help();
exit(0);
#if 0
} else if (strcmp("--format", argv[i]) == 0) {
i++;
if (i == argc) {
printf("%s: missing argument for option --format\n", ProgName);
exit(1);
}
if (strcasecmp(argv[i], "blackbox") == 0) {
format = F_BLACKBOX;
} else {
printf("%s: unknown theme format '%s'\n", ProgName, argv[i]);
exit(1);
}
#endif
} else {
if (file) {
printf("%s: invalid argument '%s'\n", ProgName, argv[i]);
@@ -461,63 +440,52 @@ int main(int argc, char **argv)
perror(file);
exit(1);
}
#if 0
if (format == F_BLACKBOX) {
style = readBlackBoxStyle(file);
if (!style) {
printf("%s: could not open style file\n", ProgName);
if (S_ISDIR(statbuf.st_mode)) {
char buffer[4018];
char *prefix;
/* theme pack */
if (*argv[argc - 1] != '/') {
if (!getcwd(buffer, 4000)) {
printf("%s: complete path for %s is too long\n", ProgName, file);
exit(1);
}
if (strlen(buffer) + strlen(file) > 4000) {
printf("%s: complete path for %s is too long\n", ProgName, file);
exit(1);
}
strcat(buffer, "/");
} else {
buffer[0] = 0;
}
strcat(buffer, file);
prefix = malloc(strlen(buffer) + 10);
if (!prefix) {
printf("%s: out of memory\n", ProgName);
exit(1);
}
} else
#endif
{
if (S_ISDIR(statbuf.st_mode)) {
char buffer[4018];
char *prefix;
/* theme pack */
strcpy(prefix, buffer);
if (*argv[argc - 1] != '/') {
if (!getcwd(buffer, 4000)) {
printf("%s: complete path for %s is too long\n", ProgName, file);
exit(1);
}
if (strlen(buffer) + strlen(file) > 4000) {
printf("%s: complete path for %s is too long\n", ProgName, file);
exit(1);
}
strcat(buffer, "/");
} else {
buffer[0] = 0;
}
strcat(buffer, file);
strcat(buffer, "/style");
prefix = malloc(strlen(buffer) + 10);
if (!prefix) {
printf("%s: out of memory\n", ProgName);
exit(1);
}
strcpy(prefix, buffer);
style = WMReadPropListFromFile(buffer);
if (!style) {
perror(buffer);
printf("%s:could not load style file.\n", ProgName);
exit(1);
}
strcat(buffer, "/style");
hackPaths(style, prefix);
free(prefix);
} else {
/* normal style file */
style = WMReadPropListFromFile(buffer);
if (!style) {
perror(buffer);
printf("%s:could not load style file.\n", ProgName);
exit(1);
}
hackPaths(style, prefix);
free(prefix);
} else {
/* normal style file */
style = WMReadPropListFromFile(file);
if (!style) {
perror(file);
printf("%s:could not load style file.\n", ProgName);
exit(1);
}
style = WMReadPropListFromFile(file);
if (!style) {
perror(file);
printf("%s:could not load style file.\n", ProgName);
exit(1);
}
}
@@ -561,32 +529,3 @@ int main(int argc, char **argv)
exit(0);
}
#if 0
char *getToken(char *str, int i, char *buf)
{
}
static WMPropList *readBlackBoxStyle(char *path)
{
FILE *f;
char buffer[128], char token[128];
WMPropList *style, *p;
f = fopen(path, "rb");
if (!f) {
perror(path);
return NULL;
}
while (1) {
if (!fgets(buffer, 127, f))
break;
if (strncasecmp(buffer, "menu.title:", 11) == 0) {
}
}
}
#endif