netinet{,6}: Assert in{,6}_inithead() are only used for system routing tables.
[dragonfly.git] / contrib / ldns / ldns / host2str.h
1 /**
2  * host2str.h -  txt presentation of RRs
3  *
4  * a Net::DNS like library for C
5  *
6  * (c) NLnet Labs, 2005-2006
7  *
8  * See the file LICENSE for the license
9  */
10
11 /**
12  * \file
13  *
14  * Contains functions to translate the main structures to their text
15  * representation, as well as functions to print them.
16  */
17
18 #ifndef LDNS_HOST2STR_H
19 #define LDNS_HOST2STR_H
20
21 #include <ldns/common.h>
22 #include <ldns/error.h>
23 #include <ldns/rr.h>
24 #include <ldns/rdata.h>
25 #include <ldns/packet.h>
26 #include <ldns/buffer.h>
27 #include <ldns/resolver.h>
28 #include <ldns/zone.h>
29 #include <ctype.h>
30
31 #include "ldns/util.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #define LDNS_APL_IP4            1
38 #define LDNS_APL_IP6            2
39 #define LDNS_APL_MASK           0x7f
40 #define LDNS_APL_NEGATION       0x80
41
42 /** 
43  * Represent a NULL pointer (in stead of a pointer to a ldns_rr as "; (null)" 
44  * as opposed to outputting nothing at all in such a case.
45  */
46 #define LDNS_COMMENT_NULLS              0x0001
47 /** Show key id with DNSKEY RR's as comment */
48 #define LDNS_COMMENT_KEY_ID             0x0002
49 /** Show if a DNSKEY is a ZSK or KSK as comment */
50 #define LDNS_COMMENT_KEY_TYPE           0x0004
51 /** Show DNSKEY key size as comment */
52 #define LDNS_COMMENT_KEY_SIZE           0x0008
53 /** Show key id, type and size as comment for DNSKEY RR's */
54 #define LDNS_COMMENT_KEY                (LDNS_COMMENT_KEY_ID  \
55                                         |LDNS_COMMENT_KEY_TYPE\
56                                         |LDNS_COMMENT_KEY_SIZE)
57 /** Provide bubblebabble representation for DS RR's as comment */
58 #define LDNS_COMMENT_BUBBLEBABBLE       0x0010
59 /** Show when a NSEC3 RR has the optout flag set as comment */
60 #define LDNS_COMMENT_FLAGS              0x0020
61 /** Show the unhashed owner and next owner names for NSEC3 RR's as comment */
62 #define LDNS_COMMENT_NSEC3_CHAIN        0x0040
63 /** Print mark up */
64 #define LDNS_COMMENT_LAYOUT             0x0080
65 /** Also comment KEY_ID with RRSIGS **/
66 #define LDNS_COMMENT_RRSIGS             0x0100
67 #define LDNS_FMT_ZEROIZE_RRSIGS         0x0200
68 #define LDNS_FMT_PAD_SOA_SERIAL         0x0400
69
70 /**
71  * Output format specifier
72  *
73  * Determines how Packets, Resource Records and Resource record data fiels are
74  * formatted when printing or converting to string.
75  * Currently it is only used to specify what aspects of a Resource Record are
76  * annotated in the comment section of the textual representation the record.
77  * This is speciefed with flags and potential exra data (such as for example
78  * a lookup map of hashes to real names for annotation NSEC3 records).
79  */
80 struct ldns_struct_output_format
81 {
82         /** Specification of how RR's should be formatted in text */
83         int   flags;
84         /** Potential extra data to be used with formatting RR's in text */
85         void *data;
86 };
87 typedef struct ldns_struct_output_format ldns_output_format;
88
89 /**
90  * Standard output format record that disables commenting in the textual 
91  * representation of Resource Records completely.
92  */
93 extern const ldns_output_format *ldns_output_format_nocomments;
94 /**
95  * Standard output format record that annotated only DNSKEY RR's with commenti
96  * text.
97  */
98 extern const ldns_output_format *ldns_output_format_onlykeyids;
99 /**
100  * The default output format record. Same as ldns_output_format_onlykeyids.
101  */
102 extern const ldns_output_format *ldns_output_format_default;
103 /**
104  * Standard output format record that shows all DNSKEY related information in
105  * the comment text, plus the optout flag when set with NSEC3's, plus the
106  * bubblebabble representation of DS RR's.
107  */
108 extern const ldns_output_format *ldns_output_format_bubblebabble;
109
110 /**
111  * Converts an ldns packet opcode value to its mnemonic, and adds that
112  * to the output buffer
113  * \param[in] *output the buffer to add the data to
114  * \param[in] opcode to find the string representation of
115  * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
116  */
117 ldns_status
118 ldns_pkt_opcode2buffer_str(ldns_buffer *output, ldns_pkt_opcode opcode);
119
120 /**
121  * Converts an ldns packet rcode value to its mnemonic, and adds that
122  * to the output buffer
123  * \param[in] *output the buffer to add the data to
124  * \param[in] rcode to find the string representation of
125  * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
126  */
127 ldns_status
128 ldns_pkt_rcode2buffer_str(ldns_buffer *output, ldns_pkt_rcode rcode);
129
130 /**
131  * Converts an ldns algorithm type to its mnemonic, and adds that
132  * to the output buffer
133  * \param[in] *output the buffer to add the data to
134  * \param[in] algorithm to find the string representation of
135  * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
136  */
137 ldns_status
138 ldns_algorithm2buffer_str(ldns_buffer *output,
139                           ldns_algorithm algorithm);
140
141 /**
142  * Converts an ldns certificate algorithm type to its mnemonic, 
143  * and adds that to the output buffer
144  * \param[in] *output the buffer to add the data to
145  * \param[in] cert_algorithm to find the string representation of
146  * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
147  */
148 ldns_status
149 ldns_cert_algorithm2buffer_str(ldns_buffer *output,
150                                ldns_cert_algorithm cert_algorithm);
151
152
153 /**
154  * Converts a packet opcode to its mnemonic and returns that as
155  * an allocated null-terminated string.
156  * Remember to free it.
157  *
158  * \param[in] opcode the opcode to convert to text
159  * \return null terminated char * data, or NULL on error
160  */
161 char *ldns_pkt_opcode2str(ldns_pkt_opcode opcode);
162
163 /**
164  * Converts a packet rcode to its mnemonic and returns that as
165  * an allocated null-terminated string.
166  * Remember to free it.
167  *
168  * \param[in] rcode the rcode to convert to text
169  * \return null terminated char * data, or NULL on error
170  */
171 char *ldns_pkt_rcode2str(ldns_pkt_rcode rcode);
172
173 /**
174  * Converts a signing algorithms to its mnemonic and returns that as
175  * an allocated null-terminated string.
176  * Remember to free it.
177  *
178  * \param[in] algorithm the algorithm to convert to text
179  * \return null terminated char * data, or NULL on error
180  */
181 char *ldns_pkt_algorithm2str(ldns_algorithm algorithm);
182
183 /**
184  * Converts a cert algorithm to its mnemonic and returns that as
185  * an allocated null-terminated string.
186  * Remember to free it.
187  *
188  * \param[in] cert_algorithm to convert to text
189  * \return null terminated char * data, or NULL on error
190  */
191 char *ldns_pkt_cert_algorithm2str(ldns_cert_algorithm cert_algorithm);
192
193 /** 
194  * Converts an LDNS_RDF_TYPE_A rdata element to string format and adds it to the output buffer 
195  * \param[in] *rdf The rdata to convert
196  * \param[in] *output The buffer to add the data to
197  * \return LDNS_STATUS_OK on success, and error status on failure
198  */
199 ldns_status ldns_rdf2buffer_str_a(ldns_buffer *output, const ldns_rdf *rdf);
200
201 /** 
202  * Converts an LDNS_RDF_TYPE_AAAA rdata element to string format and adds it to the output buffer 
203  * \param[in] *rdf The rdata to convert
204  * \param[in] *output The buffer to add the data to
205  * \return LDNS_STATUS_OK on success, and error status on failure
206  */
207 ldns_status ldns_rdf2buffer_str_aaaa(ldns_buffer *output, const ldns_rdf *rdf);
208
209 /** 
210  * Converts an LDNS_RDF_TYPE_STR rdata element to string format and adds it to the output buffer 
211  * \param[in] *rdf The rdata to convert
212  * \param[in] *output The buffer to add the data to
213  * \return LDNS_STATUS_OK on success, and error status on failure
214  */
215 ldns_status ldns_rdf2buffer_str_str(ldns_buffer *output, const ldns_rdf *rdf);
216
217 /** 
218  * Converts an LDNS_RDF_TYPE_B64 rdata element to string format and adds it to the output buffer 
219  * \param[in] *rdf The rdata to convert
220  * \param[in] *output The buffer to add the data to
221  * \return LDNS_STATUS_OK on success, and error status on failure
222  */
223 ldns_status ldns_rdf2buffer_str_b64(ldns_buffer *output, const ldns_rdf *rdf);
224
225 /** 
226  * Converts an LDNS_RDF_TYPE_B32_EXT rdata element to string format and adds it to the output buffer 
227  * \param[in] *rdf The rdata to convert
228  * \param[in] *output The buffer to add the data to
229  * \return LDNS_STATUS_OK on success, and error status on failure
230  */
231 ldns_status ldns_rdf2buffer_str_b32_ext(ldns_buffer *output, const ldns_rdf *rdf);
232
233 /** 
234  * Converts an LDNS_RDF_TYPE_HEX rdata element to string format and adds it to the output buffer 
235  * \param[in] *rdf The rdata to convert
236  * \param[in] *output The buffer to add the data to
237  * \return LDNS_STATUS_OK on success, and error status on failure
238  */
239 ldns_status ldns_rdf2buffer_str_hex(ldns_buffer *output, const ldns_rdf *rdf);
240
241 /** 
242  * Converts an LDNS_RDF_TYPE_TYPE rdata element to string format and adds it to the output buffer 
243  * \param[in] *rdf The rdata to convert
244  * \param[in] *output The buffer to add the data to
245  * \return LDNS_STATUS_OK on success, and error status on failure
246  */
247 ldns_status ldns_rdf2buffer_str_type(ldns_buffer *output, const ldns_rdf *rdf);
248
249 /** 
250  * Converts an LDNS_RDF_TYPE_CLASS rdata element to string format and adds it to the output buffer 
251  * \param[in] *rdf The rdata to convert
252  * \param[in] *output The buffer to add the data to
253  * \return LDNS_STATUS_OK on success, and error status on failure
254  */
255 ldns_status ldns_rdf2buffer_str_class(ldns_buffer *output, const ldns_rdf *rdf);
256
257 /** 
258  * Converts an LDNS_RDF_TYPE_ALG rdata element to string format and adds it to the output buffer 
259  * \param[in] *rdf The rdata to convert
260  * \param[in] *output The buffer to add the data to
261  * \return LDNS_STATUS_OK on success, and error status on failure
262  */
263 ldns_status ldns_rdf2buffer_str_alg(ldns_buffer *output, const ldns_rdf *rdf);
264
265 /**
266  * Converts an ldns_rr_type value to its string representation,
267  * and places it in the given buffer
268  * \param[in] *output The buffer to add the data to
269  * \param[in] type the ldns_rr_type to convert
270  * \return LDNS_STATUS_OK on success, and error status on failure
271  */
272 ldns_status ldns_rr_type2buffer_str(ldns_buffer *output,
273                                     const ldns_rr_type type);
274
275 /**
276  * Converts an ldns_rr_type value to its string representation,
277  * and returns that string. For unknown types, the string
278  * "TYPE<id>" is returned. This function allocates data that must be
279  * freed by the caller
280  * \param[in] type the ldns_rr_type to convert
281  * \return a newly allocated string
282  */
283 char *ldns_rr_type2str(const ldns_rr_type type);
284
285 /**
286  * Converts an ldns_rr_class value to its string representation,
287  * and places it in the given buffer
288  * \param[in] *output The buffer to add the data to
289  * \param[in] klass the ldns_rr_class to convert
290  * \return LDNS_STATUS_OK on success, and error status on failure
291  */
292 ldns_status ldns_rr_class2buffer_str(ldns_buffer *output,
293                                      const ldns_rr_class klass);
294
295 /**
296  * Converts an ldns_rr_class value to its string representation,
297  * and returns that string. For unknown types, the string
298  * "CLASS<id>" is returned. This function allocates data that must be
299  * freed by the caller
300  * \param[in] klass the ldns_rr_class to convert
301  * \return a newly allocated string
302  */
303 char *ldns_rr_class2str(const ldns_rr_class klass);
304
305
306 /** 
307  * Converts an LDNS_RDF_TYPE_CERT rdata element to string format and adds it to the output buffer 
308  * \param[in] *rdf The rdata to convert
309  * \param[in] *output The buffer to add the data to
310  * \return LDNS_STATUS_OK on success, and error status on failure
311  */
312 ldns_status ldns_rdf2buffer_str_cert_alg(ldns_buffer *output, const ldns_rdf *rdf);
313
314 /** 
315  * Converts an LDNS_RDF_TYPE_LOC rdata element to string format and adds it to the output buffer 
316  * \param[in] *rdf The rdata to convert
317  * \param[in] *output The buffer to add the data to
318  * \return LDNS_STATUS_OK on success, and error status on failure
319  */
320 ldns_status ldns_rdf2buffer_str_loc(ldns_buffer *output, const ldns_rdf *rdf);
321
322 /** 
323  * Converts an LDNS_RDF_TYPE_UNKNOWN rdata element to string format and adds it to the output buffer 
324  * \param[in] *rdf The rdata to convert
325  * \param[in] *output The buffer to add the data to
326  * \return LDNS_STATUS_OK on success, and error status on failure
327  */
328 ldns_status ldns_rdf2buffer_str_unknown(ldns_buffer *output, const ldns_rdf *rdf);
329
330 /** 
331  * Converts an LDNS_RDF_TYPE_NSAP rdata element to string format and adds it to the output buffer 
332  * \param[in] *rdf The rdata to convert
333  * \param[in] *output The buffer to add the data to
334  * \return LDNS_STATUS_OK on success, and error status on failure
335  */
336 ldns_status ldns_rdf2buffer_str_nsap(ldns_buffer *output, const ldns_rdf *rdf);
337
338 /** 
339  * Converts an LDNS_RDF_TYPE_ATMA rdata element to string format and adds it to the output buffer 
340  * \param[in] *rdf The rdata to convert
341  * \param[in] *output The buffer to add the data to
342  * \return LDNS_STATUS_OK on success, and error status on failure
343  */
344 ldns_status ldns_rdf2buffer_str_atma(ldns_buffer *output, const ldns_rdf *rdf);
345
346 /** 
347  * Converts an LDNS_RDF_TYPE_WKS rdata element to string format and adds it to the output buffer 
348  * \param[in] *rdf The rdata to convert
349  * \param[in] *output The buffer to add the data to
350  * \return LDNS_STATUS_OK on success, and error status on failure
351  */
352 ldns_status ldns_rdf2buffer_str_wks(ldns_buffer *output, const ldns_rdf *rdf);
353
354 /** 
355  * Converts an LDNS_RDF_TYPE_NSEC rdata element to string format and adds it to the output buffer 
356  * \param[in] *rdf The rdata to convert
357  * \param[in] *output The buffer to add the data to
358  * \return LDNS_STATUS_OK on success, and error status on failure
359  */
360 ldns_status ldns_rdf2buffer_str_nsec(ldns_buffer *output, const ldns_rdf *rdf);
361
362 /** 
363  * Converts an LDNS_RDF_TYPE_PERIOD rdata element to string format and adds it to the output buffer 
364  * \param[in] *rdf The rdata to convert
365  * \param[in] *output The buffer to add the data to
366  * \return LDNS_STATUS_OK on success, and error status on failure
367  */
368 ldns_status ldns_rdf2buffer_str_period(ldns_buffer *output, const ldns_rdf *rdf);
369
370 /** 
371  * Converts an LDNS_RDF_TYPE_TSIGTIME rdata element to string format and adds it to the output buffer 
372  * \param[in] *rdf The rdata to convert
373  * \param[in] *output The buffer to add the data to
374  * \return LDNS_STATUS_OK on success, and error status on failure
375  */
376 ldns_status ldns_rdf2buffer_str_tsigtime(ldns_buffer *output, const ldns_rdf *rdf);
377
378 /** 
379  * Converts an LDNS_RDF_TYPE_APL rdata element to string format and adds it to the output buffer 
380  * \param[in] *rdf The rdata to convert
381  * \param[in] *output The buffer to add the data to
382  * \return LDNS_STATUS_OK on success, and error status on failure
383  */
384 ldns_status ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf);
385
386 /** 
387  * Converts an LDNS_RDF_TYPE_INT16_DATA rdata element to string format and adds it to the output buffer 
388  * \param[in] *rdf The rdata to convert
389  * \param[in] *output The buffer to add the data to
390  * \return LDNS_STATUS_OK on success, and error status on failure
391  */
392 ldns_status ldns_rdf2buffer_str_int16_data(ldns_buffer *output, const ldns_rdf *rdf);
393
394 /** 
395  * Converts an LDNS_RDF_TYPE_IPSECKEY rdata element to string format and adds it to the output buffer 
396  * \param[in] *rdf The rdata to convert
397  * \param[in] *output The buffer to add the data to
398  * \return LDNS_STATUS_OK on success, and error status on failure
399  */
400 ldns_status ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf);
401
402 /** 
403  * Converts an LDNS_RDF_TYPE_TSIG rdata element to string format and adds it to the output buffer 
404  * \param[in] *rdf The rdata to convert
405  * \param[in] *output The buffer to add the data to
406  * \return LDNS_STATUS_OK on success, and error status on failure
407  */
408 ldns_status ldns_rdf2buffer_str_tsig(ldns_buffer *output, const ldns_rdf *rdf);
409
410
411 /**
412  * Converts the data in the rdata field to presentation
413  * format (as char *) and appends it to the given buffer
414  *
415  * \param[in] output pointer to the buffer to append the data to
416  * \param[in] rdf the pointer to the rdafa field containing the data
417  * \return status
418  */
419 ldns_status ldns_rdf2buffer_str(ldns_buffer *output, const ldns_rdf *rdf);
420
421 /**
422  * Converts the data in the resource record to presentation
423  * format (as char *) and appends it to the given buffer.
424  * The presentation format of DNSKEY record is annotated with comments giving
425  * the id, type and size of the key.
426  *
427  * \param[in] output pointer to the buffer to append the data to
428  * \param[in] rr the pointer to the rr field to convert
429  * \return status
430  */
431 ldns_status ldns_rr2buffer_str(ldns_buffer *output, const ldns_rr *rr);
432
433 /**
434  * Converts the data in the resource record to presentation
435  * format (as char *) and appends it to the given buffer.
436  * The presentation format is annotated with comments giving
437  * additional information on the record.
438  *
439  * \param[in] output pointer to the buffer to append the data to
440  * \param[in] fmt how to format the textual representation of the 
441  *            resource record.
442  * \param[in] rr the pointer to the rr field to convert
443  * \return status
444  */
445 ldns_status ldns_rr2buffer_str_fmt(ldns_buffer *output, 
446                 const ldns_output_format *fmt, const ldns_rr *rr);
447
448 /**
449  * Converts the data in the DNS packet to presentation
450  * format (as char *) and appends it to the given buffer
451  *
452  * \param[in] output pointer to the buffer to append the data to
453  * \param[in] pkt the pointer to the packet to convert
454  * \return status
455  */
456 ldns_status ldns_pkt2buffer_str(ldns_buffer *output, const ldns_pkt *pkt);
457
458 /**
459  * Converts the data in the DNS packet to presentation
460  * format (as char *) and appends it to the given buffer
461  *
462  * \param[in] output pointer to the buffer to append the data to
463  * \param[in] fmt how to format the textual representation of the packet
464  * \param[in] pkt the pointer to the packet to convert
465  * \return status
466  */
467 ldns_status ldns_pkt2buffer_str_fmt(ldns_buffer *output,
468                 const ldns_output_format *fmt, const ldns_pkt *pkt);
469
470 /** 
471  * Converts an LDNS_RDF_TYPE_NSEC3_SALT rdata element to string format and adds it to the output buffer 
472  * \param[in] *rdf The rdata to convert
473  * \param[in] *output The buffer to add the data to
474  * \return LDNS_STATUS_OK on success, and error status on failure
475  */
476 ldns_status ldns_rdf2buffer_str_nsec3_salt(ldns_buffer *output, const ldns_rdf *rdf);
477
478
479 /**
480  * Converts the data in the DNS packet to presentation
481  * format (as char *) and appends it to the given buffer
482  *
483  * \param[in] output pointer to the buffer to append the data to
484  * \param[in] k the pointer to the private key to convert
485  * \return status
486  */
487 ldns_status ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k);
488
489 /**
490  * Converts an LDNS_RDF_TYPE_INT8 rdata element to string format and adds it to the output buffer
491  * \param[in] *rdf The rdata to convert
492  * \param[in] *output The buffer to add the data to
493  * \return LDNS_STATUS_OK on success, and error status on failure
494  */
495 ldns_status ldns_rdf2buffer_str_int8(ldns_buffer *output, const ldns_rdf *rdf);
496
497 /**
498  * Converts an LDNS_RDF_TYPE_INT16 rdata element to string format and adds it to the output buffer
499  * \param[in] *rdf The rdata to convert
500  * \param[in] *output The buffer to add the data to
501  * \return LDNS_STATUS_OK on success, and error status on failure
502  */
503 ldns_status ldns_rdf2buffer_str_int16(ldns_buffer *output, const ldns_rdf *rdf);
504
505 /**
506  * Converts an LDNS_RDF_TYPE_INT32 rdata element to string format and adds it to the output buffer
507  * \param[in] *rdf The rdata to convert
508  * \param[in] *output The buffer to add the data to
509  * \return LDNS_STATUS_OK on success, and error status on failure
510  */
511 ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf);
512
513 /**
514  * Converts an LDNS_RDF_TYPE_TIME rdata element to string format and adds it to the output buffer
515  * \param[in] *rdf The rdata to convert
516  * \param[in] *output The buffer to add the data to
517  * \return LDNS_STATUS_OK on success, and error status on failure
518  */
519 ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf);
520
521 /**
522  * Converts the data in the rdata field to presentation format and
523  * returns that as a char *.
524  * Remember to free it.
525  *
526  * \param[in] rdf The rdata field to convert
527  * \return null terminated char * data, or NULL on error
528  */
529 char *ldns_rdf2str(const ldns_rdf *rdf);
530
531 /**
532  * Converts the data in the resource record to presentation format and
533  * returns that as a char *.
534  * Remember to free it.
535  *
536  * \param[in] rr The rdata field to convert
537  * \return null terminated char * data, or NULL on error
538  */
539 char *ldns_rr2str(const ldns_rr *rr);
540
541 /**
542  * Converts the data in the resource record to presentation format and
543  * returns that as a char *.
544  * Remember to free it.
545  *
546  * \param[in] fmt how to format the resource record
547  * \param[in] rr The rdata field to convert
548  * \return null terminated char * data, or NULL on error
549  */
550 char *ldns_rr2str_fmt(const ldns_output_format *fmt, const ldns_rr *rr);
551
552 /**
553  * Converts the data in the DNS packet to presentation format and
554  * returns that as a char *.
555  * Remember to free it.
556  *
557  * \param[in] pkt The rdata field to convert
558  * \return null terminated char * data, or NULL on error
559  */
560 char *ldns_pkt2str(const ldns_pkt *pkt);
561
562 /**
563  * Converts the data in the DNS packet to presentation format and
564  * returns that as a char *.
565  * Remember to free it.
566  *
567  * \param[in] fmt how to format the packet
568  * \param[in] pkt The rdata field to convert
569  * \return null terminated char * data, or NULL on error
570  */
571 char *ldns_pkt2str_fmt(const ldns_output_format *fmt, const ldns_pkt *pkt);
572
573 /**
574  * Converts a private key to the test presentation fmt and
575  * returns that as a char *.
576  * Remember to free it.
577  *
578  * \param[in] k the key to convert to text
579  * \return null terminated char * data, or NULL on error
580  */
581 char *ldns_key2str(const ldns_key *k);
582
583 /**
584  * Converts a list of resource records to presentation format
585  * and returns that as a char *.
586  * Remember to free it.
587  *
588  * \param[in] rr_list the rr_list to convert to text
589  * \return null terminated char * data, or NULL on error
590  */
591 char *ldns_rr_list2str(const ldns_rr_list *rr_list);
592
593 /**
594  * Converts a list of resource records to presentation format
595  * and returns that as a char *.
596  * Remember to free it.
597  *
598  * \param[in] fmt how to format the list of resource records
599  * \param[in] rr_list the rr_list to convert to text
600  * \return null terminated char * data, or NULL on error
601  */
602 char *ldns_rr_list2str_fmt(
603                 const ldns_output_format *fmt, const ldns_rr_list *rr_list);
604
605 /**
606  * Returns a copy of the data in the buffer as a null terminated
607  * char * string. The returned string must be freed by the caller.
608  * The buffer must be in write modus and may thus not have been flipped.
609  *
610  * \param[in] buffer buffer containing char * data
611  * \return null terminated char * data, or NULL on error
612  */
613 char *ldns_buffer2str(ldns_buffer *buffer);
614
615 /**
616  * Exports and returns the data in the buffer as a null terminated
617  * char * string. The returned string must be freed by the caller.
618  * The buffer must be in write modus and may thus not have been flipped.
619  * The buffer is fixed after this function returns.
620  *
621  * \param[in] buffer buffer containing char * data
622  * \return null terminated char * data, or NULL on error
623  */
624 char *ldns_buffer_export2str(ldns_buffer *buffer);
625
626 /**
627  * Prints the data in the rdata field to the given file stream
628  * (in presentation format)
629  *
630  * \param[in] output the file stream to print to
631  * \param[in] rdf the rdata field to print
632  * \return void
633  */
634 void ldns_rdf_print(FILE *output, const ldns_rdf *rdf);
635
636 /**
637  * Prints the data in the resource record to the given file stream
638  * (in presentation format)
639  *
640  * \param[in] output the file stream to print to
641  * \param[in] rr the resource record to print
642  * \return void
643  */
644 void ldns_rr_print(FILE *output, const ldns_rr *rr);
645
646 /**
647  * Prints the data in the resource record to the given file stream
648  * (in presentation format)
649  *
650  * \param[in] output the file stream to print to
651  * \param[in] fmt format of the textual representation
652  * \param[in] rr the resource record to print
653  * \return void
654  */
655 void ldns_rr_print_fmt(FILE *output, 
656                 const ldns_output_format *fmt, const ldns_rr *rr);
657
658 /**
659  * Prints the data in the DNS packet to the given file stream
660  * (in presentation format)
661  *
662  * \param[in] output the file stream to print to
663  * \param[in] pkt the packet to print
664  * \return void
665  */
666 void ldns_pkt_print(FILE *output, const ldns_pkt *pkt);
667
668 /**
669  * Prints the data in the DNS packet to the given file stream
670  * (in presentation format)
671  *
672  * \param[in] output the file stream to print to
673  * \param[in] fmt format of the textual representation
674  * \param[in] pkt the packet to print
675  * \return void
676  */
677 void ldns_pkt_print_fmt(FILE *output, 
678                 const ldns_output_format *fmt, const ldns_pkt *pkt);
679
680 /**
681  * Converts a rr_list to presentation format and appends it to
682  * the output buffer
683  * \param[in] output the buffer to append output to
684  * \param[in] list the ldns_rr_list to print
685  * \return ldns_status
686  */
687 ldns_status ldns_rr_list2buffer_str(ldns_buffer *output, const ldns_rr_list *list);
688
689 /**
690  * Converts a rr_list to presentation format and appends it to
691  * the output buffer
692  * \param[in] output the buffer to append output to
693  * \param[in] fmt format of the textual representation
694  * \param[in] list the ldns_rr_list to print
695  * \return ldns_status
696  */
697 ldns_status ldns_rr_list2buffer_str_fmt(ldns_buffer *output, 
698                 const ldns_output_format *fmt, const ldns_rr_list *list);
699
700 /**
701  * Converts the header of a packet to presentation format and appends it to
702  * the output buffer
703  * \param[in] output the buffer to append output to
704  * \param[in] pkt the packet to convert the header of
705  * \return ldns_status
706  */
707 ldns_status ldns_pktheader2buffer_str(ldns_buffer *output, const ldns_pkt *pkt);
708
709 /**
710  * print a rr_list to output
711  * \param[in] output the fd to print to
712  * \param[in] list the rr_list to print
713  */
714 void ldns_rr_list_print(FILE *output, const ldns_rr_list *list);
715
716 /**
717  * print a rr_list to output
718  * \param[in] output the fd to print to
719  * \param[in] fmt format of the textual representation
720  * \param[in] list the rr_list to print
721  */
722 void ldns_rr_list_print_fmt(FILE *output, 
723                 const ldns_output_format *fmt, const ldns_rr_list *list);
724
725 /**
726  * Print a resolver (in sofar that is possible) state
727  * to output.
728  * \param[in] output the fd to print to
729  * \param[in] r the resolver to print
730  */
731 void ldns_resolver_print(FILE *output, const ldns_resolver *r);
732
733 /**
734  * Print a resolver (in sofar that is possible) state
735  * to output.
736  * \param[in] output the fd to print to
737  * \param[in] fmt format of the textual representation
738  * \param[in] r the resolver to print
739  */
740 void ldns_resolver_print_fmt(FILE *output, 
741                 const ldns_output_format *fmt, const ldns_resolver *r);
742
743 /**
744  * Print a zone structure * to output. Note the SOA record
745  * is included in this output
746  * \param[in] output the fd to print to
747  * \param[in] z the zone to print
748  */
749 void ldns_zone_print(FILE *output, const ldns_zone *z);
750
751 /**
752  * Print a zone structure * to output. Note the SOA record
753  * is included in this output
754  * \param[in] output the fd to print to
755  * \param[in] fmt format of the textual representation
756  * \param[in] z the zone to print
757  */
758 void ldns_zone_print_fmt(FILE *output, 
759                 const ldns_output_format *fmt, const ldns_zone *z);
760
761 /**
762  * Print the ldns_rdf containing a dname to the buffer
763  * \param[in] output the buffer to print to
764  * \param[in] dname the dname to print
765  * \return ldns_status message if the printing succeeded
766  */
767 ldns_status ldns_rdf2buffer_str_dname(ldns_buffer *output, const ldns_rdf *dname);
768
769 #ifdef __cplusplus
770 }
771 #endif
772
773 #endif /* LDNS_HOST2STR_H */