Fix build for tarball
[cascardo/f2fchat.git] / f2fchat.c
index 55bdc5a..05e6a5b 100644 (file)
--- a/f2fchat.c
+++ b/f2fchat.c
  */
 
 #include "friend.h"
+#include <glib.h>
+#include <stdio.h>
+#include "menu.h"
+
+static GMainLoop *uloop;
+
+static void quit(gchar **args, GSocketAddress *address)
+{
+       g_main_loop_quit(uloop);
+}
+
+static struct menu_item quit_menu = { "quit", quit };
+
+static void add_quit_cmd(GMainLoop *loop)
+{
+       uloop = loop;
+       menu_add(&quit_menu);
+}
 
 int main(int argc, char **argv)
 {
        struct cache *cache;
-       int out = 0;
+       GMainLoop *loop;
+       g_type_init();
+       if (sock_init()) {
+               fprintf(stderr, "Error creating socket.\n");
+               return 1;
+       }
+       friend_init();
        create_cache(&cache);
        load_cache(cache, "friends.cache");
-       while (!out) {
-               out = 1;
-       }
+       loop = g_main_loop_new(g_main_context_default(), TRUE);
+       add_quit_cmd(loop);
+       g_main_loop_run(loop);
        store_cache(cache, "friends.cache");
        destroy_cache(cache);
        return 0;