server.c - shared from CS50 IDE
char* indexes(const char* path) | |
{ | |
// TODO | |
{ | |
size_t n = (strlen(path) + 12); | |
char * string = (char *) malloc(n); | |
if(strstr(path, "/index.php") == NULL) | |
{ | |
return NULL; | |
} | |
if(strstr(path, "/index.php") != NULL) | |
{ | |
strcpy(string, path); | |
strcat(string, "/index.php"); | |
if(access(string, F_OK) == 0) | |
return string; | |
} | |
if(strstr(path,"/index.html") == NULL) | |
{ | |
return NULL; | |
} | |
if(strstr(path, "/index.html") != NULL) | |
{ | |
strcpy(string, path); | |
strcat(string, "/index.html"); | |
if(access(string, F_OK) == 0) | |
return string; | |
} | |
free(string); | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment