1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

s3:utils: Migrate smbcontrol to new cmdline option parser

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andreas Schneider 2021-01-13 13:28:11 +01:00 committed by Andrew Bartlett
parent 774663094d
commit 824c355ed7
2 changed files with 23 additions and 8 deletions

View File

@ -26,7 +26,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "lib/util/server_id.h"
#include "popt_common.h"
#include "lib/cmdline/cmdline.h"
#include "librpc/gen_ndr/spoolss.h"
#include "nt_printing.h"
#include "printing/notify.h"
@ -1703,7 +1703,7 @@ int main(int argc, const char **argv)
struct tevent_context *evt_ctx;
struct messaging_context *msg_ctx;
static struct poptOption long_options[] = {
struct poptOption long_options[] = {
/* POPT_AUTOHELP */
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, help_options,
0, "Help options:", NULL },
@ -1711,20 +1711,37 @@ int main(int argc, const char **argv)
"Set timeout value in seconds", "TIMEOUT" },
POPT_COMMON_SAMBA
POPT_COMMON_VERSION
POPT_TABLEEND
};
TALLOC_CTX *frame = talloc_stackframe();
int ret = 0;
bool ok;
smb_init_locale();
setup_logging(argv[0], DEBUG_STDOUT);
ok = samba_cmdline_init(frame,
SAMBA_CMDLINE_CONFIG_CLIENT,
false /* require_smbconf */);
if (!ok) {
DBG_ERR("Failed to init cmdline parser!\n");
TALLOC_FREE(frame);
exit(1);
}
lp_set_cmdline("log level", "0");
/* Parse command line arguments using popt */
pc = poptGetContext(
"smbcontrol", argc, (const char **)argv, long_options, 0);
pc = samba_popt_get_context(getprogname(),
argc,
argv,
long_options,
0);
if (pc == NULL) {
DBG_ERR("Failed to setup popt context!\n");
TALLOC_FREE(frame);
exit(1);
}
poptSetOtherOptionHelp(pc, "[OPTION...] <destination> <message-type> "
"<parameters>");
@ -1768,8 +1785,6 @@ int main(int argc, const char **argv)
evt_ctx = global_event_context();
lp_load_global(get_dyn_CONFIGFILE());
/* Need to invert sense of return code -- samba
* routines mostly return True==1 for success, but
* shell needs 0. */

View File

@ -20,7 +20,7 @@ bld.SAMBA3_BINARY('smbcontrol',
deps='''
talloc
smbconf
popt_samba3
CMDLINE_S3
cmdline_contexts
PRINTBASE''')