summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-08 11:23:33 +0800
committerwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-08 11:23:33 +0800
commit92e58a71d62d05a505d97f49aca4809e572a13aa (patch)
treee734e7221ede549002d091ad9090c0f0282bd098 /daemon
parent025b412716299fa943df505f4da4fd5cef8eb146 (diff)
downloadpttbbs-92e58a71d62d05a505d97f49aca4809e572a13aa.tar
pttbbs-92e58a71d62d05a505d97f49aca4809e572a13aa.tar.gz
pttbbs-92e58a71d62d05a505d97f49aca4809e572a13aa.tar.bz2
pttbbs-92e58a71d62d05a505d97f49aca4809e572a13aa.tar.lz
pttbbs-92e58a71d62d05a505d97f49aca4809e572a13aa.tar.xz
pttbbs-92e58a71d62d05a505d97f49aca4809e572a13aa.tar.zst
pttbbs-92e58a71d62d05a505d97f49aca4809e572a13aa.zip
Added fromd test client
Clean headers git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4096 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'daemon')
-rw-r--r--daemon/fromd/Makefile5
-rw-r--r--daemon/fromd/fromc.c38
-rw-r--r--daemon/fromd/fromd.c3
-rw-r--r--daemon/fromd/ip_desc_db.c2
4 files changed, 44 insertions, 4 deletions
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 <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#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 <stdio.h>
+#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <signal.h>
@@ -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 <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
#include <arpa/inet.h>
#include "bbs.h"