]> git.sur5r.net Git - ngadmin/blob - cli/com_name.c
Let commands handle themselves absence of arguments
[ngadmin] / cli / com_name.c
1
2 #include "commands.h"
3
4
5 bool do_name_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
6 {
7         const struct swi_attr *sa;
8         
9         
10         if (argc > 0) {
11                 printf("this command takes no argument\n");
12                 return false;
13         }
14         
15         sa = ngadmin_getCurrentSwitch(nga);
16         if (sa == NULL) {
17                 printf("must be logged\n");
18                 return false;
19         }
20         
21         puts(sa->name);
22         
23         
24         return true;
25 }
26
27
28 bool do_name_set (int argc, const char **argv, struct ngadmin *nga)
29 {
30         int i;
31         const struct swi_attr *sa;
32         
33         
34         if (argc != 1) {
35                 printf("usage: name set <value>\n");
36                 return false;
37         }
38         
39         sa = ngadmin_getCurrentSwitch(nga);
40         if (sa == NULL) {
41                 printf("must be logged\n");
42                 return false;
43         }
44         
45         i = ngadmin_setName(nga, argv[0]);
46         printErrCode(i);
47         
48         
49         return true;
50 }
51
52
53 bool do_name_clear (int argc, const char **argv UNUSED, struct ngadmin *nga)
54 {
55         int i;
56         const struct swi_attr *sa;
57         
58         
59         if (argc > 0) {
60                 printf("this command takes no argument\n");
61                 return false;
62         }
63         
64         sa = ngadmin_getCurrentSwitch(nga);
65         if (sa == NULL) {
66                 printf("must be logged\n");
67                 return false;
68         }
69         
70         i = ngadmin_setName(nga, NULL);
71         printErrCode(i);
72         
73         
74         return true;
75 }
76
77