# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Remember to change ADNS_VERSION_STRING in client/client.h too, and
+# possibly library soname (MAJOR and MINOR in settings.make.in).
DISTVERSION= pre-1.0-1
+
srcdir= @srcdir@
VPATH= @srcdir@
4. http://www.chiark.greenend.org.uk/~ian/adns/
5. http://www.chiark.greenend.org.uk/~ian/adns/adns.tar.gz
6. http://www.chiark.greenend.org.uk/~ian/adns/adns.h.txt
- 7. http://www.chiark.greenend.org.uk/~ian/adns/adnsresfilter.txt
+ 7. http://www.chiark.greenend.org.uk/~ian/adns/adnshost.txt
8. ftp://ftp.chiark.greenend.org.uk/users/ian/adns/
9. http://www.chiark.greenend.org.uk/~ian/adns/ftp/
10. http://www.chiark.greenend.org.uk/ucgi/~ijackson/cvsweb/adns/
<!-- Please ensure that all links continine to be correct -->
<!-- both for www.gnu.org and chiark. -->
<!-- -->
-<!-- $Id: README.html,v 1.4 2000/09/17 01:56:15 ian Exp $ -->
+<!-- $Id: README.html,v 1.5 2000/09/17 14:09:22 ian Exp $ -->
<p>
release</A> as a gzipped tarfile.
<li><A href="http://www.chiark.greenend.org.uk/~ian/adns/adns.h.txt">adns.h</A>
API header file with comments, and
- <A href="http://www.chiark.greenend.org.uk/~ian/adns/adnsresfilter.txt">usage
+ <A href="http://www.chiark.greenend.org.uk/~ian/adns/adnshost.txt">usage
message for adnshost</A> (currently there is no manual, sorry).
<li>All versions released so far are also available via
<A href="ftp://ftp.chiark.greenend.org.uk/users/ian/adns/">anonymous
* adnshost, adnslogres, adnsresfilter have options for config override.
* adnsresfilter has --debug option.
* Improvements to adnslogres (incl. new -c option) from Tony Finch.
- * adnslogres has --help option.
+ * adnslogres has --help option, all utilities support --version.
* Documentation improved somewhat, including new GPL-vs-LGPL file.
Changes for non-BETA release:
{ ot_desconly, "other global options:" },
{ ot_funcarg, "Configuration to use instead of /etc/resolv.conf",
0, "config", 0,0, of_config, "<config-text>" },
+ { ot_func, "Print version number",
+ 0, "version", 0,0, of_version },
{ ot_func, "Print usage information",
0, "help", 0,0, of_help },
if (ferror(stdout)) sysfail("write usage message",errno);
}
+void of_version(const struct optioninfo *oi, const char *arg, const char *arg2) {
+ VERSION_PRINT_QUIT("adnshost");
+}
+
void of_help(const struct optioninfo *oi, const char *arg, const char *arg2) {
printusage();
if (fclose(stdout)) sysfail("finish writing output",errno);
#include "config.h"
#include "adns.h"
#include "dlist.h"
+#include "client.h"
#ifdef ADNS_REGRESS_TEST
# include "hredirect.h"
extern char *ov_id;
extern struct perqueryflags_remember ov_pqfr;
-extern optfunc of_config, of_help, of_type, of_ptr, of_reverse;
+extern optfunc of_config, of_version, of_help, of_type, of_ptr, of_reverse;
extern optfunc of_asynch_id, of_cancel_id;
const struct optioninfo *opt_findl(const char *opt);
void *xmalloc(size_t sz);
char *xstrsave(const char *str);
-void quitnow(int rc) NONRETURNING;
-
extern int rcode;
extern const char *config_text; /* 0 => use defaults */
*/
static const char * const cvsid =
- "$Id: adnslogres.c,v 1.19 2000/09/17 00:43:10 ian Exp $";
+ "$Id: adnslogres.c,v 1.20 2000/09/17 14:09:02 ian Exp $";
#include <sys/types.h>
#include <sys/time.h>
#include "config.h"
#include "adns.h"
+#include "client.h"
#ifdef ADNS_REGRESS_TEST
# include "hredirect.h"
}
static void printhelp(FILE *file) {
- fprintf(file, "usage: %s [-d] [-p] [-c concurrency] [-C config] [logfile]\n",
- progname);
+ fputs("usage: adnslogres [<options>] [<logfile>]\n"
+ " adnslogres --version|--help\n"
+ "options: -c <concurrency> set max number of outstanding queries\n"
+ " -p use poll(2) instead of select(2)\n"
+ " -d turn on debugging\n"
+ " -C <config> use instead of contents of resolv.conf\n",
+ stdout);
}
static void usage(void) {
extern char *optarg;
FILE *inf;
- if (argv[1] && !strcmp(argv[1],"--help")) {
- printhelp(stdout);
+ if (argv[1] && !strncmp(argv[1],"--",2)) {
+ if (!strcmp(argv[1],"--help")) {
+ printhelp(stdout);
+ } else if (!strcmp(argv[1],"--version")) {
+ fputs(VERSION_MESSAGE("adnslogres"),stdout);
+ } else {
+ usage();
+ }
if (ferror(stdout) || fclose(stdout)) { perror("stdout"); exit(1); }
exit(0);
}
#include "adns.h"
#include "dlist.h"
#include "tvarith.h"
+#include "client.h"
#ifdef ADNS_REGRESS_TEST
# include "hredirect.h"
return 0;
}
-static void quit(int exitstatus) NONRETURNING;
-static void quit(int exitstatus) {
+void quitnow(int exitstatus) {
nonblock(0,0);
nonblock(1,0);
exit(exitstatus);
static void sysfail(const char *what) NONRETURNING;
static void sysfail(const char *what) {
fprintf(stderr,"adnsresfilter: system call failed: %s: %s\n",what,strerror(errno));
- quit(2);
+ quitnow(2);
}
static void *xmalloc(size_t sz) {
static void usage(void) {
if (printf("usage: adnsresfilter [<options ...>]\n"
- " adnsresfilter -h|--help\n"
+ " adnsresfilter -h|--help | --version\n"
"options: -t<milliseconds>|--timeout <milliseconds>\n"
" -w|--wait (always wait for queries to time out or fail)\n"
" -b|--brackets (require [...] around IP addresses)\n"
static void usageerr(const char *why) {
fprintf(stderr,"adnsresfilter: bad usage: %s\n",why);
usage();
- quit(1);
+ quitnow(1);
}
static void adnsfail(const char *what, int e) NONRETURNING;
static void adnsfail(const char *what, int e) {
fprintf(stderr,"adnsresfilter: adns call failed: %s: %s\n",what,strerror(e));
- quit(2);
+ quitnow(2);
}
static void settimeout(const char *arg) {
} else if (!strcmp(arg,"--debug")) {
initflags |= adns_if_debug;
} else if (!strcmp(arg,"--help")) {
- usage(); quit(0);
+ usage(); quitnow(0);
+ } else if (!strcmp(arg,"--version")) {
+ VERSION_PRINT_QUIT("adnsresfilter"); quitnow(0);
} else {
usageerr("unknown long option");
}
break;
case 'h':
usage();
- quit(0);
+ quitnow(0);
default:
usageerr("unknown short option");
}
--- /dev/null
+/*
+ * clients.h
+ * - useful declarations and definitions for adns client programs
+ */
+/*
+ * This file is
+ * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
+ *
+ * It is part of adns, which is
+ * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
+ * Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *
+ * 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 02111-1307, USA.
+ */
+
+#ifndef CLIENT_H_INCLUDED
+#define CLIENT_H_INCLUDED
+
+#define ADNS_VERSION_STRING "1.0"
+
+#define COPYRIGHT_MESSAGE \
+ "Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>\n" \
+ "Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>\n" \
+ "This is free software; see the source for copying conditions. There is NO\n" \
+ "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
+
+#define VERSION_MESSAGE(program) \
+ program " (GNU adns) " ADNS_VERSION_STRING "\n\n" COPYRIGHT_MESSAGE
+
+#define VERSION_PRINT_QUIT(program) \
+ if (fputs(VERSION_MESSAGE(program),stdout) == EOF || \
+ fclose(stdout)) { \
+ perror(program ": write version message"); \
+ quitnow(-1); \
+ } \
+ quitnow(0);
+
+void quitnow(int rc) NONRETURNING;
+
+#endif