From 924b3cc953182c4f72d6356b7209c4ccb5647fb1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 8 Aug 2005 22:29:44 +0000 Subject: r9218: make the winreg library code handle arbitrary paths more efficiently and more conveniently (caller doesn't need to know the hive names now) (This used to be commit dadd7e22fb439f7b18c429a95c75902e4741ba8d) --- source4/scripting/libjs/winreg.js | 54 +++++++++++++++++++++++++++------------ testprogs/ejs/winreg.js | 33 ++++++++++++++---------- 2 files changed, 58 insertions(+), 29 deletions(-) diff --git a/source4/scripting/libjs/winreg.js b/source4/scripting/libjs/winreg.js index 129cfe0898..703b8da2a7 100644 --- a/source4/scripting/libjs/winreg.js +++ b/source4/scripting/libjs/winreg.js @@ -42,29 +42,48 @@ function winreg_open_path(reg, path) var list = new Object(); list.length = 0; + + /* cope with a leading slash */ + if (components[0] == '') { + for (i=0;i<(components.length-1);i++) { + components[i] = components[i+1]; + } + components.length--; + } + if (components.length == 0) { + return undefined; + } + var handle = winreg_open_hive(reg, components[0]); if (handle == undefined) { return undefined; } - for (i=1;i"); - return -1; +if (options.ARGV.length < 1) { + println("Usage: winreg.js "); + return -1; } var binding = options.ARGV[0]; reg = winreg_init(); @@ -30,8 +30,8 @@ security_init(reg); print("Connecting to " + binding + "\n"); status = reg.connect(binding); if (status.is_ok != true) { - print("Failed to connect to " + binding + " - " + status.errstr + "\n"); - return -1; + print("Failed to connect to " + binding + " - " + status.errstr + "\n"); + return -1; } function list_path(path) { @@ -41,18 +41,25 @@ function list_path(path) { return; } for (i=0;i 1) { + root = options.ARGV[1]; +} else { + root = ''; } -print("All OK\n"); +printf("Listing registry tree '%s'\n", root); +list_path(root); return 0; -- cgit