/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- net_help_usage
- net_usage
- net_help
1 /*
2 Samba Unix/Linux SMB client library
3 net help commands
4 Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "includes.h"
21 #include "utils/net.h"
22
23 static int net_usage(struct net_context *c, int argc, const char **argv);
24
25 static int net_help_usage(struct net_context *c, int argc, const char **argv)
/* [<][>][^][v][top][bottom][index][help] */
26 {
27 c->display_usage = true;
28 return net_usage(c, argc, argv);
29 }
30
31 static int net_usage(struct net_context *c, int argc, const char **argv)
/* [<][>][^][v][top][bottom][index][help] */
32 {
33 struct functable *table = (struct functable*) c->private_data;
34 int i;
35
36 d_printf("Usage:\n");
37 for (i=0; table[i].funcname != NULL; i++) {
38 if (c->display_usage) {
39 d_printf("net %s usage:\n", table[i].funcname);
40 d_printf("\n%s\n\n", table[i].usage);
41 } else {
42 d_printf("%s %-15s %s\n", "net", table[i].funcname,
43 table[i].description);
44 }
45
46 }
47
48 net_common_flags_usage(c, argc, argv);
49 return -1;
50 }
51
52 /*
53 handle "net help *" subcommands
54 */
55 int net_help(struct net_context *c, int argc, const char **argv)
/* [<][>][^][v][top][bottom][index][help] */
56 {
57 struct functable *func = (struct functable *)c->private_data;
58
59 if (argc == 0) {
60 return net_usage(c, argc, argv);
61 }
62
63 if (StrCaseCmp(argv[0], "help") == 0) {
64 return net_help_usage(c, argc, argv);
65 }
66
67 c->display_usage = true;
68 return net_run_function(c, argc, argv, "net help", func);
69 }