Skip to content

Instantly share code, notes, and snippets.

/server.c Secret

Created Dec 24, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.