#include "config.h"
#include <getopt.h>
+#include <libgen.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#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"
"\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 {
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,
if (optind >= argc) {
rc = EXIT_FAILURE;
- usage();
+ usage(basename(argv[0]));
goto out;
}
#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <limits.h>
#include <poll.h>
#include <signal.h>
};
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"
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) {
#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <limits.h>
#include <math.h>
#include <poll.h>
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"
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,
path = argv[2];
if (path[0] == '-')
- return usage();
+ return usage(basename(argv[0]));
fd = open(path, O_RDONLY|O_NONBLOCK);
if (fd < 0) {