📄 c-wtx6.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> The WTX Protocol </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-wtx.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-wtx.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-wtx5.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-extend.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="86069">4.6 Integrating WTX with Applications</a></i></h3></font><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86070">4.6.1 Using the Tcl and C APIs Together</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86072"> </a>Both the Tcl and C APIs provide access to all the WTX protocol commands. Which API to use for a particular application or module depends on whether an interactive or a compiled environment is more appropriate to the specific task. For example, you might write a development tool in C for which you wish to provide the same level of configurability as the rest of Tornado. The Tcl API is well suited to this application, and in fact is used to configure the various Tornado tools.</p><dd><p class="Body"><a name="86073"> </a>When using Tcl and C APIs together, an important question to address is: within which API will the target server connection be created? The API which creates the connection also creates the handle name. The handle must be passed to the other API in order for it to access the target server.</p><dd><p class="Body"><a name="86075"> </a>If connections are to be created by Tcl code using the <b class="tclProc">wtxToolAttach</b> command, the C code can obtain the <b class="symbol_UC">HWTX</b> structure associated with a Tcl handle name with the C routine <b class="routine"><i class="routine">wtxTclHandle</i></b><b>( )</b>:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="86077"> HWTX wtxTclHandle (char * handleName) </a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="86078"> </a>If you call this routine with a <b class="symbol_UC">NULL</b> argument, it returns the handle at the top of the Tcl<b class="command"> </b>handle stack. </p><dd><p class="Body"><a name="86080"> </a>If connections are to be created by C code calling <b class="routine"><i class="routine">wtxToolAttach</i></b><b>( )</b>, the C program can pass the C API handle to the Tcl interpreter by calling <b class="routine"><i class="routine">wtxTclHandleGrant</i></b><b>( )</b>:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="86082"> char * wtxTclHandleGrant (HWTX hWtx) </a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="86083"> </a>If you call this routine with a C API handle, a Tcl handle is created and placed on the top of the Tcl handle stack. The routine returns the handle name used by Tcl. If the C program wishes to close one of these connections, it should first revoke the Tcl handle with <b class="routine"><i class="routine">wtxTclHandleRevoke</i></b><b>( )</b>:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="86085"> void wtxTclHandleRevoke (HWTX hWtx) </a></b></pre></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86086">4.6.2 Integrating WTX Tcl with Other Tcl Applications</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86088"> </a>You can integrate WTX Tcl with other Tcl interpreters. The shared library <i class="textVariable">installDir</i><b class="symbol_UC">/</b><b class="file">host/</b><i class="textVariable">hostType</i><b class="file">/lib/</b><b class="library">libwtxtcl</b> can be linked with any Tcl 8.0 application. You must initialize the library with a call to <b class="routine"><i class="routine">wtxTclInit</i></b><b>( )</b>, supplying the Tcl interpreter handle as an argument:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="86090"> int wtxTclInit (Tcl_Interp * pInterp)</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="86091"> </a>Once you initialize the library, all the WTX Tcl commands are available to the Tcl interpreter. For example, to attach to a target, you can evaluate a <b class="tclProc">wtxToolAttach</b> Tcl expression.</p><dd><p class="Body"><a name="79990"> </a></p></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-wtx.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-wtx.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-wtx5.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-extend.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 --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -