]> git.sur5r.net Git - ngadmin/blob - cli/com_restart.c
Cli: refactor, change coding style
[ngadmin] / cli / com_restart.c
1
2 #include "commands.h"
3
4
5 bool do_restart (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga UNUSED)
6 {
7         int i, ret = true;
8         const struct swi_attr *sa;
9         char line[16];
10         
11         
12         sa = ngadmin_getCurrentSwitch(nga);
13         if (sa == NULL) {
14                 printf("must be logged\n");
15                 ret = false;
16                 goto end;
17         }
18         
19         printf("The switch will be restarted. Continue ? [y/N]: ");
20         fflush(stdout);
21         
22         if (fgets(line, sizeof(line), stdin) != NULL && strcasecmp(line, "y\n") == 0) {
23                 i = ngadmin_restart(nga);
24                 printErrCode(i);
25         }
26         
27 end:
28         
29         return ret;
30 }
31
32