path: root/include/osmocom/core
diff options
authorNeels Hofmeyr <neels@hofmeyr.de>2019-03-07 23:08:40 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2019-04-11 05:36:36 +0000
commitd79ccc65f7134839a6d00f0eb70f43c2b614e9c8 (patch)
tree0f384b06dc30611611bd18cf1270ecc92429a764 /include/osmocom/core
parent04cb09cbf1b2f6f496e3474a87f15f905964f090 (diff)
add osmo_str_startswith()
Move from a static implementation in tdef_vty.c to utils.c, I also want to use this in osmo-msc. The point is that the telnet VTY allows unambiguous partly matches of keyword args. For example, if I have a command definition of: compare (apples|oranges) then it is perfectly legal as for the vty parser to write only compare app One could expect the VTY to then pass the unambiguous match of "apples" to the parsing function, but that is not the case. Hence a VTY function implementation is faced with parsing a keyword of "app" instead of the expected "apples". This is actually a very widespread bug in our VTY implementations, which assume that exactly one full keyword will always be found. I am now writing new commands in a way that are able to manage only the starts of keywords. Arguably, strstr(a, b) == a does the same thing, but it searches the entire string unnecessarily. Change-Id: Ib2ffb0e9a870dd52e081c7e66d8818057d159513
Diffstat (limited to 'include/osmocom/core')
1 files changed, 2 insertions, 0 deletions
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 51e43ee..474e36c 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -237,4 +237,6 @@ struct osmo_strbuf {
#define OSMO_STRBUF_PRINTF(STRBUF, fmt, args...) \
OSMO_STRBUF_APPEND(STRBUF, snprintf, fmt, ##args)
+bool osmo_str_startswith(const char *str, const char *startswith_str);
/*! @} */