Commit e5a0a06f authored by Pekka Pessi's avatar Pekka Pessi

sofia-sip/msg_header.h: added msg_header_add_format(()

darcs-hash:20080903173521-db55f-d2f25b4afa2f2e8fa7361b12e0f79fb4cf2f9a8c.gz
parent ccb645e0
......@@ -2732,6 +2732,44 @@ int msg_header_add_make(msg_t *msg,
return msg_header_add(msg, pub, hh, h);
}
/** Add formatting result to message.
*
* Parse result from printf-formatted params as a given header field and add
* result to the message.
*/
int msg_header_add_format(msg_t *msg,
msg_pub_t *pub,
msg_hclass_t *hc,
char const *fmt,
...)
{
msg_header_t *h, **hh;
va_list va;
if (msg == NULL)
return -1;
if (pub == NULL)
pub = msg->m_object;
hh = msg_hclass_offset(msg->m_class, pub, hc);
if (hh == NULL)
return -1;
if (!fmt)
return 0;
va_start(va, fmt);
h = msg_header_vformat(msg_home(msg), hc, fmt, va);
va_end(va);
if (!h)
return -1;
return msg_header_add(msg, pub, hh, h);
}
/**Add string contents to message.
*
* Duplicate a string containing headers (or a message body, if the string
......
......@@ -142,6 +142,12 @@ SOFIAPUBFUN int msg_header_add_make(msg_t *msg,
msg_hclass_t *hc,
char const *s);
SOFIAPUBFUN int msg_header_add_format(msg_t *msg,
msg_pub_t *pub,
msg_hclass_t *hc,
char const *fmt,
...);
SOFIAPUBFUN int msg_header_prepend(msg_t *msg,
msg_pub_t *pub,
msg_header_t **hh,
......
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