summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2008-05-19 00:19:18 +0200
committerKai Blin <kai@samba.org>2008-06-10 09:45:36 +0200
commit0f1b3ed5c0326cdca931adc43806ec4df0d3abf3 (patch)
tree3792bb68135c3ededd7322cab9f6dd06d2184eee /source3/utils
parent2ca10c462d23a76fcb9e48865fcfcdacc0dde5ee (diff)
downloadsamba-0f1b3ed5c0326cdca931adc43806ec4df0d3abf3.tar.gz
samba-0f1b3ed5c0326cdca931adc43806ec4df0d3abf3.tar.bz2
samba-0f1b3ed5c0326cdca931adc43806ec4df0d3abf3.zip
net: Autogenerate "net help" output from net's functable.
(This used to be commit 0feb40bc8408412336c667df4f8bf57c77446ca7)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net.c1
-rw-r--r--source3/utils/net.h1
-rw-r--r--source3/utils/net_help.c91
3 files changed, 30 insertions, 63 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index b56ca7e26c..b1401e97ba 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -758,6 +758,7 @@ static struct functable3 net_func[] = {
c->opt_password = getenv("PASSWD");
}
+ c->private_data = net_func;
rc = net_run_function3(c, argc_new-1, argv_new+1, "net", net_func);
DEBUG(2,("return code = %d\n", rc));
diff --git a/source3/utils/net.h b/source3/utils/net.h
index b89caca856..d1e759c5a9 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -62,6 +62,7 @@ struct net_context {
struct libnetapi_ctx *netapi_ctx;
bool display_usage;
+ void *private_data;
const char *share_type[];
};
diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c
index ddb8d76336..035914431e 100644
--- a/source3/utils/net_help.c
+++ b/source3/utils/net_help.c
@@ -20,45 +20,31 @@
#include "includes.h"
#include "utils/net.h"
+static int net_usage(struct net_context *c, int argc, const char **argv);
+
static int net_help_usage(struct net_context *c, int argc, const char **argv)
{
- d_printf(
-"\n"\
-"Usage: net help <function>\n"\
-"\n"\
-"Valid functions are:\n"\
-" RPC RAP ADS FILE SHARE SESSION SERVER DOMAIN PRINTQ USER GROUP VALIDATE\n"\
-" GROUPMEMBER ADMIN SERVICE PASSWORD TIME LOOKUP GETLOCALSID SETLOCALSID\n"\
-" SETDOMAINSID CHANGESCRETPW LOOKUP SAM\n");
- return -1;
+ c->display_usage = true;
+ return net_usage(c, argc, argv);
}
static int net_usage(struct net_context *c, int argc, const char **argv)
{
- d_printf(" net time\t\tto view or set time information\n"\
- " net lookup\t\tto lookup host name or ip address\n"\
- " net user\t\tto manage users\n"\
- " net group\t\tto manage groups\n"\
- " net sam\t\tto edit the local user database directly\n"\
- " net lookup\t\tto look up various things\n"\
- " net groupmap\t\tto manage group mappings\n"\
- " net join\t\tto join a domain\n"\
- " net cache\t\tto operate on cache tdb file\n"\
- " net getlocalsid [NAME]\tto get the SID for local name\n"\
- " net setlocalsid SID\tto set the local domain SID\n"\
- " net setdomainsid SID\tto set the domain SID on member servers\n"\
- " net changesecretpw\tto change the machine password in the local secrets database only\n"\
- " \tthis requires the -f flag as a safety barrier\n"\
- " net status\t\tShow server status\n"\
- " net usersidlist\tto get a list of all users with their SIDs\n"
- " net usershare\t\tto add, delete and list locally user-modifiable shares\n"
- " net conf\t\tto view and edit samba's registry based configuration\n"
- "\n"\
- " net ads <command>\tto run ADS commands\n"\
- " net rap <command>\tto run RAP (pre-RPC) commands\n"\
- " net rpc <command>\tto run RPC commands\n"\
- "\n"\
- "Type \"net help <option>\" to get more information on that option\n");
+ struct functable3 *table = (struct functable3*) c->private_data;
+ int i;
+
+ d_printf("Usage:\n");
+ for (i=0; table[i].funcname != NULL; i++) {
+ if (c->display_usage) {
+ d_printf("net %s usage:\n", table[i].funcname);
+ d_printf("\n%s\n\n", table[i].usage);
+ } else {
+ d_printf("%s %-15s %s\n", "net", table[i].funcname,
+ table[i].description);
+ }
+
+ }
+
net_common_flags_usage(c, argc, argv);
return -1;
}
@@ -68,37 +54,16 @@ static int net_usage(struct net_context *c, int argc, const char **argv)
*/
int net_help(struct net_context *c, int argc, const char **argv)
{
- struct functable func[] = {
- {"ADS", net_ads_usage},
- {"RAP", net_rap_usage},
- {"RPC", net_rpc_usage},
+ struct functable3 *func = (struct functable3 *)c->private_data;
- {"FILE", net_file_usage},
- {"SHARE", net_share_usage},
- {"SESSION", net_rap_session_usage},
- {"SERVER", net_rap_server_usage},
- {"DOMAIN", net_rap_domain_usage},
- {"PRINTQ", net_rap_printq_usage},
- {"USER", net_user_usage},
- {"GROUP", net_group_usage},
- {"GROUPMAP", net_groupmap_usage},
- {"JOIN", net_join_usage},
- {"DOM", net_dom_usage},
- {"VALIDATE", net_rap_validate_usage},
- {"GROUPMEMBER", net_rap_groupmember_usage},
- {"ADMIN", net_rap_admin_usage},
- {"SERVICE", net_rap_service_usage},
- {"PASSWORD", net_rap_password_usage},
- {"TIME", net_time_usage},
- {"LOOKUP", net_lookup_usage},
- {"USERSHARE", net_usershare_usage},
- {"USERSIDLIST", net_usersidlist_usage},
-#ifdef WITH_FAKE_KASERVER
- {"AFS", net_afs_usage},
-#endif
+ if (argc == 0) {
+ return net_usage(c, argc, argv);
+ }
- {"HELP", net_help_usage},
- {NULL, NULL}};
+ if (StrCaseCmp(argv[0], "help") == 0) {
+ return net_help_usage(c, argc, argv);
+ }
- return net_run_function(c, argc, argv, func, net_usage);
+ c->display_usage = true;
+ return net_run_function3(c, argc, argv, "net help", func);
}