networking · intermediate · ~15 min
Extract the SIP method token.
A SIP request line looks like INVITE sip:bob@host SIP/2.0. Implement int sip_method(const char *line, char *out, int outsz) copying the first token (method) into out, returning its length, or -1 if there is no space.
#include <string.h>
int sip_method(const char *line, char *out, int outsz) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.