summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/tools
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-10-14 04:43:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:00 -0500
commit2ad8e1443de55a005cb9249ba317ab8541ec7c90 (patch)
treef770faf7ff80afa3fde12694b62a9a59eee9317c /source4/lib/ldb/tools
parent57b8c5cd227d33b2eec34ed503b0b14c04344a87 (diff)
downloadsamba-2ad8e1443de55a005cb9249ba317ab8541ec7c90.tar.gz
samba-2ad8e1443de55a005cb9249ba317ab8541ec7c90.tar.bz2
samba-2ad8e1443de55a005cb9249ba317ab8541ec7c90.zip
r19273: - fixed error handling with the ldap backend
- propogate errors to the ldbadd command line tool - use the rdn_name module when testing the tdb backend to allow the same test code to correctly test the ldap and non-ldap backends (This used to be commit dd82c474a123d90329bda653a4cb73c93e087b15)
Diffstat (limited to 'source4/lib/ldb/tools')
-rw-r--r--source4/lib/ldb/tools/ldbadd.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index 6a0f510244..9595703e92 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -54,10 +54,10 @@ static void usage(void)
/*
add records from an opened file
*/
-static int process_file(struct ldb_context *ldb, FILE *f)
+static int process_file(struct ldb_context *ldb, FILE *f, int *count)
{
struct ldb_ldif *ldif;
- int ret, count=0;
+ int ret = LDB_SUCCESS;
while ((ldif = ldb_ldif_read_file(ldb, f))) {
if (ldif->changetype != LDB_CHANGETYPE_ADD &&
@@ -74,12 +74,12 @@ static int process_file(struct ldb_context *ldb, FILE *f)
ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn));
failures++;
} else {
- count++;
+ (*count)++;
}
ldb_ldif_read_free(ldb, ldif);
}
- return count;
+ return ret;
}
@@ -87,7 +87,7 @@ static int process_file(struct ldb_context *ldb, FILE *f)
int main(int argc, const char **argv)
{
struct ldb_context *ldb;
- int i, count=0;
+ int i, ret=0, count=0;
struct ldb_cmdline *options;
ldb_global_init();
@@ -97,7 +97,7 @@ int main(int argc, const char **argv)
options = ldb_cmdline_process(ldb, argc, argv, usage);
if (options->argc == 0) {
- count += process_file(ldb, stdin);
+ ret = process_file(ldb, stdin, &count);
} else {
for (i=0;i<options->argc;i++) {
const char *fname = options->argv[i];
@@ -107,7 +107,7 @@ int main(int argc, const char **argv)
perror(fname);
exit(1);
}
- count += process_file(ldb, f);
+ ret = process_file(ldb, f, &count);
fclose(f);
}
}
@@ -116,5 +116,5 @@ int main(int argc, const char **argv)
printf("Added %d records with %d failures\n", count, failures);
- return 0;
+ return ret;
}