summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-06-04 03:32:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:33 -0500
commitb1243510793cd135f1464dcfeec0b7e88999d1a0 (patch)
tree960539c5792f72d5354cb03abc8b10a9f011dc8b
parent6ade5fc245a6f56b991b1b66742509270d65479d (diff)
downloadsamba-b1243510793cd135f1464dcfeec0b7e88999d1a0.tar.gz
samba-b1243510793cd135f1464dcfeec0b7e88999d1a0.tar.xz
samba-b1243510793cd135f1464dcfeec0b7e88999d1a0.zip
r7261: Pass by reference is done in js via MPR_TYPE_OBJECT. Update argument
parsing and example for resolveName(). (This used to be commit 1a4a54931733ebfa743401a184fe460c044427b4)
-rw-r--r--source4/scripting/ejs/smbcalls.c9
-rw-r--r--testprogs/ejs/resolveName.js11
2 files changed, 13 insertions, 7 deletions
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index 5d4c61b04b..93496bd9c9 100644
--- a/source4/scripting/ejs/smbcalls.c
+++ b/source4/scripting/ejs/smbcalls.c
@@ -271,6 +271,11 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv)
goto done;
}
+ if (argv[0]->type != MPR_TYPE_OBJECT) {
+ ejsSetErrorMsg(eid, "resolvename invalid arguments");
+ goto done;
+ }
+
if (argv[1]->type != MPR_TYPE_STRING) {
ejsSetErrorMsg(eid, "resolveName invalid arguments");
goto done;
@@ -291,8 +296,8 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv)
nt_status = resolve_name(&name, tmp_ctx, &reply_addr);
if (NT_STATUS_IS_OK(nt_status)) {
- mprDestroyAllVars(argv[0]);
- *argv[0] = mprCreateStringVar(reply_addr, True);
+ mprSetPropertyValue(argv[0], "value",
+ mprCreateStringVar(reply_addr, 1));
}
ejsSetReturnValue(eid, mprNTSTATUS(nt_status));
diff --git a/testprogs/ejs/resolveName.js b/testprogs/ejs/resolveName.js
index c2d06b5c74..1619b69d69 100644
--- a/testprogs/ejs/resolveName.js
+++ b/testprogs/ejs/resolveName.js
@@ -2,11 +2,12 @@
Demonstrate use of resolveName() js function
*/
-var result;
-res = resolveName(result, "frogurt");
+var result = new Object();
-if (!res.is_ok) {
- println(res.errstr);
+res = resolveName(result, ARGV[0]);
+
+if (res.is_ok) {
+ println(result.value);
} else {
- println(result);
+ println(res.errstr);
}