summaryrefslogtreecommitdiff
path: root/comm/OLD/porttest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'comm/OLD/porttest.cc')
-rw-r--r--comm/OLD/porttest.cc72
1 files changed, 72 insertions, 0 deletions
diff --git a/comm/OLD/porttest.cc b/comm/OLD/porttest.cc
new file mode 100644
index 0000000..c73268d
--- /dev/null
+++ b/comm/OLD/porttest.cc
@@ -0,0 +1,72 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1990-1993
+ * Laboratoire de Recherche en Informatique (LRI)
+ *
+ * Port server: test program
+ *
+ * $Id$
+ * $CurLog$
+ */
+
+#include "PortServer.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+int
+fMatch (const char* match, lword host, sword port, const char*)
+{
+ printf ("0x%lx:%d -> %s\n", host, port, match);
+ return 1;
+}
+
+main (int argc, char **argv)
+{
+ char *host = 0;
+ char *service = "portserv";
+
+ if (argc > 1 && argv [1] [0] == ':') {
+ host = argv [1] + 1;
+ argc--, argv++;
+ }
+ if (argc > 1 && argv [1] [0] == '=') {
+ service = argv [1] + 1;
+ argc--, argv++;
+ }
+ UchPortServer ps (service, host);
+
+ switch (argc) {
+ case 1:
+ ps.Dump ();
+ break;
+ case 2:
+ if (strcmp (argv [1], "quit") == 0)
+ ps.Quit ();
+ else
+ if (argv [1] [0] == '?')
+ ps.Match (argv [1] + 1, fMatch);
+ else {
+ UchInetAddress* addr = ps.Inquire (argv [1]);
+ if (addr) {
+ printf ("0x%lx:%d\n", addr->Host (), addr->Port ());
+ delete addr;
+ } else
+ printf ("not found\n");
+ }
+ break;
+ case 3: {
+ UchInetAddress addr ("", atoi (argv [2]));
+ if (argv [1] [0] == '-')
+ ps.Remove (argv [1] + 1, addr, 987);
+ else
+ ps.Register (argv [1], addr, 987);
+ break;
+ }
+ }
+}
+