Blame view

3rdparty/libosip2-5.3.0/release/include/osipparser2/osip_body.h 3.26 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
  /*
    The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
    Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com
  
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
  
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
  
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  
  #ifndef _OSIP_BODY_H_
  #define _OSIP_BODY_H_
  
  #include <osipparser2/headers/osip_content_type.h>
  
  /**
   * @file osip_body.h
   * @brief oSIP SIP Message Body Routines
   *
   */
  
  /**
   * @defgroup oSIP_BODY oSIP body API
   * @ingroup osip2_parser
   * @{
   */
  
  /**
   * Structure for holding Body
   * @var osip_body_t
   */
  typedef struct osip_body osip_body_t;
  
  /**
   * Structure for holding Body
   * @struct osip_body
   */
  struct osip_body {
    char *body;           /**< buffer containing data */
    size_t length;        /**< length of data */
    osip_list_t *headers; /**< List of headers (when mime is used) */
    osip_content_type_t *content_type;
    /**< Content-Type (when mime is used) */
  };
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  /**
   * Allocate a osip_body_t element.
   * @param body The element to work on.
   */
  int osip_body_init(osip_body_t **body);
  /**
   * Free a osip_body_t element.
   * @param body The element to work on.
   */
  void osip_body_free(osip_body_t *body);
  /**
   * Parse a osip_body_t element.
   * @param body The element to work on.
   * @param buf The buffer to parse.
   * @param length The length of the buffer to parse.
   */
  int osip_body_parse(osip_body_t *body, const char *buf, size_t length);
  /**
   * Clone a osip_body_t element.
   * @param body The element to clone.
   * @param dest The cloned element.
   */
  int osip_body_clone(const osip_body_t *body, osip_body_t **dest);
  /**
   * Parse a osip_body_t element. (for mime message format) (NOT TESTED, use with care)
   * @param body The element to work on.
   * @param buf The buffer to parse.
   * @param length The length of the buffer to parse.
   */
  int osip_body_parse_mime(osip_body_t *body, const char *buf, size_t length);
  /**
   * Get a string representation of a osip_body_t element.
   * @param body The element to work on.
   * @param dest The resulting buffer.
   * @param length The length of the returned buffer.
   */
  int osip_body_to_str(const osip_body_t *body, char **dest, size_t *length);
  
  /**
   * Set the Content-Type header in the osip_body_t element.
   * @param body The element to work on.
   * @param hvalue The content type string value.
   */
  int osip_body_set_contenttype(osip_body_t *body, const char *hvalue);
  
  /**
   * Add a header in the osip_body_t element.
   * @param body The element to work on.
   * @param hname The header string name.
   * @param hvalue The header string value.
   */
  int osip_body_set_header(osip_body_t *body, const char *hname, const char *hvalue);
  
  #ifdef __cplusplus
  }
  #endif
  /** @} */
  #endif