about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-02-10 23:53:13 +0000
committerJames Booth <boothj5@gmail.com>2012-02-10 23:53:13 +0000
commit9db56f4fc160f15fd918aca9da09f7f1539bc420 (patch)
treec4fc093858b98e2818f03e04def5272be2ed3e74
parent0e30c795a57d0fc8bfadf986821413b790a4ae17 (diff)
downloadprofani-tty-9db56f4fc160f15fd918aca9da09f7f1539bc420.tar.gz
Moved start commands to command.module
-rw-r--r--command.c30
-rw-r--r--command.h5
-rw-r--r--profanity.c37
3 files changed, 35 insertions, 37 deletions
diff --git a/command.c b/command.c
index 7b578cd8..8477a639 100644
--- a/command.c
+++ b/command.c
@@ -11,6 +11,36 @@ static int cmd_msg(char *cmd);
 static int cmd_close(char *cmd);
 static int cmd_default(char *cmd);
 
+int handle_start_command(char *cmd)
+{
+    int result;
+
+    if (strcmp(cmd, "/quit") == 0) {
+        result = QUIT_PROF;
+    } else if (strncmp(cmd, "/help", 5) == 0) {
+        cons_help();
+        inp_clear();
+        result = AWAIT_COMMAND;
+    } else if (strncmp(cmd, "/connect ", 9) == 0) {
+        char *user;
+        user = strndup(cmd+9, strlen(cmd)-9);
+
+        inp_bar_get_password();
+        char passwd[20];
+        inp_get_password(passwd);
+
+        inp_bar_print_message(user);
+        jabber_connect(user, passwd);
+        result = START_MAIN;
+    } else {
+        cons_bad_command(cmd);
+        inp_clear();
+        result = AWAIT_COMMAND;
+    }
+
+    return result;
+}
+
 int handle_command(char *cmd)
 {
     int result = FALSE;
diff --git a/command.h b/command.h
index b06663cf..219b4302 100644
--- a/command.h
+++ b/command.h
@@ -1,6 +1,11 @@
 #ifndef COMMAND_H
 #define COMMAND_H
 
+#define AWAIT_COMMAND 1
+#define START_MAIN 2
+#define QUIT_PROF 3
+
+int handle_start_command(char *cmd);
 int handle_command(char *cmd);
 
 #endif
diff --git a/profanity.c b/profanity.c
index 2160eda8..e06ac12d 100644
--- a/profanity.c
+++ b/profanity.c
@@ -9,12 +9,6 @@
 #include "jabber.h"
 #include "command.h"
 
-#define AWAIT_COMMAND 1
-#define START_MAIN 2
-#define QUIT_PROF 3
-
-static int handle_start_command(char *cmd);
-
 static void profanity_main(void);
 static void profanity_event_loop(int *ch, char *cmd, int *size);
 
@@ -88,34 +82,3 @@ static void profanity_event_loop(int *ch, char *cmd, int *size)
     // get another character from the command box
     inp_poll_char(ch, cmd, size);
 } 
-
-static int handle_start_command(char *cmd)
-{
-    int result;
-
-    if (strcmp(cmd, "/quit") == 0) {
-        result = QUIT_PROF;
-    } else if (strncmp(cmd, "/help", 5) == 0) {
-        cons_help();
-        inp_clear();
-        result = AWAIT_COMMAND;
-    } else if (strncmp(cmd, "/connect ", 9) == 0) {
-        char *user;
-        user = strndup(cmd+9, strlen(cmd)-9);
-
-        inp_bar_get_password();
-        char passwd[20];
-        inp_get_password(passwd);
-
-        inp_bar_print_message(user);
-        jabber_connect(user, passwd);
-        result = START_MAIN;
-    } else {
-        cons_bad_command(cmd);
-        inp_clear();
-        result = AWAIT_COMMAND;
-    }
-
-    return result;
-}
-