summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorC. Davis <cd.rattan@gmail.com>2012-07-13 17:07:44 -0700
committerMichael Adam <obnox@samba.org>2013-04-29 13:05:49 +0200
commit632cefa1da3e0ecda5932420cc551d40faa245af (patch)
tree749a584badc6ac206dc92554489a0b714f25f5cb /source3/utils
parent89d3067c22406d943555fcc7c41e7d57ddfbb152 (diff)
downloadsamba-632cefa1da3e0ecda5932420cc551d40faa245af.tar.gz
samba-632cefa1da3e0ecda5932420cc551d40faa245af.tar.bz2
samba-632cefa1da3e0ecda5932420cc551d40faa245af.zip
regedit: Make all hives browsable.
Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/regedit.c63
1 files changed, 54 insertions, 9 deletions
diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c
index b088ea47cd..6e25897476 100644
--- a/source3/utils/regedit.c
+++ b/source3/utils/regedit.c
@@ -26,15 +26,61 @@
#include <ncurses.h>
#include <menu.h>
-/* test navigating HKLM hierarchy */
-static void display_test_window(TALLOC_CTX *mem_ctx, struct registry_context *ctx)
+/* load all available hives */
+static struct tree_node *load_hives(TALLOC_CTX *mem_ctx,
+ struct registry_context *ctx)
+{
+ const char *hives[] = {
+ "HKEY_CLASSES_ROOT",
+ "HKEY_CURRENT_USER",
+ "HKEY_LOCAL_MACHINE",
+ "HKEY_PERFORMANCE_DATA",
+ "HKEY_USERS",
+ "HKEY_CURRENT_CONFIG",
+ "HKEY_DYN_DATA",
+ "HKEY_PERFORMANCE_TEXT",
+ "HKEY_PERFORMANCE_NLSTEXT",
+ NULL
+ };
+ struct tree_node *root, *prev, *node;
+ struct registry_key *key;
+ WERROR rv;
+ size_t i;
+
+ root = NULL;
+ prev = NULL;
+
+ for (i = 0; hives[i] != NULL; ++i) {
+ rv = reg_get_predefined_key_by_name(ctx, hives[i], &key);
+ if (!W_ERROR_IS_OK(rv)) {
+ return root;
+ }
+
+ node = tree_node_new(mem_ctx, NULL, hives[i], key);
+ if (node == NULL) {
+ return NULL;
+ }
+
+ if (root == NULL) {
+ root = node;
+ }
+ if (prev) {
+ tree_node_append(prev, node);
+ }
+ prev = node;
+ }
+
+ return root;
+}
+
+/* test navigating available hives */
+static void display_test_window(TALLOC_CTX *mem_ctx,
+ struct registry_context *ctx)
{
WINDOW *tree_window;
struct tree_view *view;
struct tree_node *root, *node;
- struct registry_key *key;
int c;
- WERROR rv;
initscr();
start_color();
@@ -43,17 +89,16 @@ static void display_test_window(TALLOC_CTX *mem_ctx, struct registry_context *ct
keypad(stdscr, TRUE);
tree_window = newwin(25, 80, 0, 0);
+ SMB_ASSERT(tree_window != NULL);
keypad(tree_window, TRUE);
- rv = reg_get_predefined_key_by_name(ctx, "HKEY_LOCAL_MACHINE", &key);
- SMB_ASSERT(W_ERROR_IS_OK(rv));
-
- root = tree_node_new(mem_ctx, NULL, "HKEY_LOCAL_MACHINE", key);
+ root = load_hives(mem_ctx, ctx);
SMB_ASSERT(root != NULL);
view = tree_view_new(mem_ctx, root, tree_window, 15, 40, 3, 0);
- SMB_ASSERT(root != NULL);
+ SMB_ASSERT(view != NULL);
+
refresh();
tree_view_show(view);