summaryrefslogtreecommitdiffstats
path: root/daemon/fromd
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/fromd')
-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"