diff options
author | portix <none@none> | 2012-05-15 14:35:39 +0200 |
---|---|---|
committer | portix <none@none> | 2012-05-15 14:35:39 +0200 |
commit | d4f4a7faea6799346a6ccc1448f4750e4304be97 (patch) | |
tree | 36fd322fcc7acca4daff250b9e2b7647c3b779e6 /src/util.c | |
parent | 0cccf1c72c9685f8fed922fe4ea4da72cb301130 (diff) | |
download | dwb-d4f4a7faea6799346a6ccc1448f4750e4304be97.zip |
New command sanitize
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -705,5 +705,31 @@ util_str_chug(const char *str) { while (g_ascii_isspace(*str)) str++; return str; - +} +Sanitize +util_string_to_sanitize(const char *string) { + Sanitize s = 0; + if (string == NULL || *string == 0) + return SANITIZE_ALL; + char **token = g_strsplit(string, " ", -1); + for (int i=0; token[i]; i++) { + if (!strcmp(token[i], "history")) + s |= SANITIZE_HISTORY; + else if (!strcmp(token[i], "cookies")) + s |= SANITIZE_COOKIES; + else if (!strcmp(token[i], "cache")) + s |= SANITIZE_CACHE; + else if (!strcmp(token[i], "all")) + s |= SANITIZE_ALL; + else if (!strcmp(token[i], "session")) + s |= SANITIZE_SESSION; + else if (!strcmp(token[i], "allsessions")) + s |= SANITIZE_ALLSESSIONS; + else { + s = -1; + break; + } + } + g_strfreev(token); + return s; } |