Fix build for tarball
[cascardo/f2fchat.git] / f2fchat.c
index 711811c..05e6a5b 100644 (file)
--- a/f2fchat.c
+++ b/f2fchat.c
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#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;
+       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");
+       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;
 }