pespin has uploaded this change for review.
library/Misc_Helpers: Introduce API f_str_oct_split()
Similar to existing f_str_split() but operating on octetstrings.
It uses the external f_strstr_oct() function to look up in an efficient
way.
This function will be used by HTTP2 code to split multipart data based
on boundary specified in the HTTP2 Header.
Change-Id: Ie26062bf00133d25be4b41424186484d34b18dce
---
M library/Misc_Helpers.ttcn
1 file changed, 21 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/48/43648/1
diff --git a/library/Misc_Helpers.ttcn b/library/Misc_Helpers.ttcn
index 967c8d1..917b718 100644
--- a/library/Misc_Helpers.ttcn
+++ b/library/Misc_Helpers.ttcn
@@ -134,4 +134,25 @@
return parts;
}
+/* Samem as f_str_split() but using octetstring */
+type record of octetstring ro_octetstring;
+function f_str_oct_split(octetstring str, octetstring delim := ''O) return ro_octetstring
+{
+ var integer pos := 0;
+ var ro_octetstring parts := {};
+ var integer delim_pos;
+ var integer end := lengthof(str);
+ while (pos < end) {
+ delim_pos := f_strstr_oct(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 + lengthof(delim);
+ }
+ return parts;
+}
+
}
To view, visit change 43648. To unsubscribe, or for help writing mail filters, visit settings.