Skip to content

Instantly share code, notes, and snippets.

/server.c Secret

Created December 24, 2016 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7432e4874a2b967cd0c58127b65e230b to your computer and use it in GitHub Desktop.
Save anonymous/7432e4874a2b967cd0c58127b65e230b to your computer and use it in GitHub Desktop.
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