Merge branch 'vendor/GCC'
[dragonfly.git] / contrib / bind-9.3 / lib / dns / include / dns / dbtable.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: dbtable.h,v 1.16.206.1 2004/03/06 08:13:55 marka Exp $ */
19
20 #ifndef DNS_DBTABLE_H
21 #define DNS_DBTABLE_H 1
22
23 /*****
24  ***** Module Info
25  *****/
26
27 /*
28  * DNS DB Tables
29  *
30  * XXX <TBS> XXX
31  *
32  * MP:
33  *      The module ensures appropriate synchronization of data structures it
34  *      creates and manipulates.
35  *
36  * Reliability:
37  *      No anticipated impact.
38  *
39  * Resources:
40  *      None.
41  *
42  * Security:
43  *      No anticipated impact.
44  *
45  * Standards:
46  *      None.
47  */
48
49 #include <isc/lang.h>
50
51 #include <dns/types.h>
52
53 #define DNS_DBTABLEFIND_NOEXACT         0x01
54
55 ISC_LANG_BEGINDECLS
56
57 isc_result_t
58 dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
59                    dns_dbtable_t **dbtablep);
60 /*
61  * Make a new dbtable of class 'rdclass'
62  *
63  * Requires:
64  *      mctx != NULL
65  *      dbtablep != NULL && *dptablep == NULL
66  *      'rdclass' is a valid class
67  *
68  * Returns:
69  *      ISC_R_SUCCESS
70  *      ISC_R_NOMEMORY
71  *      ISC_R_UNEXPECTED
72  */
73
74 void
75 dns_dbtable_attach(dns_dbtable_t *source, dns_dbtable_t **targetp);
76 /*
77  * Attach '*targetp' to 'source'.
78  *
79  * Requires:
80  *
81  *      'source' is a valid dbtable.
82  *
83  *      'targetp' points to a NULL dns_dbtable_t *.
84  *
85  * Ensures:
86  *
87  *      *targetp is attached to source.
88  */
89
90 void
91 dns_dbtable_detach(dns_dbtable_t **dbtablep);
92 /*
93  * Detach *dbtablep from its dbtable.
94  *
95  * Requires:
96  *
97  *      '*dbtablep' points to a valid dbtable.
98  *
99  * Ensures:
100  *
101  *      *dbtablep is NULL.
102  *
103  *      If '*dbtablep' is the last reference to the dbtable,
104  *
105  *              All resources used by the dbtable will be freed
106  */
107
108 isc_result_t
109 dns_dbtable_add(dns_dbtable_t *dbtable, dns_db_t *db);
110 /*
111  * Add 'db' to 'dbtable'.
112  *
113  * Requires:
114  *      'dbtable' is a valid dbtable.
115  *
116  *      'db' is a valid database with the same class as 'dbtable'
117  */
118
119 void
120 dns_dbtable_remove(dns_dbtable_t *dbtable, dns_db_t *db);
121 /*
122  * Remove 'db' from 'dbtable'.
123  *
124  * Requires:
125  *      'db' was previously added to 'dbtable'.
126  */
127
128 void
129 dns_dbtable_adddefault(dns_dbtable_t *dbtable, dns_db_t *db);
130 /*
131  * Use 'db' as the result of a dns_dbtable_find() if no better match is
132  * available.
133  */
134
135 void
136 dns_dbtable_getdefault(dns_dbtable_t *dbtable, dns_db_t **db);
137 /*
138  * Get the 'db' used as the result of a dns_dbtable_find()
139  * if no better match is available.
140  */
141
142 void
143 dns_dbtable_removedefault(dns_dbtable_t *dbtable);
144 /*
145  * Remove the default db from 'dbtable'.
146  */
147
148 isc_result_t
149 dns_dbtable_find(dns_dbtable_t *dbtable, dns_name_t *name,
150                  unsigned int options, dns_db_t **dbp);
151 /*
152  * Find the deepest match to 'name' in the dbtable, and return it
153  *
154  * Notes:
155  *      If the DNS_DBTABLEFIND_NOEXACT option is set, the best partial
156  *      match (if any) to 'name' will be returned.
157  *
158  * Returns:  ISC_R_SUCCESS              on success
159  *           <something else>           no default and match
160  */
161
162 ISC_LANG_ENDDECLS
163
164 #endif /* DNS_DBTABLE_H */