Registry tools "regshell" and "regtree": Small fixup's
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Sat, 13 Sep 2008 10:26:03 +0000 (12:26 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 21 Sep 2008 21:17:59 +0000 (23:17 +0200)
I fixed up my fault regarding the handling of the default value (if it doesn't exist
it hasn't the index number zero and you get immediately the subvalues). Then I corrected an error in regshell to find the right registry context.

source4/lib/registry/tools/regshell.c
source4/lib/registry/tools/regtree.c

index fb7a08e38f8a47dd6ad7ecce7bd385ea73dc4451..208b19fba88e1f7677fb1a3339b60485133d2df9 100644 (file)
@@ -226,13 +226,7 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv)
                return error;
        }
 
-       /* default value */
-       if (W_ERROR_IS_OK(reg_key_get_value_by_index(ctx, ctx->current, 0,
-               &name, &valuetype, &valuedata)))
-               printf("V \"(Default)\" %s %s\n", str_regtype(valuetype),
-                          reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), valuetype, valuedata));
-       /* other values */
-       for (i = 1; W_ERROR_IS_OK(error = reg_key_get_value_by_index(ctx,
+       for (i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(ctx,
                ctx->current, i, &name, &valuetype, &valuedata)); i++)
                printf("V \"%s\" %s %s\n", name, str_regtype(valuetype),
                           reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), valuetype, valuedata));
@@ -440,7 +434,7 @@ static char **reg_complete_key(const char *text, int start, int end)
        len = strlen(text);
        for(i = 0; j < MAX_COMPLETIONS-1; i++) {
                status = reg_key_get_subkey_by_index(mem_ctx, base, i,
-                                                    &subkeyname, NULL, NULL);
+                                            &subkeyname, NULL, NULL);
                if(W_ERROR_IS_OK(status)) {
                        if(!strncmp(text, subkeyname, len)) {
                                matches[j] = strdup(subkeyname);
@@ -538,7 +532,8 @@ int main(int argc, char **argv)
        if (ctx->current == NULL) {
                int i;
 
-               for (i = 0; reg_predefined_keys[i].handle; i++) {
+               for (i = 0; (reg_predefined_keys[i].handle != 0) &&
+                       (ctx->current == NULL); i++) {
                        WERROR err;
                        err = reg_get_predefined_key(ctx->registry,
                                                     reg_predefined_keys[i].handle,
index 17a9163adc61f3ec3fe70ff560b2928a60b0fa33..2175f9c9d3432cefbede8c34318200ffcdb1bbfb 100644 (file)
@@ -38,8 +38,7 @@ static void print_tree(int level, struct registry_key *p,
                       bool fullpath, bool novals)
 {
        struct registry_key *subkey;
-       const char *valuename;
-       const char *keyname;
+       const char *valuename, *keyname;
        uint32_t valuetype;
        DATA_BLOB valuedata;
        struct security_descriptor *sec_desc;
@@ -73,17 +72,7 @@ static void print_tree(int level, struct registry_key *p,
 
        if (!novals) {
                mem_ctx = talloc_init("print_tree");
-               /* default value */
-               if (W_ERROR_IS_OK(reg_key_get_value_by_index(mem_ctx, p, 0,
-                       &valuename, &valuetype, &valuedata))) {
-                       int j;
-                       for(j = 0; j < level+1; j++) putchar(' ');
-                       printf("%s\n",  reg_val_description(mem_ctx,
-                               lp_iconv_convenience(cmdline_lp_ctx),
-                               "(Default)", valuetype, valuedata));
-               }
-               /* other values */
-               for(i = 1; W_ERROR_IS_OK(error = reg_key_get_value_by_index(
+               for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(
                        mem_ctx, p, i, &valuename, &valuetype, &valuedata));
                        i++) {
                        int j;