summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorportix <none@none>2012-05-15 14:35:39 +0200
committerportix <none@none>2012-05-15 14:35:39 +0200
commitd4f4a7faea6799346a6ccc1448f4750e4304be97 (patch)
tree36fd322fcc7acca4daff250b9e2b7647c3b779e6 /src/util.c
parent0cccf1c72c9685f8fed922fe4ea4da72cb301130 (diff)
downloaddwb-d4f4a7faea6799346a6ccc1448f4750e4304be97.zip
New command sanitize
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index 6259aef1..7a0d0ea9 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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;
}