return ret;
}
+
+int db_hash_traverse_update(struct db_hash_context *dh,
+ db_hash_record_parser_fn parser,
+ void *private_data, int *count)
+{
+ struct db_hash_traverse_state state;
+ int ret;
+
+ if (dh == NULL || parser == NULL) {
+ return EINVAL;
+ }
+
+ state.parser = parser;
+ state.private_data = private_data;
+
+ ret = tdb_traverse(dh->db, db_hash_traverse_parser, &state);
+ if (ret == -1) {
+ ret = db_hash_map_tdb_error(dh);
+ } else {
+ if (count != NULL) {
+ *count = ret;
+ }
+ ret = 0;
+ }
+
+ return ret;
+}
int db_hash_exists(struct db_hash_context *dh, uint8_t *keybuf, size_t keylen);
/**
- * @brief Traverse the database
+ * @brief Traverse the database without modification
*
- * The parser function should non-zero value to stop traverse.
+ * The parser function should return non-zero value to stop traverse.
*
* @param[in] dh The tdb hash table context
* @param[in] parser Function called for each record
db_hash_record_parser_fn parser, void *private_data,
int *count);
+/**
+ * @brief Traverse the database for modifications
+ *
+ * The parser function should return non-zero value to stop traverse.
+ *
+ * @param[in] dh The tdb hash table context
+ * @param[in] parser Function called for each record
+ * @param[in] private_data Private data to parser function
+ * @param[out] count Number of records traversed
+ * @return 0 on success, errno on failure
+ */
+int db_hash_traverse_update(struct db_hash_context *dh,
+ db_hash_record_parser_fn parser,
+ void *private_data, int *count);
+
#endif /* __CTDB_DB_HASH_H__ */