#ifdef USE_TCLX
#include <tclExtend.h>
#endif
#include <tcl.h>
#include <stdlib.h>

int main(int argc, char **argv) {
        char *Tcl_argv;
	char *tcl_sourceit;
	int small=0;
        Tcl_Interp *interp;
	if (argc<2) {
		return(printf("Usage: %s [-s] <filename>\n", argv[0]));
	}
	if (!strcmp(argv[1],"-s")) small=1;
	tcl_sourceit=malloc(strlen(argv[1+small])+8);
	sprintf(tcl_sourceit, "source %s",argv[1+small]);
        interp=Tcl_CreateInterp();
	if (small==0) {
	        Tcl_Init(interp);
#ifdef USE_TCLX
	        Tclx_Init(interp);
#endif
	}
        Tcl_argv=Tcl_Merge(argc-(2+small), argv+(2+small));
        Tcl_SetVar(interp, "argv", Tcl_argv, TCL_GLOBAL_ONLY);
        Tcl_SetVar(interp, "argv0", argv[1+small], TCL_GLOBAL_ONLY);
        Tcl_Eval(interp, tcl_sourceit);
        return(0);
}

