#!/usr/bin/perl

########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

sub idnConfigure(){

  my $ptrBin = shift;
  my %myBin;
  unless (ref($ptrBin)=~/HASH/){
    if (defined(%bin)){
      $ptrBin=\%bin;
    }else{
      $ptrBin=\%myBin;
    }
  }

  my $ret;

  $ind_vendor= 'idnkit';
  my $idn_name = 'idnconv';

  unless ($idn_shell && (-x $idn_shell) && ($idn_shell =~ /\/$idn_name$/)){
    $idn_shell = &getBin($idn_name,1,('/bin','/usr/bin','/usr/local/bin'))||"/usr/local/bin/$idn_name";
    unless (-x $idn_shell){
      $idn_shell = &BinQuestion( &ltext('install_bin_path',$idn_name) , $idn_shell);
    }
  }

	unless ($iconv_shell && -x $iconv_shell){
		$iconv_shell = &getBin('iconv',1,('/bin','/usr/bin','/usr/local/bin')) || 
			$bin_iconv || $ptrBin->{'iconv'};
		unless( $iconv_shell && -x $iconv_shell ) {
      $iconv_shell = &BinQuestion( &ltext('install_bin_path','iconv') , '/usr/bin/iconv');
		}
	}

	if ( $iconv_shell && -x $iconv_shell ) {
		if ( open( OUT, "$iconv_shell -l |") ) {
			while ( <OUT> ) {
				chomp;
				if ( /(?:^|\s)(utf-?8)(?:\s|$)/i ){
					$iconv_utf8 = $1;
				}
			}
			close (OUT);
			$bin_iconv = $iconv_shell;
			$ptrBin->{'iconv'} = $iconv_shell;
		}
	}

  $ptrBin->{'idn'}=$idn_shell;
  if ($idn_vendor = &idnCheckVendor($idn_shell)){
	  $ret=1;
	  unless($idn_vendor =~ /idnkit/) {
		  $ret=0;
	  }
  }
  
  if ($ret){
    return ($idn_vendor,$idn_shell,$iconv_shell,$iconv_utf8);
  }else{
    return undef;
  }
}

return 1;
