aboutsummaryrefslogtreecommitdiff
path: root/common/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/util.cpp')
-rw-r--r--common/util.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/common/util.cpp b/common/util.cpp
index 8bf704456a..eaef9ce0b5 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -61,6 +61,39 @@ extern bool isSmartphone(void);
namespace Common {
+bool matchString(const char *str, const char *pat) {
+ const char *p = 0;
+ const char *q = 0;
+
+ for (;;) {
+ switch (*pat) {
+ case '*':
+ p = ++pat;
+ q = str;
+ break;
+
+ default:
+ if (*pat != *str) {
+ if (p) {
+ pat = p;
+ str = ++q;
+ if (!*str)
+ return !*pat;
+ break;
+ }
+ else
+ return false;
+ }
+ // fallthrough
+ case '?':
+ if (!*str)
+ return !*pat;
+ pat++;
+ str++;
+ }
+ }
+}
+
//
// Print hexdump of the data passed in
//