Unified · Split
| @@ -0,0 +1,42 @@ | ||
| 1 | +libgio -- Programmable Virtual Files or Streams | |
| 2 | + | |
| 3 | +Synopsis | |
| 4 | + libgio is a small library to approximate Go's io.Reader and | |
| 5 | + io.Writer interfaces, Common Lisp's grey-streams, and OpenVMS's | |
| 6 | + programmable I/O. libgio takes a struct with the methods to read | |
| 7 | + or write to the stream, open and close the stream, and some other | |
| 8 | + stuff, and returns a libgio file descriptor. You can then use this | |
| 9 | + descriptor to read, write, seek, open, and close the stream. Note | |
| 10 | + that these are not normal file descriptors, but they look like it, | |
| 11 | + and basically feel like it. | |
| 12 | + | |
| 13 | +struct ReadWriter { | |
| 14 | + RWLock; | |
| 15 | + int (*open)(ReadWriter*); | |
| 16 | + int (*close)(ReadWriter*); | |
| 17 | + long (*pread)(ReadWriter*, void*, long, vlong); | |
| 18 | + long (*pwrite)(ReadWriter*, void*, long, vlong); | |
| 19 | + void *aux; | |
| 20 | + u64int offset; | |
| 21 | + u64int length; | |
| 22 | +}; | |
| 23 | + | |
| 24 | +int gopen(ReadWriter*, void *aux) | |
| 25 | + This function takes a ReadWriter struct and auxillary data, and | |
| 26 | + creates a gio file descriptor. | |
| 27 | + | |
| 28 | +int gclose(int gio_fd) | |
| 29 | + This destroys the gio file descriptor. | |
| 30 | + | |
| 31 | +long gread(int gio_fd, void *buf, long len, vlong off) | |
| 32 | + This is functionally the same as pread, but operates on a gio fd. | |
| 33 | + | |
| 34 | +long gwrite(int gio_fd, void *buf, long len, vlong off) | |
| 35 | + This is functionally the same as pwrite, but operates on a gio fd. | |
| 36 | + | |
| 37 | +vlong gseek(int gio_fd, vlong off, int whence) | |
| 38 | + This is functionally the same as seek but operates on a gio fd. | |
| 39 | + | |
| 40 | +int fd2gio(int fd) | |
| 41 | + This takes a system fd and returns a gio fd. | |
| 42 | + | |