]>
Commit | Line | Data |
---|---|---|
8e1d77f9 ER |
1 | #!/usr/bin/perl -w |
2 | # $Id$ | |
3 | # process vmware locations database | |
4 | # filter the database and keep only single answers not the complete log | |
5 | ||
6 | use strict; | |
7 | ||
8 | my (%files, %dirs, %answer, %config); | |
9 | while (<>) { | |
10 | chomp; | |
11 | next if /^$/ or /^#/; | |
12 | my ($cmd, $args) = split(/ /, $_, 2); | |
13 | my ($key, $value) = split(/ /, $args, 2); | |
14 | $files{$key} = $value,next if $cmd eq 'file'; | |
15 | $config{$key} = 1,next if $cmd eq 'config'; | |
16 | $dirs{$args} = 1,next if $cmd eq 'directory'; | |
17 | $answer{$key} = $value,next if $cmd eq 'answer'; | |
18 | delete $answer{$key},next if $cmd eq 'remove_answer'; | |
19 | delete $files{$key},next if $cmd eq 'remove_file'; | |
20 | warn "unknown config stub: [$cmd]\n"; | |
21 | } | |
22 | ||
23 | foreach my $key (sort keys %answer) { | |
24 | my $value = $answer{$key}; | |
25 | printf("answer %s %s\n", $key, $value); | |
26 | } | |
27 | ||
28 | while (my($key, $value) = each %dirs) { | |
29 | printf("directory %s\n", $key); | |
30 | } | |
31 | ||
32 | while (my($key, $value) = each %files) { | |
33 | if ($value) { | |
34 | printf("file %s %s\n", $key, $value); | |
35 | } else { | |
36 | printf("file %s\n", $key); | |
37 | } | |
38 | } | |
39 | while (my($key, $value) = each %files) { | |
40 | if ($value) { | |
41 | printf("file %s %s\n", $key, $value); | |
42 | } else { | |
43 | printf("file %s\n", $key); | |
44 | } | |
45 | if (exists $config{$key}) { | |
46 | printf("config %s\n", $key); | |
47 | delete $config{$key}; | |
48 | } | |
49 | } | |
50 | ||
51 | while (my($key, $value) = each %config) { | |
52 | printf("config %s\n", $key); | |
53 | } |