summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/ejsrpc.c2
-rw-r--r--source4/scripting/ejs/mprutil.c23
-rw-r--r--source4/scripting/ejs/smbcalls.c2
-rw-r--r--source4/scripting/ejs/smbcalls_auth.c4
-rw-r--r--source4/scripting/ejs/smbcalls_cli.c2
-rw-r--r--source4/scripting/ejs/smbcalls_nss.c4
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c2
7 files changed, 23 insertions, 16 deletions
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c
index 8b6bc328dd..57e0a8f690 100644
--- a/source4/scripting/ejs/ejsrpc.c
+++ b/source4/scripting/ejs/ejsrpc.c
@@ -58,7 +58,7 @@ NTSTATUS ejs_pull_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const cha
*/
NTSTATUS ejs_push_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name)
{
- NDR_CHECK(mprSetVar(*v, name, mprCreateObjVar(name, MPR_DEFAULT_HASH_SIZE)));
+ NDR_CHECK(mprSetVar(*v, name, mprObject(name)));
return mprGetVar(v, name);
}
diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c
index a9cf71b15d..40ca050a96 100644
--- a/source4/scripting/ejs/mprutil.c
+++ b/source4/scripting/ejs/mprutil.c
@@ -25,6 +25,14 @@
#include "lib/ldb/include/ldb.h"
/*
+ return a default mpr object
+*/
+struct MprVar mprObject(const char *name)
+{
+ return ejsCreateObj(name?name:"(NULL)", MPR_DEFAULT_HASH_SIZE);
+}
+
+/*
find a mpr component, allowing for sub objects, using the '.' convention
*/
NTSTATUS mprGetVar(struct MprVar **v, const char *name)
@@ -75,7 +83,7 @@
}
v2 = mprGetProperty(v, objname, NULL);
if (v2 == NULL) {
- mprSetVar(v, objname, mprCreateObjVar(objname, MPR_DEFAULT_HASH_SIZE));
+ mprSetVar(v, objname, mprObject(objname));
v2 = mprGetProperty(v, objname, NULL);
}
status = mprSetVar(v2, p+1, val);
@@ -104,7 +112,7 @@ struct MprVar mprList(const char *name, const char **list)
struct MprVar var;
int i;
- var = mprCreateObjVar(name, MPR_DEFAULT_HASH_SIZE);
+ var = mprObject(name);
for (i=0;list && list[i];i++) {
mprAddArray(&var, i, mprCreateStringVar(list[i], 1));
}
@@ -119,7 +127,6 @@ struct MprVar mprList(const char *name, const char **list)
*/
struct MprVar mprString(const char *s)
{
- struct MprVar var;
if (s == NULL) {
return mprCreatePtrVar(NULL, "NULL");
}
@@ -154,7 +161,7 @@ struct MprVar mprLdbMessage(struct ldb_message *msg)
const char *multivalued[] = { "objectClass", "memberOf", "privilege",
"member", NULL };
- var = mprCreateObjVar(msg->dn, MPR_DEFAULT_HASH_SIZE);
+ var = mprObject(msg->dn);
for (i=0;i<msg->num_elements;i++) {
struct ldb_message_element *el = &msg->elements[i];
@@ -164,7 +171,7 @@ struct MprVar mprLdbMessage(struct ldb_message *msg)
val = mprData(el->values[0].data, el->values[0].length);
} else {
int j;
- val = mprCreateObjVar(el->name, MPR_DEFAULT_HASH_SIZE);
+ val = mprObject(el->name);
for (j=0;j<el->num_values;j++) {
mprAddArray(&val, j,
mprData(el->values[j].data,
@@ -191,7 +198,7 @@ struct MprVar mprLdbArray(struct ldb_message **msg, int count, const char *name)
struct MprVar res;
int i;
- res = mprCreateObjVar(name?name:"(NULL)", MPR_DEFAULT_HASH_SIZE);
+ res = mprObject(name);
for (i=0;i<count;i++) {
mprAddArray(&res, i, mprLdbMessage(msg[i]));
}
@@ -249,7 +256,7 @@ struct MprVar mprNTSTATUS(NTSTATUS status)
{
struct MprVar res;
- res = mprCreateObjVar("ntstatus", MPR_DEFAULT_HASH_SIZE);
+ res = mprObject("ntstatus");
mprSetVar(&res, "errstr", mprCreateStringVar(nt_errstr(status), 1));
mprSetVar(&res, "v", mprCreateIntegerVar(NT_STATUS_V(status)));
@@ -266,7 +273,7 @@ struct MprVar mprWERROR(WERROR status)
{
struct MprVar res;
- res = mprCreateObjVar("werror", MPR_DEFAULT_HASH_SIZE);
+ res = mprObject("werror");
mprSetVar(&res, "errstr", mprCreateStringVar(win_errstr(status), 1));
mprSetVar(&res, "v", mprCreateIntegerVar(W_ERROR_V(status)));
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index 5972518036..2da1e8c669 100644
--- a/source4/scripting/ejs/smbcalls.c
+++ b/source4/scripting/ejs/smbcalls.c
@@ -70,7 +70,7 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv)
static int ejs_IfaceList(MprVarHandle eid, int argc, struct MprVar **argv)
{
int i, count = iface_count();
- struct MprVar ret = mprCreateObjVar("interfaces", MPR_DEFAULT_HASH_SIZE);
+ struct MprVar ret = mprObject("interfaces");
for (i=0;i<count;i++) {
mprAddArray(&ret, i, mprString(iface_n_ip(i)));
}
diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c
index 8e72f68fc1..089d4b6bea 100644
--- a/source4/scripting/ejs/smbcalls_auth.c
+++ b/source4/scripting/ejs/smbcalls_auth.c
@@ -101,7 +101,7 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
remote_host = mprToString(mprGetProperty(argv[0], "rhost", NULL));
tmp_ctx = talloc_new(mprMemCtx());
- auth = mprCreateObjVar("auth", MPR_DEFAULT_HASH_SIZE);
+ auth = mprObject("auth");
if (domain && strcmp("System User", domain) == 0) {
@@ -126,7 +126,7 @@ static int ejs_domain_list(MprVarHandle eid, int argc, char **argv)
return -1;
}
- list = mprCreateObjVar("list", MPR_DEFAULT_HASH_SIZE);
+ list = mprObject("list");
mprSetVar(&list, "0", mprCreateStringVar("System User", 1));
mpr_Return(eid, list);
diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c
index 8d00b80362..c5611d555d 100644
--- a/source4/scripting/ejs/smbcalls_cli.c
+++ b/source4/scripting/ejs/smbcalls_cli.c
@@ -674,7 +674,7 @@ static int ejs_list(MprVarHandle eid, int argc, MprVar **argv)
attribute = mprVarToInteger(argv[2]);
- result = mprCreateObjVar("list", MPR_DEFAULT_HASH_SIZE);
+ result = mprObject("list");
smbcli_list(tree, mask, attribute, ejs_list_helper, &result);
diff --git a/source4/scripting/ejs/smbcalls_nss.c b/source4/scripting/ejs/smbcalls_nss.c
index 1eef1eff79..abbf6cf10f 100644
--- a/source4/scripting/ejs/smbcalls_nss.c
+++ b/source4/scripting/ejs/smbcalls_nss.c
@@ -35,7 +35,7 @@ static struct MprVar mpr_passwd(struct passwd *pwd)
if (pwd == NULL) {
return mprCreateUndefinedVar();
}
- ret = mprCreateObjVar("passwd", MPR_DEFAULT_HASH_SIZE);
+ ret = mprObject("passwd");
mprSetVar(&ret, "pw_name", mprString(pwd->pw_name));
mprSetVar(&ret, "pw_passwd", mprString(pwd->pw_passwd));
@@ -56,7 +56,7 @@ static struct MprVar mpr_group(struct group *grp)
if (grp == NULL) {
return mprCreateUndefinedVar();
}
- ret = mprCreateObjVar("group", MPR_DEFAULT_HASH_SIZE);
+ ret = mprObject("group");
mprSetVar(&ret, "gr_name", mprString(grp->gr_name));
mprSetVar(&ret, "gr_passwd", mprString(grp->gr_passwd));
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index bb05eda426..53f7bc2e55 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -227,7 +227,7 @@ static int ejs_irpc_call(int eid, struct MprVar *conn, struct MprVar *io,
talloc_steal(reqs, reqs[i]);
}
- mprSetVar(io, "results", mprCreateObjVar("results", MPR_DEFAULT_HASH_SIZE));
+ mprSetVar(io, "results", mprObject("results"));
results = mprGetProperty(io, "results", NULL);
/* and receive the results, placing them in io.results[i] */