diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-11 07:42:43 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:20:05 -0500 |
commit | f583a85d4d520b0ab6ca83efd36e71563108b370 (patch) | |
tree | f3d6bfd4e4100402a88cc1040860652905bd6eac /source4/scripting/ejs/smbscript.c | |
parent | 9ab58c5e0127a66ae79cb867cfcf271734241b3d (diff) | |
download | samba-f583a85d4d520b0ab6ca83efd36e71563108b370.tar.gz samba-f583a85d4d520b0ab6ca83efd36e71563108b370.tar.bz2 samba-f583a85d4d520b0ab6ca83efd36e71563108b370.zip |
r8316: give full access to the popt command line parsing in ejs scripts, including
access to the samba common options. For example:
ok = GetOptions(ARGV, options,
"POPT_AUTOHELP",
"POPT_COMMON_SAMBA",
"myopt=s",
"intopt=i",
"noopt");
this allows scripts to support their own extended options properly
(This used to be commit 775fb56ac287b8d485b38f633b9480d7b7ab64e3)
Diffstat (limited to 'source4/scripting/ejs/smbscript.c')
-rw-r--r-- | source4/scripting/ejs/smbscript.c | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index bf9049af36..691cd44730 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -22,7 +22,6 @@ */ #include "includes.h" -#include "lib/cmdline/popt_common.h" #include "dynconfig.h" #include "lib/ejs/ejs.h" #include "scripting/ejs/smbcalls.h" @@ -43,37 +42,18 @@ void ejs_exception(const char *reason) TALLOC_CTX *mem_ctx = talloc_new(NULL); const char **argv_list = NULL; const char *fname; - struct MprVar v, *return_var; + struct MprVar *return_var; int exit_status, i; - poptContext pc; - int opt; - struct poptOption long_options[] = { - POPT_AUTOHELP - POPT_COMMON_SAMBA - POPT_COMMON_CREDENTIALS - POPT_COMMON_VERSION - POPT_TABLEEND - }; - - popt_common_dont_ask(); - - pc = poptGetContext("smbscript", argc, argv, long_options, 0); - - poptSetOtherOptionHelp(pc, "<script> <args> ..."); - - while((opt = poptGetNextOpt(pc)) != -1) /* noop */ ; smbscript_init_subsystems; - mprSetCtx(mem_ctx); - argv = poptGetArgs(pc); - if (argv == NULL || - argv[0] == NULL) { - poptPrintUsage(pc, stdout, 0); + if (argc < 2) { + fprintf(stderr, "You must supply a script name\n"); exit(1); } - fname = argv[0]; + + fname = argv[1]; if (ejsOpen(NULL, NULL, NULL) != 0) { fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " @@ -96,8 +76,7 @@ void ejs_exception(const char *reason) argv_list = str_list_add(argv_list, argv[i]); } talloc_steal(mem_ctx, argv_list); - v = mprList("ARGV", argv_list); - mprSetVar(ejsGetGlobalObject(eid), "ARGV", v); + mprSetVar(ejsGetGlobalObject(eid), "ARGV", mprList("ARGV", argv_list)); /* load the script and advance past interpreter line*/ script = file_load(fname, &script_size, mem_ctx); |