summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/scripting/libjs/base.js53
-rw-r--r--source4/scripting/libjs/encoder.js116
-rw-r--r--source4/scripting/libjs/server_call.js83
3 files changed, 0 insertions, 252 deletions
diff --git a/source4/scripting/libjs/base.js b/source4/scripting/libjs/base.js
index d861073a07..790dfeb3e0 100644
--- a/source4/scripting/libjs/base.js
+++ b/source4/scripting/libjs/base.js
@@ -21,48 +21,6 @@ function printf()
}
/*
- helper function to setup a rpc io object, ready for input
-*/
-function irpcObj()
-{
- var o = new Object();
- o.input = new Object();
- return o;
-}
-
-/*
- check that a status result is OK
-*/
-function check_status_ok(status)
-{
- if (status.is_ok != true) {
- printVars(status);
- }
- assert(status.is_ok == true);
-}
-
-/*
- check that two arrays are equal
-*/
-function check_array_equal(a1, a2)
-{
- assert(a1.length == a2.length);
- for (i=0; i<a1.length; i++) {
- assert(a1[i] == a2[i]);
- }
-}
-
-/*
- check that an array is all zeros
-*/
-function check_array_zero(a)
-{
- for (i=0; i<a.length; i++) {
- assert(a[i] == 0);
- }
-}
-
-/*
substitute strings of the form ${NAME} in str, replacing
with substitutions from subobj
*/
@@ -90,14 +48,3 @@ function substitute_var(str, subobj)
}
return join("", list);
}
-
-/*
- return "s" if a number should be shown as plural
-*/
-function plural(n)
-{
- if (n == 1) {
- return "";
- }
- return "s";
-}
diff --git a/source4/scripting/libjs/encoder.js b/source4/scripting/libjs/encoder.js
deleted file mode 100644
index 6cb780c00d..0000000000
--- a/source4/scripting/libjs/encoder.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- server side js functions for encoding/decoding objects into linear strings
-
- Copyright Andrew Tridgell 2005
- released under the GNU GPL Version 3 or later
-*/
-/*
- usage:
-
- enc = encodeObject(obj);
- obj = decodeObject(enc);
-
- The encoded format of the object is a string that is safe to
- use in URLs
-
- Note that only data elements are encoded, not functions
-*/
-
-function __count_members(o) {
- var i, count = 0;
- for (i in o) {
- count++;
- }
- if (o.length != undefined) {
- count++;
- }
- return count;
-}
-
-function __replace(str, old, rep) {
- var s = string_init();
- var a = s.split(old, str);
- var j = s.join(rep, a);
- return s.join(rep, a);
-}
-
-function encodeElement(e, name) {
- var t = typeof(e);
- var r;
- var s = string_init();
- if (t == 'object' && e == null) {
- t = 'null';
- }
- if (t == 'object') {
- r = s.sprintf("%s:%s:%s", name, t, encodeObject(e));
- } else if (t == "string") {
- var enc = s.encodeURIComponent(e);
- var rep = __replace(enc, '%', '#');
- r = s.sprintf("%s:%s:%s:",
- name, t, __replace(s.encodeURIComponent(e),'%','#'));
- } else if (t == "boolean" || t == "number") {
- r = s.sprintf("%s:%s:%s:", name, t, "" + e);
- } else if (t == "undefined" || t == "null") {
- r = s.sprintf("%s:%s:", name, t);
- } else if (t == "pointer") {
- r = s.sprintf("%s:string:(POINTER):", name);
- } else {
- println("Unable to linearise type " + t);
- r = "";
- }
- return r;
-}
-
-function encodeObject(o) {
- var s = string_init();
- var i, r = s.sprintf("%u:", __count_members(o));
- for (i in o) {
- r = r + encodeElement(o[i], i);
- }
- if (o.length != undefined) {
- r = r + encodeElement(o.length, 'length');
- }
- return r;
-}
-
-function decodeObjectArray(a) {
- var s = string_init();
- var o = new Object();
- var i, count = a[a.i]; a.i++;
- for (i=0;i<count;i++) {
- var name = a[a.i]; a.i++;
- var type = a[a.i]; a.i++;
- var value;
- if (type == 'object') {
- o[name] = decodeObjectArray(a);
- } else if (type == "string") {
- value = s.decodeURIComponent(__replace(a[a.i],'#','%')); a.i++;
- o[name] = value;
- } else if (type == "boolean") {
- value = a[a.i]; a.i++;
- if (value == 'true') {
- o[name] = true;
- } else {
- o[name] = false;
- }
- } else if (type == "undefined") {
- o[name] = undefined;
- } else if (type == "null") {
- o[name] = null;
- } else if (type == "number") {
- value = a[a.i]; a.i++;
- o[name] = value + 0;
- } else {
- println("Unable to delinearise type " + t);
- assert(t == "supported type");
- }
- }
- return o;
-}
-
-function decodeObject(str) {
- var s = string_init();
- var a = s.split(':', str);
- a.i = 0;
- return decodeObjectArray(a);
-}
diff --git a/source4/scripting/libjs/server_call.js b/source4/scripting/libjs/server_call.js
deleted file mode 100644
index 46414a90dd..0000000000
--- a/source4/scripting/libjs/server_call.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- server side js functions for handling async calls from js clients
-
- Copyright Andrew Tridgell 2005
- released under the GNU GPL Version 3 or later
-*/
-
-libinclude("encoder.js");
-
-/*
- register a new call
-*/
-function __register_call(name, func)
-{
- var c = this;
- c.calls[name] = func;
-}
-
-/*
- run a call sent from the client, and output the returned object (if any)
-*/
-function __run_call() {
- var c = this;
- var name = form['ajaj_func'];
- if (name == undefined) {
- /* no function to run */
- return;
- }
- var args = form['ajaj_args'];
- if (args == undefined) {
- println("no function arguments given in run_call");
- exit(0);
- }
- args = decodeObject(args);
- if (c.calls[name] == undefined) {
- println("undefined remote call " + name);
- exit(0);
- }
- var f = c.calls[name];
- var res;
- /* oh what a hack - should write a varargs ejs helper */
- if (args.length == 0) {
- res = f();
- } else if (args.length == 1) {
- res = f(args[0]);
- } else if (args.length == 2) {
- res = f(args[0], args[1]);
- } else if (args.length == 3) {
- res = f(args[0], args[1], args[2]);
- } else if (args.length == 4) {
- res = f(args[0], args[1], args[2], args[3]);
- } else if (args.length == 5) {
- res = f(args[0], args[1], args[2], args[3], args[4]);
- } else if (args.length == 6) {
- res = f(args[0], args[1], args[2], args[3], args[4], args[5]);
- } else if (args.length == 7) {
- res = f(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
- } else if (args.length == 8) {
- res = f(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
- } else {
- println("too many arguments for remote call: " + name);
- exit(0);
- }
- var repobj = new Object();
- repobj.res = res;
- write(encodeObject(repobj));
- exit(0);
-}
-
-
-
-/*
- initialise a server call object
-*/
-function servCallObj()
-{
- var c = new Object();
- c.add = __register_call;
- c.run = __run_call;
- c.calls = new Object();
- return c;
-}
-