[sr-dev] git:master:ab59aace: textops: docs for subst_v(...) function

2024-08-02 Thread Daniel-Constantin Mierla via sr-dev
Module: kamailio
Branch: master
Commit: ab59aace74cca90be6d341a3f96e72693e939992
URL: 
https://github.com/kamailio/kamailio/commit/ab59aace74cca90be6d341a3f96e72693e939992

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2024-08-02T11:42:07+02:00

textops: docs for subst_v(...) function

---

Modified: src/modules/textops/doc/textops_admin.xml

---

Diff:  
https://github.com/kamailio/kamailio/commit/ab59aace74cca90be6d341a3f96e72693e939992.diff
Patch: 
https://github.com/kamailio/kamailio/commit/ab59aace74cca90be6d341a3f96e72693e939992.patch

---

diff --git a/src/modules/textops/doc/textops_admin.xml 
b/src/modules/textops/doc/textops_admin.xml
index 9c121e51c70..57414c05e81 100644
--- a/src/modules/textops/doc/textops_admin.xml
+++ b/src/modules/textops/doc/textops_admin.xml
@@ -809,6 +809,44 @@ if ( subst_hf("From", "/:test@/:best@/", "a") ) { /**/ 
};


 
+   
+   
+   subst_hf(itext, subexp, 
ovp)
+   
+   
+   Sed-like substitution subexp applied to itext, with result 
stored in opv.
+   
+   Meaning of the parameters is as follows:
+   
+   
+   itext - input text, it can 
contain variables.
+   
+   
+   
+   subexp - substitution 
expression
+   in the same format as of the 'subst' function 
parameter, it can
+   contain variables.
+   
+   
+   
+   opv - variable name where to 
store the
+   result.
+   
+   
+   
+   
+   This function can be used from ANY_ROUTE.
+   
+   
+   subst_v usage
+   
+...
+subst_v("$var(x)", "/:test@/:best@/", "$var(r)");
+...
+
+   
+   
+


set_body(txt, content_type)

___
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org


[sr-dev] git:master:e1954d76: textops: new function subst_v(...)

2024-08-02 Thread Daniel-Constantin Mierla via sr-dev
Module: kamailio
Branch: master
Commit: e1954d7624eecdc33137d224c248240e2df90703
URL: 
https://github.com/kamailio/kamailio/commit/e1954d7624eecdc33137d224c248240e2df90703

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2024-08-02T11:36:25+02:00

textops: new function subst_v(...)

- perform sed-like substituion over input text and store in a variable

---

Modified: src/modules/textops/textops.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/e1954d7624eecdc33137d224c248240e2df90703.diff
Patch: 
https://github.com/kamailio/kamailio/commit/e1954d7624eecdc33137d224c248240e2df90703.patch

---

diff --git a/src/modules/textops/textops.c b/src/modules/textops/textops.c
index 6baf40de6ad..d28d7f508cf 100644
--- a/src/modules/textops/textops.c
+++ b/src/modules/textops/textops.c
@@ -100,6 +100,7 @@ static int subst_uri_f(struct sip_msg *, char *, char *);
 static int subst_user_f(struct sip_msg *, char *, char *);
 static int subst_body_f(struct sip_msg *, char *, char *);
 static int subst_hf_f(struct sip_msg *, char *, char *, char *);
+static int subst_v_f(struct sip_msg *, char *, char *, char *);
 static int filter_body_f(struct sip_msg *, char *, char *);
 static int is_present_hf_f(struct sip_msg *msg, char *str_hf, char *foo);
 static int search_append_body_f(struct sip_msg *, char *, char *);
