This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/17232 ) Change subject: Native_Functions: Add f_str_to{lower,upper}() ...................................................................... Native_Functions: Add f_str_to{lower,upper}() TTCN-3 interestingly doens't seem to have any case-insensitive string matching or functions to convert to uppwer/lowercase. Change-Id: I2e6e0fd2da001a3cc6d9c31c9e766ae54bf17b2f --- M library/Native_FunctionDefs.cc M library/Native_Functions.ttcn 2 files changed, 36 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/library/Native_FunctionDefs.cc b/library/Native_FunctionDefs.cc index f6d5d1d..78ca4d1 100644 --- a/library/Native_FunctionDefs.cc +++ b/library/Native_FunctionDefs.cc @@ -16,6 +16,7 @@ #include <stdio.h> #include <string.h> #include <errno.h> +#include <ctype.h> #include <Charstring.hh> #include <Octetstring.hh> @@ -75,5 +76,34 @@ return CHARSTRING(str); } +CHARSTRING f__str__tolower(const CHARSTRING& in) +{ + TTCN_Buffer ttcn_buffer(in); + TTCN_Buffer buf_out; + CHARSTRING out; + unsigned int i; + + const char *in_str = (const char *)ttcn_buffer.get_data(); + for (i = 0; i < strlen(in_str); i++) + buf_out.put_c((unsigned char) tolower(in_str[i])); + buf_out.get_string(out); + return out; +} + +CHARSTRING f__str__toupper(const CHARSTRING& in) +{ + TTCN_Buffer ttcn_buffer(in); + TTCN_Buffer buf_out; + CHARSTRING out; + unsigned int i; + + const char *in_str = (const char *)ttcn_buffer.get_data(); + for (i = 0; i < strlen(in_str); i++) + buf_out.put_c((unsigned char) toupper(in_str[i])); + buf_out.get_string(out); + return out; +} + + } // namespace diff --git a/library/Native_Functions.ttcn b/library/Native_Functions.ttcn index d59670a..c43004a 100644 --- a/library/Native_Functions.ttcn +++ b/library/Native_Functions.ttcn @@ -11,4 +11,10 @@ external function f_inet_ntoa(in octetstring oct) return charstring; /* like inet_ntoa() but input is host byte order */ external function f_inet_hntoa(in octetstring oct) return charstring; + + /* convert content of charstring to lower-case using tolower(3) */ + external function f_str_tolower(in charstring input) return charstring; + + /* convert content of charstring to upper-case using toupper(3) */ + external function f_str_toupper(in charstring input) return charstring; } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/17232 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I2e6e0fd2da001a3cc6d9c31c9e766ae54bf17b2f Gerrit-Change-Number: 17232 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200219/414d7b15/attachment.htm>