diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2005-08-28 14:51:35 +0000 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2005-08-28 14:51:35 +0000 |
commit | 35fc70096e948281feb4bb0a62a0c05fef485830 (patch) | |
tree | f250b9045e13e16f2d63733bd7c577bc03da23ae | |
parent | a265e608020ddefc6fcc6e17ff2ec38e94791838 (diff) | |
download | fetchmail-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.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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"); |