hesiod.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#endif
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file is primarily maintained by <tytso@mit.edu> and <ghudson@mit.edu>.
*/
/*
* hesiod.c --- the core portion of the hesiod resolver.
*
* This file is derived from the hesiod library from Project Athena;
* It has been extensively rewritten by Theodore Ts'o to have a more
* thread-safe interface.
*/
/* Imports */
#include "port_before.h"
#include <errno.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "port_after.h"
#include "pathnames.h"
#include "hesiod.h"
#include "hesiod_p.h"
/* Forward */
int hesiod_init(void **context);
void hesiod_end(void *context);
const char *type);
const char *type);
const char *name);
/* Public */
/*
* This function is called to initialize a hesiod_p.
*/
int
hesiod_init(void **context) {
char *cp;
if (ctx == 0) {
return (-1);
}
#ifdef ORIGINAL_ISC_CODE
#else
#endif /* ORIGINAL_ISC_CODE */
#ifdef DEF_RHS
/*
* Use compiled in defaults.
*/
goto cleanup;
}
#ifdef HAVE_STRLCPY
#else
#endif
#else
goto cleanup;
#endif
}
/*
* The default RHS can be overridden by an environment
* variable.
*/
goto cleanup;
}
if (cp[0] == '.') {
#ifdef HAVE_STRLCPY
#else
#endif
} else {
#ifdef HAVE_STRLCPY
#else
#endif
#ifdef HAVE_STRLCAT
#else
#endif
}
}
/*
* If there is no default hesiod realm set, we return an
* error.
*/
goto cleanup;
}
#if 0
goto cleanup;
#endif
return (0);
return (-1);
}
/*
* This function deallocates the hesiod_p
*/
void
hesiod_end(void *context) {
int save_errno = errno;
errno = save_errno;
}
/*
* This function takes a hesiod (name, type) and returns a DNS
* name which is to be resolved.
*/
char *
char *bindname;
/* Decide what our RHS is, and set cp to the end of the actual name. */
"rhs-extension")) != NULL)
else {
return (NULL);
}
} else {
}
/*
* Allocate the space we need, including up to three periods and
* the terminating NUL.
*/
if (rhs_list)
return NULL;
}
/* Now put together the DNS name. */
}
if (RHS[0] != '.')
if (rhs_list)
return (bindname);
}
/*
* This is the core function. Given a hesiod (name, type), it
* returns an array of strings returned by the resolver.
*/
char **
char **retvec;
return (NULL);
return (NULL);
}
return (retvec);
}
return (NULL);
return (retvec);
}
void
char **p;
for (p = list; *p; p++)
free(*p);
}
/*
* This function parses the /etc/hesiod.conf file
*/
static int
/*
* Clear the existing configuration variable, just in case
* they're set.
*/
/*
* Now open and parse the file...
*/
return (-1);
continue;
cp++;
cp++;
*cp++ = '\0';
cp++;
cp++;
*cp++ = '\0';
else
continue;
if (!*cpp) {
goto cleanup;
}
}
return (0);
return (-1);
}
/*
* Given a DNS class and a DNS name, do a lookup for TXT records, and
* return a list of them.
*/
static char **
struct {
int type; /* RR type */
int class; /* RR class */
int dlen; /* len of data section */
} rr;
int i, j, n, skip;
/*
* Construct the query and send it.
*/
if (n < 0) {
return (NULL);
}
if (n < 0) {
return (NULL);
}
if (n < HFIXEDSZ) {
return (NULL);
}
/*
* OK, parse the result.
*/
/* Skip query, trying to get to the answer section which follows. */
for (i = 0; i < qdcount; i++) {
return (NULL);
}
}
if (!list) {
return (NULL);
}
j = 0;
for (i = 0; i < ancount; i++) {
if (skip < 0) {
goto cleanup;
}
goto cleanup;
}
goto cleanup;
}
continue;
goto cleanup;
n = (unsigned char) *cp++;
goto cleanup;
}
cp += n;
dst += n;
}
goto cleanup;
}
*dst = '\0';
}
if (j == 0) {
goto cleanup;
}
return (list);
for (i = 0; i < j; i++)
return (NULL);
}
struct __res_state *
__hesiod_res_get(void *context) {
struct __res_state *res;
return (NULL);
}
}
}
void
void (*free_res)(void *)) {
}
}
static int
return (-1);
return (-1);
return (0);
}