my $file = shift;
my $buf, my @mails;
- die("No filename!") unless($file);
- open(PKT, '<', $file) or die("Can't open $file!\n");
+ if(!$file) {
+ LOG::warn("No filename!");
+ return;
+ }
+
+ if(!(open(PKT, '<', $file))) {
+ LOG::warn("Can't open $file!");
+ return;
+ }
binmode(PKT);
- die("Short packet!") if(read(PKT, $buf, 0x3a) != 0x3a);
+ if(read(PKT, $buf, 0x3a) != 0x3a) {
+ LOG::warn("Short packet!");
+ return;
+ }
# parse packet header
my ($onode, $dnode, $year, $month, $day, $hour, $minute, $second,
$ozone, $dzone, $opoint, $dpoint, $data) = unpack(
"v v v v v v v v v v v v C C Z8 v v v n C C v v v v v a4", $buf);
- die("Unsupported packet type $type!") unless($type == 2);
+ if($type != 2) {
+ LOG::warn("Unsupported packet type $type!");
+ return;
+ }
my %packet;
if(($cw == $cwcopy) && ($cw != 0) && ($cw & 0x0001)) {
# read packed messages
while(1) {
- die("Short packet!") if(read(PKT, $buf, 2) != 2);
+ if(read(PKT, $buf, 2) != 2) {
+ LOG::warn("Short packet!");
+ return;
+ }
my $type = unpack("v", $buf);
if($type == 0) {
close(PKT);
return(@mails);
} elsif($type != 2) {
- die("Unsupported message type $type!");
+ LOG::warn("Unsupported message type $type!");
+ return;
}
- die("Short packet!") if(read(PKT, $buf, 0x20) != 0x20);
+ if(read(PKT, $buf, 0x20) != 0x20) {
+ LOG::warn("Short packet!");
+ return;
+ }
# parse message header
my ($tname, $fname, $subj, $text);