Author: glen                         Date: Tue Apr  8 05:15:30 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- simple locations db parser

---- Files affected:
SOURCES:
   VMware-server-parse-locations.pl (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/VMware-server-parse-locations.pl
diff -u /dev/null SOURCES/VMware-server-parse-locations.pl:1.1
--- /dev/null   Tue Apr  8 07:15:31 2008
+++ SOURCES/VMware-server-parse-locations.pl    Tue Apr  8 07:15:25 2008
@@ -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);
+}
================================================================
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to