Skip to content

Instantly share code, notes, and snippets.

Created March 19, 2016 07:23
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/9b456e088be7e3854b7d to your computer and use it in GitHub Desktop.
Save anonymous/9b456e088be7e3854b7d to your computer and use it in GitHub Desktop.
indexes.c
char* indexes(const char* path)
{
char* a = "/index.html";
char* b = "/index.php";
char* indexhtml = malloc(strlen(a) + strlen(path) + 1);
strcpy(indexhtml, path);
strcat(indexhtml, a);
char* indexphp = malloc(strlen(b) + strlen(path) + 1);
strcpy(indexphp, path);
strcat(indexphp, b);
if(access(indexhtml, F_OK) == 1)
{
return indexhtml;
}
else if(access(indexphp, F_OK) == 1)
{
return indexphp;
}
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment