X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fchat.git;a=blobdiff_plain;f=tictactoe.c;h=e9296633522e7f709afaab145ab89c15a5ed525b;hp=cc1dab586c90dd491dfc91c723a64beedf2d9340;hb=HEAD;hpb=fda5401ec167ff1f13aabe4fa0bba5e788ee7cd7 diff --git a/tictactoe.c b/tictactoe.c index cc1dab5..e929663 100644 --- a/tictactoe.c +++ b/tictactoe.c @@ -26,53 +26,33 @@ #include "tcp_connect.h" #include "iksemel_extra.h" #include "xmpp.h" +#include "disco.h" -int -myhook (void *data, int type, iks *stanza) +static void +loop (hc_xmpp_t *xmpp) { - if (!iks_strcmp (iks_name (stanza), "stream:features")) - { - hc_xmpp_features (data, stanza); - if (hc_xmpp_is_tls_supported (data)) - fprintf (stderr, "TLS is supported\n"); - if (hc_xmpp_is_sasl_supported (data)) - fprintf (stderr, "SASL is supported\n"); - } - else - { - fprintf (stderr, "Other: %s\n", iks_string (iks_stack (stanza), stanza)); - } - return IKS_OK; -} - -void -write_stream (hc_xmpp_t *xmpp); -{ - char *buffer = NULL; - asprintf (&buffer, "", xmpp->server); - write (xmpp->fd, buffer, strlen (buffer)); - free (buffer); -} - -void -loop (hc_xmpp_t *xmpp); -{ - char buffer[4096]; - int r; - while ((r = read (xmpp->fd, buffer, sizeof (buffer))) > 0) - iks_parse (xmpp->parser, buffer, r, 0); + while (1) + hc_xmpp_read_and_parse (xmpp); } int main (int argc, char **argv) { - char *server = "jabber-br.org"; + char *server; + char *user; + char *password; hc_xmpp_t *xmpp; + if (argc < 4) + { + printf ("tictactoe server user password\n"); + return 1; + } + server = argv[1]; + user = argv[2]; + password = argv[3]; dns_init (NULL, 1); - xmpp = hc_xmpp_new (myhook, server); - write_stream (xmpp); + xmpp = hc_xmpp_new (hc_xmpp_hook, server, user, password); + hc_xmpp_send_stream (xmpp); loop (xmpp); return 0; }