From c6b57a96dce258f3cfe510b0f71d74c0a71efe1e Mon Sep 17 00:00:00 2001 From: Stephane Bortzmeyer Date: Wed, 26 May 2004 20:12:12 +0000 Subject: [PATCH] * Documentation for plugins * Better build system, with clean and dist targets --- SRC/ChangeLog | 8 +++++ SRC/Makefile.am | 2 +- SRC/Makefile.in | 11 ++++--- SRC/configure | 8 +++-- SRC/configure.ac | 4 ++- SRC/echoping.1 | 13 ++++++-- SRC/plugins/Makefile.in | 27 ++++++++++++++++- SRC/plugins/Makefile.plugins.in | 8 ++++- SRC/plugins/configure | 5 +++- SRC/plugins/configure.ac | 4 +++ SRC/plugins/dns/Makefile.in | 4 +++ SRC/plugins/dns/dns.c | 5 ++-- SRC/plugins/postgresql/Makefile.in | 3 ++ SRC/plugins/postgresql/postgresql.c | 4 +-- SRC/plugins/random/Makefile.in | 9 ++++-- SRC/plugins/random/echoping_random.1 | 36 +++++++++++++++++++++++ SRC/plugins/whois/Makefile.in | 4 +++ SRC/plugins/whois/echoping_whois.1 | 44 ++++++++++++++++++++++++++++ 18 files changed, 179 insertions(+), 20 deletions(-) create mode 100644 SRC/plugins/random/echoping_random.1 create mode 100644 SRC/plugins/whois/echoping_whois.1 diff --git a/SRC/ChangeLog b/SRC/ChangeLog index bc42310..e854214 100644 --- a/SRC/ChangeLog +++ b/SRC/ChangeLog @@ -1,3 +1,11 @@ +6.0 (not yet released) + + * Plugins: several plugins (TODO: list) are now shipped with + echoping and you can write your own. All new protocols will now be + supported via plugins. Consequences: + - you now need an Unix with a working dlopen(3) + - echoping now requires the popt parsing library + 5.2.0 (2004-02-29) * IDN (Unicode domain names) support diff --git a/SRC/Makefile.am b/SRC/Makefile.am index 6c8be9d..e454f61 100644 --- a/SRC/Makefile.am +++ b/SRC/Makefile.am @@ -64,7 +64,7 @@ upload-force: dist rm -f upload.log ncftpput -d upload.log upload.sourceforge.net /incoming $(distdir).tar.gz -realclean: clean +realclean: distclean rm -rf *~ autom4te.cache EXTRA_DIST = $(man_MANS) $(TESTS) $(DOCS) $(MORE_TESTS) diff --git a/SRC/Makefile.in b/SRC/Makefile.in index 75cbdc1..eda0fe8 100644 --- a/SRC/Makefile.in +++ b/SRC/Makefile.in @@ -68,6 +68,7 @@ LTLIB = @LTLIB@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ +plugins_dir = @plugins_dir@ bin_PROGRAMS = echoping man_MANS = echoping.1 @@ -86,7 +87,7 @@ EXTRA_DIST = $(man_MANS) $(TESTS) $(DOCS) $(MORE_TESTS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h -CONFIG_CLEAN_FILES = +CONFIG_CLEAN_FILES = echoping.1 PROGRAMS = $(bin_PROGRAMS) @@ -108,8 +109,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 missing \ -mkinstalldirs +config.h.in config.sub configure configure.ac echoping.1.in install-sh \ +missing mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) @@ -166,6 +167,8 @@ distclean-hdr: -rm -f config.h maintainer-clean-hdr: +echoping.1: $(top_builddir)/config.status echoping.1.in + cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status mostlyclean-binPROGRAMS: @@ -599,7 +602,7 @@ upload-force: dist rm -f upload.log ncftpput -d upload.log upload.sourceforge.net /incoming $(distdir).tar.gz -realclean: clean +realclean: distclean rm -rf *~ autom4te.cache # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/SRC/configure b/SRC/configure index 8761978..d114c24 100755 --- a/SRC/configure +++ b/SRC/configure @@ -310,7 +310,7 @@ ac_includes_default="\ #endif" ac_subdirs_all="$ac_subdirs_all plugins" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE CPP EGREP subdirs LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE CPP EGREP plugins_dir subdirs LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -6037,10 +6037,12 @@ cat >>confdefs.h <<_ACEOF _ACEOF +echo $plugins_dir > plugins/dir + subdirs="$subdirs plugins" - ac_config_files="$ac_config_files Makefile" + ac_config_files="$ac_config_files Makefile echoping.1" 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 @@ -6577,6 +6579,7 @@ do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "echoping.1" ) CONFIG_FILES="$CONFIG_FILES echoping.1" ;; "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 @@ -6692,6 +6695,7 @@ s,@MAKEINFO@,$MAKEINFO,;t t s,@SET_MAKE@,$SET_MAKE,;t t s,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t +s,@plugins_dir@,$plugins_dir,;t t s,@subdirs@,$subdirs,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t diff --git a/SRC/configure.ac b/SRC/configure.ac index ad6c816..2bdf95e 100644 --- a/SRC/configure.ac +++ b/SRC/configure.ac @@ -296,8 +296,10 @@ else plugins_dir=`interpolate '$libdir/echoping'` fi AC_DEFINE_UNQUOTED(PLUGINS_DIR, "$plugins_dir", [Directory where the plugins will be installed]) +AC_SUBST(plugins_dir) +echo $plugins_dir > plugins/dir AC_CONFIG_SUBDIRS(plugins) -AC_OUTPUT(Makefile) +AC_OUTPUT(Makefile echoping.1) AC_DEFUN([DISPLAY_SETTING], [ diff --git a/SRC/echoping.1 b/SRC/echoping.1 index 86e8995..76b2c3c 100644 --- a/SRC/echoping.1 +++ b/SRC/echoping.1 @@ -127,8 +127,13 @@ or (depending on your Unix). /usr/include/netinet/ip.h may contain interesting constants for setting Type Of Service. .IP -m\ plugin -Load the given plugin. Quite experimental. The documentation for a -plugin is in echoping_PLUGIN(1). The plugin-specific options appear +Load the given plugin. Quite experimental. The plugin is first +searched in the normal library directories (see +.BR ld.so(8) +) then in /usr/local/lib/echoping. The documentation for a +given plugin is in +.BR echoping_PLUGINNAME(1) +. The plugin-specific options appear .B after the hostname. .SH EXAMPLES @@ -213,5 +218,9 @@ See the TODO file or SourceForge bug tracking system at .SH SEE ALSO See the README for information about other network measurements programs. +.SH FILES +.IP "\fB/usr/local/lib/echoping \fR" 4 +Plugins directory + .SH AUTHOR Stephane Bortzmeyer diff --git a/SRC/plugins/Makefile.in b/SRC/plugins/Makefile.in index 6fa23ce..4d23e23 100644 --- a/SRC/plugins/Makefile.in +++ b/SRC/plugins/Makefile.in @@ -1,4 +1,5 @@ SUBDIRS=@subdirs@ +DISTFILES=configure configure.ac Makefile.plugins.in Makefile.in all: ifneq (${SUBDIRS},) @@ -9,14 +10,38 @@ endif install: ifneq (${SUBDIRS},) + test -d @plugins_dir@ || mkdir @plugins_dir@ @for subdir in ${SUBDIRS}; do \ (cd $$subdir && ${MAKE} $@) \ done endif -distdir: +configure: configure.ac + autoconf + +distdir: configure + test -d ${top_distdir}/plugins || mkdir ${top_distdir}/plugins + cp ${DISTFILES} ${top_distdir}/plugins + +ifneq (${SUBDIRS},) + @for subdir in ${SUBDIRS}; do \ + (cd $$subdir && ${MAKE} $@) \ + done +endif + +clean: ifneq (${SUBDIRS},) @for subdir in ${SUBDIRS}; do \ (cd $$subdir && ${MAKE} $@) \ done endif + +distclean: clean +ifneq (${SUBDIRS},) + @for subdir in ${SUBDIRS}; do \ + (cd $$subdir && ${MAKE} $@) \ + done +endif + rm -f Makefile Makefile.plugins + +# TODO: distclean and clean diff --git a/SRC/plugins/Makefile.plugins.in b/SRC/plugins/Makefile.plugins.in index 8a3cf60..656f8fa 100644 --- a/SRC/plugins/Makefile.plugins.in +++ b/SRC/plugins/Makefile.plugins.in @@ -1,11 +1,14 @@ CCFLAGS=-DHAVE_CONFIG_H -Wall -O0 -g CCDYNAMICFLAGS=${CCFLAGS} -fPIC +ifeq ("${LDFLAGS}","") LDFLAGS= +endif LDDYNAMICFLAGS=${LDFLAGS} -shared # Autoconf variables prefix = @prefix@ exec_prefix = @exec_prefix@ -DESTDIR=@libdir@/echoping +DESTDIR=@plugins_dir@ +MANDIR=@mandir@ INSTALL=@INSTALL@ %.o: %.c @@ -27,4 +30,7 @@ distclean: clean # $Id$ +## Local Variables: ## +## mode:makefile ## +## End: ## diff --git a/SRC/plugins/configure b/SRC/plugins/configure index 876ca5a..a56238c 100755 --- a/SRC/plugins/configure +++ b/SRC/plugins/configure @@ -273,7 +273,7 @@ PACKAGE_BUGREPORT= ac_unique_file="Makefile.plugins.in" ac_subdirs_all="$ac_subdirs_all random whois dns postgresql" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA subdirs LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA subdirs plugins_dir LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -1324,6 +1324,8 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' subdirs="$subdirs random whois dns postgresql" +plugins_dir=`cat dir` + ac_config_files="$ac_config_files Makefile.plugins Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -1965,6 +1967,7 @@ s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t s,@subdirs@,$subdirs,;t t +s,@plugins_dir@,$plugins_dir,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF diff --git a/SRC/plugins/configure.ac b/SRC/plugins/configure.ac index 380bae2..f281f2d 100644 --- a/SRC/plugins/configure.ac +++ b/SRC/plugins/configure.ac @@ -2,6 +2,10 @@ dnl $Id$ AC_INIT(Makefile.plugins.in) AC_PROG_INSTALL +dnl TODO: allow to exclude or include plugins +dnl TODO: writes a LDAP plugin AC_CONFIG_SUBDIRS(random whois dns postgresql) +plugins_dir=`cat dir` +AC_SUBST(plugins_dir) AC_OUTPUT(Makefile.plugins Makefile) diff --git a/SRC/plugins/dns/Makefile.in b/SRC/plugins/dns/Makefile.in index 659e066..4a47d64 100644 --- a/SRC/plugins/dns/Makefile.in +++ b/SRC/plugins/dns/Makefile.in @@ -1,4 +1,7 @@ PLUGIN=dns.so +LDFLAGS=-lresolv +DISTFILES=dns.c Makefile.in configure.ac configure config.h.in + include ../Makefile.plugins ifeq (@DNS_BUILD@,1) @@ -18,6 +21,7 @@ endif distdir: test -d ../${top_distdir}/plugins/dns || mkdir ../${top_distdir}/plugins/dns + ${INSTALL} ${DISTFILES} ../${top_distdir}/plugins/dns # $Id$ diff --git a/SRC/plugins/dns/dns.c b/SRC/plugins/dns/dns.c index 44b5886..3eccf52 100644 --- a/SRC/plugins/dns/dns.c +++ b/SRC/plugins/dns/dns.c @@ -1,6 +1,7 @@ /* * DNS plugin. - * + * TODO: return errors to echoping (name server not existing, for instance) + * TODO: allow options like TCP * $Id$ */ @@ -125,7 +126,7 @@ start (struct addrinfo *res) sizeof (struct sockaddr)); if (res_init () < 0) err_sys ("res_init"); - _res.nsaddr_list[0] = name_server_sockaddr_in; /* TODO: and IPv6? */ + _res.nsaddr_list[0] = name_server_sockaddr_in; /* TODO: and IPv6? Detect _resext with autoconf (*BSD) and use it */ _res.nscount = 1; _res.options &= ~(RES_DNSRCH | RES_DEFNAMES | RES_NOALIASES); } diff --git a/SRC/plugins/postgresql/Makefile.in b/SRC/plugins/postgresql/Makefile.in index 7584a12..d6c6b09 100644 --- a/SRC/plugins/postgresql/Makefile.in +++ b/SRC/plugins/postgresql/Makefile.in @@ -1,4 +1,6 @@ PLUGIN=postgresql.so +LDFLAGS=-lpq +DISTFILES=postgresql.c Makefile.in configure.ac configure config.h.in include ../Makefile.plugins @@ -19,6 +21,7 @@ endif distdir: test -d ../${top_distdir}/plugins/postgresql || mkdir ../${top_distdir}/plugins/postgresql + ${INSTALL} ${DISTFILES} ../${top_distdir}/plugins/postgresql # $Id$ diff --git a/SRC/plugins/postgresql/postgresql.c b/SRC/plugins/postgresql/postgresql.c index 34da989..c03eb31 100644 --- a/SRC/plugins/postgresql/postgresql.c +++ b/SRC/plugins/postgresql/postgresql.c @@ -1,6 +1,6 @@ /* * PostgreSQL plugin. - * + * TODO: loops with and without opening the connection each time? * $Id$ */ @@ -58,7 +58,7 @@ init (const int argc, const char **argv) postgresql_usage (msg); } } - if (request == NULL) + if (request == NULL) /* TODO: a default like SELECT now()? */ postgresql_usage ("Mandatory request missing"); if (conninfo == NULL) postgresql_usage ("Mandatory connection information missing"); diff --git a/SRC/plugins/random/Makefile.in b/SRC/plugins/random/Makefile.in index 9f8b383..4dd1223 100644 --- a/SRC/plugins/random/Makefile.in +++ b/SRC/plugins/random/Makefile.in @@ -1,6 +1,6 @@ PLUGIN=random.so - -include ../Makefile.plugins +MANPAGE=echoping_random.1 +DISTFILES=random.c Makefile.in configure.ac configure config.h.in ${MANPAGE} ifeq (@RANDOM_BUILD@,1) all: ${PLUGIN} @@ -9,9 +9,12 @@ all: @echo "Not building the random plugin" endif +include ../Makefile.plugins + ifeq (@RANDOM_BUILD@,1) install: all prepare-install ${INSTALL} ${PLUGIN} ${DESTDIR} + ${INSTALL} ${MANPAGE} ${MANDIR}/man1 else install: @echo "Not installing the random plugin" @@ -19,7 +22,7 @@ endif distdir: test -d ../${top_distdir}/plugins/random || mkdir ../${top_distdir}/plugins/random - cp random.c Makefile.in configure.ac configure ../${top_distdir}/plugins/random + ${INSTALL} ${DISTFILES} ../${top_distdir}/plugins/random # $Id$ diff --git a/SRC/plugins/random/echoping_random.1 b/SRC/plugins/random/echoping_random.1 new file mode 100644 index 0000000..6fc7b8f --- /dev/null +++ b/SRC/plugins/random/echoping_random.1 @@ -0,0 +1,36 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH ECHOPING_RANDOM SECTION 1 "May 26, 2004" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +echoping_random \- echoping plugin which just sleeps a random time +.SH SYNOPSIS +.B echoping +.RI [echoping\ options] +.RI -m\ random +.B hostname +.SH DESCRIPTION +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +random is a dummy echoping plugin, made only for demo purposes. +.SH OPTIONS +No options +.SH SEE ALSO +.BR echoping (1), +.SH AUTHOR +Stephane Bortzmeyer diff --git a/SRC/plugins/whois/Makefile.in b/SRC/plugins/whois/Makefile.in index b4b1126..c3ae5b9 100644 --- a/SRC/plugins/whois/Makefile.in +++ b/SRC/plugins/whois/Makefile.in @@ -1,4 +1,6 @@ PLUGIN=whois.so +MANPAGE=echoping_whois.1 +DISTFILES=whois.c Makefile.in configure.ac configure config.h.in ${MANPAGE} include ../Makefile.plugins @@ -12,6 +14,7 @@ endif ifeq (@WHOIS_BUILD@,1) install: all prepare-install ${INSTALL} ${PLUGIN} ${DESTDIR} + ${INSTALL} ${MANPAGE} ${MANDIR}/man1 else install: @echo "Not installing the whois plugin" @@ -19,6 +22,7 @@ endif distdir: test -d ../${top_distdir}/plugins/whois || mkdir ../${top_distdir}/plugins/whois + ${INSTALL} ${DISTFILES} ../${top_distdir}/plugins/whois # $Id$ diff --git a/SRC/plugins/whois/echoping_whois.1 b/SRC/plugins/whois/echoping_whois.1 new file mode 100644 index 0000000..249acf1 --- /dev/null +++ b/SRC/plugins/whois/echoping_whois.1 @@ -0,0 +1,44 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH ECHOPING_WHOIS SECTION 1 "May 26, 2004" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +echoping_whois \- echoping plugin which connects to a whois server +.SH SYNOPSIS +.B echoping +.RI [echoping\ options] +.RI -m\ whois +.B hostname +.RI -r\ request +.RI -d +.SH DESCRIPTION +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +whois is an echoping plugin to connect to whois/nicname servers (see +RFC 954). +.SH OPTIONS +.TP +.B \-r, \-\-request +The request to the whois server (typically a domain name) +.TP +.B \-d, \-\-dump +Dumps the result of the request +.SH SEE ALSO +.BR echoping (1), +.SH AUTHOR +Stephane Bortzmeyer