Commit b562e52e authored by Lubos Slovak's avatar Lubos Slovak

public-libs: Unprefixed some symbols.

Symbols in libknot/internal/ should not have knot_ prefix unless
they are a replacement for a system function.
parent 12869471
......@@ -307,8 +307,8 @@ static int tsig_parse_str(knot_tsig_key_t *key, const char *str)
int algorithm = KNOT_TSIG_ALG_HMAC_MD5;
if (s) {
*s++ = '\0'; /* Last part separator */
knot_lookup_table_t *alg = NULL;
alg = knot_lookup_by_name(knot_tsig_alg_names, h);
lookup_table_t *alg = NULL;
alg = lookup_by_name(knot_tsig_alg_names, h);
if (alg) {
algorithm = alg->id;
} else {
......@@ -357,8 +357,8 @@ static int tsig_parse_line(knot_tsig_key_t *k, char *l)
}
/* Lookup algorithm. */
knot_lookup_table_t *alg;
alg = knot_lookup_by_name(knot_tsig_alg_names, a);
lookup_table_t *alg;
alg = lookup_by_name(knot_tsig_alg_names, a);
if (!alg) {
return KNOT_EMALF;
......
......@@ -222,7 +222,7 @@ static void nsec3_fill_rdata(uint8_t *rdata, const knot_nsec3_params_t *params,
rdata += 1;
*rdata = 0; // flags
rdata += 1;
knot_wire_write_u16(rdata, params->iterations); // iterations
wire_write_u16(rdata, params->iterations); // iterations
rdata += 2;
*rdata = params->salt_length; // salt length
rdata += 1;
......
......@@ -380,7 +380,7 @@ int axfr_answer_process(knot_pkt_t *pkt, struct answer_data *adata)
/* Check RCODE. */
uint8_t rcode = knot_wire_get_rcode(pkt->wire);
if (rcode != KNOT_RCODE_NOERROR) {
knot_lookup_table_t *lut = knot_lookup_by_id(knot_rcode_names, rcode);
lookup_table_t *lut = lookup_by_id(knot_rcode_names, rcode);
if (lut != NULL) {
AXFRIN_LOG(LOG_ERR, "server responded with %s", lut->name);
}
......
......@@ -881,7 +881,7 @@ static int process_soa_answer(knot_pkt_t *pkt, struct answer_data *data)
knot_rdataset_t *soa = node_rdataset(zone->contents->apex, KNOT_RRTYPE_SOA);
uint32_t our_serial = knot_soa_serial(soa);
uint32_t their_serial = knot_soa_serial(&answer->rr[0].rrs);
if (knot_serial_compare(our_serial, their_serial) >= 0) {
if (serial_compare(our_serial, their_serial) >= 0) {
ANSWER_LOG(LOG_INFO, data, "refresh, outgoing", "zone is up-to-date");
zone_events_cancel(zone, ZONE_EVENT_EXPIRE);
return KNOT_NS_PROC_DONE; /* Our zone is up to date. */
......
......@@ -171,7 +171,7 @@ static int ixfr_load_chsets(list_t *chgsets, const zone_t *zone,
/* Compare serials. */
uint32_t serial_to = zone_contents_serial(zone->contents);
uint32_t serial_from = knot_soa_serial(&their_soa->rrs);
int ret = knot_serial_compare(serial_to, serial_from);
int ret = serial_compare(serial_to, serial_from);
if (ret <= 0) { /* We have older/same age zone. */
return KNOT_EUPTODATE;
}
......@@ -695,7 +695,7 @@ int ixfr_process_answer(knot_pkt_t *pkt, struct answer_data *adata)
/* Check RCODE. */
uint8_t rcode = knot_wire_get_rcode(pkt->wire);
if (rcode != KNOT_RCODE_NOERROR) {
knot_lookup_table_t *lut = knot_lookup_by_id(knot_rcode_names, rcode);
lookup_table_t *lut = lookup_by_id(knot_rcode_names, rcode);
if (lut != NULL) {
IXFRIN_LOG(LOG_WARNING, "server responded with %s", lut->name);
}
......
......@@ -122,7 +122,7 @@ int notify_process_answer(knot_pkt_t *pkt, struct answer_data *adata)
/* Check RCODE. */
uint8_t rcode = knot_wire_get_rcode(pkt->wire);
if (rcode != KNOT_RCODE_NOERROR) {
knot_lookup_table_t *lut = knot_lookup_by_id(knot_rcode_names, rcode);
lookup_table_t *lut = lookup_by_id(knot_rcode_names, rcode);
if (lut != NULL) {
NOTIFY_RLOG(LOG_WARNING, "server responded with %s", lut->name);
}
......
......@@ -96,7 +96,7 @@ typedef struct server_t {
/*! \brief Zone database. */
knot_zonedb_t *zone_db;
knot_namedb_t *timers_db;
namedb_t *timers_db;
/*! \brief I/O handlers. */
unsigned tu_size;
......
......@@ -419,7 +419,7 @@ static bool skip_soa(const knot_rrset_t *rr, int64_t sn)
{
if (rr->type == KNOT_RRTYPE_SOA &&
(rr->rclass == KNOT_CLASS_NONE || rr->rclass == KNOT_CLASS_ANY ||
knot_serial_compare(knot_soa_serial(&rr->rrs), sn) <= 0)) {
serial_compare(knot_soa_serial(&rr->rrs), sn) <= 0)) {
return true;
}
......
......@@ -1366,7 +1366,7 @@ uint32_t zone_contents_next_serial(const zone_contents_t *zone, int policy)
}
/* If the new serial is 'lower' or equal than the new one, warn the user.*/
if (knot_serial_compare(old_serial, new_serial) >= 0) {
if (serial_compare(old_serial, new_serial) >= 0) {
log_zone_warning(zone->apex->owner, "updated serial is lower "
"than current, serial %u -> %u",
old_serial, new_serial);
......
......@@ -235,7 +235,7 @@ int zone_events_init(zone_t *zone)
}
int zone_events_setup(struct zone_t *zone, worker_pool_t *workers,
evsched_t *scheduler, knot_namedb_t *timers_db)
evsched_t *scheduler, namedb_t *timers_db)
{
if (!zone || !workers || !scheduler) {
return KNOT_EINVAL;
......
......@@ -52,7 +52,7 @@ typedef struct zone_events {
event_t *event; //!< Scheduler event.
worker_pool_t *pool; //!< Server worker pool.
knot_namedb_t *timers_db; //!< Persistent zone timers database.
namedb_t *timers_db; //!< Persistent zone timers database.
task_t task; //!< Event execution context.
time_t time[ZONE_EVENT_COUNT]; //!< Event execution times.
......@@ -81,7 +81,7 @@ int zone_events_init(struct zone_t *zone);
* \return KNOT_E*
*/
int zone_events_setup(struct zone_t *zone, worker_pool_t *workers,
evsched_t *scheduler, knot_namedb_t *timers_db);
evsched_t *scheduler, namedb_t *timers_db);
/*!
* \brief Deinitialize zone events.
......
......@@ -255,7 +255,7 @@ static int check_dnskey_rdata(const knot_rrset_t *rrset, size_t rdata_pos)
const uint16_t mask = 1 << 8; //0b0000000100000000;
const knot_rdata_t *rr_data = knot_rdataset_at(&rrset->rrs, rdata_pos);
uint16_t flags = knot_wire_read_u16(knot_rdata_data(rr_data));
uint16_t flags = wire_read_u16(knot_rdata_data(rr_data));
if (flags & mask) {
return KNOT_EOK;
} else {
......
......@@ -63,10 +63,10 @@ static void clear_timers(time_t *timers)
}
/*! \brief Stores timers for persistent events. */
static int store_timers(knot_txn_t *txn, zone_t *zone)
static int store_timers(namedb_txn_t *txn, zone_t *zone)
{
// Create key
knot_val_t key = { .len = knot_dname_size(zone->name), .data = zone->name };
namedb_val_t key = { .len = knot_dname_size(zone->name), .data = zone->name };
// Create value
uint8_t packed_timer[EVENT_KEY_PAIR_SIZE * PERSISTENT_EVENT_COUNT];
......@@ -79,24 +79,24 @@ static int store_timers(knot_txn_t *txn, zone_t *zone)
// Write event key and timer to buffer
packed_timer[offset] = event_id_to_key[event];
offset += 1;
knot_wire_write_u64(packed_timer + offset,
wire_write_u64(packed_timer + offset,
(int64_t)zone_events_get_time(zone, event));
offset += sizeof(uint64_t);
}
knot_val_t val = { .len = sizeof(packed_timer), .data = packed_timer };
namedb_val_t val = { .len = sizeof(packed_timer), .data = packed_timer };
// Store
return namedb_lmdb_api()->insert(txn, &key, &val, 0);
}
/*! \brief Reads timers for persistent events. */
static int read_timers(knot_txn_t *txn, const zone_t *zone, time_t *timers)
static int read_timers(namedb_txn_t *txn, const zone_t *zone, time_t *timers)
{
const struct namedb_api *db_api = namedb_lmdb_api();
assert(db_api);
knot_val_t key = { .len = knot_dname_size(zone->name), .data = zone->name };
knot_val_t val;
namedb_val_t key = { .len = knot_dname_size(zone->name), .data = zone->name };
namedb_val_t val;
int ret = db_api->find(txn, &key, &val, 0);
if (ret != KNOT_EOK && ret != KNOT_ENOENT) {
......@@ -116,7 +116,7 @@ static int read_timers(knot_txn_t *txn, const zone_t *zone, time_t *timers)
if (known_event_key(db_key)) {
const zone_event_type_t event = key_to_event_id[db_key];
timers[event] =
(time_t)knot_wire_read_u64((uint8_t *)val.data + offset);
(time_t)wire_read_u64((uint8_t *)val.data + offset);
}
offset += sizeof(uint64_t);
}
......@@ -126,7 +126,7 @@ static int read_timers(knot_txn_t *txn, const zone_t *zone, time_t *timers)
/* -------- API ------------------------------------------------------------- */
int open_timers_db(const char *storage, knot_namedb_t **db_ptr)
int open_timers_db(const char *storage, namedb_t **db_ptr)
{
if (!storage || !db_ptr) {
return KNOT_EINVAL;
......@@ -149,7 +149,7 @@ int open_timers_db(const char *storage, knot_namedb_t **db_ptr)
return ret;
}
void close_timers_db(knot_namedb_t *timer_db)
void close_timers_db(namedb_t *timer_db)
{
if (!timer_db) {
return;
......@@ -161,7 +161,7 @@ void close_timers_db(knot_namedb_t *timer_db)
db_api->deinit(timer_db);
}
int read_zone_timers(knot_namedb_t *timer_db, const zone_t *zone, time_t *timers)
int read_zone_timers(namedb_t *timer_db, const zone_t *zone, time_t *timers)
{
if (timer_db == NULL) {
clear_timers(timers);
......@@ -171,8 +171,8 @@ int read_zone_timers(knot_namedb_t *timer_db, const zone_t *zone, time_t *timers
const struct namedb_api *db_api = namedb_lmdb_api();
assert(db_api);
knot_txn_t txn;
int ret = db_api->txn_begin(timer_db, &txn, KNOT_NAMEDB_RDONLY);
namedb_txn_t txn;
int ret = db_api->txn_begin(timer_db, &txn, NAMEDB_RDONLY);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -186,7 +186,7 @@ int read_zone_timers(knot_namedb_t *timer_db, const zone_t *zone, time_t *timers
return KNOT_EOK;
}
int write_zone_timers(knot_namedb_t *timer_db, zone_t *zone)
int write_zone_timers(namedb_t *timer_db, zone_t *zone)
{
if (timer_db == NULL) {
return KNOT_EOK;
......@@ -195,7 +195,7 @@ int write_zone_timers(knot_namedb_t *timer_db, zone_t *zone)
const struct namedb_api *db_api = namedb_lmdb_api();
assert(db_api);
knot_txn_t txn;
namedb_txn_t txn;
int ret = db_api->txn_begin(timer_db, &txn, 0);
if (ret != KNOT_EOK) {
return ret;
......@@ -210,7 +210,7 @@ int write_zone_timers(knot_namedb_t *timer_db, zone_t *zone)
return db_api->txn_commit(&txn);
}
int sweep_timer_db(knot_namedb_t *timer_db, knot_zonedb_t *zone_db)
int sweep_timer_db(namedb_t *timer_db, knot_zonedb_t *zone_db)
{
if (timer_db == NULL) {
return KNOT_EOK;
......@@ -219,8 +219,8 @@ int sweep_timer_db(knot_namedb_t *timer_db, knot_zonedb_t *zone_db)
const struct namedb_api *db_api = namedb_lmdb_api();
assert(db_api);
knot_txn_t txn;
int ret = db_api->txn_begin(timer_db, &txn, KNOT_NAMEDB_SORTED);
namedb_txn_t txn;
int ret = db_api->txn_begin(timer_db, &txn, NAMEDB_SORTED);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -230,14 +230,14 @@ int sweep_timer_db(knot_namedb_t *timer_db, knot_zonedb_t *zone_db)
return KNOT_EOK;
}
knot_iter_t *it = db_api->iter_begin(&txn, 0);
namedb_iter_t *it = db_api->iter_begin(&txn, 0);
if (it == NULL) {
db_api->txn_abort(&txn);
return KNOT_ERROR;
}
while (it) {
knot_val_t key;
namedb_val_t key;
ret = db_api->iter_key(it, &key);
if (ret != KNOT_EOK) {
db_api->txn_abort(&txn);
......
......@@ -28,14 +28,14 @@
*
* \return KNOT_E*
*/
int open_timers_db(const char *storage, knot_namedb_t **timer_db);
int open_timers_db(const char *storage, namedb_t **timer_db);
/*!
* \brief Closes zone timers db.
*
* \param timer_db Timer database.
*/
void close_timers_db(knot_namedb_t *timer_db);
void close_timers_db(namedb_t *timer_db);
/*!
* \brief Reads zone timers from timers db.
......@@ -50,7 +50,7 @@ void close_timers_db(knot_namedb_t *timer_db);
*
* \return KNOT_E*
*/
int read_zone_timers(knot_namedb_t *timer_db, const zone_t *zone, time_t *timers);
int read_zone_timers(namedb_t *timer_db, const zone_t *zone, time_t *timers);
/*!
* \brief Writes zone timers to timers db.
......@@ -60,7 +60,7 @@ int read_zone_timers(knot_namedb_t *timer_db, const zone_t *zone, time_t *timers
*
* \return KNOT_E*
*/
int write_zone_timers(knot_namedb_t *timer_db, zone_t *zone);
int write_zone_timers(namedb_t *timer_db, zone_t *zone);
/*!
* \brief Removes stale zones info from timers db.
......@@ -69,4 +69,4 @@ int write_zone_timers(knot_namedb_t *timer_db, zone_t *zone);
* \param zone_db Current zone database.
* \return KNOT_EOK or an error
*/
int sweep_timer_db(knot_namedb_t *timer_db, knot_zonedb_t *zone_db);
int sweep_timer_db(namedb_t *timer_db, knot_zonedb_t *zone_db);
......@@ -63,11 +63,11 @@ static int knot_zone_diff_load_soas(const zone_contents_t *zone1,
int64_t soa_serial1 = knot_soa_serial(&soa_rrset1.rrs);
int64_t soa_serial2 = knot_soa_serial(&soa_rrset2.rrs);
if (knot_serial_compare(soa_serial1, soa_serial2) == 0) {
if (serial_compare(soa_serial1, soa_serial2) == 0) {
return KNOT_ENODIFF;
}
if (knot_serial_compare(soa_serial1, soa_serial2) > 0) {
if (serial_compare(soa_serial1, soa_serial2) > 0) {
return KNOT_ERANGE;
}
......
......@@ -314,7 +314,7 @@ bool zone_transfer_needed(const zone_t *zone, const knot_pkt_t *pkt)
return false;
}
return knot_serial_compare(zone_contents_serial(zone->contents),
return serial_compare(zone_contents_serial(zone->contents),
knot_soa_serial(&soa.rrs)) < 0;
}
......@@ -19,7 +19,7 @@
#include "libknot/internal/macros.h"
_public_
knot_lookup_table_t knot_opcode_names[] = {
lookup_table_t knot_opcode_names[] = {
{ KNOT_OPCODE_QUERY, "QUERY" },
{ KNOT_OPCODE_IQUERY, "IQUERY" },
{ KNOT_OPCODE_STATUS, "STATUS" },
......@@ -29,7 +29,7 @@ knot_lookup_table_t knot_opcode_names[] = {
};
_public_
knot_lookup_table_t knot_rcode_names[] = {
lookup_table_t knot_rcode_names[] = {
{ KNOT_RCODE_NOERROR, "NOERROR" },
{ KNOT_RCODE_FORMERR, "FORMERR" },
{ KNOT_RCODE_SERVFAIL, "SERVFAIL" },
......@@ -46,7 +46,7 @@ knot_lookup_table_t knot_rcode_names[] = {
};
_public_
knot_lookup_table_t knot_tsig_err_names[] = {
lookup_table_t knot_tsig_err_names[] = {
{ KNOT_TSIG_ERR_BADSIG, "BADSIG" },
{ KNOT_TSIG_ERR_BADKEY, "BADKEY" },
{ KNOT_TSIG_ERR_BADTIME, "BADTIME" },
......@@ -55,7 +55,7 @@ knot_lookup_table_t knot_tsig_err_names[] = {
};
_public_
knot_lookup_table_t knot_tkey_err_names[] = {
lookup_table_t knot_tkey_err_names[] = {
{ KNOT_TKEY_ERR_BADMODE, "BADMODE" },
{ KNOT_TKEY_ERR_BADNAME, "BADNAME" },
{ KNOT_TKEY_ERR_BADALG, "BADALG" },
......@@ -63,7 +63,7 @@ knot_lookup_table_t knot_tkey_err_names[] = {
};
_public_
knot_lookup_table_t knot_tsig_alg_names[] = {
lookup_table_t knot_tsig_alg_names[] = {
{ KNOT_TSIG_ALG_HMAC_MD5, "hmac-md5" },
{ KNOT_TSIG_ALG_HMAC_SHA1, "hmac-sha1" },
{ KNOT_TSIG_ALG_HMAC_SHA224, "hmac-sha224" },
......@@ -74,7 +74,7 @@ knot_lookup_table_t knot_tsig_alg_names[] = {
};
_public_
knot_lookup_table_t knot_tsig_alg_dnames_str[] = {
lookup_table_t knot_tsig_alg_dnames_str[] = {
{ KNOT_TSIG_ALG_GSS_TSIG, "gss-tsig." },
{ KNOT_TSIG_ALG_HMAC_MD5, "hmac-md5.sig-alg.reg.int." },
{ KNOT_TSIG_ALG_HMAC_SHA1, "hmac-sha1." },
......@@ -86,7 +86,7 @@ knot_lookup_table_t knot_tsig_alg_dnames_str[] = {
};
_public_
knot_lookup_table_t knot_tsig_alg_dnames[] = {
lookup_table_t knot_tsig_alg_dnames[] = {
{ KNOT_TSIG_ALG_GSS_TSIG, "\x08" "gss-tsig" },
{ KNOT_TSIG_ALG_HMAC_MD5, "\x08" "hmac-md5" "\x07" "sig-alg" "\x03" "reg" "\x03" "int" },
{ KNOT_TSIG_ALG_HMAC_SHA1, "\x09" "hmac-sha1" },
......@@ -98,7 +98,7 @@ knot_lookup_table_t knot_tsig_alg_dnames[] = {
};
_public_
knot_lookup_table_t knot_dnssec_alg_names[] = {
lookup_table_t knot_dnssec_alg_names[] = {
{ KNOT_DNSSEC_ALG_RSAMD5, "RSAMD5" },
{ KNOT_DNSSEC_ALG_DH, "DH" },
{ KNOT_DNSSEC_ALG_DSA, "DSA" },
......
......@@ -191,42 +191,42 @@ typedef enum {
/*!
* \brief DNS operation code names.
*/
extern knot_lookup_table_t knot_opcode_names[];
extern lookup_table_t knot_opcode_names[];
/*!
* \brief DNS reply code names.
*/
extern knot_lookup_table_t knot_rcode_names[];
extern lookup_table_t knot_rcode_names[];
/*!
* \brief TSIG error names.
*/
extern knot_lookup_table_t knot_tsig_err_names[];
extern lookup_table_t knot_tsig_err_names[];
/*!
* \brief TKEY error names.
*/
extern knot_lookup_table_t knot_tkey_err_names[];
extern lookup_table_t knot_tkey_err_names[];
/*!
* \brief TSIG key algorithm names.
*/
extern knot_lookup_table_t knot_tsig_alg_names[];
extern lookup_table_t knot_tsig_alg_names[];
/*!
* \brief TSIG key algorithm names in a domain form.
*/
extern knot_lookup_table_t knot_tsig_alg_dnames_str[];
extern lookup_table_t knot_tsig_alg_dnames_str[];
/*!
* \brief TSIG key algorithm domain names.
*/
extern knot_lookup_table_t knot_tsig_alg_dnames[];
extern lookup_table_t knot_tsig_alg_dnames[];
/*!
* \brief DNSSEC algorithm names.
*/
extern knot_lookup_table_t knot_dnssec_alg_names[];
extern lookup_table_t knot_dnssec_alg_names[];
/*!
* \brief Returns length of TSIG digest for given algorithm.
......
......@@ -387,7 +387,7 @@ int knot_load_key_params(const char *filename, knot_key_params_t *key_params)
key_params->name = name;
key_params->rdata = rdata;
key_params->keytag = knot_keytag(rdata.data, rdata.size);
key_params->flags = knot_wire_read_u16(rdata.data);
key_params->flags = wire_read_u16(rdata.data);
char *buffer = NULL;
size_t buffer_size = 0;
......
......@@ -78,19 +78,19 @@ int knot_rrsig_write_rdata(uint8_t *rdata, const knot_dnssec_key_t *key,
uint8_t *w = rdata;
knot_wire_write_u16(w, covered_type); // type covered
wire_write_u16(w, covered_type); // type covered
w += sizeof(uint16_t);
*w = key->algorithm; // algorithm
w += sizeof(uint8_t);
*w = owner_labels; // labels
w += sizeof(uint8_t);
knot_wire_write_u32(w, owner_ttl); // original TTL
wire_write_u32(w, owner_ttl); // original TTL
w += sizeof(uint32_t);
knot_wire_write_u32(w, sig_expires); // signature expiration
wire_write_u32(w, sig_expires); // signature expiration
w += sizeof(uint32_t);
knot_wire_write_u32(w, sig_incepted); // signature inception
wire_write_u32(w, sig_incepted); // signature inception
w += sizeof(uint32_t);
knot_wire_write_u16(w, key->keytag); // key fingerprint
wire_write_u16(w, key->keytag); // key fingerprint
w += sizeof(uint16_t);
assert(w == rdata + RRSIG_RDATA_SIGNER_OFFSET);
......
......@@ -21,22 +21,22 @@
#include "libknot/internal/mempattern.h"
enum {
KNOT_NAMEDB_RDONLY = 1 << 0,
KNOT_NAMEDB_SORTED = 1 << 1
NAMEDB_RDONLY = 1 << 0,
NAMEDB_SORTED = 1 << 1
};
typedef void knot_namedb_t;
typedef void knot_iter_t;
typedef void namedb_t;
typedef void namedb_iter_t;
typedef struct knot_val {
void *data;
size_t len;
} knot_val_t;
} namedb_val_t;
typedef struct knot_txn {
knot_namedb_t *db;
namedb_t *db;
void *txn;
} knot_txn_t;
} namedb_txn_t;
struct namedb_api {
......@@ -44,27 +44,27 @@ struct namedb_api {
/* Context operations */
int (*init)(const char *config, knot_namedb_t **db, mm_ctx_t *mm);
void (*deinit)(knot_namedb_t *db);
int (*init)(const char *config, namedb_t **db, mm_ctx_t *mm);
void (*deinit)(namedb_t *db);
/* Transactions */
int (*txn_begin)(knot_namedb_t *db, knot_txn_t *txn, unsigned flags);
int (*txn_commit)(knot_txn_t *txn);
void (*txn_abort)(knot_txn_t *txn);
int (*txn_begin)(namedb_t *db, namedb_txn_t *txn, unsigned flags);
int (*txn_commit)(namedb_txn_t *txn);
void (*txn_abort)(namedb_txn_t *txn);
/* Data access */
int (*count)(knot_txn_t *txn);
int (*find)(knot_txn_t *txn, knot_val_t *key, knot_val_t *val, unsigned flags);
int (*insert)(knot_txn_t *txn, knot_val_t *key, knot_val_t *val, unsigned flags);
int (*del)(knot_txn_t *txn,knot_val_t *key);
int (*count)(namedb_txn_t *txn);
int (*find)(namedb_txn_t *txn, namedb_val_t *key, namedb_val_t *val, unsigned flags);
int (*insert)(namedb_txn_t *txn, namedb_val_t *key, namedb_val_t *val, unsigned flags);
int (*del)(namedb_txn_t *txn,namedb_val_t *key);
/* Iteration */
knot_iter_t *(*iter_begin)(knot_txn_t *txn, unsigned flags);
knot_iter_t *(*iter_next)(knot_iter_t *iter);
int (*iter_key)(knot_iter_t *iter, knot_val_t *key);
int (*iter_val)(knot_iter_t *iter, knot_val_t *val);
void (*iter_finish)(knot_iter_t *iter);
namedb_iter_t *(*iter_begin)(namedb_txn_t *txn, unsigned flags);
namedb_iter_t *(*iter_next)(namedb_iter_t *iter);
int (*iter_key)(namedb_iter_t *iter, namedb_val_t *key);
int (*iter_val)(namedb_iter_t *iter, namedb_val_t *val);
void (*iter_finish)(namedb_iter_t *iter);
};
......@@ -20,7 +20,7 @@
#include "libknot/internal/trie/hat-trie.h"
#include "libknot/internal/mempattern.h"
static int init(const char *config, knot_namedb_t **db, mm_ctx_t *mm)
static int init(const char *config, namedb_t **db, mm_ctx_t *mm)
{
if (config != NULL || db == NULL) {
return KNOT_EINVAL;
......@@ -36,22 +36,22 @@ static int init(const char *config, knot_namedb_t **db, mm_ctx_t *mm)
return KNOT_EOK;
}
static void deinit(knot_namedb_t *db)
static void deinit(namedb_t *db)
{
hattrie_free((hattrie_t *)db);
}
static int txn_begin(knot_namedb_t *db, knot_txn_t *txn, unsigned flags)
static int txn_begin(namedb_t *db, namedb_txn_t *txn, unsigned flags)
{
txn->txn = (void *)(size_t)flags;
txn->db = db;
return KNOT_EOK; /* N/A */
}
static int txn_commit(knot_txn_t *txn)
static int txn_commit(namedb_txn_t *txn)
{
/* Rebuild order index only for WR transactions. */
if ((size_t)txn->txn & KNOT_NAMEDB_RDONLY) {
if ((size_t)txn->txn & NAMEDB_RDONLY) {
return KNOT_EOK;
}
......@@ -59,16 +59,16 @@ static int txn_commit(knot_txn_t *txn)
return KNOT_EOK;
}
static void txn_abort(knot_txn_t *txn)
static void txn_abort(namedb_txn_t *txn)
{
}
static int count(knot_txn_t *txn)
static int count(namedb_txn_t *txn)
{
return hattrie_weight((hattrie_t *)txn->db);
}
static int find(knot_txn_t *txn, knot_val_t *key, knot_val_t *val, unsigned flags)
static int find(namedb_txn_t *txn, namedb_val_t *key, namedb_val_t *val, unsigned flags)
{
value_t *ret = hattrie_tryget((hattrie_t *)txn->db, key->data, key->len);
if (ret == NULL) {
......@@ -80,7 +80,7 @@ static int find(knot_txn_t *txn, knot_val_t *key, knot_val_t *val, unsigned flag
return KNOT_EOK;
}
static int insert(knot_txn_t *txn, knot_val_t *key, knot_val_t *val, unsigned flags)
static int insert(namedb_txn_t *txn, namedb_val_t *key, namedb_val_t *val, unsigned flags)
{
value_t *ret = hattrie_get((hattrie_t *)txn->db, key->data, key->len);
if (ret == NULL) {
......@@ -91,17 +91,17 @@ static int insert(knot_txn_t *txn, knot_val_t *key, knot_val_t *val, unsigned fl
return KNOT_EOK;
}
static int del(knot_txn_t *txn, knot_val_t *key)
static int del(namedb_txn_t *txn, namedb_val_t *key)
{
return hattrie_del((hattrie_t *)txn->db, key->data, key->len);
}
static knot_iter_t *iter_begin(knot_txn_t *txn, unsigned flags)
static namedb_iter_t *iter_begin(namedb_txn_t *txn, unsigned flags)
{
return hattrie_iter_begin((hattrie_t *)txn->db, (flags & KNOT_NAMEDB_SORTED));
return hattrie_iter_begin((hattrie_t *)txn->db, (flags & NAMEDB_SORTED));
}
static knot_iter_t *iter_next(knot_iter_t *iter)
static namedb_iter_t *iter_next(namedb_iter_t *iter)
{
hattrie_iter_next((hattrie_iter_t *)iter);
if (hattrie_iter_finished((hattrie_iter_t *)iter)) {
......@@ -112,7 +112,7 @@ static knot_iter_t *iter_next(knot_iter_t *iter)
return iter;
}
static int iter_key(knot_iter_t *iter, knot_val_t *val)
static int iter_key(namedb_iter_t *iter, namedb_val_t *val)
{
val->data = (void *)hattrie_iter_key((hattrie_iter_t *)iter, &val->len);
if (val->data == NULL) {
......@@ -122,7 +122,7 @@ static int iter_key(knot_iter_t *iter, knot_val_t *val)
return KNOT_EOK;
}
static int iter_val(knot_iter_t *iter, knot_val_t *val)
static int iter_val(namedb_iter_t *iter, namedb_val_t *val)
{
value_t *ret = hattrie_iter_val((hattrie_iter_t *)iter);
if (ret == NULL) {
......@@ -134,7 +134,7 @@ static int iter_val(knot_iter_t *iter, knot_val_t *val)
return KNOT_EOK;
}
static void iter_finish(knot_iter_t *iter)
static void iter_finish(namedb_iter_t *iter)
{
hattrie_iter_free((hattrie_iter_t *)iter);
}
......
......@@ -25,7 +25,7 @@
/*----------------------------------------------------------------------------*/
_public_
knot_lookup_table_t *knot_lookup_by_name(knot_lookup_table_t *table,
lookup_table_t *lookup_by_name(lookup_table_t *table,
const char *name)
{
while (table->name != NULL) {
......@@ -40,7 +40,7 @@ knot_lookup_table_t *knot_lookup_by_name(knot_lookup_table_t *table,
/*----------------------------------------------------------------------------*/
_public_
knot_lookup_table_t *knot_lookup_by_id(knot_lookup_table_t *table,
lookup_table_t *lookup_by_id(lookup_table_t *table,
int id)
{
while (table->name != NULL) {
......@@ -61,7 +61,7 @@ static int32_t serial_difference(uint32_t s1, uint32_t s2)
}
_public_
int knot_serial_compare(uint32_t s1, uint32_t s2)