use the http_proxy environment variable if it is present
authorgregor herrmann <gregoa@debian.org>
Mon, 12 Jan 2009 17:08:52 +0000 (18:08 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 12 Jan 2009 18:26:48 +0000 (10:26 -0800)
Tweaked by greg k-h a bit to free the memory properly.

bti.c

diff --git a/bti.c b/bti.c
index 9d37103..a06c818 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -336,8 +336,11 @@ static void parse_configfile(struct session *session)
                        session->host = HOST_IDENTICA;
                free(host);
        }
-       if (proxy)
+       if (proxy) {
+               if (session->proxy)
+                       free(session->proxy);
                session->proxy = proxy;
+       }
 
        /* Free buffer and close file.  */
        free(line);
@@ -362,6 +365,7 @@ int main(int argc, char *argv[], char *envp[])
        char *tweet;
        int retval;
        int option;
+       char *http_proxy;
 #if 0
        char *home = getenv("HOME");
        char *pwd = getenv("PWD");
@@ -374,6 +378,17 @@ int main(int argc, char *argv[], char *envp[])
        }
 
        curl_global_init(CURL_GLOBAL_ALL);
+
+       /* Set environment variables first, before reading command line options
+        * or config file values. */
+       http_proxy = getenv("http_proxy");
+       if (http_proxy) {
+               if (session->proxy)
+                       free(session->proxy);
+               session->proxy = strdup(http_proxy);
+               dbg("http_proxy = %s\n", session->proxy);
+       }
+
        parse_configfile(session);
 
        while (1) {