mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:35:10 +00:00
[ADD/WIP] Matrix<->XMPP DMs.
There is still this fun issue with the blocking XML parser leaking memory on pthread_cancel, I'll try to deal with that later, maybe with a test stanza. I also apologise for swearing in the last commit. I promise it won't happen again, Prosody.
This commit is contained in:
parent
bdb4fd2f68
commit
2cc4b0ed17
11 changed files with 325 additions and 63 deletions
|
|
@ -1,9 +1,5 @@
|
|||
#include <XML.h>
|
||||
|
||||
#include <Cytoplasm/Log.h>
|
||||
|
||||
/* TODO: The rest of all that. */
|
||||
|
||||
XMLElement *
|
||||
XMLDecode(Stream *stream, bool autofree)
|
||||
{
|
||||
|
|
@ -27,12 +23,12 @@ XMLDecode(Stream *stream, bool autofree)
|
|||
stack = ArrayCreate();
|
||||
while ((event = XMLCrank(lexer)) && (!ret || ArraySize(stack)))
|
||||
{
|
||||
bool flag = false;
|
||||
switch (event->type)
|
||||
{
|
||||
case XML_LEXER_STARTELEM:
|
||||
/* Create a new element that will populated. */
|
||||
top = XMLCreateTag(event->element);
|
||||
Log(LOG_INFO, "<%s>", top->name);
|
||||
XMLAddChild(peek(), top);
|
||||
while (HashMapIterate(event->attrs, &key, (void **) &val))
|
||||
{
|
||||
|
|
@ -50,7 +46,6 @@ XMLDecode(Stream *stream, bool autofree)
|
|||
/* Create a new element that will populated. */
|
||||
top = XMLCreateTag(event->element);
|
||||
XMLAddChild(peek(), top);
|
||||
Log(LOG_INFO, "<%s />", top->name);
|
||||
while (HashMapIterate(event->attrs, &key, (void **) &val))
|
||||
{
|
||||
XMLAddAttr(top, key, val);
|
||||
|
|
@ -65,11 +60,25 @@ XMLDecode(Stream *stream, bool autofree)
|
|||
/* Fallthrough */
|
||||
case XML_LEXER_ENDELEM:
|
||||
/* Pop out an element out of the DOM. */
|
||||
Log(LOG_INFO, "</>");
|
||||
pop();
|
||||
if (!ArraySize(stack))
|
||||
{
|
||||
XMLFreeEvent(event);
|
||||
event = NULL;
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XML_LEXER_DATA:
|
||||
top = XMLCreateText(event->data);
|
||||
XMLAddChild(peek(), top);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
break;
|
||||
}
|
||||
XMLFreeEvent(event);
|
||||
event = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -658,8 +658,6 @@ XMLParseAttQuote(XMLexer *lexer)
|
|||
|
||||
point = XMLInitialiseBuffer(lexer);
|
||||
|
||||
/* TODO: My Prosody is actually trolling me.
|
||||
* GIVE ME A FUCKING STREAM ID YOU RETARD. */
|
||||
while ((c = XMLGetc(lexer)))
|
||||
{
|
||||
if (!IsNormalQ(c))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue