URI Parser APIs
To demonstrate how to use the libosip2 parser, the simplest way is to start playing with URI. (Uniform Resource Identifier)
For each parser (headers, SIP message or URI), you'll always find something close to this minimal subset of methods:
xxxx_init(osip_xxx_t **el);
xxxx_free(osip_xxx_t *el);
xxxx_parse(osip_xxx_t *el, char *source);
xxxx_to_str(osip_xxx_t *el, char **dest);
For the URI parser, the API is documented in osip_uri.h
Basic URI operations
- Here is the sequence needed to parse a given buffer containing a sip URI:
int i;
if (i!=0) { fprintf(stderr, "cannot allocate\n"); return -1; }
if (i!=0) { fprintf(stderr, "cannot parse uri\n"); }
int osip_uri_parse(osip_uri_t *url, const char *buf)
Definition: osip_uri.c:99
void osip_uri_free(osip_uri_t *url)
Definition: osip_uri.c:791
int osip_uri_init(osip_uri_t **url)
Definition: osip_uri.c:31
Definition: osip_uri.h:167
char *dest;
if (i!=0) { fprintf(stderr, "cannot get printable URI\n"); return -1; }
fprintf(stdout, "URI: %s\n", dest);
osip_free(dest);
int osip_uri_to_str(const osip_uri_t *url, char **dest)
Definition: osip_uri.c:569