Make znc compile without getopt_long

If getopt_long() (GNU extension) isn't available, we use the plain old getopt()
instead. This means that long options won't work, but at least this compiles.

Tested on Solaris 9, but should also work on Irix.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2011-03-24 14:01:26 +01:00
parent 36ffa163a8
commit fbe2b7403a
2 changed files with 21 additions and 2 deletions
+1 -1
View File
@@ -164,7 +164,7 @@ if test "$POLL" = "yes"; then
fi
AC_CHECK_LIB( gnugetopt, getopt_long,)
AC_CHECK_FUNCS([lstat])
AC_CHECK_FUNCS([lstat getopt_long])
PKG_PROG_PKG_CONFIG()
# ----- Check for dlopen
+20 -1
View File
@@ -7,9 +7,28 @@
*/
#include "znc.h"
#include <getopt.h>
#include <sys/wait.h>
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#else
#define no_argument 0
#define required_argument 1
#define optional_argument 2
struct option {
const char *a;
int opt;
int *flag;
int val;
};
static inline int getopt_long(int argc, char * const argv[], const char *optstring, const struct option *, int *)
{
return getopt(argc, argv, optstring);
}
#endif
static const struct option g_LongOpts[] = {
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'v' },