[Freeswitch-svn] [commit] r9541 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/msg libsofia-sip-ua/msg/sofia-sip

Freeswitch SVN mikej at freeswitch.org
Fri Sep 12 12:27:44 EDT 2008


Author: mikej
Date: Fri Sep 12 12:27:43 2008
New Revision: 9541

Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_header.h

Log:
Wed Sep  3 13:35:21 EDT 2008  Pekka Pessi <first.last at nokia.com>
  * sofia-sip/msg_header.h: added msg_header_add_format(()



Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Fri Sep 12 12:27:43 2008
@@ -1 +1 @@
-Fri Sep 12 12:06:16 EDT 2008
+Fri Sep 12 12:27:38 EDT 2008

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.c	Fri Sep 12 12:27:43 2008
@@ -2732,6 +2732,44 @@
   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

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_header.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_header.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_header.h	Fri Sep 12 12:27:43 2008
@@ -142,6 +142,12 @@
 				    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,



More information about the Freeswitch-svn mailing list