diff options
author | Jim McDonough <jmcd@samba.org> | 2002-03-07 18:56:51 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-03-07 18:56:51 +0000 |
commit | 6e6318525a810e2d397401ee75b9993ad17d455d (patch) | |
tree | 3c9856b031486086f82c0c53ae8125ecf6b633ca /source3/rpcclient | |
parent | 39e14916e48a5290e7766aa4f845900365bb42c3 (diff) | |
download | samba-6e6318525a810e2d397401ee75b9993ad17d455d.tar.gz samba-6e6318525a810e2d397401ee75b9993ad17d455d.tar.xz samba-6e6318525a810e2d397401ee75b9993ad17d455d.zip |
Convert rpcclient to use popt instead of getopt. Includes changing of got_pass from BOOL to int. Also includes long option names...anyone want those different before I update the doc? Please try this out. I've tried to test all the flags, but the more times we kick the tires...
(This used to be commit cd34897749dc5819dd7239269fbd5dcef5bea5c0)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r-- | source3/rpcclient/rpcclient.c | 78 |
1 files changed, 46 insertions, 32 deletions
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 68457e2b8f2..2a9d01f5201 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -533,15 +533,15 @@ static void usage(void) { printf("Usage: rpcclient server [options]\n"); - printf("\t-A authfile file containing user credentials\n"); - printf("\t-c \"command string\" execute semicolon separated cmds\n"); - printf("\t-d debuglevel set the debuglevel\n"); - printf("\t-l logfile name of logfile to use as opposed to stdout\n"); - printf("\t-h Print this help message.\n"); - printf("\t-N don't ask for a password\n"); - printf("\t-s configfile specify an alternative config file\n"); - printf("\t-U username set the network username\n"); - printf("\t-W domain set the domain name for user account\n"); + printf("\t-A or --authfile authfile file containing user credentials\n"); + printf("\t-c or --command \"command string\" execute semicolon separated cmds\n"); + printf("\t-d or --debug debuglevel set the debuglevel\n"); + printf("\t-l or --logfile logfile logfile to use instead of stdout\n"); + printf("\t-h or --help Print this help message.\n"); + printf("\t-N or --nopass don't ask for a password\n"); + printf("\t-s or --conf configfile specify an alternative config file\n"); + printf("\t-U or --user username set the network username\n"); + printf("\t-W or --workgroup domain set the domain name for user account\n"); printf("\n"); } @@ -552,22 +552,43 @@ static void usage(void) extern char *optarg; extern int optind; extern pstring global_myname; - BOOL got_pass = False; + int got_pass = 0; BOOL interactive = True; int opt; int olddebug; - pstring cmdstr = ""; + char *cmdstr = ""; struct cli_state *cli; fstring password="", username="", domain="", server=""; + char *opt_authfile=NULL, + *opt_username=NULL, + *opt_domain=NULL, + *opt_configfile=NULL, + *opt_logfile=NULL; pstring logfile; struct cmd_set **cmd_set; struct in_addr server_ip; NTSTATUS nt_status; extern BOOL AllowDebugChange; + poptContext pc; + struct poptOption long_options[] = { + {"authfile", 'A', POPT_ARG_STRING, &opt_authfile, 'A'}, + {"conf", 's', POPT_ARG_STRING, &opt_configfile, 's'}, + {"nopass", 'N', POPT_ARG_NONE, &got_pass}, + {"debug", 'd', POPT_ARG_INT, &DEBUGLEVEL}, + {"debuglevel", 'd', POPT_ARG_INT, &DEBUGLEVEL}, + {"user", 'U', POPT_ARG_STRING, &opt_username, 'U'}, + {"workgroup", 'W', POPT_ARG_STRING, &opt_domain, 'W'}, + {"command", 'c', POPT_ARG_STRING, &cmdstr}, + {"logfile", 'l', POPT_ARG_STRING, &opt_logfile, 'l'}, + {"help", 'h', POPT_ARG_NONE, 0, 'h'}, + { 0, 0, 0, 0} + }; + + setlinebuf(stdout); DEBUGLEVEL = 1; @@ -588,51 +609,44 @@ static void usage(void) argv++; argc--; - while ((opt = getopt(argc, argv, "A:s:Nd:U:W:c:l:h")) != EOF) { + pc = poptGetContext(NULL, argc, (const char **) argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + + while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case 'A': /* only get the username, password, and domain from the file */ - read_authfile (optarg, username, password, domain); + read_authfile (opt_authfile, username, + password, domain); if (strlen (password)) - got_pass = True; - break; - - case 'c': - pstrcpy(cmdstr, optarg); - break; - - case 'd': - DEBUGLEVEL = atoi(optarg); + got_pass = 1; break; case 'l': - slprintf(logfile, sizeof(logfile) - 1, "%s.client", optarg); + slprintf(logfile, sizeof(logfile) - 1, "%s.client", + opt_logfile); lp_set_logfile(logfile); interactive = False; break; - case 'N': - got_pass = True; - break; - case 's': - pstrcpy(dyn_CONFIGFILE, optarg); + pstrcpy(dyn_CONFIGFILE, opt_configfile); break; case 'U': { char *lp; - pstrcpy(username,optarg); + pstrcpy(username,opt_username); if ((lp=strchr_m(username,'%'))) { *lp = 0; pstrcpy(password,lp+1); - got_pass = True; - memset(strchr_m(optarg,'%')+1,'X',strlen(password)); + got_pass = 1; + memset(strchr_m(opt_username,'%')+1,'X',strlen(password)); } break; } case 'W': - pstrcpy(domain, optarg); + pstrcpy(domain, opt_domain); break; case 'h': |