| 21.6 Solutions to Exercises |
|
|
There is no correct answer here. The point is to do the exercise. Only http://www.MapFree.com/sbf/tcl/book/canvas.tcl Only sunscript.sun.com 3 Change disallow trustedto allow trusted ifallowed trustedURLs $originURLand add this section section trustedURLs allow file:*
The basic idea is to change the allow statement to allow trusted ifallowed trustedHomeURLs $originURLand add a section something like section trustedHomeURLs allow * disallow http://www.mapfree.com* disallow http:/206.244.69.58*but there are substantial difficulties in the last step. The reason is that you must write a disallow statement for any identifier this server may have on the Internet. Since one server can serve multiple domain names and have multiple IP addresses, it will be difficult for you to be sure you have really excluded it from your set of acceptable servers. When trust is needed, it is safer to list the servers you trust than to try to avoid problematical servers with disallow. "Safer" does not mean "safe." See the remark after this exercise.
set F [CI invokehidden open sample] CI eval "set Contents \[read $F]; close $F"
This solution is available as script ES21.4b.
proc nonet_open {Intrp args} {
if {"[string index [lindex $args 0] 0]"=="|"} {
error "cannot open a pipeline"
} elseif {[llength $args]==0} {
$Intrp invokehidden open
} else {
eval {$Intrp invokehidden} open $args
}
}
proc create_nonet_interp Name {
interp create $Name
$Name hide socket
$Name hide interp
$Name hide open
$Name hide exec
$Name hide unknown
$Name alias open nonet_open $Name
return $Name
}
#! /usr/local/bin/wish8.0
## A network-inhibited interpreter that operates interactively through a
## text widget
## source procedures for the network-inhibited interpreter
source ES21.4b
## source scrollable
source ES18.1c
## source copy_paste
source ES20.3b
## create a scrollable widget object in its own toplevel window
set txt [scrollable . text 1]
bind $txt <Control-c> exit
wm title . "Network Free Command Window"
wm iconname . "Tk"
## prohibit editing before command line (but permit keyboard movement)
bind $txt <Key> {
if {"%K"=="BackSpace"} {
if [%W compare insert <= boundary] break
} elseif { "%K"=="Right" || "%K"=="Left" || "%K"=="Up" || "%K"=="Down" \
|| "%K"=="Prior" || "%K"=="Next"
} {
continue
} elseif [%W compare insert < boundary] {
%W mark set insert {end -1char}
}
%W see {insert linestart}
%W see insert
}
## create a network-inhibited interpreter
create_nonet_interp noNet
load {} Tk noNet
noNet eval wm title . .
## arrange for command execution
proc doCommand txt {
set CommandLine [$txt get boundary end]
if {[info complete $CommandLine]} {
catch {noNet eval $CommandLine} CatchBak
if {"$CatchBak"!=""} {
$txt insert insert \n$CatchBak
}
$txt insert insert \n
startNewCommandLine $txt
$txt see {insert linestart}
$txt see insert
} else {
$txt insert insert \n
$txt see insert
}
}
bind $txt <Key-Return> {
if {[%W compare insert < boundary]} {
%W mark set insert {end -1char}
}
doCommand %W
break
}
## start command line with prompt and mark
proc startNewCommandLine txt {
global PROMPT
$txt insert insert $PROMPT
$txt mark set boundary insert
}
set PROMPT "> "
startNewCommandLine $txt
$txt mark gravity boundary left
## setup standardized cut and paste
copy_paste $txt
|
Author's Home Page |
|
Order from Amazon. |