+ pmx[ind].name = (char *)NULL;
+ pmx[ind].pref = -1;
+ return(pmx);
+}
+#endif /* HAVE_RES_SEARCH */
+
+#ifdef STANDALONE
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+#ifdef HAVE_RES_SEARCH
+ struct mxentry *responses;
+#endif
+
+ if (argc != 2 || 0 == strcmp(argv[1], "-h")) {
+ fprintf(stderr, "Usage: %s domain\n", argv[0]);
+ exit(1);
+ }
+
+#ifdef HAVE_RES_SEARCH
+ responses = getmxrecords(argv[1]);
+ if (responses == (struct mxentry *)NULL) {
+ puts("No MX records found");
+ } else {
+ do {
+ printf("%s %d\n", responses->name, responses->pref);
+ } while ((++responses)->name);
+ }
+#else
+ puts("This program was compiled without HAS_RES_SEARCH and does nothing.");
+#endif
+
+ return 0;