sip_header.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * This file is part of the Sofia-SIP package
  3. *
  4. * Copyright (C) 2005 Nokia Corporation.
  5. *
  6. * Contact: Pekka Pessi <pekka.pessi@nokia.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. /**@CFILE sip_header.c
  25. *
  26. * SIP header handling.
  27. *
  28. * @author Pekka Pessi <Pekka.Pessi@nokia.com>.
  29. *
  30. * @date Created: Tue Jun 13 02:57:51 2000 ppessi
  31. */
  32. #include "config.h"
  33. /* Avoid casting sip_t to msg_pub_t and sip_header_t to msg_header_t */
  34. #define MSG_PUB_T struct sip_s
  35. #define MSG_HDR_T union sip_header_u
  36. /* Get bodies of inlined functions included in library */
  37. #define SIP_STATIC_INLINE
  38. #include <sofia-sip/su_alloc.h>
  39. #include "sofia-sip/sip_parser.h"
  40. #include <sofia-sip/sip_status.h>
  41. #include <stddef.h>
  42. #include <stdlib.h>
  43. #include <string.h>
  44. #include <stdio.h>
  45. #include <limits.h>
  46. #include <stdarg.h>
  47. #include <assert.h>
  48. /** Copy a SIP header.
  49. *
  50. * @deprecated Use msg_header_copy() instead.
  51. */
  52. sip_header_t *sip_header_copy(su_home_t *home, sip_header_t const *h)
  53. {
  54. if (h == NULL || h == SIP_NONE)
  55. return NULL;
  56. return msg_header_copy_as(home, h->sh_class, h);
  57. }
  58. /** Duplicate a SIP header.
  59. *
  60. * @deprecated Use msg_header_dup() instead.
  61. */
  62. sip_header_t *sip_header_dup(su_home_t *home, sip_header_t const *h)
  63. {
  64. if (h == NULL || h == SIP_NONE)
  65. return NULL;
  66. return msg_header_dup_as(home, h->sh_class, h);
  67. }
  68. /** Decode a SIP header.
  69. *
  70. * @deprecated Use msg_header_d() instead.
  71. */
  72. sip_header_t *sip_header_d(su_home_t *home, msg_t const *msg, char const *b)
  73. {
  74. return msg_header_d(home, msg, b);
  75. }
  76. /** Encode a SIP header.
  77. *
  78. * @deprecated Use msg_header_e() instead.
  79. */
  80. issize_t sip_header_e(char b[], isize_t bsiz, sip_header_t const *h, int flags)
  81. {
  82. return msg_header_e(b, bsiz, (msg_header_t const *)h, flags);
  83. }
  84. sip_header_t *sip_header_format(su_home_t *home,
  85. msg_hclass_t *hc,
  86. char const *fmt,
  87. ...)
  88. {
  89. sip_header_t *h;
  90. va_list ap;
  91. va_start(ap, fmt);
  92. h = msg_header_vformat(home, hc, fmt, ap);
  93. va_end(ap);
  94. return h;
  95. }
  96. /** Add a duplicate of header object to a SIP message. */
  97. int sip_add_dup(msg_t *msg,
  98. sip_t *sip,
  99. sip_header_t const *o)
  100. {
  101. return msg_header_add_dup(msg, (msg_pub_t *)sip, o);
  102. }
  103. int sip_add_dup_as(msg_t *msg,
  104. sip_t *sip,
  105. msg_hclass_t *hc,
  106. sip_header_t const *o)
  107. {
  108. return msg_header_add_dup_as(msg, (msg_pub_t *)sip, hc, o);
  109. }
  110. int sip_add_make(msg_t *msg,
  111. sip_t *sip,
  112. msg_hclass_t *hc,
  113. char const *s)
  114. {
  115. return msg_header_add_make(msg, sip, hc, s);
  116. }