db.c revision b3e2e7c4d6b5c5ee90ba5bb775d635834dccec81
5cd4555ad444fd391002ae32450572054369fd42Rob Austein * Copyright (C) 1999 Internet Software Consortium.
4b01d45a49f1c2cc4bddc9a1b4c78232867de134Andreas Gustafsson * Permission to use, copy, modify, and distribute this software for any
938440694b33cd752e9e4b71a526368b4811c177Tinderbox User * purpose with or without fee is hereby granted, provided that the above
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews * copyright notice and this permission notice appear in all copies.
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
4b01d45a49f1c2cc4bddc9a1b4c78232867de134Andreas Gustafsson * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
4b01d45a49f1c2cc4bddc9a1b4c78232867de134Andreas Gustafsson * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
4b01d45a49f1c2cc4bddc9a1b4c78232867de134Andreas Gustafsson * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein *** Private Types
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeintypedef struct {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein dns_result_t (*create)(isc_mem_t *mctx, dns_name_t *name,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein *** Supported DB Implementations Registry
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Supported database implementations must be registered here.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * It might be nice to generate this automatically some day.
821350367e2c7313c02eb275e8e05d5193b47cfdJeremy C. Reed *** Basic DB Methods
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeindns_db_create(isc_mem_t *mctx, char *db_type, dns_name_t *origin,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein unsigned int argc, char *argv[], dns_db_t **dbp)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Create a new database using implementation 'db_type'.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein for (impinfo = implementations; impinfo->name != NULL; impinfo++)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein return ((impinfo->create)(mctx, origin, cache, rdclass,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeindns_db_attach(dns_db_t *source, dns_db_t **targetp) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Attach *targetp to source.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Detach *dbp from its database.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Does 'db' have cache semantics?
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Does 'db' have zone semantics?
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Is 'db' secure?
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein REQUIRE((db->attributes & DNS_DBATTR_CACHE) == 0);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * The origin of the database.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * The class of the database.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeindns_db_beginload(dns_db_t *db, dns_addrdatasetfunc_t *addp,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Begin loading 'db'.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein return ((db->methods->beginload)(db, addp, dbloadp));
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeindns_db_endload(dns_db_t *db, dns_dbload_t **dbloadp) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Finish loading 'db'.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Load master file 'filename' into 'db'.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein result = dns_db_beginload(db, &callbacks.add, &callbacks.add_private);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein result = dns_master_loadfile(filename, &db->origin, &db->origin,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein eresult = dns_db_endload(db, &callbacks.add_private);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * We always call dns_db_endload(), but we only want to return its
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * result if dns_master_loadfile() succeeded. If dns_master_loadfile()
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * failed, we want to return the result code it gave us.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeindns_db_dump(dns_db_t *db, dns_dbversion_t *version, char *filename) {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Dump 'db' into master file 'filename'.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein return ((db->methods->dump)(db, version, filename));
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein *** Version Methods
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeindns_db_currentversion(dns_db_t *db, dns_dbversion_t **versionp) {
iteratorp));
newrdataset));