On the first check I get all correct except error 404. Not sure where to implement that. After implementing Indexes and Load, I tried check50 only to get Unexpected end of input. Not sure how to debug this one. Any suggestion?
I'll provide my code for load and indexes since there wrong. If I'm breaking a rule, please let me know admin.
char* indexes(const char* path)
{
char* iphp = "/index.php";
char* ihtml = "/index.html";
char* ipc = malloc(strlen(path) + strlen(iphp) + 1 );
char* ihc = malloc(strlen(path) + strlen(ihtml) + 1);
strcpy(ipc, path);
strcpy(ihc, path);
strcat(ipc, iphp);
strcat(ihc, ihtml);
printf("ihc: %s\nipc: %s\n", ihc, ipc);
if (access(ipc, F_OK) == 0){
free(ihc);
return ipc;
}
else if (access(ihc, F_OK) == 0){
free(ipc);
return ihc;
}
else{
free(ipc);
free(ihc);
return NULL;
}
}
bool load(FILE* file, BYTE** content, size_t* length)
{
if (file == NULL){
return false;
}
int counter = 0;
char c;
char* toc = malloc(1);
while( (c = fgetc(file)) != EOF){
toc[counter] = c;
counter++;
toc = realloc(toc,counter + 1);
}
*length = 0;
*content = toc;
*length = counter;
return true;
}