Fix up the "reg_common_open_remote" call
[ira/wip.git] / source4 / lib / registry / tools / regshell.c
index d5c506ab31d915655d29205d2a44d9252040522d..98f7f02c38cec5e3340ddc5bfcd956640c6df2d7 100644 (file)
@@ -141,7 +141,8 @@ static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv)
                return WERR_INVALID_PARAM;
        }
 
-       if (!reg_string_to_val(ctx, argv[2], argv[3], &val.data_type,
+       if (!reg_string_to_val(ctx, lp_iconv_convenience(cmdline_lp_ctx), 
+                              argv[2], argv[3], &val.data_type,
                               &val.data)) {
                fprintf(stderr, "Unable to interpret data\n");
                return WERR_INVALID_PARAM;
@@ -161,9 +162,7 @@ static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv)
        struct registry_key *new = NULL;
        WERROR error;
 
-       if(argc < 2) {
-               new = ctx->current;
-       } else {
+       if(argc == 2) {
                error = reg_open_key(ctx->registry, ctx->current, argv[1],
                                     &new);
                if(!W_ERROR_IS_OK(error)) {
@@ -171,11 +170,11 @@ static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv)
                                win_errstr(error)));
                        return error;
                }
-       }
 
-       ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]);
-       printf("Current path is: %s\n", ctx->path);
-       ctx->current = new;
+               ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]);
+               ctx->current = new;
+       }
+       printf("New path is: %s\n", ctx->path);
 
        return WERR_OK;
 }
@@ -187,7 +186,7 @@ static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv)
        WERROR error;
 
        if (argc != 2) {
-               fprintf(stderr, "Usage: print <valuename>");
+               fprintf(stderr, "Usage: print <valuename>\n");
                return WERR_INVALID_PARAM;
        }
 
@@ -199,7 +198,7 @@ static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv)
        }
 
        printf("%s\n%s\n", str_regtype(value_type),
-                  reg_val_data_string(ctx, value_type, value_data));
+                  reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), value_type, value_data));
 
        return WERR_OK;
 }
@@ -233,7 +232,7 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv)
                                                                     &data_type,
                                                                     &data)); i++) {
                printf("V \"%s\" %s %s\n", name, str_regtype(data_type),
-                          reg_val_data_string(ctx, data_type, data));
+                          reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), data_type, data));
        }
 
        return WERR_OK;
@@ -497,6 +496,7 @@ int main(int argc, char **argv)
        poptContext pc;
        const char *remote = NULL;
        struct regshell_context *ctx;
+       struct event_context *ev_ctx;
        bool ret = true;
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -515,17 +515,19 @@ int main(int argc, char **argv)
 
        ctx = talloc_zero(NULL, struct regshell_context);
 
+       ev_ctx = s4_event_context_init(ctx);
+
        if (remote != NULL) {
-               ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx, 
-                                                      cmdline_credentials);
+               ctx->registry = reg_common_open_remote(remote, ev_ctx,
+                                        cmdline_lp_ctx, cmdline_credentials);
        } else if (file != NULL) {
-               ctx->current = reg_common_open_file(file, cmdline_lp_ctx, cmdline_credentials);
+               ctx->current = reg_common_open_file(file, ev_ctx, cmdline_lp_ctx, cmdline_credentials);
                if (ctx->current == NULL)
                        return 1;
                ctx->registry = ctx->current->context;
                ctx->path = talloc_strdup(ctx, "");
        } else {
-               ctx->registry = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx);
+               ctx->registry = reg_common_open_local(cmdline_credentials, ev_ctx, cmdline_lp_ctx);
        }
 
        if (ctx->registry == NULL)