Fix the mess with ldb includes.
[metze/samba/wip.git] / source4 / lib / ldb / tools / ldbadd.c
index 4ee66c4fc088b490e55f8d5560a24bab117d7c60..be02334797fa4e4f21f47901f0343d23fc274e21 100644 (file)
@@ -31,7 +31,7 @@
  *  Author: Andrew Tridgell
  */
 
-#include "ldb_includes.h"
+#include "ldb.h"
 #include "tools/cmdline.h"
 
 static int failures;
@@ -88,10 +88,15 @@ int main(int argc, const char **argv)
        int i, ret=0, count=0;
        struct ldb_cmdline *options;
 
-       ldb = ldb_init(NULL);
+       ldb = ldb_init(NULL, NULL);
 
        options = ldb_cmdline_process(ldb, argc, argv, usage);
 
+       if (ldb_transaction_start(ldb) != 0) {
+               printf("Failed to start transaction: %s\n", ldb_errstring(ldb));
+               exit(1);
+       }
+
        if (options->argc == 0) {
                ret = process_file(ldb, stdin, &count);
        } else {
@@ -108,6 +113,11 @@ int main(int argc, const char **argv)
                }
        }
 
+       if (count != 0 && ldb_transaction_commit(ldb) != 0) {
+               printf("Failed to commit transaction: %s\n", ldb_errstring(ldb));
+               exit(1);
+       }
+
        talloc_free(ldb);
 
        printf("Added %d records with %d failures\n", count, failures);