home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 316.lha / EtaleFileReader / bfgets.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-30  |  443 b   |  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.