#ifndef OMIT_TK #include #else #include #endif #include #include #include #include #include #include #include #ifdef OS_WIN # include #endif #include "memFile.h" extern memFileData *tclTkInitData[]; /* ** Do an immediate exit. Do not attempt a clean shutdown. Just die. */ static int hardExitCmd( void *NotUsed, /* Client data for this command */ Tcl_Interp *interp, /* The interpreter used to report errors */ int objc, /* Number of arguments */ Tcl_Obj *const* objv /* Values of all arguments */ ){ exit(0); } Tcl_Interp * memCreateInterp(int argc, char **argv){ Tcl_Interp *interp; char *args; char buf[100]; char paths[256], lib[100]; int tty; Tcl_Obj *path, *listObjPtr, *pathObjPtr, *tmpObj; int rtn, listLen, i; Tcl_GlobTypeData type; /* Create a Tcl interpreter */ Tcl_FindExecutable(argv[0]); interp = Tcl_CreateInterp(); path = NULL; /* Work around bug 873311 in Tcl - avoid an infinite loop on shutdown ** that occurs in TclFinalizeFilesystem by just not calling that routine. ** The "exit" command makes no attempt to shut down Tcl, it just dies. */ Tcl_CreateObjCommand(interp, "exit", hardExitCmd, 0, 0); if( Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 1)==0 ) goto init_error; args = Tcl_Merge(argc-1, (const char**)(argv+1)); Tcl_SetVar(interp, "argv", args, TCL_GLOBAL_ONLY); ckfree(args); sprintf(buf, "%d", argc-1); Tcl_SetVar(interp, "argc", buf, TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); // sprintf(buf, "set memTcl(compile-timestamp) [clock scan {%s %s}]", // __TIME__, __DATE__); // Tcl_Eval(interp, buf); Tcl_SetVar(interp, "memTcl(compile-timestamp", "_TIMESTAMP_", TCL_GLOBAL_ONLY); /* ** Set up variables containing version information. */ /* We have to initialize the virtual filesystem before calling ** Tcl_Init(). Otherwise, Tcl_Init() will not be able to find ** its startup script files. */ Memfile_Init(interp); memFile_Mount(NULL, interp, "/mem", tclTkInitData); // Get the top level dirs from the mem file system. // Find the tcl8.x path for library, and the others are // the auto_path places to search. listObjPtr = Tcl_NewListObj(0, NULL); pathObjPtr = Tcl_NewStringObj("/mem", -1); type.type = TCL_GLOB_TYPE_DIR; rtn = memFile_MatchInDirectory(NULL, listObjPtr, pathObjPtr, "*", &type); if (rtn == TCL_ERROR) { printf("FAILED to find any Tcl library dirs\n"); Tcl_Eval(interp, "puts $errorInfo"); exit (-1); } Tcl_ListObjLength(interp, listObjPtr, &listLen); *paths = 0; *lib= 0; for (i=0; iresult, "Error", MB_ICONSTOP|MB_OK); #else fprintf(stderr, "%s: unable to initialize: %s\n", argv[0], interp->result); #endif return 1; }