-
-
Save anonymous/7432e4874a2b967cd0c58127b65e230b to your computer and use it in GitHub Desktop.
server.c - shared from CS50 IDE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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