move f_str_split() from UPF_Tests to Osmocom_VTY_Functions
I want to use it in a new function f_verify_talloc_bytes() added to
Osmocom_VTY_Functions.ttcn in I2948ee6f167369a2252f85b493e9653b93c7e4e9.
Change-Id: I9ddd9977734efd7599481261f04df82620845cef
diff --git a/library/Osmocom_VTY_Functions.ttcn b/library/Osmocom_VTY_Functions.ttcn
index 6e3ee37..ed506a7 100644
--- a/library/Osmocom_VTY_Functions.ttcn
+++ b/library/Osmocom_VTY_Functions.ttcn
@@ -15,6 +15,7 @@
import from TELNETasp_PortType all;
import from Osmocom_Types all;
import from TCCConversion_Functions all;
+ import from Socket_API_Definitions all;
modulepar {
charstring mp_prompt_prefix := "OpenBSC";
@@ -290,4 +291,23 @@
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "talloc count mismatch");
}
+public function f_str_split(charstring str, charstring delim := "\n") return ro_charstring
+{
+ var integer pos := 0;
+ var ro_charstring parts := {};
+ var integer delim_pos;
+ var integer end := lengthof(str);
+ while (pos < end) {
+ delim_pos := f_strstr(str, delim, pos);
+ if (delim_pos < 0) {
+ delim_pos := end;
+ }
+ if (delim_pos > pos) {
+ parts := parts & { substr(str, pos, delim_pos - pos) };
+ }
+ pos := delim_pos + 1;
+ }
+ return parts;
+}
+
}