* added some socket stuff
[citadel.git] / ctdlsh / src / main.c
1 /*
2  * (c) 2009 by Art Cancro and citadel.org
3  * This program is released under the terms of the GNU General Public License v3.
4  */
5
6 #include <config.h>
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include <stdio.h>
10 #include <readline/readline.h>
11
12 int main(int argc, char **argv)
13 {
14         char *cmd = NULL;
15         char *prompt = "> ";
16         int server_socket = 0;
17
18         printf("Attaching to server...\r");
19         fflush(stdout);
20         server_socket = sock_connect("localhost", "504", "tcp");
21         if (server_socket < 0) {
22                 exit(1);
23         }
24         printf("                      \r");
25
26         printf("\nCitadel administration shell v" PACKAGE_VERSION "\n");
27         printf("(c) 2009 citadel.org GPLv3\n");
28         printf("Type a command.  Or don't.  We don't care.\n\n");
29
30         while (cmd = readline(prompt)) {
31
32                 if ((cmd) && (*cmd)) {
33                         add_history(cmd);
34                 }
35
36                 printf("\nHaha, you said: '%s'\n\n", cmd);
37                 free(cmd);
38         }
39
40         exit(0);
41 }