9 static char *
rcsid=
"@(#)$Id$";
14 #include <sys/types.h> 37 fd=open(fname, dir, acsmode);
38 if (fd<0)
return(
NULL);
46 else if ((dir & 3)==0) {
48 else if (dir & O_WRONLY) {
58 if (pisfilestream(s) && !isint(s->c.fstream.fname)) {
59 fd=
intval(s->c.fstream.fd);
60 if (fd>=0) stat=close(fd);
63 pointer_update(s->c.stream.direction,
NIL);
75 register byte *strbuf;
78 strbuf=(s->c.stream.buffer)->c.str.chars;
79 if (pisfilestream(s)) {
80 if (isint(s->c.fstream.fname)) {
85 c=msgrcv(
intval(s->c.fstream.fd),
86 strbuf-4,
intval(lsave),0,0);
88 #if system5 || Solaris2 89 if (c<0) { breakck;
goto tryqread;}
91 #if sun3 || sun4 || vax || apollo || news || sanyo || mips || i386 || alpha || x86_64 || ARM 94 s->c.stream.buffer->c.str.length=lsave;
95 if (c==0)
return(EOF);
100 intval((s->c.stream.buffer)->c.str.length)););
102 printf(
";; read; stat=%d errno=%d, intsig=%d\n", c,
errno, ctx->
intsig);}
105 if (c<0)
goto tryfread;
107 if (c<=0)
return(EOF);
117 register byte *strbuf;
121 if (elmtypeof(b)==ELM_FOREIGN) strbuf=(
byte *)(b->
c.
ivec.
iv[0]);
123 c=
intval(s->c.stream.count);
124 if (c>=
intval(s->c.stream.tail)) {
127 fprintf(stderr,
"EOF ");
144 if (ch==EOF)
return(ch);
145 c=
intval(s->c.stream.count);
148 if (elmtypeof(b)==ELM_FOREIGN) sb=(
byte *)(b->
c.
ivec.
iv[0]);
161 {
register int fno,stat,cnt,blen;
162 register pointer lsave,bstr,extstr;
167 cnt=
intval(s->c.stream.count);
169 if (cnt<=0)
return(0);
170 if (pisfilestream(s)) {
171 fno=
intval(s->c.fstream.fd);
172 if (isint(s->c.fstream.fname)) {
176 stat=msgsnd(fno,bstr->
c.
str.
chars-4,cnt,0);
184 if (stat<0) { breakck;
goto tryfwrite;}
186 #if sun3 || sun4 || apollo || vax || news || sanyo || mips || alpha 190 if (stat>=0) { s->c.stream.count=
makeint(0);
return(0);}
198 pointer_update(s->c.stream.buffer,extstr);
199 s->c.stream.tail=
makeint(cnt*2-1);}
207 {
register int c,slen;
208 register byte *strbuf;
209 c=
intval(s->c.stream.count);
210 strbuf=(s->c.stream.buffer)->c.str.chars;
211 slen=
intval((s->c.stream.buffer)->c.str.length);
214 c=
intval(s->c.stream.count);
215 strbuf=(s->c.stream.buffer)->c.str.chars;}
222 {
register int bcount,bsize,i=0,
count;
223 register byte *strbuf;
225 bcount=
intval(s->c.stream.count);
226 strbuf=(s->c.stream.buffer)->c.str.chars;
227 bsize=
intval((s->c.stream.buffer)->c.str.length);
231 bsize=
intval((s->c.stream.buffer)->c.str.length);
232 bcount=
intval(s->c.stream.count);
233 strbuf=(s->c.stream.buffer)->c.str.chars;}
235 memcpy(&strbuf[bcount], &mes[i],
count);
238 s->c.stream.count=
makeint(bcount);}
context * euscontexts[MAXTHREAD]
pointer mkfilestream(context *, pointer, pointer, int, pointer)
static int fillstream(pointer s)
int writestr(pointer s, byte *mes, int len)
pointer csend(context *,...)
int written_count[MAXTHREAD]
pointer mkiostream(context *, pointer, pointer)
int closestream(pointer s)
int unreadch(pointer s, int ch)
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
int writech(pointer s, byte ch)
int flushstream(pointer s)
#define GC_REGION(cmp_statement)
pointer makestring(char *, int)
pointer openfile(context *ctx, char *fname, int dir, int acsmode, int size)