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