summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-07-08 18:25:56 +0000
committerAndrew Tridgell <tridge@samba.org>2001-07-08 18:25:56 +0000
commitb4230fb93a23d16ab8883f45d9bc55e0342d8671 (patch)
tree6f0295be0d5b98c3098e49374683c32abcb323bd /source3/rpcclient
parent955247fa38fcf5167edf7935a694e75514bc7dcf (diff)
downloadsamba-b4230fb93a23d16ab8883f45d9bc55e0342d8671.tar.gz
samba-b4230fb93a23d16ab8883f45d9bc55e0342d8671.tar.bz2
samba-b4230fb93a23d16ab8883f45d9bc55e0342d8671.zip
improved the command line parsing of rpcclient
(This used to be commit 29d8f9bcb3f55365740a5bbafc75dd2dffc107a9)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/rpcclient.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index e66b15bb11..decad75c87 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -503,9 +503,9 @@ struct cli_state *setup_connection(struct cli_state *cli, char *system_name,
/* Print usage information */
-static void usage(char *pname)
+static void usage(void)
{
- printf("Usage: %s server [options]\n", pname);
+ printf("Usage: rpcclient [options] server\n");
printf("\t-A authfile file containing user credentials\n");
printf("\t-c \"command string\" execute semicolon separated cmds\n");
@@ -544,18 +544,7 @@ static void usage(char *pname)
DEBUGLEVEL = 1;
- /* Parse options */
- if (argc < 2) {
- usage(argv[0]);
- return 0;
- }
-
- pstrcpy(server, argv[1]);
-
- argv++;
- argc--;
-
- while ((opt = getopt(argc, argv, "A:s:Nd:U:W:c:l:")) != EOF) {
+ while ((opt = getopt(argc, argv, "A:s:Nd:U:W:c:l:h")) != EOF) {
switch (opt) {
case 'A':
/* only get the username, password, and domain from the file */
@@ -588,6 +577,7 @@ static void usage(char *pname)
case 'U': {
char *lp;
pstrcpy(username,optarg);
+ printf("got user=%s\n", username);
if ((lp=strchr_m(username,'%'))) {
*lp = 0;
pstrcpy(password,lp+1);
@@ -603,14 +593,25 @@ static void usage(char *pname)
case 'h':
default:
- usage(argv[0]);
+ usage();
exit(1);
}
}
+
+ argv += optind;
+ argc -= optind;
+
+ /* Parse options */
+ if (argc < 1) {
+ usage();
+ return 0;
+ }
+ pstrcpy(server, argv[0]);
+
/* the following functions are part of the Samba debugging
facilities. See lib/debug.c */
- setup_logging (argv[0], interactive);
+ setup_logging("rpcclient", interactive);
if (!interactive)
reopen_logs();