/sys/doc/ Documentation archive

PUTC(III)                    6/12/72                    PUTC(III)

     putc, putw, fcreat, fflush  -  buffered output

     mov  $filename,r0
     jsr  r5,fcreat; iobuf

     fcreat(file, iobuf)
     char *file;
     struct buf *iobuf;

     (get byte in r0)
     jsr  r5,putc; iobuf

     putc(c, iobuf)
     int c;
     struct buf *iobuf;

     (get word in r0)
     jsr  r5,putw; iobuf

     putw(w, iobuf);
     int w;
     struct buf *iobuf;

     jsr  r5,flush; iobuf

     struct buf *iobuf;

     Fcreat  creates  the  given  file (mode 666) and sets up the
     buffer iobuf (size 518 bytes); putc and putw write a byte or
     word  respectively  onto the file; flush forces the contents
     of the buffer to be written, but does not  close  the  file.
     The structure of the buffer is:
     struct buf {
          int fildes;    /* File descriptor */
          int nunused;   /* Remaining slots */
          char *xfree;   /* Ptr to next free slot */
          char buff[512];     /* The buffer */

     Before terminating, a program should call flush to force out
     the last of the output (fflush from C).

     The user must supply iobuf, which should  begin  on  a  word

     To  write  a  new file using the same buffer, it suffices to
     call [f]flush, close the file, and call fcreat again.

                              - 1 -

PUTC(III)                    6/12/72                    PUTC(III)

     creat(II), write(II), getc(III)

     Fcreat sets the error  bit  (c-bit)  if  the  file  creation
     failed  (from  C,  returns  -1).  Putc and putw return their
     character (word) argument.  In all calls errno is set appro-
     priately to 0 or to a system error number.  See introduction


                              - 2 -