?? c-extend2.html
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Extending Tornado Tools </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-extend.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-extend.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-extend1.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-extend3.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="84394">5.2 Outlining the Example Problem</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84395"> </a>This chapter steps through the process of extending tool functionality. The example problem is in two parts: determine the status of all attached network interfaces, and display this information both with the Tornado shell (WindSh) and with the Tornado browser. Determining the network interface status requires that you create code to query the state of certain data structures on the target. The information needed is similar to that produced by the target shell routine <b class="routine"><i class="routine">ifShow</i></b><b>( )</b>. Once you extract the information, you can create a new host shell procedure that displays the information. After completing the shell implementation, you can add a new display to the Tornado browser as well.</p><dd><p class="Body"><a name="84396"> </a>To see what information is needed, review the output of the target shell <b class="routine"><i class="routine">ifShow</i></b><b>( )</b>routine.</p><dl class="margin"><dd><pre class="Code2"><b><a name="84397"></b><tt class="output">-> </tt><b>ifShow </b><tt class="output">dc (unit number 0): Flags: (0x8063) UP BROADCAST RUNNING ARP MULTICAST Type: ETHERNET_CSMACD Internet address: 147.11.36.111 Broadcast address: 147.11.36.255 Netmask 0xffff0000 Subnetmask 0xffffff00 Ethernet address is 08:00:3e:24:dd:70 Metric is 0 Maximum Transfer Unit size is 1500 30954 packets received; 6 packets sent 30954 multicast packets received 5 multicast packets sent 0 input errors; 0 output errors 0 collisions; 0 dropped</tt><b></a></b></pre></dl><dd><p class="Body"><a name="84408"> </a>To simplify this example, the network mask information is omitted (it is maintained in a different linked list); instead, the example focuses on the information that is directly available in the <b class="symbol_lc">ifnet</b> linked list of structures.</p><dd><p class="Body"><a name="84409"> </a>The solution is implemented through three files of Tcl code. The Tornado shell and browser share the Tcl code which gathers information from the target. The shell calls these information-gathering routines and then formats the output for printing. The browser uses these routines to supply graphical objects with data, providing a more interactive presentation of the same data. <a href="c-extend2.html#84416">Figure 5-1</a> shows the directory location and relationship of the three elements. <div class="frame"><h4 class="EntityTitle"><a name="84416"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 5-1: Organization of Tcl Extension Files</font></a></h4><dl class="margin"><div class="Anchor"><a name="84446"> </a><img class="figure" border="0" src="images/c-extend0.gif"></div></dl></div></p><dd><p class="Body"><a name="84447"> </a>All Tcl-based Tornado tools have a directory in the resource hierarchy where you can place files of Tcl extension code: <i class="textVariable">installDir</i><b class="file">/host/resource/tcl/app-config/</b><i class="emphasis">toolName</i>. When each tool starts, it reads all the extension files it finds in order<sup><a href="#foot"><b class="FootnoteMarker">1</b></a></sup>. This means any extension to a tool can be packaged as a set of files which are inserted into the Tornado tree. The tools automatically read these files, allowing Tornado to be extended without modifying any of the existing files. </p><dd><p class="Body"><a name="84451"> </a>Since extension files are read in a specific order, a "patch" file can be inserted after an existing file to modify the behavior of an existing service (for example, by redefining a Tcl procedure found in the first file). To add a later modification that extends the <b class="symbol_lc">NetShow</b> extension you are creating, you might provide a file called <b class="file">01NetShow2.tcl</b>, which would be read immediately after <b class="file">01NetShow.tcl</b>. </p><dd><p class="Body"><a name="84452"> </a>The files located in <i class="textVariable">installDir</i><b class="file">/host/resource/tcl</b> are not automatically sourced. Include a source statement in any extension files that need to access this shared code.</p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/caution.gif"></td><td><hr><div class="CalloutCell"><a name="85728"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">CAUTION: </font></b></a>During development, you may wish to place your working files in your <i class="textVariable">homeDir</i><b class="file">/.wind</b> directory. UNIX users can define the <b class="symbol_UC">$HOME</b> constant to be <i class="textVariable">homeDir</i>. Files in the <b class="symbol_UC">$HOME</b><b class="file">/.wind</b> directory are automatically sourced when you restart the tool, and this practice protects other Tornado users from any problems with your development code. Windows users will need to source the files. (For more information, see the <i class="term">Tornado User's Guide: Directories and Files</i>.) <b></b></div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><a name="foot"><hr></a><p class="FootnoteNumberMarker">1: <span class="Footnote"><a name="84450"> </a>Files are read in shell collating order (the same order that the files would be displayed by the <b class="routine"><i class="routine">ls</i></b><b>( )</b> routine). This is why these files typically start with two numbers: so that new additions to this directory can be interleaved with existing files easily.</span><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-extend.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-extend.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-extend1.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-extend3.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 4.0.11 template: CSS Template, Jan 1998 - Jefro --->
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -