Module: kamailio
Branch: 5.2
Commit: 110de27806d7703939b3123cff7a8fe423028d0a
URL:
https://github.com/kamailio/kamailio/commit/110de27806d7703939b3123cff7a8fe…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-05-21T13:18:16+02:00
core: pv - define the string printed for null value
- added function to return the str null value
(cherry picked from commit c84a89a3ab5b3f3174203753e51926143b0309f8)
---
Modified: src/core/pvapi.c
Modified: src/core/pvar.h
---
Diff:
https://github.com/kamailio/kamailio/commit/110de27806d7703939b3123cff7a8fe…
Patch:
https://github.com/kamailio/kamailio/commit/110de27806d7703939b3123cff7a8fe…
---
diff --git a/src/core/pvapi.c b/src/core/pvapi.c
index 878ae30f8e..9b5234f1be 100644
--- a/src/core/pvapi.c
+++ b/src/core/pvapi.c
@@ -674,7 +674,8 @@ static char pv_str_empty_buf[2];
static char pv_str_null_buf[8];
static str pv_str_empty = { "", 0 };
-static str pv_str_null = { "<null>", 6 };
+#define PV_STR_NULL_VAL "<null>"
+static str pv_str_null = { PV_STR_NULL_VAL, sizeof(PV_STR_NULL_VAL)-1 };
int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
{
if(res==NULL)
@@ -686,6 +687,14 @@ int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t
*res)
return 0;
}
+/**
+ *
+ */
+str *pv_get_null_str(void)
+{
+ return &pv_str_null;
+}
+
/**
*
*/
@@ -2003,7 +2012,7 @@ int pv_init_api(void)
pv_str_empty_buf[0] = '\0';
pv_str_empty_buf[1] = '\0';
pv_str_empty.s = pv_str_empty_buf;
- strcpy(pv_str_null_buf, "<null>");
+ strcpy(pv_str_null_buf, PV_STR_NULL_VAL);
pv_str_null.s = pv_str_null_buf;
if(register_pvars_mod("core", _core_pvs)<0)
diff --git a/src/core/pvar.h b/src/core/pvar.h
index 3e838e20f8..564bc03d90 100644
--- a/src/core/pvar.h
+++ b/src/core/pvar.h
@@ -209,6 +209,7 @@ int pv_free_extra_list(void);
int pv_locate_name(str *in);
pv_spec_t* pv_cache_get(str *name);
str* pv_cache_get_name(pv_spec_t *spec);
+str *pv_get_null_str(void);
/*! \brief PV helper functions */
int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);