mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:15:10 +00:00
[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:
parent
0815834d7d
commit
a1a0d9c880
2 changed files with 73 additions and 6 deletions
17
src/XML/Parser.c
Normal file
17
src/XML/Parser.c
Normal 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. */
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,12 @@
|
||||||
#include <XMPP.h>
|
#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>
|
#include <XML.h>
|
||||||
|
|
||||||
/* TODO: Write the stream system once we have our XML implementation
|
/* TODO: Write the stream system once we have our XML implementation
|
||||||
|
|
@ -15,9 +22,53 @@ Stream *
|
||||||
XMPPInitialiseCompStream(char *host, int port)
|
XMPPInitialiseCompStream(char *host, int port)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* TODO */
|
||||||
(void) host;
|
int sd = -1;
|
||||||
(void) port;
|
struct addrinfo hints, *res, *res0;
|
||||||
return NULL;
|
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
|
bool
|
||||||
|
|
@ -26,12 +77,11 @@ XMPPAuthenticateCompStream(Stream *stream, char *shared)
|
||||||
/* TODO */
|
/* TODO */
|
||||||
(void) stream;
|
(void) stream;
|
||||||
(void) shared;
|
(void) shared;
|
||||||
return NULL;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XMPPEndCompStream(Stream *stream)
|
XMPPEndCompStream(Stream *stream)
|
||||||
{
|
{
|
||||||
(void) stream;
|
StreamClose(stream);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue