summaryrefslogtreecommitdiff
path: root/source3/lib/ldb/tools/ldbadd.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/ldb/tools/ldbadd.c')
-rw-r--r--source3/lib/ldb/tools/ldbadd.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/source3/lib/ldb/tools/ldbadd.c b/source3/lib/ldb/tools/ldbadd.c
index 4dde2a1ef53..155395e065a 100644
--- a/source3/lib/ldb/tools/ldbadd.c
+++ b/source3/lib/ldb/tools/ldbadd.c
@@ -35,8 +35,6 @@
#include "ldb/include/includes.h"
#include "ldb/tools/cmdline.h"
-static int failures;
-
static void usage(void)
{
printf("Usage: ldbadd <options> <ldif...>\n");
@@ -53,7 +51,8 @@ static void usage(void)
/*
add records from an opened file
*/
-static int process_file(struct ldb_context *ldb, FILE *f, int *count)
+static int process_file(struct ldb_context *ldb, FILE *f, int *count,
+ int *failures)
{
struct ldb_ldif *ldif;
int ret = LDB_SUCCESS;
@@ -71,7 +70,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, int *count)
if (ret != LDB_SUCCESS) {
fprintf(stderr, "ERR: \"%s\" on DN %s\n",
ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn));
- failures++;
+ (*failures)++;
} else {
(*count)++;
}
@@ -86,7 +85,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, int *count)
int main(int argc, const char **argv)
{
struct ldb_context *ldb;
- int i, ret=0, count=0;
+ int i, ret=0, count=0, failures=0;
struct ldb_cmdline *options;
ldb_global_init();
@@ -96,7 +95,7 @@ int main(int argc, const char **argv)
options = ldb_cmdline_process(ldb, argc, argv, usage);
if (options->argc == 0) {
- ret = process_file(ldb, stdin, &count);
+ ret = process_file(ldb, stdin, &count, &failures);
} else {
for (i=0;i<options->argc;i++) {
const char *fname = options->argv[i];
@@ -106,7 +105,7 @@ int main(int argc, const char **argv)
perror(fname);
exit(1);
}
- ret = process_file(ldb, f, &count);
+ ret = process_file(ldb, f, &count, &failures);
fclose(f);
}
}