Enlightenment CVS committal

Author  : englebass
Project : e_modules
Module  : weather

Dir     : e_modules/weather


Modified Files:
        e_mod_main.c 


Log Message:
Better check for missing http_proxy env.

===================================================================
RCS file: /cvs/e/e_modules/weather/e_mod_main.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -3 -r1.63 -r1.64
--- e_mod_main.c        18 May 2008 16:24:43 -0000      1.63
+++ e_mod_main.c        13 Aug 2008 05:29:43 -0000      1.64
@@ -57,7 +57,9 @@
 {
    const char *host;
    int port;
-} proxy; 
+} proxy = {
+   NULL, 0
+}; 
 
 /* Module Function Protos */
 static void _weather_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
@@ -442,31 +444,36 @@
 static void
 _weather_get_proxy (void)
 {
-  char env[128];
+  char *env;
 
-  snprintf (env, sizeof (env), "%s", getenv ("http_proxy"));
-  if (!env[0]) snprintf (env, sizeof (env), "%s", getenv ("HTTP_PROXY"));
+  env = getenv ("http_proxy");
+  if ((!env) || (!*env)) env = getenv ("HTTP_PROXY");
+  if ((!env) || (!*env)) return;
   if (strncmp (env, "http://";, 7)) return;
 
   char *host = NULL;
   char *p;
   int port = 0;
 
+  env = strdup(env);
   host = strchr (env, ':');
   host += 3;
   p = strchr (host, ':');
   if (p)
-       {
-         *p = 0;
-         p++;
-         if (sscanf (p, "%d", &port) != 1)
-           port = 0;
-       }
+    {
+      *p = 0;
+      p++;
+      if (sscanf (p, "%d", &port) != 1)
+          port = 0;
+    }
+  // FIXME: A proxy doesn't necessarily need a port
   if ((host) && (port))
-       {
-         proxy.host = evas_stringshare_add (host);
-         proxy.port = port;
-       }
+    {
+      if (proxy.host) evas_stringshare_del(proxy.host);
+      proxy.host = evas_stringshare_add (host);
+      proxy.port = port;
+    }
+  free(env);
 }
 
 static int



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to