]> git.pld-linux.org Git - packages/VMware-server.git/commitdiff
- simple locations db parser
authorElan Ruusamäe <glen@pld-linux.org>
Tue, 8 Apr 2008 05:15:25 +0000 (05:15 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    VMware-server-parse-locations.pl -> 1.1

VMware-server-parse-locations.pl [new file with mode: 0755]

diff --git a/VMware-server-parse-locations.pl b/VMware-server-parse-locations.pl
new file mode 100755 (executable)
index 0000000..a1263dd
--- /dev/null
@@ -0,0 +1,53 @@
+#!/usr/bin/perl -w
+# $Id$
+# process vmware locations database
+# filter the database and keep only single answers not the complete log
+
+use strict;
+
+my (%files, %dirs, %answer, %config);
+while (<>) {
+       chomp;
+       next if /^$/ or /^#/;
+       my ($cmd, $args) = split(/ /, $_, 2);
+       my ($key, $value) = split(/ /, $args, 2);
+       $files{$key} = $value,next if $cmd eq 'file';
+       $config{$key} = 1,next if $cmd eq 'config';
+       $dirs{$args} = 1,next if $cmd eq 'directory';
+       $answer{$key} = $value,next if $cmd eq 'answer';
+       delete $answer{$key},next if $cmd eq 'remove_answer';
+       delete $files{$key},next if $cmd eq 'remove_file';
+       warn "unknown config stub: [$cmd]\n";
+}
+
+foreach my $key (sort keys %answer) {
+       my $value = $answer{$key};
+       printf("answer %s %s\n", $key, $value);
+}
+
+while (my($key, $value) = each %dirs) {
+       printf("directory %s\n", $key);
+}
+
+while (my($key, $value) = each %files) {
+       if ($value) {
+               printf("file %s %s\n", $key, $value);
+       } else {
+               printf("file %s\n", $key);
+       }
+}
+while (my($key, $value) = each %files) {
+       if ($value) {
+               printf("file %s %s\n", $key, $value);
+       } else {
+               printf("file %s\n", $key);
+       }
+       if (exists $config{$key}) {
+               printf("config %s\n", $key);
+               delete $config{$key};
+       }
+}
+
+while (my($key, $value) = each %config) {
+       printf("config %s\n", $key);
+}
This page took 0.057154 seconds and 4 git commands to generate.