@@ -252,6 +253,8 @@ static cmd_export_t cmds[] = {
{"subst_body", (cmd_function)subst_body_f, 1, fixup_substre, 0,
ANY_ROUTE},
{"subst_hf", (cmd_function)subst_hf_f, 3, fixup_subst_hf, 0, 
ANY_ROUTE},
+   {"subst_v", (cmd_function)subst_v_f, 3, fixup_spve2_pvar,
+   fixup_free_spve2_pvar, ANY_ROUTE},
{"filter_body", (cmd_function)filter_body_f, 1, fixup_str_null, 
0,
ANY_ROUTE},
{"append_time", (cmd_function)append_time_f, 0, 0, 0,
@@ -1527,6 +1530,76 @@ static int subst_body_f(struct sip_msg *msg, char 
*subst, char *ignored)
return subst_body_helper_f(msg, (struct subst_expr *)subst);
 }
 
+/* sed-perl style re: s/regular expression/replacement/flags, like
+ *  subst but with variables */
+static int subst_v_helper_f(
+   sip_msg_t *msg, str *itext, str *subex, pv_spec_t *pvd)
+{
+   str *result;
+   int nmatches;
+   struct subst_expr *se;
+   pv_value_t val;
+
+   if(pvd->setf == NULL) {
+   LM_ERR("the variable is read only\n");
+   return -1;
+   }
+   se = subst_parser(subex);
+   if(se == 0) {
+   LM_ERR("bad subst re: %.*s\n", subex->len, subex->s);
+   return -1;
+   }
+   /* pkg malloc'ed result */
+   result = subst_str(itext->s, msg, se, &nmatches);
+   if(result == NULL) {
+   if(nmatches < 0) {
+   LM_ERR("substitution failed\n");
+   }
+   return -1;
+   }
+   memset(&val, 0, sizeof(pv_value_t));
+   val.rs.s = result->s;
+   val.rs.len = result->len;
+   val.flags = PV_VAL_STR;
+   pvd->setf(msg, &pvd->pvp, (int)EQ_T, &val);
+
+   pkg_free(result->s);
+   pkg_free(result);
+   return 1;
+}
+
+/* sed-perl style re: s/regular expression/replacement/flags, like
+ *  subst but with variables */
+static int ki_subst_v(sip_msg_t *msg, str *itext, str *subex, str *opv)
+{
+   pv_spec_t *pvd = NULL;
+
+   pvd = pv_cache_get(opv);
+   if(pvd == NULL) {
+   LM_ERR("failed to get pv spec\n");
+   return -1;
+   }
+   return subst_v_helper_f(msg, itext, subex, pvd);
+}
+
+static int subst_v_f(sip_msg_t *msg, char *pitext, char *psubex, char *popv)
+{
+   str itext = STR_NULL;
+   str subex = STR_NULL;
+
+   if(fixup_get_svalue(msg, (gparam_t *)pitext, &itext) < 0) {
+   LM_ERR("failed to get header name\n");
+   return -1;
+   }
+   if(fixup_get_svalue(msg, (gparam_t *)psubex, &subex) < 0) {
+   LM_ERR("failed to get header name\n");
+   return -1;
+   }
+
+   return subst_v_helper_f(msg, &itext, &subex, (pv_spec_t *)popv);
+}
+
+
 static inline int find_line_start(
char *text, unsigned int text_len, char **buf, unsigned int 
*buf_len)
 {
@@ -5282,6 +5355,11 @@ static sr_kemi_t sr_kemi_textops_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+   { str_init("textops"), str_init("subst_v"),
+   SR_KEMIP_INT, ki_subst_v,
+   { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
+   SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+   },
{ str_init("textops"), str_init("remove_hf"),
SR_KEMIP_INT, ki_remove_hf,
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,

___

[sr-dev] git:master:e92375c9: modules: readme files regenerated - textops ... [skip ci]

2024-08-02 Thread Kamailio Dev via sr-dev
Module: kamailio
Branch: master
Commit: e92375c96eace6340e42bca622e9835df6b5d17f
URL: 
https://github.com/kamailio/kamailio/commit/e92375c96eace6340e42bca622e9835df6b5d17f

Author: Kamailio Dev 
Committer: Kamailio Dev 
Date: 2024-08-02T11:46:11+02:00

modules: readme files regenerated - textops ... [skip ci]

---

Modified: src/modules/textops/README

---

Diff:  
https://github.com/kamailio/kamailio/commit/e92375c96eace6340e42bca622e9835df6b5d17f.diff
Patch: 
https://github.com/kamailio/kamailio/commit/e92375c96eace6340e42bca622e9835df6b5d17f.patch

___
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org


[sr-dev] git:master:40238581: textops: docs - fixed typo in subst_v() function name

2024-08-02 Thread Daniel-Constantin Mierla via sr-dev
Module: kamailio
Branch: master
Commit: 40238581af0eea0787547bdacc2ff0fccf19cbba
URL: 
https://github.com/kamailio/kamailio/commit/40238581af0eea0787547bdacc2ff0fccf19cbba

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2024-08-02T12:28:19+02:00

textops: docs - fixed typo in subst_v() function name

- unnoticed after copy and paste

---

Modified: src/modules/textops/doc/textops_admin.xml

---

Diff:  
https://github.com/kamailio/kamailio/commit/40238581af0eea0787547bdacc2ff0fccf19cbba.diff
Patch: 
https://github.com/kamailio/kamailio/commit/40238581af0eea0787547bdacc2ff0fccf19cbba.patch

---

diff --git a/src/modules/textops/doc/textops_admin.xml 
b/src/modules/textops/doc/textops_admin.xml
index 57414c05e81..86f02b97336 100644
--- a/src/modules/textops/doc/textops_admin.xml
+++ b/src/modules/textops/doc/textops_admin.xml
@@ -811,7 +811,7 @@ if ( subst_hf("From", "/:test@/:best@/", "a") ) { /**/ 
};
 


-   subst_hf(itext, subexp, 
ovp)
+   subst_v(itext, subexp, ovp)


Sed-like substitution subexp applied to itext, with result 
stored in opv.

___
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org


[sr-dev] git:master:1243755d: modules: readme files regenerated - textops ... [skip ci]

2024-08-02 Thread Kamailio Dev via sr-dev
Module: kamailio
Branch: master
Commit: 1243755d20192e7d5d1c492462a0f9f66521abac
URL: 
https://github.com/kamailio/kamailio/commit/1243755d20192e7d5d1c492462a0f9f66521abac

Author: Kamailio Dev 
Committer: Kamailio Dev 
Date: 2024-08-02T12:31:10+02:00

modules: readme files regenerated - textops ... [skip ci]

---

Modified: src/modules/textops/README

---

Diff:  
https://github.com/kamailio/kamailio/commit/1243755d20192e7d5d1c492462a0f9f66521abac.diff
Patch: 
https://github.com/kamailio/kamailio/commit/1243755d20192e7d5d1c492462a0f9f66521abac.patch

---

diff --git a/src/modules/textops/README b/src/modules/textops/README
index c19d629085f..60d805706fb 100644
--- a/src/modules/textops/README
+++ b/src/modules/textops/README
@@ -59,7 +59,7 @@ Ovidiu Sas
   4.18. subst_user('/re/repl/flags')
   4.19. subst_body('/re/repl/flags')
   4.20. subst_hf(hf, subexp, flags)
-  4.21. subst_hf(itext, subexp, ovp)
+  4.21. subst_v(itext, subexp, ovp)
   4.22. set_body(txt, content_type)
   4.23. set_reply_body(txt, content_type)
   4.24. filter_body(content_type)
@@ -213,7 +213,7 @@ Chapter 1. Admin Guide
 4.18. subst_user('/re/repl/flags')
 4.19. subst_body('/re/repl/flags')
 4.20. subst_hf(hf, subexp, flags)
-4.21. subst_hf(itext, subexp, ovp)
+4.21. subst_v(itext, subexp, ovp)
 4.22. set_body(txt, content_type)
 4.23. set_reply_body(txt, content_type)
 4.24. filter_body(content_type)
@@ -320,7 +320,7 @@ From: medabeda
4.18. subst_user('/re/repl/flags')
4.19. subst_body('/re/repl/flags')
4.20. subst_hf(hf, subexp, flags)
-   4.21. subst_hf(itext, subexp, ovp)
+   4.21. subst_v(itext, subexp, ovp)
4.22. set_body(txt, content_type)
4.23. set_reply_body(txt, content_type)
4.24. filter_body(content_type)
@@ -742,7 +742,7 @@ if ( subst_body('/^o=(.*) /o=$fU /') ) {};
 if ( subst_hf("From", "/:test@/:best@/", "a") ) { /**/ };
 ...
 
-4.21.  subst_hf(itext, subexp, ovp)
+4.21.  subst_v(itext, subexp, ovp)
 
Sed-like substitution subexp applied to itext, with result stored in
opv.

___
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org


[sr-dev] Re: [kamailio/kamailio] Memory usage increases everytime tls.reload is executed (Issue #3823)

2024-08-02 Thread github-actions[bot] via sr-dev
This issue is stale because it has been open 6 weeks with no activity. Remove 
stale label or comment or this will be closed in 2 weeks.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3823#issuecomment-2266341494
You are receiving this because you are subscribed to this thread.

Message ID: ___
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org