use TRELoad
'BitFieldTie';
our @EXPORT = qw(run_command chat fatal banner string2bf hexstring2bf
#our %opt = ( verbose => 1 );
##############################################################################
return $$Verbose if ref $Verbose;
##############################################################################
##############################################################################
my $obj = Midas
::Error
->throw($msg, $code);
##############################################################################
$level = 1 unless defined $level;
return unless verbose
>= $level;
my @lines = split /\n/, "$msgs";
my $string = "$Prg: " . (join "\n$Prg: $_", @lines);
##############################################################################
chat
"###########################################################\n", 2;
foreach my $line (@lines) {
print "$Prg: ## $line\n" if verbose
> 0;
chat
"###########################################################\n", 2;
##############################################################################
foreach my $key (keys %args) {
fatal
"Midas::Command does not recongnize configuration option ".
return ( verbose
=> $Verbose,
##############################################################################
my @options = qw( verbose=i fatal! errcode=i pass_errcode! );
Getopt
::Long
::Configure
('no_pass_through');
GetOptions
(\
%cmd_opt, @options) or
fatal
"Cannot parse flags to run_command: @flags\n";
if(verbose
>= $cmd_opt{verbose
}) {
print "$Prg: $command\n";
$status = system($command) unless opt_n
;
if($cmd_opt{fatal
} and $status) {
my $core = $status & 128;
my $core_msg = $core ?
"Dumped core." : "";
fatal
"Command \"$command\" died via signal $sig. $core_msg\n",
if($cmd_opt{pass_errcode
} and exists $ERRCODES{$exit}) {
fatal
"Command \"$command\" failed. $core_msg\n", $exit;
fatal
"Command \"$command\" failed with status $exit. $core_msg\n",
##############################################################################
fatal
"Cannot run string2bf without a width argument!\n", M_CODE
if($string =~ /^\s*0[xX]/ or ref($string) or $CONFIG{default_radix
} eq 'hex')
(my $mystring = $string) =~ s/^\s*0[xX]//;
my $max_digits = int($width / 4);
$max_digits++ if (($max_digits) * 4 != $width);
if(length $mystring > $max_digits) {
my $difference = (length $mystring) - $max_digits;
my $leader = substr($mystring, 0, $difference);
return "Hex overflow: \"$string\" won't fit in $width bits!\n"
unless $leader eq ('0' x
$difference);
my $max_bf = BitFieldTie
->new(65, "1");
$max_bf->left_shift($width);
$test_bf = BitFieldTie
->new_dec(65, $string);
if($test_bf->ucompare($max_bf) >= 0) {
return "Dec Overflow: \"$string\" won't fit in $width bits!\n";
$bf = BitFieldTie
->new($width, $string);
$bf = BitFieldTie
->new_dec($width, $string);
##############################################################################
$string = "0x$string" unless $string =~ /^\s*0[xX]/;
return string2bf
($string, $width);
##############################################################################