#include "includes.h"
#include "system/filesys.h"
-#include "popt_common.h"
+#include "lib/cmdline/cmdline.h"
#include "lib/param/loadparm.h"
#include "lib/crypto/gnutls_helpers.h"
#include "cmdline_contexts.h"
int main(int argc, const char *argv[])
{
- const char *config_file = get_dyn_CONFIGFILE();
+ const char *config_file = NULL;
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
int s;
static int show_defaults;
static int skip_logic_checks = 0;
const char *weak_crypo_str = "";
+ bool ok;
struct poptOption long_options[] = {
POPT_AUTOHELP
.val = 0,
.descrip = "Limit testparm to a named section",
},
+ POPT_COMMON_DEBUG_ONLY
+ POPT_COMMON_OPTION_ONLY
POPT_COMMON_VERSION
- POPT_COMMON_DEBUGLEVEL
- POPT_COMMON_OPTION
POPT_TABLEEND
};
TALLOC_CTX *frame = talloc_stackframe();
smb_init_locale();
+
+ ok = samba_cmdline_init(frame,
+ SAMBA_CMDLINE_CONFIG_NONE,
+ true /* require_smbconf */);
+ if (!ok) {
+ DBG_ERR("Failed to init cmdline parser!\n");
+ ret = 1;
+ goto done;
+ }
+
/*
* Set the default debug level to 1.
* Allow it to be overridden by the command line,
*/
lp_set_cmdline("log level", "1");
- pc = poptGetContext(NULL, argc, argv, long_options,
- POPT_CONTEXT_KEEP_FIRST);
+ pc = samba_popt_get_context(getprogname(),
+ argc,
+ argv,
+ long_options,
+ 0);
+ if (pc == NULL) {
+ DBG_ERR("Failed to setup popt context!\n");
+ ret = 1;
+ goto done;
+ }
+
poptSetOtherOptionHelp(pc, "[OPTION...] <config-file> [host-name] [host-ip]");
while(poptGetNextOpt(pc) != -1);
exit(0);
}
- setup_logging(poptGetArg(pc), DEBUG_STDERR);
-
- if (poptPeekArg(pc))
+ if (poptPeekArg(pc)) {
config_file = poptGetArg(pc);
+ } else {
+ config_file = get_dyn_CONFIGFILE();
+ }
cname = poptGetArg(pc);
caddr = poptGetArg(pc);