/usr/share/plplot5.10.0/tcl/plserver.tcl is in plplot-tcl 5.10.0+dfsg2-0.1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | # $Id: plserver.tcl 3242 2001-09-24 03:06:28Z jcard $
#----------------------------------------------------------------------------
# PLPLOT TK/TCL graphics renderer menu procs
# Maurice LeBrun
# 26-Apr-1993
# IFS, University of Texas at Austin
#
# This file includes the main initialization, cleanup, and communication
# procs. Those dealing with the plframe widget and "megawidget" are kept
# elsewhere.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# plserver_init
# Create the main window, menus, etc.
#----------------------------------------------------------------------------
proc plserver_init {} {
global file_menu_on plserver_init_done
if { ! [info exists plserver_init_done] } {
set plserver_init_done 1
# Set up toplevel
plstdwin .
# Create the window for the menu bar
# No File/Help menu! save plot area! Set in plconfig.tcl
if $file_menu_on then {
frame .menu -relief raised -borderwidth 1
pack append . .menu {top fillx}
#------------
# File menu
#------------
menubutton .menu.file -text "File" -menu .menu.file.m -underline 0
menu .menu.file.m
# .menu.file.m add command \
# -label "Open" \
# -command {null_command "Open"} \
# -underline 0
.menu.file.m add command \
-label "About..." \
-command about \
-underline 0
# if { ! [ info exists child ] } then {
# .menu.file.m add command \
# -label "Launch client..." \
# -command {null_command "Launch client..."} \
# -underline 0
# }
.menu.file.m add separator
.menu.file.m add command \
-label "Exit" \
-command exit \
-underline 0
bind . <Control-x> exit
pack append .menu .menu.file {left}
#--------------
# Debug menu
#--------------
if {[info exists debug_on]} then {
menubutton .menu.debug -text "Debug" -menu .menu.debug.m -underline 0
menu .menu.debug.m
.menu.debug.m add command \
-label "Execute TCL command" \
-command evalCmd \
-underline 0
pack append .menu .menu.debug {left}
}
#--------------
# Help menu
#--------------
menubutton .menu.help -text "Help" -menu .menu.help.m -underline 0
menu .menu.help.m
.menu.help.m add command \
-label "On Tcl/TK..." \
-command help_tcltk \
-underline 3
.menu.help.m add command \
-label "On GUI..." \
-command help_gui \
-underline 3
.menu.help.m add command \
-label "On Keys..." \
-command help_keys \
-underline 3
pack append .menu .menu.help {right}
bind . <Control-x> exit
# Set up for keyboard-based menu traversal
tk_menuBar .menu .menu.file .menu.help
tk_bindForTraversal . .menu
global tk_version
if {$tk_version < 4.0} then {
focus default .
}
}
}
# Set up initial link to client.
plserver_link_init
}
#----------------------------------------------------------------------------
# client_cmd
#
# Send string to client. Does it in the background and catches errors
# (if client is busy it won't respond).
#
# The first "after 1" ensures the command is issued in the server's
# background, so that we always continue processing events. This is
# important for handshaking and good for performance.
#
# The second "after 1" (or the dp_RDO if Tcl-DP rpc is used) ensures that
# the client process doesn't try to send a reply. Also good for
# performance but mainly to prevent problems if the server exits before
# the client can reply (so there is nothing to reply to).
#----------------------------------------------------------------------------
proc client_cmd {msg} {
global dp client
if { $dp } then {
after 1 catch [list "dp_RDO [list $client] $msg"]
} else {
# after 1 catch [list "send [list $client] after 1 $msg"]
after 1 catch [list "send -async [list $client] $msg"]
}
}
#----------------------------------------------------------------------------
# plserver_link_init
#
# Set up link between client and server interpreters.
#----------------------------------------------------------------------------
proc plserver_link_init {} {
global dp client
if { $dp } then {
global client_host client_port server_host server_port
if { ! [ info exists client_host ] } then {
set client_host localhost
}
set server_host [host_id]
set server_port [dp_MakeRPCServer]
set client [dp_MakeRPCClient $client_host $client_port]
dp_RDO [list $client] set server_host $server_host
dp_RDO [list $client] set server_port $server_port
dp_RDO [list $client] set client [list $client]
} else {
global client_name server_name
set server_name [winfo name .]
set client $client_name
send $client "set server_name [list $server_name]"
send $client "set client [list $client]"
}
}
#----------------------------------------------------------------------------
# plserver_link_end
#
# Terminate link between client and server interpreters.
# Operates on the 1 client / 1 plserver principle for now.
#----------------------------------------------------------------------------
proc plserver_link_end {} {
global dp client plclient_exiting
if { [info exists client] } then {
# Tell client we are exiting.
if { $dp } then {
dp_RPC [list $client] set plserver_exiting 1
} else {
send $client "set plserver_exiting 1"
}
# If the client isn't exiting, cause it to.
if { ! [info exists plclient_exiting] } then {
if { $dp } then {
dp_RPC [list $client] dp_after 1 abort
} else {
send $client "after 1 abort"
}
wait_until {[info exists plclient_exiting]}
}
# Clean up socket communications if using Tcl-DP.
if { $dp } then {
catch dp_CloseRPC [list $client]
}
}
}
#----------------------------------------------------------------------------
# plserver_start
#
# Startup proc when client is run independently.
#----------------------------------------------------------------------------
proc plserver_start {{use_dp 0}} {
global dp client
set dp $use_dp
plserver_init
if { $dp } then {
global client_host client_port server_host server_port
set server_host [host_id]
set server_port [dp_MakeRPCServer]
puts stderr "Please start client with flags: "
puts stderr " -server_host $server_host -server_port $server_port"
wait_until {[info exists client_port]}
set client "[dp_MakeRPCClient $client_host $client_port]"
dp_RDO [list $client] set client [list $client]
} else {
global client_name server_name
#puts stderr "Please start client with flags: "
#puts stderr " -server_name $server_name"
tkwait variable client_name
set client $client_name
send $client "set client [list $client]"
}
}
|