summaryrefslogtreecommitdiff
path: root/src/stdio/__string_read.c
blob: 5c3728d7fc5fd0b56fd36339fb4beac7cc998798 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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;
}