Chapter 3. Custom SGITCL Extensions

This chapter provides a brief introduction to the extension packages included with SGITCL that are not likely to be found on other platforms.

tclObjSrv—for Objectserver

The tclObjSrv library is a Tcl Motif interface to the IRIX Cadmin distributed object system; see objectserver(1M) for details. To use the tclObjSrv library, first initialize it with dlopen:

moat> dlopen libtclObjSrv.so init ObjSrv_Init 
199.99.99.1
moat> .hostObject info 

The ObjSrv_Init routine returns the IP address of the current host. You can change to a different host by setting the _objAddr variable to the IP address of that machine. The hostObject routine retrieves object information for the current class.

See the tclObjSrv(3Tcl) reference page for more information about the tclObjSrv library.

rstat—Kernel Statistics

The rstat library is a Tcl interface to the rstatd kernel statistics daemon; see rstatd(1M) for details. This library is self-initializing: the first time you call an rstat procedure, SGITCL does a dlopen of librstat.so. The rstat library offers two commands that can be used to gather remote statistics from within Tcl programs:

nfsping 

Returns 1 if NFS daemons are running on the given hostname, 0 if not

rstat 

Returns a value pair list of kernel statistics on the remote hostname

For more information about the rstat library, try the Tcl help facility:

sgitcl> help rstat/rstat 

sautil—for Network Maps

The sautil library is a Tcl interface to system administration utilities for dealing with network information maps, for example YP maps for password, group, hosts, networks, protocols, and services. To use the sautil library, first initialize it with dlopen:

% ypmatch joeuser passwd 
joeuser::508:10:Joseph User,,,,,,,<eng>:/home/joeuser:/usr/bin/tcsh
% sgitcl 
sgitcl> dlopen libsautil.so init SAUtil_Init 
sgitcl> getpwnam pwent joeuser 
pw_name pw_passwd pw_uid pw_gid pw_comment pw_gecos pw_dir pw_shell
sgitcl> set pwent(pw_shell) 
/usr/bin/tcsh

In the example above, getpwnam returns the array element identifiers for the password entry array pwent. The set command shows that these array elements have been filled in according to the YP password map entry for joeuser.

System administration utilities for dealing with network information maps have the same names as standard C library routines for dealing with /etc files for password, group, hosts, networks, protocols, and services. These utilities are self-documenting—they print the proper usage if issued without arguments. Table 3-1 shows the utilities available:

Table 3-1. sautil Library for Network Information

YP Map

Utilities Available

group

getgrnam, getgrgid, getgrent, setgrent, endgrent

hosts

hostname, hostid, sysid, gethostbyname, gethostbyaddr
gethostent, sethostent, endhostent

networks

getnetbyname, getnetbyaddr, getnetent, setnetent, endnetent

passwd

pwcrypt, setpwent, getpwent, endpwent, getpwnam, getpwuid

protocols

getprotobyname, getprotobynumber, getprotoent, setprotoent, endprotoent

services

getservbyname, getservbyport, getservent, setservent, endservent

For more information about each of the sautils utilities above, use the Tcl help facility, giving the name of a YP map and a utility:

sgitcl> help sautils/YPmap/utility 

SNMP—Simple Network Management

The snmp library is a Tcl interface for SNMP (simple network management protocol) as implemented on IRIX 6.2. The snmp library is self-initializing: the first time you call one of its library procedures, SGITCL does a dlopen of libsnmp.so.

These are the supported SNMP library procedures:

snmpget 

retrieve a list of hostnames and SNMP variables

snmpgetnext 

get the next hostname variable in a list

snmpgettable 

retrieve a simple value or an SNMP table

snmpresolve 

return the appropriate IP address of a given hostname

snmpping 

return round-trip time for ICMP echo request (requires root privilege)

For more information about procedures in the snmp library, use the Tcl help facility:

sgitcl> help snmp/snmpping 

wwwHelp—Web Browser Help

The wwwHelp library is a Tcl Motif interface to build a help menu that invokes the Netscape Web browser for displaying help. The wwwHelpMenu routine reads a ViewKit helpmap file, by default from /usr/share/help, and constructs a help menu.

sgiHelp—ViewKit Help

The sgiHelp library is a Tcl Motif interface to the entire range of ViewKit help facilities. Before using these routines, you need to open the libsgihelp.so dynamic library:

moat> dlopen libsgihelp.so 

These procedures parse a Viewkit helpmap file to create a help menu with either help pages or contextual help. Here is a list of related help routines:

sgiHelpMenu  

process entries from a helpmap file to build a help menu

sgiVersionCallback  


create a dialog box containing version information

sgiHelpSubMenu  


read a helpmap file to build a help menu and any necessary submenus

sgiOnContextHelp  


retrieve contextual help based on question-mark mouse pointer

Support for Silicon Graphics Widgets

The Tcl Motif libraries include support for the following custom SGm widgets:

  • help menus in IRIS ViewKit style

  • the icon-panel library

  • SGm widgets (sgiGrid, sgiThumbWheel, sgiDropPocket, sgiPrintBox, sgiFinder, sgiVisualDrawingArea).

  • Dt widgets (dtComboBox, dtDropDownList dtDropDownComboBox)

  • Xbae Matrix widget (xbaeMatrix)

See TmSgiGrid(3Tm), TmSgiPanel(3Tm), and TmThumbWheel(3Tm) for more information about these widgets.