Commit 9882e1ca authored by Pekka Pessi's avatar Pekka Pessi

msg: add msg_q_value() (sofia-sip/msg_mime.h)

Declaring as a part of public API.

Note that value for empty q= string is now 1000.
parent ace102dd
......@@ -928,21 +928,23 @@ MSG_HEADER_CLASS(msg_, multipart, NULL, "", mp_common, append, msg_multipart);
*
* The function msg_q_value() converts q-value string @a q to numeric value
* in range (0..1000). Q values are used, for instance, to describe
* relative priorities of registered contacts.
* relative priorities of acceptable Content-Types.
*
* @param q q-value string ("1" | "." 1,3DIGIT)
*
* @return
* The function msg_q_value() returns an integer in range 0 .. 1000.
*
* @NEW_UNRELEASED
*/
unsigned msg_q_value(char const *q)
{
unsigned value = 0;
if (!q)
return 500;
return 1000;
if (q[0] != '0' && q[0] != '.' && q[0] != '1')
return 500;
return 500; /* Garbage... */
while (q[0] == '0')
q++;
if (q[0] >= '1' && q[0] <= '9')
......@@ -950,8 +952,7 @@ unsigned msg_q_value(char const *q)
if (q[0] == '\0')
return 0;
if (q[0] != '.')
/* Garbage... */
return 500;
return 500; /* Garbage... */
if (q[1] >= '0' && q[1] <= '9') {
value = (q[1] - '0') * 100;
......
......@@ -230,6 +230,8 @@ SOFIAPUBFUN char *msg_accept_any_dup_one(msg_header_t *dst,
SOFIAPUBFUN
msg_content_length_t *msg_content_length_create(su_home_t *home, uint32_t n);
SOFIAPUBFUN unsigned msg_q_value(char const *q);
/** MIME multipart protocol name. @HIDE */
#define MSG_MULTIPART_VERSION_CURRENT msg_mime_version_1_0
SOFIAPUBVAR char const msg_mime_version_1_0[];
......
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