Index of /tcl/ftparchive/sorted/net/txrx1.0

      Name                   Last modified     Size  Description

[DIR] Parent Directory 28-Oct-99 15:46 - [   ] README 13-Aug-96 14:32 8k [CMP] txrx1.0.tar.gz 15-Aug-96 13:15 111k

An ONC RPC implementation as a dynamically loadable extension for Tcl 7.5

by Cristian Mata
cristian@cs.sunysb.edu

See the file "license.terms" for information on usage and redistribution
of this file, and for a DISCLAIMER OF ALL WARRANTIES.

Tcl implementation based upon a sample extension
by Scott Stanton w/ help from Ray Johnson
scott.stanton@eng.sun.com
ray.johnson@eng.sun.com

1. Introduction
---------------

This directory contains an RPC implementation based on RFC 1831/1832
as a dynamically loadable extension for Tcl 7.5.  The documentation
for the extension is located in the "doc" subdirectory in HTML format.

2. Compiling the extension
--------------------------

For Unix systems:

   (a) Make sure that the Tcl 7.5 release is present in the directory
       ../tcl7.5.  This example will only work with Tcl 7.5.  Also, be
       sure that you have configured Tcl before you configure the
       example.  You can obtain the Tcl 7.5 release by anonymous ftp
       from ftp.sunlabs.com:/pub/tcl.

       Hint: If the Tcl distribution is not in ../tcl7.5, make a symbolic
       link to it from .. or use --with-Tcl=DIR on the command line 
       for ./configure.

   (b) Type "./configure".  This runs a configuration script created
       by GNU autoconf, which configures Tcl for your system and
       creates a Makefile.  The configure script allows you to
       customize the Tcl configuration for your site; for details on
       how you can do this, type "./configure -help" or refer to the
       autoconf documentation (not included here).  Note: the example
       will use the same C compiler (e.g. gcc) as Tcl, as well as
       several other of Tcl's configuration options.  You should not
       usually modify CC in the Makefile generated here (if do you, be
       sure to check all of the definitions related to dynamic loading
       to make sure that they are still correct).  The example
       "configure" supports the following special switches in addition
       to the standard ones:
	   --with-tcl=DIR	Specifies the directory containing the Tcl
				binaries and Tcl's platform-dependent
				configuration information.  By default
				the Tcl directory is assumed to be in
				the location given by (a) above.

   (c) Type "make".  This will create a shared library called
       "example.so" and a package index file called "pkgIndex.tcl".

   (d) Type "make test" to test the example.  This will attempt to
       load txrx from the current directory.  If it
       succeeds, you will see no message, otherwise you will see
	   error messages indicating which tests have failed.

For Microsoft Windows systems:

   (a) Make sure that you have installed the Tcl 7.5 binary release.
       Because most "make" programs don't support long file names, you
       should install Tcl into a directory that does not contain
       spaces in the name.  This is primarily an issue under Windows
       95, since the default location is under the "Program Files"
       directory.

       Hint: Install the release under \Tcl. Remember to set the environment
       variables TCL_LIBRARY and TK_LIBRARY to point to the right directories.
       If Tcl is installed on C: under \Tcl, then TCL/TK_LIBRARY should be
       /tcl/lib/tcl7.5, respectively /tcl/lib/tk4.1.

   (b) If you are using the Borland compilers:

        CAUTION: this extension hasn't been tested with the BORLAND
        compiler. 

	1. Copy the file "makefile.bc" to the file "makefile".

	2. Edit "makefile" and change the BORLAND and TCL macros to
	   point to the directories where the Borland and Tcl releases
	   are installed.

	3. Type "make".  This will create a DLL called "example.dll"
	   and a package index file called "pkgIndex.tcl".

   (c) If you are using the Visual C++ compilers:

	1. You will need the file "vclibs41.zip" from the
	   ftp.sunlabs.com:/pub/tcl archive.  This file contains the
	   .LIB import files needed to link against the binary release
	   of Tcl 7.5.

	2. Unzip the vclibs41.zip archive into the current directory.
	   This should create the tcl75.lib and tk41.lib files.

	3. Copy the file "makefile.vc" to the file "makefile".

	4. Edit "makefile" and change the TOOLS32 and TCL variables to point
	   to the directories where the Visual C++ and Tcl releases are
	   installed.

	5. Type "nmake".  This will create a DLL called "example.dll"
	   and a package index file called "pkgIndex.tcl".

	6. Type "nmake test" to test the example.  This will attempt
	   to load the example package from the current directory.  If
	   it succeeds, you will see the message "Test passed.",
	   otherwise you will see an error.

    (d) You can install the example by placing "txrx.dll" and "txrx.tcl"
	in the directory containing tclsh75.exe or a directory on your
	path.  In addition, you should place the pkgIndex.tcl file
	into a directory on your auto_path.

