mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
fixes & test for rendering
This commit is contained in:
parent
f4791db17c
commit
0ee3404bda
6 changed files with 75 additions and 25 deletions
|
@ -1,11 +1,40 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "../include/psyc/lib.h"
|
||||
#include "../include/psyc/render.h"
|
||||
|
||||
#define myUNI "psyc://10.100.1000/~ludwig"
|
||||
|
||||
/* example renderer generating a presence packet */
|
||||
int writePresence(const char *avail, int availlen, const char *desc, int desclen) {
|
||||
int writePresence(const char *avail, int availlen, const char *desc, int desclen)
|
||||
{
|
||||
PSYC_Modifier routing[] = {
|
||||
PSYC_newModifier2(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_source"), PSYC_C2ARG(myUNI),
|
||||
PSYC_MODIFIER_ROUTING),
|
||||
PSYC_newModifier2(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_context"), PSYC_C2ARG(myUNI),
|
||||
PSYC_MODIFIER_CHECK_LENGTH),
|
||||
};
|
||||
|
||||
PSYC_Modifier entity[] = {
|
||||
// presence is to be assigned permanently in distributed state
|
||||
PSYC_newModifier2(C_GLYPH_OPERATOR_ASSIGN, PSYC_C2ARG("_degree_availability"),
|
||||
avail, availlen, PSYC_PACKET_CHECK_LENGTH),
|
||||
PSYC_newModifier2(C_GLYPH_OPERATOR_ASSIGN, PSYC_C2ARG("_description_presence"),
|
||||
desc, desclen, PSYC_PACKET_CHECK_LENGTH),
|
||||
};
|
||||
|
||||
PSYC_Packet packet = PSYC_newPacket2(routing, PSYC_NUM_ELEM(routing),
|
||||
entity, PSYC_NUM_ELEM(entity),
|
||||
PSYC_C2ARG("_notice_presence"),
|
||||
NULL, 0,
|
||||
//PSYC_C2ARG("foobar"),
|
||||
PSYC_PACKET_CHECK_LENGTH);
|
||||
|
||||
char buffer[512];
|
||||
PSYC_render(&packet, buffer, sizeof(buffer));
|
||||
write(0, buffer, packet.length);
|
||||
|
||||
/*
|
||||
PSYC_RenderState *pb; // a chunk of mem will host both struct and buf1
|
||||
// char *t;
|
||||
// unsigned int l;
|
||||
|
@ -33,10 +62,11 @@ int writePresence(const char *avail, int availlen, const char *desc, int desclen
|
|||
// (void) PSYC_doneRender(pb, &t, &l);
|
||||
// write(stdout, t, l);
|
||||
free(pb);
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
return writePresence("_here", 0, "I'm omnipresent right now", 0);
|
||||
return writePresence(PSYC_C2ARG("_here"), PSYC_C2ARG("I'm omnipresent right now"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue