[MOD] Continue XM{PP,L}werk.

I think I'll actually geninuely start my break as soon as I'm finished
with the encoder/decoder(given our current SAX lexer).
This commit is contained in:
LDA 2024-06-15 14:51:12 +02:00
commit a1a0d9c880
2 changed files with 73 additions and 6 deletions

17
src/XML/Parser.c Normal file
View file

@ -0,0 +1,17 @@
#include <XML.h>
/* TODO: The rest of all that. */
XMLElement *
XMLDecode(Stream *stream, bool autofree)
{
/* TODO: Use the existing SAX parser to decode everything */
return NULL;
}
void
XMLEncode(Stream *stream, XMLElement *element)
{
/* TODO: Write the entire XML element. This shouldn't be
* too hard. */
}

View file

@ -1,5 +1,12 @@
#include <XMPP.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <netdb.h>
#include <XML.h>
/* TODO: Write the stream system once we have our XML implementation
@ -15,9 +22,53 @@ Stream *
XMPPInitialiseCompStream(char *host, int port)
{
/* TODO */
(void) host;
(void) port;
return NULL;
int sd = -1;
struct addrinfo hints, *res, *res0;
int error;
char serv[8];
Stream *stream;
snprintf(serv, sizeof(serv), "%hu", port);
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(host, serv, &hints, &res0);
for (res = res0; res; res = res->ai_next)
{
sd = socket(res->ai_family, res->ai_socktype,
res->ai_protocol);
if (sd < 0)
{
continue;
}
if (connect(sd, res->ai_addr, res->ai_addrlen) < 0)
{
close(sd);
sd = -1;
continue;
}
break;
}
if (sd < 0)
{
return NULL;
}
freeaddrinfo(res0);
stream = StreamFd(sd);
if (!stream)
{
close(sd);
return NULL;
}
return stream;
}
bool
@ -26,12 +77,11 @@ XMPPAuthenticateCompStream(Stream *stream, char *shared)
/* TODO */
(void) stream;
(void) shared;
return NULL;
return false;
}
void
XMPPEndCompStream(Stream *stream)
{
(void) stream;
return NULL;
StreamClose(stream);
}