9370047cf9b38799b7a565548c311e8b1f7b5e0a
[citadel.git] / ctdlsh / config.c
1 /*
2  * (c) 1987-2016 by Art Cancro and citadel.org
3  * This program is open source software, released under the terms of the GNU General Public License v3.
4  * It runs really well on the Linux operating system.
5  * We love open source software but reject Richard Stallman's linguistic fascism.
6  */
7
8 #include "ctdlsh.h"
9
10
11 int show_full_config(int server_socket) {
12         char buf[1024];
13
14         sock_puts(server_socket, "CONF listval");
15         sock_getln(server_socket, buf, sizeof buf);
16         if (buf[0] != '1') {
17                 printf("%s\n", &buf[4]);
18                 return(cmdret_error);
19         }
20
21         while (sock_getln(server_socket, buf, sizeof buf), strcmp(buf, "000")) {
22                 char *val = NULL;
23                 char *p = strchr(buf, '|');
24                 if (p != NULL) {
25                         val = p;
26                         ++val;
27                         *p = 0;
28                 }
29                 printf("%-30s = %s\n", buf, val);
30                 
31         }
32
33         return(cmdret_ok);
34 }
35
36
37 int cmd_config(int server_socket, char *cmdbuf) {
38
39         char buf[4096];
40         strncpy(buf, cmdbuf, sizeof buf);
41         char *p = strchr(buf, ' ');
42         if (p == NULL) {
43                 return show_full_config(server_socket);
44         }
45
46         while (p[0]==' ') ++p;
47
48         if (strlen(p) == 0) {
49                 return show_full_config(server_socket);
50         }
51
52         return(cmdret_error);
53 }