Finish removal of iconv_convenience in public API's.
[bbaumbach/samba-autobuild/.git] / source4 / lib / registry / tools / regtree.c
index 19e4a010b4319a3ed5a0655d53633c0b50e9c393..68579406722dcfa7103a92938c8a6d008aea3c99 100644 (file)
  * @param fullpath Whether the full pat hshould be printed or just the last bit
  * @param novals Whether values should not be printed
  */
-static void print_tree(int level, struct registry_key *p,
+static void print_tree(unsigned int level, struct registry_key *p,
                       const char *name,
                       bool fullpath, bool novals)
 {
        struct registry_key *subkey;
-       const char *valuename;
-       const char *keyname;
-       uint32_t value_type;
-       DATA_BLOB value_data;
+       const char *valuename, *keyname;
+       uint32_t valuetype;
+       DATA_BLOB valuedata;
        struct security_descriptor *sec_desc;
        WERROR error;
-       int i;
+       unsigned int i;
        TALLOC_CTX *mem_ctx;
 
        for(i = 0; i < level; i++) putchar(' '); puts(name);
@@ -56,40 +55,38 @@ static void print_tree(int level, struct registry_key *p,
                                                                      &keyname,
                                                                      NULL,
                                                                      NULL)); i++) {
-               SMB_ASSERT(strlen(keyname) > 0);
+
+               SMB_ASSERT(strlen(keyname) > 0);
                if (!W_ERROR_IS_OK(reg_open_key(mem_ctx, p, keyname, &subkey)))
-                       continue;
+                       continue;
+
                print_tree(level+1, subkey, (fullpath && strlen(name))?
-                                               talloc_asprintf(mem_ctx, "%s\\%s",
-                                                               name, keyname):
-                                               keyname, fullpath, novals);
+                                               talloc_asprintf(mem_ctx, "%s\\%s",
+                                                               name, keyname):
+                                               keyname, fullpath, novals);
+               talloc_free(subkey);
        }
        talloc_free(mem_ctx);
 
        if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
-               DEBUG(0, ("Error occured while fetching subkeys for '%s': %s\n",
+               DEBUG(0, ("Error occurred while fetching subkeys for '%s': %s\n",
                                  name, win_errstr(error)));
        }
 
        if (!novals) {
                mem_ctx = talloc_init("print_tree");
-               for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(mem_ctx,
-                                                                           p,
-                                                                           i,
-                                                                           &valuename,
-                                                                           &value_type,
-                                                                           &value_data)); i++) {
-                       int j;
-                       char *desc;
+               for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(
+                       mem_ctx, p, i, &valuename, &valuetype, &valuedata));
+                       i++) {
+                       unsigned int j;
                        for(j = 0; j < level+1; j++) putchar(' ');
-                       desc = reg_val_description(mem_ctx, lp_iconv_convenience(cmdline_lp_ctx), valuename,
-                                                  value_type, value_data);
-                       printf("%s\n", desc);
+                       printf("%s\n",  reg_val_description(mem_ctx,
+                               valuename, valuetype, valuedata));
                }
                talloc_free(mem_ctx);
 
                if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
-                       DEBUG(0, ("Error occured while fetching values for '%s': %s\n",
+                       DEBUG(0, ("Error occurred while fetching values for '%s': %s\n",
                                name, win_errstr(error)));
                }
        }
@@ -103,13 +100,14 @@ static void print_tree(int level, struct registry_key *p,
 
 int main(int argc, char **argv)
 {
-       int opt, i;
+       int opt;
+       unsigned int i;
        const char *file = NULL;
        const char *remote = NULL;
        poptContext pc;
        struct registry_context *h = NULL;
        struct registry_key *start_key = NULL;
-       struct event_context *ev_ctx;
+       struct tevent_context *ev_ctx;
        WERROR error;
        bool fullpath = false, no_values = false;
        struct poptOption long_options[] = {