From 25b3e718f2ebcf2d3dd78957f48666f783c75a29 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 9 Aug 2014 11:16:02 +0200 Subject: allow to use long command line arguments --- mpd-notification.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mpd-notification.c b/mpd-notification.c index 957d8ca..44cc4a6 100644 --- a/mpd-notification.c +++ b/mpd-notification.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "config.h" #include "version.h" @@ -25,6 +26,15 @@ #define DEBUG 0 #endif +const static char optstring[] = "hH:p:"; +const static struct option options_long[] = { + /* name has_arg flag val */ + { "help", no_argument, NULL, 'h' }, + { "host", required_argument, NULL, 'H' }, + { "port", required_argument, NULL, 'p' }, + { 0, 0, 0, 0 } +}; + /* global variables */ char *program = NULL; NotifyNotification * notification = NULL; @@ -63,7 +73,7 @@ int main(int argc, char ** argv) { # endif /* get command line options */ - while ((i = getopt(argc, argv, "hH:p:")) != -1) + while ((i = getopt_long(argc, argv, optstring, options_long, NULL)) != -1) switch (i) { case 'h': fprintf(stderr, "usage: %s [-h] [-H HOST] [-p PORT]\n", program); -- cgit v1.2.3-54-g00ecf