mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 19:55:10 +00:00
[ADD] Make and start using an XML encoder
Now, we have basic sanitation!!!!!!
This commit is contained in:
parent
c8b3ec8203
commit
b408cbf224
4 changed files with 110 additions and 19 deletions
|
|
@ -1,29 +1,35 @@
|
|||
#include <XMPP.h>
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
|
||||
#include <XML.h>
|
||||
|
||||
void
|
||||
XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type)
|
||||
{
|
||||
XMLElement *message, *body, *data;
|
||||
char *from;
|
||||
if (!comp || !fr || !to || !msg)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StreamPrintf(
|
||||
comp->stream, "<message from='%s@%s' to='%s'",
|
||||
fr, comp->host, to
|
||||
);
|
||||
if (type)
|
||||
{
|
||||
StreamPrintf(comp->stream, " type='%s'", type);
|
||||
}
|
||||
StreamPrintf(comp->stream, ">");
|
||||
StreamPrintf(comp->stream,
|
||||
"<body>"
|
||||
"%s"
|
||||
"</body>"
|
||||
"</message>",
|
||||
msg
|
||||
);
|
||||
|
||||
message = XMLCreateTag("message");
|
||||
XMLAddAttr(message, "from", (from = StrConcat(3, fr, "@", comp->host)));
|
||||
XMLAddAttr(message, "to", to);
|
||||
XMLAddAttr(message, "type", type);
|
||||
|
||||
body = XMLCreateTag("body");
|
||||
data = XMLCreateText(msg);
|
||||
|
||||
XMLAddChild(message, body);
|
||||
XMLAddChild(body, data);
|
||||
|
||||
XMLEncode(comp->stream, message);
|
||||
StreamFlush(comp->stream);
|
||||
XMLFreeElement(message);
|
||||
Free(from);
|
||||
}
|
||||
void
|
||||
XMPPSendPresence(XMPPComponent *comp, char *fr, char *to)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue