zone2sqlite.c revision 4259095c8058beb9b475f1884dbeda375979e6f6
/*
* Copyright (C) 2007 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: zone2sqlite.c,v 1.1 2007/03/05 05:30:22 marka Exp $ */
#include <stdlib.h>
#include <string.h>
#include <dns/dbiterator.h>
#include <dns/fixedname.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/rdatatype.h>
#include <sqlite3.h>
#ifndef UNUSED
#define UNUSED(x) (x) = (x)
#endif
/*
* Generate an SQLite table from a zone.
*/
typedef struct _dbinfo {
char *filename;
char *table;
} dbinfo_t;
static void
closeandexit(int status)
{
}
}
static void
{
if (result != ISC_R_SUCCESS) {
closeandexit(1);
}
}
static isc_result_t
{
return (ISC_R_SUCCESS);
} else {
/* a connection is returned even if the open fails */
return (ISC_R_FAILURE);
}
}
static int
{
return 0;
}
static void
{
unsigned char typearray[20];
unsigned char dataarray[2048];
isc_buffer_t b;
char *sql;
int res;
namearray[isc_buffer_usedlength(&b)] = 0;
typearray[isc_buffer_usedlength(&b)] = 0;
dataarray[isc_buffer_usedlength(&b)] = 0;
"INSERT INTO %q (NAME, TTL, RDTYPE, RDATA)"
" VALUES ('%q', %d, '%q', '%q') ",
closeandexit(1);
}
}
int
{
char *sql;
int res;
isc_buffer_t b;
if (argc != 5) {
exit(1);
}
if (result == DNS_R_SEENINCLUDE)
closeandexit(1);
}
#if 0
}
#endif
#if 0
closeandexit(1);
}
#endif
"CREATE TABLE %q "
"(NAME TEXT, TTL INTEGER, RDTYPE TEXT, RDATA TEXT) ",
closeandexit(1);
}
while (result == ISC_R_SUCCESS) {
if (result == ISC_R_NOMORE)
break;
while (result == ISC_R_SUCCESS) {
while (result == ISC_R_SUCCESS) {
}
}
}
#if 0
closeandexit(1);
}
#endif
dns_db_detach(&db);
closeandexit(0);
exit(0);
}