X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=www%2Fwproto.c;fp=www%2Fwproto.c;h=992d8007e421db03cab4d563f246888cb85ab95e;hb=a99bbcafcacb3b34d19e2ccef4ee636dfbe883e1;hp=eedbe74905f9f09979445d775ed6493e3a067fe3;hpb=1140389ab96fc8ca7bc9c8dc642adbcec625f4a6;p=egate.git diff --git a/www/wproto.c b/www/wproto.c index eedbe74..992d800 100644 --- a/www/wproto.c +++ b/www/wproto.c @@ -41,6 +41,10 @@ * 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. @@ -156,14 +160,17 @@ static void wproto_uncache(WCLIENT wc, int level); 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; } @@ -231,7 +238,9 @@ int wo_flush(WCLIENT wc) 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); } @@ -478,6 +487,7 @@ WCLIENT wproto_init (const char *fifoDir, const char *prog) newp->outbuffer_offset = 0; newp->cache_level = -1; newp->cache_fd = -1; + newp->save_level = 0; return newp; } @@ -527,6 +537,25 @@ static int wproto_findcache(WCLIENT wc, char *name) 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;