package conf;
use Tie::File;

sub var_read
{
    my ($classname,$path)=@_;
    my ($self)={};
    bless($self,$classname);
my @array;
tie @array, 'Tie::File', $path,mode=>O_RDONLY;
#print"!!!$array[0]:$array[1]\n\n";
for(@array)
#    open(my $conf_file,$path);
#    while(<$conf_file>)
    {
        s/#.*//;
        if(/^(\s)*$/) {next;}
        chomp;
	if(/\[(.*)\]/) {$section=$1;next;}
        my @fields=split;
        $self->{"$section.$fields[0]"}=$fields[1];
    }
untie @array;
    close($conf_file);
    return $self;
}

sub get_binary
{
    my ($self,$n)=@_;
    my @array=();
    my $m;
    my $i;
    for $i (0..7)
    {
    $m=$n;
    $n=$n>>1;
    $n=$n<<1;
    $array[$i]=$m-$n;
    $n=$n>>1;
    }
return @array;
}

#sub ntomac
#{
#my ($self,$n)=@_;
#return sprintf("%x %x %x %x %x %x",((($n&0xFF00000000)>>40),(($n&0xFF00000000)>>32),(($n&0xFF000000)>>24),(($n&0xFF0000)>>16),(($n&0xFF00)>>8),($n&0xFF)));
#}

1;