From 55e746ad560d4406821bc2d721cbb929b79a7a0a Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 22 Aug 2005 14:32:58 +0000 Subject: 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) --- source4/scripting/ejs/smbcalls_creds.c | 37 ++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'source4/scripting/ejs/smbcalls_creds.c') diff --git a/source4/scripting/ejs/smbcalls_creds.c b/source4/scripting/ejs/smbcalls_creds.c index 61a5139cda..45da5895e4 100644 --- a/source4/scripting/ejs/smbcalls_creds.c +++ b/source4/scripting/ejs/smbcalls_creds.c @@ -23,6 +23,7 @@ #include "includes.h" #include "scripting/ejs/smbcalls.h" #include "lib/appweb/ejs/ejs.h" +#include "lib/cmdline/popt_common.h" /* helper function to get the local objects credentials ptr @@ -184,19 +185,9 @@ static int ejs_creds_get_workstation(MprVarHandle eid, int argc, struct MprVar * /* initialise credentials ejs object */ -static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv) +static int ejs_credentials_obj(MprVarHandle eid, int argc, struct MprVar **argv, struct cli_credentials *creds) { struct MprVar *obj = mprInitObject(eid, "credentials", argc, argv); - struct cli_credentials *creds; - - creds = cli_credentials_init(mprMemCtx()); - if (creds == NULL) { - return -1; - } - - cli_credentials_guess(creds); - cli_credentials_set_username(creds, "", CRED_GUESSED); - cli_credentials_set_password(creds, "", CRED_GUESSED); mprSetPtrChild(obj, "creds", creds); @@ -216,6 +207,30 @@ static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv } +/* + initialise credentials ejs object +*/ +static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv) +{ + struct cli_credentials *creds; + + creds = cli_credentials_init(mprMemCtx()); + if (creds == NULL) { + return -1; + } + + return ejs_credentials_obj(eid, argc, argv, creds); +} + +/* + initialise cmdline credentials ejs object +*/ +int ejs_credentials_cmdline(int eid, int argc, struct MprVar **argv) +{ + return ejs_credentials_obj(eid, argc, argv, cmdline_credentials); +} + + /* setup C functions that be called from ejs */ -- cgit