diff options
author | Kai Blin <kai@samba.org> | 2008-05-22 09:41:21 +0200 |
---|---|---|
committer | Kai Blin <kai@samba.org> | 2008-06-10 09:45:19 +0200 |
commit | 44c260743cc01d7fa07b66b771b94de98b5b7444 (patch) | |
tree | 728926ad2d7a93bb1af3e2747816af40f6adf149 /source3/utils/net_util.c | |
parent | 6fd35d25bff4e1ceef07613c732dd7800afda35f (diff) | |
download | samba-44c260743cc01d7fa07b66b771b94de98b5b7444.tar.gz samba-44c260743cc01d7fa07b66b771b94de98b5b7444.tar.xz samba-44c260743cc01d7fa07b66b771b94de98b5b7444.zip |
net: Add net_run_function3
(This used to be commit ba1108f06ae5860c8f418dc383b027068780abf9)
Diffstat (limited to 'source3/utils/net_util.c')
-rw-r--r-- | source3/utils/net_util.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c index 20f004b790..c641e61c5c 100644 --- a/source3/utils/net_util.c +++ b/source3/utils/net_util.c @@ -592,3 +592,30 @@ int net_run_function2(struct net_context *c, int argc, const char **argv, return -1; } +int net_run_function3(struct net_context *c, int argc, const char **argv, + const char *whoami, struct functable3 *table) +{ + int i; + if (argc != 0) { + for (i=0; table[i].funcname != NULL; i++) { + if (StrCaseCmp(argv[0], table[i].funcname) == 0) + return table[i].fn(c, argc-1, argv+1); + } + } + + if (c->display_usage == false) { + d_fprintf(stderr, "Invalid command: %s %s\n", whoami, + (argc > 0)?argv[0]:""); + } + d_printf("Usage:\n"); + for (i=0; table[i].funcname != NULL; i++) { + if(c->display_usage == false) + d_printf("%s %-15s %s\n", whoami, table[i].funcname, + table[i].description); + else + d_printf("%s\n", table[i].usage); + } + + return c->display_usage?0:-1; +} + |