comparison 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
comparison
equal deleted inserted replaced
45:f1cf80c7e243 46:5427b26525cd
1 /*
2 * Some utility functions for working with SIP URIs.
3 */
4
5 #include <string.h>
6 #include <strings.h>
7
8 user_from_sip_uri(uri, outbuf, maxlen)
9 char *uri, *outbuf;
10 unsigned maxlen;
11 {
12 char *cp, *dp;
13 unsigned n;
14
15 if (strncasecmp(uri, "sip:", 4))
16 return(-1);
17 cp = uri + 4;
18 dp = outbuf;
19 n = 0;
20 for (;;) {
21 if (!*cp)
22 return(-1);
23 if (*cp == '@')
24 break;
25 if (n >= maxlen)
26 return(-2);
27 *dp++ = *cp++;
28 n++;
29 }
30 *dp = '\0';
31 return(0);
32 }