1a46c0ec8Sopenharmony_ci/*
2a46c0ec8Sopenharmony_ci * Copyright © 2017 Red Hat, Inc.
3a46c0ec8Sopenharmony_ci *
4a46c0ec8Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5a46c0ec8Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6a46c0ec8Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7a46c0ec8Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8a46c0ec8Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9a46c0ec8Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10a46c0ec8Sopenharmony_ci *
11a46c0ec8Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12a46c0ec8Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13a46c0ec8Sopenharmony_ci * Software.
14a46c0ec8Sopenharmony_ci *
15a46c0ec8Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16a46c0ec8Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17a46c0ec8Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18a46c0ec8Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19a46c0ec8Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20a46c0ec8Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21a46c0ec8Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
22a46c0ec8Sopenharmony_ci */
23a46c0ec8Sopenharmony_ci
24a46c0ec8Sopenharmony_ci#include "config.h"
25a46c0ec8Sopenharmony_ci
26a46c0ec8Sopenharmony_ci#include <getopt.h>
27a46c0ec8Sopenharmony_ci#include <stdio.h>
28a46c0ec8Sopenharmony_ci
29a46c0ec8Sopenharmony_ci#include "shared.h"
30a46c0ec8Sopenharmony_ci
31a46c0ec8Sopenharmony_cistatic inline void
32a46c0ec8Sopenharmony_ciusage(void)
33a46c0ec8Sopenharmony_ci{
34a46c0ec8Sopenharmony_ci	printf("Usage: libinput measure [--help] <feature> [/dev/input/event0]\n");
35a46c0ec8Sopenharmony_ci}
36a46c0ec8Sopenharmony_ci
37a46c0ec8Sopenharmony_ciint
38a46c0ec8Sopenharmony_cimain(int argc, char **argv)
39a46c0ec8Sopenharmony_ci{
40a46c0ec8Sopenharmony_ci	int option_index = 0;
41a46c0ec8Sopenharmony_ci
42a46c0ec8Sopenharmony_ci	while (1) {
43a46c0ec8Sopenharmony_ci		int c;
44a46c0ec8Sopenharmony_ci		static struct option opts[] = {
45a46c0ec8Sopenharmony_ci			{ "help",	no_argument,	0, 'h' },
46a46c0ec8Sopenharmony_ci			{ 0, 0, 0, 0}
47a46c0ec8Sopenharmony_ci		};
48a46c0ec8Sopenharmony_ci
49a46c0ec8Sopenharmony_ci		c = getopt_long(argc, argv, "+h", opts, &option_index);
50a46c0ec8Sopenharmony_ci		if (c == -1)
51a46c0ec8Sopenharmony_ci			break;
52a46c0ec8Sopenharmony_ci
53a46c0ec8Sopenharmony_ci		switch(c) {
54a46c0ec8Sopenharmony_ci		case 'h':
55a46c0ec8Sopenharmony_ci			usage();
56a46c0ec8Sopenharmony_ci			return EXIT_SUCCESS;
57a46c0ec8Sopenharmony_ci		default:
58a46c0ec8Sopenharmony_ci			usage();
59a46c0ec8Sopenharmony_ci			return EXIT_FAILURE;
60a46c0ec8Sopenharmony_ci		}
61a46c0ec8Sopenharmony_ci	}
62a46c0ec8Sopenharmony_ci
63a46c0ec8Sopenharmony_ci	if (optind >= argc) {
64a46c0ec8Sopenharmony_ci		usage();
65a46c0ec8Sopenharmony_ci		return EXIT_FAILURE;
66a46c0ec8Sopenharmony_ci	}
67a46c0ec8Sopenharmony_ci
68a46c0ec8Sopenharmony_ci	argc--;
69a46c0ec8Sopenharmony_ci	argv++;
70a46c0ec8Sopenharmony_ci
71a46c0ec8Sopenharmony_ci	return tools_exec_command("libinput-measure", argc, argv);
72a46c0ec8Sopenharmony_ci}
73