#!/usr/bin/perl
#
# Poderosa 設定ファイルをv3系からv4系に変換
#

use strict;

my $con = 0;
my %h;
while(<>){
	chomp;
	s/^\s+|\s+$//g;
	if(/\s*connection {/){
		$con = 1;
		next;
	}
	if($con && /}/){
		$con = 0;
		poderosa3to4(%h);
		next;
	}	
	if($con){
		my($key, $val) = split("=", $_);
		$h{$key}=$val;
	}
}

sub poderosa3to4
{
	my(%h) = @_;
	print <<"EOD";
      Poderosa.Usability.MRUItem {
        Poderosa.Protocols.SSHLoginParameter {
          destination=$h{'host'}
          account=$h{'account'}
        }
        Poderosa.Terminal.TerminalSettings {
          encoding=$h{'encoding'}
          transmit-nl=$h{'transmit-nl'}
          caption=$h{'host'}
        }
      }
EOD
}
