1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   7 #=====================================================================
 
   8 # SQL-Ledger Accounting
 
  11 #  Author: Dieter Simader
 
  12 #   Email: dsimader@sql-ledger.org
 
  13 #     Web: http://www.sql-ledger.org
 
  17 # This program is free software; you can redistribute it and/or modify
 
  18 # it under the terms of the GNU General Public License as published by
 
  19 # the Free Software Foundation; either version 2 of the License, or
 
  20 # (at your option) any later version.
 
  22 # This program is distributed in the hope that it will be useful,
 
  23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  25 # GNU General Public License for more details.
 
  26 # You should have received a copy of the GNU General Public License
 
  27 # along with this program; if not, write to the Free Software
 
  28 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
  30 #=====================================================================
 
  32 # routines to retrieve / manipulate win ini style files
 
  33 # ORDER is used to keep the elements in the order they appear in .ini
 
  35 #=====================================================================
 
  44   $main::lxdebug->enter_sub(2);
 
  46   my ($type, $file, %options) = @_;
 
  51   my $self = { FILE => $file, ORDER => [] };
 
  53   open my $fh, "$file" or $::form->error("$file : $!");
 
  58     if (!$options{verbatim}) {
 
  60       # remove any trailing whitespace
 
  71       $cur = $self->{$1} ||= { };
 
  73       push @{ $self->{ORDER} }, $1;
 
  75       # add key=value to $id
 
  76       my ($key, $value) = split m/=/, $_, 2;
 
  78       $cur->{$key} = $value;
 
  84   $main::lxdebug->leave_sub(2);
 
  86   return bless $self, $type;
 
  90   $main::lxdebug->enter_sub();
 
  94   my $file = $self->{FILE};
 
  95   my $fh   = IO::File->new($file, "w") || $::form->error("$file : $!");
 
  97   foreach my $section_name (sort keys %{ $self }) {
 
  98     next if $section_name =~ m/^[A-Z]+$/;
 
 100     my $section = $self->{$section_name};
 
 101     print $fh "[${section_name}]\n";
 
 102     map { print $fh "${_}=$section->{$_}\n" } sort keys %{ $section };
 
 108   $main::lxdebug->leave_sub();