~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/handoffClient/system.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # system.tcl --
  2 #
  3 #       FIXME: This file needs a description here.
  4 #
  5 # Copyright (c) 1993-2002 The Regents of the University of California.
  6 # All rights reserved.
  7 #
  8 # Redistribution and use in source and binary forms, with or without
  9 # modification, are permitted provided that the following conditions are met:
 10 #
 11 # A. Redistributions of source code must retain the above copyright notice,
 12 #    this list of conditions and the following disclaimer.
 13 # B. Redistributions in binary form must reproduce the above copyright notice,
 14 #    this list of conditions and the following disclaimer in the documentation
 15 #    and/or other materials provided with the distribution.
 16 # C. Neither the names of the copyright holders nor the names of its
 17 #    contributors may be used to endorse or promote products derived from this
 18 #    software without specific prior written permission.
 19 #
 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 23 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 #
 31 # $Header: /usr/mash/src/repository/mash/mash-1/tcl/handoffClient/system.tcl,v 1.12 2002/02/03 04:27:00 lim Exp $
 32 
 33 
 34 Class System
 35 
 36 
 37 System proc create_instance { {observer {}} } {
 38         global tcl_platform
 39         regsub -all " " $tcl_platform(os) "_" tmpOS
 40         if {[Class info instances System/$tmpOS]==""} {
 41                 global argv0
 42                 puts stderr "$argv0: no support for $tcl_platform(os)"
 43                 exit -1
 44         }
 45 
 46         $self set instance_ [new System/$tmpOS $observer]
 47 }
 48 
 49 
 50 System proc instance { } {
 51         return [$self set instance_]
 52 }
 53 
 54 
 55 System instproc init { observer } {
 56         $self set observer_ $observer
 57 }
 58 
 59 
 60 System instproc start_ping { addr } {
 61         $self instvar observer_
 62         $observer_ log "Trying to ping $addr"
 63         set chan [open "| ping $addr"]
 64         fconfigure $chan -blocking 0
 65         return $chan
 66 }
 67 
 68 
 69 System instproc ping_needs_cancel { } {
 70         # for unix this is true, for windows this is false
 71         return 1
 72 }
 73 
 74 
 75 System instproc kill { chan } {
 76         $self instvar observer_
 77         set pid [pid $chan]
 78         $observer_ log [exec kill -TERM $pid]
 79         catch {close $chan}
 80 }
 81 
 82 
 83 #System instproc ping { addr } {
 84 #       $self instvar observer_ ping_pid_
 85 #       if { ![$self ping_allowed] } {
 86 #               $observer_ log "PING has been disabled on this system"
 87 #       }
 88 #
 89 #       if [info exists ping_pid_] {
 90 #               $observer_ log "A ping process is currently in existence"
 91 #               return
 92 #       }
 93 #
 94 #       if { ![$self have_redirect_exec] } return
 95 #       $observer_ log "Trying to ping $addr"
 96 #       set ping_pid_ [redirect_exec "$self ping_output $observer_" \
 97 #                       ping $addr &]
 98 #}
 99 
100 
101 #System instproc ping_allowed { } {
102 #       if { [$self get_option disableping]!={} } {
103 #               return 0
104 #       } else {
105 #               return 1
106 #       }
107 #}
108 
109 
110 #System instproc have_redirect_exec { } {
111 #       if { [info commands redirect_exec] != "redirect_exec" } {
112 #       #       $self instvar observer_
113 #               $observer_ log "You seem to have an old version of mash\
114 #                               \nwithout support for \"redirect_exec\"\
115 #                               \n(or you are using an version of Tcl older\
116 #                               than 8.0)"
117 #               return 0
118 #       } else {
119 #               return 1
120 #       }
121 #}
122 
123 
124 #System instproc ping_output { observer data } {
125 #       if { [catch {$self ping_output_ $observer $data} err] } {
126 #               global errorInfo
127 #               puts "$err\n$errorInfo"
128 #       }
129 #}
130 
131 
132 #System instproc ping_output_ { observer data } {
133 #       #$self instvar observer_ ping_pid_
134 #
135 ##      if { [string length $data]==0 } {
136 #               # we have hit the end of the output
137 #               catch {$observer_ ping_done}
138 #               if { [info exists ping_pid_] } { unset ping_pid_ }
139 #       } else {
140 #               $observer_ log $data -nonewline
141 #       }
142 #}
143 
144 
145 #System instproc cancel_ping { } {
146 #       $self instvar observer_ ping_pid_
147 #
148 #       if { ![info exists ping_pid_] } {
149 #       #       $observer_ log "No PING in progress"
150 #               return
151 #       }
152 #
153 #       if { ![$self have_redirect_exec] } return
154 #
155 #       $observer_ log "Attempting to kill PING process (pid $ping_pid_)"
156 #       redirect_exec "$observer_ log" kill -TERM $ping_pid_
157 #       if { [info exists ping_pid_] } { unset ping_pid_ }
158 #}
159 
160 
161 System instproc get_default_route { } {
162         if {[catch {exec netstat -rn | grep default} tmpReply]} {
163                 return ""
164         } else {
165                 return [lindex $tmpReply 1]
166         }
167 }
168 
169 
170 System instproc delete_default_route { } {
171         exec route delete default
172 }
173 
174 
175 System instproc add_default_route { addr } {
176         exec route add default $addr
177 }
178 
179 
180 Class System/FreeBSD      -superclass System
181 Class System/BSD/OS       -superclass System
182 Class System/Linux        -superclass System
183 Class System/Win32        -superclass System
184 Class System/Windows_95   -superclass System/Win32
185 Class System/Windows_NT   -superclass System/Win32
186 
187 
188 System/Linux instproc delete_default_route { } {
189         exec route del default
190 }
191 
192 
193 System/Linux instproc add_default_route { addr } {
194         exec route add default gw $addr
195 }
196 
197 
198 System/Win32 instproc get_default_route { } {
199         puts "Calling route print"
200         if {[catch {exec route print 0.0.0.0} tmpReply]} {
201                 puts "Hmmm.... caught error when trying to query Win32 route\
202                                 find?"
203                 puts "$tmpReply"
204         }
205         puts "Done calling route print"
206         if {[string first "None" $tmpReply] == -1} {
207                 return [lindex $tmpReply 11]
208         } else {
209                 return ""
210         }
211 }
212 
213 
214 System/Win32 instproc delete_default_route { } {
215         puts "Calling route delete"
216         exec route delete 0.0.0.0
217         puts "Done calling route delete"
218 }
219 
220 
221 System/Win32 instproc add_default_route { addr } {
222         puts "Calling route add"
223         exec route add 0.0.0.0 mask 0.0.0.0 $addr
224         puts "Done calling route add"
225 }
226 
227 
228 System/Win32 instproc ping_needs_cancel { } {
229         return 0
230 }
231 
232 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.