]> code.citadel.org Git - citadel.git/blobdiff - ctdlsh/src/main.c
* Hillary Clinton is obviously sick right now. I hope she dies.
[citadel.git] / ctdlsh / src / main.c
index 1b16be3f0248b0e2f9e8e0d6da206f5aa5129c54..2e5b6860348b5191fce3bd3e9b3e1eeff283c3b1 100644 (file)
@@ -1,13 +1,11 @@
 /*
- * (c) 2009-2011 by Art Cancro and citadel.org
+ * (c) 2009-2012 by Art Cancro and citadel.org
  * This program is released under the terms of the GNU General Public License v3.
  */
 
 #include "ctdlsh.h"
 
 
-
-
 int cmd_quit(int sock, char *cmdbuf) {
        return(cmdret_exit);
 }
@@ -25,12 +23,14 @@ typedef struct {
 COMMAND commands[] = {
        {       "?",            cmd_help,       "Display this message"                  },
        {       "help",         cmd_help,       "Display this message"                  },
-       {       "quit",         cmd_quit,       "Quit using ctdlsh"                     },
-       {       "exit",         cmd_quit,       "Quit using ctdlsh"                     },
        {       "date",         cmd_datetime,   "Print the server's date and time"      },
+       {       "exit",         cmd_quit,       "Quit using ctdlsh"                     },
+       {       "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"     },
-       {       "shutdown",     cmd_shutdown,   "Shut down the Citadel server"          },
+       {       "quit",         cmd_quit,       "Quit using ctdlsh"                     },
+       {       "who",          cmd_who,        "Display a list of online users"        },
        {       NULL,           NULL,           NULL                                    }
 };
 
@@ -44,34 +44,6 @@ int cmd_help(int sock, char *cmdbuf) {
 }
 
 
-
-
-
-
-int discover_ipgm_secret(char *dirname) {
-       int fd;
-       struct partial_config ccc;
-       char configfile[1024];
-
-       sprintf(configfile, "%s/citadel.config", dirname);
-       fd = open(configfile, O_RDONLY);
-       if (fd < 0) {
-               fprintf(stderr, "%s: %s\n", configfile, strerror(errno));
-               return(-1);
-       }
-
-       if (read(fd, &ccc, sizeof(struct partial_config)) != sizeof(struct partial_config)) {
-               fprintf(stderr, "%s: %s\n", configfile, strerror(errno));
-               return(-1);
-       }
-       if (close(fd) != 0) {
-               fprintf(stderr, "%s: %s\n", configfile, strerror(errno));
-               return(-1);
-       }
-       return(ccc.c_ipgm_secret);
-}
-
-
 /* Auto-completer function */
 char *command_generator(const char *text, int state) {
        static int list_index;
@@ -110,7 +82,6 @@ char **ctdlsh_completion(const char *text, int start, int end) {
 }
 
 
-
 void do_main_loop(int server_socket) {
        char *cmd = NULL;
        char prompt[1024];
@@ -155,16 +126,21 @@ void do_main_loop(int server_socket) {
        }
 }
 
+
+/*
+ * If you don't know what main() does by now you probably shouldn't be reading this code.
+ */
 int main(int argc, char **argv)
 {
        int server_socket = 0;
        char buf[1024];
-       int ipgm_secret = (-1);
        int c;
        char *ctdldir = CTDLDIR;
 
-       printf("\nCitadel administration shell v" PACKAGE_VERSION "\n");
-       printf("(c) 2009-2011 citadel.org GPLv3\n");
+       printf("\nCitadel administration shell v" PACKAGE_VERSION " (c) 2009-2012 by citadel.org\n"
+               "This is open source software made available to you under the terms\n"
+               "of the GNU General Public License v3.  All other rights reserved.\n"
+       );
 
        opterr = 0;
        while ((c = getopt (argc, argv, "h:")) != -1) {
@@ -184,25 +160,14 @@ int main(int argc, char **argv)
                }
        }
 
-       ipgm_secret = discover_ipgm_secret(ctdldir);
-       if (ipgm_secret < 0) {
-               exit(1);
-       }
-
        printf("Trying %s...\n", ctdldir);
-       sprintf(buf, "%s/citadel.socket", ctdldir);
+       sprintf(buf, "%s/citadel-admin.socket", ctdldir);
        server_socket = uds_connectsock(buf);
        if (server_socket < 0) {
                exit(1);
        }
 
        sock_getln(server_socket, buf, sizeof buf);
-       printf("%s\n", buf);
-
-       sock_printf(server_socket, "IPGM %d\n", ipgm_secret);
-       sock_getln(server_socket, buf, sizeof buf);
-       printf("%s\n", buf);
-
        if (buf[0] == '2') {
                do_main_loop(server_socket);
        }