summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-07 08:20:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:19 -0500
commitf44b9ae3e6e7d37020d4e644862772428b3a68ae (patch)
treeb453e266aea2c39619fe008e75c242cd3bb370bf /source4/scripting/ejs
parent3c2dc30b3ee719ceb7846f975b83a79c9cb1a9d7 (diff)
downloadsamba-f44b9ae3e6e7d37020d4e644862772428b3a68ae.tar.gz
samba-f44b9ae3e6e7d37020d4e644862772428b3a68ae.tar.bz2
samba-f44b9ae3e6e7d37020d4e644862772428b3a68ae.zip
r8198: - handled push/pull of simple strings in ejs
- improved the error handling, so the ejs wrappers don't just ignore a type they don't handle, instead an exception is issued saying what isn't handled (This used to be commit a77c2aa8606ad668f6a513211a1d9e7d6193d741)
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/ejsrpc.c47
-rw-r--r--source4/scripting/ejs/ejsrpc.h14
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c4
3 files changed, 56 insertions, 9 deletions
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c
index 4984518c7f..75f748f146 100644
--- a/source4/scripting/ejs/ejsrpc.c
+++ b/source4/scripting/ejs/ejsrpc.c
@@ -24,21 +24,38 @@
#include "lib/ejs/ejs.h"
#include "scripting/ejs/ejsrpc.h"
-NTSTATUS ejs_pull_rpc(struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull)
+NTSTATUS ejs_pull_rpc(int eid, const char *callname,
+ struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull)
{
- struct ejs_rpc *ejs = talloc(ptr, struct ejs_rpc);
+ struct ejs_rpc *ejs = talloc(ptr, struct ejs_rpc);
+ NT_STATUS_HAVE_NO_MEMORY(ejs);
+ ejs->eid = eid;
+ ejs->callname = callname;
return ejs_pull(ejs, v, ptr);
}
-NTSTATUS ejs_push_rpc(struct MprVar *v, const void *ptr, ejs_push_function_t ejs_push)
+NTSTATUS ejs_push_rpc(int eid, const char *callname,
+ struct MprVar *v, const void *ptr, ejs_push_function_t ejs_push)
{
struct ejs_rpc *ejs = talloc(ptr, struct ejs_rpc);
+ NT_STATUS_HAVE_NO_MEMORY(ejs);
+ ejs->eid = eid;
+ ejs->callname = callname;
return ejs_push(ejs, v, ptr);
}
/*
+ panic in the ejs wrapper code
+ */
+NTSTATUS ejs_panic(struct ejs_rpc *ejs, const char *why)
+{
+ ejsSetErrorMsg(ejs->eid, "rpc_call '%s' failed - %s", ejs->callname, why);
+ return NT_STATUS_INTERNAL_ERROR;
+}
+
+/*
find a mpr component, allowing for sub objects, using the '.' convention
*/
static struct MprVar *mprGetVar(struct MprVar *v, const char *name)
@@ -279,3 +296,27 @@ NTSTATUS ejs_push_array(struct ejs_rpc *ejs,
return mprSetVar(v, "length", mprCreateIntegerVar(i));
}
+
+/*
+ pull a string
+*/
+NTSTATUS ejs_pull_string(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const char **s)
+{
+ struct MprVar *var;
+ var = mprGetVar(v, name);
+ if (var == NULL) {
+ return NT_STATUS_INVALID_PARAMETER_MIX;
+ }
+ *s = mprToString(var);
+ return NT_STATUS_OK;
+}
+
+/*
+ push a string
+*/
+NTSTATUS ejs_push_string(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const char *s)
+{
+ return mprSetVar(v, name, mprCreateStringVar(s, True));
+}
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
index 1febb90ad6..5fb6ace863 100644
--- a/source4/scripting/ejs/ejsrpc.h
+++ b/source4/scripting/ejs/ejsrpc.h
@@ -21,7 +21,8 @@
*/
struct ejs_rpc {
-
+ int eid;
+ const char *callname;
};
typedef NTSTATUS (*ejs_pull_t)(struct ejs_rpc *, struct MprVar *, const char *, void *);
@@ -29,11 +30,13 @@ typedef NTSTATUS (*ejs_push_t)(struct ejs_rpc *, struct MprVar *, const char *,
typedef NTSTATUS (*ejs_pull_function_t)(struct ejs_rpc *, struct MprVar *, void *);
typedef NTSTATUS (*ejs_push_function_t)(struct ejs_rpc *, struct MprVar *, const void *);
+NTSTATUS ejs_panic(struct ejs_rpc *ejs, const char *why);
+
int ejs_rpc_call(int eid, int argc, struct MprVar **argv, const char *callname,
ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push);
-NTSTATUS ejs_pull_rpc(struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull);
-NTSTATUS ejs_push_rpc(struct MprVar *v, const void *ptr, ejs_push_function_t ejs_push);
+NTSTATUS ejs_pull_rpc(int eid, const char *callname, struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull);
+NTSTATUS ejs_push_rpc(int eid, const char *callname, struct MprVar *v, const void *ptr, ejs_push_function_t ejs_push);
NTSTATUS ejs_pull_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name);
NTSTATUS ejs_push_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name);
@@ -63,4 +66,7 @@ NTSTATUS ejs_pull_array(struct ejs_rpc *ejs,
NTSTATUS ejs_push_array(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, uint32_t length,
size_t elsize, void *r, ejs_push_t ejs_push);
-
+NTSTATUS ejs_pull_string(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const char **s);
+NTSTATUS ejs_push_string(struct ejs_rpc *ejs,
+ struct MprVar *v, const char *name, const char *s);
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index 631f1c3a37..00675165ea 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -128,7 +128,7 @@ done:
}
/* convert the mpr object into a C structure */
- status = ejs_pull_rpc(io, ptr, ejs_pull);
+ status = ejs_pull_rpc(eid, callname, io, ptr, ejs_pull);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
@@ -152,7 +152,7 @@ done:
ndr_print_function_debug(call->ndr_print, call->name, NDR_OUT, ptr);
}
- status = ejs_push_rpc(io, ptr, ejs_push);
+ status = ejs_push_rpc(eid, callname, io, ptr, ejs_push);
talloc_free(ptr);
done: