Author: ArcRiley Date: 2009-01-07 11:34:37 -0500 (Wed, 07 Jan 2009) New Revision: 1433
Modified: trunk/concordance/src/Core.c Log: * replaced asprintf with g_string_printf for windows compatibility * no longer accepts namespace-less <stream> elements Modified: trunk/concordance/src/Core.c =================================================================== --- trunk/concordance/src/Core.c 2009-01-07 05:08:25 UTC (rev 1432) +++ trunk/concordance/src/Core.c 2009-01-07 16:34:37 UTC (rev 1433) @@ -591,10 +591,12 @@ cdef : \*/ conSession* session = (conSession*) s; conCoreObject* self = session->core; - gchar* buff; - gint blen; + GString* buff; gint i; + /* initialize response buffer */ + buff = g_string_new(""); + /* this from http://www.xml.com/pub/a/1999/09/expat/index.html?page=2 */ for (i = 0; i < session->depth; i++) printf(" "); @@ -607,27 +609,38 @@ switch (session->depth) { case 0 : { /* only stream element is valid at depth == 0 */ - if (strcmp(name, "stream") == 0 || strcmp(name, "stream:stream") == 0) { - /* write stream:stream tags + if (strcmp(name, "stream:stream") == 0) { + /* send stream:stream and stream:features - int asprintf (char **strp, - const char *fmt, + void g_string_printf (GString *string, + const gchar *format, ...); */ - blen = asprintf(&buff, - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" - "<stream:stream from=\"%s\" id=\"%s\"" - " xmlns:stream=\"http://etherx.jabber.org/streams\"" - " xmlns=\"jabber:client\">", - "selket.apogean.org", - "1"); - conCore_sessionSend(session, buff, blen); - free(buff); + g_string_printf(buff, + "<?xml version='1.0' encoding='UTF-8'?>" + "<stream:stream xmlns='jabber:client'" + " xmlns:stream='http://etherx.jabber.org/streams'" + " from='%s' id='%s'>" + "<stream:features>" + "<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>" + "<mechanism>DIGEST-MD5</mechanism></mechanisms>" + "</stream:features>", + "selket.apogean.org", "concordance-1"); + conCore_sessionSend(session, buff->str, buff->len); } /* should disconnect here, something other than session was sent */ } } + + /* increase XML depth regardless of element */ session->depth++; + + /* free response buffer before returning + + gchar* g_string_free (GString *string, + gboolean free_segment); + */ + g_string_free(buff, TRUE); } @@ -656,7 +669,7 @@ strn = g_strndup(str, str_len); for (i = 0; i < session->depth; i++) printf(" "); - printf("%s\n", strn); + printf("\"%s\"\n", strn); g_free(strn); } _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn