# main.tcl
# Copyright (c) 2001-2004 Digi International Inc., All Rights Reserved
# 
# This software contains proprietary and confidential information of Digi
# International Inc.  By accepting transfer of this copy, Recipient agrees
# to retain this software in confidence, to prevent disclosure to others,
# and to make no use of this software other than that for which it was
# delivered.  This is an unpublished copyrighted work of Digi International
# Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
# prohibited.
# 
# Restricted Rights Legend
#
# Use, duplication, or disclosure by the Government is subject to
# restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
# Technical Data and Computer Software clause at DFARS 252.227-7031 or
# subparagraphs (c)(1) and (2) of the Commercial Computer Software -
# Restricted Rights at 48 CFR 52.227-19, as applicable.
#
# Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
#
# ***************************************************************************


## Make sure Tk was loaded
if {[lsearch -regexp [info loaded] " Tk"] < 0} {
    if { $tcl_platform(platform) != "windows" } {
        puts ""
        puts "Please set your DISPLAY variable to a valid display."
        puts "(e.g. DISPLAY=localhost:0; export DISPLAY)"
        puts "A character based program may be available\; try the command:"
        puts "./setup -nogui"
    }
    
    exit
}

proc debug {} {    
    foreach var [namespace eval dg {info vars}] { 
        if {[info exists dg::$var]} {
            append txt "\n$var=[set dg::$var]" 
        }
    }
    tk_messageBox -message $txt; exit 0
}

proc ParsePackages {path} {
    global loc
    array set loc {}

    set ch [open $path r]
    while {![eof $ch]} {
        set line [string trim [gets $ch]]
        if {$line == ""} { continue }
        if {[string equal [string index $line 0] ";"]} { continue }

        if {[regexp -- {^(.+)=(.+)$} $line null strName strLocation]} {
            set loc([string tolower $strName]) $strLocation
            continue
        }      
    }

    if {[array size loc] == 0} {
         tk_messageBox -message "Error reading package data file"
         exit 0
    }

    close $ch
}
package require msgcat
namespace import ::msgcat::*
source frontend/common/init.tcl
set filePackages [file join $dg::dirRoot specific packages]
ParsePackages $filePackages
source [file join $dg::dirRoot frontend specific setup.ini]
::dg::fe::FEMain


exit 0

