File: parseconfig.pl

package info (click to toggle)
foomatic-filters 4.0.17-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,108 kB
  • sloc: ansic: 6,371; sh: 2,532; makefile: 154; perl: 93; python: 8
file content (44 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl

my $configpath = "/etc/foomatic";

sub readConfFile
{
    my ($file) = @_;

    my %conf;
    # Read config file if present
    if (open CONF, "< $file")
    {
        while (<CONF>)
        {
            $conf{$1}="$2" if (m/^\s*([^\#\s]\S*)\s*:\s*(.*)\s*$/);
        }
        close CONF;
    }

    return %conf;
}

%conf = readConfFile("$configpath/filter.conf");
print( 'db_set foomatic-filters/filter_debug ',
       $conf{debug} > 0 ? 'true' : 'false', ";\n") if exists $conf{debug};
if (exists $conf{textfilter})
{
    if ($conf{textfilter} =~ m/^(a2ps|enscript|mpage)$/)
    {
        print "db_set foomatic-filters/textfilter $1;\n";
    }
    elsif ($conf{textfilter} =~ m/^\s*$/)
    {
        print "db_set foomatic-filters/textfilter Automagic;\n";
    }
    else
    {
        print "db_set foomatic-filters/textfilter Custom;\n";
        print "db_set foomatic-filters/custom_textfilter $conf{textfilter};\n";
    }
}
print( 'db_set foomatic-filters/ps_accounting ',
       $conf{ps_accounting} ? 'true' : 'false',
       "\n") if exists $conf{ps_accounting};