X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb1_tdb.c;h=cc7e580f2c3f1e8fc596da4a53c3039b94ad36de;hp=1ada443d60795a440ac2edc5ea740f68db9b86d8;hb=39f55294799c6443c0ad7bef09f1c113cf89d295;hpb=19e6c1a250ade1e7204ada17163294855585e825;ds=inline diff --git a/ccan/tdb2/tdb1_tdb.c b/ccan/tdb2/tdb1_tdb.c index 1ada443d..cc7e580f 100644 --- a/ccan/tdb2/tdb1_tdb.c +++ b/ccan/tdb2/tdb1_tdb.c @@ -27,13 +27,13 @@ #include "tdb1_private.h" -_PUBLIC_ TDB1_DATA tdb1_null; +TDB1_DATA tdb1_null; /* non-blocking increment of the tdb sequence number if the tdb has been opened using the TDB1_SEQNUM flag */ -_PUBLIC_ void tdb1_increment_seqnum_nonblock(struct tdb1_context *tdb) +void tdb1_increment_seqnum_nonblock(struct tdb1_context *tdb) { tdb1_off_t seqnum=0; @@ -199,7 +199,7 @@ static TDB1_DATA _tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key) return ret; } -_PUBLIC_ TDB1_DATA tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key) +TDB1_DATA tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key) { TDB1_DATA ret = _tdb1_fetch(tdb, key); @@ -224,7 +224,7 @@ _PUBLIC_ TDB1_DATA tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key) * Return -1 if the record was not found. */ -_PUBLIC_ int tdb1_parse_record(struct tdb1_context *tdb, TDB1_DATA key, +int tdb1_parse_record(struct tdb1_context *tdb, TDB1_DATA key, int (*parser)(TDB1_DATA key, TDB1_DATA data, void *private_data), void *private_data) @@ -267,7 +267,7 @@ static int tdb1_exists_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t ha return 1; } -_PUBLIC_ int tdb1_exists(struct tdb1_context *tdb, TDB1_DATA key) +int tdb1_exists(struct tdb1_context *tdb, TDB1_DATA key) { uint32_t hash = tdb->hash_fn(&key); int ret; @@ -425,7 +425,7 @@ static int tdb1_delete_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t ha return ret; } -_PUBLIC_ int tdb1_delete(struct tdb1_context *tdb, TDB1_DATA key) +int tdb1_delete(struct tdb1_context *tdb, TDB1_DATA key) { uint32_t hash = tdb->hash_fn(&key); int ret; @@ -594,7 +594,7 @@ static int _tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, return 0 on success, -1 on failure */ -_PUBLIC_ int tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA dbuf, int flag) +int tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA dbuf, int flag) { uint32_t hash; int ret; @@ -615,7 +615,7 @@ _PUBLIC_ int tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA dbuf, } /* Append to an entry. Create if not exist. */ -_PUBLIC_ int tdb1_append(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA new_dbuf) +int tdb1_append(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA new_dbuf) { uint32_t hash; TDB1_DATA dbuf; @@ -661,30 +661,11 @@ failed: } -/* - return the name of the current tdb file - useful for external logging functions -*/ -_PUBLIC_ const char *tdb1_name(struct tdb1_context *tdb) -{ - return tdb->name; -} - -/* - return the underlying file descriptor being used by tdb, or -1 - useful for external routines that want to check the device/inode - of the fd -*/ -_PUBLIC_ int tdb1_fd(struct tdb1_context *tdb) -{ - return tdb->fd; -} - /* return the current logging function useful for external tdb routines that wish to log tdb errors */ -_PUBLIC_ tdb1_log_func tdb1_log_fn(struct tdb1_context *tdb) +tdb1_log_func tdb1_log_fn(struct tdb1_context *tdb) { return tdb->log.log_fn; } @@ -700,7 +681,7 @@ _PUBLIC_ tdb1_log_func tdb1_log_fn(struct tdb1_context *tdb) The aim of this sequence number is to allow for a very lightweight test of a possible tdb change. */ -_PUBLIC_ int tdb1_get_seqnum(struct tdb1_context *tdb) +int tdb1_get_seqnum(struct tdb1_context *tdb) { tdb1_off_t seqnum=0; @@ -708,70 +689,11 @@ _PUBLIC_ int tdb1_get_seqnum(struct tdb1_context *tdb) return seqnum; } -_PUBLIC_ int tdb1_hash_size(struct tdb1_context *tdb) +int tdb1_hash_size(struct tdb1_context *tdb) { return tdb->header.hash_size; } -_PUBLIC_ size_t tdb1_map_size(struct tdb1_context *tdb) -{ - return tdb->map_size; -} - -_PUBLIC_ int tdb1_get_flags(struct tdb1_context *tdb) -{ - return tdb->flags; -} - -_PUBLIC_ void tdb1_add_flags(struct tdb1_context *tdb, unsigned flags) -{ - if ((flags & TDB1_ALLOW_NESTING) && - (flags & TDB1_DISALLOW_NESTING)) { - tdb->ecode = TDB1_ERR_NESTING; - TDB1_LOG((tdb, TDB1_DEBUG_FATAL, "tdb1_add_flags: " - "allow_nesting and disallow_nesting are not allowed together!")); - return; - } - - if (flags & TDB1_ALLOW_NESTING) { - tdb->flags &= ~TDB1_DISALLOW_NESTING; - } - if (flags & TDB1_DISALLOW_NESTING) { - tdb->flags &= ~TDB1_ALLOW_NESTING; - } - - tdb->flags |= flags; -} - -_PUBLIC_ void tdb1_remove_flags(struct tdb1_context *tdb, unsigned flags) -{ - if ((flags & TDB1_ALLOW_NESTING) && - (flags & TDB1_DISALLOW_NESTING)) { - tdb->ecode = TDB1_ERR_NESTING; - TDB1_LOG((tdb, TDB1_DEBUG_FATAL, "tdb1_remove_flags: " - "allow_nesting and disallow_nesting are not allowed together!")); - return; - } - - if (flags & TDB1_ALLOW_NESTING) { - tdb->flags |= TDB1_DISALLOW_NESTING; - } - if (flags & TDB1_DISALLOW_NESTING) { - tdb->flags |= TDB1_ALLOW_NESTING; - } - - tdb->flags &= ~flags; -} - - -/* - enable sequence number handling on an open tdb -*/ -_PUBLIC_ void tdb1_enable_seqnum(struct tdb1_context *tdb) -{ - tdb->flags |= TDB1_SEQNUM; -} - /* add a region of the file to the freelist. Length is the size of the region in bytes, @@ -804,7 +726,7 @@ static int tdb1_free_region(struct tdb1_context *tdb, tdb1_off_t offset, ssize_t This code carefully steps around the recovery area, leaving it alone */ -_PUBLIC_ int tdb1_wipe_all(struct tdb1_context *tdb) +int tdb1_wipe_all(struct tdb1_context *tdb) { int i; tdb1_off_t offset = 0; @@ -910,7 +832,7 @@ static int repack_traverse(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA da /* repack a tdb */ -_PUBLIC_ int tdb1_repack(struct tdb1_context *tdb) +int tdb1_repack(struct tdb1_context *tdb) { struct tdb1_context *tmp_db; struct traverse_state state;