diff options
author | Tim Potter <tpot@samba.org> | 2001-07-20 04:38:58 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2001-07-20 04:38:58 +0000 |
commit | 8db78af9702dab2e89f1f7adf56996a20a8cb2f4 (patch) | |
tree | 999554eb81aaba3e118902697d0a41debbecb466 /source3/rpcclient/rpcclient.c | |
parent | 31fe984d2fc7a2813404a8c25816bb6bb25adfe9 (diff) | |
download | samba-8db78af9702dab2e89f1f7adf56996a20a8cb2f4.tar.gz samba-8db78af9702dab2e89f1f7adf56996a20a8cb2f4.tar.bz2 samba-8db78af9702dab2e89f1f7adf56996a20a8cb2f4.zip |
Started adding some help/usage info for rpcclient commands.
(This used to be commit 37052a1bcc5cd049918c3d5ac4c41c3a669290af)
Diffstat (limited to 'source3/rpcclient/rpcclient.c')
-rw-r--r-- | source3/rpcclient/rpcclient.c | 78 |
1 files changed, 62 insertions, 16 deletions
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 6420dbbdb5..1ab88747ea 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -188,6 +188,7 @@ static void get_username (char *username) } /* Fetch the SID for this domain */ + void fetch_domain_sid(struct cli_state *cli) { POLICY_HND pol; @@ -262,23 +263,66 @@ void init_rpcclient_creds(struct ntuser_creds *creds, char* username, } +/* Display help on commands */ + static uint32 cmd_help(struct cli_state *cli, int argc, char **argv) { - struct cmd_list *temp_list; + struct cmd_list *tmp; + struct cmd_set *tmp_set; - for (temp_list = cmd_list; temp_list; temp_list = temp_list->next) { - struct cmd_set *temp_set = temp_list->cmd_set; + /* Usage */ - while(temp_set->name) { - printf("%15s\t\t%s\n", temp_set->name, - temp_set->description); - temp_set++; + if (argc > 2) { + printf("Usage: %s [command]\n", argv[0]); + return 0; + } + + /* Help on one command */ + + if (argc == 2) { + for (tmp = cmd_list; tmp; tmp = tmp->next) { + + tmp_set = tmp->cmd_set; + + while(tmp_set->name) { + if (strequal(argv[1], tmp_set->name)) { + if (tmp_set->usage && + tmp_set->usage[0]) + printf("%s\n", tmp_set->usage); + else + printf("No help for %s\n", tmp_set->name); + + return 0; + } + + tmp_set++; + } + } + + printf("No such command: %s\n", argv[1]); + return 0; + } + + /* List all commands */ + + for (tmp = cmd_list; tmp; tmp = tmp->next) { + + tmp_set = tmp->cmd_set; + + while(tmp_set->name) { + + printf("%15s\t\t%s\n", tmp_set->name, + tmp_set->description); + + tmp_set++; } } return 0; } +/* Change the debug level */ + static uint32 cmd_debuglevel(struct cli_state *cli, int argc, char **argv) { if (argc > 2) { @@ -304,19 +348,21 @@ static uint32 cmd_quit(struct cli_state *cli, int argc, char **argv) /* Build in rpcclient commands */ static struct cmd_set rpcclient_commands[] = { - { "GENERAL OPTIONS", NULL, "" }, - { "help", cmd_help, "Print list of commands" }, - { "?", cmd_help, "Print list of commands" }, - { "debuglevel", cmd_debuglevel, "Set debug level" }, - { "exit", cmd_quit, "Exit program" }, - { "quit", cmd_quit, "Exit program" }, - - { NULL, NULL, NULL } + + { "GENERAL OPTIONS" }, + + { "help", cmd_help, "Get help on commands", "[command]" }, + { "?", cmd_help, "Get help on commands", "[command]" }, + { "debuglevel", cmd_debuglevel, "Set debug level", "level" }, + { "exit", cmd_quit, "Exit program", "" }, + { "quit", cmd_quit, "Exit program", "" }, + + { NULL } }; static struct cmd_set separator_command[] = { { "---------------", NULL, "----------------------" }, - { NULL, NULL, NULL } + { NULL } }; |