From 213b721ff942560a4de5e94ccd0e9945f7bc194f Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 1 Feb 2018 10:46:42 +0100 Subject: [PATCH] Use long command-line options In addition to the short form (e.g. "-p"), add the long form ("--port"). --- app/src/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main.c b/app/src/main.c index 6036f20e..2e7a65d8 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -1,5 +1,6 @@ #include "scrcpy.h" +#include #include #include #include @@ -12,9 +13,14 @@ struct args { Uint16 maximum_size; }; -int parse_args(struct args *args, int argc, char *argv[]) { +static int parse_args(struct args *args, int argc, char *argv[]) { + static const struct option long_options[] = { + {"port", required_argument, NULL, 'p'}, + {"max-size", required_argument, NULL, 'm'}, + {NULL, 0, NULL, 0 }, + }; int c; - while ((c = getopt(argc, argv, "p:m:")) != -1) { + while ((c = getopt_long(argc, argv, "p:m:", long_options, NULL)) != -1) { switch (c) { case 'p': { char *endptr;