Blame view

3rdparty/libosip2-5.3.0/help/doxygen/ht1-uri.dox 1.36 KB
73ef4ff3   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  /**
   * @ingroup libosip2 The GNU oSIP stack
   * @defgroup howto_uri How-To parse URI.
  
   * @section howto_uri1 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:
  
  ~~~~~~~{.c}
  	// 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);
  	
  ~~~~~~~
  
  For the URI parser, the API is documented in osip_uri.h
  
   * @section howto_uri2 Basic URI operations
  
  + Here is the sequence needed to parse a given buffer containing a sip URI:
  
  ~~~~~~~{.c}
          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);
  ~~~~~~~
  
  + Here is the sequence needed to convert the URI into a printable
  string.
  
  **Note**: dest is allocated dynamically and must be released at the end
  of the call sequence to avoid memory leaks.
  
  ~~~~~~~{.c}
  	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);
  ~~~~~~~
  
  */