Now uses the popt library instead of the standard getopt, to parse options.

Initial
Stephane Bortzmeyer 20 years ago
parent 245c2f1edb
commit 1b179e9f79

@ -41,6 +41,15 @@ interface, with getnameinfo/getaddrinfo. If your system does not
support it (Mac OS X <= 10.1), you have no other choices than using
echoping 4.
There is no option to disable the use of dlopen() or the popt
library. dlopen() is necessary for the plugins (and, in the future,
all protocol code will be in plugins). The popt library provides a
better and easier parsing of options and, more important, is necessary
for resuming parsing, something that the plugins rely heavily on. If
your system does not support dlopen() or if you do not want to install
the popt library (which is free and runs on every Unix), you have no
other choices than using echoping 5.
Standard "autoconf/configure" options are supported such as --prefix
to set the installation root directory.

@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -108,8 +108,8 @@ MANS = $(man_MANS)
NROFF = nroff
DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \
Makefile.am Makefile.in NEWS TODO acinclude.m4 aclocal.m4 config.guess \
config.h.in config.sub configure configure.ac install-sh ltmain.sh \
missing mkinstalldirs
config.h.in config.sub configure configure.ac install-sh missing \
mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
@ -134,7 +134,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
$(ACLOCAL_M4): configure.ac acinclude.m4
cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure.ac $(CONFIG_STATUS_DEPENDENCIES)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
@ -287,7 +287,7 @@ maintainer-clean-recursive:
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" = "." && dot_seen=yes; \
test "$$subdir" != "." || dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \
@ -329,7 +329,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LI
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP))
mostlyclean-tags:

48
SRC/aclocal.m4 vendored

