aboutsummaryrefslogtreecommitdiff
path: root/dpid/dpidc
diff options
context:
space:
mode:
authorjcid <devnull@localhost>2007-10-07 00:36:34 +0200
committerjcid <devnull@localhost>2007-10-07 00:36:34 +0200
commit93715c46a99c96d6c866968312691ec9ab0f6a03 (patch)
tree573f19ec6aa740844f53a7c0eb7114f04096bf64 /dpid/dpidc
Initial revision
Diffstat (limited to 'dpid/dpidc')
-rw-r--r--dpid/dpidc31
1 files changed, 31 insertions, 0 deletions
diff --git a/dpid/dpidc b/dpid/dpidc
new file mode 100644
index 00000000..88b887cb
--- /dev/null
+++ b/dpid/dpidc
@@ -0,0 +1,31 @@
+#!/usr/bin/perl -w
+# Author: Ferdi Franceschini
+#
+# dpid control program
+# Currently allows
+# register: Tells dpid to register all available dpis
+# stop: Stops dpid.
+
+use strict;
+use IO::Socket::UNIX;
+
+# Get socket directory name
+open(DSD, "<$ENV{HOME}/.dillo/dpi_socket_dir");
+my $dir = <DSD>;
+close(DSD);
+
+my $socket = IO::Socket::UNIX->new(Peer => "$dir/dpid.srs", Type => SOCK_STREAM, Timeout => 1000 ) or die "new: $@";
+
+$socket->autoflush(1);
+
+my %dpi_command = (
+ "register" => "<dpi cmd='register_all' '>",
+ "stop" => "<dpi cmd='DpiBye' '>",
+ );
+
+if ( exists($dpi_command{$ARGV[0]}) ) {
+ print $socket $dpi_command{$ARGV[0]};
+} else {
+ close($socket);
+ print "Usage: dpidc register|stop\n";
+}