summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerb Lewis <herb@samba.org>2007-03-09 19:48:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:32 -0500
commitec5167efa940884d2c74fd92a791e1c5b8746f2e (patch)
tree6881c00f088cdd0784d1ba3ef80aa4f038198a77
parent98e58694eed08f24e9d243445655aa0105b98ecc (diff)
downloadsamba-ec5167efa940884d2c74fd92a791e1c5b8746f2e.tar.gz
samba-ec5167efa940884d2c74fd92a791e1c5b8746f2e.tar.bz2
samba-ec5167efa940884d2c74fd92a791e1c5b8746f2e.zip
r21780: let smbcontrol use POPT_COMMON_SAMBA options to allow setting debug
level. Fix calculation of argc after options are stripped. I couldn't find a popt function that returned this. (This used to be commit 6bcbf23e2ae67615a2416e70be2f68bd58fba5b9)
-rw-r--r--source3/utils/smbcontrol.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index ec1e101e06..060079a573 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -1145,22 +1145,12 @@ int main(int argc, const char **argv)
poptContext pc;
int opt;
- static struct poptOption wbinfo_options[] = {
+ static struct poptOption long_options[] = {
+ POPT_AUTOHELP
{ "timeout", 't', POPT_ARG_INT, &timeout, 't',
"Set timeout value in seconds", "TIMEOUT" },
- { "configfile", 's', POPT_ARG_STRING, NULL, 's',
- "Use alternative configuration file", "CONFIGFILE" },
-
- POPT_TABLEEND
- };
-
- struct poptOption options[] = {
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, wbinfo_options, 0,
- "Options" },
-
- POPT_AUTOHELP
- POPT_COMMON_VERSION
+ POPT_COMMON_SAMBA
POPT_TABLEEND
};
@@ -1171,7 +1161,7 @@ int main(int argc, const char **argv)
/* Parse command line arguments using popt */
pc = poptGetContext(
- "smbcontrol", argc, (const char **)argv, options, 0);
+ "smbcontrol", argc, (const char **)argv, long_options, 0);
poptSetOtherOptionHelp(pc, "[OPTION...] <destination> <message-type> "
"<parameters>");
@@ -1182,11 +1172,6 @@ int main(int argc, const char **argv)
while ((opt = poptGetNextOpt(pc)) != -1) {
switch(opt) {
case 't': /* --timeout */
- argc -= 2;
- break;
- case 's': /* --configfile */
- pstrcpy(dyn_CONFIGFILE, poptGetOptArg(pc));
- argc -= 2;
break;
default:
fprintf(stderr, "Invalid option\n");
@@ -1200,7 +1185,10 @@ int main(int argc, const char **argv)
correct value in the above switch statement. */
argv = (const char **)poptGetArgs(pc);
- argc--; /* Don't forget about argv[0] */
+ argc = 0;
+ while (argv[argc] != NULL) {
+ argc++;
+ }
if (argc == 1)
usage(&pc);