/* * FSAccess.c * * WARNING: This does not allow proper use of read-write streams * No checks are made to invalidate a read buffer on a write stream. */ #include "DataExch.h" #include "FSAccess.h" void PutPacket(), WatchPacketsIn(); unsigned min(n1, n2) unsigned n1, n2; { if (n10) { chunk = min(len, MSGSIZE); (void) PutPacket(SWRITE, stream, 0, r, chunk); len = len - chunk; r = r + chunk; }; } int write(d, buf, nbytes) int d; char *buf; int nbytes; { (void) PutBlock((unsigned) d, buf, 0, (unsigned) nbytes); return(nbytes); } void PutText(stream, txt) unsigned stream; char *txt; { unsigned len; len = getTextLength(txt); (void) PutBlock(stream, txt, 0, len); } #define SBUFSIZE 8*1024 static struct streamBuffer { unsigned stream; unsigned indexOfStart; unsigned lastIndexUsed; unsigned last; unsigned length; /* the buffer is valid till buff[length] */ char buff[SBUFSIZE]; }; #define STRBUFNO 8 static struct streamBuffer streamBuffers[STRBUFNO]; long findLastBuffer(stream) unsigned stream; { long i; for (i=0; i=0 && indexDiff