view dpid/dpidc @ 1103:94b9265663f6

New utility function: a_Utf8_end_of_char()
author corvid <corvid@lavabit.com>
date Sun, 17 May 2009 12:04:13 -0400
parents 6ee11bf9e3ea
children 7faa2c7a544f
line wrap: on
line source
#!/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";
}