From 7d7bf8f8b186a7cade458d0e9ac9771aa3122b31 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 23 Apr 2016 20:49:06 +0200 Subject: [PATCH] examples/parse_args.h: check in config.h if getopt.h was found --- examples/parse_args.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/parse_args.h b/examples/parse_args.h index 0548038a..5090f888 100644 --- a/examples/parse_args.h +++ b/examples/parse_args.h @@ -18,6 +18,12 @@ */ +#include "config.h" + +#ifdef HAVE_GETOPT_H +#include +#endif + extern int verbose; // input / output extern int usejack; @@ -63,6 +69,7 @@ void usage (FILE * stream, int exit_code); void usage (FILE * stream, int exit_code) { +#ifdef HAVE_GETOPT_H fprintf (stream, "usage: %s [ options ] \n", prog_name); fprintf (stream, " -i --input input file\n" @@ -106,12 +113,17 @@ void usage (FILE * stream, int exit_code) " -v --verbose be verbose\n" " -h --help display this message\n" ); +#else /* HAVE_GETOPT_H */ + fprintf (stream, "warning: compiled with getopt.h, no argument parsing\n"); + fprintf (stream, "usage: %s \n", prog_name); +#endif /* HAVE_GETOPT_H */ exit (exit_code); } int parse_args (int argc, char **argv) { +#ifdef HAVE_GETOPT_H const char *options = "hv" "i:r:B:H:" #ifdef PROG_HAS_JACK @@ -157,11 +169,13 @@ parse_args (int argc, char **argv) {"force-overwrite", 0, NULL, 'f'}, {NULL, 0, NULL, 0} }; +#endif /* HAVE_GETOPT_H */ prog_name = argv[0]; if (argc < 1) { usage (stderr, 1); return -1; } +#ifdef HAVE_GETOPT_H do { next_option = getopt_long (argc, argv, options, long_options, NULL); switch (next_option) { @@ -235,6 +249,7 @@ parse_args (int argc, char **argv) } } while (next_option != -1); +#endif /* HAVE_GETOPT_H */ // if unique, use the non option argument as the source if ( source_uri == NULL ) { -- 2.11.0