Commit 28994659 authored by Pekka Pessi's avatar Pekka Pessi

Added @deprecated to deprecated sip functions.

darcs-hash:20060511134702-65a35-e5d6b108013ee7c85c153bc9b673ea34f21e1840.gz
parent 7f513dd6
......@@ -784,7 +784,7 @@ int sip_addr_d(su_home_t *home,
char *s,
int slen)
{
sip_addr_t *a = h->sh_addr;
sip_addr_t *a = (sip_addr_t *)h;
char const *comment = NULL;
if (sip_name_addr_d(home,
&s,
......@@ -796,13 +796,13 @@ int sip_addr_d(su_home_t *home,
return -1;
a->a_tag = msg_params_find(a->a_params, "tag=");
return 0;
}
static int sip_addr_e(char b[], int bsiz, sip_header_t const *h, int flags)
{
sip_addr_t const *a = h->sh_addr;
sip_addr_t const *a = (sip_addr_t const *)h;
return sip_name_addr_e(b, bsiz,
flags,
......@@ -827,7 +827,7 @@ static
int sip_addr_dup_xtra(sip_header_t const *h, int offset)
{
int rv = offset;
sip_addr_t const *a = h->sh_addr;
sip_addr_t const *a = (sip_addr_t const *)h;
MSG_PARAMS_SIZE(rv, a->a_params);
rv += MSG_STRING_SIZE(a->a_display);
......@@ -842,16 +842,14 @@ int sip_addr_dup_xtra(sip_header_t const *h, int offset)
static char *sip_addr_dup_one(sip_header_t *dst, sip_header_t const *src,
char *b, int xtra)
{
sip_addr_t *a = dst->sh_addr;
sip_addr_t const *o = src->sh_addr;
sip_addr_t *a = (sip_addr_t *)dst;
sip_addr_t const *o = (sip_addr_t *)src;
char *end = b + xtra;
b = msg_params_dup(&a->a_params, o->a_params, b, xtra);
MSG_STRING_DUP(b, a->a_display, o->a_display);
URL_DUP(b, end, a->a_url, o->a_url);
a->a_tag = msg_params_find(a->a_params, "tag=");
assert(b <= end);
return b;
......@@ -897,36 +895,8 @@ sip_addr_make_url(su_home_t *home, msg_hclass_t *hc, url_string_t const *us)
return NULL;
}
/**
* Add a parameter to an addr object.
*
* The function sip_addr_add_param() adds a parameter to an sip_addr_t
* object.
*
* @param home memory home
* @param a sip_addr_t object
* @param param parameter string
*
* @return The function sip_addr_add_param() returns 0 when successful,
* and -1 upon an error. */
/** Add a tag to address structure. */
static
int sip_addr_add_param(su_home_t *home,
sip_addr_t *a,
char const *param)
{
sip_fragment_clear(a->a_common);
if (msg_params_replace(home, (msg_param_t **)&a->a_params, param) < 0)
return -1;
a->a_tag = msg_params_find(a->a_params, "tag=");
return 0;
}
/** Add a tag to address structure.
*
*
*/
int sip_addr_tag(su_home_t *home, sip_addr_t *a, char const *tag)
{
if (a && tag) {
......@@ -950,7 +920,8 @@ int sip_addr_tag(su_home_t *home, sip_addr_t *a, char const *tag)
tag = su_strdup(home, tag);
if (tag)
return sip_addr_add_param(home, a, tag);
if (msg_header_replace_param(home, a->a_common, tag) >= 0)
return 0;
}
return -1;
......@@ -1005,7 +976,7 @@ int sip_call_id_d(su_home_t *home,
{
sip_call_id_t *i = h->sh_call_id;
i->i_id = s;
i->i_id = s; /* XXX - why not sip_word_at_word_d(&s); */
i->i_hash = msg_hash_string(s);
return 0;
......@@ -1431,7 +1402,7 @@ static int sip_contact_update(msg_common_t *h,
* The function sip_contact_add_param() adds a parameter to a contact
* object. It does not copy the contents of the string @c param.
*
* @note This function @b does @b not @b duplicate @p param.
* @note This function @b does @b not duplicate @p param.
*
* @param home memory home
* @param m sip_contact_t object
......@@ -1783,7 +1754,7 @@ int sip_from_add_param(su_home_t *home,
sip_from_t *from,
char const *param)
{
return sip_addr_add_param(home, from, param);
return msg_header_replace_param(home, from->a_common, param);
}
/**@ingroup sip_from
......@@ -1799,9 +1770,8 @@ int sip_from_add_param(su_home_t *home,
* @param from @b From header to modify
* @param tag tag token or parameter to be added
*
* @return
* The function sip_from_tag() returns 0 when successful, or -1 upon an
* error.
* @retval 0 when successful
* @retval -1 upon an error.
*/
int sip_from_tag(su_home_t *home, sip_from_t *from, char const *tag)
{
......@@ -2424,18 +2394,22 @@ sip_to_create(su_home_t *home, url_string_t const *url)
* The function sip_to_add_param() adds a parameter to an sip_to_t
* object.
*
* @note This function @b does @b not duplicate @p param.
*
* @param home memory home
* @param to sip_to_t object
* @param param parameter string
*
* @return The function sip_to_add_param() returns 0 when successful,
* or -1 upon an error.
*
* @deprecated Use msg_header_replace_param() directly.
*/
int sip_to_add_param(su_home_t *home,
sip_to_t *to,
char const *param)
{
return sip_addr_add_param(home, to, param);
return msg_header_replace_param(home, to->a_common, param);
}
/* ====================================================================== */
......@@ -2674,7 +2648,7 @@ static int sip_via_update(msg_common_t *h,
*
* Add a parameter to a via object.
*
* @note This function @b does @b not @b duplicate @p param.
* @note This function @b does @b not duplicate @p param.
*
* @param home memory home
* @param v sip_via_t object
......@@ -2682,6 +2656,8 @@ static int sip_via_update(msg_common_t *h,
*
* @retval 0 when successful
* @retval -1 upon an error.
*
* @deprecated Use msg_header_replace_param() directly.
*/
int sip_via_add_param(su_home_t *home,
sip_via_t *v,
......
......@@ -207,15 +207,20 @@ int sip_allow_events_e(char b[], int bsiz, sip_header_t const *h, int f)
return msg_list_e(b, bsiz, h, f);
}
/** Append an event to a Allow-Events header. */
/** Append an event to a Allow-Events header.
*
* @note This function @b does @b duplicate @p event.
*
* @deprecated Use msg_header_replace_param() directly.
*/
int sip_allow_events_add(su_home_t *home,
sip_allow_events_t *ae,
char const *e)
char const *event)
{
e = su_strdup(home, e);
if (!e)
event = su_strdup(home, event);
if (!event)
return -1;
return msg_params_replace(home, (msg_param_t **)&ae->k_items, e);
return msg_header_replace_param(home, ae->k_common, event);
}
/* ====================================================================== */
......
......@@ -53,7 +53,10 @@
#include <assert.h>
/** Copy a SIP header. */
/** Copy a SIP header.
*
* @deprecated Use msg_header_copy() instead.
*/
sip_header_t *sip_header_copy(su_home_t *home, sip_header_t const *h)
{
if (h == NULL || h == SIP_NONE)
......@@ -61,7 +64,10 @@ sip_header_t *sip_header_copy(su_home_t *home, sip_header_t const *h)
return msg_header_copy_as(home, h->sh_class, h);
}
/** Duplicate a SIP header. */
/** Duplicate a SIP header.
*
* @deprecated Use msg_header_dup() instead.
*/
sip_header_t *sip_header_dup(su_home_t *home, sip_header_t const *h)
{
if (h == NULL || h == SIP_NONE)
......@@ -70,13 +76,19 @@ sip_header_t *sip_header_dup(su_home_t *home, sip_header_t const *h)
}
/** Decode a SIP header. */
/** Decode a SIP header.
*
* @deprecated Use msg_header_d() instead.
*/
sip_header_t *sip_header_d(su_home_t *home, msg_t const *msg, char const *b)
{
return msg_header_d(home, msg, b);
}
/** Encode a SIP header. */
/** Encode a SIP header.
*
* @deprecated Use msg_header_e() instead.
*/
int sip_header_e(char b[], int bsiz, sip_header_t const *h, int flags)
{
return msg_header_e(b, bsiz, (msg_header_t const *)h, flags);
......
......@@ -494,11 +494,11 @@ char *sip_word_at_word_d(char **ss)
/**Add message separator, then test if message is complete.
*
* Add sip_content_length and sip_separator if they are missing.
* It then tests that all necessary message components (@b From, @b To, @b
* The test that all necessary message components (@b From, @b To, @b
* CSeq, @b Call-ID, @b Content-Length and message separator are present.
*
* @retval 0 when successful
* @retval -1 upon an error
* @retval -1 upon an error: headers are missing and they could not be added
*/
int sip_complete_message(msg_t *msg)
{
......
......@@ -347,7 +347,20 @@ sip_sanity_check(sip_t const *sip)
return 0;
}
/** Decode the header string */
/** Decode a string containg header field.
*
* The header object is initialized with the contents of the string. The
* string is modified when parsing. The home is used to allocate extra
* memory required when parsing, e.g., for parameter list or when there
* string contains multiple header fields.
*
* @deprecated
* Use msg_header_make() or header-specific make functions, e.g.,
* sip_via_make().
*
* @retval 0 when successful
* @retval -1 upon an error.
*/
int sip_header_field_d(su_home_t *home, sip_header_t *h, char *s, int slen)
{
assert(SIP_HDR_TEST(h));
......@@ -367,12 +380,13 @@ int sip_header_field_d(su_home_t *home, sip_header_t *h, char *s, int slen)
return -1;
}
/** Encode a SIP header contents. */
/** Encode a SIP header contents.
*
* @deprecated Use msg_header_field_e() instead.
*/
int sip_header_field_e(char *b, int bsiz, sip_header_t const *h, int flags)
{
assert(h); assert(h->sh_class);
return h->sh_class->hc_print(b, bsiz, h, flags);
return msg_header_field_e(b, bsiz, h, flags);
}
/** Convert the header @a h to a string allocated from @a home. */
......@@ -734,11 +748,15 @@ unsigned long sip_payload_serialize(msg_t *msg, sip_payload_t *pl)
}
/**
* Remove extra parameters from an AOR URL. The parameters listed in the RFC
* 3261 table 1 include port number, method, maddr, ttl, transport, lr and
* headers.
* Remove extra parameters from an AOR URL.
*
* The extra parameters listed in the RFC 3261 table 1 include port number,
* method, maddr, ttl, transport, lr and headers.
*
* @note The funtion modifies the @a url.
* @note The funtion modifies the @a url and the strings attached to it.
*
* @retval 0 when successful
* @retval -1 upon an error
*/
int sip_aor_strip(url_t *url)
{
......
......@@ -369,7 +369,9 @@ int test_basic(void)
TEST_1(sip_from_add_param(home, f, "tag=tagged") == 0);
TEST_S(f->a_tag, "tagged");
TEST_1(sip_from_tag(home, f, "jxahudsf") == -1);
f->a_params = NULL;
while (f->a_params && f->a_params[0])
msg_header_remove_param(f->a_common, f->a_params[0]);
TEST(f->a_tag, NULL);
TEST_1(sip_from_add_param(home, f, "test=1") == 0);
TEST_1(sip_from_tag(home, f, "jxahudsf") == 0);
TEST_S(f->a_tag, "jxahudsf");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment