added ldb_ldif_message_string()
authorAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 01:14:33 +0000 (11:14 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 08:19:54 +0000 (18:19 +1000)
This function provides a easy function for displaying a ldb_message
structure in a human readable format. It is especially useful for
calling in gdb.

source4/lib/ldb/common/ldb_ldif.c
source4/lib/ldb/include/ldb.h

index 30370e6999aabd4cc754aae9c32589b639bff2f1..83f08b609b8c4772dd003fe0b030ca2dc347a723 100644 (file)
@@ -799,3 +799,19 @@ char *ldb_ldif_write_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
        }
        return state.string;
 }
+
+/*
+  convenient function to turn a ldb_message into a string. Useful for
+  debugging
+ */
+char *ldb_ldif_message_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, 
+                             enum ldb_changetype changetype,
+                             const struct ldb_message *msg)
+{
+       struct ldb_ldif ldif;
+
+       ldif.changetype = changetype;
+       ldif.msg = msg;
+
+       return ldb_ldif_write_string(ldb, mem_ctx, &ldif);
+}
index 8972fc83e9a091ec733f34b45c0ba794ec4c178a..4e47497a5e0e9a26d72016f18b0acdefe861d2c9 100644 (file)
@@ -1463,6 +1463,18 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif
 char * ldb_ldif_write_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, 
                          const struct ldb_ldif *msg);
 
+
+/*
+   Produce a string form of an ldb message
+
+   convenient function to turn a ldb_message into a string. Useful for
+   debugging
+ */
+char *ldb_ldif_message_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, 
+                             enum ldb_changetype changetype,
+                             const struct ldb_message *msg);
+
+
 /**
    Base64 encode a buffer