diff options
-rw-r--r-- | uzbl.c | 22 | ||||
-rw-r--r-- | uzbl.h | 3 |
2 files changed, 25 insertions, 0 deletions
@@ -132,6 +132,28 @@ itos(int val) { return g_strdup(tmp); } +static char * +str_replace (const char* search, const char* replace, const char* string) { + char newstring[512]; + char tempstring[512]; + unsigned int i = 0; + + memset (newstring, 0, sizeof (newstring)); + + for (i = 0; i < strlen (string) - strlen (search); i ++) { + memset (tempstring, 0, sizeof (tempstring)); + strncpy (tempstring, string + i, sizeof (search) + 1); + + if (strcmp (tempstring, search) == 0) { + strncpy (newstring, string, i); + strcat (newstring, replace); + strcat (newstring, string + i + sizeof (search) + 1); + } + } + + return (char *)newstring; +} + /* --- CALLBACKS --- */ static gboolean @@ -122,4 +122,7 @@ search_text (WebKitWebView *page, const char *param); static void run_js (WebKitWebView * web_view, const gchar *param); +static char * +str_replace (const char* search, const char* replace, const char* string); + /* vi: set et ts=4: */ |