It is a lot nicer to getenv() what you need once and makes the code a lot

more readable.
This commit is contained in:
christos 2011-06-25 17:13:34 +00:00
parent ce0ea4e1c5
commit 478d1edef4
1 changed files with 14 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ftp.c,v 1.1.1.11 2010/03/24 20:51:44 joerg Exp $ */ /* $NetBSD: ftp.c,v 1.2 2011/06/25 17:13:34 christos Exp $ */
/*- /*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2008, 2009, 2010 Joerg Sonnenberger <joerg@NetBSD.org> * Copyright (c) 2008, 2009, 2010 Joerg Sonnenberger <joerg@NetBSD.org>
@ -1097,17 +1097,22 @@ static struct url *
ftp_get_proxy(struct url * url, const char *flags) ftp_get_proxy(struct url * url, const char *flags)
{ {
struct url *purl; struct url *purl;
char *p; char *p, *fp, *FP, *hp, *HP;
if (flags != NULL && strchr(flags, 'd') != NULL) if (flags != NULL && strchr(flags, 'd') != NULL)
return (NULL); return NULL;
if (fetch_no_proxy_match(url->host)) if (fetch_no_proxy_match(url->host))
return (NULL); return NULL;
if (((p = getenv("FTP_PROXY")) || (p = getenv("ftp_proxy")) ||
(p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) && FP = getenv("FTP_PROXY");
fp = getenv("ftp_proxy");
HP = getenv("HTTP_PROXY");
hp = getenv("http_proxy");
if (((p = FP) || (p = fp) || (p = HP) || (p = hp))) &&
*p && (purl = fetchParseURL(p)) != NULL) { *p && (purl = fetchParseURL(p)) != NULL) {
if (!*purl->scheme) { if (!*purl->scheme) {
if (getenv("FTP_PROXY") || getenv("ftp_proxy")) if (fp || FP)
strcpy(purl->scheme, SCHEME_FTP); strcpy(purl->scheme, SCHEME_FTP);
else else
strcpy(purl->scheme, SCHEME_HTTP); strcpy(purl->scheme, SCHEME_HTTP);
@ -1116,10 +1121,10 @@ ftp_get_proxy(struct url * url, const char *flags)
purl->port = fetch_default_proxy_port(purl->scheme); purl->port = fetch_default_proxy_port(purl->scheme);
if (strcasecmp(purl->scheme, SCHEME_FTP) == 0 || if (strcasecmp(purl->scheme, SCHEME_FTP) == 0 ||
strcasecmp(purl->scheme, SCHEME_HTTP) == 0) strcasecmp(purl->scheme, SCHEME_HTTP) == 0)
return (purl); return purl;
fetchFreeURL(purl); fetchFreeURL(purl);
} }
return (NULL); return NULL;
} }
/* /*