State reestablised when shell restarts. History of previous
[egate.git] / www / wtcl.c
index 7a0cb26..9ed644c 100644 (file)
  * USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * $Log: wtcl.c,v $
- * Revision 1.7  1995/10/31 16:56:25  adam
+ * Revision 1.8  1995/11/06 17:44:23  adam
+ * State reestablised when shell restarts. History of previous
+ * result sets.
+ *
+ * Revision 1.7  1995/10/31  16:56:25  adam
  * Record presentation.
  *
  * Revision 1.6  1995/10/31  10:03:54  adam
 
 static void *do_create (WCLIENT wcl, void *args);
 static int do_exec (const char *fname, char *parms, void *mydata);
+static int do_load (char *parms, void *mydata);
+static int do_save (char *parms, void *mydata);
 
 static struct w_interp_type w_interp_t = {
     "tcl",
     do_create,
-    do_exec
+    do_exec,
+    do_load,
+    do_save
 };
 
 W_Interp_Type w_interp_tcl = &w_interp_t;
@@ -118,6 +126,8 @@ static int proc_wabort_invoke (ClientData clientData, Tcl_Interp *interp,
     struct tcl_info *p = (struct tcl_info*) clientData;
 
     p->wabort = 1;
+    if (argc > 1)
+        Tcl_AppendResult (interp, argv[1], NULL);
     return TCL_RETURN;
 }
 
@@ -336,3 +346,39 @@ static int do_exec (const char *fname, char *parms, void *mydata)
     fclose (inf);
     return 0;
 }
+
+
+static int do_load (char *parms, void *mydata)
+{
+    struct tcl_info *p = mydata;
+    char fname[80];
+    int r;
+
+    sprintf (fname, "tcl.state.%d", p->wcl->id);
+    r = Tcl_EvalFile (p->interp, fname);
+    if (r == TCL_ERROR)
+        report_error (p, p->interp->errorLine, 
+                      "Error in Tcl loadState in line", 
+                      Tcl_GetVar (p->interp, "errorInfo", 0));
+    return 0;
+}
+
+static int do_save (char *parms, void *mydata)
+{
+    struct tcl_info *p = mydata;
+    struct Tcl_CmdInfo cinfo;
+
+    if (Tcl_GetCommandInfo(p->interp, "saveState", &cinfo))
+    {
+        int r;
+
+        gw_log (GW_LOG_DEBUG, mod, "saveState");
+        r = Tcl_Eval (p->interp, "saveState\n");
+        if (r == TCL_ERROR)
+            report_error (p, p->interp->errorLine, 
+                          "Error in Tcl saveState in line", 
+                          Tcl_GetVar (p->interp, "errorInfo", 0));
+    }
+    return 0;
+}
+