/*
* Copyright (C) 2004, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000, 2001 Internet Software Consortium.
*
* 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.
*/
/* $Id$ */
/*
* A simple database driver that calls a Tcl procedure to define
* the contents of the DNS namespace. The procedure is loaded
* from the file lookup.tcl; look at the comments there for
* more information.
*/
#include <config.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <tcl.h>
#include <tcldb.h>
} while (0)
typedef struct tcldb_driver {
static isc_result_t
int tclres;
return (ISC_R_NOMEMORY);
"initializing tcldb: "
"loading 'lookup.tcl' failed: %s",
goto cleanup;
}
return (ISC_R_SUCCESS);
return (result);
}
static void
}
/*
* Perform a lookup, by invoking the Tcl procedure "lookup".
*/
static isc_result_t
{
int tclres;
int i;
char *cmd;
cmdv[0] = "lookup";
"zone '%s': tcl lookup function failed: %s",
return (ISC_R_FAILURE);
}
goto fail;
}
goto malformed;
for (i = 0; i < rrc; i++) {
goto failrr;
}
if (fieldc != 3)
goto malformed;
fieldv[2]);
if (tmpres != ISC_R_SUCCESS)
}
if (result == ISC_R_SUCCESS)
return (result);
"zone '%s': "
"malformed return value from tcl lookup function: %s",
fail:
return (result);
}
/*
* Set up per-zone state. In our case, the database arguments of the
* zone are collected into a Tcl list and assigned to an element of
* the global array "dbargs".
*/
static isc_result_t
void *driverdata, void **dbdata)
{
*dbdata = driverdata;
return (ISC_R_SUCCESS);
}
/*
* This driver does not support zone transfer, so allnodes() is NULL.
*/
NULL, /* authority */
NULL, /* allnodes */
NULL /* destroy */
};
/*
* Initialize the tcldb driver.
*/
tcldb_init(void) {
if (result != ISC_R_SUCCESS)
return (result);
}
/*
* Wrapper around dns_sdb_unregister().
*/
void
tcldb_clear(void) {
if (the_driver != NULL)
}