diff options
author | Barrucadu <mike@barrucadu.co.uk> | 2009-05-03 23:13:34 +0100 |
---|---|---|
committer | Barrucadu <mike@barrucadu.co.uk> | 2009-05-03 23:13:34 +0100 |
commit | b6a39ed3eba72d2c3fea3ae9ed28ff7510a05e1f (patch) | |
tree | b2b0f297ccc23cbda395f8edf92e533f97d9cb3b | |
parent | fbf3bbced3165bc67364f20d4ff6c1f994beac3b (diff) |
Added hacky variable suppot (currently "%webkit-major%", "%webkit-minor%" and "%webkit-micro%", alas no "%kernver%" or "%commit%" yet) to user agent.
I'm tired and it's late. I've probably done this in a very poor way which would be infinitely better.
Now I am going to go and sleep. When I wake up and come on IRC, tell me how bad the code is :P
-rw-r--r-- | examples/configs/sampleconfig | 2 | ||||
-rw-r--r-- | examples/configs/sampleconfig-dev | 2 | ||||
-rw-r--r-- | uzbl.c | 16 |
3 files changed, 14 insertions, 6 deletions
diff --git a/examples/configs/sampleconfig b/examples/configs/sampleconfig index e4fd3a6..4fcdead 100644 --- a/examples/configs/sampleconfig +++ b/examples/configs/sampleconfig @@ -56,6 +56,6 @@ S = script alert("hi"); proxy_server = #values 0-3 http_debug = 0 -user-agent = uzbl +user-agent = uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) max_conns = max_conns_per_host = diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index 7ce220f..9c4664e 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -57,7 +57,7 @@ S = script alert("hi"); #proxy_server = http://127.0.0.1:8118 #values 0-3 http_debug = 0 -user-agent = uzbl +user-agent = uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) max_conns = max_conns_per_host = @@ -134,20 +134,20 @@ itos(int val) { static char * str_replace (const char* search, const char* replace, const char* string) { - char newstring[512]; - char tempstring[512]; + char newstring[1024]; + char tempstring[1024]; 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); + strncpy (tempstring, string + i, strlen (search)); if (strcmp (tempstring, search) == 0) { strncpy (newstring, string, i); strcat (newstring, replace); - strcat (newstring, string + i + sizeof (search) + 1); + strcat (newstring, string + i + strlen (search)); } } @@ -981,6 +981,14 @@ settings_init () { } if(useragent){ + char* newagent = malloc(1024); + + strcpy(newagent, str_replace("%webkit-major%", itos(WEBKIT_MAJOR_VERSION), useragent)); + strcpy(newagent, str_replace("%webkit-minor%", itos(WEBKIT_MINOR_VERSION), newagent)); + strcpy(newagent, str_replace("%webkit-micro%", itos(WEBKIT_MICRO_VERSION), newagent)); + + useragent = malloc(1024); + strcpy(useragent, newagent); g_object_set(G_OBJECT(soup_session), SOUP_SESSION_USER_AGENT, useragent, NULL); } |