summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Piotrowski <0mp@FreeBSD.org>2020-11-13 14:43:42 +0100
committerMateusz Piotrowski <0mp@FreeBSD.org>2020-11-24 01:27:22 +0100
commit497a30b22bd05bc0d9b3de6c8ff53a96b3a58817 (patch)
tree69708e1e182f512e1269f964b310461c1c1a5614
parent049396aab18849eef257af1116951a83416339e6 (diff)
Replace program_invocation_short_name with argv[0]
It's good enough for our purpose and it is more portable. Also, because argv[0] is not globally accessible, let's define a new global variable for that called progname.
-rw-r--r--evtest.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/evtest.c b/evtest.c
index 4227207..5f6bed6 100644
--- a/evtest.c
+++ b/evtest.c
@@ -110,6 +110,7 @@ static const struct query_mode {
};
static int grab_flag = 0;
+static char* progname;
static volatile sig_atomic_t stop = 0;
static void interrupt_handler(int sig)
@@ -928,7 +929,7 @@ static int version(void)
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "<version undefined>"
#endif
- printf("%s %s\n", program_invocation_short_name, PACKAGE_VERSION);
+ printf("%s %s\n", progname, PACKAGE_VERSION);
return EXIT_SUCCESS;
}
@@ -940,12 +941,11 @@ static int usage(void)
{
printf("USAGE:\n");
printf(" Capture mode:\n");
- printf(" %s [--grab] /dev/input/eventX\n", program_invocation_short_name);
+ printf(" %s [--grab] /dev/input/eventX\n", progname);
printf(" --grab grab the device for exclusive access\n");
printf("\n");
printf(" Query mode: (check exit code)\n");
- printf(" %s --query /dev/input/eventX <type> <value>\n",
- program_invocation_short_name);
+ printf(" %s --query /dev/input/eventX <type> <value>\n", progname);
printf("\n");
printf("<type> is one of: EV_KEY, EV_SW, EV_LED, EV_SND\n");
@@ -1347,6 +1347,8 @@ int main (int argc, char **argv)
const char *event_type;
enum evtest_mode mode = MODE_CAPTURE;
+ progname = argv[0];
+
while (1) {
int option_index = 0;
int c = getopt_long(argc, argv, "", long_options, &option_index);