I can't seem to find a problem in my load and indexes function. I need help asap. PS- my lookup and parse functions show all green ticks on check50
char* indexes(const char* path)
{
// TODO
int length = strlen(path);
char* copy = malloc(length + 13);
strcpy(copy,path);
strcat(copy,"/index.html");
if(access(copy, F_OK) != -1)
return copy;
else
free(copy);
char* copy2 = malloc(length + 13);
strcpy(copy2,path);
strcat(copy2,"/index.php");
if(access(copy2, F_OK) != -1)
return copy2;
else
free(copy2);
return NULL;
}
bool load(FILE* file, BYTE** content, size_t* length)
{
int i=0;
// TODO
char* buffer = malloc(sizeof(BYTE));
*length =0;
while(!feof(file))
{
if(file == NULL)
return false;
buffer[i] = fgetc(file);
buffer = realloc(buffer,++i);
*length = *length + sizeof(BYTE);
}
*content = buffer;
return true;
}