Use getopt() if getopt_long() is not available

This commit is contained in:
pooler 2012-04-08 23:28:54 +02:00
parent 654a23904b
commit 858601d91f
2 changed files with 16 additions and 1 deletions

View file

@ -36,6 +36,7 @@ AC_CHECK_DECLS([be32dec, le32dec, be32enc, le32enc], [], [],
])
AC_FUNC_ALLOCA
AC_CHECK_FUNCS([getopt_long])
case $target in
i*86-*-*)

View file

@ -30,7 +30,6 @@
#include <sys/sysctl.h>
#endif
#endif
#include <getopt.h>
#include <jansson.h>
#include <curl/curl.h>
#include "compat.h"
@ -128,6 +127,17 @@ static unsigned long accepted_count = 0L;
static unsigned long rejected_count = 0L;
double *thr_hashrates;
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#else
struct option {
const char *name;
int has_arg;
int *flag;
int val;
};
#endif
static char const usage[] = "\
Usage: " PROGRAM_NAME " [OPTIONS]\n\
Options:\n\
@ -895,7 +905,11 @@ static void parse_cmdline(int argc, char *argv[])
int key;
while (1) {
#if HAVE_GETOPT_LONG
key = getopt_long(argc, argv, short_options, options, NULL);
#else
key = getopt(argc, argv, short_options);
#endif
if (key < 0)
break;