summaryrefslogtreecommitdiffstats
path: root/mpd-notification.c
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-08-09 11:16:02 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-08-09 11:16:02 +0200
commit25b3e718f2ebcf2d3dd78957f48666f783c75a29 (patch)
treeb52b1594c54c70d2c1fc58ea75555dfd8149a2b5 /mpd-notification.c
parentfdb8c0055c216aed33270372d93d2f316657c97d (diff)
downloadmpd-notification-25b3e718f2ebcf2d3dd78957f48666f783c75a29.tar.gz
mpd-notification-25b3e718f2ebcf2d3dd78957f48666f783c75a29.tar.zst
allow to use long command line arguments
Diffstat (limited to 'mpd-notification.c')
-rw-r--r--mpd-notification.c12
1 files changed, 11 insertions, 1 deletions
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 <stdlib.h>
#include <string.h>
#include <signal.h>
+#include <getopt.h>
#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);