about summary refs log tree commit diff stats
path: root/profanity.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-02-09 23:15:53 +0000
committerJames Booth <boothj5@gmail.com>2012-02-09 23:15:53 +0000
commita7df149ee901310ad8ac89fa2ddbd52f9c8d9e70 (patch)
tree5c150f4243cdad7be3105b3ac0238bd55189d335 /profanity.c
parentdbfb1551d6ec1fd7efdd2b62117c9dae49cc68ce (diff)
downloadprofani-tty-a7df149ee901310ad8ac89fa2ddbd52f9c8d9e70.tar.gz
Pulled out command module
Diffstat (limited to 'profanity.c')
-rw-r--r--profanity.c73
1 files changed, 4 insertions, 69 deletions
diff --git a/profanity.c b/profanity.c
index e21bf504..2002810d 100644
--- a/profanity.c
+++ b/profanity.c
@@ -7,14 +7,13 @@
 #include "log.h"
 #include "windows.h"
 #include "jabber.h"
+#include "command.h"
 
 #define AWAIT_COMMAND 1
 #define START_MAIN 2
 #define QUIT_PROF 3
-#define CONTINUE_EVENT_LOOP 4
 
 static int handle_start_command(char *cmd);
-static int handle_main_command(char *cmd);
 
 static void profanity_main(void);
 static void profanity_event_loop(int *ch, char *cmd, int *size);
@@ -36,10 +35,10 @@ void profanity_start(void)
 
 static void profanity_main(void)
 {
-    int cmd_result = CONTINUE_EVENT_LOOP;
+    int cmd_result = TRUE;
 
     inp_non_block();
-    while(cmd_result == CONTINUE_EVENT_LOOP) {
+    while(cmd_result == TRUE) {
         int ch = ERR;
         char cmd[100];
         int size = 0;
@@ -48,7 +47,7 @@ static void profanity_main(void)
             profanity_event_loop(&ch, cmd, &size);
 
         cmd[size++] = '\0';
-        cmd_result = handle_main_command(cmd);
+        cmd_result = handle_command(cmd);
     }
 
     jabber_disconnect();
@@ -118,67 +117,3 @@ static int handle_start_command(char *cmd)
     return result;
 }
 
-static int handle_main_command(char *cmd)
-{
-    int result;
-
-    // /quit command -> exit
-    if (strcmp(cmd, "/quit") == 0) {
-        result = QUIT_PROF;
-
-    // /help -> print help to console
-    } else if (strncmp(cmd, "/help", 5) == 0) {
-        cons_help();
-        inp_clear();
-        result = CONTINUE_EVENT_LOOP;
-
-    // /who -> request roster
-    } else if (strncmp(cmd, "/who", 4) == 0) {
-        jabber_roster_request();
-        inp_clear();
-        result = CONTINUE_EVENT_LOOP;
-
-    // /msg -> send message to a user
-    } else if (strncmp(cmd, "/msg ", 5) == 0) {
-        char *usr_msg = NULL;
-        char *usr = NULL;
-        char *msg = NULL;
-        
-        usr_msg = strndup(cmd+5, strlen(cmd)-5);
-        usr = strtok(usr_msg, " ");
-        if (usr != NULL) {
-            msg = strndup(cmd+5+strlen(usr)+1, strlen(cmd)-(5+strlen(usr)+1));
-            if (msg != NULL) {
-                jabber_send(msg, usr);
-                show_outgoing_msg("me", usr, msg);
-            }
-        }
-        inp_clear();
-        result = CONTINUE_EVENT_LOOP;
-
-    // /close -> close the current chat window, if in chat
-    } else if (strncmp(cmd, "/close", 6) == 0) {
-        if (in_chat()) {
-            close_win();
-        } else {
-            cons_bad_command(cmd);
-        }
-        inp_clear();
-        result = CONTINUE_EVENT_LOOP;
-
-    // send message to recipient, if in chat
-    } else {
-        if (in_chat()) {
-            char recipient[100] = "";
-            get_recipient(recipient);
-            jabber_send(cmd, recipient);
-            show_outgoing_msg("me", recipient, cmd);
-        } else {
-            cons_bad_command(cmd);
-        }
-        inp_clear();
-        result = CONTINUE_EVENT_LOOP;
-    }
-
066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#!/bin/sh -eu

# Check if another config is being used.
set +u
if [ -z $TUP_CONFIG ];
then
	. ./tup.config
else
	. ./$TUP_CONFIG
fi
set -u

echo "Cleaning Project..."
set -x
rm -rf $CONFIG_BUILD_DIR
rm -rf app/
rm -rf build-dir
rm -rf flatpak_repo
rm -rf .flatpak-builder/
rm -rf -- *.txz
set +x
echo "Done."