simple-dmabuf-drm: use getopt_long
Signed-off-by: Guido Günther <agx@sigxcpu.org> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
2e24198974
commit
60970ec27c
@ -38,6 +38,7 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
@ -877,30 +878,32 @@ main(int argc, char **argv)
|
|||||||
struct window *window;
|
struct window *window;
|
||||||
int opts = 0;
|
int opts = 0;
|
||||||
int import_format = DRM_FORMAT_XRGB8888;
|
int import_format = DRM_FORMAT_XRGB8888;
|
||||||
int ret = 0, i = 0;
|
int c, option_index, ret = 0;
|
||||||
|
|
||||||
if (argc > 1) {
|
static struct option long_options[] = {
|
||||||
static const char import_mode[] = "--import-immediate=";
|
{"import-format", required_argument, 0, 'f' },
|
||||||
static const char format[] = "--import-format=";
|
{"import-immediate", required_argument, 0, 'i' },
|
||||||
static const char y_inverted[] = "--y-inverted=";
|
{"y-inverted", required_argument, 0, 'y' },
|
||||||
for (i = 1; i < argc; i++) {
|
{"help", no_argument , 0, 'h' },
|
||||||
if (!strncmp(argv[i], import_mode,
|
{0, 0, 0, 0}
|
||||||
sizeof(import_mode) - 1)) {
|
};
|
||||||
if (is_true(argv[i] + sizeof(import_mode) - 1))
|
|
||||||
opts |= OPT_IMMEDIATE;
|
while ((c = getopt_long(argc, argv, "hf:i:y:",
|
||||||
}
|
long_options, &option_index)) != -1) {
|
||||||
else if (!strncmp(argv[i], format, sizeof(format) - 1)) {
|
switch (c) {
|
||||||
import_format = parse_import_format(argv[i]
|
case 'f':
|
||||||
+ sizeof(format) - 1);
|
import_format = parse_import_format(optarg);
|
||||||
}
|
break;
|
||||||
else if (!strncmp(argv[i], y_inverted,
|
case 'i':
|
||||||
sizeof(y_inverted) - 1)) {
|
if (is_true(optarg))
|
||||||
if (is_true(argv[i] + sizeof(y_inverted) - 1))
|
opts |= OPT_IMMEDIATE;
|
||||||
opts |= OPT_Y_INVERTED;
|
break;
|
||||||
}
|
case 'y':
|
||||||
else {
|
if (is_true(optarg))
|
||||||
print_usage_and_exit();
|
opts |= OPT_Y_INVERTED;
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
|
print_usage_and_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user