#include #include #include enum { bufsize = 0x20, }; static char * getall(FILE *in) { char buf[bufsize]; static char *contents = NULL; int len = 0, read; while ((read = fread(buf, 1, bufsize, in)) > 0) { len += read; contents = realloc(contents, len); memmove(&contents[len-read], buf, read); } contents = realloc(contents, ++len); contents[len-1] = '\0'; return contents; }