#!/usr/bin/perl -w
## $Id: prontosend,v 1.3 2001/02/03 13:59:02 muhri Exp $
use vars qw( %prefs $libpath $conn $locale $locale_installed);
use strict;

BEGIN { 
 $libpath = $0;
 $libpath =~ s!/[^/]+$!!;
 $libpath =~ s!/bin$!/lib/pronto!;
 if (! -e $libpath) { die _("Can't find required files in $libpath"); };
}

use lib "$libpath";
use lib "$libpath/modules/lib/perl5/site_perl/5.005";

require "prontolib.pl";
use Pronto::Send;
read_prefs();
$SIG{SEGV} = $SIG{TERM} = $SIG{QUIT} = $SIG{KILL} = \&quit;

#if copy of prontosend running then stop
if (open(TMP,"<$prefs{'MailDir'}/prontosend.running")) { 
	my $proc = <TMP>;
        if(kill (0,$proc)) {
                printf(_("Prontosend is already running. if this is not true, please delete\n
                prontosend.running in ") . $prefs{'MailDir'} ."\n");
                exit;
        }
        else {
                close(TMP);
                unlink "$prefs{'MailDir'}/prontosend.running";
        }
}
  


$conn = &open_db_conn;
if ($ARGV[0] == 1) {
	$Pronto::Send::inter = 1;
} else {
	$Pronto::Send::inter = 0;
}	
$Pronto::Send::called_from_send = 1;
&Pronto::Send::send();

sub quit {
	if(open(TMP,"<$prefs{'MailDir'}/pronto.running")) {
		my $proc = <TMP>;
        	close(TMP);
        	if(kill(0,$proc)) {
        		kill('USR2',$proc);
        	}
	}
}

