[sr-dev] git:master:ccbaf324: core: helper function to search a token before an end pointer

Daniel-Constantin Mierla miconda at gmail.com
Wed Oct 28 08:54:59 CET 2020


Module: kamailio
Branch: master
Commit: ccbaf324cf5481288f505dce5c694ca077911a04
URL: https://github.com/kamailio/kamailio/commit/ccbaf324cf5481288f505dce5c694ca077911a04

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-10-28T08:26:06+01:00

core: helper function to search a token before an end pointer

---

Modified: src/core/ut.c
Modified: src/core/ut.h

---

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

---

diff --git a/src/core/ut.c b/src/core/ut.c
index 0189b642ab..08edd2f24e 100644
--- a/src/core/ut.c
+++ b/src/core/ut.c
@@ -296,6 +296,29 @@ char *str_search(str *text, str *needle)
     return NULL;
 }
 
+/**
+ * @brief search for occurence of needlez starting from vstart and before vend
+ * @return pointer to start of needle in text or NULL if the needle
+ *	is not found
+ */
+char *stre_search_strz(char *vstart, char *vend, char *needlez)
+{
+    str text;
+    str needle;
+
+	if(vend <= vstart) {
+		return NULL;
+	}
+
+	text.s = vstart;
+	text.len = vend - vstart;
+
+	needle.s = needlez;
+	needle.len = strlen(needlez);
+
+    return str_search(&text, &needle);
+}
+
 /**
  * @brief case insensitive search for occurence of needle in text
  * @return pointer to start of needle in text or NULL if the needle
diff --git a/src/core/ut.h b/src/core/ut.h
index 5fcb245cd8..0251fb7ca2 100644
--- a/src/core/ut.h
+++ b/src/core/ut.h
@@ -1057,6 +1057,8 @@ char* get_abs_pathname(str* base, str* file);
  */
 char *str_search(str *text, str *needle);
 
+char *stre_search_strz(char *vstart, char *vend, char *needlez);
+
 char *str_casesearch(str *text, str *needle);
 
 char *strz_casesearch_strz(char *textz, char *needlez);




More information about the sr-dev mailing list