summaryrefslogtreecommitdiffstats
path: root/nbase
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:42:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:42:04 +0000
commit0d47952611198ef6b1163f366dc03922d20b1475 (patch)
tree3d840a3b8c0daef0754707bfb9f5e873b6b1ac13 /nbase
parentInitial commit. (diff)
downloadnmap-0d47952611198ef6b1163f366dc03922d20b1475.tar.xz
nmap-0d47952611198ef6b1163f366dc03922d20b1475.zip
Adding upstream version 7.94+git20230807.3be01efb1+dfsg.upstream/7.94+git20230807.3be01efb1+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'nbase')
-rw-r--r--nbase/CHANGELOG5
-rw-r--r--nbase/Makefile.in65
-rw-r--r--nbase/acinclude.m4216
-rwxr-xr-xnbase/configure6574
-rw-r--r--nbase/configure.ac301
-rw-r--r--nbase/getaddrinfo.c191
-rw-r--r--nbase/getnameinfo.c116
-rw-r--r--nbase/getopt.c304
-rw-r--r--nbase/getopt.h84
-rw-r--r--nbase/inet_ntop.c255
-rw-r--r--nbase/inet_pton.c249
-rw-r--r--nbase/nbase.h528
-rw-r--r--nbase/nbase.vcxproj131
-rw-r--r--nbase/nbase_addrset.c934
-rw-r--r--nbase/nbase_config.h.in206
-rw-r--r--nbase/nbase_crc32ct.h136
-rw-r--r--nbase/nbase_ipv6.h214
-rw-r--r--nbase/nbase_memalloc.c115
-rw-r--r--nbase/nbase_misc.c898
-rw-r--r--nbase/nbase_rnd.c360
-rw-r--r--nbase/nbase_str.c330
-rw-r--r--nbase/nbase_time.c215
-rw-r--r--nbase/nbase_winconfig.h156
-rw-r--r--nbase/nbase_winunix.c214
-rw-r--r--nbase/nbase_winunix.h196
-rw-r--r--nbase/snprintf.c647
-rw-r--r--nbase/strcasecmp.c114
-rw-r--r--nbase/test/nmakefile13
-rw-r--r--nbase/test/test-escape_windows_command_arg.c204
29 files changed, 13971 insertions, 0 deletions
diff --git a/nbase/CHANGELOG b/nbase/CHANGELOG
new file mode 100644
index 0000000..3eb7b3c
--- /dev/null
+++ b/nbase/CHANGELOG
@@ -0,0 +1,5 @@
+
+-- Added snprintf.c, inet_aton.c, inet_pton.c, and inet_ntop.c from
+ tcpdump-2000.09.17 ( www.tcpdump.org)
+
+-- Nbase library initially created (9/17/00) \ No newline at end of file
diff --git a/nbase/Makefile.in b/nbase/Makefile.in
new file mode 100644
index 0000000..db1380f
--- /dev/null
+++ b/nbase/Makefile.in
@@ -0,0 +1,65 @@
+prefix = @prefix@
+datarootdir = @datarootdir@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+sbindir = @sbindir@
+mandir = @mandir@
+srcdir = @srcdir@
+
+CC = @CC@
+AR = ar
+RANLIB = @RANLIB@
+CCOPT =
+DEFS = @DEFS@
+# With GCC, add extra security checks to source code.
+DEFS += -D_FORTIFY_SOURCE=2
+CPPFLAGS = @CPPFLAGS@
+CFLAGS = @CFLAGS@ $(CCOPT) $(GLIB_CFLAGS) $(DEFS) $(INCLS)
+STATIC =
+LDFLAGS = @LDFLAGS@ $(STATIC)
+LIBS = @LIBS@
+SHTOOL = ./shtool
+INSTALL = $(SHTOOL) install
+MAKEDEPEND = @MAKEDEPEND@
+
+TARGET = libnbase.a
+
+DEPS = getopt.h nbase.h nbase_winconfig.h nbase_config.h nbase_ipv6.h nbase_winunix.h nbase_crc32ct.h
+OBJS = @LIBOBJS@
+
+all: $(TARGET)
+
+$(TARGET): $(DEPS) $(OBJS)
+ rm -f $@
+ $(AR) cr $@ $(OBJS)
+ $(RANLIB) $@
+
+clean:
+ rm -f $(OBJS) $(TARGET)
+
+distclean: clean
+ rm -f Makefile config.cache config.log config.status nbase_config.h
+
+depend:
+ $(MAKEDEPEND) $(INCLS) -s "# DO NOT DELETE" -- $(DEFS) -- $(SRCS)
+
+configure: configure.ac
+ autoconf
+
+Makefile: Makefile.in config.status
+ ./config.status
+
+config.status: configure
+ ./config.status --recheck
+
+.cc.o:
+ $(CC) -c $(CFLAGS) $*.cc
+
+# DO NOT DELETE -- Needed by makedepend
+
+
+
+
+
+
+
diff --git a/nbase/acinclude.m4 b/nbase/acinclude.m4
new file mode 100644
index 0000000..8bc7f68
--- /dev/null
+++ b/nbase/acinclude.m4
@@ -0,0 +1,216 @@
+dnl -----------------------------------------------------------------
+dnl Nbase local macros
+dnl $Id$
+dnl -----------------------------------------------------------------
+
+dnl
+dnl check for working getaddrinfo(). This check is from
+dnl Apache 2.0.40
+dnl
+dnl Note that if the system doesn't have gai_strerror(), we
+dnl can't use getaddrinfo() because we can't get strings
+dnl describing the error codes.
+dnl
+AC_DEFUN(APR_CHECK_WORKING_GETADDRINFO,[
+ AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
+ AC_TRY_RUN( [
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+int main(void) {
+ struct addrinfo hints, *ai;
+ int error;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ error = getaddrinfo("127.0.0.1", NULL, &hints, &ai);
+ if (error) {
+ return 1;
+ }
+ if (ai->ai_addr->sa_family != AF_INET) {
+ return 1;
+ }
+ return 0;
+}
+],[
+ ac_cv_working_getaddrinfo="yes"
+],[
+ ac_cv_working_getaddrinfo="no"
+],[
+ ac_cv_working_getaddrinfo="yes"
+])])
+if test "$ac_cv_working_getaddrinfo" = "yes"; then
+ if test "$ac_cv_func_gai_strerror" != "yes"; then
+ ac_cv_working_getaddrinfo="no"
+ else
+ AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works well enough for APR])
+ fi
+fi
+])
+
+dnl
+dnl check for working getnameinfo() -- from Apache 2.0.40
+dnl
+AC_DEFUN(APR_CHECK_WORKING_GETNAMEINFO,[
+ AC_CACHE_CHECK(for working getnameinfo, ac_cv_working_getnameinfo,[
+ AC_TRY_RUN( [
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+int main(void) {
+ struct sockaddr_in sa;
+ char hbuf[256];
+ int error;
+
+ sa.sin_family = AF_INET;
+ sa.sin_port = 0;
+ sa.sin_addr.s_addr = inet_addr("127.0.0.1");
+#ifdef SIN6_LEN
+ sa.sin_len = sizeof(sa);
+#endif
+
+ error = getnameinfo((const struct sockaddr *)&sa, sizeof(sa),
+ hbuf, 256, NULL, 0,
+ NI_NUMERICHOST);
+ if (error) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+],[
+ ac_cv_working_getnameinfo="yes"
+],[
+ ac_cv_working_getnameinfo="no"
+],[
+ ac_cv_working_getnameinfo="yes"
+])])
+if test "$ac_cv_working_getnameinfo" = "yes"; then
+ AC_DEFINE(HAVE_GETNAMEINFO, 1, [Define if getnameinfo exists])
+fi
+])
+
+AC_DEFUN(APR_CHECK_SOCKADDR_IN6,[
+AC_CACHE_CHECK(for sockaddr_in6, ac_cv_define_sockaddr_in6,[
+AC_TRY_COMPILE([
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+],[
+struct sockaddr_in6 sa;
+],[
+ ac_cv_define_sockaddr_in6=yes
+],[
+ ac_cv_define_sockaddr_in6=no
+])
+])
+
+if test "$ac_cv_define_sockaddr_in6" = "yes"; then
+ have_sockaddr_in6=1
+ AC_DEFINE(HAVE_SOCKADDR_IN6, 1, [Define if struct sockaddr_in6 exists])
+else
+ have_sockaddr_in6=0
+fi
+])
+
+AC_DEFUN(CHECK_AF_INET6_DEFINE,[
+AC_CACHE_CHECK(for AF_INET6 definition, ac_cv_define_af_inet6,[
+AC_TRY_COMPILE([
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+],[
+int af = AF_INET6;
+],[
+ ac_cv_define_af_inet6=yes
+],[
+ ac_cv_define_af_inet6=no
+])
+])
+
+if test "$ac_cv_define_af_inet6" = "yes"; then
+ have_af_inet6=1
+ AC_DEFINE(HAVE_AF_INET6, 1, [Define if AF_INET6 is defined])
+else
+ have_af_inet6=0
+fi
+])
+
+AC_DEFUN(APR_CHECK_SOCKADDR_STORAGE,[
+AC_CACHE_CHECK(for sockaddr_storage, ac_cv_define_sockaddr_storage,[
+AC_TRY_COMPILE([
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+],[
+struct sockaddr_storage sa;
+],[
+ ac_cv_define_sockaddr_storage=yes
+],[
+ ac_cv_define_sockaddr_storage=no
+])
+])
+
+if test "$ac_cv_define_sockaddr_storage" = "yes"; then
+ have_sockaddr_storage=1
+ AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Define if struct sockaddr_storage exists])
+else
+ have_sockaddr_storage=0
+fi
+])
+
+dnl This test taken from GCC libjava.
+AC_DEFUN(CHECK_PROC_SELF_EXE,[
+ if test x"$cross_compiling" = x"no"; then
+ AC_CHECK_FILES(/proc/self/exe, [
+ AC_DEFINE(HAVE_PROC_SELF_EXE, 1, [Define if you have /proc/self/exe])])
+ else
+ case $host in
+ *-linux*)
+ AC_DEFINE(HAVE_PROC_SELF_EXE, 1, [Define if you have /proc/self/exe])
+ ;;
+ esac
+ fi
+])
diff --git a/nbase/configure b/nbase/configure
new file mode 100755
index 0000000..f092e21
--- /dev/null
+++ b/nbase/configure
@@ -0,0 +1,6574 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Use a proper internal environment variable to ensure we don't fall
+ # into an infinite loop, continuously re-executing ourselves.
+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+ _as_can_reexec=no; export _as_can_reexec;
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+ fi
+ # We don't want this to propagate to other subprocesses.
+ { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+ as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
+ setopt NO_GLOB_SUBST
+else
+ case \`(set -o) 2>/dev/null\` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+"
+ as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+ exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+ if (eval "$as_required") 2>/dev/null; then :
+ as_have_required=yes
+else
+ as_have_required=no
+fi
+ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ as_found=:
+ case $as_dir in #(
+ /*)
+ for as_base in sh bash ksh sh5; do
+ # Try only shells that exist, to save several forks.
+ as_shell=$as_dir/$as_base
+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ CONFIG_SHELL=$as_shell as_have_required=yes
+ if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ break 2
+fi
+fi
+ done;;
+ esac
+ as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+ CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+ if test "x$CONFIG_SHELL" != x; then :
+ export CONFIG_SHELL
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+ if test x$as_have_required = xno; then :
+ $as_echo "$0: This script requires a shell more modern than all"
+ $as_echo "$0: the shells that I found on your system."
+ if test x${ZSH_VERSION+set} = xset ; then
+ $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+ $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+ else
+ $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+ fi
+ exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+ as_lineno_1=$LINENO as_lineno_1a=$LINENO
+ as_lineno_2=$LINENO as_lineno_2a=$LINENO
+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+ # already done that, so ensure we don't try to do so again and fall
+ # in an infinite loop. This has already happened in practice.
+ _as_can_reexec=no; export _as_can_reexec
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+PACKAGE_URL=
+
+ac_unique_file="nbase.h"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='LTLIBOBJS
+LIBOBJS
+EGREP
+GREP
+CPP
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+RANLIB
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+runstatedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+with_localdirs
+enable_ipv6
+with_openssl
+'
+ ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval $ac_prev=\$ac_option
+ ac_prev=
+ continue
+ fi
+
+ case $ac_option in
+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *=) ac_optarg= ;;
+ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_dashdash$ac_option in
+ --)
+ ac_dashdash=yes ;;
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=*)
+ datadir=$ac_optarg ;;
+
+ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+ | --dataroo | --dataro | --datar)
+ ac_prev=datarootdir ;;
+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+ datarootdir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=no ;;
+
+ -docdir | --docdir | --docdi | --doc | --do)
+ ac_prev=docdir ;;
+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+ docdir=$ac_optarg ;;
+
+ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+ ac_prev=dvidir ;;
+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+ dvidir=$ac_optarg ;;
+
+ -enable-* | --enable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=\$ac_optarg ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+ ac_prev=htmldir ;;
+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+ | --ht=*)
+ htmldir=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localedir | --localedir | --localedi | --localed | --locale)
+ ac_prev=localedir ;;
+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+ localedir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst | --locals)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+ ac_prev=pdfdir ;;
+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+ pdfdir=$ac_optarg ;;
+
+ -psdir | --psdir | --psdi | --psd | --ps)
+ ac_prev=psdir ;;
+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+ psdir=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=\$ac_optarg ;;
+
+ -without-* | --without-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=no ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ case $ac_envvar in #(
+ '' | [0-9]* | *[!_$as_cr_alnum]* )
+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+ esac
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+ case $enable_option_checking in
+ no) ;;
+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+ esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+ libdir localedir mandir runstatedir
+do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+ case $ac_val in
+ */ )
+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+ eval $ac_var=\$ac_val;;
+ esac
+ # Be sure to have absolute directory names.
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+ as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+ as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then the parent directory.
+ ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_myself" : 'X\(//\)[^/]' \| \
+ X"$as_myself" : 'X\(//\)$' \| \
+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+ pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+ srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+ eval ac_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_env_${ac_var}_value=\$${ac_var}
+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking ...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+_ACEOF
+
+ cat <<\_ACEOF
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --disable-ipv6 Disable IPv6 support
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-localdirs Explicitly ask compiler to use /usr/local/{include,libs} if they exist
+ --with-openssl=DIR Use optional openssl libs and includes from DIR/lib/
+and DIR/include/openssl/)
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to the package provider.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d "$ac_dir" ||
+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+ continue
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+ cd "$ac_dir" || { ac_status=$?; continue; }
+ # Check for guested configure.
+ if test -f "$ac_srcdir/configure.gnu"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+ elif test -f "$ac_srcdir/configure"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure" --help=recursive
+ else
+ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi || ac_status=$?
+ cd "$ac_pwd" || { ac_status=$?; break; }
+ done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+ cat <<\_ACEOF
+configure
+generated by GNU Autoconf 2.69
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } > conftest.i && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=$ac_status
+fi
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if eval \${$3+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_header_compiler=yes
+else
+ ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ ac_header_preproc=yes
+else
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+ yes:no: )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+ ;;
+esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_find_intX_t LINENO BITS VAR
+# -----------------------------------
+# Finds a signed integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_intX_t ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5
+$as_echo_n "checking for int$2_t... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=no"
+ # Order is important - never check a type that is potentially smaller
+ # than half of the expected target width.
+ for ac_type in int$2_t 'int' 'long int' \
+ 'long long int' 'short int' 'signed char'; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+ enum { N = $2 / 2 - 1 };
+int
+main ()
+{
+static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+ enum { N = $2 / 2 - 1 };
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)
+ < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ case $ac_type in #(
+ int$2_t) :
+ eval "$3=yes" ;; #(
+ *) :
+ eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if eval test \"x\$"$3"\" = x"no"; then :
+
+else
+ break
+fi
+ done
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_find_intX_t
+
+# ac_fn_c_find_uintX_t LINENO BITS VAR
+# ------------------------------------
+# Finds an unsigned integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_uintX_t ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5
+$as_echo_n "checking for uint$2_t... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=no"
+ # Order is important - never check a type that is potentially smaller
+ # than half of the expected target width.
+ for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \
+ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ case $ac_type in #(
+ uint$2_t) :
+ eval "$3=yes" ;; #(
+ *) :
+ eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if eval test \"x\$"$3"\" = x"no"; then :
+
+else
+ break
+fi
+ done
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_find_uintX_t
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $2 (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ $as_echo "PATH: $as_dir"
+ done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *\'*)
+ ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+ 2)
+ as_fn_append ac_configure_args1 " '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ as_fn_append ac_configure_args " '$ac_arg'"
+ ;;
+ esac
+ done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+(
+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+ (set) 2>&1 |
+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ sed -n \
+ "s/'\''/'\''\\\\'\'''\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+ ;; #(
+ *)
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+)
+ echo
+
+ $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+ echo
+ cat confdefs.h
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ $as_echo "$as_me: caught signal $ac_signal"
+ $as_echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core core.conftest.* &&
+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+ # We do not want a PATH search for config.site.
+ case $CONFIG_SITE in #((
+ -*) ac_site_file1=./$CONFIG_SITE;;
+ */*) ac_site_file1=$CONFIG_SITE;;
+ *) ac_site_file1=./$CONFIG_SITE;;
+ esac
+elif test "x$prefix" != xNONE; then
+ ac_site_file1=$prefix/share/config.site
+ ac_site_file2=$prefix/etc/config.site
+else
+ ac_site_file1=$ac_default_prefix/share/config.site
+ ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+ test "x$ac_site_file" = xNONE && continue
+ if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file" \
+ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special files
+ # actually), so we avoid doing that. DJGPP emulates it as a regular file.
+ if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . "$cache_file";;
+ *) . "./$cache_file";;
+ esac
+ fi
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val=\$ac_cv_env_${ac_var}_value
+ eval ac_new_val=\$ac_env_${ac_var}_value
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
+ if test "$ac_old_val_w" != "$ac_new_val_w"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ ac_cache_corrupted=:
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+ eval $ac_var=\$ac_old_val
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
+$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
+$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+# Check whether --with-localdirs was given.
+if test "${with_localdirs+set}" = set; then :
+ withval=$with_localdirs; case "$with_localdirs" in
+ yes)
+ user_localdirs=1
+ ;;
+ no)
+ user_localdirs=0
+ ;;
+ esac
+
+else
+ user_localdirs=0
+fi
+
+
+if test "$user_localdirs" = 1; then
+ if test -d /usr/local/lib; then
+ LDFLAGS="$LDFLAGS -L/usr/local/lib"
+ fi
+ if test -d /usr/local/include; then
+ CPPFLAGS="$CPPFLAGS -I/usr/local/include"
+ fi
+fi
+
+ac_config_headers="$ac_config_headers nbase_config.h"
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ fi
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl.exe
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl.exe
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link_default") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile. We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ then :; else
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ fi
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
+ break;;
+ * )
+ break;;
+ esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+ ac_file=''
+fi
+if test -z "$ac_file"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+ { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ if { ac_try='./conftest$ac_cv_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ for ac_file in conftest.o conftest.obj conftest.*; do
+ test -f "$ac_file" || continue;
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+else
+ CFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ if test -n "$GCC"; then
+ CFLAGS="$CFLAGS -Wall "
+ fi
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+ ac_ct_RANLIB=$RANLIB
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_RANLIB"; then
+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_RANLIB" = x; then
+ RANLIB=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ RANLIB=$ac_ct_RANLIB
+ fi
+else
+ RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+ if test -f "$ac_dir/install-sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f "$ac_dir/install.sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f "$ac_dir/shtool"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
+$as_echo_n "checking for inline... " >&6; }
+if ${ac_cv_c_inline+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_c_inline=$ac_kw
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
+$as_echo "$ac_cv_c_inline" >&6; }
+
+case $ac_cv_c_inline in
+ inline | yes) ;;
+ *)
+ case $ac_cv_c_inline in
+ no) ac_val=;;
+ *) ac_val=$ac_cv_c_inline;;
+ esac
+ cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+ ;;
+esac
+
+
+case "$host" in
+ *-sgi-irix5* | *-sgi-irix6*)
+ if test -z "$GCC"; then
+ $as_echo "#define inline /**/" >>confdefs.h
+
+ fi
+ ;;
+esac
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if ${ac_cv_prog_CPP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$GREP"; then
+ ac_path_GREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'GREP' >> "conftest.nl"
+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_GREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_GREP="$ac_path_GREP"
+ ac_path_GREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_GREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_GREP"; then
+ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+ then ac_cv_path_EGREP="$GREP -E"
+ else
+ if test -z "$EGREP"; then
+ ac_path_EGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'EGREP' >> "conftest.nl"
+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_EGREP="$ac_path_EGREP"
+ ac_path_EGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_EGREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_EGREP"; then
+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_EGREP=$EGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in string.h getopt.h strings.h sys/param.h sys/time.h unistd.h errno.h sys/select.h sys/types.h sys/socket.h netinet/in.h arpa/inet.h sys/stat.h netdb.h sys/wait.h fcntl.h sys/resource.h inttypes.h mach-o/dyld.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
+$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
+if ${ac_cv_header_time+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_time=yes
+else
+ ac_cv_header_time=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
+$as_echo "$ac_cv_header_time" >&6; }
+if test $ac_cv_header_time = yes; then
+
+$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
+
+fi
+
+for ac_header in sys/socket.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_socket_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_SOCKET_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in net/if.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "#include <stdio.h>
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+
+"
+if test "x$ac_cv_header_net_if_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_NET_IF_H 1
+_ACEOF
+
+fi
+
+done
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__" >&5
+$as_echo_n "checking for __attribute__... " >&6; }
+if ${ac_cv___attribute__+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <stdlib.h>
+
+ static void foo(void) __attribute__ ((noreturn));
+
+ static void
+ foo(void)
+ {
+ exit(1);
+ }
+
+int
+main ()
+{
+
+ foo();
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv___attribute__=yes
+else
+ ac_cv___attribute__=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+
+if test "$ac_cv___attribute__" = "yes"; then
+
+$as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute__" >&5
+$as_echo "$ac_cv___attribute__" >&6; }
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr{} has sa_len member" >&5
+$as_echo_n "checking if sockaddr{} has sa_len member... " >&6; }
+if ${ac_cv_sockaddr_has_sa_len+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <sys/types.h>
+ #include <sys/socket.h>
+int
+main ()
+{
+unsigned int i = sizeof(((struct sockaddr *)0)->sa_len)
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_sockaddr_has_sa_len=yes
+else
+ ac_cv_sockaddr_has_sa_len=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sockaddr_has_sa_len" >&5
+$as_echo "$ac_cv_sockaddr_has_sa_len" >&6; }
+if test $ac_cv_sockaddr_has_sa_len = yes ; then
+
+$as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h
+
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
+$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
+if ${ac_cv_c_bigendian+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_c_bigendian=unknown
+ # See if we're dealing with a universal compiler.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifndef __APPLE_CC__
+ not a universal capable compiler
+ #endif
+ typedef int dummy;
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ # Check for potential -arch flags. It is not universal unless
+ # there are at least two -arch flags with different values.
+ ac_arch=
+ ac_prev=
+ for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
+ if test -n "$ac_prev"; then
+ case $ac_word in
+ i?86 | x86_64 | ppc | ppc64)
+ if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
+ ac_arch=$ac_word
+ else
+ ac_cv_c_bigendian=universal
+ break
+ fi
+ ;;
+ esac
+ ac_prev=
+ elif test "x$ac_word" = "x-arch"; then
+ ac_prev=arch
+ fi
+ done
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if test $ac_cv_c_bigendian = unknown; then
+ # See if sys/param.h defines the BYTE_ORDER macro.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+ #include <sys/param.h>
+
+int
+main ()
+{
+#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
+ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
+ && LITTLE_ENDIAN)
+ bogus endian macros
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ # It does; now see whether it defined to BIG_ENDIAN or not.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+ #include <sys/param.h>
+
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_c_bigendian=yes
+else
+ ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ if test $ac_cv_c_bigendian = unknown; then
+ # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <limits.h>
+
+int
+main ()
+{
+#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
+ bogus endian macros
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ # It does; now see whether it defined to _BIG_ENDIAN or not.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <limits.h>
+
+int
+main ()
+{
+#ifndef _BIG_ENDIAN
+ not big endian
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_c_bigendian=yes
+else
+ ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ if test $ac_cv_c_bigendian = unknown; then
+ # Compile a test program.
+ if test "$cross_compiling" = yes; then :
+ # Try to guess by grepping values from an object file.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+short int ascii_mm[] =
+ { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+ short int ascii_ii[] =
+ { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+ int use_ascii (int i) {
+ return ascii_mm[i] + ascii_ii[i];
+ }
+ short int ebcdic_ii[] =
+ { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+ short int ebcdic_mm[] =
+ { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+ int use_ebcdic (int i) {
+ return ebcdic_mm[i] + ebcdic_ii[i];
+ }
+ extern int foo;
+
+int
+main ()
+{
+return use_ascii (foo) == use_ebcdic (foo);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
+ ac_cv_c_bigendian=yes
+ fi
+ if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+ if test "$ac_cv_c_bigendian" = unknown; then
+ ac_cv_c_bigendian=no
+ else
+ # finding both strings is unlikely to happen, but who knows?
+ ac_cv_c_bigendian=unknown
+ fi
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+
+ /* Are we little or big endian? From Harbison&Steele. */
+ union
+ {
+ long int l;
+ char c[sizeof (long int)];
+ } u;
+ u.l = 1;
+ return u.c[sizeof (long int) - 1] == 1;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ac_cv_c_bigendian=no
+else
+ ac_cv_c_bigendian=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
+$as_echo "$ac_cv_c_bigendian" >&6; }
+ case $ac_cv_c_bigendian in #(
+ yes)
+ $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
+;; #(
+ no)
+ ;; #(
+ universal)
+
+$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
+
+ ;; #(
+ *)
+ as_fn_error $? "unknown endianness
+ presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
+ esac
+
+
+ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t"
+case $ac_cv_c_int8_t in #(
+ no|yes) ;; #(
+ *)
+
+cat >>confdefs.h <<_ACEOF
+#define int8_t $ac_cv_c_int8_t
+_ACEOF
+;;
+esac
+
+ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t"
+case $ac_cv_c_int16_t in #(
+ no|yes) ;; #(
+ *)
+
+cat >>confdefs.h <<_ACEOF
+#define int16_t $ac_cv_c_int16_t
+_ACEOF
+;;
+esac
+
+ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t"
+case $ac_cv_c_int32_t in #(
+ no|yes) ;; #(
+ *)
+
+cat >>confdefs.h <<_ACEOF
+#define int32_t $ac_cv_c_int32_t
+_ACEOF
+;;
+esac
+
+ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t"
+case $ac_cv_c_int64_t in #(
+ no|yes) ;; #(
+ *)
+
+cat >>confdefs.h <<_ACEOF
+#define int64_t $ac_cv_c_int64_t
+_ACEOF
+;;
+esac
+
+ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t"
+case $ac_cv_c_uint8_t in #(
+ no|yes) ;; #(
+ *)
+
+$as_echo "#define _UINT8_T 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint8_t $ac_cv_c_uint8_t
+_ACEOF
+;;
+ esac
+
+ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t"
+case $ac_cv_c_uint16_t in #(
+ no|yes) ;; #(
+ *)
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint16_t $ac_cv_c_uint16_t
+_ACEOF
+;;
+ esac
+
+ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"
+case $ac_cv_c_uint32_t in #(
+ no|yes) ;; #(
+ *)
+
+$as_echo "#define _UINT32_T 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint32_t $ac_cv_c_uint32_t
+_ACEOF
+;;
+ esac
+
+ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t"
+case $ac_cv_c_uint64_t in #(
+ no|yes) ;; #(
+ *)
+
+$as_echo "#define _UINT64_T 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint64_t $ac_cv_c_uint64_t
+_ACEOF
+;;
+ esac
+
+
+for ac_func in snprintf vsnprintf nanosleep strerror strcasestr strcasecmp strncasecmp signal
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+needsnprintf=no
+for ac_func in vsnprintf snprintf asprintf asnprintf vasprintf vasnprintf
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ needsnprintf=yes
+fi
+done
+
+if test $needsnprintf = yes; then
+ case " $LIBOBJS " in
+ *" snprintf.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS snprintf.$ac_objext"
+ ;;
+esac
+
+fi
+
+for ac_func in getopt getopt_long_only
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in usleep gettimeofday sleep localtime_s localtime_r
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+case " $LIBOBJS " in
+ *" nbase_time.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS nbase_time.$ac_objext"
+ ;;
+esac
+
+
+ac_fn_c_check_func "$LINENO" "getopt_long_only" "ac_cv_func_getopt_long_only"
+if test "x$ac_cv_func_getopt_long_only" = xyes; then :
+
+else
+ case " $LIBOBJS " in
+ *" getopt.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getopt.$ac_objext"
+ ;;
+esac
+
+fi
+
+
+for ac_func in strcasecmp strncasecmp
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ case " $LIBOBJS " in
+ *" strcasecmp.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS strcasecmp.$ac_objext"
+ ;;
+esac
+
+fi
+done
+
+
+case " $LIBOBJS " in
+ *" nbase_str.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS nbase_str.$ac_objext"
+ ;;
+esac
+
+case " $LIBOBJS " in
+ *" nbase_misc.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS nbase_misc.$ac_objext"
+ ;;
+esac
+
+case " $LIBOBJS " in
+ *" nbase_memalloc.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS nbase_memalloc.$ac_objext"
+ ;;
+esac
+
+case " $LIBOBJS " in
+ *" nbase_rnd.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS nbase_rnd.$ac_objext"
+ ;;
+esac
+
+case " $LIBOBJS " in
+ *" nbase_addrset.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS nbase_addrset.$ac_objext"
+ ;;
+esac
+
+
+# Check for IPv6 support -- modified from Apache 2.0.40:
+
+# Check whether --enable-ipv6 was given.
+if test "${enable_ipv6+set}" = set; then :
+ enableval=$enable_ipv6; if test "$enableval" = "no"; then
+ user_disabled_ipv6=1
+ fi
+else
+ user_disabled_ipv6=0
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getaddrinfo" >&5
+$as_echo_n "checking for library containing getaddrinfo... " >&6; }
+if ${ac_cv_search_getaddrinfo+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char getaddrinfo ();
+int
+main ()
+{
+return getaddrinfo ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' inet6 socket; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_getaddrinfo=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_getaddrinfo+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_getaddrinfo+:} false; then :
+
+else
+ ac_cv_search_getaddrinfo=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getaddrinfo" >&5
+$as_echo "$ac_cv_search_getaddrinfo" >&6; }
+ac_res=$ac_cv_search_getaddrinfo
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gai_strerror" >&5
+$as_echo_n "checking for library containing gai_strerror... " >&6; }
+if ${ac_cv_search_gai_strerror+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gai_strerror ();
+int
+main ()
+{
+return gai_strerror ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' inet6 socket; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_gai_strerror=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_gai_strerror+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_gai_strerror+:} false; then :
+
+else
+ ac_cv_search_gai_strerror=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gai_strerror" >&5
+$as_echo "$ac_cv_search_gai_strerror" >&6; }
+ac_res=$ac_cv_search_gai_strerror
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getnameinfo" >&5
+$as_echo_n "checking for library containing getnameinfo... " >&6; }
+if ${ac_cv_search_getnameinfo+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char getnameinfo ();
+int
+main ()
+{
+return getnameinfo ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' inet6 socket; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_getnameinfo=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_getnameinfo+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_getnameinfo+:} false; then :
+
+else
+ ac_cv_search_getnameinfo=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getnameinfo" >&5
+$as_echo "$ac_cv_search_getnameinfo" >&6; }
+ac_res=$ac_cv_search_getnameinfo
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_ntop" >&5
+$as_echo_n "checking for library containing inet_ntop... " >&6; }
+if ${ac_cv_search_inet_ntop+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char inet_ntop ();
+int
+main ()
+{
+return inet_ntop ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' nsl resolv network; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_inet_ntop=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_inet_ntop+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_inet_ntop+:} false; then :
+
+else
+ ac_cv_search_inet_ntop=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_ntop" >&5
+$as_echo "$ac_cv_search_inet_ntop" >&6; }
+ac_res=$ac_cv_search_inet_ntop
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+else
+ case " $LIBOBJS " in
+ *" inet_ntop.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS inet_ntop.$ac_objext"
+ ;;
+esac
+
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_pton" >&5
+$as_echo_n "checking for library containing inet_pton... " >&6; }
+if ${ac_cv_search_inet_pton+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char inet_pton ();
+int
+main ()
+{
+return inet_pton ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' nsl resolv network; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_inet_pton=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_inet_pton+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_inet_pton+:} false; then :
+
+else
+ ac_cv_search_inet_pton=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_pton" >&5
+$as_echo "$ac_cv_search_inet_pton" >&6; }
+ac_res=$ac_cv_search_inet_pton
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+else
+ case " $LIBOBJS " in
+ *" inet_pton.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS inet_pton.$ac_objext"
+ ;;
+esac
+
+
+fi
+
+for ac_func in gai_strerror inet_pton inet_ntop
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working getaddrinfo" >&5
+$as_echo_n "checking for working getaddrinfo... " >&6; }
+if ${ac_cv_working_getaddrinfo+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ if test "$cross_compiling" = yes; then :
+
+ ac_cv_working_getaddrinfo="yes"
+
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+int main(void) {
+ struct addrinfo hints, *ai;
+ int error;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ error = getaddrinfo("127.0.0.1", NULL, &hints, &ai);
+ if (error) {
+ return 1;
+ }
+ if (ai->ai_addr->sa_family != AF_INET) {
+ return 1;
+ }
+ return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+ ac_cv_working_getaddrinfo="yes"
+
+else
+
+ ac_cv_working_getaddrinfo="no"
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_getaddrinfo" >&5
+$as_echo "$ac_cv_working_getaddrinfo" >&6; }
+if test "$ac_cv_working_getaddrinfo" = "yes"; then
+ if test "$ac_cv_func_gai_strerror" != "yes"; then
+ ac_cv_working_getaddrinfo="no"
+ else
+
+$as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h
+
+ fi
+fi
+
+# The inet_addr function is used by APR_CHECK_WORKING_GETNAMEINFO.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_addr" >&5
+$as_echo_n "checking for library containing inet_addr... " >&6; }
+if ${ac_cv_search_inet_addr+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char inet_addr ();
+int
+main ()
+{
+return inet_addr ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' nsl; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_inet_addr=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_inet_addr+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_inet_addr+:} false; then :
+
+else
+ ac_cv_search_inet_addr=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_addr" >&5
+$as_echo "$ac_cv_search_inet_addr" >&6; }
+ac_res=$ac_cv_search_inet_addr
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working getnameinfo" >&5
+$as_echo_n "checking for working getnameinfo... " >&6; }
+if ${ac_cv_working_getnameinfo+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ if test "$cross_compiling" = yes; then :
+
+ ac_cv_working_getnameinfo="yes"
+
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+int main(void) {
+ struct sockaddr_in sa;
+ char hbuf[256];
+ int error;
+
+ sa.sin_family = AF_INET;
+ sa.sin_port = 0;
+ sa.sin_addr.s_addr = inet_addr("127.0.0.1");
+#ifdef SIN6_LEN
+ sa.sin_len = sizeof(sa);
+#endif
+
+ error = getnameinfo((const struct sockaddr *)&sa, sizeof(sa),
+ hbuf, 256, NULL, 0,
+ NI_NUMERICHOST);
+ if (error) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+ ac_cv_working_getnameinfo="yes"
+
+else
+
+ ac_cv_working_getnameinfo="no"
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_getnameinfo" >&5
+$as_echo "$ac_cv_working_getnameinfo" >&6; }
+if test "$ac_cv_working_getnameinfo" = "yes"; then
+
+$as_echo "#define HAVE_GETNAMEINFO 1" >>confdefs.h
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sockaddr_in6" >&5
+$as_echo_n "checking for sockaddr_in6... " >&6; }
+if ${ac_cv_define_sockaddr_in6+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+int
+main ()
+{
+
+struct sockaddr_in6 sa;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ ac_cv_define_sockaddr_in6=yes
+
+else
+
+ ac_cv_define_sockaddr_in6=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_sockaddr_in6" >&5
+$as_echo "$ac_cv_define_sockaddr_in6" >&6; }
+
+if test "$ac_cv_define_sockaddr_in6" = "yes"; then
+ have_sockaddr_in6=1
+
+$as_echo "#define HAVE_SOCKADDR_IN6 1" >>confdefs.h
+
+else
+ have_sockaddr_in6=0
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sockaddr_storage" >&5
+$as_echo_n "checking for sockaddr_storage... " >&6; }
+if ${ac_cv_define_sockaddr_storage+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+int
+main ()
+{
+
+struct sockaddr_storage sa;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ ac_cv_define_sockaddr_storage=yes
+
+else
+
+ ac_cv_define_sockaddr_storage=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_sockaddr_storage" >&5
+$as_echo "$ac_cv_define_sockaddr_storage" >&6; }
+
+if test "$ac_cv_define_sockaddr_storage" = "yes"; then
+ have_sockaddr_storage=1
+
+$as_echo "#define HAVE_SOCKADDR_STORAGE 1" >>confdefs.h
+
+else
+ have_sockaddr_storage=0
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for AF_INET6 definition" >&5
+$as_echo_n "checking for AF_INET6 definition... " >&6; }
+if ${ac_cv_define_af_inet6+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+int
+main ()
+{
+
+int af = AF_INET6;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ ac_cv_define_af_inet6=yes
+
+else
+
+ ac_cv_define_af_inet6=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_af_inet6" >&5
+$as_echo "$ac_cv_define_af_inet6" >&6; }
+
+if test "$ac_cv_define_af_inet6" = "yes"; then
+ have_af_inet6=1
+
+$as_echo "#define HAVE_AF_INET6 1" >>confdefs.h
+
+else
+ have_af_inet6=0
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for IPv6 support" >&5
+$as_echo_n "checking for IPv6 support... " >&6; }
+have_ipv6="0"
+if test "$user_disabled_ipv6" = 1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"no -- disabled by user\"" >&5
+$as_echo "\"no -- disabled by user\"" >&6; }
+else
+ if test "x$have_sockaddr_in6" = "x1"; then
+ if test "x$ac_cv_working_getaddrinfo" = "xyes"; then
+ if test "x$ac_cv_working_getnameinfo" = "xyes"; then
+ have_ipv6="1"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"no -- no working getnameinfo\"" >&5
+$as_echo "\"no -- no working getnameinfo\"" >&6; }
+ fi
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"no -- no working getaddrinfo\"" >&5
+$as_echo "\"no -- no working getaddrinfo\"" >&6; }
+ fi
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"no -- no sockaddr_in6\"" >&5
+$as_echo "\"no -- no sockaddr_in6\"" >&6; };
+ fi
+fi
+
+if test "x$ac_cv_working_getaddrinfo" != "xyes"; then
+case " $LIBOBJS " in
+ *" getaddrinfo.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getaddrinfo.$ac_objext"
+ ;;
+esac
+
+fi
+
+if test "x$ac_cv_working_getnameinfo" != "xyes"; then
+case " $LIBOBJS " in
+ *" getnameinfo.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getnameinfo.$ac_objext"
+ ;;
+esac
+
+fi
+
+if test "$have_ipv6" = "1"; then
+
+$as_echo "#define HAVE_IPV6 1" >>confdefs.h
+
+fi
+
+# First we test whether they specified openssl desires explicitly
+use_openssl="yes"
+specialssldir=""
+
+
+# Check whether --with-openssl was given.
+if test "${with_openssl+set}" = set; then :
+ withval=$with_openssl; case "$with_openssl" in
+ yes)
+ ;;
+ no)
+ use_openssl="no"
+ ;;
+ *)
+ specialssldir="$with_openssl"
+ ;;
+ esac
+
+fi
+
+
+
+# If they didn't specify it, we try to find it
+if test "$use_openssl" = "yes" -a -z "$specialssldir"; then
+ ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_ssl_h" = xyes; then :
+
+else
+ use_openssl="no"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed to find openssl/ssl.h so OpenSSL will not be used. If it
+ is installed you can try the --with-openssl=DIR argument" >&5
+$as_echo "$as_me: WARNING: Failed to find openssl/ssl.h so OpenSSL will not be used. If it
+ is installed you can try the --with-openssl=DIR argument" >&2;}
+fi
+
+
+
+ if test "$use_openssl" = "yes"; then
+ ac_fn_c_check_header_mongrel "$LINENO" "openssl/err.h" "ac_cv_header_openssl_err_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_err_h" = xyes; then :
+
+else
+ use_openssl="no"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed to find openssl/err.h so OpenSSL will not be used. If it
+ is installed you can try the --with-openssl=DIR argument" >&5
+$as_echo "$as_me: WARNING: Failed to find openssl/err.h so OpenSSL will not be used. If it
+ is installed you can try the --with-openssl=DIR argument" >&2;}
+fi
+
+
+ fi
+
+ if test "$use_openssl" = "yes"; then
+ ac_fn_c_check_header_mongrel "$LINENO" "openssl/rand.h" "ac_cv_header_openssl_rand_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_rand_h" = xyes; then :
+
+else
+ use_openssl="no"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed to find openssl/rand.h so OpenSSL will not be used. If i
+t is installed you can try the --with-openssl=DIR argument" >&5
+$as_echo "$as_me: WARNING: Failed to find openssl/rand.h so OpenSSL will not be used. If i
+t is installed you can try the --with-openssl=DIR argument" >&2;}
+fi
+
+
+ fi
+
+ if test "$use_openssl" = "yes"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BIO_int_ctrl in -lcrypto" >&5
+$as_echo_n "checking for BIO_int_ctrl in -lcrypto... " >&6; }
+if ${ac_cv_lib_crypto_BIO_int_ctrl+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypto $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char BIO_int_ctrl ();
+int
+main ()
+{
+return BIO_int_ctrl ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_crypto_BIO_int_ctrl=yes
+else
+ ac_cv_lib_crypto_BIO_int_ctrl=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_BIO_int_ctrl" >&5
+$as_echo "$ac_cv_lib_crypto_BIO_int_ctrl" >&6; }
+if test "x$ac_cv_lib_crypto_BIO_int_ctrl" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBCRYPTO 1
+_ACEOF
+
+ LIBS="-lcrypto $LIBS"
+
+else
+ use_openssl="no"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed to find libcrypto so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&5
+$as_echo "$as_me: WARNING: Failed to find libcrypto so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&2;}
+fi
+
+ fi
+
+ if test "$use_openssl" = "yes"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_new in -lssl" >&5
+$as_echo_n "checking for SSL_new in -lssl... " >&6; }
+if ${ac_cv_lib_ssl_SSL_new+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lssl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char SSL_new ();
+int
+main ()
+{
+return SSL_new ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_ssl_SSL_new=yes
+else
+ ac_cv_lib_ssl_SSL_new=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_new" >&5
+$as_echo "$ac_cv_lib_ssl_SSL_new" >&6; }
+if test "x$ac_cv_lib_ssl_SSL_new" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBSSL 1
+_ACEOF
+
+ LIBS="-lssl $LIBS"
+
+else
+ use_openssl="no"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed to find libssl so OpenSSL will not be used. If it is ins
+talled you can try the --with-openssl=DIR argument" >&5
+$as_echo "$as_me: WARNING: Failed to find libssl so OpenSSL will not be used. If it is ins
+talled you can try the --with-openssl=DIR argument" >&2;}
+fi
+
+ fi
+fi
+
+if test "$use_openssl" = "yes"; then
+
+$as_echo "#define HAVE_OPENSSL 1" >>confdefs.h
+
+fi
+
+
+ if test x"$cross_compiling" = x"no"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /proc/self/exe" >&5
+$as_echo_n "checking for /proc/self/exe... " >&6; }
+if ${ac_cv_file__proc_self_exe+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ test "$cross_compiling" = yes &&
+ as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5
+if test -r "/proc/self/exe"; then
+ ac_cv_file__proc_self_exe=yes
+else
+ ac_cv_file__proc_self_exe=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__proc_self_exe" >&5
+$as_echo "$ac_cv_file__proc_self_exe" >&6; }
+if test "x$ac_cv_file__proc_self_exe" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE__PROC_SELF_EXE 1
+_ACEOF
+
+
+$as_echo "#define HAVE_PROC_SELF_EXE 1" >>confdefs.h
+
+fi
+
+ else
+ case $host in
+ *-linux*)
+
+$as_echo "#define HAVE_PROC_SELF_EXE 1" >>confdefs.h
+
+ ;;
+ esac
+ fi
+
+
+ac_config_files="$ac_config_files Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+
+ (set) 2>&1 |
+ case $as_nl`(ac_space=' '; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ # `set' does not quote correctly, so add quotes: double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \.
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;; #(
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+) |
+ sed '
+ /^ac_cv_env_/b end
+ t clear
+ :clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+ if test "x$cache_file" != "x/dev/null"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+ if test ! -f "$cache_file" || test -h "$cache_file"; then
+ cat confcache >"$cache_file"
+ else
+ case $cache_file in #(
+ */* | ?:*)
+ mv -f confcache "$cache_file"$$ &&
+ mv -f "$cache_file"$$ "$cache_file" ;; #(
+ *)
+ mv -f confcache "$cache_file" ;;
+ esac
+ fi
+ fi
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+U=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
+ # will be set to the directory where LIBOBJS objects are built.
+ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+
+: "${CONFIG_STATUS=./config.status}"
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration. Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number and configuration settings, then exit
+ --config print configuration, then exit
+ -q, --quiet, --silent
+ do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to the package provider."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.69,
+ with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=?*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ --*=)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=
+ ac_shift=:
+ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
+ --config | --confi | --conf | --con | --co | --c )
+ $as_echo "$ac_cs_config"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ '') as_fn_error $? "missing file argument" ;;
+ esac
+ as_fn_append CONFIG_FILES " '$ac_optarg'"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+ ac_need_defaults=false;;
+ --he | --h)
+ # Conflict between --help and --header
+ as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+ --help | --hel | -h )
+ $as_echo "$ac_cs_usage"; exit ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+ *) as_fn_append ac_config_targets " $1"
+ ac_need_defaults=false ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ shift
+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+ CONFIG_SHELL='$SHELL'
+ export CONFIG_SHELL
+ exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+ $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+ case $ac_config_target in
+ "nbase_config.h") CONFIG_HEADERS="$CONFIG_HEADERS nbase_config.h" ;;
+ "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+
+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+ esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+ tmp= ac_tmp=
+ trap 'exit_status=$?
+ : "${ac_tmp:=$tmp}"
+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+ trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+ test -d "$tmp"
+} ||
+{
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+ eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+ ac_cs_awk_cr='\\r'
+else
+ ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+ echo "cat >conf$$subs.awk <<_ACEOF" &&
+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+ echo "_ACEOF"
+} >conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+ . ./conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+ if test $ac_delim_n = $ac_delim_num; then
+ break
+ elif $ac_last_try; then
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+ N
+ s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+ for (key in S) S_is_set[key] = 1
+ FS = ""
+
+}
+{
+ line = $ 0
+ nfields = split(line, field, "@")
+ substed = 0
+ len = length(field[1])
+ for (i = 2; i < nfields; i++) {
+ key = field[i]
+ keylen = length(key)
+ if (S_is_set[key]) {
+ value = S[key]
+ line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+ len += length(value) + length(field[++i])
+ substed = 1
+ } else
+ len += 1 + keylen
+ }
+
+ print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+ cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
+h
+s///
+s/^/:/
+s/[ ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[ ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[ ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+ if test -z "$ac_tt"; then
+ break
+ elif $ac_last_try; then
+ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any. Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[ ]*#[ ]*define[ ][ ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ for (key in D) D_is_set[key] = 1
+ FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+ line = \$ 0
+ split(line, arg, " ")
+ if (arg[1] == "#") {
+ defundef = arg[2]
+ mac1 = arg[3]
+ } else {
+ defundef = substr(arg[1], 2)
+ mac1 = arg[2]
+ }
+ split(mac1, mac2, "(") #)
+ macro = mac2[1]
+ prefix = substr(line, 1, index(line, defundef) - 1)
+ if (D_is_set[macro]) {
+ # Preserve the white space surrounding the "#".
+ print prefix "define", macro P[macro] D[macro]
+ next
+ } else {
+ # Replace #undef with comments. This is necessary, for example,
+ # in the case of _POSIX_SOURCE, which is predefined and required
+ # on some systems where configure will not decide to define it.
+ if (defundef == "undef") {
+ print "/*", prefix defundef, macro, "*/"
+ next
+ }
+ }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
+shift
+for ac_tag
+do
+ case $ac_tag in
+ :[FHLC]) ac_mode=$ac_tag; continue;;
+ esac
+ case $ac_mode$ac_tag in
+ :[FHL]*:*);;
+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+ ac_save_IFS=$IFS
+ IFS=:
+ set x $ac_tag
+ IFS=$ac_save_IFS
+ shift
+ ac_file=$1
+ shift
+
+ case $ac_mode in
+ :L) ac_source=$1;;
+ :[FH])
+ ac_file_inputs=
+ for ac_f
+ do
+ case $ac_f in
+ -) ac_f="$ac_tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+ test -f "$ac_f" ||
+ case $ac_f in
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+ esac
+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+ as_fn_append ac_file_inputs " '$ac_f'"
+ done
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ configure_input='Generated from '`
+ $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+ `' by configure.'
+ if test x"$ac_file" != x-; then
+ configure_input="$ac_file. $configure_input"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+ fi
+ # Neutralize special characters interpreted by sed in replacement strings.
+ case $configure_input in #(
+ *\&* | *\|* | *\\* )
+ ac_sed_conf_input=`$as_echo "$configure_input" |
+ sed 's/[\\\\&|]/\\\\&/g'`;; #(
+ *) ac_sed_conf_input=$configure_input;;
+ esac
+
+ case $ac_tag in
+ *:-:* | *:-) cat >"$ac_tmp/stdin" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+ esac
+ ;;
+ esac
+
+ ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ as_dir="$ac_dir"; as_fn_mkdir_p
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+ case $ac_mode in
+ :F)
+ #
+ # CONFIG_FILE
+ #
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+ p
+ q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ ac_datarootdir_hack='
+ s&@datadir@&$datadir&g
+ s&@docdir@&$docdir&g
+ s&@infodir@&$infodir&g
+ s&@localedir@&$localedir&g
+ s&@mandir@&$mandir&g
+ s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
+ "$ac_tmp/out"`; test -z "$ac_out"; } &&
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&2;}
+
+ rm -f "$ac_tmp/stdin"
+ case $ac_file in
+ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+ esac \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+ :H)
+ #
+ # CONFIG_HEADER
+ #
+ if test x"$ac_file" != x-; then
+ {
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+ } >"$ac_tmp/config.h" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ rm -f "$ac_file"
+ mv "$ac_tmp/config.h" "$ac_file" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ fi
+ else
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+ || as_fn_error $? "could not create -" "$LINENO" 5
+ fi
+ ;;
+
+
+ esac
+
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
+
diff --git a/nbase/configure.ac b/nbase/configure.ac
new file mode 100644
index 0000000..37069da
--- /dev/null
+++ b/nbase/configure.ac
@@ -0,0 +1,301 @@
+dnl # -*- mode: fundamental; -*-
+dnl # Autoconf configuration file for Nbase
+dnl #
+dnl # Process this file with autoconf to produce a configure script.
+dnl # $Id$
+
+# Because nbase is usually distributed with Nmap, the necessary files
+# config.guess, config.guess, and install-sh are not distributed with
+# nbase. Rather they are gotten from Nmap.
+
+# Require autoconf 2.13
+AC_PREREQ(2.13)
+
+# Include my own macros
+m4_include([acinclude.m4])
+
+AC_INIT(nbase.h)
+
+AC_ARG_WITH(localdirs,
+ [ --with-localdirs Explicitly ask compiler to use /usr/local/{include,libs} if they exist ],
+ [ case "$with_localdirs" in
+ yes)
+ user_localdirs=1
+ ;;
+ no)
+ user_localdirs=0
+ ;;
+ esac
+ ],
+ [ user_localdirs=0 ] )
+
+if test "$user_localdirs" = 1; then
+ if test -d /usr/local/lib; then
+ LDFLAGS="$LDFLAGS -L/usr/local/lib"
+ fi
+ if test -d /usr/local/include; then
+ CPPFLAGS="$CPPFLAGS -I/usr/local/include"
+ fi
+fi
+
+dnl use config.h instad of -D macros
+AC_CONFIG_HEADER(nbase_config.h)
+
+dnl Checks for programs.
+AC_PROG_CC
+
+ if test -n "$GCC"; then
+ CFLAGS="$CFLAGS -Wall "
+ fi
+AC_PROG_RANLIB
+dnl AC_PROG_INSTALL
+dnl AC_PATH_PROG(MAKEDEPEND, makedepend)
+
+dnl Host specific hacks
+AC_CANONICAL_HOST
+
+dnl equiv to '#define inline' to 'inline', '__inline__', '__inline' or ''
+AC_C_INLINE
+
+case "$host" in
+ *-sgi-irix5* | *-sgi-irix6*)
+ if test -z "$GCC"; then
+ AC_DEFINE(inline, )
+ fi
+ ;;
+esac
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS( string.h getopt.h strings.h sys/param.h sys/time.h unistd.h errno.h sys/select.h sys/types.h sys/socket.h netinet/in.h arpa/inet.h sys/stat.h netdb.h sys/wait.h fcntl.h sys/resource.h inttypes.h mach-o/dyld.h)
+AC_HEADER_TIME
+dnl A special check required for <net/if.h> on Darwin. See
+dnl http://www.gnu.org/software/autoconf/manual/html_node/Header-Portability.html.
+AC_CHECK_HEADERS([sys/socket.h])
+AC_CHECK_HEADERS([net/if.h], [], [],
+[#include <stdio.h>
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+])
+
+AC_MSG_CHECKING(for __attribute__)
+AC_CACHE_VAL(ac_cv___attribute__, [
+ AC_TRY_COMPILE(
+ [
+ #include <stdlib.h>
+
+ static void foo(void) __attribute__ ((noreturn));
+
+ static void
+ foo(void)
+ {
+ exit(1);
+ }
+ ],
+ [
+ foo();
+ ],
+ ac_cv___attribute__=yes,
+ ac_cv___attribute__=no
+ )
+])
+if test "$ac_cv___attribute__" = "yes"; then
+ AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
+fi
+AC_MSG_RESULT($ac_cv___attribute__)
+
+AC_SUBST(CFLAGS)
+
+
+dnl This test is from the configure.in of Unix Network Programming second
+dnl edition example code by W. Richard Stevens
+dnl ##################################################################
+dnl Check if sockaddr{} has sa_len member.
+dnl
+AC_CACHE_CHECK(if sockaddr{} has sa_len member, ac_cv_sockaddr_has_sa_len,
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <sys/socket.h>],
+ [unsigned int i = sizeof(((struct sockaddr *)0)->sa_len)],
+ ac_cv_sockaddr_has_sa_len=yes,
+ ac_cv_sockaddr_has_sa_len=no))
+if test $ac_cv_sockaddr_has_sa_len = yes ; then
+ AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [define if sockaddr has sa_len member])
+fi
+
+dnl check endedness
+AC_C_BIGENDIAN
+
+dnl determine types so nbase can export u32, u16, etc.
+AC_TYPE_INT8_T
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+
+dnl Checks for library functions.
+AC_CHECK_FUNCS( snprintf vsnprintf nanosleep strerror strcasestr strcasecmp strncasecmp signal )
+
+needsnprintf=no
+AC_CHECK_FUNCS(vsnprintf snprintf asprintf asnprintf vasprintf vasnprintf,,
+ [needsnprintf=yes])
+if test $needsnprintf = yes; then
+ AC_LIBOBJ([snprintf])
+fi
+
+AC_CHECK_FUNCS( getopt getopt_long_only)
+
+AC_CHECK_FUNCS(usleep gettimeofday sleep localtime_s localtime_r)
+dnl Some of these time functions are always needed
+AC_LIBOBJ([nbase_time])
+
+AC_CHECK_FUNC(getopt_long_only, ,
+ [ AC_LIBOBJ([getopt]) ])
+
+AC_CHECK_FUNCS(strcasecmp strncasecmp, ,
+ [ AC_LIBOBJ([strcasecmp]) ])
+
+dnl We always want some of our files
+AC_LIBOBJ([nbase_str])
+AC_LIBOBJ([nbase_misc])
+AC_LIBOBJ([nbase_memalloc])
+AC_LIBOBJ([nbase_rnd])
+AC_LIBOBJ([nbase_addrset])
+
+# Check for IPv6 support -- modified from Apache 2.0.40:
+
+AC_ARG_ENABLE(ipv6,
+ [ --disable-ipv6 Disable IPv6 support ],
+ [ if test "$enableval" = "no"; then
+ user_disabled_ipv6=1
+ fi ],
+ [ user_disabled_ipv6=0 ] )
+
+AC_SEARCH_LIBS(getaddrinfo, [inet6 socket])
+AC_SEARCH_LIBS(gai_strerror, [inet6 socket])
+AC_SEARCH_LIBS(getnameinfo, [inet6 socket])
+AC_SEARCH_LIBS(inet_ntop, [nsl resolv network], [],
+ [AC_LIBOBJ(inet_ntop)
+ ])
+AC_SEARCH_LIBS(inet_pton, [nsl resolv network], [],
+ [AC_LIBOBJ(inet_pton)
+ ])
+AC_CHECK_FUNCS([gai_strerror inet_pton inet_ntop])
+APR_CHECK_WORKING_GETADDRINFO
+# The inet_addr function is used by APR_CHECK_WORKING_GETNAMEINFO.
+AC_SEARCH_LIBS(inet_addr, [nsl])
+APR_CHECK_WORKING_GETNAMEINFO
+APR_CHECK_SOCKADDR_IN6
+APR_CHECK_SOCKADDR_STORAGE
+CHECK_AF_INET6_DEFINE
+
+AC_MSG_CHECKING(for IPv6 support)
+have_ipv6="0"
+if test "$user_disabled_ipv6" = 1; then
+ AC_MSG_RESULT("no -- disabled by user")
+else
+ if test "x$have_sockaddr_in6" = "x1"; then
+ if test "x$ac_cv_working_getaddrinfo" = "xyes"; then
+ if test "x$ac_cv_working_getnameinfo" = "xyes"; then
+ have_ipv6="1"
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT("no -- no working getnameinfo")
+ fi
+ else
+ AC_MSG_RESULT("no -- no working getaddrinfo")
+ fi
+ else
+ AC_MSG_RESULT("no -- no sockaddr_in6");
+ fi
+fi
+
+if test "x$ac_cv_working_getaddrinfo" != "xyes"; then
+AC_LIBOBJ([getaddrinfo])
+fi
+
+if test "x$ac_cv_working_getnameinfo" != "xyes"; then
+AC_LIBOBJ([getnameinfo])
+fi
+
+if test "$have_ipv6" = "1"; then
+ AC_DEFINE(HAVE_IPV6, 1, [define if IPv6 is available])
+fi
+
+# First we test whether they specified openssl desires explicitly
+use_openssl="yes"
+specialssldir=""
+
+AC_ARG_WITH(openssl,
+[ --with-openssl=DIR Use optional openssl libs and includes from [DIR]/lib/
+and [DIR]/include/openssl/)],
+[ case "$with_openssl" in
+ yes)
+ ;;
+ no)
+ use_openssl="no"
+ ;;
+ *)
+ specialssldir="$with_openssl"
+ ;;
+ esac]
+)
+
+
+# If they didn't specify it, we try to find it
+if test "$use_openssl" = "yes" -a -z "$specialssldir"; then
+ AC_CHECK_HEADER(openssl/ssl.h,,
+ [ use_openssl="no"
+ AC_MSG_WARN([Failed to find openssl/ssl.h so OpenSSL will not be used. If it
+ is installed you can try the --with-openssl=DIR argument]) ])
+
+ if test "$use_openssl" = "yes"; then
+ AC_CHECK_HEADER(openssl/err.h,,
+ [ use_openssl="no"
+ AC_MSG_WARN([Failed to find openssl/err.h so OpenSSL will not be used. If it
+ is installed you can try the --with-openssl=DIR argument]) ])
+ fi
+
+ if test "$use_openssl" = "yes"; then
+ AC_CHECK_HEADER(openssl/rand.h,,
+ [ use_openssl="no"
+ AC_MSG_WARN([Failed to find openssl/rand.h so OpenSSL will not be used. If i
+t is installed you can try the --with-openssl=DIR argument]) ])
+ fi
+
+ if test "$use_openssl" = "yes"; then
+ AC_CHECK_LIB(crypto, BIO_int_ctrl,
+ [],
+ [ use_openssl="no"
+ AC_MSG_WARN([Failed to find libcrypto so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument]) ])
+ fi
+
+ if test "$use_openssl" = "yes"; then
+ AC_CHECK_LIB(ssl, SSL_new,
+ [],
+ [ use_openssl="no"
+ AC_MSG_WARN([Failed to find libssl so OpenSSL will not be used. If it is ins
+talled you can try the --with-openssl=DIR argument]) ])
+ fi
+fi
+
+if test "$use_openssl" = "yes"; then
+ AC_DEFINE(HAVE_OPENSSL, 1, [define if libssl is available])
+fi
+
+CHECK_PROC_SELF_EXE
+
+AC_OUTPUT(Makefile)
+
diff --git a/nbase/getaddrinfo.c b/nbase/getaddrinfo.c
new file mode 100644
index 0000000..63eecf2
--- /dev/null
+++ b/nbase/getaddrinfo.c
@@ -0,0 +1,191 @@
+/***************************************************************************
+ * getaddrinfo.c -- A **PARTIAL** implementation of the getaddrinfo(3) *
+ * hostname resolution call. In particular, IPv6 is not supported and *
+ * neither are some of the flags. Service "names" are always returned as *
+ * port numbers. *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#include "nbase.h"
+
+#include <stdio.h>
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#if HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#include <assert.h>
+
+
+#if !defined(HAVE_GAI_STRERROR) || defined(__MINGW32__)
+#ifdef __MINGW32__
+#undef gai_strerror
+#endif
+
+const char *gai_strerror(int errcode) {
+ static char customerr[64];
+ switch (errcode) {
+ case EAI_FAMILY:
+ return "ai_family not supported";
+ case EAI_NODATA:
+ return "no address associated with hostname";
+ case EAI_NONAME:
+ return "hostname nor servname provided, or not known";
+ default:
+ Snprintf(customerr, sizeof(customerr), "unknown error (%d)", errcode);
+ return "unknown error.";
+ }
+ return NULL; /* unreached */
+}
+#endif
+
+#ifdef __MINGW32__
+char* WSAAPI gai_strerrorA (int errcode)
+{
+ return gai_strerror(errcode);
+}
+#endif
+
+#ifndef HAVE_GETADDRINFO
+void freeaddrinfo(struct addrinfo *res) {
+ struct addrinfo *next;
+
+ do {
+ next = res->ai_next;
+ free(res);
+ } while ((res = next) != NULL);
+}
+
+/* Allocates and initializes a new AI structure with the port and IPv4
+ address specified in network byte order */
+static struct addrinfo *new_ai(unsigned short portno, u32 addr)
+{
+ struct addrinfo *ai;
+
+ ai = (struct addrinfo *) safe_malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
+
+ memset(ai, 0, sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
+
+ ai->ai_family = AF_INET;
+ ai->ai_addrlen = sizeof(struct sockaddr_in);
+ ai->ai_addr = (struct sockaddr *)(ai + 1);
+ ai->ai_addr->sa_family = AF_INET;
+#if HAVE_SOCKADDR_SA_LEN
+ ai->ai_addr->sa_len = ai->ai_addrlen;
+#endif
+ ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = portno;
+ ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr;
+
+ return(ai);
+}
+
+
+int getaddrinfo(const char *node, const char *service,
+ const struct addrinfo *hints, struct addrinfo **res) {
+
+ struct addrinfo *cur, *prev = NULL;
+ struct hostent *he;
+ struct in_addr ip;
+ unsigned short portno;
+ int i;
+
+ if (service)
+ portno = htons(atoi(service));
+ else
+ portno = 0;
+
+ if (hints && hints->ai_flags & AI_PASSIVE) {
+ *res = new_ai(portno, htonl(0x00000000));
+ return 0;
+ }
+
+ if (!node) {
+ *res = new_ai(portno, htonl(0x7f000001));
+ return 0;
+ }
+
+ if (inet_pton(AF_INET, node, &ip)) {
+ *res = new_ai(portno, ip.s_addr);
+ return 0;
+ }
+
+ he = gethostbyname(node);
+ if (he && he->h_addr_list[0]) {
+ for (i = 0; he->h_addr_list[i]; i++) {
+ cur = new_ai(portno, ((struct in_addr *)he->h_addr_list[i])->s_addr);
+
+ if (prev)
+ prev->ai_next = cur;
+ else
+ *res = cur;
+
+ prev = cur;
+ }
+ return 0;
+ }
+
+ return EAI_NODATA;
+}
+#endif /* HAVE_GETADDRINFO */
diff --git a/nbase/getnameinfo.c b/nbase/getnameinfo.c
new file mode 100644
index 0000000..5261db0
--- /dev/null
+++ b/nbase/getnameinfo.c
@@ -0,0 +1,116 @@
+/***************************************************************************
+ * getnameinfo.c -- A **PARTIAL** implementation of the getnameinfo(3) *
+ * host resolution call. In particular, IPv6 is not supported and neither *
+ * are some of the flags. Service "names" are always returned as decimal *
+ * port numbers. *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+#include "nbase.h"
+
+#if HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#include <assert.h>
+#include <stdio.h>
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+int getnameinfo(const struct sockaddr *sa, size_t salen,
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags) {
+
+ struct sockaddr_in *sin = (struct sockaddr_in *)sa;
+ struct hostent *he;
+
+ if (sin->sin_family != AF_INET || salen != sizeof(struct sockaddr_in))
+ return EAI_FAMILY;
+
+ if (serv != NULL) {
+ Snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
+ return 0;
+ }
+
+ if (host) {
+ if (flags & NI_NUMERICHOST) {
+ Strncpy(host, inet_ntoa(sin->sin_addr), hostlen);
+ return 0;
+ } else {
+ he = gethostbyaddr((char *)&sin->sin_addr, sizeof(struct in_addr),
+ AF_INET);
+ if (he == NULL) {
+ if (flags & NI_NAMEREQD)
+ return EAI_NONAME;
+
+ Strncpy(host, inet_ntoa(sin->sin_addr), hostlen);
+ return 0;
+ }
+
+ assert(he->h_name);
+ Strncpy(host, he->h_name, hostlen);
+ return 0;
+ }
+ }
+ return 0;
+}
diff --git a/nbase/getopt.c b/nbase/getopt.c
new file mode 100644
index 0000000..f9aad9f
--- /dev/null
+++ b/nbase/getopt.c
@@ -0,0 +1,304 @@
+/*
+ * my_getopt.c - my re-implementation of getopt.
+ * Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* $Id$ */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "getopt.h"
+
+#if HAVE_CONFIG_H
+#include "nbase_config.h"
+#else
+#ifdef WIN32
+#include "nbase_winconfig.h" /* mainly for _CRT_SECURE_NO_DEPRECATE */
+#endif /* WIN32 */
+#endif /* HAVE_CONFIG_H */
+
+int optind=1, opterr=1, optopt=0;
+char *optarg=0;
+
+/* reset argument parser to start-up values */
+int getopt_reset(void)
+{
+ optind = 1;
+ opterr = 1;
+ optopt = 0;
+ optarg = 0;
+ return 0;
+}
+
+
+/* this is the plain old UNIX getopt, with GNU-style extensions. */
+/* if you're porting some piece of UNIX software, this is all you need. */
+/* this supports GNU-style permutation and optional arguments */
+
+static int _getopt(int argc, char * argv[], const char *opts)
+{
+ static int charind=0;
+ const char *s;
+ char mode, colon_mode;
+ int off = 0, opt = -1;
+
+ if(getenv("POSIXLY_CORRECT")) colon_mode = mode = '+';
+ else {
+ if((colon_mode = *opts) == ':') off ++;
+ if(((mode = opts[off]) == '+') || (mode == '-')) {
+ off++;
+ if((colon_mode != ':') && ((colon_mode = opts[off]) == ':'))
+ off ++;
+ }
+ }
+ optarg = 0;
+ if(charind) {
+ optopt = argv[optind][charind];
+ for(s=opts+off; *s; s++) if(optopt == *s) {
+ charind++;
+ if((*(++s) == ':') || ((optopt == 'W') && (*s == ';'))) {
+ if(argv[optind][charind]) {
+ optarg = &(argv[optind++][charind]);
+ charind = 0;
+ } else if(*(++s) != ':') {
+ charind = 0;
+ if(++optind >= argc) {
+ if(opterr) fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ argv[0], optopt);
+ opt = (colon_mode == ':') ? ':' : '?';
+ goto my_getopt_ok;
+ }
+ optarg = argv[optind++];
+ }
+ }
+ opt = optopt;
+ goto my_getopt_ok;
+ }
+ if(opterr) fprintf(stderr,
+ "%s: illegal option -- %c\n",
+ argv[0], optopt);
+ opt = '?';
+ if(argv[optind][++charind] == '\0') {
+ optind++;
+ charind = 0;
+ }
+ my_getopt_ok:
+ if(charind && ! argv[optind][charind]) {
+ optind++;
+ charind = 0;
+ }
+ } else if((optind >= argc) ||
+ ((argv[optind][0] == '-') &&
+ (argv[optind][1] == '-') &&
+ (argv[optind][2] == '\0'))) {
+ optind++;
+ opt = -1;
+ } else if((argv[optind][0] != '-') ||
+ (argv[optind][1] == '\0')) {
+ char *tmp;
+ int i, j, k;
+
+ if(mode == '+') opt = -1;
+ else if(mode == '-') {
+ optarg = argv[optind++];
+ charind = 0;
+ opt = 1;
+ } else {
+ for(i=j=optind; i<argc; i++) if((argv[i][0] == '-') &&
+ (argv[i][1] != '\0')) {
+ optind=i;
+ opt=_getopt(argc, argv, opts);
+ while(i > j) {
+ tmp=argv[--i];
+ for(k=i; k+1<optind; k++) argv[k]=argv[k+1];
+ argv[--optind]=tmp;
+ }
+ break;
+ }
+ if(i == argc) opt = -1;
+ }
+ } else {
+ charind++;
+ opt = _getopt(argc, argv, opts);
+ }
+ if (optind > argc) optind = argc;
+ return opt;
+}
+
+/* this is the extended getopt_long{,_only}, with some GNU-like
+ * extensions. Implements _getopt_internal in case any programs
+ * expecting GNU libc getopt call it.
+ */
+
+int _getopt_internal(int argc, char * argv[], const char *shortopts,
+ const struct option *longopts, int *longind,
+ int long_only)
+{
+ char mode, colon_mode = *shortopts;
+ int shortoff = 0, opt = -1;
+
+ if(getenv("POSIXLY_CORRECT")) colon_mode = mode = '+';
+ else {
+ if((colon_mode = *shortopts) == ':') shortoff ++;
+ if(((mode = shortopts[shortoff]) == '+') || (mode == '-')) {
+ shortoff++;
+ if((colon_mode != ':') && ((colon_mode = shortopts[shortoff]) == ':'))
+ shortoff ++;
+ }
+ }
+ optarg = 0;
+ if((optind >= argc) ||
+ ((argv[optind][0] == '-') &&
+ (argv[optind][1] == '-') &&
+ (argv[optind][2] == '\0'))) {
+ optind++;
+ opt = -1;
+ } else if((argv[optind][0] != '-') ||
+ (argv[optind][1] == '\0')) {
+ char *tmp;
+ int i, j, k;
+
+ opt = -1;
+ if(mode == '+') return -1;
+ else if(mode == '-') {
+ optarg = argv[optind++];
+ return 1;
+ }
+ for(i=j=optind; i<argc; i++) if((argv[i][0] == '-') &&
+ (argv[i][1] != '\0')) {
+ optind=i;
+ opt=_getopt_internal(argc, argv, shortopts,
+ longopts, longind,
+ long_only);
+ while(i > j) {
+ tmp=argv[--i];
+ for(k=i; k+1<optind; k++)
+ argv[k]=argv[k+1];
+ argv[--optind]=tmp;
+ }
+ break;
+ }
+ } else if((!long_only) && (argv[optind][1] != '-'))
+ opt = _getopt(argc, argv, shortopts);
+ else {
+ int charind, offset;
+ int found = 0, ind, hits = 0;
+
+ if(((optopt = argv[optind][1]) != '-') && ! argv[optind][2]) {
+ int c;
+
+ ind = shortoff;
+ while((c = shortopts[ind++])) {
+ if(((shortopts[ind] == ':') ||
+ ((c == 'W') && (shortopts[ind] == ';'))) &&
+ (shortopts[++ind] == ':'))
+ ind ++;
+ if(optopt == c) return _getopt(argc, argv, shortopts);
+ }
+ }
+ offset = 2 - (argv[optind][1] != '-');
+ for(charind = offset;
+ (argv[optind][charind] != '\0') &&
+ (argv[optind][charind] != '=');
+ charind++);
+ for(ind = 0; longopts[ind].name && !hits; ind++)
+ if((strlen(longopts[ind].name) == (size_t) (charind - offset)) &&
+ (strncmp(longopts[ind].name,
+ argv[optind] + offset, charind - offset) == 0))
+ found = ind, hits++;
+ if(!hits) for(ind = 0; longopts[ind].name; ind++)
+ if(strncmp(longopts[ind].name,
+ argv[optind] + offset, charind - offset) == 0)
+ found = ind, hits++;
+ if(hits == 1) {
+ opt = 0;
+
+ if(argv[optind][charind] == '=') {
+ if(longopts[found].has_arg == 0) {
+ opt = '?';
+ if(opterr) fprintf(stderr,
+ "%s: option `--%s' doesn't allow an argument\n",
+ argv[0], longopts[found].name);
+ } else {
+ optarg = argv[optind] + ++charind;
+ charind = 0;
+ }
+ } else if(longopts[found].has_arg == 1) {
+ if(++optind >= argc) {
+ opt = (colon_mode == ':') ? ':' : '?';
+ if(opterr) fprintf(stderr,
+ "%s: option `--%s' requires an argument\n",
+ argv[0], longopts[found].name);
+ } else optarg = argv[optind];
+ }
+ if(!opt) {
+ if (longind) *longind = found;
+ if(!longopts[found].flag) opt = longopts[found].val;
+ else *(longopts[found].flag) = longopts[found].val;
+ }
+ optind++;
+ } else if(!hits) {
+ if(offset == 1) opt = _getopt(argc, argv, shortopts);
+ else {
+ opt = '?';
+ if(opterr) fprintf(stderr,
+ "%s: unrecognized option `%s'\n",
+ argv[0], argv[optind++]);
+ }
+ } else {
+ opt = '?';
+ if(opterr) fprintf(stderr,
+ "%s: option `%s' is ambiguous\n",
+ argv[0], argv[optind++]);
+ }
+ }
+ if (optind > argc) optind = argc;
+ return opt;
+}
+
+/* This function is kinda problematic because most getopt() nowadays
+ seem to use char * const argv[] (they DON'T permute the options list),
+ but this one does. So we remove it as long as HAVE_GETOPT is define, so
+ people can use the version from their platform instead */
+
+#ifndef HAVE_GETOPT
+int getopt(int argc, char * argv[], const char *opts)
+{
+ return _getopt(argc, argv, opts);
+}
+#endif /* HAVE_GETOPT */
+
+int getopt_long(int argc, char * argv[], const char *shortopts,
+ const struct option *longopts, int *longind)
+{
+ return _getopt_internal(argc, argv, shortopts, longopts, longind, 0);
+}
+
+int getopt_long_only(int argc, char * argv[], const char *shortopts,
+ const struct option *longopts, int *longind)
+{
+ return _getopt_internal(argc, argv, shortopts, longopts, longind, 1);
+}
diff --git a/nbase/getopt.h b/nbase/getopt.h
new file mode 100644
index 0000000..72496ec
--- /dev/null
+++ b/nbase/getopt.h
@@ -0,0 +1,84 @@
+/*
+ * my_getopt.h - interface to my re-implementation of getopt.
+ * Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* $Id$ */
+
+#ifndef MY_GETOPT_H_INCLUDED
+#define MY_GETOPT_H_INCLUDED
+
+#if HAVE_CONFIG_H
+#include "nbase_config.h"
+#else
+#ifdef WIN32
+#include "nbase_winconfig.h"
+#endif /* WIN32 */
+#endif /* HAVE_CONFIG_H */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* reset argument parser to start-up values */
+extern int getopt_reset(void);
+
+#ifndef HAVE_GETOPT
+/* UNIX-style short-argument parser */
+extern int getopt(int argc, char * argv[], const char *opts);
+#endif /* HAVE_GETOPT */
+
+extern int optind, opterr, optopt;
+extern char *optarg;
+
+struct option {
+ const char *name;
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* human-readable values for has_arg */
+#undef no_argument
+#define no_argument 0
+#undef required_argument
+#define required_argument 1
+#undef optional_argument
+#define optional_argument 2
+
+/* GNU-style long-argument parsers */
+extern int getopt_long(int argc, char * argv[], const char *shortopts,
+ const struct option *longopts, int *longind);
+
+extern int getopt_long_only(int argc, char * argv[], const char *shortopts,
+ const struct option *longopts, int *longind);
+
+extern int _getopt_internal(int argc, char * argv[], const char *shortopts,
+ const struct option *longopts, int *longind,
+ int long_only);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MY_GETOPT_H_INCLUDED */
diff --git a/nbase/inet_ntop.c b/nbase/inet_ntop.c
new file mode 100644
index 0000000..da25623
--- /dev/null
+++ b/nbase/inet_ntop.c
@@ -0,0 +1,255 @@
+/* Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* Modified by Fyodor (fyodor@nmap.org) for inclusion in the Nmap
+ * Security Scanner.
+ *
+ * $Id$
+ */
+
+#include "nbase.h"
+
+#ifndef HAVE_INET_NTOP
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#include <string.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <stdio.h>
+
+#ifndef IN6ADDRSZ
+#define IN6ADDRSZ 16
+#endif
+
+#ifndef INT16SZ
+#define INT16SZ sizeof(u16)
+#endif
+
+#if !defined(EAFNOSUPPORT) && defined(WSAEAFNOSUPPORT)
+#define EAFNOSUPPORT WSAEAFNOSUPPORT
+#endif
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static const char *inet_ntop4(const unsigned char *src, char *dst, size_t size);
+#if HAVE_IPV6
+static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size);
+#endif
+
+/* char *
+ * inet_ntop(af, src, dst, size)
+ * convert a network format address to presentation format.
+ * return:
+ * pointer to presentation format address (`dst'), or NULL (see errno).
+ * author:
+ * Paul Vixie, 1996.
+ */
+const char *
+inet_ntop(int af, const void *src, char *dst, size_t size)
+{
+ switch (af) {
+ case AF_INET:
+ return (inet_ntop4((const unsigned char *) src, dst, size));
+#if HAVE_IPV6
+ case AF_INET6:
+ return (inet_ntop6((const unsigned char *) src, dst, size));
+#endif
+ default:
+#ifndef WIN32
+ errno = EAFNOSUPPORT;
+#endif
+ return (NULL);
+ }
+ /* NOTREACHED */
+}
+
+/* const char *
+ * inet_ntop4(src, dst, size)
+ * format an IPv4 address, more or less like inet_ntoa()
+ * return:
+ * `dst' (as a const)
+ * notes:
+ * (1) uses no statics
+ * (2) takes a u_char* not an in_addr as input
+ * author:
+ * Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop4(const unsigned char *src, char *dst, size_t size)
+{
+ const size_t MIN_SIZE = 16; /* space for 255.255.255.255\0 */
+ int n = 0;
+ char *next = dst;
+
+ if (size < MIN_SIZE) {
+#ifndef WIN32
+ errno = ENOSPC;
+#endif
+ return NULL;
+ }
+ do {
+ unsigned char u = *src++;
+ if (u > 99) {
+ *next++ = '0' + u/100;
+ u %= 100;
+ *next++ = '0' + u/10;
+ u %= 10;
+ }
+ else if (u > 9) {
+ *next++ = '0' + u/10;
+ u %= 10;
+ }
+ *next++ = '0' + u;
+ *next++ = '.';
+ n++;
+ } while (n < 4);
+ *--next = 0;
+ return dst;
+}
+
+#if HAVE_IPV6
+/* const char *
+ * inet_ntop6(src, dst, size)
+ * convert IPv6 binary address into presentation (printable) format
+ * author:
+ * Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop6(const unsigned char *src, char *dst, size_t size)
+{
+ /*
+ * Note that int32_t and int16_t need only be "at least" large enough
+ * to contain a value of the specified size. On some systems, like
+ * Crays, there is no such thing as an integer variable with 16 bits.
+ * Keep this in mind if you think this function should have been coded
+ * to use pointer overlays. All the world's not a VAX.
+ */
+ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
+ struct { int base, len; } best, cur;
+ u16 words[IN6ADDRSZ / INT16SZ];
+ int i;
+ const unsigned char *next_src, *src_end;
+ u16 *next_dest;
+
+ /*
+ * Preprocess:
+ * Copy the input (bytewise) array into a wordwise array.
+ * Find the longest run of 0x00's in src[] for :: shorthanding.
+ */
+ next_src = src;
+ src_end = src + IN6ADDRSZ;
+ next_dest = words;
+ best.base = -1;
+ cur.base = -1;
+ i = 0;
+ do {
+ unsigned int next_word = (unsigned int)*next_src++;
+ next_word <<= 8;
+ next_word |= (unsigned int)*next_src++;
+ *next_dest++ = next_word;
+
+ if (next_word == 0) {
+ if (cur.base == -1) {
+ cur.base = i;
+ cur.len = 1;
+ }
+ else {
+ cur.len++;
+ }
+ } else {
+ if (cur.base != -1) {
+ if (best.base == -1 || cur.len > best.len) {
+ best = cur;
+ }
+ cur.base = -1;
+ }
+ }
+
+ i++;
+ } while (next_src < src_end);
+
+ if (cur.base != -1) {
+ if (best.base == -1 || cur.len > best.len) {
+ best = cur;
+ }
+ }
+ if (best.base != -1 && best.len < 2) {
+ best.base = -1;
+ }
+
+ /*
+ * Format the result.
+ */
+ tp = tmp;
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ);) {
+ /* Are we inside the best run of 0x00's? */
+ if (i == best.base) {
+ *tp++ = ':';
+ i += best.len;
+ continue;
+ }
+ /* Are we following an initial run of 0x00s or any real hex? */
+ if (i != 0) {
+ *tp++ = ':';
+ }
+ /* Is this address an encapsulated IPv4? */
+ if (i == 6 && best.base == 0 &&
+ (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+ if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) {
+ return (NULL);
+ }
+ tp += strlen(tp);
+ break;
+ }
+ tp += Snprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]);
+ i++;
+ }
+ /* Was it a trailing run of 0x00's? */
+ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) {
+ *tp++ = ':';
+ }
+ *tp++ = '\0';
+
+ /*
+ * Check for overflow, copy, and we're done.
+ */
+ if ((size_t)(tp - tmp) > size) {
+#ifndef WIN32
+ errno = ENOSPC;
+#endif
+ return (NULL);
+ }
+ strncpy(dst, tmp, size);
+ return (dst);
+}
+#endif
+
+#endif /* ifndef HAVE_INET_NTOP */
diff --git a/nbase/inet_pton.c b/nbase/inet_pton.c
new file mode 100644
index 0000000..cef18cf
--- /dev/null
+++ b/nbase/inet_pton.c
@@ -0,0 +1,249 @@
+/* Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* Modified by Fyodor (fyodor@nmap.org) for inclusion in the Nmap
+ * Security Scanner.
+ *
+ * $Id$
+ */
+
+#include "nbase.h"
+
+#ifndef HAVE_INET_PTON
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#ifndef IN6ADDRSZ
+#define IN6ADDRSZ 16
+#endif
+
+#ifndef INT16SZ
+#define INT16SZ 2
+#endif
+
+#ifndef INADDRSZ
+#define INADDRSZ 4
+#endif
+
+#if !defined(EAFNOSUPPORT) && defined(WSAEAFNOSUPPORT)
+#define EAFNOSUPPORT WSAEAFNOSUPPORT
+#endif
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static int inet_pton4 (const char *src, unsigned char *dst);
+#if HAVE_IPV6
+static int inet_pton6 (const char *src, unsigned char *dst);
+#endif
+
+/* int
+ * inet_pton(af, src, dst)
+ * convert from presentation format (which usually means ASCII printable)
+ * to network format (which is usually some kind of binary format).
+ * return:
+ * 1 if the address was valid for the specified address family
+ * 0 if the address wasn't valid (`dst' is untouched in this case)
+ * -1 if some other error occurred (`dst' is untouched in this case, too)
+ * author:
+ * Paul Vixie, 1996.
+ */
+int
+inet_pton(int af, const char *src, void *dst)
+{
+ switch (af) {
+ case AF_INET:
+ return (inet_pton4(src, (unsigned char *) dst));
+#if HAVE_IPV6
+ case AF_INET6:
+ return (inet_pton6(src, (unsigned char *) dst));
+#endif
+ default:
+#ifndef WIN32
+ errno = EAFNOSUPPORT;
+#endif
+ return (-1);
+ }
+ /* NOTREACHED */
+}
+
+/* int
+ * inet_pton4(src, dst)
+ * like inet_aton() but without all the hexadecimal and shorthand.
+ * return:
+ * 1 if `src' is a valid dotted quad, else 0.
+ * notice:
+ * does not touch `dst' unless it's returning 1.
+ * author:
+ * Paul Vixie, 1996.
+ */
+static int
+inet_pton4(const char *src, unsigned char *dst)
+{
+ static const char digits[] = "0123456789";
+ int saw_digit, octets, ch;
+ unsigned char tmp[INADDRSZ], *tp;
+
+ saw_digit = 0;
+ octets = 0;
+ *(tp = tmp) = 0;
+ while ((ch = *src++) != '\0') {
+ const char *pch;
+
+ if ((pch = strchr(digits, ch)) != NULL) {
+ unsigned int newval = (unsigned int) (*tp * 10 + (pch - digits));
+
+ if (newval > 255)
+ return (0);
+ *tp = newval;
+ if (! saw_digit) {
+ if (++octets > 4)
+ return (0);
+ saw_digit = 1;
+ }
+ } else if (ch == '.' && saw_digit) {
+ if (octets == 4)
+ return (0);
+ *++tp = 0;
+ saw_digit = 0;
+ } else
+ return (0);
+ }
+ if (octets < 4)
+ return (0);
+
+ memcpy(dst, tmp, INADDRSZ);
+ return (1);
+}
+
+#if HAVE_IPV6
+/* int
+ * inet_pton6(src, dst)
+ * convert presentation level address to network order binary form.
+ * return:
+ * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * notice:
+ * (1) does not touch `dst' unless it's returning 1.
+ * (2) :: in a full address is silently ignored.
+ * credit:
+ * inspired by Mark Andrews.
+ * author:
+ * Paul Vixie, 1996.
+ */
+static int
+inet_pton6(const char *src, unsigned char *dst)
+{
+ static const char xdigits_l[] = "0123456789abcdef",
+ xdigits_u[] = "0123456789ABCDEF";
+ unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
+ const char *xdigits, *curtok;
+ int ch, saw_xdigit;
+ unsigned int val;
+
+ memset((tp = tmp), '\0', IN6ADDRSZ);
+ endp = tp + IN6ADDRSZ;
+ colonp = NULL;
+ /* Leading :: requires some special handling. */
+ if (*src == ':')
+ if (*++src != ':')
+ return (0);
+ curtok = src;
+ saw_xdigit = 0;
+ val = 0;
+ while ((ch = *src++) != '\0') {
+ const char *pch;
+
+ if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
+ pch = strchr((xdigits = xdigits_u), ch);
+ if (pch != NULL) {
+ val <<= 4;
+ val |= (pch - xdigits);
+ if (val > 0xffff)
+ return (0);
+ saw_xdigit = 1;
+ continue;
+ }
+ if (ch == ':') {
+ curtok = src;
+ if (!saw_xdigit) {
+ if (colonp)
+ return (0);
+ colonp = tp;
+ continue;
+ }
+ if (tp + INT16SZ > endp)
+ return (0);
+ *tp++ = (unsigned char) (val >> 8) & 0xff;
+ *tp++ = (unsigned char) val & 0xff;
+ saw_xdigit = 0;
+ val = 0;
+ continue;
+ }
+ if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
+ inet_pton4(curtok, tp) > 0) {
+ tp += INADDRSZ;
+ saw_xdigit = 0;
+ break; /* '\0' was seen by inet_pton4(). */
+ }
+ return (0);
+ }
+ if (saw_xdigit) {
+ if (tp + INT16SZ > endp)
+ return (0);
+ *tp++ = (unsigned char) (val >> 8) & 0xff;
+ *tp++ = (unsigned char) val & 0xff;
+ }
+ if (colonp != NULL) {
+ /*
+ * Since some memmove()'s erroneously fail to handle
+ * overlapping regions, we'll do the shift by hand.
+ */
+ const int n = tp - colonp;
+ int i;
+
+ for (i = 1; i <= n; i++) {
+ endp[- i] = colonp[n - i];
+ colonp[n - i] = 0;
+ }
+ tp = endp;
+ }
+ if (tp != endp)
+ return (0);
+ memcpy(dst, tmp, IN6ADDRSZ);
+ return (1);
+}
+#endif
+
+#endif /* ifndef HAVE_INET_PTON */
diff --git a/nbase/nbase.h b/nbase/nbase.h
new file mode 100644
index 0000000..b1eab82
--- /dev/null
+++ b/nbase/nbase.h
@@ -0,0 +1,528 @@
+
+/***************************************************************************
+ * nbase.h -- The main include file exposing the external API for *
+ * libnbase, a library of base (often compatibility) routines. Programs *
+ * using libnbase can guarantee the availability of functions like *
+ * (v)snprintf and inet_pton. This library also provides consistency and *
+ * extended features for some functions. It was originally written for *
+ * use in the Nmap Security Scanner ( https://nmap.org ). *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#ifndef NBASE_H
+#define NBASE_H
+
+/* NOTE -- libnbase offers the following features that you should probably
+ * be aware of:
+ *
+ * * 'inline' is defined to what is necessary for the C compiler being
+ * used (which may be nothing)
+ *
+ * * snprintf, inet_pton, memcpy, and bzero are
+ * provided if you don't have them (prototypes for these are
+ * included either way).
+ *
+ * * WORDS_BIGENDIAN is defined if platform is big endian
+ *
+ * * Definitions included which give the operating system type. They
+ * will generally be one of the following: LINUX, FREEBSD, NETBSD,
+ * OPENBSD, SOLARIS, SUNOS, BSDI, IRIX, NETBSD
+ *
+ * * Insures that getopt_* functions exist (such as getopt_long_only)
+ *
+ * * Various string functions such as Strncpy() and strcasestr() see protos
+ * for more info.
+ *
+ * * IPv6 structures like 'sockaddr_storage' are provided if they do
+ * not already exist.
+ *
+ * * Various Windows -> UNIX compatibility definitions are added (such as defining EMSGSIZE to WSAEMSGSIZE)
+ */
+
+#if HAVE_CONFIG_H
+#include "nbase_config.h"
+#else
+#ifdef WIN32
+#include "nbase_winconfig.h"
+#endif /* WIN32 */
+#endif /* HAVE_CONFIG_H */
+
+#ifdef WIN32
+#include "nbase_winunix.h"
+#endif
+
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <time.h>
+
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
+#if HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#if HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+#include <stdio.h>
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 64
+#endif
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 2048
+#endif
+
+#ifndef HAVE___ATTRIBUTE__
+#define __attribute__(args)
+#endif
+
+#include <stdarg.h>
+
+/* Keep assert() defined for security reasons */
+#undef NDEBUG
+
+/* Integer types */
+#include <stdint.h>
+typedef uint8_t u8;
+typedef int8_t s8;
+typedef uint16_t u16;
+typedef int16_t s16;
+typedef uint32_t u32;
+typedef int32_t s32;
+typedef uint64_t u64;
+typedef int64_t s64;
+
+/* Mathematical MIN/MAX/ABS (absolute value) macros */
+#ifndef MAX
+#define MAX(x,y) (((x)>(y))?(x):(y))
+#endif
+#ifndef MIN
+#define MIN(x,y) (((x)<(y))?(x):(y))
+#endif
+#ifndef ABS
+#define ABS(x) (((x) >= 0)?(x):-(x))
+#endif
+
+/* Timeval subtraction in microseconds */
+#define TIMEVAL_SUBTRACT(a,b) (((a).tv_sec - (b).tv_sec) * 1000000 + (a).tv_usec - (b).tv_usec)
+/* Timeval subtract in milliseconds */
+#define TIMEVAL_MSEC_SUBTRACT(a,b) ((((a).tv_sec - (b).tv_sec) * 1000) + ((a).tv_usec - (b).tv_usec) / 1000)
+/* Timeval subtract in seconds; truncate towards zero */
+#define TIMEVAL_SEC_SUBTRACT(a,b) ((a).tv_sec - (b).tv_sec + (((a).tv_usec < (b).tv_usec) ? - 1 : 0))
+/* Timeval subtract in fractional seconds; convert to float */
+#define TIMEVAL_FSEC_SUBTRACT(a,b) ((a).tv_sec - (b).tv_sec + (((a).tv_usec - (b).tv_usec)/1000000.0))
+
+/* assign one timeval to another timeval plus some msecs: a = b + msecs */
+#define TIMEVAL_MSEC_ADD(a, b, msecs) { (a).tv_sec = (b).tv_sec + ((msecs) / 1000); (a).tv_usec = (b).tv_usec + ((msecs) % 1000) * 1000; (a).tv_sec += (a).tv_usec / 1000000; (a).tv_usec %= 1000000; }
+#define TIMEVAL_ADD(a, b, usecs) { (a).tv_sec = (b).tv_sec + ((usecs) / 1000000); (a).tv_usec = (b).tv_usec + ((usecs) % 1000000); (a).tv_sec += (a).tv_usec / 1000000; (a).tv_usec %= 1000000; }
+
+/* Find our if one timeval is before or after another, avoiding the integer
+ overflow that can result when doing a TIMEVAL_SUBTRACT on two widely spaced
+ timevals. */
+#define TIMEVAL_BEFORE(a, b) (((a).tv_sec < (b).tv_sec) || ((a).tv_sec == (b).tv_sec && (a).tv_usec < (b).tv_usec))
+#define TIMEVAL_AFTER(a, b) (((a).tv_sec > (b).tv_sec) || ((a).tv_sec == (b).tv_sec && (a).tv_usec > (b).tv_usec))
+
+/* Convert a timeval to floating point seconds */
+#define TIMEVAL_SECS(a) ((double) (a).tv_sec + (double) (a).tv_usec / 1000000)
+
+
+/* sprintf family */
+#if !defined(HAVE_SNPRINTF) && defined(__cplusplus)
+extern "C" int snprintf (char *str, size_t sz, const char *format, ...)
+ __attribute__ ((format (printf, 3, 4)));
+#endif
+
+#if !defined(HAVE_VSNPRINTF) && defined(__cplusplus)
+extern "C" int vsnprintf (char *str, size_t sz, const char *format,
+ va_list ap)
+ __attribute__((format (printf, 3, 0)));
+#endif
+
+#if !defined(HAVE_ASPRINTF) && defined(__cplusplus)
+extern "C" int asprintf (char **ret, const char *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
+#endif
+
+#if !defined(HAVE_VASPRINTF) && defined(__cplusplus)
+extern "C" int vasprintf (char **ret, const char *format, va_list ap)
+ __attribute__((format (printf, 2, 0)));
+#endif
+
+#if !defined(HAVE_ASNPRINTF) && defined(__cplusplus)
+extern "C" int asnprintf (char **ret, size_t max_sz, const char *format, ...)
+ __attribute__ ((format (printf, 3, 4)));
+#endif
+
+#if !defined(HAVE_VASNPRINTF) && defined(__cplusplus)
+extern "C" int vasnprintf (char **ret, size_t max_sz, const char *format,
+ va_list ap)
+ __attribute__((format (printf, 3, 0)));
+#endif
+
+#if defined(NEED_SNPRINTF_PROTO) && defined(__cplusplus)
+extern "C" int snprintf (char *, size_t, const char *, ...);
+#endif
+
+#if defined(NEED_VSNPRINTF_PROTO) && defined(__cplusplus)
+extern "C" int vsnprintf (char *, size_t, const char *, va_list);
+#endif
+
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#ifndef HAVE_GETOPT_LONG_ONLY
+#include "getopt.h"
+#endif
+#endif /* HAVE_GETOPT_H */
+
+/* More Windows-specific stuff */
+#ifdef WIN32
+
+#define WIN32_LEAN_AND_MEAN /* Whatever this means! From winclude.h*/
+
+/* Apparently Windows doesn't have S_ISDIR */
+#ifndef S_ISDIR
+#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
+#endif
+
+/* Windows doesn't have the access() defines */
+#ifndef F_OK
+#define F_OK 00
+#endif
+#ifndef W_OK
+#define W_OK 02
+#endif
+#ifndef R_OK
+#define R_OK 04
+#endif
+
+/* wtf was ms thinking? */
+#define access _access
+#define stat _stat
+#define execve _execve
+#define getpid _getpid
+#define dup _dup
+#define dup2 _dup2
+#define strdup _strdup
+#define write _write
+#define open _open
+#define stricmp _stricmp
+#define putenv _putenv
+#define tzset _tzset
+
+#if defined(_MSC_VER) && _MSC_VER < 1900
+#define snprintf _snprintf
+#endif
+
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define execv _execv
+
+#endif /* WIN32 */
+
+/* Apparently Windows doesn't like /dev/null */
+#ifdef WIN32
+#define DEVNULL "NUL"
+#else
+#define DEVNULL "/dev/null"
+#endif
+
+#if defined(_MSC_VER) && !defined(__cplusplus) && !defined(inline)
+#define inline __inline
+#endif
+
+#if defined(__GNUC__)
+#define NORETURN __attribute__((noreturn))
+#elif defined(_MSC_VER)
+#define NORETURN __declspec(noreturn)
+#else
+#define NORETURN
+#endif
+
+#ifndef WIN32
+# define CHECK_FD_OP(_Op, _Ctx) \
+ if (fd >= FD_SETSIZE) { \
+ fprintf(stderr, "Attempt to " #_Op " fd %d, which is not less than " \
+ "FD_SETSIZE (%d). Try using a lower parallelism.", \
+ fd, FD_SETSIZE); \
+ abort(); \
+ } \
+ _Ctx _Op(fd, fds);
+#else
+# define CHECK_FD_OP(_Op, _Ctx) _Ctx _Op(fd, fds);
+#endif
+
+static inline int checked_fd_isset(int fd, fd_set *fds) {
+ CHECK_FD_OP(FD_ISSET, return);
+}
+
+static inline void checked_fd_clr(int fd, fd_set *fds) {
+ CHECK_FD_OP(FD_CLR, /**/);
+}
+
+static inline void checked_fd_set(int fd, fd_set *fds) {
+#ifdef WIN32
+ if (fds->fd_count >= FD_SETSIZE) {
+ fprintf(stderr, "Attempt to call FD_SET, but fd_count is %d, which is not less than "
+ "FD_SETSIZE (%d). Try using a lower parallelism.",
+ fds->fd_count, FD_SETSIZE);
+ abort();
+ }
+#endif
+ CHECK_FD_OP(FD_SET, /**/);
+}
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Returns the UNIX/Windows errno-equivalent. Note that the Windows
+ call is socket/networking specific. Also, WINDOWS TENDS TO RESET
+ THE ERROR, so it will return success the next time. So SAVE THE
+ RESULTS and re-use them, don't keep calling socket_errno(). The
+ windows error number returned is like WSAMSGSIZE, but nbase.h
+ includes #defines to correlate many of the common UNIX errors
+ with their closest Windows equivalents. So you can use EMSGSIZE
+ or EINTR. */
+int socket_errno();
+
+/* We can't just use strerror to get socket errors on Windows because it has
+ its own set of error codes: WSACONNRESET not ECONNRESET for example. This
+ function will do the right thing on Windows. Call it like
+ socket_strerror(socket_errno())
+*/
+char *socket_strerror(int errnum);
+
+/* The usleep() function is important as well */
+#ifndef HAVE_USLEEP
+#if defined( HAVE_NANOSLEEP) || defined(WIN32)
+void usleep(unsigned long usec);
+#endif
+#endif
+
+/* localtime is not thread safe. This will use a thread safe alternative on
+ * supported platforms. */
+int n_localtime(const time_t *timer, struct tm *result);
+int n_gmtime(const time_t *timer, struct tm *result);
+int n_ctime(char *buffer, size_t bufsz, const time_t *timer);
+
+/***************** String functions -- See nbase_str.c ******************/
+/* I modified this conditional because !@# Redhat does not easily provide
+ the prototype even though the function exists */
+#if !defined(HAVE_STRCASESTR) || (defined(LINUX) && !defined(__USE_GNU) && !defined(_GNU_SOURCE))
+/* strcasestr is like strstr() except case insensitive */
+char *strcasestr(const char *haystack, const char *pneedle);
+#endif
+
+#ifndef HAVE_STRCASECMP
+int strcasecmp(const char *s1, const char *s2);
+#endif
+
+#ifndef HAVE_STRNCASECMP
+int strncasecmp(const char *s1, const char *s2, size_t n);
+#endif
+
+#ifndef HAVE_GETTIMEOFDAY
+int gettimeofday(struct timeval *tv, struct timeval *tz);
+#endif
+
+#ifndef HAVE_SLEEP
+unsigned int sleep(unsigned int seconds);
+#endif
+
+/* Strncpy is like strcpy() except it ALWAYS zero-terminates, even if
+ it must truncate */
+int Strncpy(char *dest, const char *src, size_t n);
+
+int Vsnprintf(char *, size_t, const char *, va_list)
+ __attribute__ ((format (printf, 3, 0)));
+int Snprintf(char *, size_t, const char *, ...)
+ __attribute__ ((format (printf, 3, 4)));
+
+char *mkstr(const char *start, const char *end);
+/* Like strchr, but don't go past end. Nulls not handled specially. */
+const char *strchr_p(const char *str, const char *end, char c);
+
+int alloc_vsprintf(char **strp, const char *fmt, va_list va)
+ __attribute__ ((format (printf, 2, 0)));
+
+char *escape_windows_command_arg(const char *arg);
+
+/* parse_long is like strtol or atoi, but it allows digits only.
+ No whitespace, sign, or radix prefix. */
+long parse_long(const char *s, const char **tail);
+
+/* This function takes a byte count and stores a short ascii equivalent
+ in the supplied buffer. Eg: 0.122MB, 10.322Kb or 128B. */
+char *format_bytecount(unsigned long long bytes, char *buf, size_t buflen);
+
+/* Convert non-printable characters to replchar in the string */
+void replacenonprintable(char *str, int strlength, char replchar);
+
+/* Returns one if the file pathname given exists, is not a directory and
+ * is readable by the executing process. Returns two if it is readable
+ * and is a directory. Otherwise returns 0. */
+int file_is_readable(const char *pathname);
+
+/* Portable, incompatible replacements for dirname and basename. */
+char *path_get_dirname(const char *path);
+char *path_get_basename(const char *path);
+
+/* A few simple wrappers for the most common memory allocation routines which will exit() if the
+ allocation fails, so you don't always have to check -- see nbase_memalloc.c */
+void *safe_malloc(size_t size);
+void *safe_realloc(void *ptr, size_t size);
+/* Zero-initializing version of safe_malloc */
+void *safe_zalloc(size_t size);
+
+ /* Some routines for obtaining simple (not secure on systems that
+ lack /dev/random and friends' "random" numbers */
+int get_random_bytes(void *buf, int numbytes);
+int get_random_int();
+unsigned short get_random_ushort();
+unsigned int get_random_uint();
+u64 get_random_u64();
+u32 get_random_u32();
+u16 get_random_u16();
+u8 get_random_u8();
+u32 get_random_unique_u32();
+
+/* Create a new socket inheritable by subprocesses. On non-Windows systems it's
+ just a normal socket. */
+int inheritable_socket(int af, int style, int protocol);
+/* The dup function on Windows works only on file descriptors, not socket
+ handles. This function accomplishes the same thing for sockets. */
+int dup_socket(int sd);
+int unblock_socket(int sd);
+int block_socket(int sd);
+int socket_bindtodevice(int sd, const char *device);
+
+/* CRC32 Cyclic Redundancy Check */
+unsigned long nbase_crc32(unsigned char *buf, int len);
+/* CRC32C Cyclic Redundancy Check (Castagnoli) */
+unsigned long nbase_crc32c(unsigned char *buf, int len);
+/* Adler32 Checksum */
+unsigned long nbase_adler32(unsigned char *buf, int len);
+
+double tval2secs(const char *tspec);
+long tval2msecs(const char *tspec);
+const char *tval_unit(const char *tspec);
+
+int fselect(int s, fd_set *rmaster, fd_set *wmaster, fd_set *emaster, struct timeval *tv);
+
+char *hexdump(const u8 *cp, u32 length);
+
+char *executable_path(const char *argv0);
+
+/* addrset management functions and definitions */
+/* A set of addresses. Used to match against allow/deny lists. */
+struct addrset;
+
+void nbase_set_log(void (*log_user_func)(const char *, ...),void (*log_debug_func)(const char *, ...));
+struct addrset *addrset_new();
+extern void addrset_free(struct addrset *set);
+extern void addrset_print(FILE *fp, const struct addrset *set);
+extern int addrset_add_spec(struct addrset *set, const char *spec, int af, int dns);
+extern int addrset_add_file(struct addrset *set, FILE *fd, int af, int dns);
+extern int addrset_contains(const struct addrset *set, const struct sockaddr *sa);
+
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+
+#include "nbase_ipv6.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NBASE_H */
diff --git a/nbase/nbase.vcxproj b/nbase/nbase.vcxproj
new file mode 100644
index 0000000..6650892
--- /dev/null
+++ b/nbase/nbase.vcxproj
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Static|Win32">
+ <Configuration>Static</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{B630C8F7-3138-43E8-89ED-78742FA2AC5F}</ProjectGuid>
+ <RootNamespace>nbase</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Static|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Static|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Static|Win32'">.\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Static|Win32'">Release\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Lib>
+ <OutputFile>$(OutDir)nbase.lib</OutputFile>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalOptions>/D "_CRT_SECURE_NO_DEPRECATE" %(AdditionalOptions)</AdditionalOptions>
+ <PreprocessorDefinitions>WIN32;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Lib>
+ <OutputFile>$(OutDir)nbase.lib</OutputFile>
+ <LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Static|Win32'">
+ <ClCompile>
+ <AdditionalOptions>/D "_CRT_SECURE_NO_DEPRECATE" %(AdditionalOptions)</AdditionalOptions>
+ <PreprocessorDefinitions>WIN32;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Lib>
+ <OutputFile>$(OutDir)nbase.lib</OutputFile>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="getopt.c" />
+ <ClCompile Include="inet_ntop.c" />
+ <ClCompile Include="inet_pton.c" />
+ <ClCompile Include="nbase_addrset.c" />
+ <ClCompile Include="nbase_memalloc.c" />
+ <ClCompile Include="nbase_misc.c" />
+ <ClCompile Include="nbase_rnd.c" />
+ <ClCompile Include="nbase_str.c" />
+ <ClCompile Include="nbase_time.c" />
+ <ClCompile Include="nbase_winunix.c" />
+ <ClCompile Include="snprintf.c" />
+ <ClCompile Include="strcasecmp.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="getopt.h" />
+ <ClInclude Include="nbase.h" />
+ <ClInclude Include="nbase_ipv6.h" />
+ <ClInclude Include="nbase_winconfig.h" />
+ <ClInclude Include="nbase_winunix.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/nbase/nbase_addrset.c b/nbase/nbase_addrset.c
new file mode 100644
index 0000000..20981af
--- /dev/null
+++ b/nbase/nbase_addrset.c
@@ -0,0 +1,934 @@
+/***************************************************************************
+ * nbase_addrset.c -- Address set (addrset) management. *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+/* The code in this file has tests in the file ncat/tests/test-addrset.sh. Run that
+ program after making any big changes. Also, please add tests for any new
+ features. */
+
+#include <limits.h> /* CHAR_BIT */
+#include <errno.h>
+#include <assert.h>
+
+#include "nbase.h"
+
+/* A fancy logging system to allow this file to take advantage of different logging
+ systems used by various programs */
+
+static void default_log_user(const char * a, ...){};
+
+static void (*log_user)(const char *, ...) = default_log_user;
+
+static void default_log_debug(const char * a, ...){};
+
+static void (*log_debug)(const char *, ...) = default_log_debug;
+
+void nbase_set_log(void (*log_user_func)(const char *, ...),void (*log_debug_func)(const char *, ...)){
+ if (log_user_func == NULL)
+ log_user = default_log_user;
+ else
+ log_user = log_user_func;
+ if (log_debug_func == NULL)
+ log_debug = default_log_debug;
+ else
+ log_debug = log_debug_func;
+}
+
+/* Node for a radix tree (trie) used to match certain addresses.
+ * Currently, only individual numeric IP and IPv6 addresses are matched using
+ * the trie. */
+struct trie_node {
+ /* The address prefix that this node represents. */
+ u32 addr[4];
+ /* The prefix mask. Bits in addr that are not within this mask are ignored. */
+ u32 mask[4];
+ /* Addresses with the next bit after the mask equal to 1 are on this branch. */
+ struct trie_node *next_bit_one;
+ /* Addresses with the next bit after the mask equal to 0 are on this branch. */
+ struct trie_node *next_bit_zero;
+};
+
+/* We use bit vectors to represent what values are allowed in an IPv4 octet.
+ Each vector is built up of an array of bitvector_t (any convenient integer
+ type). */
+typedef unsigned long bitvector_t;
+/* A 256-element bit vector, representing legal values for one octet. */
+typedef bitvector_t octet_bitvector[(256 - 1) / (sizeof(unsigned long) * CHAR_BIT) + 1];
+
+/* A chain of tests for set inclusion. If one test is passed, the address is in
+ the set. */
+struct addrset_elem {
+ struct {
+ /* A bit vector for each address octet. */
+ octet_bitvector bits[4];
+ } ipv4;
+ struct addrset_elem *next;
+};
+
+/* A set of addresses. Used to match against allow/deny lists. */
+struct addrset {
+ /* Linked list of struct addset_elem. */
+ struct addrset_elem *head;
+ /* Radix tree for faster matching of certain cases */
+ struct trie_node *trie;
+};
+
+/* Special node pointer to represent "all possible addresses"
+ * This will be used to represent netmask specifications. */
+static struct trie_node g_TRIE_NODE_TRUE = {0};
+#define TRIE_NODE_TRUE &g_TRIE_NODE_TRUE
+
+struct addrset *addrset_new()
+{
+ struct addrset *set = (struct addrset *) safe_zalloc(sizeof(struct addrset));
+ set->head = NULL;
+
+ /* Allocate the first node of the IPv4 trie */
+ set->trie = (struct trie_node *) safe_zalloc(sizeof(struct trie_node));
+ return set;
+}
+
+static void trie_free(struct trie_node *curr)
+{
+ /* Since we descend only down one side, we at most accumulate one tree's-depth, or 128.
+ * Add 4 for safety to account for special root node and special empty stack position 0.
+ */
+ struct trie_node *stack[128+4] = {NULL};
+ int i = 1;
+
+ while (i > 0 && curr != NULL && curr != TRIE_NODE_TRUE) {
+ /* stash next_bit_one */
+ if (curr->next_bit_one != NULL && curr->next_bit_one != TRIE_NODE_TRUE) {
+ stack[i++] = curr->next_bit_one;
+ }
+ /* if next_bit_zero is valid, descend */
+ if (curr->next_bit_zero != NULL && curr->next_bit_zero != TRIE_NODE_TRUE) {
+ curr = curr->next_bit_zero;
+ }
+ else {
+ /* next_bit_one was stashed, next_bit_zero is invalid. Free it and move back up the stack. */
+ free(curr);
+ curr = stack[--i];
+ }
+ }
+}
+
+void addrset_free(struct addrset *set)
+{
+ struct addrset_elem *elem, *next;
+
+ for (elem = set->head; elem != NULL; elem = next) {
+ next = elem->next;
+ free(elem);
+ }
+
+ trie_free(set->trie);
+ free(set);
+}
+
+
+/* Public domain log2 function. https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogLookup */
+static const char LogTable256[256] = {
+#define LT(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n
+ -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+ LT(4), LT(5), LT(5), LT(6), LT(6), LT(6), LT(6),
+ LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7)
+};
+
+/* Returns a mask representing the common prefix between 2 values. */
+static u32 common_mask(u32 a, u32 b)
+{
+ u8 r; // r will be lg(v)
+ u32 t, tt; // temporaries
+ u32 v = a ^ b;
+ if (v == 0) {
+ /* values are equal, all bits are the same */
+ return 0xffffffff;
+ }
+
+ if ((tt = v >> 16))
+ {
+ r = (t = tt >> 8) ? 24 + LogTable256[t] : 16 + LogTable256[tt];
+ }
+ else
+ {
+ r = (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v];
+ }
+ if (r + 1 >= 32) {
+ /* shifting this many bits would overflow. Just return max mask */
+ return 0;
+ }
+ else {
+ return ~((1 << (r + 1)) - 1);
+ }
+}
+
+/* Given a mask and a value, return the value of the bit immediately following
+ * the masked bits. */
+static u32 next_bit_is_one(u32 mask, u32 value) {
+ if (mask == 0) {
+ /* no masked bits, check the first bit. */
+ return (0x80000000 & value);
+ }
+ else if (mask == 0xffffffff) {
+ /* Imaginary bit off the end we will say is 0 */
+ return 0;
+ }
+ /* isolate the bit by overlapping the mask with its inverse */
+ return ((mask >> 1) & ~mask) & value;
+}
+
+/* Given a mask and an address, return true if the first unmasked bit is one */
+static u32 addr_next_bit_is_one(const u32 *mask, const u32 *addr) {
+ u32 curr_mask;
+ u8 i;
+ for (i = 0; i < 4; i++) {
+ curr_mask = mask[i];
+ if (curr_mask < 0xffffffff) {
+ /* Only bother checking the first not-completely-masked portion of the address */
+ return next_bit_is_one(curr_mask, addr[i]);
+ }
+ }
+ /* Mask must be all ones, meaning that the next bit is off the end, and clearly not 1. */
+ return 0;
+}
+
+/* Return true if the masked portion of a and b is identical */
+static int mask_matches(u32 mask, u32 a, u32 b)
+{
+ return !(mask & (a ^ b));
+}
+
+/* Apply a mask and check if 2 addresses are equal */
+static int addr_matches(const u32 *mask, const u32 *sa, const u32 *sb)
+{
+ u32 curr_mask;
+ u8 i;
+ for (i = 0; i < 4; i++) {
+ curr_mask = mask[i];
+ if (curr_mask == 0) {
+ /* No more applicable bits */
+ break;
+ }
+ else if (!mask_matches(curr_mask, sa[i], sb[i])) {
+ /* Doesn't match. */
+ return 0;
+ }
+ }
+ /* All applicable bits match. */
+ return 1;
+}
+
+/* Helper function to allocate and initialize a new node */
+static struct trie_node *new_trie_node(const u32 *addr, const u32 *mask)
+{
+ u8 i;
+ struct trie_node *new_node = (struct trie_node *) safe_zalloc(sizeof(struct trie_node));
+ for (i=0; i < 4; i++) {
+ new_node->addr[i] = addr[i];
+ new_node->mask[i] = mask[i];
+ }
+ /* New nodes default to matching true. Override if not. */
+ new_node->next_bit_one = new_node->next_bit_zero = TRIE_NODE_TRUE;
+ return new_node;
+}
+
+/* Split a node into 2: one that matches the greatest common prefix with addr
+ * and one that does not. */
+static void trie_split (struct trie_node *this, const u32 *addr, const u32 *mask)
+{
+ struct trie_node *new_node;
+ u32 new_mask[4] = {0,0,0,0};
+ u8 i;
+ /* Calculate the mask of the common prefix */
+ for (i=0; i < 4; i++) {
+ new_mask[i] = common_mask(this->addr[i], addr[i]);
+ if (new_mask[i] > this->mask[i]){
+ /* Addrs have more bits in common than we care about for this node. */
+ new_mask[i] = this->mask[i];
+ }
+ if (new_mask[i] > mask[i]) {
+ /* new addr's mask is broader, so this node is superseded. */
+ this->mask[i] = mask[i];
+ for (i++; i < 4; i++) {
+ this->mask[i] = 0;
+ }
+ /* The longer mask is superseded. Delete following nodes. */
+ trie_free(this->next_bit_one);
+ trie_free(this->next_bit_zero);
+ /* Anything below here will always match. */
+ this->next_bit_one = this->next_bit_zero = TRIE_NODE_TRUE;
+ return;
+ }
+ if (new_mask[i] < 0xffffffff) {
+ break;
+ }
+ }
+ if (new_mask[i] >= this->mask[i]) {
+ /* This node completely contains the new addr and mask. No need to split or add */
+ return;
+ }
+ /* Make a copy of this node to continue matching what it has been */
+ new_node = new_trie_node(this->addr, this->mask);
+ new_node->next_bit_one = this->next_bit_one;
+ new_node->next_bit_zero = this->next_bit_zero;
+ /* Adjust this node to the smaller mask */
+ for (i=0; i < 4; i++) {
+ this->mask[i] = new_mask[i];
+ }
+ /* Put the new node on the appropriate branch */
+ if (addr_next_bit_is_one(this->mask, this->addr)) {
+ this->next_bit_one = new_node;
+ this->next_bit_zero = NULL;
+ }
+ else {
+ this->next_bit_zero = new_node;
+ this->next_bit_one = NULL;
+ }
+}
+
+/* Helper for address insertion */
+static void _trie_insert (struct trie_node *this, const u32 *addr, const u32 *mask)
+{
+ /* On entry, at least the 1st bit must match this node */
+ assert(this == TRIE_NODE_TRUE || (this->addr[0] ^ addr[0]) < (1 << 31));
+
+ while (this != NULL && this != TRIE_NODE_TRUE) {
+ /* Split the node if necessary to ensure a match */
+ trie_split(this, addr, mask);
+
+ /* At this point, this node matches the addr up to this->mask. */
+ if (addr_next_bit_is_one(this->mask, addr)) {
+ /* next bit is one: insert on the one branch */
+ if (this->next_bit_one == NULL) {
+ /* Previously unmatching branch, always the case when splitting */
+ this->next_bit_one = new_trie_node(addr, mask);
+ return;
+ }
+ else {
+ this = this->next_bit_one;
+ }
+ }
+ else {
+ /* next bit is zero: insert on the zero branch */
+ if (this->next_bit_zero == NULL) {
+ /* Previously unmatching branch, always the case when splitting */
+ this->next_bit_zero = new_trie_node(addr, mask);
+ return;
+ }
+ else {
+ this = this->next_bit_zero;
+ }
+ }
+ }
+}
+
+/* Helper function to turn a sockaddr into an array of u32, used internally */
+static int sockaddr_to_addr(const struct sockaddr *sa, u32 *addr)
+{
+ if (sa->sa_family == AF_INET) {
+ /* IPv4-mapped IPv6 address */
+ addr[0] = addr[1] = 0;
+ addr[2] = 0xffff;
+ addr[3] = ntohl(((struct sockaddr_in *) sa)->sin_addr.s_addr);
+ }
+#ifdef HAVE_IPV6
+ else if (sa->sa_family == AF_INET6) {
+ u8 i;
+ unsigned char *addr6 = ((struct sockaddr_in6 *) sa)->sin6_addr.s6_addr;
+ for (i=0; i < 4; i++) {
+ addr[i] = (addr6[i*4] << 24) + (addr6[i*4+1] << 16) + (addr6[i*4+2] << 8) + addr6[i*4+3];
+ }
+ }
+#endif
+ else {
+ return 0;
+ }
+ return 1;
+}
+
+static int sockaddr_to_mask (const struct sockaddr *sa, int bits, u32 *mask)
+{
+ int i, k;
+ if (bits >= 0) {
+ if (sa->sa_family == AF_INET) {
+ bits += 96;
+ }
+#ifdef HAVE_IPV6
+ else if (sa->sa_family == AF_INET6) {
+ ; /* do nothing */
+ }
+#endif
+ else {
+ return 0;
+ }
+ }
+ else
+ bits = 128;
+ k = bits / 32;
+ for (i=0; i < 4; i++) {
+ if (i < k) {
+ mask[i] = 0xffffffff;
+ }
+ else if (i > k) {
+ mask[i] = 0;
+ }
+ else {
+ mask[i] = 0xfffffffe << (31 - bits % 32);
+ }
+ }
+ return 1;
+}
+
+/* Insert a sockaddr into the trie */
+static void trie_insert (struct trie_node *this, const struct sockaddr *sa, int bits)
+{
+ u32 addr[4] = {0};
+ u32 mask[4] = {0};
+ if (!sockaddr_to_addr(sa, addr)) {
+ log_debug("Unknown address family %u, address not inserted.\n", sa->sa_family);
+ return;
+ }
+ if (!sockaddr_to_mask(sa, bits, mask)) {
+ log_debug("Bad netmask length %d for address family %u, address not inserted.\n", bits, sa->sa_family);
+ return;
+ }
+ /* First node doesn't have a mask or address of its own; we have to check the
+ * first bit manually. */
+ if (0x80000000 & addr[0]) {
+ /* First bit is 1, so insert on ones branch */
+ if (this->next_bit_one == NULL) {
+ /* Empty branch, just add it. */
+ this->next_bit_one = new_trie_node(addr, mask);
+ return;
+ }
+ _trie_insert(this->next_bit_one, addr, mask);
+ }
+ else {
+ /* First bit is 0, so insert on zeros branch */
+ if (this->next_bit_zero == NULL) {
+ /* Empty branch, just add it. */
+ this->next_bit_zero = new_trie_node(addr, mask);
+ return;
+ }
+ _trie_insert(this->next_bit_zero, addr, mask);
+ }
+}
+
+/* Helper for matching addresses */
+static int _trie_match (const struct trie_node *this, const u32 *addr)
+{
+ while (this != TRIE_NODE_TRUE && this != NULL
+ && addr_matches(this->mask, this->addr, addr)) {
+ if (1 & this->mask[3]) {
+ /* We've matched all possible bits! Yay! */
+ return 1;
+ }
+ else if (addr_next_bit_is_one(this->mask, addr)) {
+ this = this->next_bit_one;
+ }
+ else {
+ this = this->next_bit_zero;
+ }
+ }
+ if (this == TRIE_NODE_TRUE) {
+ return 1;
+ }
+ return 0;
+}
+
+static int trie_match (const struct trie_node *this, const struct sockaddr *sa)
+{
+ u32 addr[4] = {0};
+ if (!sockaddr_to_addr(sa, addr)) {
+ log_debug("Unknown address family %u, cannot match.\n", sa->sa_family);
+ return 0;
+ }
+ /* Manually check first bit to decide which branch to match against */
+ if (0x80000000 & addr[0]) {
+ return _trie_match(this->next_bit_one, addr);
+ }
+ else {
+ return _trie_match(this->next_bit_zero, addr);
+ }
+ return 0;
+}
+
+/* A debugging function to print out the contents of an addrset_elem. For IPv4
+ this is the four bit vectors. For IPv6 it is the address and netmask. */
+static void addrset_elem_print(FILE *fp, const struct addrset_elem *elem)
+{
+ const size_t num_bitvector = sizeof(octet_bitvector) / sizeof(bitvector_t);
+ int i;
+ size_t j;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < num_bitvector; j++)
+ fprintf(fp, "%0*lX ", (int) (sizeof(bitvector_t) * 2), elem->ipv4.bits[i][num_bitvector - 1 - j]);
+ fprintf(fp, "\n");
+ }
+}
+
+void addrset_print(FILE *fp, const struct addrset *set)
+{
+ const struct addrset_elem *elem;
+ for (elem = set->head; elem != NULL; elem = elem->next) {
+ fprintf(fp, "addrset_elem: %p\n", elem);
+ addrset_elem_print(fp, elem);
+ }
+}
+
+/* This is a wrapper around getaddrinfo that automatically handles hints for
+ IPv4/IPv6, TCP/UDP, and whether name resolution is allowed. */
+static int resolve_name(const char *name, struct addrinfo **result, int af, int use_dns)
+{
+ struct addrinfo hints = { 0 };
+ int rc;
+
+ hints.ai_protocol = IPPROTO_TCP;
+
+ /* First do a non-DNS lookup for any address family (just checks for a valid
+ numeric address). We recognize numeric addresses no matter the setting of
+ af. This is also the last step if use_dns is false. */
+ hints.ai_flags |= AI_NUMERICHOST;
+ hints.ai_family = AF_UNSPEC;
+ *result = NULL;
+ rc = getaddrinfo(name, NULL, &hints, result);
+ if (rc == 0 || !use_dns)
+ return rc;
+
+ /* Do a DNS lookup now. When we look up a name we only want addresses
+ corresponding to the value of af. */
+ hints.ai_flags &= ~AI_NUMERICHOST;
+ hints.ai_family = af;
+ *result = NULL;
+ rc = getaddrinfo(name, NULL, &hints, result);
+
+ return rc;
+}
+
+/* This is an address family-agnostic version of inet_ntop. */
+static char *address_to_string(const struct sockaddr *sa, size_t sa_len,
+ char *buf, size_t len)
+{
+ getnameinfo(sa, sa_len, buf, len, NULL, 0, NI_NUMERICHOST);
+
+ return buf;
+}
+
+/* Break an IPv4 address into an array of octets. octets[0] contains the most
+ significant octet and octets[3] the least significant. */
+static void in_addr_to_octets(const struct in_addr *ia, uint8_t octets[4])
+{
+ u32 hbo = ntohl(ia->s_addr);
+
+ octets[0] = (uint8_t) ((hbo & (0xFFU << 24)) >> 24);
+ octets[1] = (uint8_t) ((hbo & (0xFFU << 16)) >> 16);
+ octets[2] = (uint8_t) ((hbo & (0xFFU << 8)) >> 8);
+ octets[3] = (uint8_t) (hbo & 0xFFU);
+}
+
+#define BITVECTOR_BITS (sizeof(bitvector_t) * CHAR_BIT)
+#define BIT_SET(v, n) ((v)[(n) / BITVECTOR_BITS] |= 1UL << ((n) % BITVECTOR_BITS))
+#define BIT_IS_SET(v, n) (((v)[(n) / BITVECTOR_BITS] & 1UL << ((n) % BITVECTOR_BITS)) != 0)
+
+static int parse_ipv4_ranges(struct addrset_elem *elem, const char *spec);
+static void apply_ipv4_netmask_bits(struct addrset_elem *elem, int bits);
+
+/* Add a host specification into the address set. Returns 1 on success, 0 on
+ error. */
+int addrset_add_spec(struct addrset *set, const char *spec, int af, int dns)
+{
+ char *local_spec;
+ char *netmask_s;
+ const char *tail;
+ long netmask_bits;
+ struct addrinfo *addrs, *addr;
+ struct addrset_elem *elem;
+ int rc;
+
+ /* Make a copy of the spec to mess with. */
+ local_spec = strdup(spec);
+ if (local_spec == NULL)
+ return 0;
+
+ /* Read the CIDR netmask bits, if present. */
+ netmask_s = strchr(local_spec, '/');
+ if (netmask_s == NULL) {
+ /* A negative value means unspecified; default depends on the address
+ family. */
+ netmask_bits = -1;
+ } else {
+ *netmask_s = '\0';
+ netmask_s++;
+ errno = 0;
+ netmask_bits = parse_long(netmask_s, &tail);
+ if (errno != 0 || *tail != '\0' || tail == netmask_s) {
+ log_user("Error parsing netmask in \"%s\".\n", spec);
+ free(local_spec);
+ return 0;
+ }
+ }
+
+ /* See if it's a plain IP address */
+ rc = resolve_name(local_spec, &addrs, af, 0);
+ if (rc == 0 && addrs != NULL) {
+ /* Add all addresses to the trie */
+ for (addr = addrs; addr != NULL; addr = addr->ai_next) {
+ char addr_string[128];
+ if ((addr->ai_family == AF_INET && netmask_bits > 32)
+#ifdef HAVE_IPV6
+ || (addr->ai_family == AF_INET6 && netmask_bits > 128)
+#endif
+ ) {
+ log_user("Illegal netmask in \"%s\". Must be smaller than address bit length.\n", spec);
+ free(local_spec);
+ freeaddrinfo(addrs);
+ return 0;
+ }
+ address_to_string(addr->ai_addr, addr->ai_addrlen, addr_string, sizeof(addr_string));
+ trie_insert(set->trie, addr->ai_addr, netmask_bits);
+ log_debug("Add IP %s/%d to addrset (trie).\n", addr_string, netmask_bits);
+ }
+ free(local_spec);
+ freeaddrinfo(addrs);
+ return 1;
+ }
+
+ elem = (struct addrset_elem *) safe_malloc(sizeof(*elem));
+ memset(elem->ipv4.bits, 0, sizeof(elem->ipv4.bits));
+
+ /* Check if this is an IPv4 address, with optional ranges and wildcards. */
+ if (parse_ipv4_ranges(elem, local_spec)) {
+ if (netmask_bits > 32) {
+ log_user("Illegal netmask in \"%s\". Must be between 0 and 32.\n", spec);
+ free(local_spec);
+ free(elem);
+ return 0;
+ }
+ apply_ipv4_netmask_bits(elem, netmask_bits);
+ log_debug("Add IPv4 range %s/%ld to addrset.\n", local_spec, netmask_bits > 0 ? netmask_bits : 32);
+ elem->next = set->head;
+ set->head = elem;
+ free(local_spec);
+ return 1;
+ } else {
+ free(elem);
+ }
+
+ /* When all else fails, resolve the name. */
+ rc = resolve_name(local_spec, &addrs, af, dns);
+ if (rc != 0) {
+ log_user("Error resolving name \"%s\": %s\n", local_spec, gai_strerror(rc));
+ free(local_spec);
+ return 0;
+ }
+ if (addrs == NULL)
+ log_user("Warning: no addresses found for %s.\n", local_spec);
+ free(local_spec);
+
+ /* Walk the list of addresses and add them all to the set with netmasks. */
+ for (addr = addrs; addr != NULL; addr = addr->ai_next) {
+ char addr_string[128];
+
+ address_to_string(addr->ai_addr, addr->ai_addrlen, addr_string, sizeof(addr_string));
+
+ /* Note: it is possible that in this loop we are dealing with addresses
+ of more than one family (e.g., IPv4 and IPv6). But we have at most
+ one netmask value for all of them. Whatever netmask we have is
+ applied blindly to whatever addresses there are, which may not be
+ what you want if a /24 is applied to IPv6 and will cause an error if
+ a /120 is applied to IPv4. */
+ if (addr->ai_family == AF_INET) {
+
+ if (netmask_bits > 32) {
+ log_user("Illegal netmask in \"%s\". Must be between 0 and 32.\n", spec);
+ freeaddrinfo(addrs);
+ return 0;
+ }
+ log_debug("Add IPv4 %s/%ld to addrset (trie).\n", addr_string, netmask_bits > 0 ? netmask_bits : 32);
+
+#ifdef HAVE_IPV6
+ } else if (addr->ai_family == AF_INET6) {
+ if (netmask_bits > 128) {
+ log_user("Illegal netmask in \"%s\". Must be between 0 and 128.\n", spec);
+ freeaddrinfo(addrs);
+ return 0;
+ }
+ log_debug("Add IPv6 %s/%ld to addrset (trie).\n", addr_string, netmask_bits > 0 ? netmask_bits : 128);
+#endif
+ } else {
+ log_debug("ignoring address %s for %s. Family %d socktype %d protocol %d.\n", addr_string, spec, addr->ai_family, addr->ai_socktype, addr->ai_protocol);
+ continue;
+ }
+
+ trie_insert(set->trie, addr->ai_addr, netmask_bits);
+ }
+
+ if (addrs != NULL)
+ freeaddrinfo(addrs);
+
+ return 1;
+}
+
+/* Add whitespace-separated host specifications from fd into the address set.
+ Returns 1 on success, 0 on error. */
+int addrset_add_file(struct addrset *set, FILE *fd, int af, int dns)
+{
+ char buf[1024];
+ int c, i;
+
+ for (;;) {
+ /* Skip whitespace. */
+ while ((c = getc(fd)) != EOF) {
+ if (!isspace(c))
+ break;
+ }
+ if (c == EOF)
+ break;
+ ungetc(c, fd);
+
+ i = 0;
+ while ((c = getc(fd)) != EOF) {
+ if (isspace(c))
+ break;
+ if (i + 1 > sizeof(buf) - 1) {
+ /* Truncate the specification to give a little context. */
+ buf[11] = '\0';
+ log_user("Host specification starting with \"%s\" is too long.\n", buf);
+ return 0;
+ }
+ buf[i++] = c;
+ }
+ buf[i] = '\0';
+
+ if (!addrset_add_spec(set, buf, af, dns))
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Parse an IPv4 address with optional ranges and wildcards into bit vectors.
+ Each octet must match the regular expression '(\*|#?(-#?)?(,#?(-#?)?)*)',
+ where '#' stands for an integer between 0 and 255. Return 1 on success, 0 on
+ error. */
+static int parse_ipv4_ranges(struct addrset_elem *elem, const char *spec)
+{
+ const char *p;
+ int octet_index, i;
+
+ p = spec;
+ octet_index = 0;
+ while (*p != '\0' && octet_index < 4) {
+ if (*p == '*') {
+ for (i = 0; i < 256; i++)
+ BIT_SET(elem->ipv4.bits[octet_index], i);
+ p++;
+ } else {
+ for (;;) {
+ long start, end;
+ const char *tail;
+
+ errno = 0;
+ start = parse_long(p, &tail);
+ /* Is this a range open on the left? */
+ if (tail == p) {
+ if (*p == '-')
+ start = 0;
+ else
+ return 0;
+ }
+ if (errno != 0 || start < 0 || start > 255)
+ return 0;
+ p = tail;
+
+ /* Look for a range. */
+ if (*p == '-') {
+ p++;
+ errno = 0;
+ end = parse_long(p, &tail);
+ /* Is this range open on the right? */
+ if (tail == p)
+ end = 255;
+ if (errno != 0 || end < 0 || end > 255 || end < start)
+ return 0;
+ p = tail;
+ } else {
+ end = start;
+ }
+
+ /* Fill in the range in the bit vector. */
+ for (i = start; i <= end; i++)
+ BIT_SET(elem->ipv4.bits[octet_index], i);
+
+ if (*p != ',')
+ break;
+ p++;
+ }
+ }
+ octet_index++;
+ if (octet_index < 4) {
+ if (*p != '.')
+ return 0;
+ p++;
+ }
+ }
+ if (*p != '\0' || octet_index < 4)
+ return 0;
+
+ return 1;
+}
+
+/* Expand a single-octet bit vector to include any additional addresses that
+ result when mask is applied. */
+static void apply_ipv4_netmask_octet(octet_bitvector bits, uint8_t mask)
+{
+ unsigned int i, j;
+ uint32_t chunk_size;
+
+ /* Process the bit vector in chunks, first of size 1, then of size 2, up to
+ size 128. Check the next bit of the mask. If it is 1, do nothing.
+ Otherwise, pair up the chunks (first with the second, third with the
+ fourth, etc.). For each pair of chunks, set a bit in one chunk if it is
+ set in the other. chunk_size also serves as an index into the mask. */
+ for (chunk_size = 1; chunk_size < 256; chunk_size <<= 1) {
+ if ((mask & chunk_size) != 0)
+ continue;
+ for (i = 0; i < 256; i += chunk_size * 2) {
+ for (j = 0; j < chunk_size; j++) {
+ if (BIT_IS_SET(bits, i + j))
+ BIT_SET(bits, i + j + chunk_size);
+ else if (BIT_IS_SET(bits, i + j + chunk_size))
+ BIT_SET(bits, i + j);
+ }
+ }
+ }
+}
+
+/* Expand an addrset_elem's IPv4 bit vectors to include any additional addresses
+ that result when the given netmask is applied. The mask is in network byte
+ order. */
+static void apply_ipv4_netmask(struct addrset_elem *elem, uint32_t mask)
+{
+ mask = ntohl(mask);
+ /* Apply the mask one octet at a time. It's done this way because ranges
+ span exactly one octet. */
+ apply_ipv4_netmask_octet(elem->ipv4.bits[0], (mask & 0xFF000000) >> 24);
+ apply_ipv4_netmask_octet(elem->ipv4.bits[1], (mask & 0x00FF0000) >> 16);
+ apply_ipv4_netmask_octet(elem->ipv4.bits[2], (mask & 0x0000FF00) >> 8);
+ apply_ipv4_netmask_octet(elem->ipv4.bits[3], (mask & 0x000000FF));
+}
+
+/* Expand an addrset_elem's IPv4 bit vectors to include any additional addresses
+ that result from the application of a CIDR-style netmask with the given
+ number of bits. If bits is negative it is taken to be 32. */
+static void apply_ipv4_netmask_bits(struct addrset_elem *elem, int bits)
+{
+ uint32_t mask;
+
+ if (bits > 32)
+ return;
+ if (bits < 0)
+ bits = 32;
+
+ if (bits == 0)
+ mask = htonl(0x00000000);
+ else
+ mask = htonl(0xFFFFFFFF << (32 - bits));
+ apply_ipv4_netmask(elem, mask);
+}
+
+static int match_ipv4_bits(const octet_bitvector bits[4], const struct sockaddr *sa)
+{
+ uint8_t octets[4];
+
+ if (sa->sa_family != AF_INET)
+ return 0;
+
+ in_addr_to_octets(&((const struct sockaddr_in *) sa)->sin_addr, octets);
+
+ return BIT_IS_SET(bits[0], octets[0])
+ && BIT_IS_SET(bits[1], octets[1])
+ && BIT_IS_SET(bits[2], octets[2])
+ && BIT_IS_SET(bits[3], octets[3]);
+}
+
+static int addrset_elem_match(const struct addrset_elem *elem, const struct sockaddr *sa)
+{
+ return match_ipv4_bits(elem->ipv4.bits, sa);
+}
+
+int addrset_contains(const struct addrset *set, const struct sockaddr *sa)
+{
+ struct addrset_elem *elem;
+
+ /* First check the trie. */
+ if (trie_match(set->trie, sa))
+ return 1;
+
+ /* If that didn't match, check the rest of the addrset_elem in order */
+ if (sa->sa_family == AF_INET) {
+ for (elem = set->head; elem != NULL; elem = elem->next) {
+ if (addrset_elem_match(elem, sa))
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/nbase/nbase_config.h.in b/nbase/nbase_config.h.in
new file mode 100644
index 0000000..38194d9
--- /dev/null
+++ b/nbase/nbase_config.h.in
@@ -0,0 +1,206 @@
+
+/***************************************************************************
+ * nbase_config.h.in -- Autoconf uses this template, combined with the *
+ * configure script knowledge about system capabilities, to build the *
+ * nbase_config.h file that lets nbase (and libraries that call it) better *
+ * understand system particulars. *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+#ifndef NBASE_CONFIG_H
+#define NBASE_CONFIG_H
+
+#undef HAVE_USLEEP
+
+#undef HAVE_NANOSLEEP
+
+#undef HAVE_STRUCT_ICMP
+
+#undef HAVE_IP_IP_SUM
+
+#undef inline
+
+#undef STDC_HEADERS
+
+#undef HAVE_STRING_H
+
+#undef HAVE_NETDB_H
+
+#undef HAVE_GETOPT_H
+
+#undef HAVE_UNISTD_H
+
+#undef HAVE_STRINGS_H
+
+#undef HAVE_BSTRING_H
+
+#undef WORDS_BIGENDIAN
+
+#undef HAVE_MEMORY_H
+
+#undef HAVE_LIBIBERTY_H
+
+#undef HAVE_FCNTL_H
+
+#undef HAVE_ERRNO_H
+
+/* both bzero() and memcpy() are used in the source */
+#undef HAVE_BZERO
+#undef HAVE_MEMCPY
+#undef HAVE_STRERROR
+
+#undef HAVE_SYS_PARAM_H
+
+#undef HAVE_SYS_SELECT_H
+
+#undef HAVE_SYS_SOCKIO_H
+
+#undef HAVE_SYS_SOCKET_H
+
+#undef HAVE_SYS_WAIT_H
+
+#undef HAVE_NET_IF_H
+
+#undef BSD_NETWORKING
+
+#undef HAVE_STRCASESTR
+
+#undef HAVE_STRCASECMP
+
+#undef HAVE_STRNCASECMP
+
+#undef HAVE_GETTIMEOFDAY
+
+#undef HAVE_SLEEP
+
+#undef HAVE_SIGNAL
+
+#undef HAVE_GETOPT
+
+#undef HAVE_GETOPT_LONG_ONLY
+
+#undef HAVE_SOCKADDR_SA_LEN
+
+#undef HAVE_NETINET_IF_ETHER_H
+
+#undef HAVE_NETINET_IN_H
+
+#undef HAVE_SYS_TIME_H
+
+#undef PWD_H
+
+#undef HAVE_ARPA_INET_H
+
+#undef HAVE_SYS_RESOURCE_H
+
+#undef HAVE_INTTYPES_H
+
+#undef HAVE_MACH_O_DYLD_H
+
+#undef HAVE_SYS_STAT_H
+
+#undef SPRINTF_RETURNS_STRING
+
+#undef STUPID_SOLARIS_CHECKSUM_BUG
+
+/* IPv6 stuff */
+#undef HAVE_IPV6
+#undef HAVE_AF_INET6
+#undef HAVE_SOCKADDR_IN6
+#undef HAVE_SOCKADDR_STORAGE
+#undef HAVE_GETADDRINFO
+#undef HAVE_GAI_STRERROR
+#undef HAVE_GETNAMEINFO
+#undef HAVE_INET_NTOP
+#undef HAVE_INET_PTON
+
+#undef int8_t
+#undef int16_t
+#undef int32_t
+#undef int64_t
+#undef uint8_t
+#undef uint16_t
+#undef uint32_t
+#undef uint64_t
+
+#undef HAVE_SNPRINTF
+#undef HAVE_VASNPRINTF
+#undef HAVE_ASPRINTF
+#undef HAVE_VASPRINTF
+#undef HAVE_VFPRINTF
+#undef HAVE_VSNPRINTF
+#undef NEED_SNPRINTF_PROTO
+#undef NEED_VSNPRINTF_PROTO
+
+/* define if your compiler has __attribute__ */
+#undef HAVE___ATTRIBUTE__
+
+#undef HAVE_OPENSSL
+
+#undef HAVE_PROC_SELF_EXE
+
+#undef LINUX
+#undef FREEBSD
+#undef OPENBSD
+#undef SOLARIS
+#undef SUNOS
+#undef BSDI
+#undef IRIX
+#undef HPUX
+#undef NETBSD
+
+#endif /* NBASE_CONFIG_H */
diff --git a/nbase/nbase_crc32ct.h b/nbase/nbase_crc32ct.h
new file mode 100644
index 0000000..aa9203a
--- /dev/null
+++ b/nbase/nbase_crc32ct.h
@@ -0,0 +1,136 @@
+
+/***************************************************************************
+ * nbase_crc32ct.h -- CRC-32C (Castagnoli) table definitions. *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#ifndef NBASE_CRC32CT_H
+#define NBASE_CRC32CT_H
+
+#define CRC32C_POLY 0x1EDC6F41
+#define CRC32C(c,d) (c=(c>>8)^crc_c[(c^(d))&0xFF])
+
+static unsigned long crc_c[256] = {
+0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L,
+0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL,
+0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL,
+0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L,
+0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL,
+0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L,
+0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L,
+0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL,
+0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL,
+0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L,
+0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L,
+0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL,
+0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L,
+0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL,
+0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL,
+0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L,
+0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L,
+0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L,
+0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L,
+0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L,
+0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L,
+0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L,
+0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L,
+0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L,
+0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L,
+0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L,
+0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L,
+0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L,
+0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L,
+0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L,
+0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L,
+0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L,
+0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL,
+0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L,
+0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L,
+0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL,
+0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L,
+0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL,
+0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL,
+0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L,
+0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L,
+0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL,
+0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL,
+0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L,
+0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL,
+0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L,
+0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L,
+0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL,
+0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L,
+0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL,
+0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL,
+0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L,
+0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL,
+0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L,
+0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L,
+0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL,
+0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL,
+0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L,
+0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L,
+0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL,
+0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L,
+0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL,
+0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL,
+0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L,
+};
+
+#endif /* NBASE_CRC32CT_H */
+
diff --git a/nbase/nbase_ipv6.h b/nbase/nbase_ipv6.h
new file mode 100644
index 0000000..04cd568
--- /dev/null
+++ b/nbase/nbase_ipv6.h
@@ -0,0 +1,214 @@
+
+/***************************************************************************
+ * nbase_ipv6.h -- IPv6 portability classes and structures These were *
+ * written by fyodor@nmap.org . *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#ifndef NBASE_IPV6_H
+#define NBASE_IPV6_H
+
+#ifdef __amigaos__
+#ifndef _NMAP_AMIGAOS_H_
+#include "../nmap_amigaos.h"
+#endif
+#endif
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+#ifndef HAVE_AF_INET6
+#define AF_INET6 10
+#define PF_INET6 10
+#endif /* HAVE_AF_INET6 */
+#ifndef HAVE_INET_PTON
+/* int
+ * inet_pton(af, src, dst)
+ * convert from presentation format (which usually means ASCII printable)
+ * to network format (which is usually some kind of binary format).
+ * return:
+ * 1 if the address was valid for the specified address family
+ * 0 if the address wasn't valid (`dst' is untouched in this case)
+ * -1 if some other error occurred (`dst' is untouched in this case, too)
+ * author:
+ * Paul Vixie, 1996.
+ */
+int inet_pton(int af, const char *src, void *dst);
+#endif /* HAVE_INET_PTON */
+
+#ifndef HAVE_INET_NTOP
+/* char *
+ * inet_ntop(af, src, dst, size)
+ * convert a network format address to presentation format.
+ * return:
+ * pointer to presentation format address (`dst'), or NULL (see errno).
+ * author:
+ * Paul Vixie, 1996.
+ */
+const char *inet_ntop(int af, const void *src, char *dst, size_t size);
+#endif /* HAVE_INET_NTOP */
+
+#ifndef HAVE_SOCKADDR_STORAGE
+struct sockaddr_storage {
+ u16 ss_family;
+ u16 __align_to_64[3];
+ u64 __padding[16];
+};
+#endif /* SOCKADDR_STORAGE */
+
+/* Compares two sockaddr_storage structures with a return value like strcmp.
+ First the address families are compared, then the addresses if the families
+ are equal. The structures must be real full-length sockaddr_storage
+ structures, not something shorter like sockaddr_in. */
+int sockaddr_storage_cmp(const struct sockaddr_storage *a,
+ const struct sockaddr_storage *b);
+
+/* Does sockaddr_storage_cmp(a, b) == 0 for you. */
+int sockaddr_storage_equal(const struct sockaddr_storage *a,
+ const struct sockaddr_storage *b);
+
+/* This function is an easier version of inet_ntop because you don't
+ need to pass a dest buffer. Instead, it returns a static buffer that
+ you can use until the function is called again (by the same or another
+ thread in the process). If there is a weird error (like sslen being
+ too short) then NULL will be returned. */
+const char *inet_ntop_ez(const struct sockaddr_storage *ss, size_t sslen);
+
+
+#if !HAVE_GETNAMEINFO || !HAVE_GETADDRINFO
+#if !defined(EAI_MEMORY)
+#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
+#define EAI_AGAIN 2 /* temporary failure in name resolution */
+#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
+#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
+#define EAI_FAMILY 5 /* ai_family not supported */
+#define EAI_MEMORY 6 /* memory allocation failure */
+#define EAI_NODATA 7 /* no address associated with hostname */
+#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
+#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
+#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
+#define EAI_SYSTEM 11 /* system error returned in errno */
+#define EAI_BADHINTS 12
+#define EAI_PROTOCOL 13
+#define EAI_MAX 14
+#endif /* EAI_MEMORY */
+#endif /* !HAVE_GETNAMEINFO || !HAVE_GETADDRINFO */
+
+#if !HAVE_GETNAMEINFO
+/* This replacement version is *NOT* a full implementation by any
+ stretch of the imagination */
+/* getnameinfo flags */
+#if !defined(NI_NAMEREQD)
+#define NI_NOFQDN 8
+#define NI_NUMERICHOST 16
+#define NI_NAMEREQD 32
+#define NI_NUMERICSERV 64
+#define NI_DGRAM 128
+#endif
+
+struct sockaddr;
+int getnameinfo(const struct sockaddr *sa, size_t salen,
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags);
+#endif /* !HAVE_GETNAMEINFO */
+
+#if !HAVE_GETADDRINFO
+/* This replacement version is *NOT* a full implementation by any
+ stretch of the imagination */
+struct addrinfo {
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+ size_t ai_addrlen; /* length of ai_addr */
+ char *ai_canonname; /* canonical name for nodename */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
+};
+
+/* getaddrinfo Flags */
+#if !defined(AI_PASSIVE) || !defined(AI_CANONNAME) || !defined(AI_NUMERICHOST)
+#define AI_PASSIVE 1
+#define AI_CANONNAME 2
+#define AI_NUMERICHOST 4
+#endif
+
+void freeaddrinfo(struct addrinfo *res);
+int getaddrinfo(const char *node, const char *service,
+ const struct addrinfo *hints, struct addrinfo **res);
+
+#endif /* !HAVE_GETADDRINFO */
+
+#ifndef HAVE_GAI_STRERROR
+const char *gai_strerror(int errcode);
+#endif
+
+int sockaddr_storage_inet_pton(const char * ip_str, struct sockaddr_storage * addr);
+const char *sockaddr_storage_iptop(const struct sockaddr_storage * addr, char * dst);
+
+#endif /* NBASE_IPV6_H */
diff --git a/nbase/nbase_memalloc.c b/nbase/nbase_memalloc.c
new file mode 100644
index 0000000..4fccc1e
--- /dev/null
+++ b/nbase/nbase_memalloc.c
@@ -0,0 +1,115 @@
+
+/***************************************************************************
+ * nbase_memalloc.c -- A few simple functions related to memory *
+ * allocation. Right now they are just safe_ versions of well known calls *
+ * like malloc that quit if the allocation fails (so you don't have to *
+ * have a bunch of ugly checks in your code. These were written by *
+ * fyodor@nmap.org . *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#include "nbase.h"
+#include <stdio.h>
+
+NORETURN static void fatal(char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+static void fatal(char *fmt, ...) {
+ va_list ap;
+
+ va_start(ap, fmt);
+ fflush(stdout);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\nQUITTING!\n");
+ va_end(ap);
+ exit(1);
+}
+
+void *safe_malloc(size_t size) {
+ void *mymem;
+
+ if ((int)size < 0) /* Catch caller errors */
+ fatal("Tried to malloc negative amount of memory!!!");
+ mymem = malloc(size);
+ if (mymem == NULL)
+ fatal("Malloc Failed! Probably out of space.");
+ return mymem;
+}
+
+void *safe_realloc(void *ptr, size_t size) {
+ void *mymem;
+
+ if ((int)size < 0) /* Catch caller errors */
+ fatal("Tried to realloc negative amount of memory!!!");
+ mymem = realloc(ptr, size);
+ if (mymem == NULL)
+ fatal("Realloc Failed! Probably out of space.");
+ return mymem;
+}
+
+/* Zero-initializing version of safe_malloc */
+void *safe_zalloc(size_t size) {
+ void *mymem;
+
+ if ((int)size < 0)
+ fatal("Tried to malloc negative amount of memory!!!");
+ mymem = calloc(1, size);
+ if (mymem == NULL)
+ fatal("Malloc Failed! Probably out of space.");
+ return mymem;
+}
diff --git a/nbase/nbase_misc.c b/nbase/nbase_misc.c
new file mode 100644
index 0000000..db265ef
--- /dev/null
+++ b/nbase/nbase_misc.c
@@ -0,0 +1,898 @@
+
+/***************************************************************************
+ * nbase_misc.c -- Some small miscellaneous utility/compatibility *
+ * functions. *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#include "nbase.h"
+
+#ifndef WIN32
+#include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
+#else
+#include <winsock2.h>
+#endif
+
+#include <limits.h>
+#include <stdio.h>
+#include "nbase_ipv6.h"
+#include "nbase_crc32ct.h"
+
+#include <assert.h>
+#include <fcntl.h>
+
+#ifdef WIN32
+#include <conio.h>
+#endif
+
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN 46
+#endif
+
+/* Returns the UNIX/Windows errno-equivalent. Note that the Windows
+ call is socket/networking specific. The windows error number
+ returned is like WSAMSGSIZE, but nbase.h includes #defines to
+ correlate many of the common UNIX errors with their closest Windows
+ equivalents. So you can use EMSGSIZE or EINTR. */
+int socket_errno() {
+#ifdef WIN32
+ return WSAGetLastError();
+#else
+ return errno;
+#endif
+}
+
+/* We can't just use strerror to get socket errors on Windows because it has
+ its own set of error codes: WSACONNRESET not ECONNRESET for example. This
+ function will do the right thing on Windows. Call it like
+ socket_strerror(socket_errno())
+*/
+char *socket_strerror(int errnum) {
+#ifdef WIN32
+ static char buffer[256];
+
+ if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS |
+ FORMAT_MESSAGE_MAX_WIDTH_MASK,
+ 0, errnum, 0, buffer, sizeof(buffer), NULL))
+ {
+ Snprintf(buffer, 255, "socket error %d; FormatMessage error: %08x", errnum, GetLastError());
+ };
+
+ return buffer;
+#else
+ return strerror(errnum);
+#endif
+}
+
+/* Compares two sockaddr_storage structures with a return value like strcmp.
+ First the address families are compared, then the addresses if the families
+ are equal. The structures must be real full-length sockaddr_storage
+ structures, not something shorter like sockaddr_in. */
+int sockaddr_storage_cmp(const struct sockaddr_storage *a,
+ const struct sockaddr_storage *b) {
+ if (a->ss_family < b->ss_family)
+ return -1;
+ else if (a->ss_family > b->ss_family)
+ return 1;
+ if (a->ss_family == AF_INET) {
+ struct sockaddr_in *sin_a = (struct sockaddr_in *) a;
+ struct sockaddr_in *sin_b = (struct sockaddr_in *) b;
+ if (sin_a->sin_addr.s_addr < sin_b->sin_addr.s_addr)
+ return -1;
+ else if (sin_a->sin_addr.s_addr > sin_b->sin_addr.s_addr)
+ return 1;
+ else
+ return 0;
+ } else if (a->ss_family == AF_INET6) {
+ struct sockaddr_in6 *sin6_a = (struct sockaddr_in6 *) a;
+ struct sockaddr_in6 *sin6_b = (struct sockaddr_in6 *) b;
+ return memcmp(sin6_a->sin6_addr.s6_addr, sin6_b->sin6_addr.s6_addr,
+ sizeof(sin6_a->sin6_addr.s6_addr));
+ } else {
+ assert(0);
+ }
+ return 0; /* Not reached */
+}
+
+int sockaddr_storage_equal(const struct sockaddr_storage *a,
+ const struct sockaddr_storage *b) {
+ return sockaddr_storage_cmp(a, b) == 0;
+}
+
+/* This function is an easier version of inet_ntop because you don't
+ need to pass a dest buffer. Instead, it returns a static buffer that
+ you can use until the function is called again (by the same or another
+ thread in the process). If there is a weird error (like sslen being
+ too short) then NULL will be returned. */
+const char *inet_ntop_ez(const struct sockaddr_storage *ss, size_t sslen) {
+
+ const struct sockaddr_in *sin = (struct sockaddr_in *) ss;
+ static char str[INET6_ADDRSTRLEN];
+#if HAVE_IPV6
+ const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) ss;
+#endif
+
+ str[0] = '\0';
+
+ if (sin->sin_family == AF_INET) {
+ if (sslen < sizeof(struct sockaddr_in))
+ return NULL;
+ return inet_ntop(AF_INET, &sin->sin_addr, str, sizeof(str));
+ }
+#if HAVE_IPV6
+ else if(sin->sin_family == AF_INET6) {
+ if (sslen < sizeof(struct sockaddr_in6))
+ return NULL;
+ return inet_ntop(AF_INET6, &sin6->sin6_addr, str, sizeof(str));
+ }
+#endif
+ //Some laptops report the ip and address family of disabled wifi cards as null
+ //so yes, we will hit this sometimes.
+ return NULL;
+}
+
+/* Create a new socket inheritable by subprocesses. On non-Windows systems it's
+ just a normal socket. */
+int inheritable_socket(int af, int style, int protocol) {
+#ifdef WIN32
+ /* WSASocket is just like socket, except that the sockets it creates are
+ inheritable by subprocesses (such as are created by CreateProcess), while
+ those created by socket are not. */
+ return WSASocket(af, style, protocol, NULL, 0, WSA_FLAG_OVERLAPPED);
+#else
+ return socket(af, style, protocol);
+#endif
+}
+
+/* The dup function on Windows works only on file descriptors, not socket
+ handles. This function accomplishes the same thing for sockets. */
+int dup_socket(int sd) {
+#ifdef WIN32
+ HANDLE copy;
+
+ if (DuplicateHandle(GetCurrentProcess(), (HANDLE) sd,
+ GetCurrentProcess(), &copy,
+ 0, FALSE, DUPLICATE_SAME_ACCESS) == 0) {
+ return -1;
+ }
+
+ return (int) copy;
+#else
+ return dup(sd);
+#endif
+}
+
+int unblock_socket(int sd) {
+#ifdef WIN32
+ unsigned long one = 1;
+
+ ioctlsocket(sd, FIONBIO, &one);
+
+ return 0;
+#else
+ int options;
+
+ /* Unblock our socket to prevent recvfrom from blocking forever on certain
+ * target ports. */
+ options = fcntl(sd, F_GETFL);
+ if (options == -1)
+ return -1;
+
+ return fcntl(sd, F_SETFL, O_NONBLOCK | options);
+#endif /* WIN32 */
+}
+
+/* Convert a socket to blocking mode */
+int block_socket(int sd) {
+#ifdef WIN32
+ unsigned long options = 0;
+
+ ioctlsocket(sd, FIONBIO, &options);
+
+ return 0;
+#else
+ int options;
+
+ options = fcntl(sd, F_GETFL);
+ if (options == -1)
+ return -1;
+
+ return fcntl(sd, F_SETFL, (~O_NONBLOCK) & options);
+#endif
+}
+
+/* Use the SO_BINDTODEVICE sockopt to bind with a specific interface (Linux
+ only). Pass NULL or an empty string to remove device binding. */
+int socket_bindtodevice(int sd, const char *device) {
+ char padded[sizeof(int)];
+ size_t len;
+
+ len = strlen(device) + 1;
+ /* In Linux 2.6.20 and earlier, there is a bug in SO_BINDTODEVICE that causes
+ EINVAL to be returned if the optlen < sizeof(int); this happens for example
+ with the interface names "" and "lo". Pad the string with null characters
+ so it is above this limit if necessary.
+ http://article.gmane.org/gmane.linux.network/71887
+ http://article.gmane.org/gmane.linux.network/72216 */
+ if (len < sizeof(padded)) {
+ /* We rely on strncpy padding with nulls here. */
+ strncpy(padded, device, sizeof(padded));
+ device = padded;
+ len = sizeof(padded);
+ }
+
+#ifdef SO_BINDTODEVICE
+ /* Linux-specific sockopt asking to use a specific interface. See socket(7). */
+ if (setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, device, len) < 0)
+ return 0;
+#endif
+
+ return 1;
+}
+
+/* Convert a time specification into a count of seconds. A time specification is
+ * a non-negative real number, possibly followed by a units suffix. The suffixes
+ * are "ms" for milliseconds, "s" for seconds, "m" for minutes, or "h" for
+ * hours. Seconds is the default with no suffix. -1 is returned if the string
+ * can't be parsed. */
+double tval2secs(const char *tspec) {
+ double d;
+ char *tail;
+
+ errno = 0;
+ d = strtod(tspec, &tail);
+ if (*tspec == '\0' || errno != 0)
+ return -1;
+ if (strcasecmp(tail, "ms") == 0)
+ return d / 1000.0;
+ else if (*tail == '\0' || strcasecmp(tail, "s") == 0)
+ return d;
+ else if (strcasecmp(tail, "m") == 0)
+ return d * 60.0;
+ else if (strcasecmp(tail, "h") == 0)
+ return d * 60.0 * 60.0;
+ else
+ return -1;
+}
+
+long tval2msecs(const char *tspec) {
+ double s, ms;
+
+ s = tval2secs(tspec);
+ if (s == -1)
+ return -1;
+ ms = s * 1000.0;
+ if (ms > LONG_MAX || ms < LONG_MIN)
+ return -1;
+
+ return (long) ms;
+}
+
+/* Returns the unit portion of a time specification (such as "ms", "s", "m", or
+ "h"). Returns NULL if there was a parsing error or no unit is present. */
+const char *tval_unit(const char *tspec) {
+ double d;
+ char *tail;
+
+ errno = 0;
+ d = strtod(tspec, &tail);
+ /* Avoid GCC 4.6 error "variable 'd' set but not used
+ [-Wunused-but-set-variable]". */
+ (void) d;
+ if (*tspec == '\0' || errno != 0 || *tail == '\0')
+ return NULL;
+
+ return tail;
+}
+
+/* A replacement for select on Windows that allows selecting on stdin
+ * (file descriptor 0) and selecting on zero file descriptors (just for
+ * the timeout). Plain Windows select doesn't work on non-sockets like
+ * stdin and returns an error if no file descriptors were given, because
+ * they were NULL or empty. This only works for sockets and stdin; if
+ * you have a descriptor referring to a normal open file in the set,
+ * Windows will return WSAENOTSOCK. */
+int fselect(int s, fd_set *rmaster, fd_set *wmaster, fd_set *emaster, struct timeval *tv)
+{
+#ifdef WIN32
+ static int stdin_thread_started = 0;
+ int fds_ready = 0;
+ int iter = -1;
+ int do_select = 0;
+ struct timeval stv;
+ fd_set rset, wset, eset;
+ int r_stdin = 0;
+ int e_stdin = 0;
+ int stdin_ready = 0;
+
+ /* Figure out whether there are any FDs in the sets, as @$@!$# Windows
+ returns WSAINVAL (10022) if you call a select() with no FDs, even though
+ the Linux man page says that doing so is a good, reasonably portable way
+ to sleep with subsecond precision. Sigh. */
+ if (rmaster != NULL) {
+ /* If stdin is requested, clear it and remember it. */
+ if (checked_fd_isset(STDIN_FILENO, rmaster)) {
+ r_stdin = 1;
+ checked_fd_clr(STDIN_FILENO, rmaster);
+ }
+ /* If any are left, we'll do a select. Otherwise, it's a sleep. */
+ do_select = do_select || rmaster->fd_count;
+ }
+
+ /* Same thing with exceptions */
+ if (emaster != NULL) {
+ if (checked_fd_isset(STDIN_FILENO, emaster)) {
+ e_stdin = 1;
+ checked_fd_clr(STDIN_FILENO, emaster);
+ }
+ do_select = do_select || emaster->fd_count;
+ }
+
+ /* stdin can't be written to, so ignore it. */
+ if (wmaster != NULL) {
+ assert(!checked_fd_isset(STDIN_FILENO, wmaster));
+ do_select = do_select || wmaster->fd_count;
+ }
+
+ /* Handle the case where stdin is not in scope. */
+ if (!(r_stdin || e_stdin)) {
+ if (do_select) {
+ /* Do a normal select. */
+ return select(s, rmaster, wmaster, emaster, tv);
+ } else {
+ /* No file descriptors given. Just sleep. */
+ if (tv == NULL) {
+ /* Sleep forever. */
+ while (1)
+ sleep(10000);
+ } else {
+ usleep(tv->tv_sec * 1000000UL + tv->tv_usec);
+ return 0;
+ }
+ }
+ }
+
+ /* This is a hack for Windows, which doesn't allow select()ing on
+ * non-sockets (like stdin). We remove stdin from the fd_set and
+ * loop while select()ing on everything else, with a timeout of
+ * 125ms. Then we check if stdin is ready and increment fds_ready
+ * and set stdin in rmaster if it looks good. We just keep looping
+ * until we have something or it times out.
+ */
+
+ /* nbase_winunix.c has all the nasty details behind checking if
+ * stdin has input. It involves a background thread, which we start
+ * now if necessary. */
+ if (!stdin_thread_started) {
+ int ret = win_stdin_start_thread();
+ assert(ret != 0);
+ stdin_thread_started = 1;
+ }
+
+ if (tv) {
+ int usecs = (tv->tv_sec * 1000000) + tv->tv_usec;
+
+ iter = usecs / 125000;
+
+ if (usecs % 125000)
+ iter++;
+ }
+
+ FD_ZERO(&rset);
+ FD_ZERO(&wset);
+ FD_ZERO(&eset);
+
+ while (!fds_ready && iter) {
+ stv.tv_sec = 0;
+ stv.tv_usec = 125000;
+
+ if (rmaster)
+ rset = *rmaster;
+ if (wmaster)
+ wset = *wmaster;
+ if (emaster)
+ eset = *emaster;
+
+ if(r_stdin) {
+ stdin_ready = win_stdin_ready();
+ if(stdin_ready)
+ stv.tv_usec = 0; /* get status but don't wait since stdin is ready */
+ }
+
+ fds_ready = 0;
+ /* selecting on anything other than stdin? */
+ if (do_select)
+ fds_ready = select(s, &rset, &wset, &eset, &stv);
+ else
+ usleep(stv.tv_sec * 1000000UL + stv.tv_usec);
+
+ if (fds_ready > -1 && stdin_ready) {
+ checked_fd_set(STDIN_FILENO, &rset);
+ fds_ready++;
+ }
+
+ if (tv)
+ iter--;
+ }
+
+ if (rmaster)
+ *rmaster = rset;
+ if (wmaster)
+ *wmaster = wset;
+ if (emaster)
+ *emaster = eset;
+
+ return fds_ready;
+#else
+ return select(s, rmaster, wmaster, emaster, tv);
+#endif
+}
+
+
+/*
+ * CRC32 Cyclic Redundancy Check
+ *
+ * From: http://www.ietf.org/rfc/rfc1952.txt
+ *
+ * Copyright (c) 1996 L. Peter Deutsch
+ *
+ * Permission is granted to copy and distribute this document for any
+ * purpose and without charge, including translations into other
+ * languages and incorporation into compilations, provided that the
+ * copyright notice and this notice are preserved, and that any
+ * substantive changes or deletions from the original are clearly
+ * marked.
+ *
+ */
+
+/* Table of CRCs of all 8-bit messages. */
+static unsigned long crc_table[256];
+
+/* Flag: has the table been computed? Initially false. */
+static int crc_table_computed = 0;
+
+/* Make the table for a fast CRC. */
+static void make_crc_table(void)
+{
+ unsigned long c;
+ int n, k;
+
+ for (n = 0; n < 256; n++) {
+ c = (unsigned long) n;
+ for (k = 0; k < 8; k++) {
+ if (c & 1) {
+ c = 0xedb88320L ^ (c >> 1);
+ } else {
+ c = c >> 1;
+ }
+ }
+ crc_table[n] = c;
+ }
+ crc_table_computed = 1;
+}
+
+/*
+ Update a running crc with the bytes buf[0..len-1] and return
+ the updated crc. The crc should be initialized to zero. Pre- and
+ post-conditioning (one's complement) is performed within this
+ function so it shouldn't be done by the caller. Usage example:
+
+ unsigned long crc = 0L;
+
+ while (read_buffer(buffer, length) != EOF) {
+ crc = update_crc(crc, buffer, length);
+ }
+ if (crc != original_crc) error();
+*/
+static unsigned long update_crc(unsigned long crc,
+ unsigned char *buf, int len)
+{
+ unsigned long c = crc ^ 0xffffffffL;
+ int n;
+
+ if (!crc_table_computed)
+ make_crc_table();
+ for (n = 0; n < len; n++) {
+ c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
+ }
+ return c ^ 0xffffffffL;
+}
+
+/* Return the CRC of the bytes buf[0..len-1]. */
+unsigned long nbase_crc32(unsigned char *buf, int len)
+{
+ return update_crc(0L, buf, len);
+}
+
+
+/*
+ * CRC-32C (Castagnoli) Cyclic Redundancy Check.
+ * Taken straight from Appendix C of RFC 4960 (SCTP), with the difference that
+ * the remainder register (crc32) is initialized to 0xffffffffL rather than ~0L,
+ * for correct operation on platforms where unsigned long is longer than 32
+ * bits.
+ */
+
+/* Return the CRC-32C of the bytes buf[0..len-1] */
+unsigned long nbase_crc32c(unsigned char *buf, int len)
+{
+ int i;
+ unsigned long crc32 = 0xffffffffL;
+ unsigned long result;
+ unsigned char byte0, byte1, byte2, byte3;
+
+ for (i = 0; i < len; i++) {
+ CRC32C(crc32, buf[i]);
+ }
+
+ result = ~crc32;
+
+ /* result now holds the negated polynomial remainder;
+ * since the table and algorithm is "reflected" [williams95].
+ * That is, result has the same value as if we mapped the message
+ * to a polynomial, computed the host-bit-order polynomial
+ * remainder, performed final negation, then did an end-for-end
+ * bit-reversal.
+ * Note that a 32-bit bit-reversal is identical to four inplace
+ * 8-bit reversals followed by an end-for-end byteswap.
+ * In other words, the bytes of each bit are in the right order,
+ * but the bytes have been byteswapped. So we now do an explicit
+ * byteswap. On a little-endian machine, this byteswap and
+ * the final ntohl cancel out and could be elided.
+ */
+
+ byte0 = result & 0xff;
+ byte1 = (result >> 8) & 0xff;
+ byte2 = (result >> 16) & 0xff;
+ byte3 = (result >> 24) & 0xff;
+ crc32 = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3);
+ return crc32;
+}
+
+
+/*
+ * Adler32 Checksum Calculation.
+ * Taken straight from RFC 2960 (SCTP).
+ */
+
+#define ADLER32_BASE 65521 /* largest prime smaller than 65536 */
+
+/*
+ * Update a running Adler-32 checksum with the bytes buf[0..len-1]
+ * and return the updated checksum. The Adler-32 checksum should
+ * be initialized to 1.
+ */
+static unsigned long update_adler32(unsigned long adler,
+ unsigned char *buf, int len)
+{
+ unsigned long s1 = adler & 0xffff;
+ unsigned long s2 = (adler >> 16) & 0xffff;
+ int n;
+
+ for (n = 0; n < len; n++) {
+ s1 = (s1 + buf[n]) % ADLER32_BASE;
+ s2 = (s2 + s1) % ADLER32_BASE;
+ }
+ return (s2 << 16) + s1;
+}
+
+/* Return the Adler32 of the bytes buf[0..len-1] */
+unsigned long nbase_adler32(unsigned char *buf, int len)
+{
+ return update_adler32(1L, buf, len);
+}
+
+#undef ADLER32_BASE
+
+
+/* This function returns a string containing the hexdump of the supplied
+ * buffer. It uses current locale to determine if a character is printable or
+ * not. It prints 73char+\n wide lines like these:
+
+0000 e8 60 65 86 d7 86 6d 30 35 97 54 87 ff 67 05 9e .`e...m05.T..g..
+0010 07 5a 98 c0 ea ad 50 d2 62 4f 7b ff e1 34 f8 fc .Z....P.bO{..4..
+0020 c4 84 0a 6a 39 ad 3c 10 63 b2 22 c4 24 40 f4 b1 ...j9.<.c.".$@..
+
+ * The lines look basically like Wireshark's hex dump.
+ * WARNING: This function returns a pointer to a DYNAMICALLY allocated buffer
+ * that the caller is supposed to free().
+ * */
+char *hexdump(const u8 *cp, u32 length){
+ static char asciify[257]; /* Stores character table */
+ int asc_init=0; /* Flag to generate table only once */
+ u32 i=0, hex=0, asc=0; /* Array indexes */
+ u32 line_count=0; /* For byte count at line start */
+ char *current_line=NULL; /* Current line to write */
+ char *buffer=NULL; /* Dynamic buffer we return */
+ #define LINE_LEN 74 /* Length of printed line */
+ char line2print[LINE_LEN]; /* Stores current line */
+ char printbyte[16]; /* For byte conversion */
+ int bytes2alloc; /* For buffer */
+ memset(line2print, ' ', LINE_LEN); /* We fill the line with spaces */
+
+ /* On the first run, generate a list of nice printable characters
+ * (according to current locale) */
+ if( asc_init==0){
+ asc_init=1;
+ for(i=0; i<256; i++){
+ if( isalnum(i) || isdigit(i) || ispunct(i) ){ asciify[i]=i; }
+ else{ asciify[i]='.'; }
+ }
+ }
+ /* Allocate enough space to print the hex dump */
+ bytes2alloc=(length%16==0)? (1 + LINE_LEN * (length/16)) : (1 + LINE_LEN * (1+(length/16))) ;
+ buffer=(char *)safe_zalloc(bytes2alloc);
+ current_line=buffer;
+#define HEX_START 7
+#define ASC_START 57
+/* This is how or line looks like.
+0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f .`e...m05.T..g..[\n]
+01234567890123456789012345678901234567890123456789012345678901234567890123
+0 1 2 3 4 5 6 7
+ ^ ^ ^
+ | | |
+ HEX_START ASC_START Newline
+*/
+ i=0;
+ while( i < length ){
+ memset(line2print, ' ', LINE_LEN); /* Fill line with spaces */
+ snprintf(line2print, sizeof(line2print), "%04x", (16*line_count++) % 0xFFFF); /* Add line No.*/
+ line2print[4]=' '; /* Replace the '\0' inserted by snprintf() with a space */
+ hex=HEX_START; asc=ASC_START;
+ do { /* Print 16 bytes in both hex and ascii */
+ if (i%16 == 8) hex++; /* Insert space every 8 bytes */
+ snprintf(printbyte, sizeof(printbyte), "%02x", cp[i]);/* First print the hex number */
+ line2print[hex++]=printbyte[0];
+ line2print[hex++]=printbyte[1];
+ line2print[hex++]=' ';
+ line2print[asc++]=asciify[ cp[i] ]; /* Then print its ASCII equivalent */
+ i++;
+ } while (i < length && i%16 != 0);
+ /* Copy line to output buffer */
+ line2print[LINE_LEN-1]='\n';
+ memcpy(current_line, line2print, LINE_LEN);
+ current_line += LINE_LEN;
+ }
+ buffer[bytes2alloc-1]='\0';
+ return buffer;
+} /* End of hexdump() */
+
+/* This is like strtol or atoi, but it allows digits only. No whitespace, sign,
+ or radix prefix. */
+long parse_long(const char *s, const char **tail)
+{
+ if (!isdigit((int) (unsigned char) *s)) {
+ *tail = (char *) s;
+ return 0;
+ }
+
+ return strtol(s, (char **) tail, 10);
+}
+
+
+
+/* This function takes a byte count and stores a short ascii equivalent
+ in the supplied buffer. Eg: 0.122MB, 10.322Kb or 128B. */
+char *format_bytecount(unsigned long long bytes, char *buf, size_t buflen) {
+ assert(buf != NULL);
+
+ if (bytes < 1000)
+ Snprintf(buf, buflen, "%uB", (unsigned int) bytes);
+ else if (bytes < 1000000)
+ Snprintf(buf, buflen, "%.3fKB", bytes / 1000.0);
+ else
+ Snprintf(buf, buflen, "%.3fMB", bytes / 1000000.0);
+
+ return buf;
+}
+
+/* Returns one if the file pathname given exists, is not a directory and
+ * is readable by the executing process. Returns two if it is readable
+ * and is a directory. Otherwise returns 0. */
+int file_is_readable(const char *pathname) {
+ char *pathname_buf = strdup(pathname);
+ int status = 0;
+ struct stat st;
+
+#ifdef WIN32
+ // stat on windows only works for "dir_name" not for "dir_name/" or "dir_name\\"
+ int pathname_len = strlen(pathname_buf);
+ char last_char = pathname_buf[pathname_len - 1];
+
+ if( last_char == '/'
+ || last_char == '\\')
+ pathname_buf[pathname_len - 1] = '\0';
+
+#endif
+
+ if (stat(pathname_buf, &st) == -1)
+ status = 0;
+ else if (access(pathname_buf, R_OK) != -1)
+ status = S_ISDIR(st.st_mode) ? 2 : 1;
+
+ free(pathname_buf);
+ return status;
+}
+
+#if HAVE_PROC_SELF_EXE
+static char *executable_path_proc_self_exe(void) {
+ char buf[1024];
+ char *path;
+ int n;
+
+ n = readlink("/proc/self/exe", buf, sizeof(buf));
+ if (n < 0 || n >= sizeof(buf))
+ return NULL;
+ path = (char *) safe_malloc(n + 1);
+ /* readlink does not null-terminate. */
+ memcpy(path, buf, n);
+ path[n] = '\0';
+
+ return path;
+}
+#endif
+
+#if HAVE_MACH_O_DYLD_H
+#include <mach-o/dyld.h>
+/* See the dyld(3) man page on OS X. */
+static char *executable_path_NSGetExecutablePath(void) {
+ char buf[1024];
+ uint32_t size;
+
+ size = sizeof(buf);
+ if (_NSGetExecutablePath(buf, &size) == 0)
+ return strdup(buf);
+ else
+ return NULL;
+}
+#endif
+
+#if WIN32
+static char *executable_path_GetModuleFileName(void) {
+ char buf[1024];
+ int n;
+
+ n = GetModuleFileName(GetModuleHandle(0), buf, sizeof(buf));
+ if (n <= 0 || n >= sizeof(buf))
+ return NULL;
+
+ return strdup(buf);
+}
+#endif
+
+static char *executable_path_argv0(const char *argv0) {
+ if (argv0 == NULL)
+ return NULL;
+ /* We can get the path from argv[0] if it contains a directory separator.
+ (Otherwise it was looked up in $PATH). */
+ if (strchr(argv0, '/') != NULL)
+ return strdup(argv0);
+#if WIN32
+ if (strchr(argv0, '\\') != NULL)
+ return strdup(argv0);
+#endif
+ return NULL;
+}
+
+char *executable_path(const char *argv0) {
+ char *path;
+
+ path = NULL;
+#if HAVE_PROC_SELF_EXE
+ if (path == NULL)
+ path = executable_path_proc_self_exe();
+#endif
+#if HAVE_MACH_O_DYLD_H
+ if (path == NULL)
+ path = executable_path_NSGetExecutablePath();
+#endif
+#if WIN32
+ if (path == NULL)
+ path = executable_path_GetModuleFileName();
+#endif
+ if (path == NULL)
+ path = executable_path_argv0(argv0);
+
+ return path;
+}
+
+int sockaddr_storage_inet_pton(const char * ip_str, struct sockaddr_storage * addr)
+{
+ struct sockaddr_in * addrv4p = (struct sockaddr_in *) addr;
+#if HAVE_IPV6
+ struct sockaddr_in6 * addrv6p = (struct sockaddr_in6 *) addr;
+ if ( 1 == inet_pton(AF_INET6, ip_str, &(addrv6p->sin6_addr)) )
+ {
+ addr->ss_family = AF_INET6;
+ return 1;
+ }
+#endif // HAVE_IPV6
+
+ if ( 1 == inet_pton(AF_INET, ip_str, &(addrv4p->sin_addr)) )
+ {
+ addr->ss_family = AF_INET;
+ return 1;
+ }
+
+ return 0;
+}
+
+const char *sockaddr_storage_iptop(const struct sockaddr_storage * addr, char * dst)
+{
+ switch (addr->ss_family){
+ case AF_INET:
+ {
+ const struct sockaddr_in * ipv4_ptr = (const struct sockaddr_in *) addr;
+ return inet_ntop(addr->ss_family, &(ipv4_ptr->sin_addr), dst, INET_ADDRSTRLEN);
+ }
+#if HAVE_IPV6
+ case AF_INET6:
+ {
+ const struct sockaddr_in6 * addrv6p = (struct sockaddr_in6 *) addr;
+ return inet_ntop(addr->ss_family, &(addrv6p->sin6_addr), dst, INET6_ADDRSTRLEN);
+ }
+#endif
+ default:
+ {
+ return NULL;
+ }}
+}
diff --git a/nbase/nbase_rnd.c b/nbase/nbase_rnd.c
new file mode 100644
index 0000000..bd1f57f
--- /dev/null
+++ b/nbase/nbase_rnd.c
@@ -0,0 +1,360 @@
+
+/***************************************************************************
+ * nbase_rnd.c -- Some simple routines for obtaining random numbers for *
+ * casual use. These are pretty secure on systems with /dev/urandom, but *
+ * falls back to poor entropy for seeding on systems without such support. *
+ * *
+ * Based on DNET / OpenBSD arc4random(). *
+ * *
+ * Copyright (c) 2000 Dug Song <dugsong@monkey.org> *
+ * Copyright (c) 1996 David Mazieres <dm@lcs.mit.edu> *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#include "nbase.h"
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif /* HAV_SYS_TIME_H */
+#ifdef WIN32
+#include <wincrypt.h>
+#endif /* WIN32 */
+
+/* data for our random state */
+struct nrand_handle {
+ u8 i, j, s[256], *tmp;
+ int tmplen;
+};
+typedef struct nrand_handle nrand_h;
+
+static void nrand_addrandom(nrand_h *rand, u8 *buf, int len) {
+ int i;
+ u8 si;
+
+ /* Mix entropy in buf with s[]...
+ *
+ * This is the ARC4 key-schedule. It is rather poor and doesn't mix
+ * the key in very well. This causes a bias at the start of the stream.
+ * To eliminate most of this bias, the first N bytes of the stream should
+ * be dropped.
+ */
+ rand->i--;
+ for (i = 0; i < 256; i++) {
+ rand->i = (rand->i + 1);
+ si = rand->s[rand->i];
+ rand->j = (rand->j + si + buf[i % len]);
+ rand->s[rand->i] = rand->s[rand->j];
+ rand->s[rand->j] = si;
+ }
+ rand->j = rand->i;
+}
+
+static u8 nrand_getbyte(nrand_h *r) {
+ u8 si, sj;
+
+ /* This is the core of ARC4 and provides the pseudo-randomness */
+ r->i = (r->i + 1);
+ si = r->s[r->i];
+ r->j = (r->j + si);
+ sj = r->s[r->j];
+ r->s[r->i] = sj; /* The start of the the swap */
+ r->s[r->j] = si; /* The other half of the swap */
+ return (r->s[(si + sj) & 0xff]);
+}
+
+int nrand_get(nrand_h *r, void *buf, size_t len) {
+ u8 *p;
+ size_t i;
+
+ /* Hand out however many bytes were asked for */
+ for (p = buf, i = 0; i < len; i++) {
+ p[i] = nrand_getbyte(r);
+ }
+ return (0);
+}
+
+void nrand_init(nrand_h *r) {
+ u8 seed[256]; /* Starts out with "random" stack data */
+ int i;
+
+ /* Gather seed entropy with best the OS has to offer */
+#ifdef WIN32
+ HCRYPTPROV hcrypt = 0;
+
+ CryptAcquireContext(&hcrypt, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
+ CryptGenRandom(hcrypt, sizeof(seed), seed);
+ CryptReleaseContext(hcrypt, 0);
+#else
+ struct timeval *tv = (struct timeval *)seed;
+ int *pid = (int *)(seed + sizeof(*tv));
+ int fd;
+
+ gettimeofday(tv, NULL); /* fill lowest seed[] with time */
+ *pid = getpid(); /* fill next lowest seed[] with pid */
+
+ /* Try to fill the rest of the state with OS provided entropy */
+ if ((fd = open("/dev/urandom", O_RDONLY)) != -1 ||
+ (fd = open("/dev/arandom", O_RDONLY)) != -1) {
+ ssize_t n;
+ do {
+ errno = 0;
+ n = read(fd, seed + sizeof(*tv) + sizeof(*pid),
+ sizeof(seed) - sizeof(*tv) - sizeof(*pid));
+ } while (n < 0 && errno == EINTR);
+ close(fd);
+ }
+#endif
+
+ /* Fill up our handle with starter values */
+ for (i = 0; i < 256; i++) { r->s[i] = i; };
+ r->i = r->j = 0;
+
+ nrand_addrandom(r, seed, 128); /* lower half of seed data for entropy */
+ nrand_addrandom(r, seed + 128, 128); /* Now use upper half */
+ r->tmp = NULL;
+ r->tmplen = 0;
+
+ /* This stream will start biased. Get rid of 1K of the stream */
+ nrand_get(r, seed, 256); nrand_get(r, seed, 256);
+ nrand_get(r, seed, 256); nrand_get(r, seed, 256);
+}
+
+int get_random_bytes(void *buf, int numbytes) {
+ static nrand_h state;
+ static int state_init = 0;
+
+ /* Initialize if we need to */
+ if (!state_init) {
+ nrand_init(&state);
+ state_init = 1;
+ }
+
+ /* Now fill our buffer */
+ nrand_get(&state, buf, numbytes);
+
+ return 0;
+}
+
+int get_random_int() {
+ int i;
+ get_random_bytes(&i, sizeof(int));
+ return i;
+}
+
+unsigned int get_random_uint() {
+ unsigned int i;
+ get_random_bytes(&i, sizeof(unsigned int));
+ return i;
+}
+
+u64 get_random_u64() {
+ u64 i;
+ get_random_bytes(&i, sizeof(i));
+ return i;
+}
+
+
+u32 get_random_u32() {
+ u32 i;
+ get_random_bytes(&i, sizeof(i));
+ return i;
+}
+
+u16 get_random_u16() {
+ u16 i;
+ get_random_bytes(&i, sizeof(i));
+ return i;
+}
+
+u8 get_random_u8() {
+ u8 i;
+ get_random_bytes(&i, sizeof(i));
+ return i;
+}
+
+unsigned short get_random_ushort() {
+ unsigned short s;
+ get_random_bytes(&s, sizeof(unsigned short));
+ return s;
+}
+
+
+/* This function is magic ;-)
+ *
+ * Sometimes Nmap wants to generate IPs that look random
+ * but don't have any duplicates. The strong RC4 generator
+ * can't be used for this purpose because it can generate duplicates
+ * if you get enough IPs (birthday paradox).
+ *
+ * This routine exploits the fact that a LCG won't repeat for the
+ * entire duration of its period. An LCG has some pretty bad
+ * properties though so this routine does extra work to try to
+ * tweak the LCG output so that is has very good statistics but
+ * doesn't repeat. The tweak used was mostly made up on the spot
+ * but is generally based on good ideas and has been moderately
+ * tested. See links and reasoning below.
+ */
+u32 get_random_unique_u32() {
+ static u32 state, tweak1, tweak2, tweak3;
+ static int state_init = 0;
+ u32 output;
+
+ /* Initialize if we need to */
+ if (!state_init) {
+ get_random_bytes(&state, sizeof(state));
+ get_random_bytes(&tweak1, sizeof(tweak1));
+ get_random_bytes(&tweak2, sizeof(tweak2));
+ get_random_bytes(&tweak3, sizeof(tweak3));
+
+ state_init = 1;
+ }
+
+ /* What is this math crap?
+ *
+ * The whole idea behind this generator is that an LCG can be constructed
+ * with a period of exactly 2^32. As long as the LCG is fed back onto
+ * itself the period will be 2^32. The tweak after the LCG is just
+ * a good permutation in GF(2^32).
+ *
+ * To accomplish the tweak the notion of rounds and round keys from
+ * block ciphers has been borrowed. The only special aspect of this
+ * block cipher is that the first round short-circuits the LCG.
+ *
+ * This block cipher uses three rounds. Each round is as follows:
+ *
+ * 1) Affine transform in GF(2^32)
+ * 2) Rotate left by round constant
+ * 3) XOR with round key
+ *
+ * For round one the affine transform is used as an LCG.
+ */
+
+ /* Reasoning:
+ *
+ * Affine transforms were chosen both to make a LCG and also
+ * to try to introduce non-linearity.
+ *
+ * The rotate up each round was borrowed from SHA-1 and was introduced
+ * to help obscure the obvious short cycles when you truncate an LCG with
+ * a power-of-two period like the one used.
+ *
+ * The XOR with the round key was borrowed from several different
+ * published functions (but see Xorshift)
+ * and provides a different sequence for the full LCG.
+ * There are 3 32 bit round keys. This generator can
+ * generate 2^96 different sequences of period 2^32.
+ *
+ * This generator was tested with Dieharder. It did not fail any test.
+ */
+
+ /* See:
+ *
+ * http://en.wikipedia.org/wiki/Galois_field
+ * http://en.wikipedia.org/wiki/Affine_cipher
+ * http://en.wikipedia.org/wiki/Linear_congruential_generator
+ * http://en.wikipedia.org/wiki/Xorshift
+ * http://en.wikipedia.org/wiki/Sha-1
+ *
+ * http://seclists.org/nmap-dev/2009/q3/0695.html
+ */
+
+
+ /* First off, we need to evolve the state with our LCG
+ * We'll use the LCG from Numerical Recipes (m=2^32,
+ * a=1664525, c=1013904223). All by itself this generator
+ * pretty bad. We're going to try to fix that without causing
+ * duplicates.
+ */
+ state = (((state * 1664525) & 0xFFFFFFFF) + 1013904223) & 0xFFFFFFFF;
+
+ output = state;
+
+ /* With a normal LCG, we would just output the state.
+ * In this case, though, we are going to try to destroy the
+ * linear correlation between IPs by approximating a random permutation
+ * in GF(2^32) (collision-free)
+ */
+
+ /* Then rotate and XOR */
+ output = ((output << 7) | (output >> (32 - 7)));
+ output = output ^ tweak1; /* This is the round key */
+
+ /* End round 1, start round 2 */
+
+ /* Then put it through an affine transform (glibc constants) */
+ output = (((output * 1103515245) & 0xFFFFFFFF) + 12345) & 0xFFFFFFFF;
+
+ /* Then rotate and XOR some more */
+ output = ((output << 15) | (output >> (32 - 15)));
+ output = output ^ tweak2;
+
+ /* End round 2, start round 3 */
+
+ /* Then put it through another affine transform (Quick C/C++ constants) */
+ output = (((output * 214013) & 0xFFFFFFFF) + 2531011) & 0xFFFFFFFF;
+
+ /* Then rotate and XOR some more */
+ output = ((output << 5) | (output >> (32 - 5)));
+ output = output ^ tweak3;
+
+ return output;
+}
diff --git a/nbase/nbase_str.c b/nbase/nbase_str.c
new file mode 100644
index 0000000..0649bd1
--- /dev/null
+++ b/nbase/nbase_str.c
@@ -0,0 +1,330 @@
+
+/***************************************************************************
+ * nbase_str.c -- string related functions in the nbase library. These *
+ * were written by fyodor@nmap.org . *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#include "nbase.h"
+#include <assert.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#ifndef HAVE_STRCASESTR
+char *strcasestr(const char *haystack, const char *pneedle) {
+ char buf[512];
+ unsigned int needlelen;
+ const char *p;
+ char *needle, *q, *foundto;
+
+ /* Should crash if !pneedle -- this is OK */
+ if (!*pneedle)
+ return (char *)haystack;
+ if (!haystack)
+ return NULL;
+
+ needlelen = (unsigned int)strlen(pneedle);
+ if (needlelen >= sizeof(buf))
+ needle = (char *)safe_malloc(needlelen + 1);
+ else
+ needle = buf;
+
+ p = pneedle;
+ q = needle;
+
+ while ((*q++ = tolower((int)(unsigned char)*p++)))
+ ;
+
+ p = haystack - 1;
+ foundto = needle;
+ while (*++p) {
+ if (tolower((int)(unsigned char)*p) == *foundto) {
+ if (!*++foundto) {
+ /* Yeah, we found it */
+ if (needlelen >= sizeof(buf))
+ free(needle);
+ return (char *)(p - needlelen + 1);
+ }
+ } else {
+ p -= foundto - needle;
+ foundto = needle;
+ }
+ }
+ if (needlelen >= sizeof(buf))
+ free(needle);
+ return NULL;
+}
+#endif
+
+int Strncpy(char *dest, const char *src, size_t n) {
+ strncpy(dest, src, n);
+ if (dest[n - 1] == '\0')
+ return 0;
+ dest[n - 1] = '\0';
+ return -1;
+}
+
+int Vsnprintf(char *s, size_t n, const char *fmt, va_list ap) {
+ int ret;
+
+ ret = vsnprintf(s, n, fmt, ap);
+
+ if (ret < 0 || (unsigned)ret >= n)
+ s[n - 1] = '\0'; /* technically redundant */
+
+ return ret;
+}
+
+int Snprintf(char *s, size_t n, const char *fmt, ...) {
+ va_list ap;
+ int ret;
+
+ va_start(ap, fmt);
+ ret = Vsnprintf(s, n, fmt, ap);
+ va_end(ap);
+
+ return ret;
+}
+
+/* Make a new allocated null-terminated string from the bytes [start, end). */
+char *mkstr(const char *start, const char *end) {
+ char *s;
+
+ assert(end >= start);
+ s = (char *)safe_malloc(end - start + 1);
+ memcpy(s, start, end - start);
+ s[end - start] = '\0';
+
+ return s;
+}
+
+/* Like strchr, but don't go past end. Nulls not handled specially. */
+const char *strchr_p(const char *str, const char *end, char c) {
+ const char *q=str;
+ assert(str && end >= str);
+ for (; q < end; q++) {
+ if (*q == c)
+ return q;
+ }
+ return NULL;
+}
+
+/* vsprintf into a dynamically allocated buffer, similar to asprintf in
+ Glibc. Return the length of the buffer or -1 on error. */
+int alloc_vsprintf(char **strp, const char *fmt, va_list va) {
+ va_list va_tmp;
+ char *s;
+ int size = 32;
+ int n;
+
+ s = NULL;
+ size = 32;
+ for (;;) {
+ s = (char *)safe_realloc(s, size);
+
+#ifdef WIN32
+ va_tmp = va;
+#else
+ va_copy(va_tmp, va);
+#endif
+ n = vsnprintf(s, size, fmt, va_tmp);
+ va_end(va_tmp);
+
+ if (n >= size)
+ size = n + 1;
+ else if (n < 0)
+ size = size * 2;
+ else
+ break;
+ }
+ *strp = s;
+
+ return n;
+}
+
+/* Used by escape_windows_command_arg to append a character to the given buffer
+ at a given position, resizing the buffer if necessary. The position gets
+ moved by one byte after the call. */
+static char* safe_append_char(char* buf, char byte, unsigned int *rpos, unsigned int *rsize)
+{
+ if (*rpos >= *rsize) {
+ *rsize += 512;
+ buf = (char*) safe_realloc(buf, *rsize);
+ }
+ buf[(*rpos)++] = byte;
+ return buf;
+}
+
+/* Escape a string so that it can be round-tripped into a command line string
+ and retrieved by the default C/C++ command line parser. You can escape a list
+ of strings with this function, join them with spaces, pass them to
+ CreateProcess, and the new process will get the same list of strings in its
+ argv array.
+
+ http://msdn.microsoft.com/en-us/library/17w5ykft%28v=vs.85%29.aspx
+ http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
+
+ Returns a dynamically allocated string.
+
+ This function has a test program in test/test-escape_windows_command_arg.c.
+ Run that program after making any changes. */
+char *escape_windows_command_arg(const char *arg)
+{
+ const char *p;
+ char *ret;
+ unsigned int rpos = 0, rsize = 1;
+
+ ret = (char *) safe_malloc(rsize);
+ ret = safe_append_char(ret, '"', &rpos, &rsize);
+
+ for (p = arg; *p != '\0'; p++) {
+ unsigned int num_backslashes;
+ unsigned int i;
+
+ num_backslashes = 0;
+ for (; *p == '\\'; p++)
+ num_backslashes++;
+
+ if (*p == '\0') {
+ /* Escape all backslashes, but let the terminating double quotation
+ mark we add below be interpreted as a metacharacter. */
+ for (i = 0; i < num_backslashes*2; i++)
+ ret = safe_append_char(ret, '\\', &rpos, &rsize);
+ break;
+ } else if (*p == '"') {
+ /* Escape all backslashes and the following double quotation
+ mark. */
+ for (i = 0; i < num_backslashes*2 + 1; i++)
+ ret = safe_append_char(ret, '\\', &rpos, &rsize);
+ ret[rpos++] = *p;
+ } else {
+ /* Backslashes aren't special here. */
+ for (i = 0; i < num_backslashes; i++)
+ ret = safe_append_char(ret, '\\', &rpos, &rsize);
+ ret = safe_append_char(ret, *p, &rpos, &rsize);
+ }
+ }
+
+ ret = safe_append_char(ret, '"', &rpos, &rsize);
+ ret = safe_append_char(ret, '\0', &rpos, &rsize);
+
+ return ret;
+}
+
+/* Convert non-printable characters to replchar in the string */
+void replacenonprintable(char *str, int strlength, char replchar) {
+ int i;
+
+ for (i = 0; i < strlength; i++)
+ if (!isprint((int)(unsigned char)str[i]))
+ str[i] = replchar;
+
+ return;
+}
+
+/* Returns the position of the last directory separator (slash, also backslash
+ on Win32) in a path. Returns -1 if none was found. */
+static int find_last_path_separator(const char *path) {
+#ifndef WIN32
+ const char *PATH_SEPARATORS = "/";
+#else
+ const char *PATH_SEPARATORS = "\\/";
+#endif
+ const char *p;
+
+ p = path + strlen(path) - 1;
+ while (p >= path) {
+ if (strchr(PATH_SEPARATORS, *p) != NULL)
+ return (int)(p - path);
+ p--;
+ }
+
+ return -1;
+}
+
+/* Returns the directory name part of a path (everything up to the last
+ directory separator). If there is no separator, returns ".". If there is only
+ one separator and it is the first character, returns "/". Returns NULL on
+ error. The returned string must be freed. */
+char *path_get_dirname(const char *path) {
+ char *result;
+ int i;
+
+ i = find_last_path_separator(path);
+ if (i == -1)
+ return strdup(".");
+ if (i == 0)
+ return strdup("/");
+
+ result = (char *)safe_malloc(i + 1);
+ strncpy(result, path, i);
+ result[i] = '\0';
+
+ return result;
+}
+
+/* Returns the file name part of a path (everything after the last directory
+ separator). Returns NULL on error. The returned string must be freed. */
+char *path_get_basename(const char *path) {
+ int i;
+
+ i = find_last_path_separator(path);
+
+ return strdup(path + i + 1);
+}
diff --git a/nbase/nbase_time.c b/nbase/nbase_time.c
new file mode 100644
index 0000000..eb1b902
--- /dev/null
+++ b/nbase/nbase_time.c
@@ -0,0 +1,215 @@
+
+/***************************************************************************
+ * nbase_time.c -- Some small time-related utility/compatibility *
+ * functions. *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#include "nbase.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <time.h>
+#ifdef WIN32
+#include <sys/timeb.h>
+#include <winsock2.h>
+#endif
+
+#ifndef HAVE_USLEEP
+void usleep(unsigned long usec) {
+#ifdef HAVE_NANOSLEEP
+struct timespec ts;
+ts.tv_sec = usec / 1000000;
+ts.tv_nsec = (usec % 1000000) * 1000;
+nanosleep(&ts, NULL);
+#else /* Windows style */
+ Sleep( usec / 1000 );
+#endif /* HAVE_NANOSLEEP */
+}
+#endif
+
+/* Thread safe time stuff */
+#ifdef WIN32
+/* On Windows, use CRT function localtime_s:
+ * errno_t localtime_s(
+ * struct tm* const tmDest,
+ * time_t const* const sourceTime
+ * );
+ */
+int n_localtime(const time_t *timer, struct tm *result) {
+ return localtime_s(result, timer);
+}
+
+int n_gmtime(const time_t *timer, struct tm *result) {
+ return gmtime_s(result, timer);
+}
+
+int n_ctime(char *buffer, size_t bufsz, const time_t *timer) {
+ return ctime_s(buffer, bufsz, timer);
+}
+
+#else /* WIN32 */
+
+#include <errno.h>
+#ifdef HAVE_LOCALTIME_S
+/* C11 localtime_s similar to Posix localtime_r, but with validity checking:
+ * struct tm *localtime_s(const time_t *restrict time, struct tm *restrict result);
+ */
+int n_localtime(const time_t *timer, struct tm *result) {
+ struct tm *tmp = localtime_s(timer, result);
+ if (!tmp) {
+ return errno;
+ }
+ return 0;
+}
+
+int n_gmtime(const time_t *timer, struct tm *result) {
+ struct tm *tmp = gmtime_s(timer, result);
+ if (!tmp) {
+ return errno;
+ }
+ return 0;
+}
+
+int n_ctime(char *buffer, size_t bufsz, const time_t *timer) {
+ return ctime_s(buffer, bufsz, timer);
+}
+#else
+#ifdef HAVE_LOCALTIME_R
+/* POSIX localtime_r thread-safe localtime function:
+ * struct tm *localtime_r(const time_t *timep, struct tm *result);
+ */
+int n_localtime(const time_t *timer, struct tm *result) {
+ struct tm *tmp = localtime_r(timer, result);
+ if (!tmp) {
+ return errno;
+ }
+ return 0;
+}
+
+int n_gmtime(const time_t *timer, struct tm *result) {
+ struct tm *tmp = gmtime_r(timer, result);
+ if (!tmp) {
+ return errno;
+ }
+ return 0;
+}
+
+int n_ctime(char *buffer, size_t bufsz, const time_t *timer) {
+ char *tmp = ctime_r(timer, buffer);
+ if (!tmp) {
+ return errno;
+ }
+ return 0;
+}
+
+#else
+/* No thread-safe alternatives. */
+// Using C99's one-line commments since LGTM.com does not recognize C-style
+// block comments. This may cause problems, but only for very old systems
+// without a C99-compatible compiler that do not have localtime_r or
+// localtime_s
+int n_localtime(const time_t *timer, struct tm *result) {
+ struct tm *tmp = localtime(timer); // lgtm[cpp/potentially-dangerous-function]
+ if (tmp)
+ *result = *tmp;
+ else
+ return errno;
+ return 0;
+}
+
+int n_gmtime(const time_t *timer, struct tm *result) {
+ struct tm *tmp = gmtime(timer); // lgtm[cpp/potentially-dangerous-function]
+ if (tmp)
+ *result = *tmp;
+ else
+ return errno;
+ return 0;
+}
+
+int n_ctime(char *buffer, size_t bufsz, const time_t *timer) {
+ char *tmp = ctime(timer); // lgtm[cpp/potentially-dangerous-function]
+ if (tmp)
+ Strncpy(buffer, tmp, bufsz);
+ else
+ return errno;
+ return 0;
+}
+#endif /* HAVE_LOCALTIME_R */
+#endif /* HAVE_LOCALTIME_S */
+#endif /* WIN32 */
+
+#ifdef WIN32
+int gettimeofday(struct timeval *tv, struct timeval *tz)
+{
+ struct _timeb timebuffer;
+
+ _ftime( &timebuffer );
+
+ tv->tv_sec = (long) timebuffer.time;
+ tv->tv_usec = timebuffer.millitm * 1000;
+ return 0;
+};
+
+unsigned int sleep(unsigned int seconds)
+{
+ Sleep(1000*seconds);
+ return(0);
+};
+#endif /* WIN32 */
+
diff --git a/nbase/nbase_winconfig.h b/nbase/nbase_winconfig.h
new file mode 100644
index 0000000..e9678a6
--- /dev/null
+++ b/nbase/nbase_winconfig.h
@@ -0,0 +1,156 @@
+/***************************************************************************
+ * nbase_winconfig.h -- Since the Windows port is currently eschewing *
+ * autoconf-style configure scripts, nbase_winconfig.h contains the *
+ * platform-specific definitions for Windows and is used as a replacement *
+ * for nbase_config.h *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#ifndef NBASE_WINCONFIG_H
+#define NBASE_WINCONFIG_H
+
+/* Define the earliest version of Windows we support. These control
+what parts of the Windows API are available. The available constants
+are in <sdkddkver.h>.
+http://msdn.microsoft.com/en-us/library/aa383745.aspx
+http://blogs.msdn.com/oldnewthing/archive/2007/04/11/2079137.aspx */
+#undef _WIN32_WINNT
+#define _WIN32_WINNT _WIN32_WINNT_WIN7
+#undef NTDDI_VERSION
+#define NTDDI_VERSION NTDDI_WIN7
+
+//This disables the warning 4800 http://msdn.microsoft.com/en-us/library/b6801kcy(v=vs.71).aspx
+#pragma warning(disable : 4800)
+/* It doesn't really have struct IP, but we use a different one instead
+ of the one that comes with Nmap */
+#define HAVE_STRUCT_IP 1
+/* #define HAVE_STRUCT_ICMP 1 */
+#define HAVE_STRNCASECMP 1
+#define HAVE_IP_IP_SUM 1
+#define STDC_HEADERS 1
+#define HAVE_STRING_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_FCNTL_H 1
+#define HAVE_ERRNO_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_MEMCPY 1
+#define HAVE_STRERROR 1
+/* #define HAVE_SYS_SOCKIO_H 1 */
+/* #undef HAVE_TERMIOS_H */
+#define HAVE_ERRNO_H 1
+#define HAVE_GAI_STRERROR 1
+/* #define HAVE_STRCASESTR 1 */
+#define HAVE_STRCASECMP 1
+#define HAVE_NETINET_IF_ETHER_H 1
+#define HAVE_SYS_STAT_H 1
+/* #define HAVE_INTTYPES_H */
+
+/* These functions are available on Vista and later */
+#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN6
+#define HAVE_INET_PTON 1
+#define HAVE_INET_NTOP 1
+#endif
+
+#ifdef _MSC_VER
+/* <wspiapi.h> only comes with Visual Studio. */
+#define HAVE_WSPIAPI_H 1
+#else
+#undef HAVE_WSPIAPI_H
+#endif
+
+#define HAVE_GETADDRINFO 1
+#define HAVE_GETNAMEINFO 1
+
+#define HAVE_SNPRINTF 1
+// #undef HAVE_VASPRINTF
+#define HAVE_VSNPRINTF 1
+
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+typedef signed __int8 int8_t;
+typedef signed __int16 int16_t;
+typedef signed __int32 int32_t;
+typedef signed __int64 int64_t;
+
+#define HAVE_IPV6 1
+#define HAVE_AF_INET6 1
+#define HAVE_SOCKADDR_STORAGE 1
+
+/* Without these, Windows will give us all sorts of crap about using functions
+ like strcpy() even if they are done safely */
+#define _CRT_SECURE_NO_DEPRECATE 1
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS 1
+#endif
+#pragma warning(disable: 4996)
+
+#ifdef __GNUC__
+#define bzero(addr, num) __builtin_memset (addr, '\0', num)
+#else
+#define __attribute__(x)
+#endif
+
+#define HAVE_OPENSSL 1
+#define HAVE_DTLS_CLIENT_METHOD 1
+#define HAVE_SSL_SET_TLSEXT_HOST_NAME 1
+/* Apparently __func__ isn't yet supported */
+#define __func__ __FUNCTION__
+
+#endif /* NBASE_WINCONFIG_H */
diff --git a/nbase/nbase_winunix.c b/nbase/nbase_winunix.c
new file mode 100644
index 0000000..a20a506
--- /dev/null
+++ b/nbase/nbase_winunix.c
@@ -0,0 +1,214 @@
+/***************************************************************************
+ * nbase_winunix.h -- Background code that allows checking for input on *
+ * stdin on Windows without blocking. *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#include <assert.h>
+
+#include "nbase.h"
+
+#include "nbase_winunix.h"
+
+/*
+This code makes it possible to check for input on stdin on Windows without
+blocking. There are two obstacles that need to be overcome. The first is that
+select on Windows works for sockets only, not stdin. The other is that the
+Windows command shell doesn't echo typed characters to the screen unless the
+program is actively reading from stdin (which would normally mean blocking).
+
+The strategy is to create a background thread that constantly reads from stdin.
+The thread blocks while reading, which lets characters be echoed. The thread
+writes each block of data into an anonymous pipe. We juggle file descriptors and
+Windows file handles to make the rest of the program think that the other end of
+the pipe is stdin. Only the thread keeps a reference to the real stdin. Windows
+has a PeekNamedPipe function that we use to check for input in the pipe without
+blocking.
+
+Call win_stdin_start_thread to start the thread and win_stdin_ready for the
+non-blocking input check. Any other operations on stdin (read, scanf, etc.)
+should be transparent, except I noticed that eof(0) returns 1 when there is
+nothing in the pipe, but will return 0 again if more is written to the pipe. Any
+data buffered but not delivered to the program before starting the background
+thread may be lost when the thread is started.
+*/
+
+/* The background thread that reads and buffers the true stdin. */
+static HANDLE stdin_thread = NULL;
+
+/* This is a copy of the true stdin file handle before any redirection. It is
+ read by the thread. */
+static HANDLE thread_stdin_handle = NULL;
+/* The thread writes to this pipe and standard input is reassigned to be the
+ read end of it. */
+static HANDLE stdin_pipe_r = NULL, stdin_pipe_w = NULL;
+
+/* This is the thread that reads from the true stdin (thread_stdin_handle) and
+ writes to stdin_pipe_w, which is reassigned to be the stdin that the rest of
+ the program sees. Once started, it never finishes except in case of error.
+ win_stdin_start_thread is responsible for setting up thread_stdin_handle. */
+static DWORD WINAPI win_stdin_thread_func(void *data) {
+ DWORD n, nwritten;
+ char buffer[BUFSIZ];
+
+ for (;;) {
+ if (ReadFile(thread_stdin_handle, buffer, sizeof(buffer), &n, NULL) == 0)
+ break;
+ if (n == -1 || n == 0)
+ break;
+
+ if (WriteFile(stdin_pipe_w, buffer, n, &nwritten, NULL) == 0)
+ break;
+ if (nwritten != n)
+ break;
+ }
+ CloseHandle(thread_stdin_handle);
+ CloseHandle(stdin_pipe_w);
+
+ return 0;
+}
+
+/* Get the newline translation mode (_O_TEXT or _O_BINARY) of a file
+ descriptor. _O_TEXT does CRLF-LF translation and _O_BINARY does none.
+ Complementary to _setmode. */
+static int _getmode(int fd)
+{
+ int mode;
+
+ /* There is no standard _getmode function, but _setmode returns the
+ previous value. Set it to a dummy value and set it back. */
+ mode = _setmode(fd, _O_BINARY);
+ _setmode(fd, mode);
+
+ return mode;
+}
+
+/* Start the reader thread and do all the file handle/descriptor redirection.
+ Returns nonzero on success, zero on error. */
+int win_stdin_start_thread(void) {
+ int stdin_fd;
+ int stdin_fmode;
+
+ assert(stdin_thread == NULL);
+ assert(stdin_pipe_r == NULL);
+ assert(stdin_pipe_w == NULL);
+ assert(thread_stdin_handle == NULL);
+
+ /* Create the pipe that win_stdin_thread_func writes to. We reassign the
+ read end to be the new stdin that the rest of the program sees. */
+ if (CreatePipe(&stdin_pipe_r, &stdin_pipe_w, NULL, 0) == 0)
+ return 0;
+
+ /* Make a copy of the stdin handle to be used by win_stdin_thread_func. It
+ will remain a reference to the the true stdin after we fake stdin to read
+ from the pipe instead. */
+ if (DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE),
+ GetCurrentProcess(), &thread_stdin_handle,
+ 0, FALSE, DUPLICATE_SAME_ACCESS) == 0) {
+ CloseHandle(stdin_pipe_r);
+ CloseHandle(stdin_pipe_w);
+ return 0;
+ }
+
+ /* Set the stdin handle to read from the pipe. */
+ if (SetStdHandle(STD_INPUT_HANDLE, stdin_pipe_r) == 0) {
+ CloseHandle(stdin_pipe_r);
+ CloseHandle(stdin_pipe_w);
+ CloseHandle(thread_stdin_handle);
+ return 0;
+ }
+ /* Need to redirect file descriptor 0 also. _open_osfhandle makes a new file
+ descriptor from an existing handle. */
+ /* Remember the newline translation mode (_O_TEXT or _O_BINARY), and
+ restore it in the new file descriptor. */
+ stdin_fmode = _getmode(STDIN_FILENO);
+ stdin_fd = _open_osfhandle((intptr_t) GetStdHandle(STD_INPUT_HANDLE), _O_RDONLY | stdin_fmode);
+ if (stdin_fd == -1) {
+ CloseHandle(stdin_pipe_r);
+ CloseHandle(stdin_pipe_w);
+ CloseHandle(thread_stdin_handle);
+ return 0;
+ }
+ dup2(stdin_fd, STDIN_FILENO);
+
+ /* Finally, start up the thread. We don't bother keeping a reference to it
+ because it runs until program termination. From here on out all reads
+ from the stdin handle or file descriptor 0 will be reading from the
+ anonymous pipe that is fed by the thread. */
+ stdin_thread = CreateThread(NULL, 0, win_stdin_thread_func, NULL, 0, NULL);
+ if (stdin_thread == NULL) {
+ CloseHandle(stdin_pipe_r);
+ CloseHandle(stdin_pipe_w);
+ CloseHandle(thread_stdin_handle);
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Check if input is available on stdin, once all the above has taken place. */
+int win_stdin_ready(void) {
+ DWORD n;
+
+ assert(stdin_pipe_r != NULL);
+
+ if (!PeekNamedPipe(stdin_pipe_r, NULL, 0, NULL, &n, NULL))
+ return 1;
+
+ return n > 0;
+}
diff --git a/nbase/nbase_winunix.h b/nbase/nbase_winunix.h
new file mode 100644
index 0000000..9b2230c
--- /dev/null
+++ b/nbase/nbase_winunix.h
@@ -0,0 +1,196 @@
+/***************************************************************************
+ * nbase_winunix.h -- Misc. compatibility routines that generally try to *
+ * reproduce UNIX-centric concepts on Windows. *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#ifndef NBASE_WINUNIX_H
+#define NBASE_WINUNIX_H
+
+
+#include "nbase_winconfig.h"
+
+/* Winsock defines its own error codes that are analogous to but
+ different from those in <errno.h>. The error macros have similar
+ names, for example
+ EINTR -> WSAEINTR
+ ECONNREFUSED -> WSAECONNREFUSED
+ But the values are different. The errno codes are small integers,
+ while the Winsock codes start at 10000 or so.
+ http://msdn.microsoft.com/en-us/library/ms737828
+
+ Later in this file there is a block of code that defines the errno
+ names to their Winsock equivalents, so that you can write code using
+ the errno names only, and have it still work on Windows. However this
+ causes some problems that are worked around in the following few
+ lines. First, we prohibit the inclusion of <errno.h>, so that the
+ only error codes visible are those we explicitly define in this file.
+ This will cause a compilation error if someone uses a code we're not
+ yet aware of instead of using an incompatible value at runtime.
+ Second, because <errno.h> is not defined, the C++0x header
+ <system_error> doesn't compile, so we pretend not to have C++0x to
+ avoid it. */
+#if _MSC_VER < 1600 /* Breaks on VS2010 and later */
+#define _INC_ERRNO /* suppress errno.h */
+#define _ERRNO_H_ /* Also for errno.h suppression */
+#define _SYSTEM_ERROR_
+#undef _HAS_CPP0X
+#define _HAS_CPP0X 0
+#else
+/* VS2013: we include errno.h, then redefine the constants we want.
+ * This may work in other versions, but haven't tested (since the other method
+ * has been working just fine). */
+#include <errno.h>
+#endif
+
+/* Suppress winsock.h */
+#define _WINSOCKAPI_
+#define WIN32_LEAN_AND_MEAN
+
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2tcpip.h> /* IPv6 stuff */
+#if HAVE_WSPIAPI_H
+/* <wspiapi.h> is necessary for getaddrinfo before Windows XP, but it isn't
+ available on some platforms like MinGW. */
+#include <wspiapi.h>
+#endif
+#include <time.h>
+#include <iptypes.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <io.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <process.h>
+#include <limits.h>
+#include <WINCRYPT.H>
+#include <math.h>
+
+
+#define SIOCGIFCONF 0x8912 /* get iface list */
+
+#ifndef GLOBALS
+#define GLOBALS 1
+
+#endif
+
+#define munmap(ptr, len) win32_munmap(ptr, len)
+
+/* Windows error message names */
+#undef ECONNABORTED
+#define ECONNABORTED WSAECONNABORTED
+#undef ECONNRESET
+#define ECONNRESET WSAECONNRESET
+#undef ECONNREFUSED
+#define ECONNREFUSED WSAECONNREFUSED
+#undef EAGAIN
+#define EAGAIN WSAEWOULDBLOCK
+#undef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#undef EHOSTUNREACH
+#define EHOSTUNREACH WSAEHOSTUNREACH
+#undef ENETDOWN
+#define ENETDOWN WSAENETDOWN
+#undef ENETUNREACH
+#define ENETUNREACH WSAENETUNREACH
+#undef ENETRESET
+#define ENETRESET WSAENETRESET
+#undef ETIMEDOUT
+#define ETIMEDOUT WSAETIMEDOUT
+#undef EHOSTDOWN
+#define EHOSTDOWN WSAEHOSTDOWN
+#undef EINPROGRESS
+#define EINPROGRESS WSAEINPROGRESS
+#undef EINVAL
+#define EINVAL WSAEINVAL /* Invalid argument */
+#undef EPERM
+#define EPERM WSAEACCES /* Operation not permitted */
+#undef EACCES
+#define EACCES WSAEACCES /* Operation not permitted */
+#undef EINTR
+#define EINTR WSAEINTR /* Interrupted system call */
+#undef ENOBUFS
+#define ENOBUFS WSAENOBUFS /* No buffer space available */
+#undef EMSGSIZE
+#define EMSGSIZE WSAEMSGSIZE /* Message too long */
+#undef ENOMEM
+#define ENOMEM WSAENOBUFS
+#undef ENOTSOCK
+#define ENOTSOCK WSAENOTSOCK
+#undef EOPNOTSUPP
+#define EOPNOTSUPP WSAEOPNOTSUPP
+#undef EIO
+#define EIO WSASYSCALLFAILURE
+
+/*
+This is not used by our network code, and causes problems in programs using
+Nbase that legitimately use ENOENT for file operations.
+#undef ENOENT
+#define ENOENT WSAENOENT
+*/
+
+#define close(x) closesocket(x)
+
+typedef unsigned short u_short_t;
+
+int win_stdin_start_thread(void);
+int win_stdin_ready(void);
+
+#endif /* NBASE_WINUNIX_H */
diff --git a/nbase/snprintf.c b/nbase/snprintf.c
new file mode 100644
index 0000000..0680786
--- /dev/null
+++ b/nbase/snprintf.c
@@ -0,0 +1,647 @@
+/* Note -- this file was obtained from tcpdump-2000-9-17 CVS snapshot *
+ * ( www.tcpdump.org). It has been modified slightly for *
+ * compatibility with libnbase. Modification details may be in the *
+ * nbase CHANGELOG - fyodor@nmap.org */
+
+
+/*
+ * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* $Id$ */
+
+#if HAVE_CONFIG_H
+#include "nbase_config.h"
+#else
+#ifdef WIN32
+#include "nbase_winconfig.h"
+#endif /* WIN32 */
+#endif /* HAVE_CONFIG_H */
+
+#ifndef lint
+static const char rcsid[] __attribute__((unused)) =
+ "@(#) $Header$";
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/types.h>
+
+#if HAVE_LIBIBERTY_H
+#include <libiberty.h>
+#endif
+
+#include "nbase.h"
+
+#ifndef min
+#define min(a,b) ((a)>(b)?(b):(a))
+#endif
+#ifndef max
+#define max(a,b) ((b)>(a)?(b):(a))
+#endif
+
+enum format_flags {
+ minus_flag = 1,
+ plus_flag = 2,
+ space_flag = 4,
+ alternate_flag = 8,
+ zero_flag = 16
+};
+
+/*
+ * Common state
+ */
+
+struct state {
+ unsigned char *str;
+ unsigned char *s;
+ unsigned char *theend;
+ size_t sz;
+ size_t max_sz;
+ int (*append_char)(struct state *, unsigned char);
+ int (*reserve)(struct state *, size_t);
+ /* XXX - methods */
+};
+
+#ifndef HAVE_VSNPRINTF
+static int
+sn_reserve (struct state *state, size_t n)
+{
+ return state->s + n > state->theend;
+}
+
+static int
+sn_append_char (struct state *state, unsigned char c)
+{
+ if (sn_reserve (state, 1)) {
+ return 1;
+ } else {
+ *state->s++ = c;
+ return 0;
+ }
+}
+#endif
+
+static int
+as_reserve (struct state *state, size_t n)
+{
+ if (state->s + n > state->theend) {
+ int off = state->s - state->str;
+ unsigned char *tmp;
+
+ if (state->max_sz && state->sz >= state->max_sz)
+ return 1;
+
+ state->sz = max(state->sz * 2, state->sz + n);
+ if (state->max_sz)
+ state->sz = min(state->sz, state->max_sz);
+ tmp = safe_realloc(state->str, state->sz);
+ state->str = tmp;
+ state->s = state->str + off;
+ state->theend = state->str + state->sz - 1;
+ }
+ return 0;
+}
+
+static int
+as_append_char (struct state *state, unsigned char c)
+{
+ if(as_reserve (state, 1))
+ return 1;
+ else {
+ *state->s++ = c;
+ return 0;
+ }
+}
+
+static int
+append_number(struct state *state,
+ unsigned long num, unsigned base, char *rep,
+ int width, int prec, int flags, int minusp)
+{
+ int len = 0;
+ int i;
+
+ /* given precision, ignore zero flag */
+ if(prec != -1)
+ flags &= ~zero_flag;
+ else
+ prec = 1;
+ /* zero value with zero precision -> "" */
+ if(prec == 0 && num == 0)
+ return 0;
+ do{
+ if((*state->append_char)(state, rep[num % base]))
+ return 1;
+ len++;
+ num /= base;
+ }while(num);
+ prec -= len;
+ /* pad with prec zeros */
+ while(prec-- > 0){
+ if((*state->append_char)(state, '0'))
+ return 1;
+ len++;
+ }
+ /* add length of alternate prefix (added later) to len */
+ if(flags & alternate_flag && (base == 16 || base == 8))
+ len += base / 8;
+ /* pad with zeros */
+ if(flags & zero_flag){
+ width -= len;
+ if(minusp || (flags & space_flag) || (flags & plus_flag))
+ width--;
+ while(width-- > 0){
+ if((*state->append_char)(state, '0'))
+ return 1;
+ len++;
+ }
+ }
+ /* add alternate prefix */
+ if(flags & alternate_flag && (base == 16 || base == 8)){
+ if(base == 16)
+ if((*state->append_char)(state, rep[10] + 23)) /* XXX */
+ return 1;
+ if((*state->append_char)(state, '0'))
+ return 1;
+ }
+ /* add sign */
+ if(minusp){
+ if((*state->append_char)(state, '-'))
+ return 1;
+ len++;
+ } else if(flags & plus_flag) {
+ if((*state->append_char)(state, '+'))
+ return 1;
+ len++;
+ } else if(flags & space_flag) {
+ if((*state->append_char)(state, ' '))
+ return 1;
+ len++;
+ }
+ if(flags & minus_flag)
+ /* swap before padding with spaces */
+ for(i = 0; i < len / 2; i++){
+ char c = state->s[-i-1];
+ state->s[-i-1] = state->s[-len+i];
+ state->s[-len+i] = c;
+ }
+ width -= len;
+ while(width-- > 0){
+ if((*state->append_char)(state, ' '))
+ return 1;
+ len++;
+ }
+ if(!(flags & minus_flag))
+ /* swap after padding with spaces */
+ for(i = 0; i < len / 2; i++){
+ char c = state->s[-i-1];
+ state->s[-i-1] = state->s[-len+i];
+ state->s[-len+i] = c;
+ }
+
+ return 0;
+}
+
+static int
+append_string (struct state *state,
+ unsigned char *arg,
+ int width,
+ int prec,
+ int flags)
+{
+ if(!arg)
+ arg = (unsigned char *) "(null)";
+ if(prec != -1)
+ width -= prec;
+ else
+ width -= strlen((char *)arg);
+ if(!(flags & minus_flag))
+ while(width-- > 0)
+ if((*state->append_char) (state, ' '))
+ return 1;
+ if (prec != -1) {
+ while (*arg && prec--)
+ if ((*state->append_char) (state, *arg++))
+ return 1;
+ } else {
+ while (*arg)
+ if ((*state->append_char) (state, *arg++))
+ return 1;
+ }
+ if(flags & minus_flag)
+ while(width-- > 0)
+ if((*state->append_char) (state, ' '))
+ return 1;
+ return 0;
+}
+
+static int
+append_char(struct state *state,
+ unsigned char arg,
+ int width,
+ int flags)
+{
+ while(!(flags & minus_flag) && --width > 0)
+ if((*state->append_char) (state, ' '))
+ return 1;
+
+ if((*state->append_char) (state, arg))
+ return 1;
+ while((flags & minus_flag) && --width > 0)
+ if((*state->append_char) (state, ' '))
+ return 1;
+
+ return 0;
+}
+
+/*
+ * This can't be made into a function...
+ */
+
+#define PARSE_INT_FORMAT(res, arg, unsig) \
+if (long_flag) \
+ res = (unsig long)va_arg(arg, unsig long); \
+else if (short_flag) \
+ res = (unsig short)va_arg(arg, unsig int); \
+else \
+ res = (unsig int)va_arg(arg, unsig int)
+
+/*
+ * zyxprintf - return 0 or -1
+ */
+
+static int
+xyzprintf (struct state *state, const char *char_format, va_list ap)
+{
+ const unsigned char *format = (const unsigned char *)char_format;
+ unsigned char c;
+
+ while((c = *format++)) {
+ if (c == '%') {
+ int flags = 0;
+ int width = 0;
+ int prec = -1;
+ int long_flag = 0;
+ int short_flag = 0;
+
+ /* flags */
+ while((c = *format++)){
+ if(c == '-')
+ flags |= minus_flag;
+ else if(c == '+')
+ flags |= plus_flag;
+ else if(c == ' ')
+ flags |= space_flag;
+ else if(c == '#')
+ flags |= alternate_flag;
+ else if(c == '0')
+ flags |= zero_flag;
+ else
+ break;
+ }
+
+ if((flags & space_flag) && (flags & plus_flag))
+ flags ^= space_flag;
+
+ if((flags & minus_flag) && (flags & zero_flag))
+ flags ^= zero_flag;
+
+ /* width */
+ if (isdigit((int) c))
+ do {
+ width = width * 10 + c - '0';
+ c = *format++;
+ } while(isdigit((int) c));
+ else if(c == '*') {
+ width = va_arg(ap, int);
+ c = *format++;
+ }
+
+ /* precision */
+ if (c == '.') {
+ prec = 0;
+ c = *format++;
+ if (isdigit((int) c))
+ do {
+ prec = prec * 10 + c - '0';
+ c = *format++;
+ } while(isdigit((int) c));
+ else if (c == '*') {
+ prec = va_arg(ap, int);
+ c = *format++;
+ }
+ }
+
+ /* size */
+
+ if (c == 'h') {
+ short_flag = 1;
+ c = *format++;
+ } else if (c == 'l') {
+ long_flag = 1;
+ c = *format++;
+ }
+
+ switch (c) {
+ case 'c' :
+ if(append_char(state, va_arg(ap, int), width, flags))
+ return -1;
+ break;
+ case 's' :
+ if (append_string(state,
+ va_arg(ap, unsigned char*),
+ width,
+ prec,
+ flags))
+ return -1;
+ break;
+ case 'd' :
+ case 'i' : {
+ long arg;
+ unsigned long num;
+ int minusp = 0;
+
+ PARSE_INT_FORMAT(arg, ap, signed);
+
+ if (arg < 0) {
+ minusp = 1;
+ num = -arg;
+ } else
+ num = arg;
+
+ if (append_number (state, num, 10, "0123456789",
+ width, prec, flags, minusp))
+ return -1;
+ break;
+ }
+ case 'u' : {
+ unsigned long arg;
+
+ PARSE_INT_FORMAT(arg, ap, unsigned);
+
+ if (append_number (state, arg, 10, "0123456789",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'o' : {
+ unsigned long arg;
+
+ PARSE_INT_FORMAT(arg, ap, unsigned);
+
+ if (append_number (state, arg, 010, "01234567",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'x' : {
+ unsigned long arg;
+
+ PARSE_INT_FORMAT(arg, ap, unsigned);
+
+ if (append_number (state, arg, 0x10, "0123456789abcdef",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'X' :{
+ unsigned long arg;
+
+ PARSE_INT_FORMAT(arg, ap, unsigned);
+
+ if (append_number (state, arg, 0x10, "0123456789ABCDEF",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'p' : {
+ unsigned long arg = (unsigned long)va_arg(ap, void*);
+
+ if (append_number (state, arg, 0x10, "0123456789ABCDEF",
+ width, prec, flags, 0))
+ return -1;
+ break;
+ }
+ case 'n' : {
+ int *arg = va_arg(ap, int*);
+ *arg = state->s - state->str;
+ break;
+ }
+ case '\0' :
+ --format;
+ /* FALLTHROUGH */
+ case '%' :
+ if ((*state->append_char)(state, c))
+ return -1;
+ break;
+ default :
+ if ( (*state->append_char)(state, '%')
+ || (*state->append_char)(state, c))
+ return -1;
+ break;
+ }
+ } else
+ if ((*state->append_char) (state, c))
+ return -1;
+ }
+ return 0;
+}
+
+#ifndef HAVE_SNPRINTF
+int
+snprintf (char *str, size_t sz, const char *format, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, format);
+ ret = vsnprintf (str, sz, format, args);
+ va_end(args);
+
+#ifdef PARANOIA
+ {
+ int ret2;
+ char *tmp;
+
+ tmp = safe_malloc (sz);
+
+ va_start(args, format);
+ ret2 = vsprintf (tmp, format, args);
+ va_end(args);
+ if (ret != ret2 || strcmp(str, tmp))
+ abort ();
+ free (tmp);
+ }
+#endif
+
+ return ret;
+}
+#endif
+
+
+#ifndef HAVE_VASNPRINTF
+int
+vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
+{
+ int st;
+ size_t len;
+ struct state state;
+
+ state.max_sz = max_sz;
+ state.sz = 1;
+ state.str = safe_malloc(state.sz);
+ state.s = state.str;
+ state.theend = state.s + state.sz - 1;
+ state.append_char = as_append_char;
+ state.reserve = as_reserve;
+
+ st = xyzprintf (&state, format, args);
+ if (st) {
+ free (state.str);
+ *ret = NULL;
+ return -1;
+ } else {
+ char *tmp;
+
+ *state.s = '\0';
+ len = state.s - state.str;
+ tmp = safe_realloc(state.str, len+1);
+ if (tmp == NULL) {
+ free (state.str);
+ *ret = NULL;
+ return -1;
+ }
+ *ret = tmp;
+ return len;
+ }
+}
+#endif
+
+#ifndef HAVE_VASPRINTF
+int
+vasprintf (char **ret, const char *format, va_list args)
+{
+ return vasnprintf (ret, 0, format, args);
+}
+#endif
+
+#ifndef HAVE_ASPRINTF
+int
+asprintf (char **ret, const char *format, ...)
+{
+ va_list args;
+ int val;
+
+ va_start(args, format);
+ val = vasprintf (ret, format, args);
+ va_end(args);
+
+#ifdef PARANOIA
+ {
+ int ret2;
+ char *tmp;
+ tmp = safe_malloc (val + 1);
+
+ va_start(args, format);
+ ret2 = vsprintf (tmp, format, args);
+ va_end(args);
+ if (val != ret2 || strcmp(*ret, tmp))
+ abort ();
+ free (tmp);
+ }
+#endif
+
+ return val;
+}
+#endif
+
+#ifndef HAVE_ASNPRINTF
+int
+asnprintf (char **ret, size_t max_sz, const char *format, ...)
+{
+ va_list args;
+ int val;
+
+ va_start(args, format);
+ val = vasnprintf (ret, max_sz, format, args);
+ va_end(args);
+
+#ifdef PARANOIA
+ {
+ int ret2;
+ char *tmp;
+ tmp = safe_malloc (val + 1);
+
+ va_start(args, format);
+ ret2 = vsprintf (tmp, format, args);
+ va_end(args);
+ if (val != ret2 || strcmp(*ret, tmp))
+ abort ();
+ free (tmp);
+ }
+#endif
+
+ return val;
+}
+#endif
+
+
+
+#ifndef HAVE_VSNPRINTF
+int
+vsnprintf (char *str, size_t sz, const char *format, va_list args)
+{
+ struct state state;
+ int ret;
+ unsigned char *ustr = (unsigned char *)str;
+
+ state.max_sz = 0;
+ state.sz = sz;
+ state.str = ustr;
+ state.s = ustr;
+ state.theend = ustr + sz - 1;
+ state.append_char = sn_append_char;
+ state.reserve = sn_reserve;
+
+ ret = xyzprintf (&state, format, args);
+ *state.s = '\0';
+ if (ret)
+ return -1;
+ else
+ return state.s - state.str;
+}
+#endif
+
diff --git a/nbase/strcasecmp.c b/nbase/strcasecmp.c
new file mode 100644
index 0000000..94d8535
--- /dev/null
+++ b/nbase/strcasecmp.c
@@ -0,0 +1,114 @@
+
+/***************************************************************************
+ * strcasecmp.c -- strcasecmp and strncasecmp for systems (like Windows) *
+ * which do not already have them. *
+ * *
+ ***********************IMPORTANT NMAP LICENSE TERMS************************
+ *
+ * The Nmap Security Scanner is (C) 1996-2023 Nmap Software LLC ("The Nmap
+ * Project"). Nmap is also a registered trademark of the Nmap Project.
+ *
+ * This program is distributed under the terms of the Nmap Public Source
+ * License (NPSL). The exact license text applying to a particular Nmap
+ * release or source code control revision is contained in the LICENSE
+ * file distributed with that version of Nmap or source code control
+ * revision. More Nmap copyright/legal information is available from
+ * https://nmap.org/book/man-legal.html, and further information on the
+ * NPSL license itself can be found at https://nmap.org/npsl/ . This
+ * header summarizes some key points from the Nmap license, but is no
+ * substitute for the actual license text.
+ *
+ * Nmap is generally free for end users to download and use themselves,
+ * including commercial use. It is available from https://nmap.org.
+ *
+ * The Nmap license generally prohibits companies from using and
+ * redistributing Nmap in commercial products, but we sell a special Nmap
+ * OEM Edition with a more permissive license and special features for
+ * this purpose. See https://nmap.org/oem/
+ *
+ * If you have received a written Nmap license agreement or contract
+ * stating terms other than these (such as an Nmap OEM license), you may
+ * choose to use and redistribute Nmap under those terms instead.
+ *
+ * The official Nmap Windows builds include the Npcap software
+ * (https://npcap.com) for packet capture and transmission. It is under
+ * separate license terms which forbid redistribution without special
+ * permission. So the official Nmap Windows builds may not be redistributed
+ * without special permission (such as an Nmap OEM license).
+ *
+ * Source is provided to this software because we believe users have a
+ * right to know exactly what a program is going to do before they run it.
+ * This also allows you to audit the software for security holes.
+ *
+ * Source code also allows you to port Nmap to new platforms, fix bugs, and add
+ * new features. You are highly encouraged to submit your changes as a Github PR
+ * or by email to the dev@nmap.org mailing list for possible incorporation into
+ * the main distribution. Unless you specify otherwise, it is understood that
+ * you are offering us very broad rights to use your submissions as described in
+ * the Nmap Public Source License Contributor Agreement. This is important
+ * because we fund the project by selling licenses with various terms, and also
+ * because the inability to relicense code has caused devastating problems for
+ * other Free Software projects (such as KDE and NASM).
+ *
+ * The free version of Nmap is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Warranties,
+ * indemnification and commercial support are all available through the
+ * Npcap OEM program--see https://nmap.org/oem/
+ *
+ ***************************************************************************/
+
+/* $Id$ */
+
+#if !defined(HAVE_STRCASECMP) || !defined(HAVE_STRNCASECMP)
+#include <stdlib.h>
+#include <string.h>
+#include "nbase.h"
+#endif
+
+#ifndef HAVE_STRCASECMP
+int strcasecmp(const char *s1, const char *s2)
+{
+ int i, ret;
+ char *cp1, *cp2;
+
+ cp1 = safe_malloc(strlen(s1) + 1);
+ cp2 = safe_malloc(strlen(s2) + 1);
+
+ for (i = 0; i < strlen(s1) + 1; i++)
+ cp1[i] = tolower((int) (unsigned char) s1[i]);
+ for (i = 0; i < strlen(s2) + 1; i++)
+ cp2[i] = tolower((int) (unsigned char) s2[i]);
+
+ ret = strcmp(cp1, cp2);
+
+ free(cp1);
+ free(cp2);
+
+ return ret;
+}
+#endif
+
+#ifndef HAVE_STRNCASECMP
+int strncasecmp(const char *s1, const char *s2, size_t n)
+{
+ int i, ret;
+ char *cp1, *cp2;
+
+ cp1 = safe_malloc(strlen(s1) + 1);
+ cp2 = safe_malloc(strlen(s2) + 1);
+
+ for (i = 0; i < strlen(s1) + 1; i++)
+ cp1[i] = tolower((int) (unsigned char) s1[i]);
+ for (i = 0; i < strlen(s2) + 1; i++)
+ cp2[i] = tolower((int) (unsigned char) s2[i]);
+
+ ret = strncmp(cp1, cp2, n);
+
+ free(cp1);
+ free(cp2);
+
+ return ret;
+}
+#endif
+
diff --git a/nbase/test/nmakefile b/nbase/test/nmakefile
new file mode 100644
index 0000000..bf3f521
--- /dev/null
+++ b/nbase/test/nmakefile
@@ -0,0 +1,13 @@
+# Build nbase in Visual C++ (so ..\nbase.lib exists). Then open a Visual
+# Studio Command Prompt (from the Start menu), and run:
+# nmake /F nmakefile
+
+!include <win32.mak>
+
+all: test-escape_windows_command_arg
+
+.c.obj:
+ $(cc) /c /D WIN32=1 /I .. $*.c
+
+test-escape_windows_command_arg: test-escape_windows_command_arg.obj
+ $(link) /OUT:test-escape_windows_command_arg.exe test-escape_windows_command_arg.obj /NODEFAULTLIB:LIBCMT ..\nbase.lib shell32.lib
diff --git a/nbase/test/test-escape_windows_command_arg.c b/nbase/test/test-escape_windows_command_arg.c
new file mode 100644
index 0000000..4b7bcdc
--- /dev/null
+++ b/nbase/test/test-escape_windows_command_arg.c
@@ -0,0 +1,204 @@
+/*
+Usage: test-escape_windows_command_arg.exe
+
+This is a test program for the escape_windows_command_arg function from
+nbase_str.c. Its code is strictly Windows-specific. Basically, it performs
+escape_windows_command_arg on arrays of strings merging its results with spaces
+and tests if an attempt to decode them with CommandLineToArgvW results in the
+same strings.
+*/
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "nbase.h"
+
+#include <shellapi.h>
+
+const char *TESTS[][5] = {
+ { NULL },
+ {"", NULL},
+ {"", "", NULL},
+ {"1", "2", "3", "4", NULL},
+ {"a", "b", "c", NULL},
+ {"a b", "c", NULL},
+ {"a b c", NULL},
+ {" a b c ", NULL},
+ {"\"quote\"", NULL},
+ {"back\\slash", NULL},
+ {"backslash at end\\", NULL},
+ {"double\"\"quote", NULL},
+ {" a\nb\tc\rd\ne", NULL},
+ {"..\\test\\toupper.lua", NULL},
+ {"backslash at end\\", "som\\ething\"af\\te\\r", NULL},
+ {"three\\\\\\backslashes", "som\\ething\"af\\te\\r", NULL},
+ {"three\"\"\"quotes", "som\\ething\"af\\te\\r", NULL},
+};
+
+static LPWSTR utf8_to_wchar(const char *s)
+{
+ LPWSTR result;
+ int size, ret;
+
+ /* Get needed buffer size. */
+ size = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0);
+ if (size == 0) {
+ fprintf(stderr, "MultiByteToWideChar 1 failed: %d\n", GetLastError());
+ exit(1);
+ }
+ result = (LPWSTR) malloc(sizeof(*result) * size);
+ ret = MultiByteToWideChar(CP_UTF8, 0, s, -1, result, size);
+ if (ret == 0) {
+ fprintf(stderr, "MultiByteToWideChar 2 failed: %d\n", GetLastError());
+ exit(1);
+ }
+
+ return result;
+}
+
+static char *wchar_to_utf8(const LPWSTR s)
+{
+ char *result;
+ int size, ret;
+
+ /* Get needed buffer size. */
+ size = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL);
+ if (size == 0) {
+ fprintf(stderr, "WideCharToMultiByte 1 failed: %d\n", GetLastError());
+ exit(1);
+ }
+ result = (char *) malloc(size);
+ ret = WideCharToMultiByte(CP_UTF8, 0, s, -1, result, size, NULL, NULL);
+ if (ret == 0) {
+ fprintf(stderr, "WideCharToMultiByte 2 failed: %d\n", GetLastError());
+ exit(1);
+ }
+
+ return result;
+}
+
+static char **wchar_to_utf8_array(const LPWSTR a[], unsigned int len)
+{
+ char **result;
+ unsigned int i;
+
+ result = (char **) malloc(sizeof(*result) * len);
+ if (result == NULL)
+ return NULL;
+ for (i = 0; i < len; i++)
+ result[i] = wchar_to_utf8(a[i]);
+
+ return result;
+}
+
+static unsigned int nullarray_length(const char *a[])
+{
+ unsigned int i;
+
+ for (i = 0; a[i] != NULL; i++)
+ ;
+
+ return i;
+}
+
+static char *append(char *p, const char *s)
+{
+ size_t plen, slen;
+
+ plen = strlen(p);
+ slen = strlen(s);
+ p = (char *) realloc(p, plen + slen + 1);
+ if (p == NULL)
+ return NULL;
+
+ return strncat(p, s, plen+slen);
+}
+
+/* Turns an array of strings into an escaped flat command line. */
+static LPWSTR build_commandline(const char *args[], unsigned int len)
+{
+ unsigned int i;
+ char *result;
+
+ result = strdup("progname");
+ for (i = 0; i < len; i++) {
+ result = append(result, " ");
+ result = append(result, escape_windows_command_arg(args[i]));
+ }
+
+ return utf8_to_wchar(result);
+}
+
+static int arrays_equal(const char **a, unsigned int alen, const char **b, unsigned int blen)
+{
+ unsigned int i;
+
+ if (alen != blen)
+ return 0;
+ for (i = 0; i < alen; i++) {
+ if (strcmp(a[i], b[i]) != 0)
+ return 0;
+ }
+
+ return 1;
+}
+
+static char *format_array(const char **args, unsigned int len)
+{
+ char *result;
+ unsigned int i;
+
+ result = strdup("");
+ result = append(result, "{");
+ for (i = 0; i < len; i++) {
+ if (i > 0)
+ result = append(result, ", ");
+ result = append(result, "[");
+ result = append(result, args[i]);
+ result = append(result, "]");
+ }
+ result = append(result, "}");
+
+ return result;
+}
+
+static int run_test(const char *args[])
+{
+ LPWSTR *argvw;
+ char **result;
+ int args_len, argvw_len, result_len;
+
+ args_len = nullarray_length(args);
+ argvw = CommandLineToArgvW(build_commandline(args, args_len), &argvw_len);
+ /* Account for added argv[0] in argvw. */
+ result = wchar_to_utf8_array(argvw+1, argvw_len-1);
+ result_len = argvw_len - 1;
+
+ if (arrays_equal((const char **) result, result_len, args, args_len)) {
+ printf("PASS %s\n", format_array(args, args_len));
+ return 1;
+ } else {
+ printf("FAIL got %s\n", format_array((const char **) result, result_len));
+ printf("expected %s\n", format_array(args, args_len));
+ return 0;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned int num_tests, num_passed;
+ unsigned int i;
+
+ num_tests = 0;
+ num_passed = 0;
+ for (i = 0; i < sizeof(TESTS) / sizeof(*TESTS); i++) {
+ num_tests++;
+ if (run_test(TESTS[i]))
+ num_passed++;
+ }
+
+ printf("%ld / %ld tests passed.\n", num_passed, num_tests);
+
+ return num_passed == num_tests ? 0 : 1;
+}