stdio.c 363 B

1234567891011121314151617181920
  1. /*
  2. * Very simple stdio library for mapping stdio functions to brfs.
  3. */
  4. #define EOF -1
  5. // returns the current char at cursor within the opened file (EOF if end of file)
  6. // increments the cursor
  7. word fgetc(word fd, word filesize)
  8. {
  9. word cursor = fs_getcursor(fd);
  10. if (cursor == filesize)
  11. {
  12. return EOF;
  13. }
  14. char c;
  15. fs_read(fd, &c, 1);
  16. return c;
  17. }