#include #include #include #include #include char* readFile(char* path) { path++; if (strlen(path) <= 1) { printf("/ converted to /index.html\n"); path = (char*)malloc(11); path = "index.html"; } FILE* fp = fopen(path, "rb"); if (!(access(path, F_OK) == 0)) { errno = -1; return ""; } char* buf = NULL; fseek(fp, 0, SEEK_END); int length = ftell(fp); rewind(fp); buf = (char*)malloc(sizeof(char) * (length + 1)); fread(buf, sizeof(char), length, fp); buf[length] = '\0'; char* tmp = buf; return tmp; }