networking · intermediate · ~15 min

SIP status code

Parse a SIP response status.

Challenge

A SIP response line looks like SIP/2.0 200 OK. Implement int sip_status_code(const char *line) returning the numeric status, or -1 if it doesn't start with SIP/.

Starter code

#include <string.h>
#include <stdlib.h>

int sip_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.