CoST patch for multiple document instance support
Subject: CoST patch for multiple document instance support
From: Boris Tobotras <tobotras@jet.msk.su>
Date: 1998/06/16
Newsgroups: comp.text.sgml
---------------------------------------------------------------------
Some other fixes available, contact me if you're using CoST.
This one adds two directives:
savestream: saves current stream for later use. Returns handle.
setstream {handle}: makes {handle} the current stream.
--- tclcost.c~ Tue Jan 27 13:57:39 1998
+++ tclcost.c Tue Jun 16 13:58:46 1998
@@ -86,6 +86,46 @@
}
}
+#define MAX_DOCUMENTS 100
+static struct {
+ ESISStream doc;
+ ESISNode node;
+} activeDocs[ MAX_DOCUMENTS ];
+static int docsCounter = 0;
+
+static CMDPROC(CostSaveStreamProc)
+{
+ if ( !current_document || docsCounter == MAX_DOCUMENTS )
+ return TCL_ERROR;
+
+ activeDocs[ docsCounter ].doc = current_document;
+ activeDocs[ docsCounter ].node = current_node;
+
+ {
+ char nn[ 10 ];
+ sprintf( nn, "esis%d", docsCounter );
+ Tcl_AppendResult( interp, nn, NULL );
+ }
+
+ ++docsCounter;
+ current_document = NULL; /* Now next "load" won't clear the data */
+ return TCL_OK;
+}
+
+static CMDPROC(CostSetStreamProc)
+{
+ int idx = -1;
+
+ CHECKNARGS( 1, "streamhandle" );
+
+ if ( sscanf( argv[ 1 ], "esis%d", &idx ) != 1
+ || idx >= docsCounter )
+ return TCL_ERROR;
+ current_document = activeDocs[ idx ].doc;
+ current_node = activeDocs[ idx ].node;
+ return TCL_OK;
+}
+
static CQStatus CostQueryContinuation(
ESISNode nd, const char *value, void *closure)
{
@@ -692,6 +732,12 @@
Tcl_CreateCommand(interp, "substitution", DefineSubstProc,NULL,NULL);
Tcl_CreateCommand(interp, "environment",
DefineEnvironmentProc,NULL,NULL);
+
+ /* BT's extensions: */
+ Tcl_CreateCommand(interp, "savestream", CostSaveStreamProc, NULL,
+ NULL);
+ Tcl_CreateCommand(interp, "setstream", CostSetStreamProc, NULL,
+ NULL );
/*
* Load startup file:
----------------------------------------
Best regards, -- Boris.