From 35fc70096e948281feb4bb0a62a0c05fef485830 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Sun, 28 Aug 2005 14:51:35 +0000 Subject: Fix crash when run standalone with no arguments. Print usage if wrong argument count. Rename trigger from TESTMAIN to STANDALONE. svn path=/trunk/; revision=4274 --- mxget.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mxget.c b/mxget.c index 5cc41064..28831d5a 100644 --- a/mxget.c +++ b/mxget.c @@ -117,12 +117,19 @@ struct mxentry *getmxrecords(const char *name) } #endif /* HAVE_RES_SEARCH */ -#ifdef TESTMAIN -main(int argc, char *argv[]) +#ifdef STANDALONE +#include + +int main(int argc, char *argv[]) { int count, i; struct mxentry *responses; + if (argc != 2 || 0 == strcmp(argv[1], "-h")) { + fprintf(stderr, "Usage: %s domain\n", argv[0]); + exit(1); + } + responses = getmxrecords(argv[1]); if (responses == (struct mxentry *)NULL) puts("No MX records found"); -- cgit v1.2.3