build: Add headers

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-05-23 01:34:59 -04:00
parent a371b6ebb0
commit a356913c39
3 changed files with 90 additions and 1 deletions
+49
View File
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause
*/
#ifndef CESCAL_READBUF_H
#define CESCAL_READBUF_H 1
#include <sys/types.h>
#include <stdint.h>
#include <stddef.h>
#define READBUF_CAP 128
/*
* Represents a read buffer that reduces system call
* overhead.
*
* @buf: Read buffer
* @size: Total populated size of offer
* @tail: Tail pointer from start of buffer
*/
struct readbuf {
char buf[READBUF_CAP];
size_t size;
size_t tail;
};
/*
* Initialize a read buffer
*
* @rb: Readbuffer to initialize
*
* Returns zero on success
*/
int readbuf_init(struct readbuf *rb);
/*
* Read from a read buffer and populate if needed
*
* @rb: Target readbuffer
* @fd: File descriptor to read from
*
* Returns the character read on success, '\0' on
* failure.
*/
char readbuf_read(struct readbuf *rb, int fd);
#endif /* !CESCAL_READBUF_H */