Skip to content
Snippets Groups Projects
Commit cd0d13f2 authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

Added an API to set/clear and fetch zone flags. Zone 'master' is now a flag.

refs #1976
parent 0f5a7619
Branches
Tags
No related merge requests found
......@@ -146,14 +146,18 @@ void knot_zone_set_version(knot_zone_t *zone, time_t version)
short knot_zone_is_master(const knot_zone_t *zone)
{
return zone->master;
return zone->flags & KNOT_ZONE_MASTER;
}
/*----------------------------------------------------------------------------*/
void knot_zone_set_master(knot_zone_t *zone, short master)
{
zone->master = master;
if (master) {
zone->flags |= KNOT_ZONE_MASTER;
} else {
zone->flags &= ~KNOT_ZONE_MASTER;
}
}
/*----------------------------------------------------------------------------*/
......@@ -262,3 +266,14 @@ void knot_zone_set_dtor(knot_zone_t *zone, int (*dtor)(struct knot_zone *))
zone->dtor = dtor;
}
}
void knot_zone_set_flag(knot_zone_t *zone, knot_zone_flag_t flag, unsigned on)
{
if (zone != NULL) {
if (on) {
zone->flags |= flag;
} else {
zone->flags &= ~flag;
}
}
}
......@@ -54,6 +54,15 @@ enum knot_zone_retvals {
typedef enum knot_zone_retvals knot_zone_retvals_t;
/*!
* \brief Zone flags.
*/
typedef enum knot_zone_flag_t {
KNOT_ZONE_SLAVE = 0 << 0, /*! Slave zone */
KNOT_ZONE_MASTER = 1 << 0, /*! Master zone. */
KNOT_ZONE_DISCARDED = 1 << 1 /*! Zone waiting to be discarded. */
} knot_zone_flag_t;
/*----------------------------------------------------------------------------*/
/*!
......@@ -71,8 +80,7 @@ struct knot_zone {
time_t version;
/*! \todo Set when loading zone. */
short master;
unsigned flags;
void *data; /*!< Pointer to generic zone-related data. */
int (*dtor)(struct knot_zone *); /*!< Data destructor. */
......@@ -179,6 +187,24 @@ void knot_zone_set_dtor(knot_zone_t *zone, int (*dtor)(struct knot_zone *));
}
}
/*!
* \brief Return zone flags.
*
* \param zone Zone.
*/
static inline unsigned knot_zone_flags(knot_zone_t *zone) {
return zone->flags;
}
/*!
* \brief Set zone flag.
*
* \param zone Zone.
* \param flag Respected flag.
* \param on 1 to set, 0 to unset flag.
*/
void knot_zone_set_flag(knot_zone_t *zone, knot_zone_flag_t flag, unsigned on);
#endif
/*! @} */
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment