diff options
author | Barrucadu <mike@barrucadu.co.uk> | 2009-05-03 22:33:58 +0100 |
---|---|---|
committer | Barrucadu <mike@barrucadu.co.uk> | 2009-05-03 22:33:58 +0100 |
commit | fbf3bbced3165bc67364f20d4ff6c1f994beac3b (patch) | |
tree | 3162d1200cd0300078e74afee49c7e99211dc4c8 /uzbl.c | |
parent | 01cfcffd7762edd4bed94e91b2013890680765a9 (diff) |
Added str_replace function. To be used for adding variables to user agent.
Diffstat (limited to 'uzbl.c')
-rw-r--r-- | uzbl.c | 22 |
1 files changed, 22 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 |