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