[ADD/WIP] Continue MUCwerk

oh man this is gonna be painful to do... xmpp is fine iff youre doing
DMs isnt it?
This commit is contained in:
LDA 2024-06-21 00:48:27 +02:00
commit d3b7f2fee0
19 changed files with 707 additions and 44 deletions

View file

@ -110,3 +110,24 @@ XMLFreeElement(XMLElement *element)
Free(element);
}
XMLElement *
XMLookForUnique(XMLElement *parent, char *tag)
{
size_t i;
if (!parent || !tag)
{
return NULL;
}
for (i = 0; i < ArraySize(parent->children); i++)
{
XMLElement *child = ArrayGet(parent->children, i);
if (StrEquals(child->name, tag))
{
return child;
}
}
return NULL;
}

View file

@ -4,6 +4,7 @@
#include <Cytoplasm/Memory.h>
#include <Cytoplasm/Array.h>
#include <Cytoplasm/Str.h>
#include <Cytoplasm/Log.h>
#include <string.h>
#include <ctype.h>
@ -122,6 +123,7 @@ XMLCrank(XMLexer *lexer)
{
XMLEvent *event = NULL;
char c;
int ch;
char *attrname;
HashMap *props;
char *key, *val;
@ -136,6 +138,7 @@ XMLCrank(XMLexer *lexer)
return NULL;
}
event = XMLCreateRelax(lexer);
switch (lexer->state)
{
case XML_STATE_NONE:
@ -235,6 +238,10 @@ XMLCrank(XMLexer *lexer)
event = XMLCreateStart(lexer, props);
break;
}
else if (XMLookahead(lexer, "'", true))
{
while (true);
}
break;
case XML_STATE_ATTRTAIL:
attrname = XMLParseName(lexer);
@ -490,7 +497,7 @@ HashMap *
XMLReadProps(XMLexer *lexer)
{
ssize_t point = XMLInitialiseBuffer(lexer);
HashMap *map = HashMapCreate();
HashMap *map = NULL;
bool error = false;
while (true)
{
@ -523,10 +530,14 @@ XMLReadProps(XMLexer *lexer)
break;
}
}
if (!map)
{
map = HashMapCreate();
}
HashMapSet(map, name, value);
Free(name);
}
if (error)
if (error || !map)
{
XMLReset(lexer, point);
}
@ -660,7 +671,20 @@ XMLParseAttQuote(XMLexer *lexer)
while ((c = XMLGetc(lexer)))
{
if (!IsNormalQ(c))
if (c == '&')
{
char *code = NULL;
int c2;
int p2 = XMLInitialiseBuffer(lexer);
while ((c2 = XMLGetc(lexer)))
{
if (c2 == ';')
{
break;
}
}
}
else if (!IsNormalQ(c))
{
break;
}
@ -687,7 +711,21 @@ XMLParseAttDouble(XMLexer *lexer)
while ((c = XMLGetc(lexer)))
{
if (!IsNormalD(c))
if (c == '&')
{
char *code = NULL;
int c2;
int p2 = XMLInitialiseBuffer(lexer);
while ((c2 = XMLGetc(lexer)))
{
if (c2 == ';')
{
break;
}
}
continue;
}
else if (!IsNormalD(c))
{
break;
}