diff options
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r-- | source4/scripting/ejs/ejsrpc.c | 33 | ||||
-rw-r--r-- | source4/scripting/ejs/ejsrpc.h | 9 |
2 files changed, 13 insertions, 29 deletions
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c index 75f748f146..965fd8d447 100644 --- a/source4/scripting/ejs/ejsrpc.c +++ b/source4/scripting/ejs/ejsrpc.c @@ -45,6 +45,13 @@ NTSTATUS ejs_push_rpc(int eid, const char *callname, return ejs_push(ejs, v, ptr); } +/* + set the switch var to be used by the next union switch +*/ +void ejs_set_switch(struct ejs_rpc *ejs, uint32_t switch_var) +{ + ejs->switch_var = switch_var; +} /* panic in the ejs wrapper code @@ -274,34 +281,10 @@ NTSTATUS ejs_pull_array(struct ejs_rpc *ejs, /* - push an array of elements -*/ -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) -{ - int i; - char *data; - - NDR_CHECK(ejs_push_struct_start(ejs, &v, name)); - - data = r; - - for (i=0;i<length;i++) { - char *id = talloc_asprintf(ejs, "%u", i); - NT_STATUS_HAVE_NO_MEMORY(id); - NDR_CHECK(ejs_push(ejs, v, id, (i*elsize)+data)); - talloc_free(id); - } - 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 *v, const char *name, char **s) { struct MprVar *var; var = mprGetVar(v, name); diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h index 5fb6ace863..67b81b3411 100644 --- a/source4/scripting/ejs/ejsrpc.h +++ b/source4/scripting/ejs/ejsrpc.h @@ -23,6 +23,9 @@ struct ejs_rpc { int eid; const char *callname; + /* as ejs does only one pass, we can use a single var for switch + handling */ + uint32_t switch_var; }; typedef NTSTATUS (*ejs_pull_t)(struct ejs_rpc *, struct MprVar *, const char *, void *); @@ -31,6 +34,7 @@ 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); +void ejs_set_switch(struct ejs_rpc *ejs, uint32_t switch_var); 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); @@ -63,10 +67,7 @@ NTSTATUS ejs_push_enum(struct ejs_rpc *ejs, NTSTATUS ejs_pull_array(struct ejs_rpc *ejs, struct MprVar *v, const char *name, uint32_t length, size_t elsize, void **r, ejs_pull_t ejs_pull); -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); + struct MprVar *v, const char *name, char **s); NTSTATUS ejs_push_string(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const char *s); |