From b80d683ce6fd7149c45beabb611185dca0a0f8ac Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 4 Sep 2018 20:39:15 +0200 Subject: [PATCH] Added new support str function --- client/util.c | 3 +++ client/util.h | 1 + 2 files changed, 4 insertions(+) diff --git a/client/util.c b/client/util.c index ffe55a781..4a256e0b2 100644 --- a/client/util.c +++ b/client/util.c @@ -817,6 +817,9 @@ extern void str_lower(char *s ){ for(int i=0; i < strlen(s); i++) s[i] = tolower( s[i] ); } +extern bool str_startswith(const char *s, const char *pre) { + return strncmp(pre, s, strlen(pre)) == 0; +} // Replace unprintable characters with a dot in char buffer extern void clean_ascii(unsigned char *buf, size_t len) { diff --git a/client/util.h b/client/util.h index fb559ea1d..637bfb3ca 100644 --- a/client/util.h +++ b/client/util.h @@ -247,6 +247,7 @@ extern uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor); extern int num_CPUs(void); // number of logical CPUs extern void str_lower(char* s); // converts string to lower case +extern bool str_startswith(const char *s, const char *pre); // check for prefix in string extern void strcleanrn(char *buf, size_t len); extern void strcreplace(char *buf, size_t len, char from, char to); extern char *strmcopy(char *buf);