cybersecurity · intermediate · ~15 min
Field-skipping on quasi-structured text.
Implement int log_status_code(const char *line) that, given a Common Log Format line such as
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
returns the HTTP status code (the integer after the closing " of the request). Return -1 on a malformed line.
int log_status_code(const char *line) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.