summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-06-04 01:08:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:32 -0500
commit383c5fb68a212eed60750793ad4b7e4bbcbcd2d5 (patch)
treea32f6224a153dc20b4ec1c4394a44226216128fe /source4
parent384ad5c71b012d11e61d5a9ad8059423f771cccb (diff)
downloadsamba-383c5fb68a212eed60750793ad4b7e4bbcbcd2d5.tar.gz
samba-383c5fb68a212eed60750793ad4b7e4bbcbcd2d5.tar.bz2
samba-383c5fb68a212eed60750793ad4b7e4bbcbcd2d5.zip
r7255: Change syntax of resolveName() js function to be more like the
resolve_name() C function. I can't figure out how to return variables by reference though. Writing to argv[] doesn't seem to work. (This used to be commit aef99859f28570b60f4fefe2981160269f6eb02a)
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/ejs/smbcalls.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index 8a02111bd5..5d4c61b04b 100644
--- a/source4/scripting/ejs/smbcalls.c
+++ b/source4/scripting/ejs/smbcalls.c
@@ -253,50 +253,53 @@ failed:
look up a netbios name
syntax:
- resolveName("frogurt");
- resolveName("frogurt", 0x1c);
+ resolveName(result, "frogurt");
+ resolveName(result, "frogurt", 0x1c);
*/
static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv)
{
+ int result = -1;
struct nbt_name name;
TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx());
- NTSTATUS result;
+ NTSTATUS nt_status;
const char *reply_addr;
/* validate arguments */
- if (argc == 1) {
- if (argv[0]->type != MPR_TYPE_STRING) {
- ejsSetErrorMsg(eid, "resolveName invalid arguments");
- goto failed;
- }
- make_nbt_name_client(&name, mprToString(argv[0]));
- } else if (argc == 2) {
+ if (argc < 2 || argc > 3) {
+ ejsSetErrorMsg(eid, "resolveName invalid arguments");
+ goto done;
+ }
+
+ if (argv[1]->type != MPR_TYPE_STRING) {
+ ejsSetErrorMsg(eid, "resolveName invalid arguments");
+ goto done;
+ }
+
+ if (argc == 2) {
+ make_nbt_name_client(&name, mprToString(argv[1]));
+ } else {
if (argv[1]->type != MPR_TYPE_INT) {
ejsSetErrorMsg(eid, "resolveName invalid arguments");
- goto failed;
+ goto done;
}
- make_nbt_name(&name, mprToString(argv[0]), mprToInt(argv[1]));
- } else {
- ejsSetErrorMsg(eid, "resolveName invalid arguments");
- goto failed;
+ make_nbt_name(&name, mprToString(argv[1]), mprToInt(argv[2]));
}
- result = resolve_name(&name, tmp_ctx, &reply_addr);
+ result = 0;
- if (!NT_STATUS_IS_OK(result)) {
- ejsSetErrorMsg(eid, "resolveName name not found");
- goto failed;
+ 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);
}
-
- ejsSetReturnString(eid, reply_addr);
- talloc_free(tmp_ctx);
- return 0;
+ ejsSetReturnValue(eid, mprNTSTATUS(nt_status));
- failed:
+ done:
talloc_free(tmp_ctx);
- return -1;
+ return result;
}
static int ejs_userAuth(MprVarHandle eid, int argc, char **argv)
@@ -308,7 +311,6 @@ static int ejs_userAuth(MprVarHandle eid, int argc, char **argv)
struct MprVar auth;
NTSTATUS nt_status;
DATA_BLOB pw_blob;
- int ret;
if (argc != 3 || *argv[0] == 0 || *argv[2] == 0) {
ejsSetErrorMsg(eid, "userAuth invalid arguments");