📄 group__howto1__uri.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>libosip: How-To parse URI.</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.8 --><div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div><h1>How-To parse URI.<br><small>[<a class="el" href="group__libosip2.html">The GNU oSIP stack</a>]</small></h1><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr></table>To demonstrate how to use the libosip2 parser, the simplest way is to start playing with URI. (Uniform Resource Identifier)<p>For each parser (headers, SIP message or URI), you'll always find something close to this minimal subset of methods:<p><pre> // allocation/release of memory. xxxx_init(osip_xxx_t **el); xxxx_free(osip_xxx_t *el);</pre><p><pre> xxxx_parse(osip_xxx_t *el, char *source); xxxx_to_str(osip_xxx_t *el, char **dest);</pre><p><pre></pre><p>For the URI parser, the API is documented in <a class="el" href="osip__uri_8h.html">osip_uri.h</a><p>Here is the sequence needed to parse a given buffer containing a sip URI:<p><pre> osip_uri_t *uri; int i;</pre><p><pre> 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><p>Here is the sequence needed to convert the URI into a printable string. Note that in this sequence, dest is allocated dynamically and must be released at the end of the call sequence to avoid memory leaks.<p><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> <hr size="1"><address style="align: right;"><small>Generated on Tue Sep 7 15:08:00 2004 for libosip by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -