diff options
author | mjentsch <mtthsjntsch@gmail.com> | 2015-07-11 20:32:59 +0300 |
---|---|---|
committer | mjentsch <mtthsjntsch@gmail.com> | 2015-07-11 20:34:19 +0300 |
commit | 47812f2f726b5775e3c7a145bbe188a78395c6eb (patch) | |
tree | 6e729531f0b05e32bcdd6aaba76719497306fc30 /tgp-utils.c | |
parent | 8f790253a7e474b3c92501488fbe6373defea7e0 (diff) |
Improve string sanitation in fallback chat
Diffstat (limited to 'tgp-utils.c')
-rw-r--r-- | tgp-utils.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tgp-utils.c b/tgp-utils.c index 4daa89f..2a7fe10 100644 --- a/tgp-utils.c +++ b/tgp-utils.c @@ -142,3 +142,18 @@ const char *tgp_mime_to_filetype (const char *mime) { } return NULL; } + +int tgp_startswith (const char *str, const char *with) { + if (! str || !with) { + return FALSE; + } + int slen = strlen (str), wlen = strlen (with); + if (wlen > slen) { + return FALSE; + } + while (*with) if (*str++ != *with++) { + return FALSE; + } + return TRUE; +} + |