home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 126_01 / putc.c < prev    next >
Text File  |  1985-03-10  |  640b  |  24 lines

  1. /* BDSC putc from stdlib1.c; modified for iobuf == 0 or 4 */
  2.  
  3. #include "bdscio.h"
  4.  
  5. int putc(c,iobuf)
  6. char c;
  7. struct _buf *iobuf;
  8. {
  9.     if (iobuf == 0) return(0); /* DUMP OUTPUT */
  10.     if (iobuf == 1) return putchar(c);
  11.     if (iobuf == 2) return (bdos(5,c));
  12.     if (iobuf == 3) return (bdos(4,c));
  13.     if (iobuf == 4) {
  14.         if (c == '\n') bdos(2,'\r');
  15.         return bdos(2,c);
  16.      }    
  17.     if (iobuf -> _nleft--) return *iobuf -> _nextp++ = c;
  18.     if ((write(iobuf -> _fd, iobuf -> _buff, NSECTS)) != NSECTS)
  19.             return ERROR;
  20.     iobuf -> _nleft = (NSECTS * SECSIZ - 1);
  21.     iobuf -> _nextp = iobuf -> _buff;
  22.     return *iobuf -> _nextp++ = c;
  23. }
  24. *********