/*
* mxget.c -- fetch MX records for given DNS name
*
- * Copyright 1996 by Eric S. Raymond
- * All rights reserved.
+ * Copyright 1997 by Eric S. Raymond
* For license terms, see the file COPYING in this directory.
*/
#include "config.h"
#ifdef HAVE_RES_SEARCH
+#include <stdio.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
/* minimum possible size of MX record in packet */
#define MIN_MX_SIZE 8 /* corresp to "a.com 0" w/ terminating space */
-struct mxentry *getmxrecords(name)
+struct mxentry *getmxrecords(const unsigned char *name)
/* get MX records for given host */
-const char *name;
{
unsigned char answer[PACKETSZ], *eom, *cp, *bp;
int n, ancount, qdcount, buflen, type, pref, ind;
static char MXHostBuf[PACKETSZ - HFIXEDSZ];
HEADER *hp;
- n = res_search(name,C_IN,T_MX,(unsigned char*)&answer, sizeof(answer));
+ pmx->name = (char *)NULL;
+ pmx->pref = -1;
+ n = res_search((char *)name,
+ C_IN,T_MX, (unsigned char*)&answer, sizeof(answer));
if (n == -1)
return((struct mxentry *)NULL);
pmx[ind].pref = pref;
++ind;
- n = strlen(bp);
+ n = strlen((const char *)bp);
bp += n;
*bp++ = '\0';