mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
Merge branch 'master' of supraverse.net:libpsyc
This commit is contained in:
commit
ae3fc4c75a
5 changed files with 38 additions and 23 deletions
4
Makefile
4
Makefile
|
@ -17,9 +17,7 @@ testdebug: debug
|
||||||
${MAKE} -C test debug
|
${MAKE} -C test debug
|
||||||
|
|
||||||
test: all
|
test: all
|
||||||
${MAKE} -C test test
|
${MAKE} -C test test nettest
|
||||||
${MAKE} -C test nettest
|
|
||||||
${MAKE} -C test nettestr
|
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
doxygen
|
doxygen
|
||||||
|
|
|
@ -409,6 +409,9 @@ psycParseRC psyc_parse (psycParseState *state, char *oper,
|
||||||
else // Search for the terminator.
|
else // Search for the terminator.
|
||||||
{
|
{
|
||||||
size_t datac = state->cursor; // start of data
|
size_t datac = state->cursor; // start of data
|
||||||
|
if (state->flags & PSYC_PARSE_ROUTING_ONLY)
|
||||||
|
state->startc = datac; // in routing-only mode restart from the start of data
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
uint8_t nl = state->buffer.ptr[state->cursor] == '\n';
|
uint8_t nl = state->buffer.ptr[state->cursor] == '\n';
|
||||||
|
|
|
@ -2,16 +2,18 @@ OPT = -O2
|
||||||
DEBUG = 2
|
DEBUG = 2
|
||||||
CFLAGS = -I../include -Wall -std=c99 ${OPT}
|
CFLAGS = -I../include -Wall -std=c99 ${OPT}
|
||||||
LDFLAGS = -L../lib
|
LDFLAGS = -L../lib
|
||||||
|
LOADLIBES = -lpsyc -lm
|
||||||
|
LOADLIBES_NET = ${LOADLIBES}
|
||||||
TARGETS = testServer testParser testMatch testRender testText isRoutingVar getVarType
|
TARGETS = testServer testParser testMatch testRender testText isRoutingVar getVarType
|
||||||
WRAPPER =
|
WRAPPER =
|
||||||
DIET = diet
|
DIET = diet
|
||||||
PORT = 4440
|
PORT = 4440
|
||||||
|
NC = nc
|
||||||
|
DIFF = diff
|
||||||
|
|
||||||
LOADLIBES = -lpsyc -lm
|
|
||||||
ifeq ($(shell uname),SunOS)
|
ifeq ($(shell uname),SunOS)
|
||||||
LOADLIBES_NET = ${LOADLIBES} -lsocket -lnsl
|
LOADLIBES_NET := ${LOADLIBES_NET} -lsocket -lnsl
|
||||||
else
|
DIFF = gdiff
|
||||||
LOADLIBES_NET = ${LOADLIBES}
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: ${TARGETS}
|
all: ${TARGETS}
|
||||||
|
@ -35,29 +37,32 @@ test: ${TARGETS}
|
||||||
./testText
|
./testText
|
||||||
./isRoutingVar
|
./isRoutingVar
|
||||||
./getVarType
|
./getVarType
|
||||||
for f in packets/[0-9]*; do echo ">> $$f"; ./testParser $$f; done
|
x=0; for f in packets/[0-9]*; do echo ">> $$f"; ./testParser $$f; x=$$((x+$$?)); done; exit $$x
|
||||||
for f in packets/[0-9]*; do echo ">> $$f"; ./testParser $$f -r; done
|
x=0; for f in packets/[0-9]*; do echo ">> $$f"; ./testParser $$f -r; x=$$((x+$$?)); done; exit $$x
|
||||||
|
|
||||||
# test packet parsing & rendering with the test server
|
nettest: nettestfull nettestsplit
|
||||||
nettest: srvstart pkt pktsplit srvkill
|
|
||||||
|
|
||||||
# same test but parse routing headers only
|
nettestrun: srvstart pkt srvkill
|
||||||
nettestr: srvstartr pkt pktsplit srvkill
|
|
||||||
|
nettestfull:
|
||||||
|
${MAKE} nettestrun
|
||||||
|
${MAKE} nettestrun srv_args=r
|
||||||
|
|
||||||
|
nettestsplit:
|
||||||
|
for n in 1 2 3 4 5; do ${MAKE} nettestrun srv_recvbuf=$$n && ${MAKE} nettestrun srv_args=r srv_recvbuf=$$n || exit $$?; done
|
||||||
|
|
||||||
pkt:
|
pkt:
|
||||||
for f in packets/[0-9]*; do echo ">> $$f"; cat $$f | nc localhost ${PORT} | diff -u $$f -; done
|
x=0; for f in packets/[0-9]*; do echo ">> $$f"; cat $$f | nc localhost ${PORT} | ${DIFF} -u $$f -; x=$$((x+$$?)); done; exit $$x
|
||||||
|
|
||||||
pktsplit:
|
pktsplit:
|
||||||
for f in packets/[0-9]*; do echo ">> $$f"; ./splittest.pl $$f ${PORT} | diff -u $$f -; done
|
x=0; for f in packets/[0-9]*; do echo ">> $$f"; ./splittest.pl $$f ${PORT} | ${DIFF} -u $$f -; x=$$((x+$$?)); done; exit $$x
|
||||||
|
|
||||||
pkterr:
|
pkterr:
|
||||||
for f in packets/err-*; do echo ">> $$f"; cat $$f | nc localhost ${PORT}; done
|
for f in packets/err-*; do echo ">> $$f"; cat $$f | nc localhost ${PORT}; done
|
||||||
|
|
||||||
srvstart:
|
srvstart:
|
||||||
./testServer ${PORT} &
|
pkill -x testServer; exit 0
|
||||||
|
./testServer ${PORT} -${srv_args} ${srv_recvbuf} &
|
||||||
srvstartr:
|
|
||||||
./testServer ${PORT} -r &
|
|
||||||
|
|
||||||
srvkill:
|
srvkill:
|
||||||
pkill -x testServer
|
pkill -x testServer
|
||||||
|
|
|
@ -4,8 +4,9 @@ use warnings;
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
$| = 1;
|
$| = 1;
|
||||||
|
|
||||||
print "Usage: splittest.pl <packet file> [<port> [<chunk length> [-v]]]\n" and exit unless @ARGV;
|
print "Usage: splittest.pl <packet file> [[<host>:]<port> [<chunk length> [-v]]]\n" and exit unless @ARGV;
|
||||||
my $port = $ARGV[1] || 4440;
|
my ($host, $port) = $ARGV[1] =~ /^(?:([a-z0-9.-]+):)?(\d+)$/i;
|
||||||
|
$host ||= 'localhost'; $port ||= 4440;
|
||||||
my $length = int($ARGV[2] || 1); $length = 1 if $length < 1;
|
my $length = int($ARGV[2] || 1); $length = 1 if $length < 1;
|
||||||
my $verbose = $ARGV[3];
|
my $verbose = $ARGV[3];
|
||||||
|
|
||||||
|
@ -13,8 +14,7 @@ open FILE, '<', $ARGV[0] or die "$ARGV[0]: $!\n";
|
||||||
my $file = ''; $file .= $_ while <FILE>;
|
my $file = ''; $file .= $_ while <FILE>;
|
||||||
close FILE;
|
close FILE;
|
||||||
|
|
||||||
my $s = IO::Socket::INET->new(Proto => "tcp", PeerAddr => "localhost", PeerPort => $port) or die "localhost:$port: $!\n";
|
my $s = IO::Socket::INET->new(Proto => "tcp", PeerAddr => $host, PeerPort => $port) or die "$host:$port: $!\n";
|
||||||
$s->autoflush(1);
|
|
||||||
|
|
||||||
my $c = 0;
|
my $c = 0;
|
||||||
while ($c < length $file) {
|
while ($c < length $file) {
|
||||||
|
|
|
@ -233,6 +233,11 @@ int main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (verbose >= 2)
|
||||||
|
printf("> %ld bytes\n", nbytes);
|
||||||
|
if (verbose >= 3)
|
||||||
|
printf("> [%.*s]", (int)nbytes, recvbuf);
|
||||||
|
|
||||||
// we got some data from a client
|
// we got some data from a client
|
||||||
parsebuf = recvbuf - contbytes;
|
parsebuf = recvbuf - contbytes;
|
||||||
psyc_setParseBuffer2(&parsers[i], parsebuf, contbytes + nbytes);
|
psyc_setParseBuffer2(&parsers[i], parsebuf, contbytes + nbytes);
|
||||||
|
@ -434,6 +439,10 @@ int main (int argc, char **argv)
|
||||||
case PSYC_PARSE_ROUTING:
|
case PSYC_PARSE_ROUTING:
|
||||||
case PSYC_PARSE_ENTITY:
|
case PSYC_PARSE_ENTITY:
|
||||||
case PSYC_PARSE_ENTITY_END:
|
case PSYC_PARSE_ENTITY_END:
|
||||||
|
oper = 0;
|
||||||
|
name.length = 0;
|
||||||
|
value.length = 0;
|
||||||
|
|
||||||
if (pname->length >= 5 && memcmp(pname->ptr, "_list", 5) == 0)
|
if (pname->length >= 5 && memcmp(pname->ptr, "_list", 5) == 0)
|
||||||
{
|
{
|
||||||
if (verbose >= 2)
|
if (verbose >= 2)
|
||||||
|
|
Loading…
Reference in a new issue