For Macintosh systems:

    Note: no project file is provided yet. If you need to build TxRx
          on a Mac you'll need to obtain the sample project file
          from ftp.sublabs.com:/pub/tcl/example.tar.gz and make
          the necessary changes to the project file.

    Before you can compile the extension, you must have the Tcl 7.5
    source release.  You can obtain the release by anonymous ftp from
    ftp.sunlabs.com:/pub/tcl/mac.  You should install the directory
    including this example at the same level as the Tcl 7.5 workspace.
    Once you've done that, you should be able to use the included
    project file as is.
    
    Note: Dynamic loading only works on Power PC Macs.

3. Porting Issues
-----------------

Because the binary release of Tcl for Windows is compiled with Borland
C++ 4.52, the malloc() and free() routines it uses are not compatible
with the malloc() and free() supplied by other C run time libraries
(either VC++ or any other compiler).  In order to avoid memory
corruption, you must never pass malloc'ed memory to Tcl, expecting Tcl
to use free() on it.  Instead you need to pass your own free proc
along with the data.  This will mostly affect uses of Tcl_SetResult
(or interp->result) and the TCL_DYNAMIC flag.  Similarly, you should
not attempt to free memory that Tcl has allocated.

Eventually, we plan to supply a Tcl_Alloc and Tcl_Free routine that
can be used by Tcl extensions to safely allocate/deallocate memory
using the Tcl allocator, regardless of the compiler used.

Note: tcl7.5p1 provides Tcl_Alloc and Tcl_Free. Txrx uses consistently 
ckalloc and ckfree to allocated/deallocate memory. In Tcl7.5p1 these
macros map to Tcl_Alloc and Tcl_Free. Txrx has been tested with 
Visual C 4.0 and there have been no memory allocattion problems.


4. Installation
---------------

No installation routine is provided. To use TxRx you will need to
set the global Tcl variable auto_path. Auto_path is a list of directories.
Append to auto_path the name of the directory where pkgIndex.tcl, 
txrx.so and txrx.tcl are located.

For example, if TxRx is located in /usr/shareware/txrx1.0 you may want
to add the following lines to a Tcl script that would like to use
TxRx:

  lappend auto_path /usr/shareware/txrx1.0
  package require txrx

  ...and use it later, e.g.
  set p [txrxCreate @/usr/shareware/tmp/txrx1.0/protocols/portmap.x]

  # Get a list of all RPC programs on your host (won't work on PCs).
  txrxCall $p localhost PMAPPROC_DUMP

  # Check if a host supports the portmapper protocol:
  # Get a list of all RPC programs registered on the remote host.
  txrxCall $p www.cs.sunysb.edu PMAPPROC_DUMP

  # Create another protocol (this time for a crude example of 'df' under
  # UNIX).
  txrxCreate m @...protocols/mount.x

  # Get a list of all Mounted directories on your favorite server.
  txrxCall $m binserv1 MOUNTPROC_DUMP

  # Cleanup things. Remember that connections are kept open for every
  # host for which a call is made!
  txrxDelete $p
  txrxDelete $m