home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / source / iolib / makbuf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1975-05-13  |  735 b   |  37 lines

  1. # include "ciodec.c"
  2. IEH3bsz 512;
  3. IEH3mbuf (fn, type)
  4. int fn, type;
  5. {
  6. struct fileps *fp;
  7. extern char *IEH3olbf[], *alloc();
  8. extern int IEHfbak[10];
  9. int bx[19], size, bloc;
  10. fp = &IEH3fpts[fn];
  11. fp->eoferr = fp->nchars = 0;
  12. fp->wrflag = type+1;
  13. /* decide whether to buffer or not */
  14. if (ttyn(fn) != 'x')
  15.     size = 1;
  16. else
  17. if (fstat(fn,bx) > 0 && bx[0] == 40 && type == 0)
  18.     size = 1;
  19. else
  20.     size = IEH3bsz;
  21. for (fp->buff = 0; size >10 && fp->buff == 0; size =/ 4)
  22.         if ((bloc = alloc(size+100)) != -1)
  23.             {
  24.             IEH3olbf[fn] = bloc;
  25.             fp->buff = fp->bptr =bloc + 100;
  26.             fp->bsize = size;
  27.             break;
  28.             }
  29. if (fp->buff == 0)
  30.     {
  31.     fp->buff = fp->bptr = &IEHfbak[fn];
  32.     fp->bsize = size>1 ? 2 : 1;
  33.     }
  34. }
  35. struct fileps IEH3fpts [10];
  36. int IEHfbak[10];
  37.