name of a variable in which the HTML output is stored.
* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wproto.c,v $
+ * Revision 1.24 1997/01/31 11:16:00 adam
+ * Enhanced the egw_source command. An optional parameter specifies the
+ * name of a variable in which the HTML output is stored.
+ *
* Revision 1.23 1997/01/27 11:27:14 adam
* Implemented a new command, egw_clear, to clear http output cache.
* Changed prototype for function wo_clear.
static char *mod = "wproto";
+void wo_expand (WCLIENT wc, size_t len)
+{
+ assert (wc->outbuffer);
+ wc->outbuffer = realloc(wc->outbuffer, wc->outbuffer_size +=
+ ((len >= OUTBUFFER_CHUNK) ? len*2 : OUTBUFFER_CHUNK));
+}
+
void wo_write (WCLIENT wc, const char *s, size_t len)
{
if (wc->outbuffer_offset + len >= wc->outbuffer_size)
- {
- assert (wc->outbuffer);
- wc->outbuffer = realloc(wc->outbuffer, wc->outbuffer_size +=
- ((len >= OUTBUFFER_CHUNK) ? len*2 : OUTBUFFER_CHUNK));
- }
+ wo_expand (wc, len);
memcpy(wc->outbuffer + wc->outbuffer_offset, s, len);
wc->outbuffer_offset += len;
}
int wo_overflow(WCLIENT wc, char ch)
{
gw_log (GW_LOG_DEBUG, mod, "wo_overflow");
- if (wo_flush(wc) < 0)
+ if (wc->save_level)
+ wo_expand (wc, 0);
+ else if (wo_flush(wc) < 0)
return -1;
return wo_putc(wc, ch);
}
newp->outbuffer_offset = 0;
newp->cache_level = -1;
newp->cache_fd = -1;
+ newp->save_level = 0;
return newp;
}
return -1;
}
+int wproto_save_push (WCLIENT wc)
+{
+ return wc->outbuffer_offset;
+ wc->save_level++;
+}
+
+char *wproto_save_pop (WCLIENT wc, int offset)
+{
+ char *cp;
+ if (!wc->save_level)
+ return NULL;
+ --(wc->save_level);
+ assert (offset <= wc->outbuffer_offset);
+ cp = wc->outbuffer + offset;
+ wc->outbuffer[wc->outbuffer_offset] = '\0';
+ wc->outbuffer_offset = offset;
+ return cp;
+}
+
static int wproto_dumpcache(WCLIENT wc, int level)
{
int fd, rd;
* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wproto.h,v $
+ * Revision 1.14 1997/01/31 11:16:01 adam
+ * Enhanced the egw_source command. An optional parameter specifies the
+ * name of a variable in which the HTML output is stored.
+ *
* Revision 1.13 1997/01/27 11:27:15 adam
* Implemented a new command, egw_clear, to clear http output cache.
* Changed prototype for function wo_clear.
int cache_fd;
struct w_select_handle *select_list;
const char *fifoDir;
+ int save_level;
} *WCLIENT, wclient_data;
#define wo_putc(wc, ch) \
void wo_puts (WCLIENT wc, const char *s);
void wo_write (WCLIENT wc, const char *s, size_t len);
+int wproto_save_push (WCLIENT wc);
+char *wproto_save_pop (WCLIENT wc, int offset);
+
#endif
* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wtcl.c,v $
+ * Revision 1.20 1997/01/31 11:16:01 adam
+ * Enhanced the egw_source command. An optional parameter specifies the
+ * name of a variable in which the HTML output is stored.
+ *
* Revision 1.19 1997/01/27 11:27:17 adam
* Implemented a new command, egw_clear, to clear http output cache.
* Changed prototype for function wo_clear.
int argc, char **argv)
{
struct tcl_info *p = (struct tcl_info*) clientData;
- int r;
+ int r, offset = 0;
- if (argc != 2)
+ if (argc < 2 || argc > 3)
{
Tcl_AppendResult (p->interp,
- "wrong # args: should be egw_source file", NULL);
+ "wrong # args: should be egw_source file ?var?",
+ NULL);
return TCL_ERROR;
}
+ if (argc == 3)
+ offset = wproto_save_push (p->wcl);
r = exec_file (argv[1], p);
- if (r == -2)
+ Tcl_ResetResult (p->interp);
+ if (argc == 3)
+ {
+ char *res = wproto_save_pop (p->wcl, offset);
+ if (res)
+ Tcl_SetVar (p->interp, argv[2], res, 0);
+ }
+ if (r == -1)
{
- Tcl_AppendResult (p->interp, "egw_source: couldn't source ",
+ Tcl_AppendResult (p->interp, "egw_source: couldn't open ",
argv[1], NULL);
return TCL_ERROR;
}
- else if (r == -1)
+ else if (r == -2)
{
Tcl_AppendResult (p->interp, "egw_source: Tcl error in script ",
argv[1], NULL);