Commit 7795afe9 authored by Pekka Pessi's avatar Pekka Pessi

msg: added msg_header_parse_str()

darcs-hash:20061005140755-65a35-90c9894fac8a75d7d6b60b3045a22caa71181e8f.gz
parent 99594a00
......@@ -2577,10 +2577,18 @@ int msg_header_add_make(msg_t *msg,
return msg_header_add(msg, pub, hh, h);
}
/** Parse a string and add resulting headers to the message.
/**Add string contents to message.
*
* The function @a msg_header_add_str() parses a string and adds resulting
* header objects to the message object.
* Duplicate a string containing headers (or a message body, if the string
* starts with linefeed), parse it and add resulting header objects to the
* message object.
*
* @param msg message object
* @param pub message header structure where heades are added (may be NULL)
* @param s string to be copied and parsed (not modified, may be NULL)
*
* @retval 0 when succesful
* @retval -1 upon an error
*/
int msg_header_add_str(msg_t *msg,
msg_pub_t *pub,
......@@ -2590,13 +2598,44 @@ int msg_header_add_str(msg_t *msg,
if (!msg)
return -1;
if (pub == NULL)
pub = msg->m_object;
if (!str)
return 0;
s = su_strdup(msg_home(msg), str);
if (s == NULL)
return -1;
return msg_header_parse_str(msg, pub, s);
}
/**Add string to message.
*
* Parse a string containing headers (or a message body, if the string
* starts with linefeed) and add resulting header objects to the message
* object.
*
* @param msg message object
* @param pub message header structure where heades are added (may be NULL)
* @param s string to be parsed (and modified)
*
* @retval 0 when succesful
* @retval -1 upon an error
*
* @sa msg_header_add_str(), url_headers_as_string()
*
* @since New in @VERSION_1_12_4
*/
int msg_header_parse_str(msg_t *msg,
msg_pub_t *pub,
char *s)
{
if (!msg)
return -1;
if (pub == NULL)
pub = msg->m_object;
if (s) {
size_t ssiz = strlen(s), used = 0;
ssize_t n = 1;
......@@ -2619,11 +2658,9 @@ int msg_header_add_str(msg_t *msg,
if (n <= 0)
return -1;
return 0;
}
return -1;
return 0;
}
/** Insert a (list of) header(s) to the fragment chain.
......
......@@ -128,6 +128,10 @@ SOFIAPUBFUN int msg_header_add_str(msg_t *msg,
msg_pub_t *pub,
char const *str);
SOFIAPUBFUN int msg_header_parse_str(msg_t *msg,
msg_pub_t *pub,
char *s);
SOFIAPUBFUN int msg_header_add_dup_as(msg_t *msg,
msg_pub_t *pub,
msg_hclass_t *hc,
......
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