2 * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
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.
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.
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.
26 #include "tcp_connect.h"
27 #include "iksemel_extra.h"
30 myhook (void *data, int type, iks *stanza)
32 char *s = iks_string (iks_stack (stanza), stanza);
33 write (1, s, strlen (s));
38 write_stream (int fd, char *server)
41 asprintf (&buffer, "<stream:stream xmlns='jabber:client' "
42 "xmlns:stream='http://etherx.jabber.org/streams' "
43 "version='1.0' to='%s'>", server);
44 write (fd, buffer, strlen (buffer));
49 loop (iksparser *parser, int fd)
53 while ((r = read (fd, buffer, sizeof (buffer))) > 0)
54 iks_parse (parser, buffer, r, 0);
58 main (int argc, char **argv)
60 char *server = "jabber-br.org";
64 fd = hc_tcp_connect (server, "xmpp-client");
65 parser = iks_extra_stream_new (NULL, myhook);
66 write_stream (fd, server);