svn commit: samba r9176 - in branches/SAMBA_4_0/swat: esptest scripting scripting/client

tridge at samba.org tridge at samba.org
Sun Aug 7 07:00:00 GMT 2005


Author: tridge
Date: 2005-08-07 07:00:00 +0000 (Sun, 07 Aug 2005)
New Revision: 9176

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9176

Log:
added a much neater method of calling printf on the server from client side js. Just
use srv_printf() and normal printf arguments




Added:
   branches/SAMBA_4_0/swat/scripting/general_calls.esp
Modified:
   branches/SAMBA_4_0/swat/esptest/qooxdoo.esp
   branches/SAMBA_4_0/swat/scripting/client/call.js


Changeset:
Modified: branches/SAMBA_4_0/swat/esptest/qooxdoo.esp
===================================================================
--- branches/SAMBA_4_0/swat/esptest/qooxdoo.esp	2005-08-07 06:22:08 UTC (rev 9175)
+++ branches/SAMBA_4_0/swat/esptest/qooxdoo.esp	2005-08-07 07:00:00 UTC (rev 9176)
@@ -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;
     };
 

Modified: branches/SAMBA_4_0/swat/scripting/client/call.js
===================================================================
--- branches/SAMBA_4_0/swat/scripting/client/call.js	2005-08-07 06:22:08 UTC (rev 9175)
+++ branches/SAMBA_4_0/swat/scripting/client/call.js	2005-08-07 07:00:00 UTC (rev 9176)
@@ -40,7 +40,7 @@
 /*
 	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 @@
 	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 @@
 	}
 }
 
+
+/*
+	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);
+}

Added: branches/SAMBA_4_0/swat/scripting/general_calls.esp
===================================================================
--- branches/SAMBA_4_0/swat/scripting/general_calls.esp	2005-08-07 06:22:08 UTC (rev 9175)
+++ branches/SAMBA_4_0/swat/scripting/general_calls.esp	2005-08-07 07:00:00 UTC (rev 9176)
@@ -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();
+%>



More information about the samba-cvs mailing list