FreeCalypso > hg > themwi-system-sw
diff libsip/uri_utils.c @ 46:5427b26525cd
libsip: beginning to flesh out
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 06 Sep 2022 20:29:44 -0800 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libsip/uri_utils.c Tue Sep 06 20:29:44 2022 -0800 @@ -0,0 +1,32 @@ +/* + * Some utility functions for working with SIP URIs. + */ + +#include <string.h> +#include <strings.h> + +user_from_sip_uri(uri, outbuf, maxlen) + char *uri, *outbuf; + unsigned maxlen; +{ + char *cp, *dp; + unsigned n; + + if (strncasecmp(uri, "sip:", 4)) + return(-1); + cp = uri + 4; + dp = outbuf; + n = 0; + for (;;) { + if (!*cp) + return(-1); + if (*cp == '@') + break; + if (n >= maxlen) + return(-2); + *dp++ = *cp++; + n++; + } + *dp = '\0'; + return(0); +}