summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiclas Zeising <zeising@daemonic.se>2020-07-28 18:22:08 +0200
committerNiclas Zeising <zeising@daemonic.se>2020-08-14 17:50:56 +0200
commit1bf2b41d3f30c5c53ce6d23727c5d802225d8d2b (patch)
tree476c5eeceebc2dcec3dcdbaca962ba94eebd5aaa
parentcca90938874baaa5bd29d6406e141e49d6bf12a6 (diff)
downloadlibevdev-1bf2b41d3f30c5c53ce6d23727c5d802225d8d2b.tar.gz
tools: use basename(argv[0]) for program name
Use baename(argv[0]) to get the program name (for usage), instead of using program_invocation_short_name, which only exists on Linux, not FreeBSD. Signed-off-by: Niclas Zeising <zeising@daemonic.se>
-rw-r--r--tools/libevdev-tweak-device.c13
-rw-r--r--tools/mouse-dpi-tool.c9
-rw-r--r--tools/touchpad-edge-detector.c11
3 files changed, 18 insertions, 15 deletions
diff --git a/tools/libevdev-tweak-device.c b/tools/libevdev-tweak-device.c
index 38e4021..391c5f9 100644
--- a/tools/libevdev-tweak-device.c
+++ b/tools/libevdev-tweak-device.c
@@ -23,6 +23,7 @@
#include "config.h"
#include <getopt.h>
+#include <libgen.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
@@ -39,7 +40,7 @@
#include "libevdev/libevdev.h"
static void
-usage(void)
+usage(const char *progname)
{
printf("%s --abs <axis> [--min min] [--max max] [--res res] [--fuzz fuzz] [--flat flat] /dev/input/eventXYZ\n"
"\tChange the absinfo struct for the named axis\n"
@@ -47,9 +48,9 @@ usage(void)
"\tChange the x/y resolution on the given device\n"
"%s --led <led> --on|--off /dev/input/eventXYZ\n"
"\tEnable or disable the named LED\n",
- program_invocation_short_name,
- program_invocation_short_name,
- program_invocation_short_name);
+ progname,
+ progname,
+ progname);
}
enum mode {
@@ -415,7 +416,7 @@ main(int argc, char **argv)
rc = EXIT_SUCCESS;
/* fallthrough */
case MODE_NONE:
- usage();
+ usage(basename(argv[0]));
goto out;
case MODE_ABS:
rc = parse_options_abs(argc, argv, &changes, &axis,
@@ -439,7 +440,7 @@ main(int argc, char **argv)
if (optind >= argc) {
rc = EXIT_FAILURE;
- usage();
+ usage(basename(argv[0]));
goto out;
}
diff --git a/tools/mouse-dpi-tool.c b/tools/mouse-dpi-tool.c
index 911f61e..55e84f2 100644
--- a/tools/mouse-dpi-tool.c
+++ b/tools/mouse-dpi-tool.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <limits.h>
#include <poll.h>
#include <signal.h>
@@ -51,8 +52,8 @@ struct measurements {
};
static int
-usage(void) {
- printf("Usage: %s /dev/input/event0\n", program_invocation_short_name);
+usage(const char *progname) {
+ printf("Usage: %s /dev/input/event0\n", progname);
printf("\n");
printf("This tool reads relative events from the kernel and calculates\n"
"the distance covered and maximum frequency of the incoming events.\n"
@@ -262,11 +263,11 @@ main (int argc, char **argv) {
struct measurements measurements = {0};
if (argc < 2)
- return usage();
+ return usage(basename(argv[0]));
path = argv[1];
if (path[0] == '-')
- return usage();
+ return usage(basename(argv[0]));
fd = open(path, O_RDONLY|O_NONBLOCK);
if (fd < 0) {
diff --git a/tools/touchpad-edge-detector.c b/tools/touchpad-edge-detector.c
index 7727cad..2e0c9fe 100644
--- a/tools/touchpad-edge-detector.c
+++ b/tools/touchpad-edge-detector.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <limits.h>
#include <math.h>
#include <poll.h>
@@ -43,8 +44,8 @@
static int signalled = 0;
static int
-usage(void) {
- printf("Usage: %s 12x34 /dev/input/eventX\n", program_invocation_short_name);
+usage(const char *progname) {
+ printf("Usage: %s 12x34 /dev/input/eventX\n", progname);
printf("\n");
printf("This tool reads the touchpad events from the kernel and calculates\n "
"the minimum and maximum for the x and y coordinates, respectively.\n"
@@ -236,11 +237,11 @@ int main (int argc, char **argv) {
struct size size;
if (argc < 3)
- return usage();
+ return usage(basename(argv[0]));
if (sscanf(argv[1], "%dx%d", &size.w, &size.h) != 2 ||
size.w <= 0 || size.h <= 0)
- return usage();
+ return usage(basename(argv[0]));
if (size.w < 30 || size.h < 30) {
fprintf(stderr,
@@ -252,7 +253,7 @@ int main (int argc, char **argv) {
path = argv[2];
if (path[0] == '-')
- return usage();
+ return usage(basename(argv[0]));
fd = open(path, O_RDONLY|O_NONBLOCK);
if (fd < 0) {