rrset-dump.h 3.09 KB
Newer Older
1
/*  Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
2 3 4 5 6 7 8 9 10 11 12 13 14 15

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
16
/*!
17
 * \file
18
 *
Daniel Salzman's avatar
Daniel Salzman committed
19
 * \brief RRset text dump facility.
20
 *
Daniel Salzman's avatar
Daniel Salzman committed
21
 * \addtogroup libknot
22
 * @{
23 24
 */

25
#pragma once
26

27
#include <stdbool.h>
28

Daniel Salzman's avatar
Daniel Salzman committed
29 30
#include "libknot/rrset.h"

31 32 33 34 35 36
/*! \brief Text output settings. */
typedef struct {
	/*!< Wrap long records. */
	bool	wrap;
	/*!< Show class. */
	bool	show_class;
37
	/*!< Show TTL. */
38
	bool	show_ttl;
39
	/*!< Print extra information. */
40
	bool	verbose;
41 42
	/*!< Show empty TTL value (keep indentation). */
	bool	empty_ttl;
43 44 45 46
	/*!< Format TTL as DHMS. */
	bool	human_ttl;
	/*!< Format timestamp as YYYYMMDDHHmmSS. */
	bool	human_tmstamp;
47 48
	/*!< Force generic data representation. */
	bool	generic;
49 50
	/*!< ASCII string to IDN string transformation callback. */
	void (*ascii_to_idn)(char **name);
51 52 53 54 55
} knot_dump_style_t;

/*! \brief Default dump style. */
extern const knot_dump_style_t KNOT_DUMP_STYLE_DEFAULT;

Daniel Salzman's avatar
Daniel Salzman committed
56 57 58 59
/*!
 * \brief Dumps rrset header.
 *
 * \param rrset		RRset to dump.
60
 * \param ttl		TTL to dump.
Daniel Salzman's avatar
Daniel Salzman committed
61
 * \param dst		Output buffer.
62
 * \param maxlen	Output buffer size.
Daniel Salzman's avatar
Daniel Salzman committed
63 64 65 66 67
 * \param style		Output style.
 *
 * \retval output length	if success.
 * \retval < 0			if error.
 */
68
int knot_rrset_txt_dump_header(const knot_rrset_t      *rrset,
69
                               const uint32_t          ttl,
70 71 72 73
                               char                    *dst,
                               const size_t            maxlen,
                               const knot_dump_style_t *style);

Daniel Salzman's avatar
Daniel Salzman committed
74 75 76 77 78 79
/*!
 * \brief Dumps rrset data.
 *
 * \param rrset		RRset to dump.
 * \param pos		Position of the record to dump.
 * \param dst		Output buffer.
80
 * \param maxlen	Output buffer size.
Daniel Salzman's avatar
Daniel Salzman committed
81 82 83 84 85
 * \param style		Output style.
 *
 * \retval output length	if success.
 * \retval < 0			if error.
 */
86 87 88 89 90 91
int knot_rrset_txt_dump_data(const knot_rrset_t      *rrset,
                             const size_t            pos,
                             char                    *dst,
                             const size_t            maxlen,
                             const knot_dump_style_t *style);

Daniel Salzman's avatar
Daniel Salzman committed
92 93 94 95 96
/*!
 * \brief Dumps rrset.
 *
 * \param rrset		RRset to dump.
 * \param dst		Output buffer.
97
 * \param maxlen	Output buffer size.
Daniel Salzman's avatar
Daniel Salzman committed
98 99 100 101 102
 * \param style		Output style.
 *
 * \retval output length	if success.
 * \retval < 0			if error.
 */
103 104 105 106
int knot_rrset_txt_dump(const knot_rrset_t      *rrset,
                        char                    *dst,
                        const size_t            maxlen,
                        const knot_dump_style_t *style);
107 108

/*! @} */