aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--uzbl.c22
-rw-r--r--uzbl.h3
2 files changed, 25 insertions, 0 deletions
diff --git a/uzbl.c b/uzbl.c
index edd0b38..af414ed 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -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
diff --git a/uzbl.h b/uzbl.h
index f81e3f6..529fae5 100644
--- a/uzbl.h
+++ b/uzbl.h
@@ -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: */