about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-03-01 01:44:47 +0000
committerJames Booth <boothj5@gmail.com>2012-03-01 01:44:47 +0000
commit723a99540d1c3971ea02645c118fda2d1814d88a (patch)
treeb207f738d09d78eaf7db6e62106794505c32021c
parent0dac914813d942ae8c4ad9eaa7ec1d9ce8dceb9a (diff)
downloadprofani-tty-723a99540d1c3971ea02645c118fda2d1814d88a.tar.gz
Tidied initialisation
-rw-r--r--main.c12
-rw-r--r--profanity.c19
-rw-r--r--profanity.h4
3 files changed, 18 insertions, 17 deletions
diff --git a/main.c b/main.c
index a9a8b6b8..97a69391 100644
--- a/main.c
+++ b/main.c
@@ -23,8 +23,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "log.h"
-#include "windows.h"
 #include "profanity.h"
 
 int main(int argc, char **argv)
@@ -47,13 +45,9 @@ int main(int argc, char **argv)
         }
     }
 
-    log_init();
-    gui_init();
-
-    profanity_main(disable_tls);
-        
-    gui_close();
-    log_close();
+    profanity_init(disable_tls);
+    profanity_run();
+    profanity_shutdown();
 
     return 0;
 }
diff --git a/profanity.c b/profanity.c
index a4c571c5..cef0aba5 100644
--- a/profanity.c
+++ b/profanity.c
@@ -32,15 +32,12 @@
 #include "command.h"
 #include "history.h"
 
-static void _profanity_init(int disable_tls);
 static void _profanity_event_loop(int *ch, char *cmd, int *size);
 
-void profanity_main(int disable_tls)
+void profanity_run(void)
 {
     int cmd_result = TRUE;
 
-    _profanity_init(disable_tls);
-
     inp_non_block();
     while(cmd_result == TRUE) {
         int ch = ERR;
@@ -54,15 +51,23 @@ void profanity_main(int disable_tls)
         cmd_result = process_input(inp);
     }
 
-    jabber_disconnect();
 }
 
-static void _profanity_init(int disable_tls)
+void profanity_init(int disable_tls)
 {
+    log_init();
+    gui_init();
     jabber_init(disable_tls);
     history_init();
 }
 
+void profanity_shutdown(void)
+{
+    jabber_disconnect();
+    gui_close();
+    log_close();
+}
+
 static void _profanity_event_loop(int *ch, char *cmd, int *size)
 {
     usleep(1);
@@ -70,4 +75,4 @@ static void _profanity_event_loop(int *ch, char *cmd, int *size)
     jabber_process_events();
     win_handle_switch(ch);
     inp_poll_char(ch, cmd, size);
-} 
+}
diff --git a/profanity.h b/profanity.h
index 6a0999f8..3013ff5b 100644
--- a/profanity.h
+++ b/profanity.h
@@ -23,6 +23,8 @@
 #ifndef PROFANITY_H
 #define PROFANITY_H
 
-void profanity_main(int disable_tls);
+void profanity_init(int disable_tls);
+void profanity_run(void);
+void profanity_shutdown(void);
 
 #endif