Merge from vendor branch CVS:
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / include / dns / masterdump.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: masterdump.h,v 1.22.2.1 2004/03/09 06:11:18 marka Exp $ */
19
20 #ifndef DNS_MASTERDUMP_H
21 #define DNS_MASTERDUMP_H 1
22
23 /***
24  ***    Imports
25  ***/
26
27 #include <stdio.h>
28
29 #include <isc/lang.h>
30
31 #include <dns/types.h>
32
33 /***
34  *** Types
35  ***/
36
37 /*
38  * Style options for masterfile dumps.  This struct is currently
39  * opaque, so applications cannot define their own style but have
40  * to choose a predefined style.  A more flexible interface may
41  * be exported in the future.
42  */
43
44 typedef struct dns_master_style dns_master_style_t;
45
46 ISC_LANG_BEGINDECLS
47
48 /***
49  ***    Constants
50  ***/
51
52 /*
53  * The default master file style.
54  *
55  * This uses $TTL directives to avoid the need to dedicate a
56  * tab stop for the TTL.  The class is only printed for the first
57  * rrset in the file and shares a tab stop with the RR type.
58  */
59 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_default;
60
61 /*
62  * A master file style that prints explicit TTL values on each 
63  * record line, never using $TTL statements.  The TTL has a tab 
64  * stop of its own, but the class and type share one.
65  */
66 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t
67                                   dns_master_style_explicitttl;
68
69 /*
70  * A master style format designed for cache files.  It prints explicit TTL
71  * values on each record line and never uses $ORIGIN or relative names.
72  */
73 extern const dns_master_style_t dns_master_style_cache;
74
75 /*
76  * A master style that prints name, ttl, class, type, and value on 
77  * every line.  Similar to explicitttl above, but more verbose.  
78  * Intended for generating master files which can be easily parsed 
79  * by perl scripts and similar applications.
80  */
81 extern const dns_master_style_t dns_master_style_simple;
82
83 /*
84  * The style used for debugging, "dig" output, etc.
85  */
86 LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_debug;
87
88 /***
89  ***    Functions
90  ***/
91
92 isc_result_t
93 dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db,
94                         dns_dbversion_t *version,
95                         const dns_master_style_t *style, FILE *f);
96 /*
97  * Dump the database 'db' to the steam 'f' in RFC1035 master
98  * file format, in the style defined by 'style'
99  * (e.g., &dns_default_master_style_default)
100  *
101  * Temporary dynamic memory may be allocated from 'mctx'.
102  *
103  * Returns:
104  *      ISC_R_SUCCESS
105  *      ISC_R_NOMEMORY
106  *      Any database or rrset iterator error.
107  *      Any dns_rdata_totext() error code.
108  */
109
110 isc_result_t
111 dns_master_dump(isc_mem_t *mctx, dns_db_t *db,
112                 dns_dbversion_t *version,
113                 const dns_master_style_t *style, const char *filename);
114 /*
115  * Dump the database 'db' to the file 'filename' in RFC1035 master
116  * file format, in the style defined by 'style'
117  * (e.g., &dns_default_master_style_default)
118  *
119  * Temporary dynamic memory may be allocated from 'mctx'.
120  *
121  * Returns:
122  *      ISC_R_SUCCESS
123  *      ISC_R_NOMEMORY
124  *      Any database or rrset iterator error.
125  *      Any dns_rdata_totext() error code.
126  */
127
128 isc_result_t
129 dns_master_rdatasettotext(dns_name_t *owner_name,
130                           dns_rdataset_t *rdataset,
131                           const dns_master_style_t *style,
132                           isc_buffer_t *target);
133 /*
134  * Convert 'rdataset' to text format, storing the result in 'target'.
135  *
136  * Notes:
137  *      The rdata cursor position will be changed.
138  *
139  * Requires:
140  *      'rdataset' is a valid non-question rdataset.
141  *
142  *      'rdataset' is not empty.
143  */
144
145 isc_result_t
146 dns_master_questiontotext(dns_name_t *owner_name,
147                           dns_rdataset_t *rdataset,
148                           const dns_master_style_t *style,
149                           isc_buffer_t *target);
150 /*
151  * Print a text representation of 'rdataset', a pseudo-rdataset
152  * representing a questino.
153  *
154  * Requires:
155  *      'rdataset' is a valid question rdataset.
156  *
157  *      'rdataset' is not empty.
158  */
159
160 isc_result_t
161 dns_rdataset_towire(dns_rdataset_t *rdataset,
162                     dns_name_t *owner_name,
163                     dns_compress_t *cctx,
164                     isc_buffer_t *target,
165                     unsigned int *countp);
166
167 isc_result_t
168 dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db,
169                             dns_dbversion_t *version,
170                             dns_dbnode_t *node, dns_name_t *name,
171                             const dns_master_style_t *style,
172                             FILE *f);
173
174 isc_result_t
175 dns_master_dumpnode(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
176                     dns_dbnode_t *node, dns_name_t *name,
177                     const dns_master_style_t *style, const char *filename);
178
179 ISC_LANG_ENDDECLS
180
181 #endif /* DNS_MASTERDUMP_H */