mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-25 15:10:14 +01:00
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>
This commit is contained in:
parent
cca9093887
commit
1bf2b41d3f
3 changed files with 18 additions and 15 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue