On Tue, Jul 24, 2007 at 03:12:22PM -0600, dann frazier wrote:
>hey,
> The following patch adds support for the no_proxy envvar to the wget
>applet. Most of the code is lifted directly from GNU's wget source
>(with a few simplifications).
>
>Originally submitted here:
> http://article.gmane.org/gmane.linux.busybox/20296
>
>The only outstanding feedback I have is the request to use argz if
>available. I certainly don't mind adding this if someone can tell me
>how to properly check for its availability.
>
>fyi, my goal with this patch is to enhance the debian installer to
>allow users who specify a proxy to disable proxy access for certain
>servers. For example, to use an internal mirror while still using the
>proxy to install security updates.

That's what apt-proxy is for, but ok.
See below.
>
>--- busybox-1.6.0/networking/wget.c.orig       2007-06-18 20:09:36.000000000 
>+0100
>+++ busybox-1.6.0/networking/wget.c    2007-06-21 00:36:21.000000000 +0100

Please diff that against svn trunk, just in case.

>@@ -84,6 +84,51 @@
> }
> #endif
> 
>+#if ENABLE_FEATURE_WGET_NOPROXY
>+char *strdupdelim (const char *beg, const char *end);
>+char *strdupdelim (const char *beg, const char *end)

which other applet uses this?
>+{
>+      char *res = xmalloc (end - beg + 1);
>+      memcpy (res, beg, end - beg);
>+      res[end - beg] = '\0';
>+      return res;
>+}
>+
>+/* Parse a string containing comma-separated elements, and return a
>+   vector of char pointers with the elements.  Spaces following the
>+   commas are ignored.  */
>+char **sepstring (const char *s);
>+char **sepstring (const char *s)

which other applet uses this?

>+{
>+      char **res;
>+      const char *p;
>+      int i = 0;
>+
>+      if (!s || !*s)
>+              return NULL;
>+      res = NULL;
>+      p = s;
>+      while (*s) {
>+              if (*s == ',') {
>+                      res = xrealloc (res, (i + 2) * sizeof (char *));
>+                      res[i] = strdupdelim (p, s);
>+                      res[++i] = NULL;
>+                      ++s;
>+                      /* Skip the blanks following the ','.  */
>+                      while (*s == ' ')
>+                              ++s;
skip_whitespace() ?
>+                              p = s;
>+              } else {
>+                      ++s;
>+              }
>+      }
>+      res = xrealloc (res, (i + 2) * sizeof (char *));
>+      res[i] = strdupdelim (p, s);
>+      res[i + 1] = NULL;
>+      return res;
>+}
>+#endif

This _sounds_ a bit bloated but i didn't check if we already have
infrastructure that could and should be reused.

>+
> int wget_main(int argc, char **argv);
> int wget_main(int argc, char **argv)
> {
>@@ -108,6 +153,11 @@
>       bool got_clen = 0;               /* got content-length: from server  */
>       int output_fd = -1;
>       bool use_proxy = 1;              /* Use proxies if env vars are set  */
>+#if ENABLE_FEATURE_WGET_NOPROXY
>+      int i, j;
>+      char *tmp;
>+      char **no_proxy = NULL;
>+#endif
>       const char *proxy_flag = "on";  /* Use proxies if env vars are set  */
>       const char *user_agent = "Wget";/* "User-Agent" header field        */
>       static const char * const keywords[] = {
>@@ -175,6 +225,22 @@
>       server.host = target.host;
>       server.port = target.port;
> 
>+#if ENABLE_FEATURE_WGET_NOPROXY
>+      tmp = getenv ("no_proxy");
>+      if (tmp)
>+              no_proxy = sepstring((const char *)str_tolower(tmp));
>+
>+      for (i = 0; no_proxy && no_proxy[i]; i++){
>+              j = strlen(server.host) - strlen(no_proxy[i]);
>+              if (j < 0)
>+                      continue;
>+              if (!strcmp(str_tolower(server.host + j),
>+                          no_proxy[i])) {
>+                      use_proxy = 0;

can you use the recently added ..._strings stuff?
You'd e.g. memchr for ',' set them to nil. Perhaps this makes the above
to public functions superfluous.


Also, what's the size(1) increase for this new option?

cheers,
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to