# $Id: idnconf.tcl,v 1.1 2003/06/04 00:27:42 marka Exp $
#
# idnconf.tcl - configure idn wrapper
#
#############################################################################
# Copyright (c) 2000,2002 Japan Network Information Center.
# All rights reserved.
#
# By using this file, you agree to the terms and conditions set forth bellow.
#
# LICENSE TERMS AND CONDITIONS
#
# The following License Terms and Conditions apply, unless a different
# license is obtained from Japan Network Information Center ("JPNIC"),
# a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
# Chiyoda-ku, Tokyo 101-0047, Japan.
#
# 1. Use, Modification and Redistribution (including distribution of any
# under this License Terms and Conditions.
#
# 2. Redistribution of source code must retain the copyright notices as they
# appear in each source code file, this License Terms and Conditions.
#
# 3. Redistribution in binary form must reproduce the Copyright Notice,
# materials provided with the distribution. For the purposes of binary
# distribution the "Copyright Notice" refers to the following language:
# "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
#
# 4. The name of JPNIC may not be used to endorse or promote products
# derived from this Software without specific prior written approval of
# JPNIC.
#
# 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#############################################################################
global configFile configBack
# idnkit version
set version "1.0"
set serverKey "HKEY_LOCAL_MACHINE\\Software\\JPNIC\\IDN"
set serverLogLevelDef -1
set serverLogLevelNone -1
set serverLogFile LogFile
set perprogKey "HKEY_LOCAL_MACHINE\\Software\\JPNIC\\IDN\\PerProg\\"
set perprogEnc Encoding
set perprogDef Default
set filesCpy11 { "wsock32.dll" }
set filesCpy20 { "wsock32.dll" "ws2_32.dll" }
set filesDel11 { "wsock32.dll" }
set filesDel20 { "wsock32.dll" "ws2_32.dll" }
########################################################################
#
# OS version check
#
proc get_os_version {} {
global os_version tcl_platform
return $os_version
}
switch -- $tcl_platform(os) {
"Windows 95" {
switch -- $tcl_platform(osVersion) {
4.0 {
}
4.10 {
}
4.90 {
}
}
}
"Windows NT" {
switch -- $tcl_platform(osVersion) {
3.51 -
4.0 {
}
5.0 {
}
default {
# XP or .NET
}
}
}
"Win32s" {
error "idn wrapper does not support Windows 3.1"
}
default {
set os_version "Unknown"
}
}
set os_version
}
proc support_dll_redirection {} {
global dll_redirection
return $dll_redirection
}
switch -- [get_os_version] {
# cannot force local DLL reference by .local file.
set dll_redirection 0
}
default {
set dll_redirection 1
}
}
set dll_redirection
}
########################################################################
#
# handling pathname
#
return $exe
}
}
proc getSystemDir {} {
global env
switch -- [get_os_version] {
"Windows 95" -
"Windows 98" -
"Windows Me" {
}
default {
}
}
return $sysDir
}
########################################################################
#
# loadList / saveList
#
# loadList - load list of wrapped executables from $configFile
# saveList - save list of wrapped executables into $configFile
#
proc loadList {} {
global configFile configBack
if { [file exists $configFile] } {
}
set aList {}
while { ! [eof $fd]} {
lappend aList "$line"
}
}
close $fd
return $aList
}
global configFile
}
close $fd
}
########################################################################
#
#
}
}
}
########################################################################
#
#
incr cnt
}
}
return $cnt
}
}
}
}
incr cnt
}
}
########################################################################
#
# registry operations
#
return $perprogDef
}
if {![isWindows]} {
return $perprogDef
}
package require registry 1.0
return $perprogDef
}
return $perprogDef
}
return $enc
}
if {![isWindows]} {
return 1
}
package require registry 1.0
set enc ""
}
return 2
}
return 0
}
proc regGetLogLevel {} {
}
global serverKey serverLogLevel
}
proc regGetLogFile {} {
# Maybe $file doesn't exist (yet). Get the longname of
# directory portion.
}
}
file nativename $lfile
}
proc regSetLogFile {file} {
global serverKey serverLogFile
}
proc regGetConfFile {} {
global serverKey serverConfFile
return {}
}
# Maybe $file doesn't exist (yet). Get the longname of
# directory portion.
}
}
file nativename $lfile
}
proc regSetConfFile {file} {
global serverKey serverConfFile
}
proc regGetWhere {} {
global serverKey
}
global serverKey
}
if {![isWindows]} {
puts "--regGetValue $key $name"
return $default
}
package require registry 1.0
return $default
}
return $default
}
return $value
}
if {![isWindows]} {
puts "--regSetValue $key $name $value"
return 1
}
package require registry 1.0
return 2
}
return 0
}
########################################################################
#
# install / uninstall DLL s
#
global env
global filesCpy11 filesCpy20
if {![isWindows]} {
return 1
}
switch -- [get_os_version] {
"Windows 95" -
"Windows 98" -
"Windows Me" {
set filesCpy $filesCpy11
}
default {
set filesCpy $filesCpy20
}
}
}
return 0
}
global filesDel11 filesDel20
if {![isWindows]} {
return 1
}
switch -- [get_os_version] {
"Windows 95" {
set filesDel $filesDel11
}
"Windows 98" -
"Windows Me" {
set filesDel $filesDel20
}
default {
set filesDel $filesDel20
}
}
}
return 0
}
########################################################################
#
#
# Make sure the program name is not empty
return
}
# It is dangerous to wrap programs in the system directory.
-message "Cannot wrap applications in the system directory.\nPlease copy the EXE file to elsewhere and wrap the copied one."
destroy $dlg
return 1
}
# Okay, copy the wrapper DLLs.
if { [fileInstall $prgName] } {
-title "Warning" \
-message "Cannot install DLLs" \
destroy $dlg
return 1
}
-title "Warning" \
-message "Cannot set encoding" \
destroy $dlg
return 2
}
# if local flag is on, create $prgName.local.
global local_dll
if {$local_dll} {
} else {
}
}
destroy $dlg
}
-title "Confirmation" \
-message "Also remove $prgName.local file?" \
}
}
}
destroy $dlg
}
return 0
}
return -1
}
close $fh
return 0
}
return -1
}
return 0
}
########################################################################
#
# dialog for Wrap / Unwrap
#
}
}
set types {
{ "Executable" .exe }
}
return
}
set enc [regGetEncode $file]
}
} else {
set prg ""
}
toplevel $top
grab $top
-value "Default"
-value "UTF-8"
if {[support_dll_redirection]} {
-variable local_dll
}
}
-title "Warning" \
-message "first, select unwrapping executable" \
return 0
}
-title "Warning" \
-message "first, select unwrapping executable" \
return 0
}
toplevel $top
grab $top
}
return
}
}
if {[support_dll_redirection]} {
set delete_type yes
switch -- $delete_type {
yes -
no {
}
}
switch -- $delete_type {
yes -
yesall {
}
}
}
}
saveList {}
}
return
}
}
}
catch {destroy $top}
toplevel $top
# wm transient $top $pw
set _logLevel [regGetLogLevel]
set _logFile [regGetLogFile]
global serverLogLevelNone
incr i
}
#label $w.lo_l -text "Log Operation:"
#grid $w.lo_l -row 2 -column 0 -sticky e -padx 4
}
return
} elseif {![file isdirectory $dir]} {
return
}
}
-title "idn wrapper Configuration" \
-message "Changing log level or file does not affect already running processes."
}
destroy $top
}
global logFileNameDef
-defaultextension .log \
if {[string compare $file {}]} {
}
}
global _logFile
}
}
global _logFile
-message "Really delete $_logFile?"]
}
}
########################################################################
#
# dialog for .local deletion
#
set parent .
set dlg .dotlocaldlg
catch {destroy $dlg}
toplevel $dlg
global dotlocal_selection
focus $bw
}
}
grab $dlg
vwait dotlocal_selection
destroy $dlg
return $dotlocal_selection
}
########################################################################
#
# dialog for advanced configuration
#
catch {destroy $top}
toplevel $top
global _mdnOperation _confFile
set _mdnOperation [regGetWhere]
set _confFile [regGetConfFile]
}
frame $w
}
frame $w
#label $w.l2 -text {Config Operation:}
#grid $w.l2 -row 1 -column 0 -sticky e -padx 4
}
global _confFile
}
}
global confFileNameDef
-defaultextension .conf \
if {[string compare $file {}]} {
}
}
global _mdnOperation _confFile
destroy $top
}
########################################################################
#
# utility
#
}
proc isWindows {} {
global tcl_platform
}
########################################################################
#
# config program start here
#
wm title . "idn wrapper - Configuration"
wm iconname . "idn wrapper - Configuration"
-text "idn wrapper Configuration Program version $version"
frame .lst
-xscrollcommand ".lst.xscroll set" \
-yscrollcommand ".lst.yscroll set"
frame .btn
#
# then set current list into listbox
#
#saveList $theList
#
########################################################################