Files
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

93 lines
1.4 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#define BLEN 512
#include <klib.h>
struct iob {
int fd; /*file descriptor*/
int cc; /*char count*/
char *cp; /*ptr to next char*/
char cbuf[BLEN]; /*char buffer*/
};
fcreat(fname,ibuf,x)
char *fname;
int x;
register struct iob *ibuf;
{
ibuf->cc = BLEN; /*no chars*/
ibuf->cp = &(ibuf->cbuf[0]);
x = (x == 0) ? 0 : 1;
return(ibuf->fd=creat(fname,2,x));
}
putc(c,ibuf)
char c;
register struct iob *ibuf;
{
if(ibuf->cc<=0) {
ibuf->cp = &(ibuf->cbuf[0]);
if(write(ibuf->fd,ibuf->cp,BLEN) != BLEN)
__outerr();
ibuf->cc = BLEN;
}
*(ibuf->cp)++ = c;
ibuf->cc--;
return(c);
}
putw(w,ibuf)
int w;
register struct iob *ibuf;
{
register j;
int i;
putc((w>>8)&0xff,ibuf);
putc(w&0xff,ibuf);
return(w);
}
lputw(x,buff)
int *x;
struct iobuf *buff;
{
return(putw(*x,buff));
}
myfflush(ibuf)
register struct iob *ibuf;
{
register i;
i = BLEN - ibuf->cc;
ibuf->cc = BLEN;
ibuf->cp = &(ibuf->cbuf[0]);
if(write(ibuf->fd,ibuf->cp,i) != i)
__outerr();
return(0);
}
,ibuf);
putc((int)l &0xff,ibuf);
return(l);
}
 != i)
__outerr();
return(0);
}
,ibuf);
putc((int)l &0xff,ibuf);
return(l);
}
 != i)
__outerr();
return(0);
}
,ibuf);
putc((int)l &0xff,ibuf);
return(l);
}