33 lines
689 B
C
33 lines
689 B
C
#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) == 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) == 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) == count;
|
|
}
|