/* * Authors: Petr Spacek * * Copyright (C) 2012 Red Hat * see file 'COPYING' for use and warranty information * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; version 2 or later * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include void logger(const char *format, ...) { va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); } #define CHECK(op) \ do { \ logger("%4u: %s = ", __LINE__, #op); \ result = (op); \ logger("%s\n", dns_result_totext(result)); \ if (result != ISC_R_SUCCESS) \ goto cleanup; \ } while (0) int main (int argc, char ** argv) { isc_result_t result = ISC_R_SUCCESS; dns_db_t *rbtdb = NULL; isc_mem_t *mctx = NULL; void *node = NULL; CHECK(isc_mem_create2(0, 0, &mctx, ISC_MEMFLAG_DEFAULT)); CHECK(isc_hash_create(mctx, NULL, 256)); CHECK(dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &rbtdb)); CHECK(dns_db_getoriginnode(rbtdb, &node)); dns_db_printnode(rbtdb, node, stderr); dns_db_detachnode(rbtdb, &node); CHECK(dns_db_getoriginnode(rbtdb, &node)); dns_db_printnode(rbtdb, node, stderr); dns_db_detachnode(rbtdb, &node); cleanup: if (result != ISC_R_SUCCESS) logger("error: %s\n", dns_result_totext(result)); (void) argc; (void) argv; return 0; }