s4-ldb: make ldb tools line buffered
[ira/wip.git] / source4 / lib / ldb / tools / cmdline.c
index b6c1de3a4f2ac0307398c085b6a8ae62d5df85a3..f0cd0a3a60c3b93bac0934dc24abfd4ceca652e4 100644 (file)
@@ -44,6 +44,7 @@ static struct poptOption popt_options[] = {
        { "editor",    'e', POPT_ARG_STRING, &options.editor, 0, "external editor", "PROGRAM" },
        { "scope",     's', POPT_ARG_STRING, NULL, 's', "search scope", "SCOPE" },
        { "verbose",   'v', POPT_ARG_NONE, NULL, 'v', "increase verbosity", NULL },
+       { "trace",     0,   POPT_ARG_NONE, &options.tracing, 0, "enable tracing", NULL },
        { "interactive", 'i', POPT_ARG_NONE, &options.interactive, 0, "input from stdin", NULL },
        { "recursive", 'r', POPT_ARG_NONE, &options.recursive, 0, "recursive delete", NULL },
        { "modules-path", 0, POPT_ARG_STRING, &options.modules_path, 0, "modules path", "PATH" },
@@ -56,6 +57,7 @@ static struct poptOption popt_options[] = {
        { "output", 'O', POPT_ARG_STRING, &options.output, 0, "Output File", "Output" },
        { NULL,    'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" },
        { "controls", 0, POPT_ARG_STRING, NULL, 'c', "controls", NULL },
+       { "show-binary", 0, POPT_ARG_NONE, &options.show_binary, 0, "display binary LDIF", NULL },
 #if (_SAMBA_BUILD_ >= 4)
        POPT_COMMON_SAMBA
        POPT_COMMON_CREDENTIALS
@@ -97,6 +99,9 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
 
 #endif
 
+       /* make the ldb utilities line buffered */
+       setlinebuf(stdout);
+
        ret = talloc_zero(ldb, struct ldb_cmdline);
        if (ret == NULL) {
                fprintf(stderr, "Out of memory!\n");
@@ -215,11 +220,19 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
                flags |= LDB_FLG_NOSYNC;
        }
 
+       if (options.show_binary) {
+               flags |= LDB_FLG_SHOW_BINARY;
+       }
+
+       if (options.tracing) {
+               flags |= LDB_FLG_ENABLE_TRACING;
+       }
+
 #if (_SAMBA_BUILD_ >= 4)
        /* Must be after we have processed command line options */
        gensec_init(cmdline_lp_ctx); 
        
-       if (ldb_set_opaque(ldb, "sessionInfo", system_session(ldb, cmdline_lp_ctx))) {
+       if (ldb_set_opaque(ldb, "sessionInfo", system_session(cmdline_lp_ctx))) {
                goto failed;
        }
        if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) {