diff options
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r-- | source4/scripting/ejs/ejsrpc.c | 21 | ||||
-rw-r--r-- | source4/scripting/ejs/ejsrpc.h | 2 | ||||
-rw-r--r-- | source4/scripting/ejs/smbcalls.c | 8 | ||||
-rw-r--r-- | source4/scripting/ejs/smbcalls_rpc.c | 9 | ||||
-rw-r--r-- | source4/scripting/ejs/smbscript.c | 2 |
5 files changed, 41 insertions, 1 deletions
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c index 19c1a2fc8d..6536b94ca4 100644 --- a/source4/scripting/ejs/ejsrpc.c +++ b/source4/scripting/ejs/ejsrpc.c @@ -273,7 +273,8 @@ NTSTATUS ejs_pull_string(struct ejs_rpc *ejs, DEBUG(1,("ejs_pull_string: unable to find '%s'\n", name)); return NT_STATUS_INVALID_PARAMETER_MIX; } - *s = mprToString(var); + *s = talloc_strdup(ejs, mprToString(var)); + NT_STATUS_HAVE_NO_MEMORY(*s); return NT_STATUS_OK; } @@ -285,3 +286,21 @@ NTSTATUS ejs_push_string(struct ejs_rpc *ejs, { return mprSetVar(v, name, mprCreateStringVar(s, True)); } + +/* + setup a constant int +*/ +void ejs_set_constant_int(int eid, const char *name, int value) +{ + struct MprVar *v = ejsGetGlobalObject(eid); + mprSetVar(v, name, mprCreateIntegerVar(value)); +} + +/* + setup a constant string +*/ +void ejs_set_constant_string(int eid, const char *name, const char *value) +{ + struct MprVar *v = ejsGetGlobalObject(eid); + mprSetVar(v, name, mprCreateStringVar(value, False)); +} diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h index fdf15c027c..0435b52365 100644 --- a/source4/scripting/ejs/ejsrpc.h +++ b/source4/scripting/ejs/ejsrpc.h @@ -68,6 +68,8 @@ NTSTATUS ejs_pull_string(struct ejs_rpc *ejs, 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); +void ejs_set_constant_int(int eid, const char *name, int value); +void ejs_set_constant_string(int eid, const char *name, const char *value); #define EJS_ALLOC_SIZE(ejs, s, size) do { \ (s) = talloc_size(ejs, size); \ diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 041bd59f1a..0f43da349d 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -198,3 +198,11 @@ void smb_setup_ejs_functions(void) ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); } + +/* + setup constants that can be used from ejs +*/ +void smb_setup_ejs_constants(int eid) +{ + smb_setup_ejs_rpc_constants(eid); +} diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c index 6ec3e29e50..f8ea37b754 100644 --- a/source4/scripting/ejs/smbcalls_rpc.c +++ b/source4/scripting/ejs/smbcalls_rpc.c @@ -173,3 +173,12 @@ void smb_setup_ejs_rpc(void) ejsDefineCFunction(-1, "rpc_connect", ejs_rpc_connect, NULL, MPR_VAR_SCRIPT_HANDLE); setup_ejs_rpcecho(); } + +/* + setup constants for rpc calls +*/ +void smb_setup_ejs_rpc_constants(int eid) +{ + void setup_ejs_constants_rpcecho(int); + setup_ejs_constants_rpcecho(eid); +} diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index aa0fc42c48..244ae0b42a 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -88,6 +88,8 @@ void ejs_exception(const char *reason) exit(127); } + smb_setup_ejs_constants(eid); + /* setup ARGV[] in the ejs environment */ for (i=1;argv[i];i++) { argv_list = str_list_add(argv_list, argv[i]); |