summaryrefslogtreecommitdiff
path: root/src/stdio/__string_read.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio/__string_read.c')
-rw-r--r--src/stdio/__string_read.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/stdio/__string_read.c b/src/stdio/__string_read.c
new file mode 100644
index 00000000..5c3728d7
--- /dev/null
+++ b/src/stdio/__string_read.c
@@ -0,0 +1,13 @@
+#include "stdio_impl.h"
+
+size_t __string_read(FILE *f, unsigned char *buf, size_t len)
+{
+ char *src = f->cookie;
+ size_t k = strnlen(src, len+256);
+ if (k < len) len = k;
+ memcpy(buf, src, len);
+ f->rpos = (void *)(src+len);
+ f->rend = (void *)(src+k);
+ f->cookie = src+k;
+ return len;
+}