mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 22:55:11 +00:00
[ADD/WIP] Basic XEP-0393 support.
Still needs lots of work. Did I fail to mention I _hate_ HTML?
This commit is contained in:
parent
94cba7acf0
commit
771c3271ad
10 changed files with 473 additions and 9 deletions
64
src/Streams/Writer.c
Normal file
64
src/Streams/Writer.c
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#include <StringStream.h>
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Stream.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
#include <Cytoplasm/Io.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static ssize_t
|
||||
ReadStreamWriter(void *coop, void *to, size_t n)
|
||||
{
|
||||
/* Reading from a stream writer is silly. */
|
||||
return 0;
|
||||
}
|
||||
static ssize_t
|
||||
WriteStreamWriter(void *coop, void *from, size_t n)
|
||||
{
|
||||
char **cook = coop;
|
||||
char *tmp = NULL;
|
||||
char *str = Malloc(n + 1);
|
||||
|
||||
memcpy(str, from, n);
|
||||
str[n] = '\0';
|
||||
|
||||
tmp = *cook;
|
||||
*cook = StrConcat(2, *cook, str);
|
||||
Free(tmp);
|
||||
Free(str);
|
||||
return 0;
|
||||
}
|
||||
static off_t
|
||||
SeekStreamWriter(void *coop, off_t mag, int sgn)
|
||||
{
|
||||
/* TODO: Seeking would be useful, though not supported yet. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
CloseStreamWriter(void *coop)
|
||||
{
|
||||
/* Nothing to free as of now. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
const static IoFunctions Functions = {
|
||||
.read = ReadStreamWriter,
|
||||
.seek = SeekStreamWriter,
|
||||
.write = WriteStreamWriter,
|
||||
.close = CloseStreamWriter,
|
||||
};
|
||||
|
||||
Stream *
|
||||
StrStreamWriter(char **buffer)
|
||||
{
|
||||
Io *raw_io;
|
||||
if (!buffer)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
raw_io = IoCreate(buffer, Functions);
|
||||
return StreamIo(raw_io);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue