tcldb.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2000, 2001, 2004, 2007, 2011, 2014, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: tcldb.c,v 1.12 2011/10/11 23:46:45 tbox 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".
*/
#ifdef DNS_CLIENTINFO_VERSION
static isc_result_t
#else
static isc_result_t
#endif /* DNS_CLIENTINFO_VERSION */
{
int tclres;
int rrc; /* RR count */
char **rrv; /* RR vector */
int i;
char *cmdv[3];
char *cmd;
#ifdef DNS_CLIENTINFO_VERSION
#endif /* DNS_CLIENTINFO_VERSION */
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 */
NULL /* lookup2 */
};
/*
* 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)
}