# -sam k (commport5@lucidx.com)

sub die {
 if ($proto) {
  unless ($ansi) {
   $end .= "\r$top packets recieved by filter";
   if ($top == 1) {
    $end =~ s/packets/packet/;
   }
  }
  else {
   $end .= "\r";
   $end .= colored($top, $totpkts);
   $end .= " ";
   if ($packets == 1) {
    $end .= colored("packet", $packets);
   }
   else {
    $end .= colored("packets", $packets);
   }
   $end .= " ";
   $end .= colored("recieved", $rec);
   $end .= " ";
   $end .= colored("by", $by);
   $end .= " ";
   $end .= colored("filter", $filter);
  }
  print STDERR $end;
  if ($if == ($$ + 1)) {
   die "\n\rpdump: $exits[int(rand(@exits))]\n";
  }
  else {
   die "\n";
  }
 }
 else {
  if ($if == ($$ + 1)) {
   die "\rpdump: $exits[int(rand(@exits))]\n";
  }
  else {
   exit;
  }
 }
}

sub error {
 print STDERR "$0 version $version\n";
 print STDERR "Usage: pdump [ -aAbCfGhILmMnNOpqRStTuUvVXzZ ] [ -B hostname ]         [ -c count ]\n";
 print STDERR "             [ -d destination-host ]          [ -D destination-port ] [ -E 'expression' ]\n";
 print STDERR "             [ -F file ]                      [ -g [ 'regexp' ] ]     [ -H 'regexp' ]\n";
 print STDRER "             [ -i interface ]                 [ -J [ -1..9 ] ]        [ -l /pdump/directory ]\n";
 print STDERR "             [ -P 'regexp' ]                  [ -Q MAC address ]      [ -r file ]\n";
 print STDERR "             [ -s snaplen ]                   [ -w file ]             [ -W 'service1, service2' ]\n";
 die          "             [ -y source-host ]               [ -Y source-port ]\n";
}

sub help {
# print STDERR "$0 version $version\n";
# print STDERR "Usage: pdump [ -aAbCfGhILmMnNOpqRStTuUvVXzZ ] [ -B hostname ]         [ -c count ]\n";
# print STDERR "             [ -d destination-host ]          [ -D destination-port ] [ -E 'expression' ]\n";
# print STDERR "             [ -F file ]                      [ -g [ 'regexp' ] ]     [ -H 'regexp' ]\n";
# print STDRER "             [ -i interface ]                 [ -J [ -1..9 ] ]        [ -l /pdump/directory ]\n";
# print STDERR "             [ -P 'regexp' ]                  [ -Q MAC address ]      [ -r file ]\n";
# print STDERR "             [ -s snaplen ]                   [ -w file ]             [ -W 'service1, service2' ]\n";
# print STDERR "             [ -y source-host ]               [ -Y source-port ]\n";
 system("more README"); # sorry, i had to do it :|
 die "\n";
}

@exits = (
 "anything else would be uncivilized",
 "for distribution only with a new PC",
 "cleaner, drier, protects even better",
 "don't leave a network without it",
 "good to the last packet",
 "it does a box good",
 "it's everywhere you want to sniff",
 "it's all day strong, all day long",
 "it's not your ordinary sniffer in perl",
 "it's shagadellic, baby",
 "the other unix sniffer",
 "to the rescue",
 "the right choice for a healthy box",
 "the fresh maker",
 "the fizz goes straight to your buffer",
 "strong enough for a man, coded for a box",
 "sanatized for your protection",
 "often imitated, never duplicated",
 "now with 10 percent more code",
 "not from concentrate",
 "no additives or preservatives",
 "nine out of ten hackers reccomend it",
 "three out of four coders reccomend it",
 "need we say more",
 "sniffs in your box, not in your pants",
 "point, click, sniff",
 "made with real code",
 "cools you to the .core",
 "all quiet on the network front",
 "no process killed",
);

#sub top {
# $top++;
# if ($amt and $top == $amt) {
#  die "\r$amt packets recieved by filter\n";
# }
#}

1;
