]> git.sur5r.net Git - gsconf/blob - shell_sys.c
d563670c9cad2e04ffcc5b9f64ef2447bdbc4b78
[gsconf] / shell_sys.c
1 #include "shell.h"
2
3
4
5 void shell_sys(char ** argv, int elem) {
6         int n, i, m, o;
7         
8         if (elem == 1) {
9                 printf(" port [show|name|password|restart] \n");
10                 return;
11         }
12         
13         if (strncmp(argv[1], "show", 4) == 0) {
14                 printf("Name: \t\t%s\n", settings.name);
15                 printf("Model: \t\t%s\n", settings.model);
16                 printf("SW-Version:\t %s\n", settings.swVersion);
17         }else if (strncmp(argv[1], "name", 4) == 0) {
18                 if (elem != 3) {
19                         printf("Please provide a name\n");
20                         return;
21                 }
22                 
23                 password();
24                 printError(gs105e_setName(argv[2]));
25                 
26         }else if (strncmp(argv[1], "password", 4) == 0) {
27         
28                 password();
29                 
30                 char * newPwd = copyString(getpass("New Password: "));
31                 if (strlen(newPwd) == 0) {
32                         printf("Password musst be at least one character!\n");
33                         return;
34                 }
35                 char * newPwdConf = copyString(getpass("New Password: "));
36                 printf("%p %p\n", settings.password, newPwd);
37                 if (strncmp(newPwd, newPwdConf, strlen(newPwd)) == 0 && strlen(newPwd) == strlen(newPwdConf)) {
38                         int e = gs105e_setPassword(newPwd);
39                         printError(e);
40                         if (e != 0)
41                                 return;
42                         settings.password = newPwd;
43                 }else {
44                         printf("Passwords do not match!\n");
45                 }
46         }else if (strncmp(argv[1], "restart", 4) == 0) {
47                 password();
48                 printError(gs105e_restart());
49         }
50         
51         
52 }