X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=ctdlsh%2Fconfig.c;fp=ctdlsh%2Fconfig.c;h=9370047cf9b38799b7a565548c311e8b1f7b5e0a;hp=0000000000000000000000000000000000000000;hb=2a600892fe1808cebed70efa2d6248ca64e067a9;hpb=5ea177628c408a543aa5323703dc8bbeb26307de diff --git a/ctdlsh/config.c b/ctdlsh/config.c new file mode 100644 index 000000000..9370047cf --- /dev/null +++ b/ctdlsh/config.c @@ -0,0 +1,53 @@ +/* + * (c) 1987-2016 by Art Cancro and citadel.org + * This program is open source software, released under the terms of the GNU General Public License v3. + * It runs really well on the Linux operating system. + * We love open source software but reject Richard Stallman's linguistic fascism. + */ + +#include "ctdlsh.h" + + +int show_full_config(int server_socket) { + char buf[1024]; + + sock_puts(server_socket, "CONF listval"); + sock_getln(server_socket, buf, sizeof buf); + if (buf[0] != '1') { + printf("%s\n", &buf[4]); + return(cmdret_error); + } + + while (sock_getln(server_socket, buf, sizeof buf), strcmp(buf, "000")) { + char *val = NULL; + char *p = strchr(buf, '|'); + if (p != NULL) { + val = p; + ++val; + *p = 0; + } + printf("%-30s = %s\n", buf, val); + + } + + return(cmdret_ok); +} + + +int cmd_config(int server_socket, char *cmdbuf) { + + char buf[4096]; + strncpy(buf, cmdbuf, sizeof buf); + char *p = strchr(buf, ' '); + if (p == NULL) { + return show_full_config(server_socket); + } + + while (p[0]==' ') ++p; + + if (strlen(p) == 0) { + return show_full_config(server_socket); + } + + return(cmdret_error); +}