I am having problems while running check50 2015.fall.pset6.server2 server.c
The thing is that all echecks are correct except these 2:
:( Requesting /test/ outputs /test/index.html \ expected an exit code of 0, not standard error of "======= Backtrace: =========\n======= M..."
:( Requesting directory containing index.php outputs index.php \ expected output, not standard error of "======= Backtrace: =========\n======= M..."
I have looked and looked but I don't see where the problem may be. I think it has to be with indexes function. I have done all kind of weird things to it as you can see, but it doesn't work, please see code:
char* indexes(const char* path) {
char* php;
char* html;
char* dir;
if (path == NULL)
{
return NULL;
}
if (path[0] == '/')
{
path++;
}
// check to see if dir ends with a /
if (strcmp(&path[(strlen(path) - 1)], "/") == 0)
{
php = "index.php";
html = "index.html";
}
else
{
php = "/index.php";
html = "/index.html";
}
dir = malloc(sizeof(strlen(path) + strlen(php) + 1));
strcpy(dir, path);
strcat(dir, php);
dir[strlen(path) + strlen(php)] = '\0';
if (access(dir, F_OK) != -1)
{
return dir;
}
else
{
free(dir);
dir = malloc(sizeof(strlen(path) + strlen(html) + 1));
strcpy(dir, path);
strcat(dir, html);
dir[strlen(path) + strlen(html)] = '\0';
if (access(dir, F_OK) != -1)
{
return dir;
}
free(dir);
}
return NULL;}
Thanks for any help!!