zonetodb.c revision e6f82b9dbba43699d9f8231a566ec4830da2cee5
/*
* Copyright (C) 2000 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: zonetodb.c,v 1.2 2000/11/17 22:01:45 bwelling Exp $ */
#include <dns/dbiterator.h>
#include <dns/fixedname.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <pgsql/libpq-fe.h>
/*
* Generate a PostgreSQL table from a zone.
*
* This is compiled this with something like the following (assuming bind9 has
* been installed):
*
* gcc -g `isc-config.sh --cflags isc dns` -c zonetodb.c
* gcc -g -o zonetodb zonetodb.o `isc-config.sh --libs isc dns` -lpq
*/
char str[10240];
void
closeandexit(int status) {
}
void
if (result != ISC_R_SUCCESS) {
closeandexit(1);
}
}
void
unsigned char typearray[20];
unsigned char dataarray[2048];
isc_buffer_t b;
namearray[isc_buffer_usedlength(&b)] = 0;
typearray[isc_buffer_usedlength(&b)] = 0;
dataarray[isc_buffer_usedlength(&b)] = 0;
"INSERT INTO %s (NAME, RDTYPE, RDATA)"
" VALUES ('%s', '%s', '%s')",
closeandexit(1);
}
}
int
isc_buffer_t b;
if (argc != 5) {
printf("Note that dbname must be an existing database.\n");
exit(1);
}
closeandexit(1);
}
"DROP TABLE %s", dbtable);
closeandexit(1);
}
"CREATE TABLE %s (NAME TEXT, RDTYPE TEXT, RDATA TEXT)",
dbtable);
closeandexit(1);
}
while (result == ISC_R_SUCCESS) {
if (result == ISC_R_NOMORE)
break;
while (result == ISC_R_SUCCESS) {
while (result == ISC_R_SUCCESS) {
}
}
}
closeandexit(1);
}
dns_db_detach(&db);
closeandexit(0);
}