diff options
Diffstat (limited to 'common.c')
-rw-r--r-- | common.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -3,6 +3,7 @@ #include <glcdskin/type.h> #include <vdr/plugin.h> +#include <string.h> #if APIVERSNUM < 10503 #include <locale.h> @@ -141,3 +142,18 @@ GLCD::cType DurationType(int Index, const std::string &Format) } return false; } + +int ParanoiaStrcmp(const char *s1, const char *s2) +{ + if (! s1 || ! s2) + return -1; + + // s1 must be under 'our' control (and thus valid), s2 may be a string w/ unexpected content + size_t n = strlen(s1); + + int rv = strncmp(s1, s2, n); + if (rv == 0) + return (s2[n] == '\0') ? 0 : -1; + else + return rv; +} |