[hackers] [surf] adding environment variables for proxy and useragent || Enno Boland (tox)

From: <hg_AT_suckless.org>
Date: Mon, 2 Nov 2009 08:27:38 +0000 (UTC)

changeset: 166:79546c08cfa7
tag: tip
user: Enno Boland (tox) <tox_AT_s01.de>
date: Mon Nov 02 09:27:32 2009 +0100
files: surf.c
description:
adding environment variables for proxy and useragent

diff -r 632954400827 -r 79546c08cfa7 surf.c
--- a/surf.c Fri Oct 30 13:40:49 2009 +0100
+++ b/surf.c Mon Nov 02 09:27:32 2009 +0100
@@ -457,7 +457,7 @@
         Client *c;
         WebKitWebSettings *settings;
         GdkGeometry hints = { 1, 1 };
- char *uri;
+ char *uri, *ua;
 
         if(!(c = calloc(1, sizeof(Client))))
                 die("Cannot malloc!\n");
@@ -532,7 +532,9 @@
         gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
         webkit_web_view_set_full_content_zoom(c->view, TRUE);
         settings = webkit_web_view_get_settings(c->view);
- g_object_set(G_OBJECT(settings), "user-agent", useragent, NULL);
+ if(!(ua = getenv("SURF_USERAGENT")))
+ ua = useragent;
+ g_object_set(G_OBJECT(settings), "user-agent", ua, NULL);
         uri = g_strconcat("file://", stylefile, NULL);
         g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
         g_free(uri);
@@ -681,6 +683,8 @@
 void
 setup(void) {
         SoupSession *s;
+ char *proxy;
+ SoupURI *puri;
 
         /* clean up any zombies immediately */
         sigchld(0);
@@ -704,6 +708,11 @@
         cookies = soup_cookie_jar_new();
         soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookies));
         g_signal_connect(cookies, "changed", G_CALLBACK(changecookie), NULL);
+ if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
+ puri = soup_uri_new(proxy);
+ g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL);
+ soup_uri_free(puri);
+ }
         reloadcookies();
 }
 
Received on Mon Nov 02 2009 - 08:27:38 UTC

This archive was generated by hypermail 2.2.0 : Mon Nov 02 2009 - 08:36:38 UTC