
#include <stdio.h>
#include <tcl.h>

void Trace1 (ClientData clientData,
             Tcl_Interp *interp,
             int level,
             char *command,
             Tcl_CmdProc *cmdProc,
             ClientData cmdClientData,
             int argc,
             const char *argv[])
{
    fprintf (stderr, "t1: %d: %s\n", level, command);
}

void Trace2 (ClientData clientData,
             Tcl_Interp *interp,
             int level,
             char *command,
             Tcl_CmdProc *cmdProc,
             ClientData cmdClientData,
             int argc,
             const char *argv[])
{
    fprintf (stderr, "t2: %d: %s\n", level, command);
}

int Trace_Init (Tcl_Interp *interp)
{
    printf ("Hello trace!\n");
    Tcl_Eval (interp, "puts 1");
    Tcl_CreateTrace (interp, 1, Trace2, NULL);
    Tcl_Eval (interp, "puts 2");
    Tcl_CreateTrace (interp, 5, Trace1, NULL);
    Tcl_Eval (interp, "puts 3");
    Tcl_Eval (interp, "source [info library]/auto.tcl");
    printf ("Bye trace!\n");
    return TCL_OK;
}
