Started working on a ctdlsh command framework to show and manipulate the server confi...
authorArt Cancro <ajc@citadel.org>
Tue, 16 Aug 2016 21:48:35 +0000 (17:48 -0400)
committerArt Cancro <ajc@citadel.org>
Tue, 16 Aug 2016 21:48:35 +0000 (17:48 -0400)
ctdlsh/Makefile
ctdlsh/README
ctdlsh/config.c [new file with mode: 0644]
ctdlsh/ctdlsh.h
ctdlsh/main.c

index 946dff0..5fddc98 100644 (file)
@@ -1,4 +1,4 @@
-OBJS := datetime.o export.o main.o passwd.o shutdown.o sockets.o who.o
+OBJS := datetime.o export.o main.o passwd.o shutdown.o sockets.o who.o config.o
 
 CFLAGS := -ggdb
 
index 35143f9..306490d 100644 (file)
@@ -5,6 +5,9 @@ submit patches, but if you attempt to use it in a production system or
 if you request support for the program, you will be told to die in a
 car fire.
 
-This is open source software.  It runs really well on the Linux operating
-system.  We reject Richard Stallman's linguistic fascism and so should you.
+License: you are permitted to use this software under the condition that
+you refer to it as "open source" and not "free software," and that you
+refer to the operating system on which it runs as "Linux" and not
+"GNU/Linux."  By reading this notice you have already accepted the license,
+and you have irrevocably agreed that Richard Stallman is a communist.
 
diff --git a/ctdlsh/config.c b/ctdlsh/config.c
new file mode 100644 (file)
index 0000000..9370047
--- /dev/null
@@ -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);
+}
index 722fa83..14103fa 100644 (file)
@@ -46,3 +46,4 @@ int cmd_passwd(int, char *);
 int cmd_shutdown(int, char *);
 int cmd_who(int, char *);
 int cmd_export(int, char *);
+int cmd_config(int, char *);
index 4e40098..93cbaef 100644 (file)
@@ -24,13 +24,14 @@ COMMAND commands[] = {
        {       "?",            cmd_help,       "Display this message"                  },
        {       "help",         cmd_help,       "Display this message"                  },
        {       "date",         cmd_datetime,   "Print the server's date and time"      },
-       {       "exit",         cmd_quit,       "Quit using ctdlsh"                     },
+       {       "config",       cmd_config,     "Configure the Citadel server"          },
        {       "export",       cmd_export,     "Export all Citadel databases"          },
        {       "shutdown",     cmd_shutdown,   "Shut down the Citadel server"          },
        {       "time",         cmd_datetime,   "Print the server's date and time"      },
        {       "passwd",       cmd_passwd,     "Set or change an account password"     },
-       {       "quit",         cmd_quit,       "Quit using ctdlsh"                     },
        {       "who",          cmd_who,        "Display a list of online users"        },
+       {       "exit",         cmd_quit,       "Quit using ctdlsh"                     },
+       {       "quit",         cmd_quit,       "Quit using ctdlsh"                     },
        {       NULL,           NULL,           NULL                                    }
 };