From 306951e28791b261f894a8b71255b4c45d105661 Mon Sep 17 00:00:00 2001 From: Florent Villard Date: Mon, 20 Oct 2003 10:51:59 +0000 Subject: change copyright remove old xml related files --- common/scripts/Vareqval.pm | 89 ---------------------------------------------- 1 file changed, 89 deletions(-) delete mode 100755 common/scripts/Vareqval.pm (limited to 'common/scripts/Vareqval.pm') diff --git a/common/scripts/Vareqval.pm b/common/scripts/Vareqval.pm deleted file mode 100755 index 110ad4ec..00000000 --- a/common/scripts/Vareqval.pm +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/perl -w - -# Author Philippe Hétroy, phetroy@mandrakesoft.com -# $Id: Vareqval.pm,v 1.3 2002-09-03 15:11:43 adesmons Exp $ - -# Module for loding and committing informations in a VAR = value file type - -package Vareqval; -use lib('./'); -use strict; -use Data::Dumper; - - -# Get all useful content of the config file -# Return a hash containg the key and the value -# ATTENTION : in the conf file, an empty value is returnes as a spaced value (mandatory because of XML compatibility) -sub get { - my $self = shift; - my $file = shift; - my %l; - local *F; open F, $file or return; - local $_; - - while () { - - my ($v, $val, $val2) = - /^\s* # leading space - (\w+)\s*=\s* # variable - ( - "(.*)" # double-quoted text - | '(.*)' # single-quoted text - | [^'"\s]* # normal text - ) - \s*$ # end of line - /x; - no warnings; - next if (!defined $v || $v eq ""); - $l{$v} = defined $val2 ? $val2 : $val; - } - - %l; -} - -# Commits changes in conf files and ifconfig -sub commit { - my $self = shift; - my ($file, $hash) = @_; - local *F; - - my $output = ""; - if (open(F, $file)) { - local $_; - - while () { - my ($pre, $key, $eq, $val, $rest) = /(^\s*)(\w+)(\s*=\s*"*'*)([^'"\s]*)(.*)/x; - - if (!defined $key) { - $output .= $_; - next; - }; - next if (!exists $hash->{$key}); #Elt has been removed - no warnings; - $val = $hash->{$key}; - delete $hash->{$key}; - $output .= defined $val ? $pre . $key . $eq . $val . $rest . "\n" : $pre . $key . $eq . $val . $rest; -# $output .= $pre . $key . $eq . $val . $rest . "\n"; - } - #appending added parameters - foreach (keys %$hash) { - $output .= $_ . "=" . $hash->{$_} . "\n"; - } - - } else { #the file does not exist - print STDERR "File $file will be created\n"; - foreach (keys %$hash) { - $output .= defined $hash->{$_} ? $_ . "=" . $hash->{$_} . "\n" : $_ . "=\n"; - } - } - -#print $output; -#print "\n------------------\n"; - - # outputing the new conf - open(F, "> $file") or return; - print F $output; - close(F); -} - -1; -- cgit v1.2.1