aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2005-08-28 14:51:35 +0000
committerMatthias Andree <matthias.andree@gmx.de>2005-08-28 14:51:35 +0000
commit35fc70096e948281feb4bb0a62a0c05fef485830 (patch)
treef250b9045e13e16f2d63733bd7c577bc03da23ae
parenta265e608020ddefc6fcc6e17ff2ec38e94791838 (diff)
downloadfetchmail-35fc70096e948281feb4bb0a62a0c05fef485830.tar.gz
fetchmail-35fc70096e948281feb4bb0a62a0c05fef485830.tar.bz2
fetchmail-35fc70096e948281feb4bb0a62a0c05fef485830.zip
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
-rw-r--r--mxget.c11
1 files 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 <stdlib.h>
+
+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");