[ Previous ] [ Contents ] [ Index ] [ Next ]

Example 5: tclhello

The following example illustrates how to extend the Tcl scripting language built into the AOLserver with your own custom C code.

This example can be found in the examples/c/tclhello directory.

    
    #include "nstcl.h"
    
    /*
     * This code adds a new TCL command named "hello" to the AOLserver.
     * To test this module, add the following to the 
     * [ns\server\server-name\modules] section of your nsd.ini file:
     * tclhello=tclhello.dll   ; or tclhello.so on Unix platforms
     * 
     * You can then run your "hello" command from the /NS/EvalTcl
     * interface provided by the AOLserver.
     */
    
    int Ns_ModuleVersion = 1;
    static Tcl_CmdProc HelloCmd;
    
    static int
    HelloCmd(ClientData dummy, Tcl_Interp *interp, int argc, char **argv)
    {
        interp->result = "Hello";
        return TCL_OK;
    }
    
    static int
    HelloInterpInit(Tcl_Interp *interp, void *context) 
    {
        Tcl_CreateCommand(interp, "hello", HelloCmd, NULL, NULL);
        return NS_OK;
    }
    
    int
    Ns_ModuleInit(char *hServer, char *hModule)
    {
        return (Ns_TclInitInterps(hServer, HelloInterpInit, NULL));
    }
    
    

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1998-99 America Online, Inc.