Line data Source code
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 0 : static int net_help_usage(struct net_context *c, int argc, const char **argv)
26 : {
27 0 : c->display_usage = true;
28 0 : return net_usage(c, argc, argv);
29 : }
30 :
31 0 : static int net_usage(struct net_context *c, int argc, const char **argv)
32 : {
33 0 : struct functable *table = (struct functable*) c->private_data;
34 : int i;
35 :
36 0 : d_printf(_("Usage:\n"));
37 0 : for (i=0; table[i].funcname != NULL; i++) {
38 0 : if (c->display_usage) {
39 0 : d_printf(_("net %s usage:\n"), table[i].funcname);
40 0 : d_printf("\n%s\n\n", _(table[i].usage));
41 : } else {
42 0 : d_printf("%s %-15s %s\n", "net", table[i].funcname,
43 0 : _(table[i].description));
44 : }
45 :
46 : }
47 :
48 0 : net_common_flags_usage(c, argc, argv);
49 0 : return -1;
50 : }
51 :
52 : /*
53 : handle "net help *" subcommands
54 : */
55 0 : int net_help(struct net_context *c, int argc, const char **argv)
56 : {
57 0 : struct functable *func = (struct functable *)c->private_data;
58 :
59 0 : if (argc == 0) {
60 0 : return net_usage(c, argc, argv);
61 : }
62 :
63 0 : if (strcasecmp_m(argv[0], "help") == 0) {
64 0 : return net_help_usage(c, argc, argv);
65 : }
66 :
67 0 : c->display_usage = true;
68 0 : return net_run_function(c, argc, argv, "net help", func);
69 : }
|