diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-08-07 07:00:00 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:31:28 -0500 |
commit | 9f4444331a3c06c58c50ea10ab6ad84904c54339 (patch) | |
tree | 73d60f5b2bfac3b21426480eaff2bc856fde8542 /swat | |
parent | 0aa43d9231eedd14310317f54660edeeee303183 (diff) | |
download | samba-9f4444331a3c06c58c50ea10ab6ad84904c54339.tar.gz samba-9f4444331a3c06c58c50ea10ab6ad84904c54339.tar.bz2 samba-9f4444331a3c06c58c50ea10ab6ad84904c54339.zip |
r9176: added a much neater method of calling printf on the server from client side js. Just
use srv_printf() and normal printf arguments
(This used to be commit 11c7e8db3d2501a6a439d3e3a63a5055cc577f51)
Diffstat (limited to 'swat')
-rw-r--r-- | swat/esptest/qooxdoo.esp | 5 | ||||
-rw-r--r-- | swat/scripting/client/call.js | 47 | ||||
-rw-r--r-- | swat/scripting/general_calls.esp | 26 |
3 files changed, 66 insertions, 12 deletions
diff --git a/swat/esptest/qooxdoo.esp b/swat/esptest/qooxdoo.esp index dbdb4ddc7a..76d3236fc9 100644 --- a/swat/esptest/qooxdoo.esp +++ b/swat/esptest/qooxdoo.esp @@ -53,8 +53,7 @@ } function start_call() { - server_call('remote.esp', 'printf', null, - "Starting calls ... (stopit=%d)\\n", stopit); + srv_printf("Starting calls ... (stopit=%d)\\n", stopit); stopit = 0; shared.counter = 0; shared.start_time = 0; @@ -62,7 +61,7 @@ }; function stop_call() { - server_call('remote.esp', 'printf', null, "Stopping calls\\n"); + srv_printf("Stopping calls\\n"); stopit = 1; }; diff --git a/swat/scripting/client/call.js b/swat/scripting/client/call.js index d1671ef70f..3af6a5a876 100644 --- a/swat/scripting/client/call.js +++ b/swat/scripting/client/call.js @@ -40,7 +40,7 @@ function __http_object() { /* usage: - server_call(url, func, callback, ...); + vserver_call(url, func, callback, args); 'func' is a function name to call on the server any additional arguments are passed to func() on the server @@ -48,17 +48,17 @@ function __http_object() { The callback() function is called with the returned object. 'callback' may be null. */ -function server_call(url, func, callback) { +function vserver_call(url, func, callback, args) { + var args2 = new Object(); + args2.length = args.length; + var i; + for (i=0;i<args.length;i++) { + args2[i] = args[i]; + } var req = __http_object(); req.open("POST", url, true); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - var args = new Object(); - var i; - for (i=3;i<arguments.length;i++) { - args[i-3] = arguments[i]; - } - args.length = i-3; - req.send("func=" + func + "&args=" + encodeObject(args)); + req.send("func=" + func + "&args=" + encodeObject(args2)); req.onreadystatechange = function() { if (4 == req.readyState && callback != null) { var o = decodeObject(req.responseText); @@ -67,3 +67,32 @@ function server_call(url, func, callback) { } } + +/* + usage: + + server_call(url, func, callback, ...); + + 'func' is a function name to call on the server + any additional arguments are passed to func() on the server + + The callback() function is called with the returned + object. 'callback' may be null. +*/ +function server_call(url, func, callback) { + var args = new Object(); + var i; + for (i=3;i<arguments.length;i++) { + args[i-3] = arguments[i]; + } + args.length = i-3; + vserver_call(url, func, callback, args); +} + + +/* + call printf on the server +*/ +function srv_printf() { + vserver_call('/scripting/general_calls.esp', 'srv_printf', null, arguments); +} diff --git a/swat/scripting/general_calls.esp b/swat/scripting/general_calls.esp new file mode 100644 index 0000000000..3a78ff6bbb --- /dev/null +++ b/swat/scripting/general_calls.esp @@ -0,0 +1,26 @@ +<% +/* + used for general purpose calls +*/ +libinclude("server_call.js"); + +/* register a call for clients to make */ +var call = servCallObj(); + +/* + a remote printf, for displaying stuff on smbd stdout +*/ +function srv_printf() +{ + println("in srv_printf"); + var s = string_init(); + print(s.vsprintf(arguments)); + return undefined; +} + +/* add some basic calls */ +call.add('srv_printf', srv_printf); + +/* run the function that was asked for */ +call.run(); +%> |