+# parse configuration file
+
+=head1 CONFIGURATION
+
+Reads configuration information from Start by parsing /etc/sa.conf,
+then ~/.sarc then ~/.sarc_$hostname, then ~/.sarc_local
+
+The configuration file contains a list of svn repositories which
+should be queried; each line can contain a tab, which indicates that
+the command following the tab should be run fater the svn directory is
+updated.
+
+The configuration files are read in the order given above.
+
+=cut
+
+sub parse_config_file {
+ my ($repos,$filename,$home) = @_;
+ return unless -e $filename and -r _;
+ my $fh = new IO::File $filename, 'r' or die "Unable to read configuration file $filename $!";
+ while (<$fh>) {
+ chomp;
+ next if /^#/;
+ my ($repo,$command) = split /\t/,$_,2;
+ $repo =~ s/^\~/$home/;
+ $$repos{$repo} = $command;
+ }
+}
+
+
+my $HOME=User->Home;
+my $HOSTNAME=qx(hostname);
+$HOSTNAME=~s/\n//g;
+my %repos;
+for ('/etc/sa.conf', "${HOME}/.sarc", "${HOME}/.sarc_${HOSTNAME}", "${HOME}/.sarc_local") {
+ if (-e $_) {
+ parse_config_file(\%repos,$_,$HOME);
+ }
+}
+