home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff254.lzh / Etale / bfgets.c < prev    next >
C/C++ Source or Header  |  1989-10-19  |  443b  |  26 lines

  1. #include "exec/types.h"
  2. #include "stdio.h"
  3. UBYTE * bfgets(fgs, num, fp)
  4. UBYTE *fgs;
  5. SHORT num;
  6. register FILE *fp;
  7. {
  8. register int c;
  9. register UBYTE *cs;
  10. cs = fgs;
  11. while ( (--num > 0) && ( (c = getc(fp)) != EOF ) )
  12.    {
  13.    *cs++ = (UBYTE)c;
  14.    if (c==0)
  15.       {
  16.       cs--;               /*  throw nulls out  */
  17.       num++;
  18.       }
  19.    if (c==0x0a) break;    /*  linefeed         */
  20.    }
  21. if (cs==fgs)
  22.    return(NULL);
  23. *cs = '\0';
  24. return(fgs);
  25. }
  26.