summaryrefslogtreecommitdiff
path: root/src/core/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/misc.c')
-rw-r--r--src/core/misc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 6bf87177..01ae0f1d 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -770,3 +770,19 @@ int expand_escape(const char **data)
return strtol(digit, NULL, 8);
}
}
+
+/* Escape all '"', "'" and '\' chars with '\' */
+char *escape_string(const char *str)
+{
+ char *ret, *p;
+
+ p = ret = g_malloc(strlen(str)*2+1);
+ while (*str != '\0') {
+ if (*str == '"' || *str == '\'' || *str == '\\')
+ *p++ = '\\';
+ *p++ = *str++;
+ }
+ *p = '\0';
+
+ return ret;
+}