#!/usr/bin/perl

package UserapCommon;

use strict;
use base 'Exporter';

our @EXPORT = qw($DATADIR $QOSDIR $QOSBIN $DEFAULT_CLASS $DEFAULT_CLASS_RATE $DEFAULT_CLASS_CEIL $UVERS $UPERIOD $PIDFILE $HTMLOUTFILE $ENABLE_HTMLOUT $DBSERVER);

#===============================================================================
#load default variables from /etc/default/qos

our $UVERS = "2.3.0";
our $DATADIR = "/var/state/qos/";
our $QOSDIR = "/etc/qos";
our $QOSBIN = "/usr/local/lib/qos";

my %def_values;
if (open F, "/etc/default/qos") {
    while (<F>) {
	my $line = $_;
	chomp $line;
	my ($name, $value) = $line =~ /([A-Za-z0-9_]+)\s*=(.*)$/;
	next if not defined $name or not defined $value;
	$value =~ s/^\s*\"?(.*?)\"?\s*$/$1/;
	$def_values{$name} = $value;
    }
    close F;
} else {
    print "WARNING! cannot open /etc/default/qos !";
}

$DATADIR=$def_values{DATADIR} if defined $def_values{DATADIR};
$QOSDIR=$def_values{QOSDIR} if defined $def_values{QOSDIR};
our $DEFAULT_CLASS=$def_values{DEFAULT_CLASS} if defined $def_values{DEFAULT_CLASS};
our $DEFAULT_CLASS_RATE=$def_values{DEFAULT_CLASS_RATE} if defined $def_values{DEFAULT_CLASS_RATE};
our $DEFAULT_CLASS_CEIL=$def_values{DEFAULT_CLASS_CEIL} if defined $def_values{DEFAULT_CLASS_CEIL};
our $PIDFILE=$def_values{PIDFILE} if defined $def_values{PIDFILE};
our $UPERIOD=$def_values{UPERIOD} if defined $def_values{UPERIOD};
our $HTMLOUTFILE=$def_values{HTMLOUTFILE} if defined $def_values{HTMLOUTFILE};
our $ENABLE_HTMLOUT=$def_values{ENABLE_HTMLOUT} if defined $def_values{ENABLE_HTMLOUT};
our $DBSERVER=$def_values{DBSERVER} if defined $def_values{DBSERVER};

1;
