diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-08 03:10:30 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:19:20 -0500 |
commit | ceb277ced9ccd13936384e94c567b37c5db2c46e (patch) | |
tree | 8d5df4dbc86b7b21f323c15f5ff529059ad62f82 /source4/scripting/ejs | |
parent | e296c8de6e57a321116f01135c5c6fcf215245a8 (diff) | |
download | samba-ceb277ced9ccd13936384e94c567b37c5db2c46e.tar.gz samba-ceb277ced9ccd13936384e94c567b37c5db2c46e.tar.bz2 samba-ceb277ced9ccd13936384e94c567b37c5db2c46e.zip |
r8213: I've started to understand the LEVELS stuff in pidl much better now,
and have re-coded the push side of the ejs generator to use it
properly. It ends up being very neat and small, and should handle much
more complex structures (like arrays of pointers to unions etc).
Also added push side support for unions. This should get more of the
echo pipe working via ejs.
(This used to be commit 2e306be1d83f722c259c4a63233e77d8bb1d5a72)
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); |