wip: working on extern in VM
- Feat: add writer externs writing fns - Feat: add VM reader functions
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <vm/internals/reader.h>
|
||||
|
||||
// Read characters with red bytes check
|
||||
bool vm_rd_char(FILE *fd, size_t count, char *o)
|
||||
{
|
||||
if (!fd || !o)
|
||||
return false;
|
||||
|
||||
return fread(o, sizeof(char), count, fd) == (sizeof(char) * count);
|
||||
}
|
||||
|
||||
// Read 16-byte uints with red bytes check
|
||||
bool vm_rd_u16(FILE *fd, size_t count, uint16_t *o)
|
||||
{
|
||||
if (!fd || !o)
|
||||
return false;
|
||||
|
||||
return fread(o, sizeof(uint16_t), count, fd) == (sizeof(uint16_t) * count);
|
||||
}
|
||||
|
||||
// Read machine word-size uints with red bytes check
|
||||
bool vm_rd_word(FILE *fd, size_t count, size_t *o)
|
||||
{
|
||||
if (!fd || !o)
|
||||
return false;
|
||||
|
||||
return fread(o, sizeof(size_t), count, fd) == (sizeof(size_t) * count);
|
||||
}
|
||||
Reference in New Issue
Block a user