summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs/smbcalls_options.c
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2005-08-22 14:32:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:34:20 -0500
commit55e746ad560d4406821bc2d721cbb929b79a7a0a (patch)
treed9baa6d6d7651e3f95313699510335c714a2e681 /source4/scripting/ejs/smbcalls_options.c
parent5bd6a114711c0033403a656b42574380a6ebcd3d (diff)
downloadsamba-55e746ad560d4406821bc2d721cbb929b79a7a0a.tar.gz
samba-55e746ad560d4406821bc2d721cbb929b79a7a0a.tar.bz2
samba-55e746ad560d4406821bc2d721cbb929b79a7a0a.zip
r9477: Convert popt options to an ejs object. Doesn't seem to break anything
except of popt help (-h) option (unexpected ?). rafal (This used to be commit 1990793b23d6198a85ce1bdf6ad43e12015db203)
Diffstat (limited to 'source4/scripting/ejs/smbcalls_options.c')
-rw-r--r--source4/scripting/ejs/smbcalls_options.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/source4/scripting/ejs/smbcalls_options.c b/source4/scripting/ejs/smbcalls_options.c
index 9fbfd312a9..8eca9ebcaa 100644
--- a/source4/scripting/ejs/smbcalls_options.c
+++ b/source4/scripting/ejs/smbcalls_options.c
@@ -28,8 +28,7 @@
/*
usage:
- var options = new Object();
- result = GetOptions(argv, options,
+ options = GetOptions(argv,
"realm=s",
"enablexx",
"myint=i");
@@ -41,6 +40,7 @@
additional command line arguments are placed in options.ARGV
*/
+
static int ejs_GetOptions(MprVarHandle eid, int argc, struct MprVar **argv)
{
poptContext pc;
@@ -52,13 +52,15 @@ static int ejs_GetOptions(MprVarHandle eid, int argc, struct MprVar **argv)
} tables[] = {
{ "POPT_AUTOHELP", poptHelpOptions, "Help options:" },
{ "POPT_COMMON_SAMBA", popt_common_samba, "Common Samba options:" },
- { "POPT_COMMON_CONNECTION", popt_common_connection, "Connection options:" },
+ { "POPT_COMMON_CONNECTION", popt_common_connection, "Connection options:" },
{ "POPT_COMMON_CREDENTIALS", popt_common_credentials, "Authentication options:" },
{ "POPT_COMMON_VERSION", popt_common_version, "Common Samba options:" }
};
+
+ struct MprVar *options = mprInitObject(eid, "options", 0, NULL);
+
TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx());
struct poptOption *long_options = NULL;
- struct MprVar *options;
int i, num_options = 0;
int opt_argc;
const char **opt_argv;
@@ -66,15 +68,12 @@ static int ejs_GetOptions(MprVarHandle eid, int argc, struct MprVar **argv)
const int BASE_OPTNUM = 0x100000;
/* validate arguments */
- if (argc < 2 ||
- argv[0]->type != MPR_TYPE_OBJECT ||
- argv[1]->type != MPR_TYPE_OBJECT) {
+ if (argc < 1 || argv[0]->type != MPR_TYPE_OBJECT) {
ejsSetErrorMsg(eid, "GetOptions invalid arguments");
return -1;
}
opt_argv = mprToArray(tmp_ctx, argv[0]);
- options = argv[1];
opt_argc = str_list_length(opt_argv);
long_options = talloc_array(tmp_ctx, struct poptOption, 1);
@@ -178,7 +177,10 @@ static int ejs_GetOptions(MprVarHandle eid, int argc, struct MprVar **argv)
poptFreeContext(pc);
talloc_free(tmp_ctx);
- mpr_Return(eid, mprCreateBoolVar(1));
+
+ /* setup methods */
+ mprSetCFunction(options, "get_credentials", ejs_credentials_cmdline);
+
return 0;
}