mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
parser: next*Buffer -> set*Buffer, added setParse*Buffer2, added PSYC_ prefix to macro
This commit is contained in:
parent
56fdfe2cd7
commit
5bbcda7da0
4 changed files with 70 additions and 42 deletions
|
@ -23,11 +23,13 @@ int main(int argc, char **argv)
|
|||
write(1, buffer, idx);
|
||||
write(1, ">> PARSE\n", 9);
|
||||
}
|
||||
|
||||
if (routing_only)
|
||||
psyc_initParseState2(&state, PSYC_PARSE_ROUTING_ONLY);
|
||||
else
|
||||
psyc_initParseState(&state);
|
||||
psyc_nextParseBuffer(&state, psyc_newString(buffer, idx));
|
||||
|
||||
psyc_setParseBuffer(&state, psyc_newString(buffer, idx));
|
||||
|
||||
// try parsing that now
|
||||
// while ((ret = psyc_parse(&state, &oper, &name, &value)))
|
||||
|
@ -58,8 +60,10 @@ int main(int argc, char **argv)
|
|||
{
|
||||
if (verbose)
|
||||
write(1, ">>> LIST START\n", 15);
|
||||
|
||||
psyc_initParseListState(&listState);
|
||||
psyc_nextParseListBuffer(&listState, value);
|
||||
psyc_setParseListBuffer(&listState, value);
|
||||
|
||||
while ((ret = psyc_parseList(&listState, &name, &value, &elem)))
|
||||
{
|
||||
switch (ret)
|
||||
|
|
|
@ -161,6 +161,7 @@ int main(int argc, char **argv)
|
|||
psyc_initParseState2(&parsers[newfd], PSYC_PARSE_ROUTING_ONLY);
|
||||
else
|
||||
psyc_initParseState(&parsers[newfd]);
|
||||
|
||||
memset(&packets[newfd], 0, sizeof(psycPacket));
|
||||
memset(&routing[newfd], 0, sizeof(psycModifier) * ROUTING_LINES);
|
||||
memset(&entity[newfd], 0, sizeof(psycModifier) * ENTITY_LINES);
|
||||
|
@ -188,7 +189,7 @@ int main(int argc, char **argv)
|
|||
} else {
|
||||
// we got some data from a client
|
||||
parsebuf = recvbuf - contbytes;
|
||||
psyc_nextParseBuffer(&parsers[i], psyc_newString(parsebuf, contbytes + nbytes));
|
||||
psyc_setParseBuffer(&parsers[i], psyc_newString(parsebuf, contbytes + nbytes));
|
||||
contbytes = 0;
|
||||
oper = 0;
|
||||
name.length = 0;
|
||||
|
@ -198,6 +199,7 @@ int main(int argc, char **argv)
|
|||
ret = psyc_parse(&parsers[i], &oper, &name, &value);
|
||||
if (verbose)
|
||||
printf("# ret = %d\n", ret);
|
||||
|
||||
switch (ret) {
|
||||
case PSYC_PARSE_ROUTING:
|
||||
assert(packets[i].routing.lines < ROUTING_LINES);
|
||||
|
@ -299,8 +301,10 @@ int main(int argc, char **argv)
|
|||
if (pname->length >= 5 && memcmp(pname->ptr, "_list", 5) == 0) {
|
||||
if (verbose)
|
||||
printf("## LIST START\n");
|
||||
|
||||
psyc_initParseListState(&listState);
|
||||
psyc_nextParseListBuffer(&listState, *pvalue);
|
||||
psyc_setParseListBuffer(&listState, *pvalue);
|
||||
|
||||
do {
|
||||
retl = psyc_parseList(&listState, pname, pvalue, &elem);
|
||||
switch (retl) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue