summaryrefslogtreecommitdiff
path: root/lib/util/util_ntdb.h
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-06-22 09:44:42 +0930
committerRusty Russell <rusty@rustcorp.com.au>2012-06-22 07:35:17 +0200
commit02bacf1f95046163dfb5afb40f33b37ccdf1f374 (patch)
tree3e6099c3ae408aec1a771cca028a91955c877794 /lib/util/util_ntdb.h
parent348159d1e4c11c330a75600269b1d45be70d8bb2 (diff)
downloadsamba-02bacf1f95046163dfb5afb40f33b37ccdf1f374.tar.gz
samba-02bacf1f95046163dfb5afb40f33b37ccdf1f374.tar.bz2
samba-02bacf1f95046163dfb5afb40f33b37ccdf1f374.zip
util: util_ntdb ntdb_fetch_int32/ntdb_store_int32 and ntdb_add_int32_atomic
Similar to the util_tdb versions, but return the error code. ntdb_add_int32_atomic seems a clearer name than tdb_change_int32_atomic. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/util/util_ntdb.h')
-rw-r--r--lib/util/util_ntdb.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/util/util_ntdb.h b/lib/util/util_ntdb.h
index eac0db4f02..7531c42dee 100644
--- a/lib/util/util_ntdb.h
+++ b/lib/util/util_ntdb.h
@@ -96,6 +96,30 @@ enum NTDB_ERROR ntdb_fetch_bystring(struct ntdb_context *ntdb,
/****************************************************************************
+ Fetch a int32_t value by a string key. *val is int32_t in native byte order.
+ ntdb must have been created with ntdb_new() (as it uses talloc_free).
+****************************************************************************/
+enum NTDB_ERROR ntdb_fetch_int32(struct ntdb_context *ntdb,
+ const char *keystr, int32_t *val);
+
+/****************************************************************************
+ Store a int32_t value by a string key. val is int32_t in native byte order.
+****************************************************************************/
+enum NTDB_ERROR ntdb_store_int32(struct ntdb_context *ntdb,
+ const char *keystr, int32_t val);
+
+
+/****************************************************************************
+ Atomic integer add; reads the old value into *oldval (if found), then stores
+ *oldval + addval back for next time. Uses chainlock to do this atomically.
+
+ Thus the first time this is ever called, oldval will be unchanged.
+****************************************************************************/
+enum NTDB_ERROR ntdb_add_int32_atomic(struct ntdb_context *ntdb,
+ const char *keystr,
+ int32_t *oldval, int32_t addval);
+
+/****************************************************************************
Turn a nul-terminated string into an NTDB_DATA.
****************************************************************************/
static inline NTDB_DATA string_term_ntdb_data(const char *string)