📄 ht1-uri.dox
字号:
/** * @ingroup libosip2 The GNU oSIP stack * @defgroup howto1_uri How-To parse URI.To demonstrate how to use the libosip2 parser, thesimplest way is to start playing with URI. (UniformResource Identifier)For each parser (headers, SIP message or URI), you'llalways find something close to this minimal subset ofmethods:<PRE> // allocation/release of memory. 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); </PRE>For the URI parser, the API is documented in osip_uri.hHere is the sequence needed to parse a given buffer containinga sip URI:<PRE> osip_uri_t *uri; int i; i=osip_uri_init(&uri); if (i!=0) { fprintf(stderr, "cannot allocate\n"); return -1; } i=osip_uri_parse(uri, buffer); if (i!=0) { fprintf(stderr, "cannot parse uri\n"); } osip_uri_free(uri);</PRE>Here is the sequence needed to convert the URI into a printablestring. Note that in this sequence, dest is allocated dynamicallyand must be released at the end of the call sequence to avoidmemory leaks.<PRE> char *dest; i = osip_uri_to_str(uri, &dest); if (i!=0) { fprintf(stderr, "cannot get printable URI\n"); return -1; } fprintf(stdout, "URI: %s\n", dest); osip_free(dest);</PRE>*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -