summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-11 07:43:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:20:06 -0500
commit1864b27857c71b998dd201acaaa3c8664b8be960 (patch)
tree9358398c8ee05a48ba0fcb2c21e4730ffffb253d
parentf583a85d4d520b0ab6ca83efd36e71563108b370 (diff)
downloadsamba-1864b27857c71b998dd201acaaa3c8664b8be960.tar.gz
samba-1864b27857c71b998dd201acaaa3c8664b8be960.tar.bz2
samba-1864b27857c71b998dd201acaaa3c8664b8be960.zip
r8317: convert the example scripts over to the new GetOptions() call
(This used to be commit 5f079d74630cf6431ec8af7240f60054cf8b9ab7)
-rw-r--r--testprogs/ejs/argv.js15
-rwxr-xr-xtestprogs/ejs/echo.js17
-rwxr-xr-xtestprogs/ejs/nbtstats10
-rwxr-xr-xtestprogs/ejs/samr.js23
4 files changed, 54 insertions, 11 deletions
diff --git a/testprogs/ejs/argv.js b/testprogs/ejs/argv.js
index 2f8dc74174..093123014a 100644
--- a/testprogs/ejs/argv.js
+++ b/testprogs/ejs/argv.js
@@ -1,7 +1,18 @@
/*
- demonstrate use of argv
+ demonstrate use of GetOptions
*/
+var ok;
+var options = new Object();
+
+ok = GetOptions(ARGV, options,
+ "POPT_AUTOHELP",
+ "POPT_COMMON_SAMBA",
+ "myopt=s",
+ "intopt=i",
+ "noopt");
+printVars(ok);
+
println("You called this script with arguments:");
-printVars(ARGV);
+printVars(options);
diff --git a/testprogs/ejs/echo.js b/testprogs/ejs/echo.js
index 312e599d50..e5b0b2b1bf 100755
--- a/testprogs/ejs/echo.js
+++ b/testprogs/ejs/echo.js
@@ -3,6 +3,17 @@
test echo pipe calls from ejs
*/
+var options = new Object();
+
+ok = GetOptions(ARGV, options,
+ "POPT_AUTOHELP",
+ "POPT_COMMON_SAMBA",
+ "POPT_COMMON_CREDENTIALS");
+if (ok == false) {
+ println("Failed to parse options: " + options.ERROR);
+ return -1;
+}
+
libinclude("base.js");
/*
@@ -198,7 +209,11 @@ if (ARGV.length == 0) {
exit(0);
}
-var binding = ARGV[0];
+if (options.ARGV.length != 1) {
+ println("Usage: samr.js <BINDING>");
+ return -1;
+}
+var binding = options.ARGV[0];
var conn = new Object();
print("Connecting to " + binding + "\n");
diff --git a/testprogs/ejs/nbtstats b/testprogs/ejs/nbtstats
index f2655e8c6e..fe93a728cd 100755
--- a/testprogs/ejs/nbtstats
+++ b/testprogs/ejs/nbtstats
@@ -3,6 +3,16 @@
demonstrate access to irpc calls from ejs
*/
+var options = new Object();
+
+ok = GetOptions(ARGV, options,
+ "POPT_AUTOHELP",
+ "POPT_COMMON_SAMBA");
+if (ok == false) {
+ println("Failed to parse options: " + options.ERROR);
+ return -1;
+}
+
var conn = new Object();
status = irpc_connect(conn, "nbt_server");
diff --git a/testprogs/ejs/samr.js b/testprogs/ejs/samr.js
index 1c613d5619..d0c2990158 100755
--- a/testprogs/ejs/samr.js
+++ b/testprogs/ejs/samr.js
@@ -3,9 +3,19 @@
test samr calls from ejs
*/
+var options = new Object();
+
+ok = GetOptions(ARGV, options,
+ "POPT_AUTOHELP",
+ "POPT_COMMON_SAMBA",
+ "POPT_COMMON_CREDENTIALS");
+if (ok == false) {
+ println("Failed to parse options: " + options.ERROR);
+ return -1;
+}
+
libinclude("base.js");
libinclude("samr.js");
-libinclude("samr.js");
/*
@@ -96,14 +106,11 @@ function test_EnumDomains(conn, handle)
}
}
-
-
-if (ARGV.length == 0) {
- print("Usage: samr.js <RPCBINDING>\n");
- exit(0);
+if (options.ARGV.length != 1) {
+ println("Usage: samr.js <BINDING>");
+ return -1;
}
-
-var binding = ARGV[0];
+var binding = options.ARGV[0];
var conn = new Object();
print("Connecting to " + binding + "\n");