mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 12:00:31 +01:00
util: removed usage of external '__progname' because it is not portable
As reported by Milan Čermák, using this variable breaks compilation on Solaris, because it is a hack which is not standard. To ensure portability, we now rely on main's argv[0] which is always available. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
ff8fc10a65
commit
3de5b8fb42
@@ -56,12 +56,12 @@ char *FontOptions[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
|
||||
static noreturn void print_help(int print_usage, int exitval)
|
||||
{
|
||||
printf("Usage: %s [-h] [-v] [--keep-xlfd] <style_file>\n", __progname);
|
||||
printf("Usage: %s [-h] [-v] [--keep-xlfd] <style_file>\n", prog_name);
|
||||
if (print_usage) {
|
||||
puts("Converts fonts in a style file into fontconfig format");
|
||||
puts("");
|
||||
@@ -92,10 +92,11 @@ int main(int argc, char **argv)
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
prog_name = argv[0];
|
||||
while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
case 'v':
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
return 0;
|
||||
/* NOTREACHED */
|
||||
case 'h':
|
||||
@@ -122,7 +123,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!S_ISREG(st.st_mode)) { /* maybe symlink too? */
|
||||
fprintf(stderr, "%s: `%s' is not a regular file\n", __progname, file);
|
||||
fprintf(stderr, "%s: `%s' is not a regular file\n", prog_name, file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -135,12 +136,12 @@ int main(int argc, char **argv)
|
||||
style = WMReadPropListFromFile(file);
|
||||
if (!style) {
|
||||
perror(file);
|
||||
printf("%s: could not load style file\n", __progname);
|
||||
printf("%s: could not load style file\n", prog_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!WMIsPLDictionary(style)) {
|
||||
printf("%s: '%s' is not a well formatted style file\n", __progname, file);
|
||||
printf("%s: '%s' is not a well formatted style file\n", prog_name, file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
|
||||
#include "../src/wconfig.h"
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
static noreturn void print_help(int print_usage, int exitval)
|
||||
{
|
||||
printf("Usage: %s [-h] [-v] [file]\n", __progname);
|
||||
printf("Usage: %s [-h] [-v] [file]\n", prog_name);
|
||||
if (print_usage) {
|
||||
puts("Retrieves program icon configuration and output to FILE or to stdout");
|
||||
puts("");
|
||||
@@ -65,10 +65,11 @@ int main(int argc, char **argv)
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
prog_name = argv[0];
|
||||
while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
case 'v':
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
return 0;
|
||||
/* NOTREACHED */
|
||||
case 'h':
|
||||
@@ -88,7 +89,7 @@ int main(int argc, char **argv)
|
||||
|
||||
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", prog_name, path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ static char *font_options[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
WMPropList *PixmapPath = NULL;
|
||||
|
||||
@@ -138,7 +138,7 @@ char *ThemePath = NULL;
|
||||
|
||||
static noreturn void print_help(int print_usage, int exitval)
|
||||
{
|
||||
printf("Usage: %s [-t] [-p] [-h] [-v] [file]\n", __progname);
|
||||
printf("Usage: %s [-t] [-p] [-h] [-v] [file]\n", prog_name);
|
||||
if (print_usage) {
|
||||
puts("Retrieves style/theme configuration and outputs to ~/GNUstep/Library/WindowMaker/Themes/file.themed/style or to stdout");
|
||||
puts("");
|
||||
@@ -299,10 +299,11 @@ int main(int argc, char **argv)
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
prog_name = argv[0];
|
||||
while ((ch = getopt_long(argc, argv, "ptvh", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
case 'v':
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
return 0;
|
||||
/* NOTREACHED */
|
||||
case 'h':
|
||||
@@ -329,7 +330,7 @@ int main(int argc, char **argv)
|
||||
style_file = argv[argc - 1];
|
||||
|
||||
if (make_pack && !style_file) {
|
||||
printf("%s: you must supply a name for the theme pack\n", __progname);
|
||||
printf("%s: you must supply a name for the theme pack\n", prog_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -339,7 +340,7 @@ int main(int argc, char **argv)
|
||||
|
||||
prop = WMReadPropListFromFile(path);
|
||||
if (!prop) {
|
||||
printf("%s: could not load WindowMaker configuration file \"%s\".\n", __progname, path);
|
||||
printf("%s: could not load WindowMaker configuration file \"%s\".\n", prog_name, path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
|
||||
#include "../src/wconfig.h"
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
static noreturn void print_help(int print_usage, int exitval)
|
||||
{
|
||||
printf("Usage: %s [-h] [-v] [file]\n", __progname);
|
||||
printf("Usage: %s [-h] [-v] [file]\n", prog_name);
|
||||
if (print_usage) {
|
||||
puts("Reads icon configuration from FILE and updates Window Maker.");
|
||||
puts("");
|
||||
@@ -65,10 +65,11 @@ int main(int argc, char **argv)
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
prog_name = argv[0];
|
||||
while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
case 'v':
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
return 0;
|
||||
/* NOTREACHED */
|
||||
case 'h':
|
||||
@@ -91,13 +92,13 @@ int main(int argc, char **argv)
|
||||
|
||||
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", prog_name, path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
iconset = WMReadPropListFromFile(argv[0]);
|
||||
if (!iconset) {
|
||||
printf("%s: could not load icon set file \"%s\".\n", __progname, argv[0]);
|
||||
printf("%s: could not load icon set file \"%s\".\n", prog_name, argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ char *CursorOptions[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
int ignoreFonts = 0;
|
||||
int ignoreCursors = 0;
|
||||
|
||||
@@ -359,7 +359,7 @@ static void hackStyle(WMPropList * style)
|
||||
|
||||
static noreturn void print_help(int print_usage, int exitval)
|
||||
{
|
||||
printf("Usage: %s [OPTIONS] FILE\n", __progname);
|
||||
printf("Usage: %s [OPTIONS] FILE\n", prog_name);
|
||||
if (print_usage) {
|
||||
puts("Reads style/theme configuration from FILE and updates Window Maker.");
|
||||
puts("");
|
||||
@@ -392,10 +392,11 @@ int main(int argc, char **argv)
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
prog_name = argv[0];
|
||||
while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
case 'v':
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
return 0;
|
||||
/* NOTREACHED */
|
||||
case 'h':
|
||||
@@ -431,7 +432,7 @@ int main(int argc, char **argv)
|
||||
prop = WMReadPropListFromFile(path);
|
||||
if (!prop) {
|
||||
perror(path);
|
||||
printf("%s: could not load WindowMaker configuration file.\n", __progname);
|
||||
printf("%s: could not load WindowMaker configuration file.\n", prog_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -450,14 +451,14 @@ int main(int argc, char **argv)
|
||||
strncat(buf, "/style", sizeof(buf) - strlen(buf) - 1);
|
||||
|
||||
if (stat(buf, &st) != 0 || !S_ISREG(st.st_mode)) { /* maybe symlink too? */
|
||||
printf("%s: %s: style file not found or not a file\n", __progname, buf);
|
||||
printf("%s: %s: style file not found or not a file\n", prog_name, buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
style = WMReadPropListFromFile(buf);
|
||||
if (!style) {
|
||||
perror(buf);
|
||||
printf("%s: could not load style file.\n", __progname);
|
||||
printf("%s: could not load style file.\n", prog_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -480,13 +481,13 @@ int main(int argc, char **argv)
|
||||
style = WMReadPropListFromFile(file);
|
||||
if (!style) {
|
||||
perror(file);
|
||||
printf("%s:could not load style file.\n", __progname);
|
||||
printf("%s:could not load style file.\n", prog_name);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!WMIsPLDictionary(style)) {
|
||||
printf("%s: '%s' is not a style file/theme\n", __progname, file);
|
||||
printf("%s: '%s' is not a style file/theme\n", prog_name, file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@
|
||||
|
||||
#include "../src/wconfig.h"
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
static noreturn void print_help(int print_usage, int exitval)
|
||||
{
|
||||
printf("Usage: %s [OPTIONS] <domain> <key>\n", __progname);
|
||||
printf("Usage: %s [OPTIONS] <domain> <key>\n", prog_name);
|
||||
if (print_usage) {
|
||||
puts("Read <key> from <domain>'s database");
|
||||
puts("");
|
||||
@@ -70,10 +70,11 @@ int main(int argc, char **argv)
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
prog_name = argv[0];
|
||||
while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
case 'v':
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
return 0;
|
||||
/* NOTREACHED */
|
||||
case 'h':
|
||||
|
||||
@@ -43,11 +43,11 @@
|
||||
|
||||
#include "../src/wconfig.h"
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
static noreturn void print_help(int print_usage, int exitval)
|
||||
{
|
||||
printf("Usage: %s [OPTIONS] <domain> <key> <value>\n", __progname);
|
||||
printf("Usage: %s [OPTIONS] <domain> <key> <value>\n", prog_name);
|
||||
if (print_usage) {
|
||||
puts("Write <value> for <key> in <domain>'s database");
|
||||
puts("");
|
||||
@@ -69,10 +69,11 @@ int main(int argc, char **argv)
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
prog_name = argv[0];
|
||||
while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
case 'v':
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
return 0;
|
||||
/* NOTREACHED */
|
||||
case 'h':
|
||||
@@ -94,7 +95,7 @@ int main(int argc, char **argv)
|
||||
key = WMCreatePLString(argv[1]);
|
||||
value = WMCreatePropListFromDescription(argv[2]);
|
||||
if (!value) {
|
||||
printf("%s: syntax error in value \"%s\"", __progname, argv[2]);
|
||||
printf("%s: syntax error in value \"%s\"", prog_name, argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ static void find_and_write(const char *group, char *list[][2], int this_is_termi
|
||||
static void other_window_managers(void);
|
||||
static void print_help(int print_usage, int exitval);
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
char *path, *terminal = NULL;
|
||||
|
||||
@@ -54,10 +54,11 @@ int main(int argc, char *argv[])
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
prog_name = argv[0];
|
||||
while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
|
||||
switch (ch) {
|
||||
case 'v':
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
return 0;
|
||||
/* NOTREACHED */
|
||||
case 'h':
|
||||
@@ -500,7 +501,7 @@ static void other_window_managers(void)
|
||||
|
||||
noreturn void print_help(int print_usage, int exitval)
|
||||
{
|
||||
printf("Usage: %s [-h] [-v]\n", __progname);
|
||||
printf("Usage: %s [-h] [-v]\n", prog_name);
|
||||
if (print_usage) {
|
||||
puts("Writes a menu structure usable as ~/GNUstep/Defaults/WMRootMenu to stdout");
|
||||
puts("");
|
||||
|
||||
@@ -48,7 +48,7 @@ static const char *terminal;
|
||||
static fct_parse_menufile *parse;
|
||||
static fct_validate_filename *validateFilename;
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
/* Global Variables from wmmenugen.h */
|
||||
WMTreeNode *menu;
|
||||
@@ -60,6 +60,7 @@ int main(int argc, char **argv)
|
||||
int i;
|
||||
int *previousDepth;
|
||||
|
||||
prog_name = argv[0];
|
||||
plMenuNodes = WMCreateArray(8); /* grows on demand */
|
||||
menu = (WMTreeNode *)NULL;
|
||||
parse = NULL;
|
||||
@@ -77,7 +78,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Usage: %s -parser:<parser> fspec [fpsec...] "
|
||||
"[-parser:<parser> fspec [fpsec...]...]\n", __progname);
|
||||
"[-parser:<parser> fspec [fpsec...]...]\n", prog_name);
|
||||
fputs( "Known parsers: xdg wmconfig\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
@@ -97,28 +98,28 @@ int main(int argc, char **argv)
|
||||
parse = &parse_wmconfig;
|
||||
validateFilename = &wmconfig_validate_file;
|
||||
} else {
|
||||
fprintf(stderr, "%s: Unknown parser \"%s\"\n", __progname, argv[i] + 8);
|
||||
fprintf(stderr, "%s: Unknown parser \"%s\"\n", prog_name, argv[i] + 8);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parse) {
|
||||
if (stat(argv[i], &st) == -1) {
|
||||
fprintf(stderr, "%s: unable to stat \"%s\"\n", __progname, argv[i]);
|
||||
fprintf(stderr, "%s: unable to stat \"%s\"\n", prog_name, argv[i]);
|
||||
} else if (S_ISREG(st.st_mode)) {
|
||||
parse(argv[i], addWMMenuEntryCallback);
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
nftw(argv[i], dirParseFunc, 16, FTW_PHYS);
|
||||
} else {
|
||||
fprintf(stderr, "%s: \"%s\" is not a file or directory\n", __progname, argv[i]);
|
||||
fprintf(stderr, "%s: \"%s\" is not a file or directory\n", prog_name, argv[i]);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "%s: argument \"%s\" with no valid parser\n", __progname, argv[i]);
|
||||
fprintf(stderr, "%s: argument \"%s\" with no valid parser\n", prog_name, argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!menu) {
|
||||
fprintf(stderr, "%s: parsers failed to create a valid menu\n", __progname);
|
||||
fprintf(stderr, "%s: parsers failed to create a valid menu\n", prog_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -127,7 +128,7 @@ int main(int argc, char **argv)
|
||||
|
||||
i = WMGetArrayItemCount(plMenuNodes);
|
||||
if (i > 2) { /* more than one submenu unprocessed is almost certainly an error */
|
||||
fprintf(stderr, "%s: unprocessed levels on the stack. fishy.\n", __progname);
|
||||
fprintf(stderr, "%s: unprocessed levels on the stack. fishy.\n", prog_name);
|
||||
return 1;
|
||||
} else if (i > 1 ) { /* possibly the top-level attachment is not yet done */
|
||||
WMPropList *first, *next;
|
||||
|
||||
@@ -85,7 +85,7 @@ Bool xineStretch = False;
|
||||
Pixmap CurrentPixmap = None;
|
||||
char *PixmapPath = NULL;
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
typedef struct BackgroundTexture {
|
||||
int refcount;
|
||||
@@ -1152,7 +1152,7 @@ static char *getFullPixmapPath(const char *file)
|
||||
|
||||
static void print_help(void)
|
||||
{
|
||||
printf("Usage: %s [options] [image]\n", __progname);
|
||||
printf("Usage: %s [options] [image]\n", prog_name);
|
||||
puts("Sets the workspace background to the specified image or a texture and");
|
||||
puts("optionally update Window Maker configuration");
|
||||
puts("");
|
||||
@@ -1247,6 +1247,7 @@ int main(int argc, char **argv)
|
||||
|
||||
WMInitializeApplication("wmsetbg", &argc, argv);
|
||||
|
||||
prog_name = argv[0];
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-helper") == 0) {
|
||||
helperMode = 1;
|
||||
@@ -1324,7 +1325,7 @@ int main(int argc, char **argv)
|
||||
quit(1);
|
||||
}
|
||||
} else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
quit(0);
|
||||
} else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
||||
print_help();
|
||||
@@ -1332,14 +1333,14 @@ int main(int argc, char **argv)
|
||||
} else if (argv[i][0] != '-') {
|
||||
image_name = argv[i];
|
||||
} else {
|
||||
printf("%s: invalid argument '%s'\n", __progname, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", __progname);
|
||||
printf("%s: invalid argument '%s'\n", prog_name, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", prog_name);
|
||||
quit(1);
|
||||
}
|
||||
}
|
||||
if (!image_name && !texture && !helperMode) {
|
||||
printf("%s: you must specify a image file name or a texture\n", __progname);
|
||||
printf("Try '%s --help' for more information\n", __progname);
|
||||
printf("%s: you must specify a image file name or a texture\n", prog_name);
|
||||
printf("Try '%s --help' for more information\n", prog_name);
|
||||
quit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
#define LINESIZE (4*1024)
|
||||
#define MAXDATA (64*1024)
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
static void print_help(void)
|
||||
{
|
||||
printf("Usage: %s [OPTIONS] [FILE]\n", __progname);
|
||||
printf("Usage: %s [OPTIONS] [FILE]\n", prog_name);
|
||||
puts("Copies data from FILE or stdin into X cut buffer.");
|
||||
puts("");
|
||||
puts(" -display <display> display to use");
|
||||
@@ -70,37 +70,38 @@ int main(int argc, char **argv)
|
||||
int limit_check = 1;
|
||||
int clear_selection = 0;
|
||||
|
||||
prog_name = argv[0];
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
||||
print_help();
|
||||
exit(0);
|
||||
} else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
exit(0);
|
||||
} else if (strcmp(argv[i], "-cutbuffer") == 0 || strcmp(argv[i], "--cutbuffer") == 0) {
|
||||
if (i < argc - 1) {
|
||||
i++;
|
||||
if (sscanf(argv[i], "%i", &buffer) != 1) {
|
||||
fprintf(stderr, "%s: could not convert '%s' to int\n",
|
||||
__progname, argv[i]);
|
||||
prog_name, argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
if (buffer < 0 || buffer > 7) {
|
||||
fprintf(stderr, "%s: invalid buffer number %i\n", __progname, buffer);
|
||||
fprintf(stderr, "%s: invalid buffer number %i\n", prog_name, buffer);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
printf("%s: missing argument for '%s'\n", __progname, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", __progname);
|
||||
printf("%s: missing argument for '%s'\n", prog_name, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", prog_name);
|
||||
exit(1);
|
||||
}
|
||||
} else if (strcmp(argv[i], "-display") == 0) {
|
||||
if (i < argc - 1) {
|
||||
display_name = argv[++i];
|
||||
} else {
|
||||
printf("%s: missing argument for '%s'\n", __progname, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", __progname);
|
||||
printf("%s: missing argument for '%s'\n", prog_name, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", prog_name);
|
||||
exit(1);
|
||||
}
|
||||
} else if (strcmp(argv[i], "-clearselection") == 0
|
||||
@@ -109,8 +110,8 @@ int main(int argc, char **argv)
|
||||
} else if (strcmp(argv[i], "-nolimit") == 0 || strcmp(argv[i], "--no-limit") == 0) {
|
||||
limit_check = 0;
|
||||
} else {
|
||||
printf("%s: invalid argument '%s'\n", __progname, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", __progname);
|
||||
printf("%s: invalid argument '%s'\n", prog_name, argv[i]);
|
||||
printf("Try '%s --help' for more information\n", prog_name);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
@@ -124,7 +125,7 @@ int main(int argc, char **argv)
|
||||
|
||||
snprintf(line, sizeof(line),
|
||||
"%s: could not open \"%s\"",
|
||||
__progname, filename);
|
||||
prog_name, filename);
|
||||
perror(line);
|
||||
exit(1);
|
||||
}
|
||||
@@ -133,7 +134,7 @@ int main(int argc, char **argv)
|
||||
dpy = XOpenDisplay(display_name);
|
||||
XSetErrorHandler(errorHandler);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "%s: could not open display \"%s\"\n", __progname, XDisplayName(display_name));
|
||||
fprintf(stderr, "%s: could not open display \"%s\"\n", prog_name, XDisplayName(display_name));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -218,7 +219,7 @@ int main(int argc, char **argv)
|
||||
nbuf = buf;
|
||||
}
|
||||
if (!nbuf) {
|
||||
fprintf(stderr, "%s: out of memory\n", __progname);
|
||||
fprintf(stderr, "%s: out of memory\n", prog_name);
|
||||
exit(1);
|
||||
}
|
||||
buf = nbuf;
|
||||
@@ -232,7 +233,7 @@ int main(int argc, char **argv)
|
||||
fprintf
|
||||
(stderr,
|
||||
"%s: too much data in input - more than %d bytes\n"
|
||||
" use the -nolimit argument to remove the limit check.\n", __progname, MAXDATA);
|
||||
" use the -nolimit argument to remove the limit check.\n", prog_name, MAXDATA);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@
|
||||
|
||||
#define MAXDATA (4*1024*1024)
|
||||
|
||||
extern char *__progname;
|
||||
static const char *prog_name;
|
||||
|
||||
static void print_help(void)
|
||||
{
|
||||
printf("Usage: %s [OPTIONS] [FILE]\n", __progname);
|
||||
printf("Usage: %s [OPTIONS] [FILE]\n", prog_name);
|
||||
puts("Copies data from X selection or cutbuffer to FILE or stdout.");
|
||||
puts("");
|
||||
puts(" -display display display to use");
|
||||
@@ -157,13 +157,14 @@ int main(int argc, char **argv)
|
||||
char *display_name = "";
|
||||
char *selection_name = NULL;
|
||||
|
||||
prog_name = argv[0];
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
if (argv[i][1] == 'h' || strcmp(argv[i], "--help") == 0) {
|
||||
print_help();
|
||||
exit(0);
|
||||
} else if (argv[i][1] == 'v' || strcmp(argv[i], "--version") == 0) {
|
||||
printf("%s (Window Maker %s)\n", __progname, VERSION);
|
||||
printf("%s (Window Maker %s)\n", prog_name, VERSION);
|
||||
exit(0);
|
||||
} else if (strcmp(argv[i], "-selection") == 0 || strcmp(argv[i], "--selection") == 0) {
|
||||
if (i < argc - 1) {
|
||||
@@ -183,28 +184,28 @@ int main(int argc, char **argv)
|
||||
i++;
|
||||
if (sscanf(argv[i], "%i", &buffer) != 1) {
|
||||
fprintf(stderr, "%s: could not convert \"%s\" to int\n",
|
||||
__progname, argv[i]);
|
||||
prog_name, argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
if (buffer < 0 || buffer > 7) {
|
||||
fprintf(stderr, "%s: invalid buffer number %i\n", __progname, buffer);
|
||||
fprintf(stderr, "%s: invalid buffer number %i\n", prog_name, buffer);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "%s: invalid argument '%s'\n", __progname, argv[i]);
|
||||
fprintf(stderr, "Try '%s --help' for more information.\n", __progname);
|
||||
fprintf(stderr, "%s: invalid argument '%s'\n", prog_name, argv[i]);
|
||||
fprintf(stderr, "Try '%s --help' for more information.\n", prog_name);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "%s: invalid argument '%s'\n", __progname, argv[i]);
|
||||
fprintf(stderr, "Try '%s --help' for more information.\n", __progname);
|
||||
fprintf(stderr, "%s: invalid argument '%s'\n", prog_name, argv[i]);
|
||||
fprintf(stderr, "Try '%s --help' for more information.\n", prog_name);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
dpy = XOpenDisplay(display_name);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "%s: could not open display \"%s\"\n", __progname, XDisplayName(display_name));
|
||||
fprintf(stderr, "%s: could not open display \"%s\"\n", prog_name, XDisplayName(display_name));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user