FreeCalypso > hg > sipout-test-utils
view libsip/grok_from.c @ 15:71f01a834820
sipout-test-voice: implement play with offset
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 May 2024 22:27:07 -0800 |
parents | 35c0d9f03c0a |
children |
line wrap: on
line source
/* * Here we implement further parsing of the From header, * beyond the preliminary step of uas_get_basic_headers(). */ #include <ctype.h> #include <string.h> #include <strings.h> #include "grok_from.h" grok_from_header(from_hdr, gfr) char *from_hdr; struct grok_from *gfr; { char *cp = from_hdr, *bp; int bracketed; if (*cp == '<' || !strncasecmp(cp, "sip:", 4)) { gfr->cnam = 0; gfr->cnam_len = 0; gfr->cnam_quoted = 0; } else { if (*cp == '"') { cp++; gfr->cnam = cp; for (;;) { if (!*cp) return(-1); if (*cp == '"') break; if (*cp++ == '\\') { if (!*cp) return(-1); cp++; } } gfr->cnam_len = cp - gfr->cnam; gfr->cnam_quoted = 1; cp++; while (isspace(*cp)) cp++; if (*cp != '<') return(-1); } else { gfr->cnam = cp; for (;;) { if (!*cp) return(-1); if (*cp == '<') break; cp++; } for (bp = cp; bp > gfr->cnam && isspace(bp[-1]); bp--) ; gfr->cnam_len = bp - gfr->cnam; gfr->cnam_quoted = 0; } } if (*cp == '<') { cp++; bracketed = 1; } else bracketed = 0; gfr->uri = cp; if (strncasecmp(cp, "sip:", 4)) return(-1); cp += 4; gfr->user = cp; for (;;) { if (!*cp || *cp == '<' || *cp == '>') return(-1); if (*cp == '@') break; cp++; } if (cp == gfr->user) return(-1); gfr->user_len = cp - gfr->user; cp++; for (;;) { switch (*cp) { case '\0': case ';': if (bracketed) return(-1); else break; case '>': if (bracketed) break; else return(-1); case '<': return(-1); default: cp++; continue; } break; } gfr->uri_len = cp - gfr->uri; return(0); }