aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Barrucadu <mike@barrucadu.co.uk>2009-05-03 22:33:58 +0100
committerGravatar Barrucadu <mike@barrucadu.co.uk>2009-05-03 22:33:58 +0100
commitfbf3bbced3165bc67364f20d4ff6c1f994beac3b (patch)
tree3162d1200cd0300078e74afee49c7e99211dc4c8 /uzbl.c
parent01cfcffd7762edd4bed94e91b2013890680765a9 (diff)
Added str_replace function. To be used for adding variables to user agent.
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c22
1 files changed, 22 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