-int cmd_quit(char *cmdbuf) {
- abort();
+int cmd_quit(int sock, char *cmdbuf) {
+ return(cmdret_exit);
}
-
-
/*
* Commands understood by ctdlsh
*/
typedef struct {
char *name;
- rl_icpfunc_t *func;
+ ctdlsh_cmdfunc_t *func;
char *doc;
} COMMAND;
-
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" },
+ { "time", cmd_datetime, "Print the server's date and time" },
+ { "passwd", cmd_passwd, "Set or change an account password" },
{ NULL, NULL, NULL }
};
+int cmd_help(int sock, char *cmdbuf) {
+ int i;
+
+ for (i=0; commands[i].func != NULL; ++i) {
+ printf("%-10s %s\n", commands[i].name, commands[i].doc);
+ }
+}
+
+
+
+
+
+
int discover_ipgm_secret(char *dirname) {
int fd;
struct partial_config ccc;
char buf[1024];
char server_reply[1024];
int i;
+ int ret = (-1);
strcpy(prompt, "> ");
rl_attempted_completion_function = ctdlsh_completion;
/* Here we go ... main command loop */
- while (cmd = readline(prompt)) {
+ while ((ret != cmdret_exit) && (cmd = readline(prompt))) {
if ((cmd) && (*cmd)) {
add_history(cmd);
- /* FIXME put something here */
+
+ for (i=0; commands[i].func != NULL; ++i) {
+ if (!strncasecmp(cmd, commands[i].name, strlen(commands[i].name))) {
+ ret = (*commands[i].func) (server_socket, cmd);
+ }
+ }
+
}
free(cmd);