util_tdb: move timeout chainlock variants from source3/lib/util/util_tdb.c
[obnox/samba/samba-obnox.git] / lib / util / util_tdb.h
index 2d805d7d20c45961b9577d370ff2e20174dce52c..d8a23330353127dd462e314cbad3385cabe79c3b 100644 (file)
@@ -27,6 +27,7 @@
 ****************************************************************/
 TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize);
 bool tdb_data_equal(TDB_DATA t1, TDB_DATA t2);
+bool tdb_data_is_empty(TDB_DATA d);
 TDB_DATA string_tdb_data(const char *string);
 TDB_DATA string_term_tdb_data(const char *string);
 
@@ -50,6 +51,24 @@ int tdb_read_lock_bystring(struct tdb_context *tdb, const char *keyval);
 ****************************************************************************/
 void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval);
 
+/****************************************************************************
+ Lock a chain, with timeout.
+****************************************************************************/
+int tdb_chainlock_with_timeout( struct tdb_context *tdb, TDB_DATA key,
+                               unsigned int timeout);
+
+/****************************************************************************
+ Lock a chain by string, with timeout Return non-zero if lock failed.
+****************************************************************************/
+int tdb_lock_bystring_with_timeout(struct tdb_context *tdb, const char *keyval,
+                                  int timeout);
+
+/****************************************************************************
+ Readlock a chain by string, with timeout Return non-zero if lock failed.
+****************************************************************************/
+int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval,
+                                       unsigned int timeout);
+
 /****************************************************************************
  Fetch a int32_t value by a arbitrary blob key, return -1 if not found.
  Output is int32_t in native byte order.
@@ -131,5 +150,11 @@ bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr, uint3
 int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf,
                      void *state);
 
+/****************************************************************************
+ Return an NTSTATUS from a TDB_ERROR
+****************************************************************************/
+
+NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err);
+
 #endif /* _____LIB_UTIL_UTIL_TDB_H__ */