Added support for a message hook and simple message sending
[cascardo/chat.git] / tictactoe.c
1 /*
2  *  Copyright (C) 2008  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along
15  *  with this program; if not, write to the Free Software Foundation, Inc.,
16  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19
20 #define _GNU_SOURCE
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <udns.h>
24 #include <unistd.h>
25 #include <string.h>
26 #include "tcp_connect.h"
27 #include "iksemel_extra.h"
28 #include "xmpp.h"
29 #include "disco.h"
30
31 static void
32 loop (hc_xmpp_t *xmpp)
33 {
34   while (1)
35     hc_xmpp_read_and_parse (xmpp);
36 }
37
38 int
39 main (int argc, char **argv)
40 {
41   char *server;
42   char *user;
43   char *password;
44   hc_xmpp_t *xmpp;
45   if (argc < 4)
46     {
47       printf ("tictactoe server user password\n");
48       return 1;
49     }
50   server = argv[1];
51   user = argv[2];
52   password = argv[3];
53   dns_init (NULL, 1);
54   xmpp = hc_xmpp_new (hc_xmpp_hook, server, user, password);
55   hc_xmpp_send_stream (xmpp);
56   loop (xmpp);
57   return 0;
58 }