summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolai Kondrashov <spbnick@gmail.com>2011-12-26 13:33:54 +0200
committerNikolai Kondrashov <spbnick@gmail.com>2011-12-26 13:33:54 +0200
commit427912d3400807f632928dfc2f8345552d06e624 (patch)
treef626da55c235419955c568022dede721b327f935
parent93b3313a4d4186f0a822fb0c5ed4149f759cc733 (diff)
downloadusbhid-dump-427912d3400807f632928dfc2f8345552d06e624.tar.gz
Stop using program_invocation_short_name
Stop using program_invocation_short_name - a GNU extension variable and extract usbhid-dump invocation name ourselves.
-rw-r--r--src/usbhid-dump.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/usbhid-dump.c b/src/usbhid-dump.c
index 7fdcad3..4c8c1bd 100644
--- a/src/usbhid-dump.c
+++ b/src/usbhid-dump.c
@@ -788,7 +788,7 @@ PACKAGE_STRING "\n"
static bool
-usage(FILE *stream)
+usage(FILE *stream, const char *program_invocation_name)
{
return
fprintf(
@@ -826,7 +826,7 @@ usage(FILE *stream)
"Signals:\n"
" USR1/USR2 pause/resume the stream dump output\n"
"\n",
- program_invocation_short_name) >= 0;
+ program_invocation_name) >= 0;
}
@@ -897,6 +897,8 @@ main(int argc, char **argv)
{
int result;
+ const char *name;
+
int c;
uint8_t bus_num = UHD_BUS_NUM_ANY;
@@ -913,10 +915,19 @@ main(int argc, char **argv)
struct sigaction sa;
+ /*
+ * Extract program invocation name
+ */
+ name = rindex(argv[0], '/');
+ if (name == NULL)
+ name = argv[0];
+ else
+ name++;
+
#define USAGE_ERROR(_fmt, _args...) \
do { \
fprintf(stderr, _fmt "\n", ##_args); \
- usage(stderr); \
+ usage(stderr, name); \
return 1; \
} while (0)
@@ -929,7 +940,7 @@ main(int argc, char **argv)
switch (c)
{
case OPT_VAL_HELP:
- usage(stdout);
+ usage(stdout, name);
return 0;
break;
case OPT_VAL_VERSION:
@@ -981,7 +992,7 @@ main(int argc, char **argv)
stream_feedback = 1;
break;
case '?':
- usage(stderr);
+ usage(stderr, name);
return 1;
break;
}