aboutsummaryrefslogtreecommitdiffstats
path: root/src/system.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/system.h')
-rw-r--r--src/system.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/system.h b/src/system.h
index b1b84925..6a2eae11 100644
--- a/src/system.h
+++ b/src/system.h
@@ -17,10 +17,24 @@
#ifndef SERD_SYSTEM_H
#define SERD_SYSTEM_H
+#include <stdint.h>
#include <stdio.h>
-FILE*
-serd_fopen(const char* path, const char* mode);
+/** fread-like wrapper for getc (which is faster). */
+static inline size_t
+serd_file_read_byte(void* buf, size_t size, size_t nmemb, void* stream)
+{
+ (void)size;
+ (void)nmemb;
+
+ const int c = getc((FILE*)stream);
+ if (c == EOF) {
+ *((uint8_t*)buf) = 0;
+ return 0;
+ }
+ *((uint8_t*)buf) = (uint8_t)c;
+ return 1;
+}
void*
serd_bufalloc(size_t size);