Commit 65c9645c authored by James Brister's avatar James Brister
Browse files

Support new 'database' statement in zone.

	database "quoted-string";
parent 7aedafe2
......@@ -172,6 +172,7 @@ controls {
zone "master.demo.zone" {
type master; // what used to be called "primary"
database "somedb -option1 -option2 arg1 arg2 arg3";
file "master.demo.zone";
check-names fail;
allow-update { none; };
......
......@@ -16,7 +16,7 @@
* SOFTWARE.
*/
/* $Id: confparser.y,v 1.71 2000/05/03 19:29:38 brister Exp $ */
/* $Id: confparser.y,v 1.72 2000/05/06 10:18:46 brister Exp $ */
#include <config.h>
......@@ -250,6 +250,7 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult);
%token L_CONTROLS
%token L_CORESIZE
%token L_DATASIZE
%token L_DATABASE
%token L_DEALLOC_ON_EXIT
%token L_DEBUG
%token L_DEFAULT
......@@ -396,7 +397,6 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult);
%type <ipaddress> query_source_v6
%type <ipaddress> ip_and_port_element
%type <iplist> in_addr_list
%type <iplist> notify_in_addr_list
%type <iplist> opt_in_addr_list
%type <iplist> opt_zone_forwarders_list
%type <iplist> port_ip_list
......@@ -3925,7 +3925,7 @@ zone_non_type_keywords: L_FILE | L_FILE_IXFR | L_IXFR_TMP | L_MASTERS |
L_MAX_TRANSFER_TIME_OUT | L_MAX_TRANSFER_IDLE_IN |
L_MAX_TRANSFER_IDLE_OUT | L_MAX_LOG_SIZE_IXFR | L_NOTIFY |
L_MAINTAIN_IXFR_BASE | L_PUBKEY | L_ALSO_NOTIFY | L_DIALUP |
L_DISABLED
L_DISABLED | L_DATABASE
;
......@@ -4367,13 +4367,29 @@ zone_option: L_FILE L_QSTRING
{
disabled = ISC_TRUE;
}
| zone_update_policy
;
| L_DATABASE L_QSTRING
{
dns_c_zone_t *zone = dns_c_ctx_getcurrzone(currcfg);
INSIST(zone != NULL);
notify_in_addr_list: opt_in_addr_list
tmpres = dns_c_zone_setdatabase(zone, $2);
isc_mem_free(memctx, $2);
if (tmpres == ISC_R_EXISTS) {
parser_warning(ISC_FALSE,
"redefining zone database.");
} else if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE,
"failed to set zone database.");
YYABORT;
}
}
| zone_update_policy
;
ip4_address: L_IP4ADDR
{
isc_sockaddr_fromin(&$$, &$1, 0);
......@@ -4612,6 +4628,7 @@ static struct token keyword_tokens [] = {
{ "cleaning-interval", L_CLEAN_INTERVAL },
{ "controls", L_CONTROLS },
{ "coresize", L_CORESIZE },
{ "database", L_DATABASE },
{ "datasize", L_DATASIZE },
{ "deallocate-on-exit", L_DEALLOC_ON_EXIT },
{ "debug", L_DEBUG },
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confzone.c,v 1.38 2000/05/03 19:29:41 brister Exp $ */
/* $Id: confzone.c,v 1.39 2000/05/06 10:18:47 brister Exp $ */
#include <config.h>
......@@ -500,7 +500,8 @@ dns_c_zone_new(isc_mem_t *mem,
newzone->internalname = (internalname == NULL ?
isc_mem_strdup(mem, name) :
isc_mem_strdup(mem, internalname));
newzone->database = NULL;
switch (ztype) {
case dns_c_zone_master:
res = master_zone_init(&newzone->u.mzone);
......@@ -580,7 +581,7 @@ dns_c_zone_print(FILE *fp, int indent, dns_c_zone_t *zone)
}
fprintf(fp, " {\n");
switch (zone->ztype) {
case dns_c_zone_master:
dns_c_printtabs(fp, indent + 1);
......@@ -613,6 +614,12 @@ dns_c_zone_print(FILE *fp, int indent, dns_c_zone_t *zone)
break;
}
if (zone->database != NULL) {
fprintf(fp, "\n");
dns_c_printtabs(fp, indent + 1);
fprintf(fp, "database \"%s\";\n", zone->database);
}
dns_c_printtabs(fp, indent);
fprintf(fp, "};\n");
}
......@@ -3867,6 +3874,11 @@ zone_delete(dns_c_zone_t **zone)
isc_mem_free(z->mem, z->name);
isc_mem_free(z->mem, z->internalname);
if (z->database != NULL) {
isc_mem_free(z->mem, z->database);
z->database = NULL;
}
switch(z->ztype) {
case dns_c_zone_master:
......@@ -4124,3 +4136,60 @@ set_iplist_field(isc_mem_t *mem,
return (res);
}
isc_result_t
dns_c_zone_setdatabase(dns_c_zone_t *zone, const char *database)
{
isc_boolean_t existed = ISC_FALSE;
REQUIRE(DNS_C_ZONE_VALID(zone));
REQUIRE(database != NULL);
REQUIRE(database[0] != '\0');
if (zone->database != NULL) {
existed = ISC_TRUE;
isc_mem_free(zone->mem, zone->database);
}
zone->database = isc_mem_strdup(zone->mem, database);
if (zone->database == NULL) {
return (ISC_R_NOMEMORY);
} else if (existed) {
return (ISC_R_EXISTS);
} else {
return (ISC_R_SUCCESS);
}
}
isc_result_t
dns_c_zone_getdatabase(dns_c_zone_t *zone, char **retval)
{
REQUIRE(DNS_C_ZONE_VALID(zone));
REQUIRE(retval != NULL);
*retval = zone->database;
if (zone->database == NULL) {
return (ISC_R_NOTFOUND);
} else {
return (ISC_R_SUCCESS);
}
}
isc_result_t
dns_c_zone_unsetdatabase(dns_c_zone_t *zone)
{
REQUIRE(DNS_C_ZONE_VALID(zone));
if (zone->database == NULL) {
return (ISC_R_NOTFOUND);
} else {
isc_mem_free(zone->mem, zone->database);
zone->database = NULL;
return (ISC_R_SUCCESS);
}
}
......@@ -200,6 +200,7 @@ struct dns_c_zone {
char *name; /* e.g. "foo.com" */
char *internalname; /* e.g. "foo.com.ext" */
char *database;
dns_rdataclass_t zclass;
dns_c_view_t *view;
......@@ -448,6 +449,17 @@ dns_c_zone_getallowupd(dns_c_zone_t *zone, dns_c_ipmatchlist_t **retval);
isc_result_t
dns_c_zone_unsetallowupd(dns_c_zone_t *zone);
isc_result_t
dns_c_zone_setdatabase(dns_c_zone_t *zone, const char *database);
isc_result_t
dns_c_zone_getdatabase(dns_c_zone_t *zone, char **retval);
isc_result_t
dns_c_zone_unsetdatabase(dns_c_zone_t *zone);
ISC_LANG_ENDDECLS
#endif /* DNS_CONFZONE_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment