From 643e5d8239ba105a5ac99ecc513289a17402714b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 2 Jul 2005 05:21:17 +0000 Subject: r8069: the beginnings of code to allow rpc calls to be made from ejs tpot, note that this shows how you can modify passed in MprVar variables in C call (This used to be commit a782541db3de6ca3b599a220265cf9e6cb0c4d7b) --- source4/scripting/ejs/smbscript.c | 43 +++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'source4/scripting/ejs/smbscript.c') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 2795e4f127..aa0fc42c48 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -4,6 +4,7 @@ Standalone client for ejs scripting. Copyright (C) Tim Potter 2005 + Copyright (C) Andrew Tridgell 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +22,7 @@ */ #include "includes.h" +#include "lib/cmdline/popt_common.h" #include "dynconfig.h" #include "lib/ejs/ejs.h" @@ -30,7 +32,7 @@ void ejs_exception(const char *reason) exit(127); } - int main(int argc, const char *argv[]) + int main(int argc, const char **argv) { EjsId eid; EjsHandle handle = 0; @@ -39,28 +41,39 @@ void ejs_exception(const char *reason) size_t script_size; TALLOC_CTX *mem_ctx = talloc_new(NULL); const char **argv_list = NULL; + const char *fname; struct MprVar v, *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 + }; - if (argc < 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); - exit(127); - } + popt_common_dont_ask(); - setup_logging(argv[0],DEBUG_STDOUT); + pc = poptGetContext("smbscript", argc, argv, long_options, 0); - if (!lp_load(dyn_CONFIGFILE)) { - fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", - argv[0], dyn_CONFIGFILE); - exit(127); - } + poptSetOtherOptionHelp(pc, "