Everything is working except for hello.php.
In the load function I try to obtain the length of the file passed to it as shown, but when hello.php is interpreted and the load function is called, it returns a length of zero for the generated file and thus a 500 Internal Server error when the content is read in the interpret function.
bool load(FILE* file, BYTE** content, size_t* length)
{
// get file size
int fileref = fileno(file);
struct stat st;
fstat(fileref, &st);
*length = st.st_size;
//make space for file content
*content = malloc(sizeof(BYTE) * *length);
//reading file into content
fread(*content, sizeof(BYTE), *length, file);
if (*content != NULL)
return true;
else
return false;
}
This seems particularly strange because when I check the file that gets passed into it via the interpret function by printing its characters, I see the following:
X-Powered-By: PHP/5.5.9-1ubuntu4.14
Content-type: text/html
<!DOCTYPE html>
<html>
<head>
<title>hello</title>
</head>
<body>
hello, Bob </body>
</html>
How could this return a length of zero?