FreeCalypso > hg > sipout-test-utils
view libsip/to_tag.c @ 8:eaf0e8f81a22
test-fsk: don't feed RTP to modem Rx during ringing
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 06 Mar 2024 21:33:49 -0800 |
parents | 35c0d9f03c0a |
children |
line wrap: on
line source
/* * The function implemented in this module extracts the tag * from the To header of a SIP destination server's response. */ #include <ctype.h> #include <string.h> #include <strings.h> #include <stdio.h> #include <stdlib.h> #include "parse.h" extern char *get_single_header(); char * extract_to_tag(msg, expect_uri) struct sip_pkt_rx *msg; char *expect_uri; { char *cp, *tag; int bracketed, c; unsigned expect_uri_len; cp = get_single_header(msg, "To", "t", (int *) 0); if (!cp) return 0; if (*cp == '<') { cp++; bracketed = 1; } else bracketed = 0; expect_uri_len = strlen(expect_uri); if (strncasecmp(cp, expect_uri, expect_uri_len)) return 0; cp += expect_uri_len; if (bracketed) { if (*cp++ != '>') return 0; } while (isspace(*cp)) cp++; if (*cp++ != ';') return 0; while (isspace(*cp)) cp++; if (strncasecmp(cp, "tag", 3)) return 0; cp += 3; while (isspace(*cp)) cp++; if (*cp++ != '=') return 0; while (isspace(*cp)) cp++; tag = cp; for (; c = *cp; cp++) { switch (c) { case '-': case '.': case '!': case '%': case '*': case '_': case '+': case '`': case '\'': case '~': continue; default: if (isalnum(c)) continue; return 0; } } return tag; }