#include <tcl.h>

void onexit(ClientData clientData, Tcl_Interp *interp)
{
    fprintf(stderr, "OnExitHandler for interp %p\n", interp);
}
	    
int Onexit_Init(Tcl_Interp *interp)
{
#ifdef USE_TCL_STUBS
    if (Tcl_InitStubs(interp, "8.5", 0) == NULL)
      return TCL_ERROR;
#else
    if (Tcl_PkgRequire(interp, "Tcl", "8.5", 0) == NULL)
      return TCL_ERROR;
#endif
    Tcl_CallWhenDeleted(interp, onexit, NULL);
    return Tcl_PkgProvide(interp, "onexit", "1.0");
}
