Module: kamailio
Branch: master
Commit: 2df3ca7d8fd995650fb937c464b99b457ee7199e
URL:
https://github.com/kamailio/kamailio/commit/2df3ca7d8fd995650fb937c464b99b4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-09-13T15:25:59+02:00
core: xavp - option to quote string values when serializing
---
Modified: src/core/xavp.c
Modified: src/core/xavp.h
Removed: src/modules/statsd/doc/statsd.txt
---
Diff:
https://github.com/kamailio/kamailio/commit/2df3ca7d8fd995650fb937c464b99b4…
Patch:
https://github.com/kamailio/kamailio/commit/2df3ca7d8fd995650fb937c464b99b4…
---
diff --git a/src/core/xavp.c b/src/core/xavp.c
index 551a039ab80..32d1cef8391 100644
--- a/src/core/xavp.c
+++ b/src/core/xavp.c
@@ -1121,6 +1121,7 @@ int xavp_serialize_fields_style(str *rname, int mode, char *obuf,
int olen)
int rlen;
char *pr = "";
char *sf = "";
+ char *qs = "";
ravp = xavp_get(rname, NULL);
if(ravp == NULL || ravp->val.type != SR_XTYPE_XAVP) {
@@ -1128,13 +1129,16 @@ int xavp_serialize_fields_style(str *rname, int mode, char *obuf,
int olen)
return 0;
}
- if(mode & 1) {
+ if(mode & XAVP_PRINT_SCPR) {
pr = ";";
sf = "";
} else {
pr = "";
sf = ";";
}
+ if(mode & XAVP_PRINT_QVAL) {
+ qs = "\"";
+ }
rlen = 0;
ostr.s = obuf;
@@ -1158,9 +1162,9 @@ int xavp_serialize_fields_style(str *rname, int mode, char *obuf,
int olen)
ostr.len = snprintf(ostr.s, olen - rlen, "%s%.*s%s",
pr, avp->name.len, avp->name.s, sf);
} else {
- ostr.len = snprintf(ostr.s, olen - rlen, "%s%.*s=%.*s%s",
- pr, avp->name.len, avp->name.s, avp->val.v.s.len,
- avp->val.v.s.s, sf);
+ ostr.len = snprintf(ostr.s, olen - rlen, "%s%.*s=%s%.*s%s%s",
+ pr, avp->name.len, avp->name.s, qs, avp->val.v.s.len,
+ avp->val.v.s.s, qs, sf);
}
if(ostr.len <= 0 || ostr.len >= olen - rlen) {
LM_ERR("failed to serialize int value (%d/%d\n", ostr.len,
diff --git a/src/core/xavp.h b/src/core/xavp.h
index 4d5c30d989b..b9131c2d2df 100644
--- a/src/core/xavp.h
+++ b/src/core/xavp.h
@@ -114,6 +114,9 @@ sr_xavp_t *xavp_get_child(str *rname, str *cname);
sr_xavp_t *xavp_get_child_with_ival(str *rname, str *cname);
sr_xavp_t *xavp_get_child_with_sval(str *rname, str *cname);
int xavp_serialize_fields(str *rname, char *obuf, int olen);
+
+#define XAVP_PRINT_SCPR 1 /* semicolon prefix */
+#define XAVP_PRINT_QVAL 2 /* quote string param values */
int xavp_serialize_fields_style(str *rname, int mode, char *obuf, int olen);
int xavp_set_child_ival(str *rname, str *cname, long ival);
diff --git a/src/modules/statsd/doc/statsd.txt b/src/modules/statsd/doc/statsd.txt
deleted file mode 100644
index e69de29bb2d..00000000000