summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/scripting/bin/winreg13
-rw-r--r--source4/scripting/ejs/mprutil.c27
-rw-r--r--source4/scripting/ejs/smbcalls_data.c2
-rw-r--r--source4/scripting/ejs/smbcalls_samba3.c28
-rw-r--r--source4/scripting/ejs/smbcalls_string.c2
-rw-r--r--source4/scripting/ejs/smbcalls_sys.c2
-rw-r--r--source4/scripting/libjs/management.js3
-rw-r--r--source4/scripting/libjs/winreg.js13
8 files changed, 48 insertions, 42 deletions
diff --git a/source4/scripting/bin/winreg b/source4/scripting/bin/winreg
index ac6f9e61ba..2114394f45 100755
--- a/source4/scripting/bin/winreg
+++ b/source4/scripting/bin/winreg
@@ -61,13 +61,15 @@ function list_values(path) {
}
function list_path(path) {
+ var count = 0;
var list = reg.enum_path(path);
if (list == undefined) {
println("Unable to list " + path);
- return;
+ return 0;
}
var i;
list_values(path);
+ count = count + list.length;
for (i=0;i<list.length;i++) {
var npath;
if (path) {
@@ -76,8 +78,9 @@ function list_path(path) {
npath = list[i];
}
println(npath);
- list_path(npath);
+ count = count + list_path(npath);
}
+ return count;
}
var root;
@@ -95,6 +98,10 @@ if (options.createkey) {
}
} else {
printf("Listing registry tree '%s'\n", root);
- list_path(root);
+ var count = list_path(root);
+ if (count == 0) {
+ println("No entries found");
+ return 1;
+ }
}
return 0;
diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c
index 9634c9bf42..91683db6bd 100644
--- a/source4/scripting/ejs/mprutil.c
+++ b/source4/scripting/ejs/mprutil.c
@@ -33,6 +33,14 @@ struct MprVar mprObject(const char *name)
}
/*
+ return a empty mpr array
+*/
+struct MprVar mprArray(const char *name)
+{
+ return ejsCreateArray(name && *name?name:"(NULL)", 0);
+}
+
+/*
find a mpr component, allowing for sub objects, using the '.' convention
*/
NTSTATUS mprGetVar(struct MprVar **v, const char *name)
@@ -101,7 +109,6 @@ struct MprVar mprObject(const char *name)
char idx[16];
mprItoa(i, idx, sizeof(idx));
mprSetVar(var, idx, v);
- mprSetVar(var, "length", mprCreateIntegerVar(i+1));
}
/*
@@ -112,13 +119,10 @@ struct MprVar mprList(const char *name, const char **list)
struct MprVar var;
int i;
- var = mprObject(name);
+ var = mprArray(name);
for (i=0;list && list[i];i++) {
mprAddArray(&var, i, mprString(list[i]));
}
- if (i==0) {
- mprSetVar(&var, "length", mprCreateIntegerVar(i));
- }
return var;
}
@@ -182,7 +186,7 @@ static struct MprVar mprLdbMessage(struct ldb_context *ldb, struct ldb_message *
val = mprData(v.data, v.length);
} else {
int j;
- val = mprObject(el->name);
+ val = mprArray(el->name);
for (j=0;j<el->num_values;j++) {
if (attr->ldif_write_fn(ldb, msg,
&el->values[j], &v) != 0) {
@@ -214,13 +218,10 @@ struct MprVar mprLdbArray(struct ldb_context *ldb,
struct MprVar res;
int i;
- res = mprObject(name);
+ res = mprArray(name);
for (i=0;i<count;i++) {
mprAddArray(&res, i, mprLdbMessage(ldb, msg[i]));
}
- if (i==0) {
- mprSetVar(&res, "length", mprCreateIntegerVar(0));
- }
return res;
}
@@ -230,6 +231,9 @@ struct MprVar mprLdbArray(struct ldb_context *ldb,
*/
const char *mprToString(const struct MprVar *v)
{
+ if (v->trigger) {
+ mprReadProperty(v, 0);
+ }
if (!mprVarIsString(v->type)) return NULL;
return v->string;
}
@@ -239,6 +243,9 @@ const char *mprToString(const struct MprVar *v)
*/
int mprToInt(const struct MprVar *v)
{
+ if (v->trigger) {
+ mprReadProperty(v, 0);
+ }
if (!mprVarIsNumber(v->type)) return 0;
return mprVarToNumber(v);
}
diff --git a/source4/scripting/ejs/smbcalls_data.c b/source4/scripting/ejs/smbcalls_data.c
index 4859de94d7..54e496ea57 100644
--- a/source4/scripting/ejs/smbcalls_data.c
+++ b/source4/scripting/ejs/smbcalls_data.c
@@ -88,7 +88,7 @@ static int ejs_blobToArray(MprVarHandle eid, int argc, struct MprVar **argv)
goto failed;
}
- array = mprObject("array");
+ array = mprArray("array");
for (i=0;i<blob->length;i++) {
mprAddArray(&array, i, mprCreateNumberVar(blob->data[i]));
diff --git a/source4/scripting/ejs/smbcalls_samba3.c b/source4/scripting/ejs/smbcalls_samba3.c
index 4a4977be60..0a05e4584f 100644
--- a/source4/scripting/ejs/smbcalls_samba3.c
+++ b/source4/scripting/ejs/smbcalls_samba3.c
@@ -31,14 +31,14 @@ static struct MprVar mprRegistry(struct samba3_regdb *reg)
struct MprVar mpv = mprObject("registry"), ks, vs, k, v;
int i, j;
- ks = mprObject("array");
+ ks = mprArray("array");
for (i = 0; i < reg->key_count; i++) {
k = mprObject("regkey");
mprSetVar(&k, "name", mprString(reg->keys[i].name));
- vs = mprObject("array");
+ vs = mprArray("array");
for (j = 0; j < reg->keys[i].value_count; j++) {
v = mprObject("regval");
@@ -90,7 +90,7 @@ static struct MprVar mprIdmapDb(struct samba3_idmapdb *db)
mprSetVar(&mpv, "user_hwm", mprCreateIntegerVar(db->user_hwm));
mprSetVar(&mpv, "group_hwm", mprCreateIntegerVar(db->group_hwm));
- mps = mprObject("array");
+ mps = mprArray("array");
for (i = 0; i < db->mapping_count; i++) {
char *tmp;
@@ -120,7 +120,7 @@ static struct MprVar mprIdmapDb(struct samba3_idmapdb *db)
static struct MprVar mprGroupMappings(struct samba3_groupdb *db)
{
- struct MprVar mpv = mprObject("array"), g;
+ struct MprVar mpv = mprArray("array"), g;
int i;
for (i = 0; i < db->groupmap_count; i++) {
@@ -161,7 +161,7 @@ static struct MprVar mprAliases(struct samba3_groupdb *db)
mprSetVar(&a, "sid", mprString(tmp));
talloc_free(tmp);
- am = mprObject("array");
+ am = mprArray("array");
for (j = 0; j < db->aliases[i].member_count; j++) {
tmp = dom_sid_string(NULL, db->aliases[i].members[j]);
@@ -218,7 +218,7 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
struct MprVar mpv = mprObject("samba3_secrets"), es, e;
int i;
- es = mprObject("array");
+ es = mprArray("array");
for (i = 0; i < sec->ldappw_count; i++) {
e = mprObject("ldappw");
@@ -231,7 +231,7 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprSetVar(&mpv, "ldappws", es);
- es = mprObject("array");
+ es = mprArray("array");
for (i = 0; i < sec->domain_count; i++) {
mprAddArray(&es, i, mprDomainSecrets(&sec->domains[i]));
@@ -243,7 +243,7 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprSetVar(&mpv, "domains", es);
- es = mprObject("trusted_domains");
+ es = mprArray("trusted_domains");
for (i = 0; i < sec->trusted_domain_count; i++) {
struct MprVar ns;
@@ -251,7 +251,7 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
int j;
e = mprObject("trusted_domain");
- ns = mprObject("array");
+ ns = mprArray("array");
for (j = 0; j < sec->trusted_domains[i].uni_name_len; j++) {
mprAddArray(&ns, j, mprString(sec->trusted_domains[i].uni_name[j]));
@@ -275,7 +275,7 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprSetVar(&mpv, "trusted_domains", es);
- es = mprObject("array");
+ es = mprArray("array");
for (i = 0; i < sec->afs_keyfile_count; i++) {
struct MprVar ks;
@@ -284,7 +284,7 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprSetVar(&e, "cell", mprString(sec->afs_keyfiles[i].cell));
- ks = mprObject("array");
+ ks = mprArray("array");
for (j = 0; j < 8; j++) {
struct MprVar k = mprObject("entry");
@@ -318,7 +318,7 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
static struct MprVar mprShares(struct samba3 *samba3)
{
- struct MprVar mpv = mprObject("array"), s;
+ struct MprVar mpv = mprArray("array"), s;
int i;
for (i = 0; i < samba3->share_count; i++) {
@@ -340,7 +340,7 @@ static struct MprVar mprShares(struct samba3 *samba3)
static struct MprVar mprSamAccounts(struct samba3 *samba3)
{
- struct MprVar mpv = mprObject("array"), m;
+ struct MprVar mpv = mprArray("array"), m;
int i;
for (i = 0; i < samba3->samaccount_count; i++) {
@@ -391,7 +391,7 @@ static struct MprVar mprSamAccounts(struct samba3 *samba3)
static struct MprVar mprWinsEntries(struct samba3 *samba3)
{
- struct MprVar mpv = mprObject("array");
+ struct MprVar mpv = mprArray("array");
int i, j;
for (i = 0; i < samba3->winsdb_count; i++) {
diff --git a/source4/scripting/ejs/smbcalls_string.c b/source4/scripting/ejs/smbcalls_string.c
index 5976e42251..e9e6e148d1 100644
--- a/source4/scripting/ejs/smbcalls_string.c
+++ b/source4/scripting/ejs/smbcalls_string.c
@@ -109,7 +109,7 @@ static int ejs_split(MprVarHandle eid, int argc, char **argv)
separator = argv[0];
s = argv[1];
- ret = mprObject("list");
+ ret = mprArray("list");
while ((p = strstr(s, separator))) {
char *s2 = talloc_strndup(tmp_ctx, s, (int)(p-s));
diff --git a/source4/scripting/ejs/smbcalls_sys.c b/source4/scripting/ejs/smbcalls_sys.c
index f39d5cbddc..1a876c9e87 100644
--- a/source4/scripting/ejs/smbcalls_sys.c
+++ b/source4/scripting/ejs/smbcalls_sys.c
@@ -32,7 +32,7 @@
static int ejs_sys_interfaces(MprVarHandle eid, int argc, struct MprVar **argv)
{
int i, count = iface_count();
- struct MprVar ret = mprObject("interfaces");
+ struct MprVar ret = mprArray("interfaces");
for (i=0;i<count;i++) {
mprAddArray(&ret, i, mprString(iface_n_ip(i)));
}
diff --git a/source4/scripting/libjs/management.js b/source4/scripting/libjs/management.js
index 26c1c0a34a..1258368e90 100644
--- a/source4/scripting/libjs/management.js
+++ b/source4/scripting/libjs/management.js
@@ -24,7 +24,7 @@ function smbsrv_sessions()
}
/* gather the results into a single array */
- var i, count=0, ret = new Object();
+ var i, count=0, ret = new Array(0);
for (i=0;i<io.results.length;i++) {
var sessions = io.results[i].info.sessions.sessions;
var j;
@@ -33,7 +33,6 @@ function smbsrv_sessions()
count++;
}
}
- ret.length = count;
return ret;
}
diff --git a/source4/scripting/libjs/winreg.js b/source4/scripting/libjs/winreg.js
index 63435ac22b..3b05f89c93 100644
--- a/source4/scripting/libjs/winreg.js
+++ b/source4/scripting/libjs/winreg.js
@@ -51,16 +51,13 @@ function __winreg_open_path(path)
{
var s = string_init();
var i, components = s.split('\\', 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--;
+ delete(components[i]);
}
if (components.length == 0) {
@@ -108,8 +105,7 @@ function __winreg_open_path(path)
*/
function __winreg_enum_path(path)
{
- var list = new Object();
- list.length = 0;
+ var list = new Array(0);
if (path == null || path == "\\" || path == "") {
return new Array("HKLM", "HKU");
@@ -155,7 +151,6 @@ function __winreg_enum_path(path)
return list;
}
list[list.length] = out.name.name;
- list.length++;
}
this.close(handle);
@@ -174,8 +169,7 @@ function __winreg_enum_path(path)
function __winreg_enum_values(path)
{
var data = datablob_init();
- var list = new Object();
- list.length = 0;
+ var list = new Array(0);
var handle = this.open_path(path);
if (handle == undefined) {
@@ -224,7 +218,6 @@ function __winreg_enum_values(path)
el.value = data.regToVar(el.rawvalue, el.type);
el.size = out.size;
list[list.length] = el;
- list.length++;
}
this.close(handle);