# HG changeset patch # User Mikael Berthe # Date 1177755405 -7200 # Node ID c96fef31ff9613f64bd3daf3581639d37d8c4ac6 # Parent ede6c7aa59b0592abf6e383af1eff62a24bc1661 Expand startswith() diff -r ede6c7aa59b0 -r c96fef31ff96 mcabber/src/settings.c --- a/mcabber/src/settings.c Fri Apr 27 23:46:15 2007 +0200 +++ b/mcabber/src/settings.c Sat Apr 28 12:16:45 2007 +0200 @@ -154,11 +154,13 @@ // We only allow assignments line, except for commands "pgp" and "source" if ((strchr(line, '=') != NULL) || - startswith(line, "pgp ") || startswith(line, "source ")) { + startswith(line, "pgp ", FALSE) || startswith(line, "source ", FALSE)) { // Only accept the set, alias, bind, pgp and source commands - if (!startswith(line, "set ") && !startswith(line, "bind ") && - !startswith(line, "alias ") && !startswith(line, "pgp ") && - !startswith(line, "source ")) { + if (!startswith(line, "set ", FALSE) && + !startswith(line, "bind ", FALSE) && + !startswith(line, "alias ", FALSE) && + !startswith(line, "pgp ", FALSE) && + !startswith(line, "source ", FALSE)) { scr_LogPrint(LPRINT_LOGNORM, "Error in configuration file (l. %d): bad command", ln); err++; diff -r ede6c7aa59b0 -r c96fef31ff96 mcabber/src/utils.c --- a/mcabber/src/utils.c Fri Apr 27 23:46:15 2007 +0200 +++ b/mcabber/src/utils.c Sat Apr 28 12:16:45 2007 +0200 @@ -648,11 +648,13 @@ } #endif /* !HAVE_STRCASESTR */ -// startswith(str, word) +// startswith(str, word, ignore_case) // Returns TRUE if string str starts with word. -int startswith(const char *str, const char *word) +int startswith(const char *str, const char *word, guint ignore_case) { - if (!strncmp(str, word, strlen(word))) + if (ignore_case && !strncasecmp(str, word, strlen(word))) + return TRUE; + else if (!ignore_case && !strncmp(str, word, strlen(word))) return TRUE; return FALSE; } diff -r ede6c7aa59b0 -r c96fef31ff96 mcabber/src/utils.h --- a/mcabber/src/utils.h Fri Apr 27 23:46:15 2007 +0200 +++ b/mcabber/src/utils.h Sat Apr 28 12:16:45 2007 +0200 @@ -43,7 +43,7 @@ char *strcasestr(const char *haystack, const char *needle); #endif -int startswith(const char *str, const char *word); +int startswith(const char *str, const char *word, guint ignore_case); #endif // __UTILS_H__