Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/majn/telegram-purple.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormjentsch <mtthsjntsch@gmail.com>2015-07-11 20:32:59 +0300
committermjentsch <mtthsjntsch@gmail.com>2015-07-11 20:34:19 +0300
commit47812f2f726b5775e3c7a145bbe188a78395c6eb (patch)
tree6e729531f0b05e32bcdd6aaba76719497306fc30 /tgp-utils.c
parent8f790253a7e474b3c92501488fbe6373defea7e0 (diff)
Improve string sanitation in fallback chat
Diffstat (limited to 'tgp-utils.c')
-rw-r--r--tgp-utils.c15
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;
+}
+