apply.h 3.02 KB
Newer Older
Daniel Salzman's avatar
Daniel Salzman committed
1
/*  Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
Lubos Slovak's avatar
Lubos Slovak committed
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/>.
 */
Daniel Salzman's avatar
Daniel Salzman committed
16 17 18 19 20 21 22 23
/*!
 * \file
 *
 * \brief Changesets application and update helpers.
 *
 * \addtogroup ddns
 * @{
 */
24

25
#pragma once
26

27
#include "knot/zone/zone.h"
28
#include "knot/updates/changesets.h"
Daniel Salzman's avatar
Daniel Salzman committed
29
#include "contrib/ucw/lists.h"
30

31 32 33 34 35 36
/*!
 * \brief Applies changesets *with* zone shallow copy.
 *
 * \param zone          Zone to be updated.
 * \param chsets        Changes to be made.
 * \param new_contents  New zone will be returned using this arg.
37
 *
38 39
 * \return KNOT_E*
 */
40
int apply_changesets(zone_t *zone, list_t *chsets,
41
                     zone_contents_t **new_contents);
42

43 44 45 46 47 48 49 50 51 52 53 54
/*!
 * \brief Applies changeset *with* zone shallow copy.
 *
 * \param zone          Zone to be updated.
 * \param ch            Change to be made.
 * \param new_contents  New zone will be returned using this arg.
 *
 * \return KNOT_E*
 */
int apply_changeset(zone_t *zone, changeset_t *ch,
                    zone_contents_t **new_contents);

55 56 57 58 59 60
/*!
 * \brief Applies changesets directly to the zone, without copying it.
 *
 * \param contents Zone contents to apply the changesets to. Will be modified.
 * \param chsets   Changesets to be applied to the zone.
 *
Marek Vavruša's avatar
Marek Vavruša committed
61
 * \return KNOT_E*
62
 */
63
int apply_changesets_directly(zone_contents_t *contents, list_t *chsets);
64 65 66 67 68 69 70 71 72

/*!
 * \brief Applies changeset directly to the zone, without copying it.
 *
 * \param contents Zone contents to apply the changesets to. Will be modified.
 * \param chsets   Changeset to be applied to the zone.
 *
 * \return KNOT_E*
 */
73
int apply_changeset_directly(zone_contents_t *contents, changeset_t *ch);
74

75
/*!
76
 * \brief Cleanups successful zone updates.
77

78 79
 * \param chgs  Changesets used to create the update.
 */
80 81
void updates_cleanup(list_t *chgs);

82 83
/*!
 * \brief Cleanups successful zone update.
84

85 86
 * \param chgs  Changeset used to create the update.
 */
87
void update_cleanup(changeset_t *change);
Jan Kadlec's avatar
Jan Kadlec committed
88

89
/*!
90
 * \brief Rollbacks failed zone updates.
91
 *
92
 * \param chgs   Changesets used to create the update.
93
 */
94 95
void updates_rollback(list_t *chgs);

96 97 98 99 100
/*!
 * \brief Rollbacks failed zone update.
 *
 * \param chgs   Changeset. used to create the update.
 */
101
void update_rollback(changeset_t *change);
Jan Kadlec's avatar
Jan Kadlec committed
102

103
/*!
104 105 106
 * \brief Shallow frees zone contents - either shallow copy after failed update
 *        or original zone contents after successful update.
 *
107 108
 * \param contents  Contents to free.
 */
109
void update_free_zone(zone_contents_t **contents);
110 111

/*! @} */