#include "exec/types.h"
#include "stdio.h"
UBYTE * bfgets(fgs, num, fp)
UBYTE *fgs;
SHORT num;
register FILE *fp;
{
register int c;
register UBYTE *cs;
cs = fgs;
while ( (--num > 0) && ( (c = getc(fp)) != EOF ) )
   {
   *cs++ = (UBYTE)c;
   if (c==0)
      {
      cs--;               /*  throw nulls out  */
      num++;
      }
   if (c==0x0a) break;    /*  linefeed         */
   }
if (cs==fgs)
   return(NULL);
*cs = '\0';
return(fgs);
}
