- simple locations db parser
[packages/VMware-server.git] / VMware-server-parse-locations.pl
CommitLineData
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
6use strict;
7
8my (%files, %dirs, %answer, %config);
9while (<>) {
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
23foreach my $key (sort keys %answer) {
24 my $value = $answer{$key};
25 printf("answer %s %s\n", $key, $value);
26}
27
28while (my($key, $value) = each %dirs) {
29 printf("directory %s\n", $key);
30}
31
32while (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}
39while (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
51while (my($key, $value) = each %config) {
52 printf("config %s\n", $key);
53}
This page took 0.033372 seconds and 4 git commands to generate.