tcldb.c revision 499b34cea04a46823d003d4c0520c8b03e8513cb
/*
* Copyright (C) 2000, 2001 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.
*/
/* $Id: tcldb.c,v 1.7 2001/01/09 21:46:28 bwelling Exp $ */
/*
* 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 rrc; /* RR count */
char **rrv; /* RR vector */
int i;
char *cmdv[3];
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++) {
int fieldc; /* Field count */
char **fieldv; /* Field vector */
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.
*/
static dns_sdbmethods_t tcldb_methods = {
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)
}