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