@ -1,6 +1,6 @@
dnl aclocal.m4 generated automatically by aclocal 1.4-p4
dnl aclocal.m4 generated automatically by aclocal 1.4-p6
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@ -1111,8 +1111,9 @@ AC_LIB_PROG_LD_GNU
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN(AM_INIT_AUTOMAKE,
[AC_REQUIRE([AC_PROG_INSTALL])
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
@ -1128,18 +1129,47 @@ AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_REQUIRE([AC_PROG_MAKE_SET])])
# Copyright 2002 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program 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. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.4-p6])])
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN(AM_SANITY_CHECK,
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
@ -1180,7 +1210,7 @@ AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN(AM_MISSING_PROG,
AC_DEFUN([AM_MISSING_PROG],
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
@ -1196,7 +1226,7 @@ AC_SUBST($1)])
# Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN(AM_CONFIG_HEADER,
AC_DEFUN([AM_CONFIG_HEADER],
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.

@ -30,6 +30,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `poptGetContext' function. */
#undef HAVE_POPTGETCONTEXT
/* Define to 1 if you have the `sigaction' function. */
#undef HAVE_SIGACTION

200
SRC/configure vendored

@ -2099,6 +2099,7 @@ 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
am__api_version="1.4"
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
@ -2288,17 +2289,17 @@ _ACEOF
missing_dir=`cd $ac_aux_dir && pwd`
echo "$as_me:$LINENO: checking for working aclocal" >&5
echo $ECHO_N "checking for working aclocal... $ECHO_C" >&6
echo "$as_me:$LINENO: checking for working aclocal-${am__api_version}" >&5
echo $ECHO_N "checking for working aclocal-${am__api_version}... $ECHO_C" >&6
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if (aclocal --version) < /dev/null > /dev/null 2>&1; then
ACLOCAL=aclocal
if (aclocal-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then
ACLOCAL=aclocal-${am__api_version}
echo "$as_me:$LINENO: result: found" >&5
echo "${ECHO_T}found" >&6
else
ACLOCAL="$missing_dir/missing aclocal"
ACLOCAL="$missing_dir/missing aclocal-${am__api_version}"
echo "$as_me:$LINENO: result: missing" >&5
echo "${ECHO_T}missing" >&6
fi
@ -2318,17 +2319,17 @@ else
echo "${ECHO_T}missing" >&6
fi
echo "$as_me:$LINENO: checking for working automake" >&5
echo $ECHO_N "checking for working automake... $ECHO_C" >&6
echo "$as_me:$LINENO: checking for working automake-${am__api_version}" >&5
echo $ECHO_N "checking for working automake-${am__api_version}... $ECHO_C" >&6
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if (automake --version) < /dev/null > /dev/null 2>&1; then
AUTOMAKE=automake
if (automake-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then
AUTOMAKE=automake-${am__api_version}
echo "$as_me:$LINENO: result: found" >&5
echo "${ECHO_T}found" >&6
else
AUTOMAKE="$missing_dir/missing automake"
AUTOMAKE="$missing_dir/missing automake-${am__api_version}"
echo "$as_me:$LINENO: result: missing" >&5
echo "${ECHO_T}missing" >&6
fi
@ -5052,6 +5053,185 @@ fi
done
for ac_func in poptGetContext
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define $ac_func innocuous_$ac_func
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); 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 $ac_func
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* 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_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
else
echo "$as_me:$LINENO: checking for poptGetContext in -lpopt" >&5
echo $ECHO_N "checking for poptGetContext in -lpopt... $ECHO_C" >&6
if test "${ac_cv_lib_popt_poptGetContext+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpopt $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char poptGetContext ();
int
main ()
{
poptGetContext ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_popt_poptGetContext=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_popt_poptGetContext=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_popt_poptGetContext" >&5
echo "${ECHO_T}$ac_cv_lib_popt_poptGetContext" >&6
if test $ac_cv_lib_popt_poptGetContext = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPOPT 1
_ACEOF
LIBS="-lpopt $LIBS"
else
{ { echo "$as_me:$LINENO: error: Missing popt library, get it from ftp://ftp.rpm.org/pub/rpm/dist/rpm-x.y.z" >&5
echo "$as_me: error: Missing popt library, get it from ftp://ftp.rpm.org/pub/rpm/dist/rpm-x.y.z" >&2;}
{ (exit 1); exit 1; }; }
fi
fi
done
for ac_func in usleep
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`

@ -150,6 +150,9 @@ AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_ntop, ,
)])
AC_CHECK_FUNCS(gettimeofday socket sigaction strerror, , AC_MSG_ERROR(Missing mandatory function))
AC_CHECK_FUNCS(poptGetContext, ,
[AC_CHECK_LIB(popt,poptGetContext, ,
[AC_MSG_ERROR([Missing popt library, get it from ftp://ftp.rpm.org/pub/rpm/dist/rpm-x.y.z])])])
AC_CHECK_FUNCS(usleep)
AC_CHECK_FUNCS(dlopen, ,
[AC_CHECK_LIB(dl,dlopen, ,

@ -41,12 +41,12 @@ extern int tvcmp ();
int
main (argc, argv)
int argc;
char *argv[];
const char *argv[];
{
extern char *optarg;
extern int optind;
int result;
int remaining = argc;
char **leftover;
int sockfd;
struct addrinfo hints, hints_numeric, *res;
@ -61,6 +61,7 @@ main (argc, argv)
FILE *files = NULL;
CHANNEL channel;
int verbose = FALSE;
int module_find = FALSE;
int n, nr = 0;
#ifdef OPENSSL
int sslcode;
@ -80,6 +81,7 @@ main (argc, argv)
unsigned int wait = 1;
#endif
unsigned char fill = ' ';
unsigned int fill_i;
unsigned short fill_requested = 0;
unsigned int i = 0;
char *plugin_name = NULL;
@ -101,6 +103,7 @@ main (argc, argv)
unsigned short http = 0;
unsigned short smtp = 0;
unsigned short discard = 0;
unsigned short chargen = 0;
unsigned short udp = 0;
unsigned short icp = 0;
@ -134,7 +137,37 @@ main (argc, argv)
int priority_requested = 0;
int tos;
int tos_requested = 0;
char *arg_end, *p;
char *p;
/* popt variables */
const struct poptOption options[] = {
{"verbose", 'v', POPT_ARG_NONE, &verbose, 'v'},
{"size", 's', POPT_ARG_INT, &size, 's'},
{"number", 'n', POPT_ARG_INT, &number, 'n'},
#ifdef HAVE_USLEEP
{"wait", 'w', POPT_ARG_FLOAT, &wait, 'w'},
#else
{"wait", 'w', POPT_ARG_INT, &wait, 'w'},
#endif
{"discard", 'd', POPT_ARG_NONE, &discard, 'd'},
{"chargen", 'c', POPT_ARG_NONE, &chargen, 'c'},
{"http", 'h', POPT_ARG_STRING, &url, 'h'},
{"icp", 'i', POPT_ARG_STRING, &url, 'i'},
{"ttcp", 'r', POPT_ARG_NONE, &ttcp, 'r'},
{"udp", 'u', POPT_ARG_NONE, &udp, 'u'},
{"timeout", 't', POPT_ARG_INT, &timeout, 't'},
{"fill", 'f', POPT_ARG_INT, &fill_i, 'f'},
{"smtp", 'S', POPT_ARG_NONE, &smtp, 'S'},
{"ssl", 'C', POPT_ARG_NONE, &ssl, 'C'},
{"priority", 'p', POPT_ARG_INT, &priority, 'p'},
{"type-of-service", 'P', POPT_ARG_INT, &tos, 'P'},
{"check-original", 'a', POPT_ARG_NONE, NULL, 'a'},
{"ignore-cache", 'A', POPT_ARG_NONE, NULL, 'A'},
{"ipv4", '4', POPT_ARG_NONE, NULL, '4'},
{"ipv6", '6', POPT_ARG_NONE, NULL, '6'},
{"module", 'm', POPT_ARG_STRING, &plugin_name, 'm'},
{NULL, 0, 0, NULL, 0, NULL, NULL}
};
null_timeval.tv_sec = 0;
null_timeval.tv_usec = 0;
@ -154,28 +187,35 @@ main (argc, argv)
{
results[i].valid = 0;
}
progname = argv[0];
while ((result =
getopt (argc, argv, "vs:n:w:dch:i:rut:f:SCp:P:aA46m:")) != -1)
progname = (char *) argv[0];
poptContext poptcon = poptGetContext (NULL, argc,
argv,
options,
0);
while ((!module_find) && (result = poptGetNextOpt (poptcon)) != -1)
{
if (result < -1)
{
err_ret ("%s: %s",
poptBadOption (poptcon, POPT_BADOPTION_NOALIAS),
poptStrerror (result));
usage ();
}
remaining--;
switch ((char) result)
{
case 'v':
verbose = TRUE;
break;
case 'r':
ttcp = 1;
break;
case 'u':
udp = 1;
break;
case 'C':
ssl = 1;
break;
case 'd':
strcpy (port_name, DISCARD_TCP_PORT);
port_to_use = USE_DISCARD;
discard = 1;
break;
case 'c':
strcpy (port_name, CHARACTER_GENERATOR_TCP_PORT);
@ -183,17 +223,17 @@ main (argc, argv)
stop_at_newlines = 0;
break;
case 'i':
remaining--;
strcpy (port_name, DEFAULT_ICP_UDP_PORT);
port_to_use = USE_ICP;
udp = 1;
icp = 1;
url = optarg;
break;
case 'h':
remaining--;
strcpy (port_name, DEFAULT_HTTP_TCP_PORT);
port_to_use = USE_HTTP;
http = 1;
url = optarg;
break;
case 'a':
nocache = 1;
@ -202,44 +242,24 @@ main (argc, argv)
nocache = 2;
break;
case 'f':
fill = *optarg;
remaining--;
fill = (char) fill_i;
fill_requested = 1;
break;
case 'S':
strcpy (port_name, "smtp");
port_to_use = USE_SMTP;
smtp = 1;
break;
case 'p':
priority = (int) strtol (optarg, &arg_end, 0);
if (arg_end == optarg || arg_end == '\0')
{
(void) fprintf (stderr,
"%s: socket priority (-p) should be numeric.\n",
progname);
exit (1);
}
else
{
priority_requested = 1;
}
remaining--;
priority_requested = 1;
break;
case 'P':
tos = (int) strtol (optarg, &arg_end, 0);
if (arg_end == optarg || arg_end == '\0')
{
(void) fprintf (stderr,
"%s: IP type of service (-P) should be "
"numeric.\n", progname);
exit (1);
}
else
{
tos_requested = 1;
}
remaining--;
tos_requested = 1;
break;
case 's':
size = atoi (optarg);
remaining--;
if (size > MAX_LINE)
{
(void) fprintf (stderr,
@ -255,7 +275,7 @@ main (argc, argv)
size_requested = 1;
break;
case 't':
timeout = atoi (optarg);
remaining--;
timeout_requested = 1;
if (size <= 0)
{
@ -264,7 +284,7 @@ main (argc, argv)
}
break;
case 'n':
number = atoi (optarg);
remaining--;
if (number > MAX_ITERATIONS)
{
(void) fprintf (stderr,
@ -281,11 +301,7 @@ main (argc, argv)
}
break;
case 'w':
#ifdef HAVE_USLEEP
wait = atof (optarg);
#else
wait = atoi (optarg);
#endif
remaining--;
if (wait <= 0)
/* atoi returns zero when there is an error. So we cannot use
'-w 0' to specify no waiting. */
@ -302,7 +318,8 @@ main (argc, argv)
family = AF_INET6;
break;
case 'm':
plugin_name = optarg;
remaining--;
module_find = TRUE;
break;
default:
usage ();
@ -405,6 +422,8 @@ main (argc, argv)
exit (1);
}
#endif
remaining--; /* No argv[0] this time */
leftover = (char **) &argv[argc - remaining];
if (plugin_name)
{
/* TODO: add '.so' to the plugin name if it's not already there */
@ -419,7 +438,7 @@ main (argc, argv)
{
err_sys ("Cannot find init in %s: %s", plugin_name, dl_result);
}
strcpy (port_name, plugin_init (argc, argv));
strcpy (port_name, plugin_init (remaining, (const char **) leftover));
plugin_start = dlsym (plugin, "start");
dl_result = dlerror ();
if (dl_result)
@ -437,9 +456,7 @@ main (argc, argv)
{
tcp = 1;
}
argc -= optind;
argv += optind;
if (argc != 1)
if (remaining != 1)
{
usage ();
}
@ -447,7 +464,7 @@ main (argc, argv)
{
printf ("\nThis is %s, version %s.\n\n", progname, VERSION);
}
server = argv[0];
server = leftover[0];
#ifdef LIBIDN
locale_server = server;
utf8_server = stringprep_locale_to_utf8 (server);
@ -588,16 +605,18 @@ main (argc, argv)
strcpy (hbuf, "?");
strcpy (pbuf, "?");
}
if (verbose)
if (plugin)
{
printf ("Running start() for the plugin %s...\n", plugin_name);
if (verbose)
{
printf ("Running start() for the plugin %s...\n", plugin_name);
}
plugin_start (res);
}
plugin_start (res);
#ifdef HTTP
if (http)
{
sendline = make_http_sendline (url, server, atoi (pbuf), nocache);
/* printf ("DEBUG: sending %s\n", sendline); */
}
else
#endif
@ -985,7 +1004,6 @@ main (argc, argv)
ERR_error_string (sslcode, NULL));
}
}
/* printf ("DEBUG: writing %s with SSL\n", sendline); */
}
#endif
#ifdef GNUTLS
@ -1009,7 +1027,6 @@ main (argc, argv)
rc, gnutls_strerror (rc));
}
}
/* printf ("DEBUG: writing %s with TLS\n", sendline); */
}
#endif
/* Write something to the server */

@ -35,6 +35,9 @@
#include <math.h>
#include <dlfcn.h>
/* popt library TODO: what if missing? */
#include <popt.h>
#ifdef OPENSSL
#include <openssl/crypto.h>
#include <openssl/x509.h>

Loading…
Cancel
Save