Define basic IO abstractions, implement for FD

This commit is contained in:
Daniel Thorpe
2024-06-20 14:23:33 +01:00
parent e38e0f8415
commit d7fbb0b4f0
5 changed files with 59 additions and 0 deletions

9
lib/include/fd_io.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef FD_IO_H
#define FD_IO_H
#include "io_abs.h"
void fd_reader(int fd, struct io_reader *reader_out);
void fd_writer(int fd, struct io_writer *writer_out);
#endif

17
lib/include/io_abs.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef IO_ABS_H
#define IO_ABS_H
#include <stdlib.h>
#include <stdint.h>
struct io_reader {
void *ctx;
ssize_t (*read)(void *ctx, uint8_t *buf, size_t len);
};
struct io_writer {
void *ctx;
ssize_t (*write)(void *ctx, const uint8_t *buf, size_t len);
};
#endif