summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-08-25 06:38:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:16:44 -0500
commit6a4794452fdfffac4d9b1c6fc95bcb475f62b68c (patch)
tree7ff863f129aa71db3f96dc9a59cb94fc04784e90 /source4/lib/ldb
parent50f5c65f7815643b0726bbe8062a0fd496fa99dc (diff)
downloadsamba-6a4794452fdfffac4d9b1c6fc95bcb475f62b68c.tar.gz
samba-6a4794452fdfffac4d9b1c6fc95bcb475f62b68c.tar.bz2
samba-6a4794452fdfffac4d9b1c6fc95bcb475f62b68c.zip
r17820: simplify the code flow a little
(This used to be commit 221272e3930e1fbf30df1ad19713935d38cde46c)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/tools/cmdline.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c
index 1fd14d1739..de24475f6e 100644
--- a/source4/lib/ldb/tools/cmdline.c
+++ b/source4/lib/ldb/tools/cmdline.c
@@ -33,6 +33,8 @@
#include "db_wrap.h"
#endif
+
+
/*
process command line options
*/
@@ -47,6 +49,8 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const
#endif
int num_options = 0;
int opt;
+ int flags = 0;
+
struct poptOption popt_options[] = {
POPT_AUTOHELP
{ "url", 'H', POPT_ARG_STRING, &options.url, 0, "database URL", "URL" },
@@ -194,29 +198,32 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const
goto failed;
}
- if (strcmp(ret->url, "NONE") != 0) {
- int flags = 0;
- if (options.nosync) {
- flags |= LDB_FLG_NOSYNC;
- }
+ if (strcmp(ret->url, "NONE") == 0) {
+ return ret;
+ }
-#ifdef _SAMBA_BUILD_
- /* Must be after we have processed command line options */
- gensec_init();
+ if (options.nosync) {
+ flags |= LDB_FLG_NOSYNC;
+ }
- if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) {
- goto failed;
- }
- if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) {
- goto failed;
- }
- ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+#ifdef _SAMBA_BUILD_
+ /* Must be after we have processed command line options */
+ gensec_init();
+
+ if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb))) {
+ goto failed;
+ }
+ if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) {
+ goto failed;
+ }
+ ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
#endif
- if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) {
- fprintf(stderr, "Failed to connect to %s - %s\n",
- ret->url, ldb_errstring(ldb));
- goto failed;
- }
+
+ /* now connect to the ldb */
+ if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) {
+ fprintf(stderr, "Failed to connect to %s - %s\n",
+ ret->url, ldb_errstring(ldb));
+ goto failed;
}
return ret;