osip_body.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
  3. Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. */
  16. #ifndef _OSIP_BODY_H_
  17. #define _OSIP_BODY_H_
  18. #include <osipparser2/headers/osip_content_type.h>
  19. /**
  20. * @file osip_body.h
  21. * @brief oSIP SIP Message Body Routines
  22. *
  23. */
  24. /**
  25. * @defgroup oSIP_BODY oSIP body API
  26. * @ingroup osip2_parser
  27. * @{
  28. */
  29. /**
  30. * Structure for holding Body
  31. * @var osip_body_t
  32. */
  33. typedef struct osip_body osip_body_t;
  34. /**
  35. * Structure for holding Body
  36. * @struct osip_body
  37. */
  38. struct osip_body {
  39. char *body; /**< buffer containing data */
  40. size_t length; /**< length of data */
  41. osip_list_t *headers; /**< List of headers (when mime is used) */
  42. osip_content_type_t *content_type;
  43. /**< Content-Type (when mime is used) */
  44. };
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. /**
  49. * Allocate a osip_body_t element.
  50. * @param body The element to work on.
  51. */
  52. int osip_body_init(osip_body_t **body);
  53. /**
  54. * Free a osip_body_t element.
  55. * @param body The element to work on.
  56. */
  57. void osip_body_free(osip_body_t *body);
  58. /**
  59. * Parse a osip_body_t element.
  60. * @param body The element to work on.
  61. * @param buf The buffer to parse.
  62. * @param length The length of the buffer to parse.
  63. */
  64. int osip_body_parse(osip_body_t *body, const char *buf, size_t length);
  65. /**
  66. * Clone a osip_body_t element.
  67. * @param body The element to clone.
  68. * @param dest The cloned element.
  69. */
  70. int osip_body_clone(const osip_body_t *body, osip_body_t **dest);
  71. /**
  72. * Parse a osip_body_t element. (for mime message format) (NOT TESTED, use with care)
  73. * @param body The element to work on.
  74. * @param buf The buffer to parse.
  75. * @param length The length of the buffer to parse.
  76. */
  77. int osip_body_parse_mime(osip_body_t *body, const char *buf, size_t length);
  78. /**
  79. * Get a string representation of a osip_body_t element.
  80. * @param body The element to work on.
  81. * @param dest The resulting buffer.
  82. * @param length The length of the returned buffer.
  83. */
  84. int osip_body_to_str(const osip_body_t *body, char **dest, size_t *length);
  85. /**
  86. * Set the Content-Type header in the osip_body_t element.
  87. * @param body The element to work on.
  88. * @param hvalue The content type string value.
  89. */
  90. int osip_body_set_contenttype(osip_body_t *body, const char *hvalue);
  91. /**
  92. * Add a header in the osip_body_t element.
  93. * @param body The element to work on.
  94. * @param hname The header string name.
  95. * @param hvalue The header string value.
  96. */
  97. int osip_body_set_header(osip_body_t *body, const char *hname, const char *hvalue);
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. /** @} */
  102. #endif