From 92e58a71d62d05a505d97f49aca4809e572a13aa Mon Sep 17 00:00:00 2001 From: wens Date: Tue, 8 Apr 2008 03:23:33 +0000 Subject: Added fromd test client Clean headers git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4096 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- daemon/fromd/Makefile | 5 ++++- daemon/fromd/fromc.c | 38 ++++++++++++++++++++++++++++++++++++++ daemon/fromd/fromd.c | 3 ++- daemon/fromd/ip_desc_db.c | 2 -- 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 daemon/fromd/fromc.c (limited to 'daemon') diff --git a/daemon/fromd/Makefile b/daemon/fromd/Makefile index 5e3e9aaa..054f9224 100644 --- a/daemon/fromd/Makefile +++ b/daemon/fromd/Makefile @@ -2,7 +2,7 @@ SRCROOT= ../.. .include "$(SRCROOT)/pttbbs.mk" -PROGRAMS= fromd +PROGRAMS= fromd fromc LDLIBS+= $(SRCROOT)/common/sys/libcmsys.a \ $(SRCROOT)/common/bbs/libcmbbs.a @@ -18,5 +18,8 @@ all: ${PROGRAMS} fromd: fromd.o ip_desc_db.o ${CC} ${CFLAGS} ${LDFLAGS} -levent -o $@ $> $(LDLIBS) +fromc: fromc.o + ${CC} ${CFLAGS} ${LDFLAGS} -o $@ $> $(LDLIBS) + clean: rm -f *~ ${PROGRAMS} fromd.o ip_desc_db.o diff --git a/daemon/fromd/fromc.c b/daemon/fromd/fromc.c new file mode 100644 index 00000000..1a5cb6b1 --- /dev/null +++ b/daemon/fromd/fromc.c @@ -0,0 +1,38 @@ +// $Id$ +#include +#include +#include + +#include "bbs.h" + +// standalone client to test fromd + +int main(int argc, char *argv[]) +{ + int port, fd; + char buf[64]; + + if (argc < 4) { + fprintf(stderr, "Usage: %s ip port lookup_ip\n", argv[0]); + return 0; + } + + if ( (port = atoi(argv[2])) == 0 ) { + fprintf(stderr, "Port given is not valid\n"); + return 1; + } + + if ( (fd = toconnect(argv[1], port)) < 0 ) { + perror("toconnect"); + return 1; + } + + write(fd, argv[2], strlen(argv[2])); + read(fd, buf, sizeof(buf)); + + printf("%s\n", buf); + + return 0; +} + + diff --git a/daemon/fromd/fromd.c b/daemon/fromd/fromd.c index c8fb0b06..04f357e6 100644 --- a/daemon/fromd/fromd.c +++ b/daemon/fromd/fromd.c @@ -1,5 +1,6 @@ // $Id$ #include +#include #include #include #include @@ -74,7 +75,7 @@ void daemonize() int main(int argc, char *argv[]) { - int ch, port = 5120, sfd; + int ch, port = 5130, sfd; char *iface_ip = NULL; Signal(SIGPIPE, SIG_IGN); diff --git a/daemon/fromd/ip_desc_db.c b/daemon/fromd/ip_desc_db.c index 137e5fa7..9a399bcb 100644 --- a/daemon/fromd/ip_desc_db.c +++ b/daemon/fromd/ip_desc_db.c @@ -2,8 +2,6 @@ #include #include #include -#include -#include #include #include "bbs.h" -- cgit v1.2.3