#include <windows.h>
#define USE_TCL_STUBS
#include "tcl.h"


typedef int (*tcl_Main_t)(int argc, char *argv[], Tcl_AppInitProc *aip);
tcl_Main_t tcl_Main;

void
LoadTcl (char *lib)
{
    HMODULE hTcl;
    typedef Tcl_Interp *(*tcl_CI_t)(void);
    tcl_CI_t tcl_CI;
    Tcl_Interp *interp;

    hTcl = LoadLibrary(lib);
    tcl_CI = (tcl_CI_t) GetProcAddress(hTcl, "Tcl_CreateInterp");
    tcl_Main = (tcl_Main_t) GetProcAddress(hTcl, "Tcl_Main");
    interp = tcl_CI();
    Tcl_InitStubs(interp, "8.1", 0);
    Tcl_DeleteInterp(interp);
}

int
Tcl_AppInit (Tcl_Interp *interp)
{
    if (Tcl_Init(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
    return TCL_OK;
}

int
main (int argc, char *argv[])
{
    LoadTcl(argv[1]);
    argv[1] = argv[0];
    tcl_Main(argc-1, &argv[1], Tcl_AppInit);
    return 0;  // not reached
}
