mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
render: restructuring into more functions, added some docs
This commit is contained in:
parent
07d7a3f776
commit
ec69b5ee3f
4 changed files with 160 additions and 97 deletions
|
@ -1,29 +1,30 @@
|
|||
#include <psyc.h>
|
||||
#include <psyc/parser.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
#include <psyc/lib.h>
|
||||
#include <psyc/parser.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int indx, ret, verbose = argc > 2;
|
||||
int idx, ret, verbose = argc > 2;
|
||||
char buffer[2048], oper;
|
||||
psycString name, value, elem;
|
||||
psycParseState state;
|
||||
psycParseListState listState;
|
||||
|
||||
int file = open(argv[1],O_RDONLY);
|
||||
if(file < 0)
|
||||
if (file < 0)
|
||||
return -1;
|
||||
indx = read(file,(void*)buffer,sizeof(buffer));
|
||||
idx = read(file,(void*)buffer,sizeof(buffer));
|
||||
|
||||
if (verbose) {
|
||||
write(1, ">> INPUT\n", 9);
|
||||
write(1, buffer, indx);
|
||||
write(1, buffer, idx);
|
||||
write(1, ">> PARSE\n", 9);
|
||||
}
|
||||
psyc_initParseState(&state);
|
||||
psyc_nextParseBuffer(&state, psyc_newString(buffer, indx));
|
||||
psyc_nextParseBuffer(&state, psyc_newString(buffer, idx));
|
||||
|
||||
// try parsing that now
|
||||
// while ((ret = psyc_parse(&state, &oper, &name, &value)))
|
||||
|
|
|
@ -23,10 +23,10 @@ int testPresence(const char *avail, int availlen, const char *desc, int desclen,
|
|||
};
|
||||
|
||||
psycPacket packet = psyc_newPacket2(routing, PSYC_NUM_ELEM(routing),
|
||||
entity, PSYC_NUM_ELEM(entity),
|
||||
PSYC_C2ARG("_notice_presence"),
|
||||
NULL, 0,
|
||||
PSYC_PACKET_CHECK_LENGTH);
|
||||
entity, PSYC_NUM_ELEM(entity),
|
||||
PSYC_C2ARG("_notice_presence"),
|
||||
NULL, 0,
|
||||
PSYC_PACKET_CHECK_LENGTH);
|
||||
|
||||
char buffer[512];
|
||||
psyc_render(&packet, buffer, sizeof(buffer));
|
||||
|
@ -68,7 +68,7 @@ int testList(const char *rendered, uint8_t verbose)
|
|||
psyc_newModifier2(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_list_text"),
|
||||
buf_text, list_text.length, list_text.flag),
|
||||
psyc_newModifier2(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_list_binary"),
|
||||
buf_bin, list_bin.length, list_text.flag),
|
||||
buf_bin, list_bin.length, list_bin.flag),
|
||||
};
|
||||
|
||||
psycPacket packet = psyc_newPacket2(routing, PSYC_NUM_ELEM(routing),
|
||||
|
@ -84,7 +84,7 @@ int testList(const char *rendered, uint8_t verbose)
|
|||
return strncmp(rendered, buffer, packet.length);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(int argc, char **argv) {
|
||||
uint8_t verbose = argc > 1;
|
||||
|
||||
if (testPresence(PSYC_C2ARG("_here"), PSYC_C2ARG("I'm omnipresent right now"), "\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue