xref: /openbsd-src/usr.bin/dig/lib/isccfg/namedconf.c (revision 4465bcfb0189fef66881a630d84d3be0e093c02b)
1*5185a700Sflorian /*
2*5185a700Sflorian  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3*5185a700Sflorian  *
4*5185a700Sflorian  * Permission to use, copy, modify, and/or distribute this software for any
5*5185a700Sflorian  * purpose with or without fee is hereby granted, provided that the above
6*5185a700Sflorian  * copyright notice and this permission notice appear in all copies.
7*5185a700Sflorian  *
8*5185a700Sflorian  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9*5185a700Sflorian  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10*5185a700Sflorian  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11*5185a700Sflorian  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12*5185a700Sflorian  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13*5185a700Sflorian  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14*5185a700Sflorian  * PERFORMANCE OF THIS SOFTWARE.
15*5185a700Sflorian  */
16*5185a700Sflorian 
17*5185a700Sflorian /*! \file */
18*5185a700Sflorian #include <stdlib.h>
19*5185a700Sflorian 
20*5185a700Sflorian #include <isccfg/cfg.h>
21*5185a700Sflorian #include <isccfg/grammar.h>
22*5185a700Sflorian 
23*5185a700Sflorian /*%
24*5185a700Sflorian  * Forward declarations of static functions.
25*5185a700Sflorian  */
26*5185a700Sflorian 
27*5185a700Sflorian static cfg_type_t cfg_type_key;
28*5185a700Sflorian 
29*5185a700Sflorian /*%
30*5185a700Sflorian  * Clauses that can be found within the 'key' statement.
31*5185a700Sflorian  */
32*5185a700Sflorian static cfg_clausedef_t
33*5185a700Sflorian key_clauses[] = {
34*5185a700Sflorian 	{ "algorithm", &cfg_type_astring, 0 },
35*5185a700Sflorian 	{ "secret", &cfg_type_sstring, 0 },
36*5185a700Sflorian 	{ NULL, NULL, 0 }
37*5185a700Sflorian };
38*5185a700Sflorian 
39*5185a700Sflorian static cfg_clausedef_t *
40*5185a700Sflorian key_clausesets[] = {
41*5185a700Sflorian 	key_clauses,
42*5185a700Sflorian 	NULL
43*5185a700Sflorian };
44*5185a700Sflorian static cfg_type_t cfg_type_key = {
45*5185a700Sflorian 	"key", cfg_parse_named_map, &cfg_rep_map, key_clausesets
46*5185a700Sflorian };
47*5185a700Sflorian 
48*5185a700Sflorian /*%
49*5185a700Sflorian  * rndc
50*5185a700Sflorian  */
51*5185a700Sflorian 
52*5185a700Sflorian static cfg_clausedef_t
53*5185a700Sflorian rndckey_clauses[] = {
54*5185a700Sflorian 	{ "key", &cfg_type_key, 0 },
55*5185a700Sflorian 	{ NULL, NULL, 0 }
56*5185a700Sflorian };
57*5185a700Sflorian 
58*5185a700Sflorian static cfg_clausedef_t *
59*5185a700Sflorian rndckey_clausesets[] = {
60*5185a700Sflorian 	rndckey_clauses,
61*5185a700Sflorian 	NULL
62*5185a700Sflorian };
63*5185a700Sflorian 
64*5185a700Sflorian /*
65*5185a700Sflorian  * session.key has exactly the same syntax as rndc.key, but it's defined
66*5185a700Sflorian  * separately for clarity (and so we can extend it someday, if needed).
67*5185a700Sflorian  */
68*5185a700Sflorian cfg_type_t cfg_type_sessionkey = {
69*5185a700Sflorian 	"sessionkey", cfg_parse_mapbody, &cfg_rep_map, rndckey_clausesets
70*5185a700Sflorian };
71*5185a700Sflorian 
72