summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-09-14 11:17:48 +0000
committerBenny Prijono <bennylp@teluu.com>2006-09-14 11:17:48 +0000
commitde41ab8738b3c8782e214d48f562d1671dc76691 (patch)
tree3d5b9ef0d54f9e87808dfe52872da3cc01f3df02 /pjsip
parentd028655fbf8461a741b19c54bc672319256d3125 (diff)
Added --duration option in PJSUA to limit the maximum duration of calls. Also added pjsip_generic_string_hdr_init2() to initialize temporary SIP header that is allocated in the stack.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@715 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsip/sip_msg.h18
-rw-r--r--pjsip/src/pjsip/sip_msg.c33
2 files changed, 45 insertions, 6 deletions
diff --git a/pjsip/include/pjsip/sip_msg.h b/pjsip/include/pjsip/sip_msg.h
index af7ad922..08f8e88e 100644
--- a/pjsip/include/pjsip/sip_msg.h
+++ b/pjsip/include/pjsip/sip_msg.h
@@ -879,6 +879,7 @@ pjsip_generic_string_hdr_create( pj_pool_t *pool,
const pj_str_t *hname,
const pj_str_t *hvalue);
+
/**
* Initialize a preallocated memory with the header structure. This function
* should only be called when application uses its own memory allocation to
@@ -903,6 +904,23 @@ pjsip_generic_string_hdr_init( pj_pool_t *pool,
const pj_str_t *hvalue);
+/**
+ * Construct a generic string header without allocating memory from the pool.
+ * This function is useful to create a temporary header which life-time is
+ * very short (for example, creating the header in the stack to be passed
+ * as argument to a function which will copy the header).
+ *
+ * @param pool The pool.
+ * @param hname The header name to be assigned to the header, or NULL to
+ * assign the header name with some string.
+ * @param hvalue Optional string to be assigned as the value.
+ *
+ * @return The header, or THROW exception.
+ */
+PJ_DECL(void) pjsip_generic_string_hdr_init2(pjsip_generic_string_hdr *h,
+ pj_str_t *hname,
+ pj_str_t *hvalue);
+
/* **************************************************************************/
diff --git a/pjsip/src/pjsip/sip_msg.c b/pjsip/src/pjsip/sip_msg.c
index d5eb1009..1e4c5729 100644
--- a/pjsip/src/pjsip/sip_msg.c
+++ b/pjsip/src/pjsip/sip_msg.c
@@ -505,6 +505,25 @@ static pjsip_hdr_vptr generic_hdr_vptr =
(pjsip_hdr_print_fptr) &pjsip_generic_string_hdr_print,
};
+
+PJ_DEF(void) pjsip_generic_string_hdr_init2(pjsip_generic_string_hdr *hdr,
+ pj_str_t *hname,
+ pj_str_t *hvalue)
+{
+ init_hdr(hdr, PJSIP_H_OTHER, &generic_hdr_vptr);
+ if (hname) {
+ hdr->name = *hname;
+ hdr->sname = *hname;
+ }
+ if (hvalue) {
+ hdr->hvalue = *hvalue;
+ } else {
+ hdr->hvalue.ptr = NULL;
+ hdr->hvalue.slen = 0;
+ }
+}
+
+
PJ_DEF(pjsip_generic_string_hdr*)
pjsip_generic_string_hdr_init( pj_pool_t *pool,
void *mem,
@@ -512,19 +531,21 @@ pjsip_generic_string_hdr_init( pj_pool_t *pool,
const pj_str_t *hvalue)
{
pjsip_generic_string_hdr *hdr = mem;
+ pj_str_t dup_hname, dup_hval;
- init_hdr(hdr, PJSIP_H_OTHER, &generic_hdr_vptr);
if (hnames) {
- pj_strdup(pool, &hdr->name, hnames);
- hdr->sname = hdr->name;
+ pj_strdup(pool, &dup_hname, hnames);
+ } else {
+ dup_hname.slen = 0;
}
+
if (hvalue) {
- pj_strdup(pool, &hdr->hvalue, hvalue);
+ pj_strdup(pool, &dup_hval, hvalue);
} else {
- hdr->hvalue.ptr = NULL;
- hdr->hvalue.slen = 0;
+ dup_hval.slen = 0;
}
+ pjsip_generic_string_hdr_init2(hdr, &dup_hname, &dup_hval);
return hdr;
}