X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fchat.git;a=blobdiff_plain;f=tictactoe.c;h=af9de7c110d0807cca052a32baf9d73ab17d65d1;hp=700a269f0a8e14a5ca14f3259a6703e37d324ca3;hb=2dd07de4ac61aea2ce976ea0841d597d8801b139;hpb=fee0c9537ee0b8dc497fd789d0c20e5db09766a8 diff --git a/tictactoe.c b/tictactoe.c index 700a269..af9de7c 100644 --- a/tictactoe.c +++ b/tictactoe.c @@ -26,44 +26,9 @@ #include "tcp_connect.h" #include "iksemel_extra.h" #include "xmpp.h" -#include "sasl.h" +#include "disco.h" -int -myhook (void *data, int type, iks *stanza) -{ - if (!iks_strcmp (iks_name (stanza), "stream:features")) - { - hc_xmpp_features (data, stanza); - if (hc_xmpp_is_sasl_supported (data)) - { - hc_xmpp_sasl_authenticate (data); - } - } - else if (!iks_strcmp (iks_find_attrib (stanza, "xmlns"), HC_XMPP_NS_SASL)) - { - hc_xmpp_sasl_iterate (data, stanza); - if (hc_xmpp_status (data) == HC_XMPP_AUTHENTICATED) - fprintf (stdout, "Authenticated\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, "", hc_xmpp_server (xmpp)); - hc_xmpp_send_buffer (xmpp, buffer, 0); - free (buffer); -} - -void +static void loop (hc_xmpp_t *xmpp) { while (1) @@ -78,8 +43,8 @@ main (int argc, char **argv) char *password = "pubsub"; hc_xmpp_t *xmpp; dns_init (NULL, 1); - xmpp = hc_xmpp_new (myhook, server, user, password); - write_stream (xmpp); + xmpp = hc_xmpp_new (hc_xmpp_hook, server, user, password); + hc_xmpp_send_stream (xmpp); loop (xmpp); return 0; }