version 1.7, 2006/01/24 17:41:25 |
version 1.7.4.1, 2007/05/17 00:43:53 |
|
|
#if defined(LIBC_SCCS) && !defined(lint) |
#if defined(LIBC_SCCS) && !defined(lint) |
#ifdef notdef |
#ifdef notdef |
static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; |
static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; |
static const char rcsid[] = "Id: res_query.c,v 1.2.2.3.4.2 2004/03/16 12:34:19 marka Exp"; |
static const char rcsid[] = "Id: res_query.c,v 1.7.18.1 2005/04/27 05:01:11 sra Exp"; |
#else |
#else |
__RCSID("$NetBSD$"); |
__RCSID("$NetBSD$"); |
#endif |
#endif |
Line 118 __weak_alias(res_hostalias,__res_hostali |
|
Line 118 __weak_alias(res_hostalias,__res_hostali |
|
#define MAXPACKET 1024 |
#define MAXPACKET 1024 |
#endif |
#endif |
|
|
/* |
/*% |
* Formulate a normal query, send, and await answer. |
* Formulate a normal query, send, and await answer. |
* Returned answer is placed in supplied buffer "answer". |
* Returned answer is placed in supplied buffer "answer". |
* Perform preliminary check of answer, returning success only |
* Perform preliminary check of answer, returning success only |
Line 130 __weak_alias(res_hostalias,__res_hostali |
|
Line 130 __weak_alias(res_hostalias,__res_hostali |
|
*/ |
*/ |
int |
int |
res_nquery(res_state statp, |
res_nquery(res_state statp, |
const char *name, /* domain name */ |
const char *name, /*%< domain name */ |
int class, int type, /* class and type of query */ |
int class, int type, /*%< class and type of query */ |
u_char *answer, /* buffer to put answer */ |
u_char *answer, /*%< buffer to put answer */ |
int anslen) /* size of answer buffer */ |
int anslen) /*%< size of answer buffer */ |
{ |
{ |
u_char buf[MAXPACKET]; |
u_char buf[MAXPACKET]; |
HEADER *hp = (HEADER *)(void *)answer; |
HEADER *hp = (HEADER *)(void *)answer; |
Line 143 res_nquery(res_state statp, |
|
Line 143 res_nquery(res_state statp, |
|
oflags = statp->_flags; |
oflags = statp->_flags; |
|
|
again: |
again: |
hp->rcode = NOERROR; /* default */ |
hp->rcode = NOERROR; /*%< default */ |
|
|
#ifdef DEBUG |
#ifdef DEBUG |
if (statp->options & RES_DEBUG) |
if (statp->options & RES_DEBUG) |
printf(";; res_query(%s, %d, %d)\n", name, class, type); |
printf(";; res_query(%s, %d, %d)\n", name, class, type); |
|
|
return (n); |
return (n); |
} |
} |
|
|
/* |
/*% |
* Formulate a normal query, send, and retrieve answer in supplied buffer. |
* Formulate a normal query, send, and retrieve answer in supplied buffer. |
* Return the size of the response on success, -1 on error. |
* Return the size of the response on success, -1 on error. |
* If enabled, implement search rules until answer or unrecoverable failure |
* If enabled, implement search rules until answer or unrecoverable failure |
|
|
*/ |
*/ |
int |
int |
res_nsearch(res_state statp, |
res_nsearch(res_state statp, |
const char *name, /* domain name */ |
const char *name, /*%< domain name */ |
int class, int type, /* class and type of query */ |
int class, int type, /*%< class and type of query */ |
u_char *answer, /* buffer to put answer */ |
u_char *answer, /*%< buffer to put answer */ |
int anslen) /* size of answer */ |
int anslen) /*%< size of answer */ |
{ |
{ |
const char *cp, * const *domain; |
const char *cp, * const *domain; |
HEADER *hp = (HEADER *)(void *)answer; |
HEADER *hp = (HEADER *)(void *)answer; |
Line 239 res_nsearch(res_state statp, |
|
Line 238 res_nsearch(res_state statp, |
|
int searched = 0; |
int searched = 0; |
|
|
errno = 0; |
errno = 0; |
RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); /* True if we never query. */ |
RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); /*%< True if we never query. */ |
|
|
dots = 0; |
dots = 0; |
for (cp = name; *cp != '\0'; cp++) |
for (cp = name; *cp != '\0'; cp++) |
dots += (*cp == '.'); |
dots += (*cp == '.'); |
Line 365 res_nsearch(res_state statp, |
|
Line 363 res_nsearch(res_state statp, |
|
return (-1); |
return (-1); |
} |
} |
|
|
/* |
/*% |
* Perform a call on res_query on the concatenation of name and domain, |
* Perform a call on res_query on the concatenation of name and domain, |
* removing a trailing dot from name if domain is NULL. |
* removing a trailing dot from name if domain is NULL. |
*/ |
*/ |
|
|
res_nquerydomain(res_state statp, |
res_nquerydomain(res_state statp, |
const char *name, |
const char *name, |
const char *domain, |
const char *domain, |
int class, int type, /* class and type of query */ |
int class, int type, /*%< class and type of query */ |
u_char *answer, /* buffer to put answer */ |
u_char *answer, /*%< buffer to put answer */ |
int anslen) /* size of answer */ |
int anslen) /*%< size of answer */ |
{ |
{ |
char nbuf[MAXDNAME]; |
char nbuf[MAXDNAME]; |
const char *longname = nbuf; |
const char *longname = nbuf; |
Line 457 res_hostalias(const res_state statp, con |
|
Line 455 res_hostalias(const res_state statp, con |
|
fclose(fp); |
fclose(fp); |
return (NULL); |
return (NULL); |
} |
} |
|
|
|
/*! \file */ |