mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
isRoutingVar, rendering, some renames
This commit is contained in:
parent
893a318b82
commit
4f86b6916b
13 changed files with 326 additions and 172 deletions
|
@ -1,7 +1,7 @@
|
|||
CFLAGS=-I../include -DDEBUG -g -O0 -Wall
|
||||
LDFLAGS=-L../src
|
||||
LOADLIBES=-lpsyc
|
||||
TARGETS=testParser testMatch testRender
|
||||
TARGETS=testParser testMatch testRender isRoutingVar
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
|
|
26
test/isRoutingVar.c
Normal file
26
test/isRoutingVar.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include <psyc.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
char* vars[] =
|
||||
{
|
||||
"_source",
|
||||
"_source_relay",
|
||||
"_source_foo",
|
||||
"_sourcherry",
|
||||
"_foo",
|
||||
"bar",
|
||||
"_",
|
||||
};
|
||||
|
||||
int i;
|
||||
for (i = 0; i < sizeof(vars) / sizeof(*vars); i++)
|
||||
{
|
||||
printf("%s: %d\n", vars[i], PSYC_isRoutingVar(vars[i], strlen(vars[i])));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -21,18 +21,18 @@ int main(int argc, char** argv)
|
|||
write(1, buffer, index);
|
||||
write(1, ">> PARSE\n", 9);
|
||||
|
||||
PSYC_initState(&state);
|
||||
PSYC_nextBuffer(&state, PSYC_createArray(buffer, index));
|
||||
PSYC_initParseState(&state);
|
||||
PSYC_nextParseBuffer(&state, PSYC_createArray(buffer, index));
|
||||
|
||||
// try parsing that now
|
||||
while ((ret = PSYC_parse(&state, &modifier, &name, &value)))
|
||||
{
|
||||
switch (ret)
|
||||
{
|
||||
case PSYC_ROUTING:
|
||||
case PSYC_ENTITY:
|
||||
case PSYC_PARSE_ROUTING:
|
||||
case PSYC_PARSE_ENTITY:
|
||||
write(1, &modifier, 1);
|
||||
case PSYC_BODY:
|
||||
case PSYC_PARSE_BODY:
|
||||
// printf("the string is '%.*s'\n", name);
|
||||
write(1, name.ptr, name.length);
|
||||
write(1, " = ", 3);
|
||||
|
@ -41,14 +41,14 @@ int main(int argc, char** argv)
|
|||
if (memcmp(name.ptr, "_list", 5) == 0)
|
||||
{
|
||||
write(1, ">>> LIST START\n", 15);
|
||||
PSYC_initListState(&listState);
|
||||
PSYC_nextListBuffer(&listState, value);
|
||||
PSYC_initParseListState(&listState);
|
||||
PSYC_nextParseListBuffer(&listState, value);
|
||||
while ((ret = PSYC_parseList(&listState, &name, &value, &elem)))
|
||||
{
|
||||
switch (ret)
|
||||
{
|
||||
case PSYC_LIST_END:
|
||||
case PSYC_LIST_ELEM:
|
||||
case PSYC_PARSE_LIST_END:
|
||||
case PSYC_PARSE_LIST_ELEM:
|
||||
write(1, "|", 1);
|
||||
write(1, elem.ptr, elem.length);
|
||||
write(1, "\n", 1);
|
||||
|
@ -58,7 +58,7 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (ret == PSYC_LIST_END)
|
||||
if (ret == PSYC_PARSE_LIST_END)
|
||||
{
|
||||
write(1, ">>> LIST END\n", 13);
|
||||
break;
|
||||
|
@ -66,10 +66,10 @@ int main(int argc, char** argv)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case PSYC_COMPLETE:
|
||||
case PSYC_PARSE_COMPLETE:
|
||||
printf("Done parsing.\n");
|
||||
continue;
|
||||
case PSYC_INSUFFICIENT:
|
||||
case PSYC_PARSE_INSUFFICIENT:
|
||||
printf("Insufficient data.\n");
|
||||
return 0;
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue