stream.h 793 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "minilisp.h"
  2. #ifndef SLEDGE_STREAM_H
  3. #define SLEDGE_STREAM_H
  4. typedef struct Filesystem {
  5. Cell* mount_point;
  6. Cell* open_fn;
  7. Cell* close_fn;
  8. Cell* read_fn;
  9. Cell* write_fn;
  10. Cell* delete_fn;
  11. Cell* mmap_fn;
  12. } Filesystem;
  13. typedef struct Stream {
  14. int id;
  15. Cell* path;
  16. long pos;
  17. long size;
  18. int mode; // read, write…
  19. // we could put here pointers to event handlers
  20. Filesystem* fs;
  21. } Stream;
  22. Cell* filesystems_init();
  23. Cell* fs_open(Cell* path);
  24. Cell* fs_mmap(Cell* path);
  25. Cell* fs_mount(Cell* path, Cell* handlers);
  26. Cell* stream_read(Cell* stream);
  27. Cell* stream_write(Cell* stream, Cell* arg);
  28. void fs_mount_builtin(char* path, void* open_handler, void* read_handler, void* write_handler, void* delete_handler, void* mmap_handler);
  29. Cell* get_fs_list();
  30. #endif