Skip to content
Snippets Groups Projects
Commit 73b3045f authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

namedb: symbol prefixes, copyrights, trailing white spaces

parent 6f137732
Branches
Tags
No related merge requests found
......@@ -19,8 +19,8 @@
#include "libknot/dname.h"
enum {
NAMEDB_RDONLY = 1 << 0,
NAMEDB_SORTED = 1 << 1
KNOT_NAMEDB_RDONLY = 1 << 0,
KNOT_NAMEDB_SORTED = 1 << 1
};
typedef void knot_namedb_t;
......@@ -42,7 +42,7 @@ struct namedb_api {
/* Context operations */
knot_namedb_t* (*init)(const char *handle, mm_ctx_t *mm);
knot_namedb_t *(*init)(const char *handle, mm_ctx_t *mm);
void (*deinit)(knot_namedb_t *db);
/* Transactions */
......@@ -66,5 +66,3 @@ struct namedb_api {
int (*iter_val)(knot_iter_t *iter, knot_val_t *val);
void (*iter_finish)(knot_iter_t *iter);
};
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
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/>.
*/
#ifdef HAVE_LMDB
#include <lmdb.h>
......@@ -54,7 +70,7 @@ static void dbase_close(struct lmdb_env *env)
mdb_env_close(env->env);
}
static knot_namedb_t* init(const char *handle, mm_ctx_t *mm)
static knot_namedb_t *init(const char *handle, mm_ctx_t *mm)
{
struct lmdb_env *env = mm_alloc(mm, sizeof(struct lmdb_env));
if (env == NULL) {
......@@ -88,7 +104,7 @@ static int txn_begin(knot_namedb_t *db, knot_txn_t *txn, unsigned flags)
txn->txn = NULL;
unsigned txn_flags = 0;
if (flags & NAMEDB_RDONLY) {
if (flags & KNOT_NAMEDB_RDONLY) {
txn_flags |= MDB_RDONLY;
}
......@@ -297,4 +313,3 @@ struct namedb_api *namedb_lmdb_api(void)
}
#endif
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
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/>.
*/
#pragma once
#include "common/namedb/namedb.h"
struct namedb_api *namedb_lmdb_api(void);
\ No newline at end of file
struct namedb_api *namedb_lmdb_api(void);
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
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/>.
*/
#include "common/namedb/namedb_trie.h"
#include "common-knot/hattrie/hat-trie.h"
#include "libknot/errcode.h"
static knot_namedb_t* init(const char *handle, mm_ctx_t *mm)
static knot_namedb_t *init(const char *handle, mm_ctx_t *mm)
{
return hattrie_create_n(TRIE_BUCKET_SIZE, mm);
}
......@@ -22,7 +38,7 @@ static int txn_begin(knot_namedb_t *db, knot_txn_t *txn, unsigned flags)
static int txn_commit(knot_txn_t *txn)
{
/* Rebuild order index only for WR transactions. */
if ((size_t)txn->txn & NAMEDB_RDONLY) {
if ((size_t)txn->txn & KNOT_NAMEDB_RDONLY) {
return KNOT_EOK;
}
......@@ -69,7 +85,7 @@ static int del(knot_txn_t *txn, knot_val_t *key)
static knot_iter_t *iter_begin(knot_txn_t *txn, unsigned flags)
{
return hattrie_iter_begin((hattrie_t *)txn->db, (flags & NAMEDB_SORTED));
return hattrie_iter_begin((hattrie_t *)txn->db, (flags & KNOT_NAMEDB_SORTED));
}
static knot_iter_t *iter_next(knot_iter_t *iter)
......@@ -122,4 +138,3 @@ struct namedb_api *namedb_trie_api(void)
return &api;
}
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
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/>.
*/
#pragma once
#include "common/namedb/namedb.h"
struct namedb_api *namedb_trie_api(void);
\ No newline at end of file
struct namedb_api *namedb_trie_api(void);
......@@ -79,7 +79,7 @@ static int namedb_test_set(unsigned nkeys, char **keys, char *dbid,
ok(ret == KNOT_EOK, "%s: txn_commit(WR)", api->name);
/* Start RD transaction. */
ret = api->txn_begin(db, &txn, NAMEDB_RDONLY);
ret = api->txn_begin(db, &txn, KNOT_NAMEDB_RDONLY);
ok(ret == KNOT_EOK, "%s: txn_begin(RD)", api->name);
/* Lookup all keys */
......@@ -119,7 +119,7 @@ static int namedb_test_set(unsigned nkeys, char **keys, char *dbid,
/* Sorted iteration. */
char key_buf[KEY_MAXLEN] = {'\0'};
iterated = 0;
it = api->iter_begin(&txn, NAMEDB_SORTED);
it = api->iter_begin(&txn, KNOT_NAMEDB_SORTED);
while (it != NULL) {
ret = api->iter_key(it, &key);
if (iterated > 0) { /* Only if previous exists. */
......
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