Below is my parse function in server.c pset6; The code is not fully commented yet, my bad; Nonetheless, why are all exit code 0 in check50, where is the loophole? Thank you.
bool parse(const char* line, char* abs_path, char* query)
{
// TODO
char * version = " HTTP/1.1";
char * method = NULL;
char * target = NULL;
char x = '?', y = '/', z = '"';
int n = strlen(query);
int p = strlen(target);
int a = strlen(line);
int b = strlen(method);
int c = strlen(version);
int d = (a - b);
int e = (d - c);
int q = (p - n);
if(line != NULL)
{
if(strchr(line, z) == 0)
{
error(400);
}
strncpy(method, line, 3);
method[3] = '\0';
if(strstr(method, "GET") != 0)
{
error(405);
}
else if(strstr(method, "GET") == 0)
{
for(int i = 0; i <= e; i++)
{
strncpy(target, line+4, d);
}
while(target != NULL)
{
if(strchr(target, z) == 0)
{
error(400);
}
if(target[1] != y)
{
error(501);
}
if(strstr(target, version) != 0)
{
error(505);
}
query = strchr(target, x);
strncpy(abs_path, target, q);
if(strchr(abs_path, '.') != 0)
{
error(501);
}
}
}
}
error(501);
return false;
}