/* This function takes a string and copies it, inserting a 'chr' before every 'chr' in it.  */
gchar* ws_strdup_escape_char(const gchar *str, const gchar chr)
/* This function takes a string and copies it, inserting a 'chr' before every 'chr' in it.  */
gchar* ws_strdup_escape_char(const gchar *str, const gchar chr)
{
    const gchar *p;
    gchar *q, *new_str;
    if(!str)
        return NULL;
    p = str;
    q = new_str = (gchar *)g_malloc (strlen(str) * 2 + 1);
    while(*p != 0) {
        if(*p == chr)
            *q++ = chr;
        *q++ = *p++;
    }
    *q = '\0';
    return new_str;
}