Based on the staff's use of access() in server.c and the documentation, I figured I could use it to see if the index.html/php exist. Unfortunately, whenever I try to use access, GDB tells me this whenever the function is called:
No symbol "F_OK" in current context.
I tried googling but foind nothing, so any hints and tips as to what is wrong would be appreciated.
My code is as follows:
char* indexes(const char* path)
{
// copy path into test string
char* test = malloc(BYTES);
strcpy(test, path);
// create separate string for index.php
char* index_php = "index.php";
// concatenate index.php to test string = newString
char* new_string = strcat(test, index_php);
// check that newString exists
if(access(new_string, F_OK) == 0)
{
free(test);
return new_string;
}
else
{
// create separate string for index.html
char* index_html = "index.html";
// concatenate index.html to test string = newString
strcat(test, index_html);
// check that newString exists
if(access(new_string, F_OK) == 0)
{
free(test);
return new_string;
}
}
free(test);
return NULL;
}