mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
r8320: make sure all our returned objects are full objects, which means they
have the toString() and valueOf() default attributes this allows all our returned objects to be used in logical expressions
This commit is contained in:
parent
333b32025f
commit
570f071b15
@ -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);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,14 @@
|
||||
#include "lib/ejs/ejs.h"
|
||||
#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
|
||||
*/
|
||||
@ -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)));
|
||||
|
@ -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)));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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] */
|
||||
|
Loading…
Reference in New Issue
Block a user