sip_header.c 3.12 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
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
 * 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., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

/**@CFILE sip_header.c
 *
 * SIP header handling.
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>.
 *
 * @date Created: Tue Jun 13 02:57:51 2000 ppessi
 */

#include "config.h"

36 37 38 39 40 41 42 43 44 45 46
/* Avoid casting sip_t to msg_pub_t and sip_header_t to msg_header_t */
#define MSG_PUB_T       struct sip_s
#define MSG_HDR_T       union sip_header_u

/* Get bodies of inlined functions included in library */
#define SIP_STATIC_INLINE

#include <sofia-sip/su_alloc.h>
#include "sofia-sip/sip_parser.h"
#include <sofia-sip/sip_status.h>

Pekka Pessi's avatar
Pekka Pessi committed
47 48 49 50 51 52 53 54 55
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>
#include <stdarg.h>

#include <assert.h>

56 57 58 59
/** Copy a SIP header.
 *
 * @deprecated Use msg_header_copy() instead.
 */
Pekka Pessi's avatar
Pekka Pessi committed
60 61 62 63 64 65 66
sip_header_t *sip_header_copy(su_home_t *home, sip_header_t const *h)
{
  if (h == NULL || h == SIP_NONE)
    return NULL;
  return msg_header_copy_as(home, h->sh_class, h);
}

67 68 69 70
/** Duplicate a SIP header.
 *
 * @deprecated Use msg_header_dup() instead.
 */
Pekka Pessi's avatar
Pekka Pessi committed
71 72 73 74 75 76 77 78
sip_header_t *sip_header_dup(su_home_t *home, sip_header_t const *h)
{
  if (h == NULL || h == SIP_NONE)
    return NULL;
  return msg_header_dup_as(home, h->sh_class, h);

}

79 80 81 82
/** Decode a SIP header.
 *
 * @deprecated Use msg_header_d() instead.
 */
Pekka Pessi's avatar
Pekka Pessi committed
83 84 85 86 87
sip_header_t *sip_header_d(su_home_t *home, msg_t const *msg, char const *b)
{
  return msg_header_d(home, msg, b);
}

88
/** Encode a SIP header.
89 90 91
 *
 * @deprecated Use msg_header_e() instead.
 */
92
issize_t sip_header_e(char b[], isize_t bsiz, sip_header_t const *h, int flags)
Pekka Pessi's avatar
Pekka Pessi committed
93
{
Pekka Pessi's avatar
Pekka Pessi committed
94
  return msg_header_e(b, bsiz, (msg_header_t const *)h, flags);
Pekka Pessi's avatar
Pekka Pessi committed
95 96
}

97
sip_header_t *sip_header_format(su_home_t *home,
Pekka Pessi's avatar
Pekka Pessi committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
				msg_hclass_t *hc,
				char const *fmt,
				...)
{
  sip_header_t *h;
  va_list ap;

  va_start(ap, fmt);

  h = msg_header_vformat(home, hc, fmt, ap);

  va_end(ap);

  return h;
}

/** Add a duplicate of header object to a SIP message. */
int sip_add_dup(msg_t *msg,
		sip_t *sip,
		sip_header_t const *o)
{
Pekka Pessi's avatar
Pekka Pessi committed
119
  return msg_header_add_dup(msg, (msg_pub_t *)sip, o);
Pekka Pessi's avatar
Pekka Pessi committed
120 121 122 123 124 125 126
}

int sip_add_dup_as(msg_t *msg,
		   sip_t *sip,
		   msg_hclass_t *hc,
		   sip_header_t const *o)
{
Pekka Pessi's avatar
Pekka Pessi committed
127
  return msg_header_add_dup_as(msg, (msg_pub_t *)sip, hc, o);
Pekka Pessi's avatar
Pekka Pessi committed
128 129 130 131 132 133 134 135 136
}

int sip_add_make(msg_t *msg,
		 sip_t *sip,
		 msg_hclass_t *hc,
		 char const *s)
{
  return msg_header_add_make(msg, sip, hc, s);
}