remove need for -DDEBUG from resolver code (conflict with db/hash)

This commit is contained in:
Paul Traina 1994-09-25 17:45:41 +00:00
parent 1359438003
commit 8bdba3f880
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3094
7 changed files with 37 additions and 76 deletions

View File

@ -12,10 +12,6 @@ SRCS+= gethostbydns.c gethostbyht.c gethostbynis.c gethostnamadr.c \
res_debug.c res_init.c res_mkquery.c res_query.c res_send.c \
send.c
# dig(1) requires the resolver to be compiled with debugging enabled
# if you don't care abut dig, you may comment this out
CFLAGS+=-DDEBUG
# machine-dependent net sources
.include "${.CURDIR}/${MACHINE}/net/Makefile.inc"

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: gethnamaddr.c,v 4.9.1.19 1994/07/22 08:42:54 vixie Exp $";
static char rcsid[] = "$Id: gethostbydns.c,v 1.1 1994/09/25 02:12:05 pst Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -327,10 +327,8 @@ gethostanswer(answer, anslen, qname, qclass, qtype)
bp += sizeof(align) - ((u_long)bp % sizeof(align));
if (bp + n >= &hostbuf[sizeof hostbuf]) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf("size (%d) too big\n", n);
#endif
had_error++;
continue;
}
@ -417,10 +415,8 @@ _gethostbydnsname(name)
}
if ((n = res_search(name, C_IN, T_A, buf.buf, sizeof(buf))) < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf("res_search failed\n");
#endif
return (NULL);
}
return (gethostanswer(&buf, n, name, C_IN, T_A));
@ -445,10 +441,8 @@ _gethostbydnsaddr(addr, len, type)
((unsigned)addr[0] & 0xff));
n = res_query(qbuf, C_IN, T_PTR, (u_char *)buf.buf, sizeof buf.buf);
if (n < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf("res_query failed\n");
#endif
return (NULL);
}
if (!(hp = gethostanswer(&buf, n, qbuf, C_IN, T_PTR)))

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: getnetbydns.c,v 1.1 1994/09/25 02:12:20 pst Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -253,10 +253,8 @@ _getnetbydnsaddr(net, net_type)
}
anslen = res_query(qbuf, C_IN, T_PTR, buf.buf, sizeof buf.buf);
if (anslen < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf("res_query failed\n");
#endif
return (NULL);
}
net_entry = getnetanswer(&buf, anslen, BYADDR);
@ -283,10 +281,8 @@ _getnetbydnsname(net)
(void)strcpy(&qbuf[0],net);
anslen = res_search(qbuf, C_IN, T_PTR, buf.buf, sizeof buf.buf);
if (anslen < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf("res_query failed\n");
#endif
return NULL;
}
return getnetanswer(&buf, anslen, BYNAME);

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static char rcsid[] = "$Id: res_init.c,v 4.9.1.12 1994/06/11 22:05:04 vixie Exp $";
static char rcsid[] = "$Id: res_init.c,v 1.2 1994/09/25 02:12:36 pst Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -341,7 +341,6 @@ res_init()
dots--;
}
*pp = NULL;
#ifdef DEBUG
if (_res.options & RES_DEBUG) {
printf(";; res_init()... default dnsrch list:\n");
for (pp = _res.dnsrch; *pp; pp++) {
@ -349,7 +348,6 @@ res_init()
}
printf(";;\t..END..\n");
}
#endif /*DEBUG*/
#endif /*!RFC1535*/
}
@ -368,12 +366,10 @@ res_setoptions(options, source)
char *cp = options;
int i;
#ifdef DEBUG
if (_res.options & RES_DEBUG) {
printf(";; res_setoptions(\"%s\", \"%s\")...\n",
options, source);
}
#endif
while (*cp) {
/* skip leading and inner runs of spaces */
while (*cp == ' ' || *cp == '\t')
@ -385,20 +381,16 @@ res_setoptions(options, source)
_res.ndots = i;
else
_res.ndots = RES_MAXNDOTS;
#ifdef DEBUG
if (_res.options & RES_DEBUG) {
printf(";;\tndots=%d\n", _res.ndots);
}
#endif
} else if (!strncmp(cp, "debug", sizeof("debug")-1)) {
#ifdef DEBUG
if (!(_res.options & RES_DEBUG)) {
printf(";; res_setoptions(\"%s\", \"%s\")..\n",
options, source);
_res.options |= RES_DEBUG;
}
printf(";;\tdebug\n");
#endif
} else {
/* XXX - print a warning here? */
}

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: res_mkquery.c,v 4.9.1.7 1994/06/01 21:09:58 vixie Exp $";
static char rcsid[] = "$Id: res_mkquery.c,v 1.2 1994/09/25 02:12:38 pst Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -85,11 +85,9 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
struct rrec *newrr = (struct rrec *) newrr_in;
u_char *dnptrs[20], **dpp, **lastdnptr;
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf(";; res_mkquery(%d, %s, %d, %d)\n",
op, dname, class, type);
#endif
/*
* Initialize header fields.
*/

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: res_query.c,v 4.9.1.13 1994/06/11 22:05:04 vixie Exp $";
static char rcsid[] = "$Id: res_query.c,v 1.2 1994/09/25 02:12:41 pst Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -111,37 +111,29 @@ res_query(name, class, type, answer, anslen)
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
return (-1);
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf(";; res_query(%s, %d, %d)\n", name, class, type);
#endif
n = res_mkquery(QUERY, name, class, type, NULL, 0, NULL,
buf, sizeof(buf));
if (n <= 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf(";; res_query: mkquery failed\n");
#endif
h_errno = NO_RECOVERY;
return (n);
}
n = res_send(buf, n, answer, anslen);
if (n < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf(";; res_query: send error\n");
#endif
h_errno = TRY_AGAIN;
return (n);
}
if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf(";; rcode = %d, ancount=%d\n", hp->rcode,
ntohs(hp->ancount));
#endif
switch (hp->rcode) {
case NXDOMAIN:
h_errno = HOST_NOT_FOUND;
@ -321,11 +313,9 @@ res_querydomain(name, domain, class, type, answer, anslen)
const char *longname = nbuf;
int n;
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf(";; res_querydomain(%s, %s, %d, %d)\n",
name, domain?domain:"<Nil>", class, type);
#endif
if (domain == NULL) {
/*
* Check for trailing '.';

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: res_send.c,v 4.9.1.12 1994/06/26 04:00:18 vixie Exp $";
static char rcsid[] = "$Id: res_send.c,v 1.2 1994/09/25 02:12:49 pst Exp $";
#endif /* LIBC_SCCS and not lint */
/* change this to "0"
@ -87,50 +87,45 @@ static int s = -1; /* socket used for communications */
static int connected = 0; /* is the socket connected */
static int vc = 0; /* is the socket a virtual ciruit? */
#ifndef DEBUG
# define Dprint(cond, args) /*empty*/
# define DprintQ(cond, args, query) /*empty*/
# define Aerror(file, string, error, address) /*empty*/
# define Perror(file, string, error) /*empty*/
#else
# define Dprint(cond, args) if (cond) {fprintf args;} else {}
# define DprintQ(cond, args, query) if (cond) {\
fprintf args;\
__p_query(query);\
} else {}
static void
Aerror(file, string, error, address)
FILE *file;
char *string;
int error;
struct sockaddr_in address;
{
int save = errno;
if (_res.options & RES_DEBUG) {
fprintf(file, "res_send: %s ([%s].%d): %s\n",
string,
inet_ntoa(address.sin_addr),
address.sin_port,
strerror(error));
}
errno = save;
}
static void
Perror(file, string, error)
FILE *file;
char *string;
int error;
{
int save = errno;
static void
Aerror(file, string, error, address)
FILE *file;
char *string;
int error;
struct sockaddr_in address;
{
int save = errno;
if (_res.options & RES_DEBUG) {
fprintf(file, "res_send: %s: %s\n",
string, strerror(error));
}
errno = save;
if (_res.options & RES_DEBUG) {
fprintf(file, "res_send: %s ([%s].%d): %s\n",
string,
inet_ntoa(address.sin_addr),
address.sin_port,
strerror(error));
}
#endif
errno = save;
}
static void
Perror(file, string, error)
FILE *file;
char *string;
int error;
{
int save = errno;
if (_res.options & RES_DEBUG) {
fprintf(file, "res_send: %s: %s\n",
string, strerror(error));
}
errno = save;
}
static res_send_qhook Qhook = NULL;
static res_send_rhook Rhook = NULL;